lecom-modeler 0.45.1 → 0.46.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/lib/index.js CHANGED
@@ -1,8 +1,4 @@
1
- var Kp=Object.defineProperty,qp=Object.defineProperties;var Zp=Object.getOwnPropertyDescriptors;var Hn=Object.getOwnPropertySymbols;var ca=Object.prototype.hasOwnProperty,da=Object.prototype.propertyIsEnumerable;var la=(e,t,o)=>t in e?Kp(e,t,{enumerable:!0,configurable:!0,writable:!0,value:o}):e[t]=o,_=(e,t)=>{for(var o in t||(t={}))ca.call(t,o)&&la(e,o,t[o]);if(Hn)for(var o of Hn(t))da.call(t,o)&&la(e,o,t[o]);return e},w=(e,t)=>qp(e,Zp(t));var gt=(e,t)=>{var o={};for(var n in e)ca.call(e,n)&&t.indexOf(n)<0&&(o[n]=e[n]);if(e!=null&&Hn)for(var n of Hn(e))t.indexOf(n)<0&&da.call(e,n)&&(o[n]=e[n]);return o};var Ri=e=>{if(typeof document=="undefined")return;let t=document.cookie.match(new RegExp(`(?:^|; )${e.replace(/([.$?*|{}()[\]\\/+^])/g,"\\$1")}=([^;]*)`));return t?decodeURIComponent(t[1]):void 0};import{initializeI18n as Jp,Translations as Qp}from"@produto-lecom/lecom-ui";var ua={translations:{general:{layout:{title:"Modeler"}},editor:{toolbar:{delete:"Delete",deleting:"Deleting...",configure_node:"Configure activity",configure_edge:"Configure routing",configure_gateway:"Configure routing",initial_task:"Initial Activity",gateway_limit_reached:"Exclusive gateway cannot have more than 2 outgoing connections",task_limit_reached:"Task cannot have more than 2 outgoing connections",start_event_limit_reached:"Start event can only connect to a single element",gateway_to_gateway_not_allowed:"Gateways cannot connect directly to other gateways",start_event_already_exists:"A start event already exists. Delete the current event to add another",script_to_end_not_allowed:"Script activities cannot connect directly to the end event",loop_to_end_not_allowed:"Loop activities cannot connect directly to the end event",initial_activity_to_end_not_allowed:"Initial activity cannot connect directly to the end event",final_activity_cannot_connect:"Final activity cannot connect to other elements",activity_has_outgoing_connections:"Activity with outgoing connections cannot connect to end event",end_event_cannot_connect_to_initial_activity:"End event cannot connect to an initial activity",initial_activity_cannot_connect_to_start_event:"Initial activity cannot connect to start event",concurrent_initial_and_final_activity:"An activity cannot be connected to both start and end events",start_event_to_service_task_not_allowed:"Start event cannot connect to an automatic activity",service_task_to_end_not_allowed:"Automatic activities cannot connect to the end event",duplicate_connection_not_allowed:"A connection already exists between these elements",connect_node:"Connect element",connecting:"Connecting...",delete_pool_lane_error:"Cannot delete the pool or lane while there are elements inside it.",delete_elements_blocked:"One or more activities cannot be deleted because there are in-progress processes in the Workspace linked to them.",delete_elements_error:"An error occurred. Please try again later."},controls:{zoom:{fit:"Fit zoom",in:"Zoom in",out:"Zoom out",reset:"Reset zoom"},actions:{move_tool:"Select elements",hand_tool:"Navigate the diagram",check:"Check diagram",check_loading:"Validating diagram...",export:{title:"Export diagram",print:"Print",html:"Export as HTML",png:"Export as PNG",feedback:{empty:"Cannot export an empty diagram",error:"Error exporting diagram"}},import_governance:"Import diagram from Governance platform",import_mermaid:"Import Mermaid",import:{title:"Import",xml:"XML",mermaid:"Mermaid",governance:"Governance",feedback:{error:"Could not import the file. Check its content."}},organize:{title:"Align diagram",vertical:"Vertical (top-down)",horizontal:"Horizontal (left-right)",feedback:{pool_lane:"Diagrams with pools or lanes cannot be arranged automatically."}},minimap:{label:"Minimap",open:"Open minimap",close:"Hide minimap"}},history:{undo:"Undo",redo:"Redo"}},modals:{mermaid_import:{title:"Import diagram from Mermaid",description:"Paste the Mermaid text (in the format supported by the modeler) to generate the diagram.",generate:"Generate",cancel:"Cancel",error_empty:"Paste the diagram text before generating.",error_parse:"Could not generate the diagram. Check the pasted text."},delete_elements:{title:"Delete elements",callout:"When deleting, the activity and routing settings will be deleted.",content:"Are you sure you want to delete?",confirm:"Delete",cancel:"Cancel"}},task_menu:{loop_not_allowed_when_connected_to_end:"Cannot create loop on activity connected to end event",script_not_allowed_when_connected_to_end:"Cannot transform to Script activity connected to end event",loop_not_allowed_when_subprocess:"Cannot create loop on subprocess",loop_not_allowed_when_service_task:"Cannot create loop on automatic activity",loop:"Activity with loop"}},validation:{success:{title:"Validation Successful",message:"The diagram was validated successfully with no errors."},errors:{title:"The diagram contains errors",subtitle:"Please review the following:",task_label_length:"Task name exceeds the maximum character limit",multiple_start_event_not_allowed:"Multiple start events are not allowed",task_flows_limit_exceeds:"The number of output connections exceeds the limit of two",duplicate_task_name:"There are multiple activities with the same name",flows_on_end_tasks_not_allowed:"Activities connected to end events cannot have other connections",conditions_flows_limit_exceeds:"Exclusive gateway has too many output connections (maximum of two)",task_label_empty:"One or more activities have no name",activity_name_invalid:"Activity name is invalid",final_activity_has_loop:"Final activities cannot have loops",nested_gateway:"Connecting gateways directly is not allowed",concurrent_initial_and_final_event:"The same activity cannot have both initial and final events",gateway_flow_to_event:"Connecting a gateway to an output event is not allowed",gateway_missing_output_streams:"One or more gateways do not have the correct number of outputs",events_nested:"Connecting events directly is not allowed",event_to_condition:"Connecting an event directly to a gateway is not allowed",script_in_final_activity:"Final activity cannot be a script type",subprocess_not_configured:"The subprocess reference is not properly configured in one or more activities",cannot_validate_subprocess_reference:"Could not validate the subprocess reference in one or more activities",start_event_not_found:"A start event is required",end_event_not_found:"At least one end event is required",service_task_without_rejection_routing:"Automated activity (RPA) without rejection routing configured",service_task_without_automation:"Automated activity (RPA) without a configured robot",service_task_connector_inactive:"Automated activity (RPA) linked to an inactive connector",service_task_integration_suspended:"Automated activity (RPA) linked to a suspended integration",service_task_automation_status_unavailable:"Could not verify the automation (RPA) status",service_task_initial_or_final:"Automated activity (RPA) cannot be an initial, final or concentrator step",service_task_in_loop:"Automated activity (RPA) cannot be in a loop"}},bpmn:{start_event:{variant:{default:"Start event"}},end_event:{variant:{default:"End event"}},annotation:{variant:{default:"Annotation"}},gateway:{menu:{title:"Change gateway type"},variant:{default:"Gateway",exclusive:"Exclusive gateway",parallel:"Parallel gateway",complex:"Complex gateway"}},task:{menu:{title:"Change task type"},variant:{default:"Task",script:"Script task",subprocess:"Subprocess",service_task:"RPA"},attribute:{loop:"Task with loop"},label:{prefix:"Activity"},feedback:{label_empty:{prefix:"Activity name was automatically set to"},label_already_exists:{prefix:"The name",middle:"already exists. The name was changed to"},invalid_first_character:"Activity name must start with a letter or number"}},lane:{variant:{default:"Pool / Lane"}},unsupported:{variant:{default:"Unsupported element"}}},adapter:{governance:{error:{DEFAULT:"Error importing diagram",NO_FILE:"No file selected",EMPTY_FILE:"Empty file",INVALID_FILE:"Invalid file",CONTAIN_NO_CELLS:"No cells found to be imported",ALREADY_INITIALIZED:"Importing from the Governance platform is only allowed in diagrams without elements. To import, delete the current diagram"},success:{default:"The diagram was imported from the Governance platform successfully and without any incompatibility detected.",incompatible_cells:"The diagram was imported from the Governance platform with incompatibilities. To know more details, click on the button below."},report:{columns:{type:"Type",value:"Value",status:"Status"},status:{imported:"Imported",adapted:"Adapted",unsupported:"Unsupported"}},action:{download:"Download report"}}}}};var pa={translations:{general:{layout:{title:"Modeler"}},editor:{toolbar:{delete:"Eliminar",deleting:"Eliminando...",configure_node:"Configurar actividad",configure_edge:"Configurar enrutamiento",configure_gateway:"Configurar enrutamiento",initial_task:"Actividad Inicial",gateway_limit_reached:"Compuerta exclusiva no puede tener m\xE1s de 2 conexiones de salida",task_limit_reached:"Actividad no puede tener m\xE1s de 2 conexiones de salida",start_event_limit_reached:"Evento inicial solo puede conectarse a un \xFAnico elemento",gateway_to_gateway_not_allowed:"Las compuertas no pueden conectarse directamente con otras compuertas",start_event_already_exists:"Ya existe un evento de inicio. Elimine el evento actual para agregar otro",script_to_end_not_allowed:"Las actividades Script no pueden conectarse directamente al evento final",loop_to_end_not_allowed:"Las actividades Loop no pueden conectarse directamente al evento final",initial_activity_to_end_not_allowed:"Actividad inicial no puede conectarse directamente al evento final",final_activity_cannot_connect:"Actividad final no puede conectarse a otros elementos",activity_has_outgoing_connections:"Actividad con conexiones de salida no puede conectarse al evento final",end_event_cannot_connect_to_initial_activity:"El evento final no puede conectarse a una actividad inicial",initial_activity_cannot_connect_to_start_event:"Actividad inicial no puede conectarse a evento de inicio",concurrent_initial_and_final_activity:"Una actividad no puede estar conectada al evento inicial y final al mismo tiempo",start_event_to_service_task_not_allowed:"El evento inicial no puede conectarse a una actividad autom\xE1tica",service_task_to_end_not_allowed:"Las actividades autom\xE1ticas no pueden conectarse al evento final",duplicate_connection_not_allowed:"Ya existe una conexi\xF3n entre estos elementos",connect_node:"Conectar elemento",connecting:"Conectando...",delete_pool_lane_error:"No se puede eliminar la piscina o carril mientras haya elementos dentro.",delete_elements_blocked:"No se pueden eliminar una o m\xE1s actividades porque existen procesos en curso en el Workspace vinculados a ellas.",delete_elements_error:"Ocurri\xF3 un error. Int\xE9ntelo de nuevo m\xE1s tarde."},controls:{zoom:{fit:"Ajustar zoom",in:"Acercar",out:"Alejar",reset:"Restablecer zoom"},actions:{move_tool:"Seleccionar elementos",hand_tool:"Navegar por el diagrama",check:"Validar diagrama",check_loading:"Validando diagrama...",export:{title:"Exportar diagrama",print:"Imprimir",html:"Exportar como HTML",png:"Exportar como PNG",feedback:{empty:"No es posible exportar un diagrama vac\xEDo",error:"Error al exportar diagrama"}},import_governance:"Importar diagrama de la plataforma Governance",import_mermaid:"Importar Mermaid",import:{title:"Importar",xml:"XML",mermaid:"Mermaid",governance:"Governance",feedback:{error:"No fue posible importar el archivo. Verifique el contenido."}},organize:{title:"Alinear diagrama",vertical:"Vertical (de arriba hacia abajo)",horizontal:"Horizontal (de izquierda a derecha)",feedback:{pool_lane:"No es posible ordenar autom\xE1ticamente diagramas con piscinas o carriles."}},minimap:{label:"Minimapa",open:"Abrir minimapa",close:"Ocultar minimapa"}},history:{undo:"Deshacer",redo:"Rehacer"}},modals:{mermaid_import:{title:"Importar diagrama a partir de Mermaid",description:"Pegue el texto Mermaid (en el formato compatible con el modelador) para generar el diagrama.",generate:"Generar",cancel:"Cancelar",error_empty:"Pegue el texto del diagrama antes de generar.",error_parse:"No fue posible generar el diagrama. Verifique el texto pegado."},delete_elements:{title:"Eliminar elementos",callout:"Al eliminar, las configuraciones de actividades y enrutamiento ser\xE1n eliminadas.",content:"\xBFEst\xE1s seguro de querer eliminar?",confirm:"Eliminar",cancel:"Cancelar"}},task_menu:{loop_not_allowed_when_connected_to_end:"No se puede crear bucle en actividad conectada al evento final",script_not_allowed_when_connected_to_end:"No se puede transformar a Script actividad conectada al evento final",loop_not_allowed_when_subprocess:"No se puede crear bucle en subproceso",loop_not_allowed_when_service_task:"No se puede crear bucle en actividad autom\xE1tica",loop:"Actividad con loop"}},validation:{success:{title:"Validaci\xF3n exitosa",message:"El diagrama ha sido validado correctamente sin errores."},errors:{title:"El diagrama contiene errores",subtitle:"Revise lo siguiente:",task_label_length:"El nombre de la actividad excede el l\xEDmite m\xE1ximo de caracteres",multiple_start_event_not_allowed:"No se permite tener m\xE1s de un evento de inicio",task_flows_limit_exceeds:"El n\xFAmero de conexiones de salida supera el l\xEDmite de dos",duplicate_task_name:"Hay varias actividades con el mismo nombre",flows_on_end_tasks_not_allowed:"Las actividades conectadas a eventos finales no pueden tener otras conexiones",conditions_flows_limit_exceeds:"Compuerta exclusiva con exceso de conexiones de salida (m\xE1ximo de dos)",task_label_empty:"El nombre de una o m\xE1s actividades no ha sido completado",activity_name_invalid:"El nombre de la actividad no es v\xE1lido",final_activity_has_loop:"Las actividades finales no pueden tener bucles",nested_gateway:"No se permite conectar compuertas directamente",concurrent_initial_and_final_event:"Una misma actividad no puede tener eventos iniciales y finales",gateway_flow_to_event:"No se permite conectar una compuerta a un evento de salida",gateway_missing_output_streams:"Una o m\xE1s compuertas no tienen el n\xFAmero correcto de salidas",events_nested:"No se permite conectar eventos directamente",event_to_condition:"No se permite conectar un evento directamente a una compuerta",script_in_final_activity:"La actividad final no puede ser de tipo script",subprocess_not_configured:"La referencia al subproceso no est\xE1 configurada correctamente en una o m\xE1s actividades",cannot_validate_subprocess_reference:"No fue posible validar la referencia al subproceso en una o m\xE1s actividades",start_event_not_found:"Es necesario tener un evento de inicio",end_event_not_found:"Es necesario tener al menos un evento final",service_task_without_rejection_routing:"Actividad autom\xE1tica (RPA) sin enrutamiento de rechazo configurado",service_task_without_automation:"Actividad autom\xE1tica (RPA) sin robot configurado",service_task_connector_inactive:"Actividad autom\xE1tica (RPA) vinculada a un conector inactivo",service_task_integration_suspended:"Actividad autom\xE1tica (RPA) vinculada a una integraci\xF3n suspendida",service_task_automation_status_unavailable:"No se pudo verificar el estado de la automatizaci\xF3n (RPA)",service_task_initial_or_final:"La actividad autom\xE1tica (RPA) no puede ser etapa inicial, final o concentradora",service_task_in_loop:"La actividad autom\xE1tica (RPA) no puede estar en un bucle"}},bpmn:{start_event:{variant:{default:"Evento de inicio"}},end_event:{variant:{default:"Evento final"}},annotation:{variant:{default:"Anotaci\xF3n"}},gateway:{menu:{title:"Cambiar tipo de compuerta"},variant:{default:"Compuerta",exclusive:"Compuerta exclusiva",parallel:"Compuerta paralela",complex:"Compuerta compleja"}},task:{menu:{title:"Cambiar tipo de tarea"},variant:{default:"Tarea",script:"Tarea de script",subprocess:"Subproceso",service_task:"RPA"},attribute:{loop:"Tarea con bucle"},label:{prefix:"Actividad"},feedback:{label_empty:{prefix:"El nombre de la actividad se estableci\xF3 autom\xE1ticamente como"},label_already_exists:{prefix:"El nombre",middle:"ya existe. El nombre fue cambiado a"},invalid_first_character:"El nombre de la actividad debe comenzar con una letra o n\xFAmero"}},lane:{variant:{default:"Piscina / Raia"}},unsupported:{variant:{default:"Elemento no soportado"}}},adapter:{governance:{error:{DEFAULT:"Error al importar diagrama",NO_FILE:"No se ha seleccionado ning\xFAn archivo",EMPTY_FILE:"Archivo vac\xEDo",INVALID_FILE:"Archivo inv\xE1lido",CONTAIN_NO_CELLS:"No se encontraron c\xE9lulas para importar",ALREADY_INITIALIZED:"La importaci\xF3n de la plataforma Governance solo se permite en diagramas sin elementos. Para importar, elimine el diagrama actual"},success:{default:"El diagrama se ha importado de la plataforma Governance correctamente y sin ninguna incompatibilidad detectada.",incompatible_cells:"El diagrama se ha importado de la plataforma Governance con incompatibilidades. Para saber m\xE1s detalles, haz click en el bot\xF3n de abajo."},report:{columns:{type:"Tipo",value:"Valor",status:"Estado"},status:{imported:"Importado",adapted:"Adaptado",unsupported:"No soportado"}},action:{download:"Descargar informe"}}}}};var fa={translations:{general:{layout:{title:"Modeler"}},editor:{toolbar:{delete:"Excluir",deleting:"Excluindo...",configure_node:"Configurar atividade",configure_edge:"Configurar roteamento",configure_gateway:"Configurar roteamento",initial_task:"Atividade Inicial",gateway_limit_reached:"Gateway exclusivo n\xE3o pode ter mais de 2 conex\xF5es de sa\xEDda",task_limit_reached:"Atividade n\xE3o pode ter mais de 2 conex\xF5es de sa\xEDda",start_event_limit_reached:"Evento inicial s\xF3 pode se conectar a um \xFAnico elemento",gateway_to_gateway_not_allowed:"Gateways n\xE3o podem se conectar diretamente com outros gateways",start_event_already_exists:"J\xE1 existe um evento de in\xEDcio. Exclua o evento atual para adicionar outro",script_to_end_not_allowed:"Atividades Script n\xE3o podem se conectar diretamente ao evento final",loop_to_end_not_allowed:"Atividades Loop n\xE3o podem se conectar diretamente ao evento final",initial_activity_to_end_not_allowed:"Atividade inicial n\xE3o pode se conectar diretamente ao evento final",final_activity_cannot_connect:"Atividade final n\xE3o pode se conectar a outros elementos",activity_has_outgoing_connections:"Atividade com conex\xF5es de sa\xEDda n\xE3o pode se conectar a um evento final",end_event_cannot_connect_to_initial_activity:"O evento final n\xE3o pode ser conectado a uma atividade inicial",initial_activity_cannot_connect_to_start_event:"Atividade inicial n\xE3o pode se conectar a evento de in\xEDcio",concurrent_initial_and_final_activity:"Uma atividade n\xE3o pode estar conectada ao evento inicial e final ao mesmo tempo",duplicate_connection_not_allowed:"J\xE1 existe uma conex\xE3o entre esses elementos",start_event_to_subprocess_not_allowed:"Evento inicial n\xE3o pode se conectar a um subprocesso",start_event_to_service_task_not_allowed:"Evento inicial n\xE3o pode se conectar a uma atividade autom\xE1tica",service_task_to_end_not_allowed:"Atividades autom\xE1ticas n\xE3o podem se conectar ao evento final",connect_node:"Conectar elemento",connecting:"Conectando...",delete_pool_lane_error:"N\xE3o \xE9 poss\xEDvel excluir a piscina ou raia enquanto houver elementos dentro dela.",delete_elements_blocked:"Uma ou mais atividades n\xE3o podem ser exclu\xEDdas porque existem processos em andamento no Workspace vinculados a elas.",delete_elements_error:"Ocorreu um erro. Tente novamente mais tarde."},controls:{zoom:{fit:"Ajustar o zoom",in:"Aumentar o zoom",out:"Diminuir o zoom",reset:"Resetar o zoom"},actions:{move_tool:"Selecionar elementos",hand_tool:"Navegar pelo diagrama",check:"Validar diagrama",check_loading:"Validando diagrama...",export:{title:"Exportar diagrama",print:"Imprimir",html:"Exportar como HTML",png:"Exportar como PNG",feedback:{empty:"N\xE3o \xE9 poss\xEDvel exportar um diagrama vazio",error:"Erro ao exportar o diagrama"}},import_governance:"Importar diagrama da plataforma Governance",import_mermaid:"Importar Mermaid",import:{title:"Importar",xml:"XML",mermaid:"Mermaid",governance:"Governance",feedback:{error:"N\xE3o foi poss\xEDvel importar o arquivo. Verifique o conte\xFAdo."}},organize:{title:"Alinhar diagrama",vertical:"Vertical (de cima para baixo)",horizontal:"Horizontal (da esquerda para a direita)",feedback:{pool_lane:"N\xE3o \xE9 poss\xEDvel ordenar automaticamente diagramas com piscinas ou raias."}},minimap:{label:"Minimapa",open:"Abrir minimapa",close:"Ocultar minimapa"}},history:{undo:"Desfazer",redo:"Refazer"}},modals:{mermaid_import:{title:"Importar diagrama a partir de Mermaid",description:"Cole o texto Mermaid (no formato suportado pelo modelador) para gerar o diagrama.",generate:"Gerar",cancel:"Cancelar",error_empty:"Cole o texto do diagrama antes de gerar.",error_parse:"N\xE3o foi poss\xEDvel gerar o diagrama. Verifique o texto colado."},delete_elements:{title:"Excluir elementos",callout:"Ao excluir, as configura\xE7\xF5es de atividades e roteamento ser\xE3o exclu\xEDdas.",content:"Deseja realmente excluir?",confirm:"Excluir",cancel:"Cancelar"}},task_menu:{loop_not_allowed_when_connected_to_end:"N\xE3o \xE9 poss\xEDvel criar loop em atividade conectada ao evento final",script_not_allowed_when_connected_to_end:"N\xE3o \xE9 poss\xEDvel transformar em Script atividade conectada ao evento final",loop_not_allowed_when_subprocess:"N\xE3o \xE9 poss\xEDvel criar loop em subprocesso",loop_not_allowed_when_service_task:"N\xE3o \xE9 poss\xEDvel criar loop em atividade autom\xE1tica",loop:"Atividade com loop"}},validation:{success:{title:"Diagrama validado com sucesso!",message:"Nenhum erro encontrado."},errors:{title:"O diagrama cont\xE9m erros",subtitle:"Veja abaixo o que precisa ser corrigido:",task_label_length:"O nome da atividade excede o limite m\xE1ximo de caracteres",multiple_start_event_not_allowed:"N\xE3o \xE9 permitido ter mais de um evento de in\xEDcio",task_flows_limit_exceeds:"O n\xFAmero de conex\xF5es de sa\xEDda ultrapassa o limite de dois",duplicate_task_name:"H\xE1 v\xE1rias atividades com o mesmo nome",flows_on_end_tasks_not_allowed:"Atividades conectadas a eventos finais n\xE3o podem ter outras conex\xF5es",conditions_flows_limit_exceeds:"Gateway exclusivo com excesso de conex\xF5es de sa\xEDda (m\xE1ximo de dois)",task_label_empty:"O nome de uma ou mais atividades n\xE3o foi preenchido",activity_name_invalid:"O nome da atividade n\xE3o \xE9 v\xE1lido",final_activity_has_loop:"Atividades finais n\xE3o podem ter loops",nested_gateway:"N\xE3o \xE9 permitido conectar gateways",concurrent_initial_and_final_event:"Uma mesma atividade n\xE3o pode ter eventos iniciais e finais",gateway_flow_to_event:"N\xE3o \xE9 permitido conectar um gateway a um evento de sa\xEDda",gateway_missing_output_streams:"Um ou mais gateways n\xE3o possuem o n\xFAmero correto de sa\xEDdas",events_nested:"N\xE3o \xE9 permitido conectar eventos",event_to_condition:"N\xE3o \xE9 permitido conectar um evento diretamente em um gateway",script_in_final_activity:"Atividade final n\xE3o pode ser do tipo script",subprocess_not_configured:"A refer\xEAncia ao subprocesso n\xE3o est\xE1 configurada corretamente em uma ou mais atividades",cannot_validate_subprocess_reference:"N\xE3o foi poss\xEDvel validar a refer\xEAncia ao subprocesso em uma ou mais atividades",start_event_not_found:"\xC9 necess\xE1rio ter um evento inicial",end_event_not_found:"\xC9 necess\xE1rio ter ao menos um evento final",service_task_without_rejection_routing:"Atividade autom\xE1tica (RPA) sem roteamento de rejei\xE7\xE3o configurado",service_task_without_automation:"Atividade autom\xE1tica (RPA) sem rob\xF4 configurado",service_task_connector_inactive:"Atividade autom\xE1tica (RPA) vinculada a um conector inativo",service_task_integration_suspended:"Atividade autom\xE1tica (RPA) vinculada a uma integra\xE7\xE3o suspensa",service_task_automation_status_unavailable:"N\xE3o foi poss\xEDvel verificar o status da automa\xE7\xE3o (RPA)",service_task_initial_or_final:"Atividade autom\xE1tica (RPA) n\xE3o pode ser etapa inicial, final ou concentradora",service_task_in_loop:"Atividade autom\xE1tica (RPA) n\xE3o pode estar em loop"}},bpmn:{start_event:{variant:{default:"Evento inicial"}},end_event:{variant:{default:"Evento final"}},annotation:{variant:{default:"Anota\xE7\xE3o"}},gateway:{menu:{title:"Alterar tipo de gateway"},variant:{default:"Gateway",exclusive:"Gateway exclusivo",parallel:"Gateway paralelo",complex:"Gateway complexo"}},task:{menu:{title:"Alterar tipo de atividade"},variant:{default:"Atividade",script:"Atividade de script",subprocess:"Subprocesso",service_task:"RPA"},attribute:{loop:"Atividade com loop"},label:{prefix:"Atividade"},feedback:{label_empty:{prefix:"O nome da atividade foi definido automaticamente como"},label_already_exists:{prefix:"O nome",middle:"j\xE1 existe. O nome foi alterado para"},invalid_first_character:"O nome da atividade deve come\xE7ar com uma letra ou n\xFAmero"}},lane:{variant:{default:"Piscina / Raia"}},unsupported:{variant:{default:"Elemento n\xE3o suportado"}}},adapter:{governance:{error:{DEFAULT:"Erro ao importar diagrama",NO_FILE:"Nenhum arquivo selecionado",EMPTY_FILE:"Arquivo vazio",INVALID_FILE:"Arquivo inv\xE1lido",CONTAIN_NO_CELLS:"N\xE3o foram encontradas c\xE9lulas para serem importadas",ALREADY_INITIALIZED:"A importa\xE7\xE3o da plataforma Governance s\xF3 \xE9 permitida em diagramas sem elementos. Para importar, apague o diagrama atual"},success:{default:"O diagrama foi importado da plataforma Governance com sucesso e sem nenhuma incompatibilidade detectada.",incompatible_cells:"O diagrama foi importado da plataforma Governance com incompatibilidades. Para saber mais detalhes, clique no bot\xE3o abaixo."},report:{columns:{type:"Tipo do elemento",value:"Valor",status:"Status"},status:{imported:"Importado",adapted:"Adaptado",unsupported:"N\xE3o suportado"}},action:{download:"Baixar relat\xF3rio"}}}}};var ma={pt_BR:fa,en_US:ua,es_ES:pa};var ga,ha,jp=(ha=(ga=Ri("LecomUserLanguage"))!=null?ga:Ri("org.springframework.web.servlet.i18n.CookieLocaleResolver.LOCALE"))!=null?ha:Qp.PT_BR;Jp({lng:jp,resources:ma});var ve=(n=>(n.EDIT="edit",n.VIEW="view",n.READONLY="readonly",n))(ve||{});var Gn=(i=>(i.ACTIVITY="activity",i.ROUTING="routing",i.GATEWAY="gateway",i.SUB_PROCESS="sub_process",i.SERVICE_TASK="service_task",i))(Gn||{}),Di=(n=>(n.START="start",n.END="end",n.BETWEEN="between",n))(Di||{}),Oi=(n=>(n.SCRIPT="script",n.LOOP="loop",n.SCRIPT_LOOP="script_loop",n))(Oi||{}),Vi=(u=>(u.SIMPLE="simple",u.LOOP="loop",u.SCRIPT="script",u.SCRIPT_LOOP="script_loop",u.COMPLEX="complex",u.EXCLUSIVE="exclusive",u.PARALLEL="parallel",u.FINAL="final",u.TO_SUB_PROCESS="to_sub_process",u.FROM_SUB_PROCESS="from_sub_process",u.FROM_SERVICE_TASK="from_service_task",u))(Vi||{});import{Bot as pf,RotateCcw as ff,ScrollText as mf,SquarePlus as gf}from"lucide-react";import{jsx as Bn,jsxs as ef}from"react/jsx-runtime";var zn=({size:e=24,className:t})=>ef("svg",{width:e,height:e,viewBox:"0 0 24 24",xmlns:"http://www.w3.org/2000/svg",fill:"currentColor",className:t,children:[Bn("path",{strokeWidth:"2",d:"M16 3V3.5085V11.9998V20.4915V21H16.5411H21.4592H22V19.123H21.4592H17.9974V11.9998V4.8773H21.4592H22V3H21.4592H16.5411H16Z"}),Bn("path",{d:"M4.41026 16.9999L2 18.7861L3.89693 21.1103L6.3072 19.324L4.41026 16.9999Z"}),Bn("path",{d:"M8.41026 13.9999L6 15.7861L7.89693 18.1103L10.3072 16.324L8.41026 13.9999Z"}),Bn("path",{d:"M12.4313 10.954L10.021 12.7402L11.9179 15.0644L14.3282 13.2781L12.4313 10.954Z"})]});import{jsx as ya}from"react/jsx-runtime";var _o=({size:e=24,className:t})=>ya("svg",{width:e,height:e,viewBox:"0 0 24 24",xmlns:"http://www.w3.org/2000/svg",fill:"#ff6565",stroke:"#ec1616",strokeWidth:3,className:t,children:ya("path",{d:"M12 22C17.5228 22 22 17.5228 22 12C22 6.47715 17.5228 2 12 2C6.47715 2 2 6.47715 2 12C2 17.5228 6.47715 22 12 22Z",strokeLinecap:"round",strokeLinejoin:"round"})});import{jsx as Zo,jsxs as tf}from"react/jsx-runtime";var bo=({size:e=24,className:t})=>tf("svg",{width:e,height:e,viewBox:"0 0 24 24",xmlns:"http://www.w3.org/2000/svg",fill:"white",stroke:"currentColor",strokeWidth:2,className:t,children:[Zo("path",{d:"M2.69991 10.2997C2.47586 10.5235 2.29812 10.7893 2.17685 11.0818C2.05558 11.3744 1.99316 11.688 1.99316 12.0047C1.99316 12.3214 2.05558 12.635 2.17685 12.9275C2.29812 13.2201 2.47586 13.4859 2.69991 13.7097L10.2899 21.2997C10.5137 21.5237 10.7795 21.7015 11.0721 21.8227C11.3646 21.944 11.6782 22.0064 11.9949 22.0064C12.3116 22.0064 12.6252 21.944 12.9177 21.8227C13.2103 21.7015 13.4761 21.5237 13.6999 21.2997L21.2899 13.7097C21.514 13.4859 21.6917 13.2201 21.813 12.9275C21.9342 12.635 21.9967 12.3214 21.9967 12.0047C21.9967 11.688 21.9342 11.3744 21.813 11.0818C21.6917 10.7893 21.514 10.5235 21.2899 10.2997L13.6999 2.70968C13.4761 2.48562 13.2103 2.30788 12.9177 2.18662C12.6252 2.06535 12.3116 2.00293 11.9949 2.00293C11.6782 2.00293 11.3646 2.06535 11.0721 2.18662C10.7795 2.30788 10.5137 2.48562 10.2899 2.70968L2.69991 10.2997Z",strokeLinecap:"round",strokeLinejoin:"round"}),Zo("path",{d:"M12 8V16",strokeLinecap:"round",strokeLinejoin:"round"}),Zo("path",{d:"M8 12H16",strokeLinecap:"round",strokeLinejoin:"round"}),Zo("path",{d:"M9.17139 9.17188L14.8282 14.8287",strokeLinecap:"round",strokeLinejoin:"round"}),Zo("path",{d:"M14.8281 9.17188L9.17127 14.8287",strokeLinecap:"round",strokeLinejoin:"round"})]});import{jsx as Hi,jsxs as of}from"react/jsx-runtime";var To=({size:e=24,className:t})=>of("svg",{width:e,height:e,viewBox:"0 0 24 24",xmlns:"http://www.w3.org/2000/svg",fill:"white",stroke:"currentColor",strokeWidth:2,className:t,children:[Hi("path",{d:"M2.69991 10.2997C2.47586 10.5235 2.29812 10.7893 2.17685 11.0818C2.05558 11.3744 1.99316 11.688 1.99316 12.0047C1.99316 12.3214 2.05558 12.635 2.17685 12.9275C2.29812 13.2201 2.47586 13.4859 2.69991 13.7097L10.2899 21.2997C10.5137 21.5237 10.7795 21.7015 11.0721 21.8227C11.3646 21.944 11.6782 22.0064 11.9949 22.0064C12.3116 22.0064 12.6252 21.944 12.9177 21.8227C13.2103 21.7015 13.4761 21.5237 13.6999 21.2997L21.2899 13.7097C21.514 13.4859 21.6917 13.2201 21.813 12.9275C21.9342 12.635 21.9967 12.3214 21.9967 12.0047C21.9967 11.688 21.9342 11.3744 21.813 11.0818C21.6917 10.7893 21.514 10.5235 21.2899 10.2997L13.6999 2.70968C13.4761 2.48562 13.2103 2.30788 12.9177 2.18662C12.6252 2.06535 12.3116 2.00293 11.9949 2.00293C11.6782 2.00293 11.3646 2.06535 11.0721 2.18662C10.7795 2.30788 10.5137 2.48562 10.2899 2.70968L2.69991 10.2997Z",strokeLinecap:"round",strokeLinejoin:"round"}),Hi("path",{d:"M14.8286 9.17188L9.17176 14.8287",strokeLinecap:"round",strokeLinejoin:"round"}),Hi("path",{d:"M9.17139 9.17188L14.8282 14.8287",strokeLinecap:"round",strokeLinejoin:"round"})]});import{jsx as Gi,jsxs as nf}from"react/jsx-runtime";var vo=({size:e=24,className:t})=>nf("svg",{width:e,height:e,viewBox:"0 0 24 24",xmlns:"http://www.w3.org/2000/svg",fill:"white",stroke:"currentColor",strokeWidth:2,className:t,children:[Gi("path",{d:"M2.69991 10.2997C2.47586 10.5235 2.29812 10.7893 2.17685 11.0818C2.05558 11.3744 1.99316 11.688 1.99316 12.0047C1.99316 12.3214 2.05558 12.635 2.17685 12.9275C2.29812 13.2201 2.47586 13.4859 2.69991 13.7097L10.2899 21.2997C10.5137 21.5237 10.7795 21.7015 11.0721 21.8227C11.3646 21.944 11.6782 22.0064 11.9949 22.0064C12.3116 22.0064 12.6252 21.944 12.9177 21.8227C13.2103 21.7015 13.4761 21.5237 13.6999 21.2997L21.2899 13.7097C21.514 13.4859 21.6917 13.2201 21.813 12.9275C21.9342 12.635 21.9967 12.3214 21.9967 12.0047C21.9967 11.688 21.9342 11.3744 21.813 11.0818C21.6917 10.7893 21.514 10.5235 21.2899 10.2997L13.6999 2.70968C13.4761 2.48562 13.2103 2.30788 12.9177 2.18662C12.6252 2.06535 12.3116 2.00293 11.9949 2.00293C11.6782 2.00293 11.3646 2.06535 11.0721 2.18662C10.7795 2.30788 10.5137 2.48562 10.2899 2.70968L2.69991 10.2997Z",strokeLinecap:"round",strokeLinejoin:"round"}),Gi("path",{d:"M12 8V16",strokeLinecap:"round",strokeLinejoin:"round"}),Gi("path",{d:"M8 12H16",strokeLinecap:"round",strokeLinejoin:"round"})]});import{jsx as Bi,jsxs as rf}from"react/jsx-runtime";var xa=({size:e=24,className:t})=>Bi("svg",{width:e,height:e,viewBox:"0 0 34 24",xmlns:"http://www.w3.org/2000/svg",fill:"currentColor",className:t,children:rf("g",{children:[Bi("path",{d:"M8.6543 11.4141V15.2148C8.51302 15.4017 8.29199 15.6068 7.99121 15.8301C7.69499 16.0488 7.30078 16.238 6.80859 16.3975C6.31641 16.557 5.70345 16.6367 4.96973 16.6367C4.34538 16.6367 3.77344 16.5319 3.25391 16.3223C2.73438 16.1081 2.28548 15.7959 1.90723 15.3857C1.53353 14.9756 1.24414 14.4766 1.03906 13.8887C0.833984 13.2962 0.731445 12.6217 0.731445 11.8652V11.1748C0.731445 10.4229 0.82487 9.75293 1.01172 9.16504C1.20312 8.57259 1.47656 8.07129 1.83203 7.66113C2.1875 7.25098 2.61589 6.94108 3.11719 6.73145C3.62305 6.51725 4.19499 6.41016 4.83301 6.41016C5.64876 6.41016 6.32324 6.54688 6.85645 6.82031C7.39421 7.08919 7.80892 7.46289 8.10059 7.94141C8.39225 8.41992 8.57682 8.9668 8.6543 9.58203H6.97266C6.91797 9.23568 6.81087 8.92578 6.65137 8.65234C6.49642 8.37891 6.27311 8.16471 5.98145 8.00977C5.69434 7.85026 5.32064 7.77051 4.86035 7.77051C4.46387 7.77051 4.11523 7.8457 3.81445 7.99609C3.51367 8.14648 3.26302 8.36751 3.0625 8.65918C2.86654 8.95085 2.71842 9.30632 2.61816 9.72559C2.5179 10.1449 2.46777 10.6234 2.46777 11.1611V11.8652C2.46777 12.4121 2.52474 12.8975 2.63867 13.3213C2.75716 13.7451 2.92578 14.1029 3.14453 14.3945C3.36784 14.6862 3.639 14.9072 3.95801 15.0576C4.27702 15.2035 4.63704 15.2764 5.03809 15.2764C5.43001 15.2764 5.7513 15.2445 6.00195 15.1807C6.2526 15.1123 6.45085 15.0326 6.59668 14.9414C6.74707 14.8457 6.86328 14.7546 6.94531 14.668V12.6924H4.87402V11.4141H8.6543ZM17.0912 11.25V11.7969C17.0912 12.5488 16.9932 13.2233 16.7973 13.8203C16.6013 14.4173 16.321 14.9255 15.9564 15.3447C15.5964 15.764 15.1635 16.0853 14.6576 16.3086C14.1518 16.5273 13.5912 16.6367 12.976 16.6367C12.3653 16.6367 11.807 16.5273 11.3012 16.3086C10.7999 16.0853 10.3646 15.764 9.99551 15.3447C9.62637 14.9255 9.33926 14.4173 9.13418 13.8203C8.93366 13.2233 8.8334 12.5488 8.8334 11.7969V11.25C8.8334 10.498 8.93366 9.82585 9.13418 9.2334C9.3347 8.63639 9.61725 8.12826 9.98184 7.70898C10.351 7.28516 10.7862 6.96387 11.2875 6.74512C11.7934 6.52181 12.3516 6.41016 12.9623 6.41016C13.5775 6.41016 14.1381 6.52181 14.6439 6.74512C15.1498 6.96387 15.585 7.28516 15.9496 7.70898C16.3142 8.12826 16.5945 8.63639 16.7904 9.2334C16.991 9.82585 17.0912 10.498 17.0912 11.25ZM15.3754 11.7969V11.2363C15.3754 10.6803 15.3207 10.1904 15.2113 9.7666C15.1065 9.33822 14.9493 8.98047 14.7396 8.69336C14.5346 8.40169 14.2816 8.18294 13.9809 8.03711C13.6801 7.88672 13.3406 7.81152 12.9623 7.81152C12.584 7.81152 12.2468 7.88672 11.9506 8.03711C11.6544 8.18294 11.4014 8.40169 11.1918 8.69336C10.9867 8.98047 10.8295 9.33822 10.7201 9.7666C10.6107 10.1904 10.5561 10.6803 10.5561 11.2363V11.7969C10.5561 12.3529 10.6107 12.8451 10.7201 13.2734C10.8295 13.7018 10.989 14.0641 11.1986 14.3604C11.4128 14.652 11.668 14.873 11.9643 15.0234C12.2605 15.1693 12.5977 15.2422 12.976 15.2422C13.3588 15.2422 13.6983 15.1693 13.9945 15.0234C14.2908 14.873 14.5414 14.652 14.7465 14.3604C14.9516 14.0641 15.1065 13.7018 15.2113 13.2734C15.3207 12.8451 15.3754 12.3529 15.3754 11.7969ZM20.6678 14.6816L23.2859 6.54688H25.1795L21.6111 16.5H20.3328L20.6678 14.6816ZM18.2479 6.54688L20.8455 14.6816L21.201 16.5H19.9158L16.3611 6.54688H18.2479Z"}),Bi("path",{d:"M24.5 4.5L28 1M28 1L31.5 4.5M28 1V8",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round"})]})});import{clsx as sf}from"clsx";import{twMerge as af}from"tailwind-merge";function G(...e){return af(sf(e))}var Rt=(e=0,t=0)=>e<t?t:e,Yn=(e=1e3)=>new Promise(t=>{setTimeout(t,e)});import{jsx as Ea,jsxs as lf}from"react/jsx-runtime";var _a=({size:e=24,className:t})=>lf("svg",{width:e,height:e,viewBox:"0 0 24 24",fill:"none",stroke:"#6b7280",strokeWidth:2,xmlns:"http://www.w3.org/2000/svg",className:G("stroke-2",t),children:[Ea("path",{d:"M19 3H5C3.89543 3 3 3.89543 3 5V19C3 20.1046 3.89543 21 5 21H19C20.1046 21 21 20.1046 21 19V5C21 3.89543 20.1046 3 19 3Z",strokeLinecap:"round",strokeLinejoin:"round"}),Ea("path",{d:"M9 3V21",strokeLinecap:"round",strokeLinejoin:"round"})]});import{jsx as zi}from"react/jsx-runtime";var ba=({size:e=24,className:t})=>zi("svg",{width:e,height:e,viewBox:"0 0 24 24",xmlns:"http://www.w3.org/2000/svg",stroke:"currentColor",className:t,children:zi("g",{children:zi("path",{d:"M4.85372 6.17472L5.31292 5.71552L5.31993 5.70863C6.88908 4.1924 8.98352 3.34122 11.1655 3.33301L11.1668 3.33301C11.167 3.33301 11.1673 3.33301 11.1675 3.33301C12.7165 3.33314 14.2308 3.79255 15.5188 4.65317C16.807 5.5139 17.811 6.7373 18.4039 8.16866C18.9968 9.60001 19.1519 11.175 18.8497 12.6945C18.5986 13.9567 18.0414 15.1334 17.232 16.1236L16.9457 16.4738L17.2655 16.7936L20.6617 20.1899L20.6617 20.1899C20.7919 20.3201 20.7919 20.5311 20.6617 20.6612L20.6616 20.6613C20.5316 20.7915 20.3205 20.7915 20.1903 20.6613L16.7941 17.265L16.4743 16.9452L16.1241 17.2315C15.1339 18.0409 13.9571 18.5981 12.695 18.8492C11.1755 19.1514 9.6005 18.9963 8.16915 18.4034C6.73778 17.8105 5.51439 16.8065 4.65365 15.5183C3.79291 14.2301 3.3335 12.7156 3.3335 11.1663C3.3335 10.9822 3.48273 10.833 3.66683 10.833C3.85093 10.833 4.00016 10.9822 4.00016 11.1663C4.00016 12.5838 4.42048 13.9694 5.20796 15.148C5.99545 16.3265 7.11474 17.245 8.42426 17.7874C9.73378 18.3299 11.1748 18.4719 12.565 18.1953C13.9552 17.9188 15.2321 17.2362 16.2344 16.234L16.2345 16.234C17.2367 15.2316 17.9193 13.9547 18.1958 12.5645C18.4724 11.1743 18.3304 9.7333 17.7879 8.42378C17.2455 7.11426 16.327 5.99497 15.1484 5.20748L14.8707 5.62322L15.1484 5.20748C13.9703 4.42031 12.5854 4.00001 11.1685 3.99968L11.1664 3.99969C9.15876 4.00767 7.23176 4.7903 5.78712 6.18424L5.78706 6.18418L5.78075 6.1905L5.32512 6.64613L4.47156 7.49968H5.67867H7.8335C8.01759 7.49968 8.16683 7.64892 8.16683 7.83302C8.16683 8.01711 8.01759 8.16635 7.8335 8.16635H3.66683C3.48274 8.16635 3.3335 8.01711 3.3335 7.83302V3.66635C3.3335 3.48225 3.48274 3.33302 3.66683 3.33302C3.85092 3.33302 4.00016 3.48225 4.00016 3.66635V5.82117V7.02827L4.85372 6.17472Z"})})});import{jsx as Ta}from"react/jsx-runtime";var Fn=({size:e=24,className:t})=>Ta("svg",{width:e,height:e,viewBox:"0 0 24 24",xmlns:"http://www.w3.org/2000/svg",fill:"#5fd9b0",stroke:"#1cad86",strokeWidth:"2",className:t,children:Ta("path",{d:"M12 22C17.5228 22 22 17.5228 22 12C22 6.47715 17.5228 2 12 2C6.47715 2 2 6.47715 2 12C2 17.5228 6.47715 22 12 22Z",strokeLinecap:"round",strokeLinejoin:"round"})});import{jsx as va}from"react/jsx-runtime";var Jo=({size:e=24,className:t})=>va("svg",{width:e,height:e,viewBox:"0 0 24 24",xmlns:"http://www.w3.org/2000/svg",fill:"white",stroke:"currentColor",className:G("stroke-2",t),children:va("path",{d:"M20 3H4C2.89543 3 2 4.34315 2 6V18C2 19.6569 2.89543 21 4 21H20C21.1046 21 22 19.6569 22 18V6C22 4.34315 21.1046 3 20 3Z",strokeLinecap:"round",strokeLinejoin:"round"})});import{jsx as Yi,jsxs as cf}from"react/jsx-runtime";var Na=({size:e=24,className:t})=>cf("svg",{width:e,height:e,viewBox:"0 0 24 24",xmlns:"http://www.w3.org/2000/svg",fill:"white",stroke:"#6b7280",strokeWidth:"2",className:t,children:[Yi("path",{d:"M20 3H4C2.89543 3 2 4.34315 2 6V18C2 19.6569 2.89543 21 4 21H20C21.1046 21 22 19.6569 22 18V6C22 4.34315 21.1046 3 20 3Z",strokeLinecap:"round",strokeLinejoin:"round"}),Yi("path",{d:"M7.5 12C7.5 12.89 7.76392 13.76 8.25839 14.5001C8.75285 15.2401 9.45566 15.8169 10.2779 16.1575C11.1002 16.4981 12.005 16.5872 12.8779 16.4135C13.7508 16.2399 14.5526 15.8113 15.182 15.182C15.8113 14.5526 16.2399 13.7508 16.4135 12.8779C16.5872 12.005 16.4981 11.1002 16.1575 10.2779C15.8169 9.45566 15.2401 8.75285 14.5001 8.25839C13.76 7.76392 12.89 7.5 12 7.5C10.742 7.50473 9.53448 7.99561 8.63 8.87L7.5 10",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round"}),Yi("path",{d:"M7.5 7.5V10H10",strokeWidth:"1.5",fill:"none",strokeLinecap:"round",strokeLinejoin:"round"})]});import{jsx as Qo,jsxs as df}from"react/jsx-runtime";var wa=({size:e=24,className:t})=>df("svg",{width:e,height:e,viewBox:"0 0 24 24",xmlns:"http://www.w3.org/2000/svg",fill:"white",stroke:"#6b7280",strokeWidth:"2",className:t,children:[Qo("path",{d:"M20 3H4C2.89543 3 2 4.34315 2 6V18C2 19.6569 2.89543 21 4 21H20C21.1046 21 22 19.6569 22 18V6C22 4.34315 21.1046 3 20 3Z",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"}),Qo("path",{d:"M15.5 14.5V8.5C15.5 8.23478 15.3946 7.98043 15.2071 7.79289C15.0196 7.60536 14.7652 7.5 14.5 7.5H8",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round"}),Qo("path",{d:"M10 16.5H16C16.2652 16.5 16.5196 16.3946 16.7071 16.2071C16.8946 16.0196 17 15.7652 17 15.5V15C17 14.8674 16.9473 14.7402 16.8536 14.6464C16.7598 14.5527 16.6326 14.5 16.5 14.5H11.5C11.3674 14.5 11.2402 14.5527 11.1464 14.6464C11.0527 14.7402 11 14.8674 11 15V15.5C11 15.7652 10.8946 16.0196 10.7071 16.2071C10.5196 16.3946 10.2652 16.5 10 16.5ZM10 16.5C9.73478 16.5 9.48043 16.3946 9.29289 16.2071C9.10536 16.0196 9 15.7652 9 15.5V8.5C9 8.23478 8.89464 7.98043 8.70711 7.79289C8.51957 7.60536 8.26522 7.5 8 7.5C7.73478 7.5 7.48043 7.60536 7.29289 7.79289C7.10536 7.98043 7 8.23478 7 8.5V9.5C7 9.63261 7.05268 9.75979 7.14645 9.85355C7.24021 9.94732 7.36739 10 7.5 10H9",strokeWidth:"1",strokeLinecap:"round",strokeLinejoin:"round"}),Qo("path",{d:"M13.5 12H11",strokeWidth:"1",strokeLinecap:"round",strokeLinejoin:"round"}),Qo("path",{d:"M13.5 10H11",strokeWidth:"1",strokeLinecap:"round",strokeLinejoin:"round"})]});import{jsx as Wn,jsxs as uf}from"react/jsx-runtime";var jo=({size:e=24,className:t})=>uf("svg",{width:e,height:e,viewBox:"0 0 24 24",xmlns:"http://www.w3.org/2000/svg",fill:"white",stroke:"currentColor",strokeWidth:2,className:t,children:[Wn("path",{d:"M20 3H4C2.89543 3 2 4.34315 2 6V18C2 19.6569 2.89543 21 4 21H20C21.1046 21 22 19.6569 22 18V6C22 4.34315 21.1046 3 20 3Z",strokeLinecap:"round",strokeLinejoin:"round"}),Wn("path",{d:"M8 21V14C8 13.4477 8.44772 13 9 13H15C15.5523 13 16 13.4477 16 14V21",strokeWidth:"1",fill:"none"}),Wn("path",{d:"M10.2222 17H13.7777",strokeWidth:"1",strokeLinecap:"round",strokeLinejoin:"round"}),Wn("path",{d:"M12 15.2227V18.7782",strokeWidth:"1",strokeLinecap:"round",strokeLinejoin:"round"})]});var re=(a=>(a.START_EVENT="START_EVENT",a.END_EVENT="END_EVENT",a.TASK="TASK",a.LANE="LANE",a.GATEWAY="GATEWAY",a.ANNOTATION="ANNOTATION",a.UNSUPPORTED="UNSUPPORTED",a))(re||{}),Je=(n=>(n.SCRIPT="SCRIPT",n.SUBPROCESS="SUBPROCESS",n.SERVICE_TASK="SERVICE_TASK",n))(Je||{}),Xn={SCRIPT:{icon:mf},SUBPROCESS:{icon:gf},SERVICE_TASK:{icon:pf}},ht=(t=>(t.LOOP="LOOP",t))(ht||{}),Un={LOOP:{icon:ff}},nt=(n=>(n.EXCLUSIVE="EXCLUSIVE",n.PARALLEL="PARALLEL",n.COMPLEX="COMPLEX",n))(nt||{}),Fi={EXCLUSIVE:{icon:To},PARALLEL:{icon:vo},COMPLEX:{icon:bo}};import{useTranslation as kb}from"@produto-lecom/lecom-ui";import{ReactFlowProvider as Rb}from"@xyflow/react";import{createContext as Db,useContext as Ob,useEffect as Vb,useId as Hb,useMemo as Up,useRef as Gb,useState as dt}from"react";import{Background as cb,MiniMap as db,ReactFlow as ub,SelectionMode as pb,useKeyPress as fb}from"@xyflow/react";import{forwardRef as mb,useImperativeHandle as gb,useRef as Yp}from"react";import{useEdgesState as Qx,useNodesState as jx,useReactFlow as eE,useStoreApi as tE}from"@xyflow/react";import{useCallback as ho,useEffect as oE}from"react";import{Position as en}from"@xyflow/react";function Ia(e,t){var y,T,b,I;let{width:o=0,height:n=0}=e.measured||{width:0,height:0},r=e.internals.positionAbsolute,i=t.internals.positionAbsolute,s=o/2,a=n/2,l=r.x+s,c=r.y+a,d=i.x+((T=(y=t==null?void 0:t.measured)==null?void 0:y.width)!=null?T:0)/2,u=i.y+((I=(b=t==null?void 0:t.measured)==null?void 0:b.height)!=null?I:0)/2,p=(d-l)/(2*s)-(u-c)/(2*a),m=(d-l)/(2*s)+(u-c)/(2*a),x=1/(Math.abs(p)+Math.abs(m)||1),E=x*p,g=x*m,h=s*(E+g)+l,f=a*(-E+g)+c;return{x:h,y:f}}function Aa(e,t){var c,d,u,p;let{positionAbsolute:o}=e.internals,n=(d=(c=e.measured)==null?void 0:c.width)!=null?d:0,r=(p=(u=e.measured)==null?void 0:u.height)!=null?p:0,i=Math.round(o.x),s=Math.round(o.y),a=Math.round(t.x),l=Math.round(t.y);return a<=i+1?en.Left:a>=i+n-1?en.Right:l<=s+1?en.Top:l>=s+r-1?en.Bottom:en.Top}function No(e,t){let o=Ia(e,t),n=Ia(t,e),r=Aa(e,o),i=Aa(t,n);return{sx:o.x,sy:o.y,tx:n.x,ty:n.y,sourcePos:r,targetPos:i}}function $n(e,t){return{isFromStartEvent:(e==null?void 0:e.type)==="START_EVENT",isGatewayToGateway:(e==null?void 0:e.type)==="GATEWAY"&&(t==null?void 0:t.type)==="GATEWAY",isActiviyToAndGateway:(e==null?void 0:e.type)==="TASK"&&(t==null?void 0:t.type)==="GATEWAY",isToEndEvent:(t==null?void 0:t.type)==="END_EVENT"}}import{orderBy as hf}from"lodash";var Kn=e=>e.some(t=>t.type==="position"&&t.dragging),Ca=e=>new Map(e.map(t=>[t.id,t])),Sa=(e,t)=>e.map(o=>{var n;return(n=t.get(o.id))!=null?n:o}),rt=e=>{var t,o,n,r,i,s,a,l;return{x:(o=(t=e.internals)==null?void 0:t.positionAbsolute.x)!=null?o:0,y:(r=(n=e.internals)==null?void 0:n.positionAbsolute.y)!=null?r:0,w:(s=(i=e.measured)==null?void 0:i.width)!=null?s:0,h:(l=(a=e.measured)==null?void 0:a.height)!=null?l:0}},jt=e=>hf(e,[o=>{let n=o.type==="LANE";return n&&!o.parentId?0:n?1:2}],["asc"]),Ma=(e,t)=>{let{x:o,y:n}=rt(e),{x:r,y:i}=rt(t);return{x:o-r,y:n-i}};var eo=({parentId:e,nodes:t,includeTypes:o=[...Object.values(re)],excludeTypes:n=[]})=>t.some(r=>r.parentId===e&&(!o.length||o.includes(r.type))&&!n.includes(r.type)),yf=(e,t)=>{let{x:o,y:n}=rt(e),{x:r,y:i}=rt(t),s=o-r,a=n-i;return Math.sqrt(s*s+a*a)},xf=(e,t)=>{let{x:o,y:n,w:r,h:i}=rt(e),{x:s,y:a,w:l,h:c}=rt(t),d=o+r/2,u=n+i/2;return d>=s&&d<=s+l&&u>=a&&u<=a+c},tn=(e,t)=>{let o=null,n=1/0;for(let r of t)if(r.id!==e.id&&xf(e,r)){let i=yf(e,r);i<n&&(n=i,o=r)}return o},Pa=(e,t)=>t.filter(o=>o.parentId===e).reduce((o,n)=>{var r,i;return Math.max(o,(i=(r=n.measured)==null?void 0:r.width)!=null?i:0)},0);var La=e=>{let t=e.filter(s=>!s.parentId);if(t.length===0)return null;let o=1/0,n=1/0,r=-1/0,i=-1/0;for(let s of t){let{position:a,width:l,height:c}=s,d=a.x+(l||0),u=a.y+(c||0);a.x<o&&(o=a.x),a.y<n&&(n=a.y),d>r&&(r=d),u>i&&(i=u)}return{x:o,y:n,w:r-o,h:i-n}},ka=({bounds:e,canvasWidth:t,canvasHeight:o,minZoom:n=.5,maxZoom:r=5,offsetX:i=0,offsetY:s=0})=>{let a=t-i*2,l=o-s*2,c=Math.min(a/e.w,l/e.h),d=Math.min(1,c),u=Math.min(Math.max(d,n),r);return{x:-e.x*u+i,y:-e.y*u+s,zoom:u}};var Wi=(e,t)=>{let o=t.find(s=>s.id===e);if(!o||o.type!=="LANE"||o.parentId)return!1;let n=rt(o),r=n.x+n.w,i=n.y+n.h;return t.some(s=>{if(s.id===e||s.parentId||s.type==="LANE")return!1;let a=rt(s);return a.x<r&&a.x+a.w>n.x&&a.y<i&&a.y+a.h>n.y})};import{useCallback as _f}from"react";import{create as bf}from"zustand";import{useStoreApi as Ef}from"@xyflow/react";var yt=()=>{let e=Ef();return{selectElements:n=>{let{edges:r,nodes:i,triggerEdgeChanges:s,triggerNodeChanges:a}=e.getState(),l=i.reduce((d,u)=>[...d,{id:u.id,type:"select",selected:n.includes(u.id)}],[]),c=r.reduce((d,u)=>[...d,{id:u.id,type:"select",selected:n.includes(u.id)}],[]);return a(l),s(c),!0},clearSelection:async()=>{let{unselectNodesAndEdges:n}=e.getState();return n(),await Yn(),!0}}};var Ra=()=>{let{selectElements:e}=yt();return _f(()=>{let o=to.getState().pathEdgeIds;e(o)},[e])},to=bf((e,t)=>({statusByNodeId:{},statusData:{},pathEdgeIds:[],setTaskStatuses:o=>{o!=null&&o.length&&e(n=>{let r=_({},n.statusByNodeId),i=_({},n.statusData),s=!1;return o.forEach(a=>{let l=`${a.diagramId}-${a.activityId}`;r[a.diagramId]!==a.status&&(r[a.diagramId]=a.status,i[l]=a,s=!0)}),s?{statusByNodeId:r,statusData:i}:n})},getTaskStatus:o=>t().statusByNodeId[o]||null,clearTaskStatuses:()=>e({statusByNodeId:{},statusData:{},pathEdgeIds:[]}),setPathEdges:o=>{e({pathEdgeIds:o})},getPathEdgeIds:()=>t().pathEdgeIds,clearPathEdges:()=>{e({pathEdgeIds:[]})},calculateFlowPath:(o,n)=>{if(!o.length||!n.length)return;t().clearPathEdges();let r=n.filter(d=>t().statusByNodeId[d]);if(r.length<=1)return;let i=[],s={};o.forEach(d=>{s[d.source]||(s[d.source]=[]),s[d.source].push({targetId:d.target,edgeId:d.id})});let a=r[0],l=r[r.length-1];o.forEach(d=>{d.target===a&&i.push(d.id)}),o.forEach(d=>{d.source===l&&i.push(d.id)});let c=(d,u)=>{let p=[],m=new Set;for(p.push({node:d,path:[]}),m.add(d);p.length>0;){let{node:x,path:E}=p.shift();if(x===u)return E;let g=s[x]||[];for(let{targetId:h,edgeId:f}of g)m.has(h)||(m.add(h),p.push({node:h,path:[...E,f]}))}return[]};for(let d=0;d<r.length-1;d++){let u=r[d],p=r[d+1],m=c(u,p);m.length>0&&i.push(...m)}i.length>0&&e({pathEdgeIds:i})}}));import{useNodesInitialized as Og,useReactFlow as Vg,useStore as Hg}from"@xyflow/react";import{useCallback as yn,useEffect as Gg,useRef as Bg,useState as Cc}from"react";import{shallow as zg}from"zustand/shallow";var Tf={value:()=>{}};function Oa(){for(var e=0,t=arguments.length,o={},n;e<t;++e){if(!(n=arguments[e]+"")||n in o||/[\s.]/.test(n))throw new Error("illegal type: "+n);o[n]=[]}return new qn(o)}function qn(e){this._=e}function vf(e,t){return e.trim().split(/^|\s+/).map(function(o){var n="",r=o.indexOf(".");if(r>=0&&(n=o.slice(r+1),o=o.slice(0,r)),o&&!t.hasOwnProperty(o))throw new Error("unknown type: "+o);return{type:o,name:n}})}qn.prototype=Oa.prototype={constructor:qn,on:function(e,t){var o=this._,n=vf(e+"",o),r,i=-1,s=n.length;if(arguments.length<2){for(;++i<s;)if((r=(e=n[i]).type)&&(r=Nf(o[r],e.name)))return r;return}if(t!=null&&typeof t!="function")throw new Error("invalid callback: "+t);for(;++i<s;)if(r=(e=n[i]).type)o[r]=Da(o[r],e.name,t);else if(t==null)for(r in o)o[r]=Da(o[r],e.name,null);return this},copy:function(){var e={},t=this._;for(var o in t)e[o]=t[o].slice();return new qn(e)},call:function(e,t){if((r=arguments.length-2)>0)for(var o=new Array(r),n=0,r,i;n<r;++n)o[n]=arguments[n+2];if(!this._.hasOwnProperty(e))throw new Error("unknown type: "+e);for(i=this._[e],n=0,r=i.length;n<r;++n)i[n].value.apply(t,o)},apply:function(e,t,o){if(!this._.hasOwnProperty(e))throw new Error("unknown type: "+e);for(var n=this._[e],r=0,i=n.length;r<i;++r)n[r].value.apply(t,o)}};function Nf(e,t){for(var o=0,n=e.length,r;o<n;++o)if((r=e[o]).name===t)return r.value}function Da(e,t,o){for(var n=0,r=e.length;n<r;++n)if(e[n].name===t){e[n]=Tf,e=e.slice(0,n).concat(e.slice(n+1));break}return o!=null&&e.push({name:t,value:o}),e}var Xi=Oa;var Zn="http://www.w3.org/1999/xhtml",Ui={svg:"http://www.w3.org/2000/svg",xhtml:Zn,xlink:"http://www.w3.org/1999/xlink",xml:"http://www.w3.org/XML/1998/namespace",xmlns:"http://www.w3.org/2000/xmlns/"};function Nt(e){var t=e+="",o=t.indexOf(":");return o>=0&&(t=e.slice(0,o))!=="xmlns"&&(e=e.slice(o+1)),Ui.hasOwnProperty(t)?{space:Ui[t],local:e}:e}function wf(e){return function(){var t=this.ownerDocument,o=this.namespaceURI;return o===Zn&&t.documentElement.namespaceURI===Zn?t.createElement(e):t.createElementNS(o,e)}}function If(e){return function(){return this.ownerDocument.createElementNS(e.space,e.local)}}function Jn(e){var t=Nt(e);return(t.local?If:wf)(t)}function Af(){}function oo(e){return e==null?Af:function(){return this.querySelector(e)}}function Va(e){typeof e!="function"&&(e=oo(e));for(var t=this._groups,o=t.length,n=new Array(o),r=0;r<o;++r)for(var i=t[r],s=i.length,a=n[r]=new Array(s),l,c,d=0;d<s;++d)(l=i[d])&&(c=e.call(l,l.__data__,d,i))&&("__data__"in l&&(c.__data__=l.__data__),a[d]=c);return new Ae(n,this._parents)}function $i(e){return e==null?[]:Array.isArray(e)?e:Array.from(e)}function Cf(){return[]}function on(e){return e==null?Cf:function(){return this.querySelectorAll(e)}}function Sf(e){return function(){return $i(e.apply(this,arguments))}}function Ha(e){typeof e=="function"?e=Sf(e):e=on(e);for(var t=this._groups,o=t.length,n=[],r=[],i=0;i<o;++i)for(var s=t[i],a=s.length,l,c=0;c<a;++c)(l=s[c])&&(n.push(e.call(l,l.__data__,c,s)),r.push(l));return new Ae(n,r)}function nn(e){return function(){return this.matches(e)}}function Qn(e){return function(t){return t.matches(e)}}var Mf=Array.prototype.find;function Pf(e){return function(){return Mf.call(this.children,e)}}function Lf(){return this.firstElementChild}function Ga(e){return this.select(e==null?Lf:Pf(typeof e=="function"?e:Qn(e)))}var kf=Array.prototype.filter;function Rf(){return Array.from(this.children)}function Df(e){return function(){return kf.call(this.children,e)}}function Ba(e){return this.selectAll(e==null?Rf:Df(typeof e=="function"?e:Qn(e)))}function za(e){typeof e!="function"&&(e=nn(e));for(var t=this._groups,o=t.length,n=new Array(o),r=0;r<o;++r)for(var i=t[r],s=i.length,a=n[r]=[],l,c=0;c<s;++c)(l=i[c])&&e.call(l,l.__data__,c,i)&&a.push(l);return new Ae(n,this._parents)}function jn(e){return new Array(e.length)}function Ya(){return new Ae(this._enter||this._groups.map(jn),this._parents)}function rn(e,t){this.ownerDocument=e.ownerDocument,this.namespaceURI=e.namespaceURI,this._next=null,this._parent=e,this.__data__=t}rn.prototype={constructor:rn,appendChild:function(e){return this._parent.insertBefore(e,this._next)},insertBefore:function(e,t){return this._parent.insertBefore(e,t)},querySelector:function(e){return this._parent.querySelector(e)},querySelectorAll:function(e){return this._parent.querySelectorAll(e)}};function Fa(e){return function(){return e}}function Of(e,t,o,n,r,i){for(var s=0,a,l=t.length,c=i.length;s<c;++s)(a=t[s])?(a.__data__=i[s],n[s]=a):o[s]=new rn(e,i[s]);for(;s<l;++s)(a=t[s])&&(r[s]=a)}function Vf(e,t,o,n,r,i,s){var a,l,c=new Map,d=t.length,u=i.length,p=new Array(d),m;for(a=0;a<d;++a)(l=t[a])&&(p[a]=m=s.call(l,l.__data__,a,t)+"",c.has(m)?r[a]=l:c.set(m,l));for(a=0;a<u;++a)m=s.call(e,i[a],a,i)+"",(l=c.get(m))?(n[a]=l,l.__data__=i[a],c.delete(m)):o[a]=new rn(e,i[a]);for(a=0;a<d;++a)(l=t[a])&&c.get(p[a])===l&&(r[a]=l)}function Hf(e){return e.__data__}function Wa(e,t){if(!arguments.length)return Array.from(this,Hf);var o=t?Vf:Of,n=this._parents,r=this._groups;typeof e!="function"&&(e=Fa(e));for(var i=r.length,s=new Array(i),a=new Array(i),l=new Array(i),c=0;c<i;++c){var d=n[c],u=r[c],p=u.length,m=Gf(e.call(d,d&&d.__data__,c,n)),x=m.length,E=a[c]=new Array(x),g=s[c]=new Array(x),h=l[c]=new Array(p);o(d,u,E,g,h,m,t);for(var f=0,y=0,T,b;f<x;++f)if(T=E[f]){for(f>=y&&(y=f+1);!(b=g[y])&&++y<x;);T._next=b||null}}return s=new Ae(s,n),s._enter=a,s._exit=l,s}function Gf(e){return typeof e=="object"&&"length"in e?e:Array.from(e)}function Xa(){return new Ae(this._exit||this._groups.map(jn),this._parents)}function Ua(e,t,o){var n=this.enter(),r=this,i=this.exit();return typeof e=="function"?(n=e(n),n&&(n=n.selection())):n=n.append(e+""),t!=null&&(r=t(r),r&&(r=r.selection())),o==null?i.remove():o(i),n&&r?n.merge(r).order():r}function $a(e){for(var t=e.selection?e.selection():e,o=this._groups,n=t._groups,r=o.length,i=n.length,s=Math.min(r,i),a=new Array(r),l=0;l<s;++l)for(var c=o[l],d=n[l],u=c.length,p=a[l]=new Array(u),m,x=0;x<u;++x)(m=c[x]||d[x])&&(p[x]=m);for(;l<r;++l)a[l]=o[l];return new Ae(a,this._parents)}function Ka(){for(var e=this._groups,t=-1,o=e.length;++t<o;)for(var n=e[t],r=n.length-1,i=n[r],s;--r>=0;)(s=n[r])&&(i&&s.compareDocumentPosition(i)^4&&i.parentNode.insertBefore(s,i),i=s);return this}function qa(e){e||(e=Bf);function t(u,p){return u&&p?e(u.__data__,p.__data__):!u-!p}for(var o=this._groups,n=o.length,r=new Array(n),i=0;i<n;++i){for(var s=o[i],a=s.length,l=r[i]=new Array(a),c,d=0;d<a;++d)(c=s[d])&&(l[d]=c);l.sort(t)}return new Ae(r,this._parents).order()}function Bf(e,t){return e<t?-1:e>t?1:e>=t?0:NaN}function Za(){var e=arguments[0];return arguments[0]=this,e.apply(null,arguments),this}function Ja(){return Array.from(this)}function Qa(){for(var e=this._groups,t=0,o=e.length;t<o;++t)for(var n=e[t],r=0,i=n.length;r<i;++r){var s=n[r];if(s)return s}return null}function ja(){let e=0;for(let t of this)++e;return e}function el(){return!this.node()}function tl(e){for(var t=this._groups,o=0,n=t.length;o<n;++o)for(var r=t[o],i=0,s=r.length,a;i<s;++i)(a=r[i])&&e.call(a,a.__data__,i,r);return this}function zf(e){return function(){this.removeAttribute(e)}}function Yf(e){return function(){this.removeAttributeNS(e.space,e.local)}}function Ff(e,t){return function(){this.setAttribute(e,t)}}function Wf(e,t){return function(){this.setAttributeNS(e.space,e.local,t)}}function Xf(e,t){return function(){var o=t.apply(this,arguments);o==null?this.removeAttribute(e):this.setAttribute(e,o)}}function Uf(e,t){return function(){var o=t.apply(this,arguments);o==null?this.removeAttributeNS(e.space,e.local):this.setAttributeNS(e.space,e.local,o)}}function ol(e,t){var o=Nt(e);if(arguments.length<2){var n=this.node();return o.local?n.getAttributeNS(o.space,o.local):n.getAttribute(o)}return this.each((t==null?o.local?Yf:zf:typeof t=="function"?o.local?Uf:Xf:o.local?Wf:Ff)(o,t))}function er(e){return e.ownerDocument&&e.ownerDocument.defaultView||e.document&&e||e.defaultView}function $f(e){return function(){this.style.removeProperty(e)}}function Kf(e,t,o){return function(){this.style.setProperty(e,t,o)}}function qf(e,t,o){return function(){var n=t.apply(this,arguments);n==null?this.style.removeProperty(e):this.style.setProperty(e,n,o)}}function nl(e,t,o){return arguments.length>1?this.each((t==null?$f:typeof t=="function"?qf:Kf)(e,t,o==null?"":o)):Dt(this.node(),e)}function Dt(e,t){return e.style.getPropertyValue(t)||er(e).getComputedStyle(e,null).getPropertyValue(t)}function Zf(e){return function(){delete this[e]}}function Jf(e,t){return function(){this[e]=t}}function Qf(e,t){return function(){var o=t.apply(this,arguments);o==null?delete this[e]:this[e]=o}}function rl(e,t){return arguments.length>1?this.each((t==null?Zf:typeof t=="function"?Qf:Jf)(e,t)):this.node()[e]}function il(e){return e.trim().split(/^|\s+/)}function Ki(e){return e.classList||new sl(e)}function sl(e){this._node=e,this._names=il(e.getAttribute("class")||"")}sl.prototype={add:function(e){var t=this._names.indexOf(e);t<0&&(this._names.push(e),this._node.setAttribute("class",this._names.join(" ")))},remove:function(e){var t=this._names.indexOf(e);t>=0&&(this._names.splice(t,1),this._node.setAttribute("class",this._names.join(" ")))},contains:function(e){return this._names.indexOf(e)>=0}};function al(e,t){for(var o=Ki(e),n=-1,r=t.length;++n<r;)o.add(t[n])}function ll(e,t){for(var o=Ki(e),n=-1,r=t.length;++n<r;)o.remove(t[n])}function jf(e){return function(){al(this,e)}}function em(e){return function(){ll(this,e)}}function tm(e,t){return function(){(t.apply(this,arguments)?al:ll)(this,e)}}function cl(e,t){var o=il(e+"");if(arguments.length<2){for(var n=Ki(this.node()),r=-1,i=o.length;++r<i;)if(!n.contains(o[r]))return!1;return!0}return this.each((typeof t=="function"?tm:t?jf:em)(o,t))}function om(){this.textContent=""}function nm(e){return function(){this.textContent=e}}function rm(e){return function(){var t=e.apply(this,arguments);this.textContent=t==null?"":t}}function dl(e){return arguments.length?this.each(e==null?om:(typeof e=="function"?rm:nm)(e)):this.node().textContent}function im(){this.innerHTML=""}function sm(e){return function(){this.innerHTML=e}}function am(e){return function(){var t=e.apply(this,arguments);this.innerHTML=t==null?"":t}}function ul(e){return arguments.length?this.each(e==null?im:(typeof e=="function"?am:sm)(e)):this.node().innerHTML}function lm(){this.nextSibling&&this.parentNode.appendChild(this)}function pl(){return this.each(lm)}function cm(){this.previousSibling&&this.parentNode.insertBefore(this,this.parentNode.firstChild)}function fl(){return this.each(cm)}function ml(e){var t=typeof e=="function"?e:Jn(e);return this.select(function(){return this.appendChild(t.apply(this,arguments))})}function dm(){return null}function gl(e,t){var o=typeof e=="function"?e:Jn(e),n=t==null?dm:typeof t=="function"?t:oo(t);return this.select(function(){return this.insertBefore(o.apply(this,arguments),n.apply(this,arguments)||null)})}function um(){var e=this.parentNode;e&&e.removeChild(this)}function hl(){return this.each(um)}function pm(){var e=this.cloneNode(!1),t=this.parentNode;return t?t.insertBefore(e,this.nextSibling):e}function fm(){var e=this.cloneNode(!0),t=this.parentNode;return t?t.insertBefore(e,this.nextSibling):e}function yl(e){return this.select(e?fm:pm)}function xl(e){return arguments.length?this.property("__data__",e):this.node().__data__}function mm(e){return function(t){e.call(this,t,this.__data__)}}function gm(e){return e.trim().split(/^|\s+/).map(function(t){var o="",n=t.indexOf(".");return n>=0&&(o=t.slice(n+1),t=t.slice(0,n)),{type:t,name:o}})}function hm(e){return function(){var t=this.__on;if(t){for(var o=0,n=-1,r=t.length,i;o<r;++o)i=t[o],(!e.type||i.type===e.type)&&i.name===e.name?this.removeEventListener(i.type,i.listener,i.options):t[++n]=i;++n?t.length=n:delete this.__on}}}function ym(e,t,o){return function(){var n=this.__on,r,i=mm(t);if(n){for(var s=0,a=n.length;s<a;++s)if((r=n[s]).type===e.type&&r.name===e.name){this.removeEventListener(r.type,r.listener,r.options),this.addEventListener(r.type,r.listener=i,r.options=o),r.value=t;return}}this.addEventListener(e.type,i,o),r={type:e.type,name:e.name,value:t,listener:i,options:o},n?n.push(r):this.__on=[r]}}function El(e,t,o){var n=gm(e+""),r,i=n.length,s;if(arguments.length<2){var a=this.node().__on;if(a){for(var l=0,c=a.length,d;l<c;++l)for(r=0,d=a[l];r<i;++r)if((s=n[r]).type===d.type&&s.name===d.name)return d.value}return}for(a=t?ym:hm,r=0;r<i;++r)this.each(a(n[r],t,o));return this}function _l(e,t,o){var n=er(e),r=n.CustomEvent;typeof r=="function"?r=new r(t,o):(r=n.document.createEvent("Event"),o?(r.initEvent(t,o.bubbles,o.cancelable),r.detail=o.detail):r.initEvent(t,!1,!1)),e.dispatchEvent(r)}function xm(e,t){return function(){return _l(this,e,t)}}function Em(e,t){return function(){return _l(this,e,t.apply(this,arguments))}}function bl(e,t){return this.each((typeof t=="function"?Em:xm)(e,t))}function*Tl(){for(var e=this._groups,t=0,o=e.length;t<o;++t)for(var n=e[t],r=0,i=n.length,s;r<i;++r)(s=n[r])&&(yield s)}var _m=[null];function Ae(e,t){this._groups=e,this._parents=t}function vl(){return new Ae([[document.documentElement]],_m)}function bm(){return this}Ae.prototype=vl.prototype={constructor:Ae,select:Va,selectAll:Ha,selectChild:Ga,selectChildren:Ba,filter:za,data:Wa,enter:Ya,exit:Xa,join:Ua,merge:$a,selection:bm,order:Ka,sort:qa,call:Za,nodes:Ja,node:Qa,size:ja,empty:el,each:tl,attr:ol,style:nl,property:rl,classed:cl,text:dl,html:ul,raise:pl,lower:fl,append:ml,insert:gl,remove:hl,clone:yl,datum:xl,on:El,dispatch:bl,[Symbol.iterator]:Tl};var wt=vl;function tr(e,t,o){e.prototype=t.prototype=o,o.constructor=e}function qi(e,t){var o=Object.create(e.prototype);for(var n in t)o[n]=t[n];return o}function ln(){}var sn=.7,rr=1/sn,wo="\\s*([+-]?\\d+)\\s*",an="\\s*([+-]?(?:\\d*\\.)?\\d+(?:[eE][+-]?\\d+)?)\\s*",xt="\\s*([+-]?(?:\\d*\\.)?\\d+(?:[eE][+-]?\\d+)?)%\\s*",Tm=/^#([0-9a-f]{3,8})$/,vm=new RegExp(`^rgb\\(${wo},${wo},${wo}\\)$`),Nm=new RegExp(`^rgb\\(${xt},${xt},${xt}\\)$`),wm=new RegExp(`^rgba\\(${wo},${wo},${wo},${an}\\)$`),Im=new RegExp(`^rgba\\(${xt},${xt},${xt},${an}\\)$`),Am=new RegExp(`^hsl\\(${an},${xt},${xt}\\)$`),Cm=new RegExp(`^hsla\\(${an},${xt},${xt},${an}\\)$`),Nl={aliceblue:15792383,antiquewhite:16444375,aqua:65535,aquamarine:8388564,azure:15794175,beige:16119260,bisque:16770244,black:0,blanchedalmond:16772045,blue:255,blueviolet:9055202,brown:10824234,burlywood:14596231,cadetblue:6266528,chartreuse:8388352,chocolate:13789470,coral:16744272,cornflowerblue:6591981,cornsilk:16775388,crimson:14423100,cyan:65535,darkblue:139,darkcyan:35723,darkgoldenrod:12092939,darkgray:11119017,darkgreen:25600,darkgrey:11119017,darkkhaki:12433259,darkmagenta:9109643,darkolivegreen:5597999,darkorange:16747520,darkorchid:10040012,darkred:9109504,darksalmon:15308410,darkseagreen:9419919,darkslateblue:4734347,darkslategray:3100495,darkslategrey:3100495,darkturquoise:52945,darkviolet:9699539,deeppink:16716947,deepskyblue:49151,dimgray:6908265,dimgrey:6908265,dodgerblue:2003199,firebrick:11674146,floralwhite:16775920,forestgreen:2263842,fuchsia:16711935,gainsboro:14474460,ghostwhite:16316671,gold:16766720,goldenrod:14329120,gray:8421504,green:32768,greenyellow:11403055,grey:8421504,honeydew:15794160,hotpink:16738740,indianred:13458524,indigo:4915330,ivory:16777200,khaki:15787660,lavender:15132410,lavenderblush:16773365,lawngreen:8190976,lemonchiffon:16775885,lightblue:11393254,lightcoral:15761536,lightcyan:14745599,lightgoldenrodyellow:16448210,lightgray:13882323,lightgreen:9498256,lightgrey:13882323,lightpink:16758465,lightsalmon:16752762,lightseagreen:2142890,lightskyblue:8900346,lightslategray:7833753,lightslategrey:7833753,lightsteelblue:11584734,lightyellow:16777184,lime:65280,limegreen:3329330,linen:16445670,magenta:16711935,maroon:8388608,mediumaquamarine:6737322,mediumblue:205,mediumorchid:12211667,mediumpurple:9662683,mediumseagreen:3978097,mediumslateblue:8087790,mediumspringgreen:64154,mediumturquoise:4772300,mediumvioletred:13047173,midnightblue:1644912,mintcream:16121850,mistyrose:16770273,moccasin:16770229,navajowhite:16768685,navy:128,oldlace:16643558,olive:8421376,olivedrab:7048739,orange:16753920,orangered:16729344,orchid:14315734,palegoldenrod:15657130,palegreen:10025880,paleturquoise:11529966,palevioletred:14381203,papayawhip:16773077,peachpuff:16767673,peru:13468991,pink:16761035,plum:14524637,powderblue:11591910,purple:8388736,rebeccapurple:6697881,red:16711680,rosybrown:12357519,royalblue:4286945,saddlebrown:9127187,salmon:16416882,sandybrown:16032864,seagreen:3050327,seashell:16774638,sienna:10506797,silver:12632256,skyblue:8900331,slateblue:6970061,slategray:7372944,slategrey:7372944,snow:16775930,springgreen:65407,steelblue:4620980,tan:13808780,teal:32896,thistle:14204888,tomato:16737095,turquoise:4251856,violet:15631086,wheat:16113331,white:16777215,whitesmoke:16119285,yellow:16776960,yellowgreen:10145074};tr(ln,Ot,{copy(e){return Object.assign(new this.constructor,this,e)},displayable(){return this.rgb().displayable()},hex:wl,formatHex:wl,formatHex8:Sm,formatHsl:Mm,formatRgb:Il,toString:Il});function wl(){return this.rgb().formatHex()}function Sm(){return this.rgb().formatHex8()}function Mm(){return Ll(this).formatHsl()}function Il(){return this.rgb().formatRgb()}function Ot(e){var t,o;return e=(e+"").trim().toLowerCase(),(t=Tm.exec(e))?(o=t[1].length,t=parseInt(t[1],16),o===6?Al(t):o===3?new Xe(t>>8&15|t>>4&240,t>>4&15|t&240,(t&15)<<4|t&15,1):o===8?or(t>>24&255,t>>16&255,t>>8&255,(t&255)/255):o===4?or(t>>12&15|t>>8&240,t>>8&15|t>>4&240,t>>4&15|t&240,((t&15)<<4|t&15)/255):null):(t=vm.exec(e))?new Xe(t[1],t[2],t[3],1):(t=Nm.exec(e))?new Xe(t[1]*255/100,t[2]*255/100,t[3]*255/100,1):(t=wm.exec(e))?or(t[1],t[2],t[3],t[4]):(t=Im.exec(e))?or(t[1]*255/100,t[2]*255/100,t[3]*255/100,t[4]):(t=Am.exec(e))?Ml(t[1],t[2]/100,t[3]/100,1):(t=Cm.exec(e))?Ml(t[1],t[2]/100,t[3]/100,t[4]):Nl.hasOwnProperty(e)?Al(Nl[e]):e==="transparent"?new Xe(NaN,NaN,NaN,0):null}function Al(e){return new Xe(e>>16&255,e>>8&255,e&255,1)}function or(e,t,o,n){return n<=0&&(e=t=o=NaN),new Xe(e,t,o,n)}function Pm(e){return e instanceof ln||(e=Ot(e)),e?(e=e.rgb(),new Xe(e.r,e.g,e.b,e.opacity)):new Xe}function Io(e,t,o,n){return arguments.length===1?Pm(e):new Xe(e,t,o,n==null?1:n)}function Xe(e,t,o,n){this.r=+e,this.g=+t,this.b=+o,this.opacity=+n}tr(Xe,Io,qi(ln,{brighter(e){return e=e==null?rr:Math.pow(rr,e),new Xe(this.r*e,this.g*e,this.b*e,this.opacity)},darker(e){return e=e==null?sn:Math.pow(sn,e),new Xe(this.r*e,this.g*e,this.b*e,this.opacity)},rgb(){return this},clamp(){return new Xe(ro(this.r),ro(this.g),ro(this.b),ir(this.opacity))},displayable(){return-.5<=this.r&&this.r<255.5&&-.5<=this.g&&this.g<255.5&&-.5<=this.b&&this.b<255.5&&0<=this.opacity&&this.opacity<=1},hex:Cl,formatHex:Cl,formatHex8:Lm,formatRgb:Sl,toString:Sl}));function Cl(){return`#${no(this.r)}${no(this.g)}${no(this.b)}`}function Lm(){return`#${no(this.r)}${no(this.g)}${no(this.b)}${no((isNaN(this.opacity)?1:this.opacity)*255)}`}function Sl(){let e=ir(this.opacity);return`${e===1?"rgb(":"rgba("}${ro(this.r)}, ${ro(this.g)}, ${ro(this.b)}${e===1?")":`, ${e})`}`}function ir(e){return isNaN(e)?1:Math.max(0,Math.min(1,e))}function ro(e){return Math.max(0,Math.min(255,Math.round(e)||0))}function no(e){return e=ro(e),(e<16?"0":"")+e.toString(16)}function Ml(e,t,o,n){return n<=0?e=t=o=NaN:o<=0||o>=1?e=t=NaN:t<=0&&(e=NaN),new pt(e,t,o,n)}function Ll(e){if(e instanceof pt)return new pt(e.h,e.s,e.l,e.opacity);if(e instanceof ln||(e=Ot(e)),!e)return new pt;if(e instanceof pt)return e;e=e.rgb();var t=e.r/255,o=e.g/255,n=e.b/255,r=Math.min(t,o,n),i=Math.max(t,o,n),s=NaN,a=i-r,l=(i+r)/2;return a?(t===i?s=(o-n)/a+(o<n)*6:o===i?s=(n-t)/a+2:s=(t-o)/a+4,a/=l<.5?i+r:2-i-r,s*=60):a=l>0&&l<1?0:s,new pt(s,a,l,e.opacity)}function kl(e,t,o,n){return arguments.length===1?Ll(e):new pt(e,t,o,n==null?1:n)}function pt(e,t,o,n){this.h=+e,this.s=+t,this.l=+o,this.opacity=+n}tr(pt,kl,qi(ln,{brighter(e){return e=e==null?rr:Math.pow(rr,e),new pt(this.h,this.s,this.l*e,this.opacity)},darker(e){return e=e==null?sn:Math.pow(sn,e),new pt(this.h,this.s,this.l*e,this.opacity)},rgb(){var e=this.h%360+(this.h<0)*360,t=isNaN(e)||isNaN(this.s)?0:this.s,o=this.l,n=o+(o<.5?o:1-o)*t,r=2*o-n;return new Xe(Zi(e>=240?e-240:e+120,r,n),Zi(e,r,n),Zi(e<120?e+240:e-120,r,n),this.opacity)},clamp(){return new pt(Pl(this.h),nr(this.s),nr(this.l),ir(this.opacity))},displayable(){return(0<=this.s&&this.s<=1||isNaN(this.s))&&0<=this.l&&this.l<=1&&0<=this.opacity&&this.opacity<=1},formatHsl(){let e=ir(this.opacity);return`${e===1?"hsl(":"hsla("}${Pl(this.h)}, ${nr(this.s)*100}%, ${nr(this.l)*100}%${e===1?")":`, ${e})`}`}}));function Pl(e){return e=(e||0)%360,e<0?e+360:e}function nr(e){return Math.max(0,Math.min(1,e||0))}function Zi(e,t,o){return(e<60?t+(o-t)*e/60:e<180?o:e<240?t+(o-t)*(240-e)/60:t)*255}function Ji(e,t,o,n,r){var i=e*e,s=i*e;return((1-3*e+3*i-s)*t+(4-6*i+3*s)*o+(1+3*e+3*i-3*s)*n+s*r)/6}function Rl(e){var t=e.length-1;return function(o){var n=o<=0?o=0:o>=1?(o=1,t-1):Math.floor(o*t),r=e[n],i=e[n+1],s=n>0?e[n-1]:2*r-i,a=n<t-1?e[n+2]:2*i-r;return Ji((o-n/t)*t,s,r,i,a)}}function Dl(e){var t=e.length;return function(o){var n=Math.floor(((o%=1)<0?++o:o)*t),r=e[(n+t-1)%t],i=e[n%t],s=e[(n+1)%t],a=e[(n+2)%t];return Ji((o-n/t)*t,r,i,s,a)}}var Qi=e=>()=>e;function km(e,t){return function(o){return e+o*t}}function Rm(e,t,o){return e=Math.pow(e,o),t=Math.pow(t,o)-e,o=1/o,function(n){return Math.pow(e+n*t,o)}}function Ol(e){return(e=+e)==1?sr:function(t,o){return o-t?Rm(t,o,e):Qi(isNaN(t)?o:t)}}function sr(e,t){var o=t-e;return o?km(e,o):Qi(isNaN(e)?t:e)}var ar=function e(t){var o=Ol(t);function n(r,i){var s=o((r=Io(r)).r,(i=Io(i)).r),a=o(r.g,i.g),l=o(r.b,i.b),c=sr(r.opacity,i.opacity);return function(d){return r.r=s(d),r.g=a(d),r.b=l(d),r.opacity=c(d),r+""}}return n.gamma=e,n}(1);function Vl(e){return function(t){var o=t.length,n=new Array(o),r=new Array(o),i=new Array(o),s,a;for(s=0;s<o;++s)a=Io(t[s]),n[s]=a.r||0,r[s]=a.g||0,i[s]=a.b||0;return n=e(n),r=e(r),i=e(i),a.opacity=1,function(l){return a.r=n(l),a.g=r(l),a.b=i(l),a+""}}}var Dm=Vl(Rl),Om=Vl(Dl);function it(e,t){return e=+e,t=+t,function(o){return e*(1-o)+t*o}}var es=/[-+]?(?:\d+\.?\d*|\.?\d+)(?:[eE][-+]?\d+)?/g,ji=new RegExp(es.source,"g");function Vm(e){return function(){return e}}function Hm(e){return function(t){return e(t)+""}}function ts(e,t){var o=es.lastIndex=ji.lastIndex=0,n,r,i,s=-1,a=[],l=[];for(e=e+"",t=t+"";(n=es.exec(e))&&(r=ji.exec(t));)(i=r.index)>o&&(i=t.slice(o,i),a[s]?a[s]+=i:a[++s]=i),(n=n[0])===(r=r[0])?a[s]?a[s]+=r:a[++s]=r:(a[++s]=null,l.push({i:s,x:it(n,r)})),o=ji.lastIndex;return o<t.length&&(i=t.slice(o),a[s]?a[s]+=i:a[++s]=i),a.length<2?l[0]?Hm(l[0].x):Vm(t):(t=l.length,function(c){for(var d=0,u;d<t;++d)a[(u=l[d]).i]=u.x(c);return a.join("")})}var Hl=180/Math.PI,lr={translateX:0,translateY:0,rotate:0,skewX:0,scaleX:1,scaleY:1};function os(e,t,o,n,r,i){var s,a,l;return(s=Math.sqrt(e*e+t*t))&&(e/=s,t/=s),(l=e*o+t*n)&&(o-=e*l,n-=t*l),(a=Math.sqrt(o*o+n*n))&&(o/=a,n/=a,l/=a),e*n<t*o&&(e=-e,t=-t,l=-l,s=-s),{translateX:r,translateY:i,rotate:Math.atan2(t,e)*Hl,skewX:Math.atan(l)*Hl,scaleX:s,scaleY:a}}var cr;function Gl(e){let t=new(typeof DOMMatrix=="function"?DOMMatrix:WebKitCSSMatrix)(e+"");return t.isIdentity?lr:os(t.a,t.b,t.c,t.d,t.e,t.f)}function Bl(e){return e==null?lr:(cr||(cr=document.createElementNS("http://www.w3.org/2000/svg","g")),cr.setAttribute("transform",e),(e=cr.transform.baseVal.consolidate())?(e=e.matrix,os(e.a,e.b,e.c,e.d,e.e,e.f)):lr)}function zl(e,t,o,n){function r(c){return c.length?c.pop()+" ":""}function i(c,d,u,p,m,x){if(c!==u||d!==p){var E=m.push("translate(",null,t,null,o);x.push({i:E-4,x:it(c,u)},{i:E-2,x:it(d,p)})}else(u||p)&&m.push("translate("+u+t+p+o)}function s(c,d,u,p){c!==d?(c-d>180?d+=360:d-c>180&&(c+=360),p.push({i:u.push(r(u)+"rotate(",null,n)-2,x:it(c,d)})):d&&u.push(r(u)+"rotate("+d+n)}function a(c,d,u,p){c!==d?p.push({i:u.push(r(u)+"skewX(",null,n)-2,x:it(c,d)}):d&&u.push(r(u)+"skewX("+d+n)}function l(c,d,u,p,m,x){if(c!==u||d!==p){var E=m.push(r(m)+"scale(",null,",",null,")");x.push({i:E-4,x:it(c,u)},{i:E-2,x:it(d,p)})}else(u!==1||p!==1)&&m.push(r(m)+"scale("+u+","+p+")")}return function(c,d){var u=[],p=[];return c=e(c),d=e(d),i(c.translateX,c.translateY,d.translateX,d.translateY,u,p),s(c.rotate,d.rotate,u,p),a(c.skewX,d.skewX,u,p),l(c.scaleX,c.scaleY,d.scaleX,d.scaleY,u,p),c=d=null,function(m){for(var x=-1,E=p.length,g;++x<E;)u[(g=p[x]).i]=g.x(m);return u.join("")}}}var ns=zl(Gl,"px, ","px)","deg)"),rs=zl(Bl,", ",")",")");var Ao=0,dn=0,cn=0,Fl=1e3,dr,un,ur=0,io=0,pr=0,pn=typeof performance=="object"&&performance.now?performance:Date,Wl=typeof window=="object"&&window.requestAnimationFrame?window.requestAnimationFrame.bind(window):function(e){setTimeout(e,17)};function mn(){return io||(Wl(Gm),io=pn.now()+pr)}function Gm(){io=0}function fn(){this._call=this._time=this._next=null}fn.prototype=fr.prototype={constructor:fn,restart:function(e,t,o){if(typeof e!="function")throw new TypeError("callback is not a function");o=(o==null?mn():+o)+(t==null?0:+t),!this._next&&un!==this&&(un?un._next=this:dr=this,un=this),this._call=e,this._time=o,is()},stop:function(){this._call&&(this._call=null,this._time=1/0,is())}};function fr(e,t,o){var n=new fn;return n.restart(e,t,o),n}function Xl(){mn(),++Ao;for(var e=dr,t;e;)(t=io-e._time)>=0&&e._call.call(void 0,t),e=e._next;--Ao}function Yl(){io=(ur=pn.now())+pr,Ao=dn=0;try{Xl()}finally{Ao=0,zm(),io=0}}function Bm(){var e=pn.now(),t=e-ur;t>Fl&&(pr-=t,ur=e)}function zm(){for(var e,t=dr,o,n=1/0;t;)t._call?(n>t._time&&(n=t._time),e=t,t=t._next):(o=t._next,t._next=null,t=e?e._next=o:dr=o);un=e,is(n)}function is(e){if(!Ao){dn&&(dn=clearTimeout(dn));var t=e-io;t>24?(e<1/0&&(dn=setTimeout(Yl,e-pn.now()-pr)),cn&&(cn=clearInterval(cn))):(cn||(ur=pn.now(),cn=setInterval(Bm,Fl)),Ao=1,Wl(Yl))}}function mr(e,t,o){var n=new fn;return t=t==null?0:+t,n.restart(r=>{n.stop(),e(r+t)},t,o),n}var Ym=Xi("start","end","cancel","interrupt"),Fm=[],Kl=0,Ul=1,hr=2,gr=3,$l=4,yr=5,gn=6;function Vt(e,t,o,n,r,i){var s=e.__transition;if(!s)e.__transition={};else if(o in s)return;Wm(e,o,{name:t,index:n,group:r,on:Ym,tween:Fm,time:i.time,delay:i.delay,duration:i.duration,ease:i.ease,timer:null,state:Kl})}function hn(e,t){var o=Ce(e,t);if(o.state>Kl)throw new Error("too late; already scheduled");return o}function ke(e,t){var o=Ce(e,t);if(o.state>gr)throw new Error("too late; already running");return o}function Ce(e,t){var o=e.__transition;if(!o||!(o=o[t]))throw new Error("transition not found");return o}function Wm(e,t,o){var n=e.__transition,r;n[t]=o,o.timer=fr(i,0,o.time);function i(c){o.state=Ul,o.timer.restart(s,o.delay,o.time),o.delay<=c&&s(c-o.delay)}function s(c){var d,u,p,m;if(o.state!==Ul)return l();for(d in n)if(m=n[d],m.name===o.name){if(m.state===gr)return mr(s);m.state===$l?(m.state=gn,m.timer.stop(),m.on.call("interrupt",e,e.__data__,m.index,m.group),delete n[d]):+d<t&&(m.state=gn,m.timer.stop(),m.on.call("cancel",e,e.__data__,m.index,m.group),delete n[d])}if(mr(function(){o.state===gr&&(o.state=$l,o.timer.restart(a,o.delay,o.time),a(c))}),o.state=hr,o.on.call("start",e,e.__data__,o.index,o.group),o.state===hr){for(o.state=gr,r=new Array(p=o.tween.length),d=0,u=-1;d<p;++d)(m=o.tween[d].value.call(e,e.__data__,o.index,o.group))&&(r[++u]=m);r.length=u+1}}function a(c){for(var d=c<o.duration?o.ease.call(null,c/o.duration):(o.timer.restart(l),o.state=yr,1),u=-1,p=r.length;++u<p;)r[u].call(e,d);o.state===yr&&(o.on.call("end",e,e.__data__,o.index,o.group),l())}function l(){o.state=gn,o.timer.stop(),delete n[t];for(var c in n)return;delete e.__transition}}function ss(e,t){var o=e.__transition,n,r,i=!0,s;if(o){t=t==null?null:t+"";for(s in o){if((n=o[s]).name!==t){i=!1;continue}r=n.state>hr&&n.state<yr,n.state=gn,n.timer.stop(),n.on.call(r?"interrupt":"cancel",e,e.__data__,n.index,n.group),delete o[s]}i&&delete e.__transition}}function ql(e){return this.each(function(){ss(this,e)})}function Xm(e,t){var o,n;return function(){var r=ke(this,e),i=r.tween;if(i!==o){n=o=i;for(var s=0,a=n.length;s<a;++s)if(n[s].name===t){n=n.slice(),n.splice(s,1);break}}r.tween=n}}function Um(e,t,o){var n,r;if(typeof o!="function")throw new Error;return function(){var i=ke(this,e),s=i.tween;if(s!==n){r=(n=s).slice();for(var a={name:t,value:o},l=0,c=r.length;l<c;++l)if(r[l].name===t){r[l]=a;break}l===c&&r.push(a)}i.tween=r}}function Zl(e,t){var o=this._id;if(e+="",arguments.length<2){for(var n=Ce(this.node(),o).tween,r=0,i=n.length,s;r<i;++r)if((s=n[r]).name===e)return s.value;return null}return this.each((t==null?Xm:Um)(o,e,t))}function Co(e,t,o){var n=e._id;return e.each(function(){var r=ke(this,n);(r.value||(r.value={}))[t]=o.apply(this,arguments)}),function(r){return Ce(r,n).value[t]}}function xr(e,t){var o;return(typeof t=="number"?it:t instanceof Ot?ar:(o=Ot(t))?(t=o,ar):ts)(e,t)}function $m(e){return function(){this.removeAttribute(e)}}function Km(e){return function(){this.removeAttributeNS(e.space,e.local)}}function qm(e,t,o){var n,r=o+"",i;return function(){var s=this.getAttribute(e);return s===r?null:s===n?i:i=t(n=s,o)}}function Zm(e,t,o){var n,r=o+"",i;return function(){var s=this.getAttributeNS(e.space,e.local);return s===r?null:s===n?i:i=t(n=s,o)}}function Jm(e,t,o){var n,r,i;return function(){var s,a=o(this),l;return a==null?void this.removeAttribute(e):(s=this.getAttribute(e),l=a+"",s===l?null:s===n&&l===r?i:(r=l,i=t(n=s,a)))}}function Qm(e,t,o){var n,r,i;return function(){var s,a=o(this),l;return a==null?void this.removeAttributeNS(e.space,e.local):(s=this.getAttributeNS(e.space,e.local),l=a+"",s===l?null:s===n&&l===r?i:(r=l,i=t(n=s,a)))}}function Jl(e,t){var o=Nt(e),n=o==="transform"?rs:xr;return this.attrTween(e,typeof t=="function"?(o.local?Qm:Jm)(o,n,Co(this,"attr."+e,t)):t==null?(o.local?Km:$m)(o):(o.local?Zm:qm)(o,n,t))}function jm(e,t){return function(o){this.setAttribute(e,t.call(this,o))}}function eg(e,t){return function(o){this.setAttributeNS(e.space,e.local,t.call(this,o))}}function tg(e,t){var o,n;function r(){var i=t.apply(this,arguments);return i!==n&&(o=(n=i)&&eg(e,i)),o}return r._value=t,r}function og(e,t){var o,n;function r(){var i=t.apply(this,arguments);return i!==n&&(o=(n=i)&&jm(e,i)),o}return r._value=t,r}function Ql(e,t){var o="attr."+e;if(arguments.length<2)return(o=this.tween(o))&&o._value;if(t==null)return this.tween(o,null);if(typeof t!="function")throw new Error;var n=Nt(e);return this.tween(o,(n.local?tg:og)(n,t))}function ng(e,t){return function(){hn(this,e).delay=+t.apply(this,arguments)}}function rg(e,t){return t=+t,function(){hn(this,e).delay=t}}function jl(e){var t=this._id;return arguments.length?this.each((typeof e=="function"?ng:rg)(t,e)):Ce(this.node(),t).delay}function ig(e,t){return function(){ke(this,e).duration=+t.apply(this,arguments)}}function sg(e,t){return t=+t,function(){ke(this,e).duration=t}}function ec(e){var t=this._id;return arguments.length?this.each((typeof e=="function"?ig:sg)(t,e)):Ce(this.node(),t).duration}function ag(e,t){if(typeof t!="function")throw new Error;return function(){ke(this,e).ease=t}}function tc(e){var t=this._id;return arguments.length?this.each(ag(t,e)):Ce(this.node(),t).ease}function lg(e,t){return function(){var o=t.apply(this,arguments);if(typeof o!="function")throw new Error;ke(this,e).ease=o}}function oc(e){if(typeof e!="function")throw new Error;return this.each(lg(this._id,e))}function nc(e){typeof e!="function"&&(e=nn(e));for(var t=this._groups,o=t.length,n=new Array(o),r=0;r<o;++r)for(var i=t[r],s=i.length,a=n[r]=[],l,c=0;c<s;++c)(l=i[c])&&e.call(l,l.__data__,c,i)&&a.push(l);return new Be(n,this._parents,this._name,this._id)}function rc(e){if(e._id!==this._id)throw new Error;for(var t=this._groups,o=e._groups,n=t.length,r=o.length,i=Math.min(n,r),s=new Array(n),a=0;a<i;++a)for(var l=t[a],c=o[a],d=l.length,u=s[a]=new Array(d),p,m=0;m<d;++m)(p=l[m]||c[m])&&(u[m]=p);for(;a<n;++a)s[a]=t[a];return new Be(s,this._parents,this._name,this._id)}function cg(e){return(e+"").trim().split(/^|\s+/).every(function(t){var o=t.indexOf(".");return o>=0&&(t=t.slice(0,o)),!t||t==="start"})}function dg(e,t,o){var n,r,i=cg(t)?hn:ke;return function(){var s=i(this,e),a=s.on;a!==n&&(r=(n=a).copy()).on(t,o),s.on=r}}function ic(e,t){var o=this._id;return arguments.length<2?Ce(this.node(),o).on.on(e):this.each(dg(o,e,t))}function ug(e){return function(){var t=this.parentNode;for(var o in this.__transition)if(+o!==e)return;t&&t.removeChild(this)}}function sc(){return this.on("end.remove",ug(this._id))}function ac(e){var t=this._name,o=this._id;typeof e!="function"&&(e=oo(e));for(var n=this._groups,r=n.length,i=new Array(r),s=0;s<r;++s)for(var a=n[s],l=a.length,c=i[s]=new Array(l),d,u,p=0;p<l;++p)(d=a[p])&&(u=e.call(d,d.__data__,p,a))&&("__data__"in d&&(u.__data__=d.__data__),c[p]=u,Vt(c[p],t,o,p,c,Ce(d,o)));return new Be(i,this._parents,t,o)}function lc(e){var t=this._name,o=this._id;typeof e!="function"&&(e=on(e));for(var n=this._groups,r=n.length,i=[],s=[],a=0;a<r;++a)for(var l=n[a],c=l.length,d,u=0;u<c;++u)if(d=l[u]){for(var p=e.call(d,d.__data__,u,l),m,x=Ce(d,o),E=0,g=p.length;E<g;++E)(m=p[E])&&Vt(m,t,o,E,p,x);i.push(p),s.push(d)}return new Be(i,s,t,o)}var pg=wt.prototype.constructor;function cc(){return new pg(this._groups,this._parents)}function fg(e,t){var o,n,r;return function(){var i=Dt(this,e),s=(this.style.removeProperty(e),Dt(this,e));return i===s?null:i===o&&s===n?r:r=t(o=i,n=s)}}function dc(e){return function(){this.style.removeProperty(e)}}function mg(e,t,o){var n,r=o+"",i;return function(){var s=Dt(this,e);return s===r?null:s===n?i:i=t(n=s,o)}}function gg(e,t,o){var n,r,i;return function(){var s=Dt(this,e),a=o(this),l=a+"";return a==null&&(l=a=(this.style.removeProperty(e),Dt(this,e))),s===l?null:s===n&&l===r?i:(r=l,i=t(n=s,a))}}function hg(e,t){var o,n,r,i="style."+t,s="end."+i,a;return function(){var l=ke(this,e),c=l.on,d=l.value[i]==null?a||(a=dc(t)):void 0;(c!==o||r!==d)&&(n=(o=c).copy()).on(s,r=d),l.on=n}}function uc(e,t,o){var n=(e+="")=="transform"?ns:xr;return t==null?this.styleTween(e,fg(e,n)).on("end.style."+e,dc(e)):typeof t=="function"?this.styleTween(e,gg(e,n,Co(this,"style."+e,t))).each(hg(this._id,e)):this.styleTween(e,mg(e,n,t),o).on("end.style."+e,null)}function yg(e,t,o){return function(n){this.style.setProperty(e,t.call(this,n),o)}}function xg(e,t,o){var n,r;function i(){var s=t.apply(this,arguments);return s!==r&&(n=(r=s)&&yg(e,s,o)),n}return i._value=t,i}function pc(e,t,o){var n="style."+(e+="");if(arguments.length<2)return(n=this.tween(n))&&n._value;if(t==null)return this.tween(n,null);if(typeof t!="function")throw new Error;return this.tween(n,xg(e,t,o==null?"":o))}function Eg(e){return function(){this.textContent=e}}function _g(e){return function(){var t=e(this);this.textContent=t==null?"":t}}function fc(e){return this.tween("text",typeof e=="function"?_g(Co(this,"text",e)):Eg(e==null?"":e+""))}function bg(e){return function(t){this.textContent=e.call(this,t)}}function Tg(e){var t,o;function n(){var r=e.apply(this,arguments);return r!==o&&(t=(o=r)&&bg(r)),t}return n._value=e,n}function mc(e){var t="text";if(arguments.length<1)return(t=this.tween(t))&&t._value;if(e==null)return this.tween(t,null);if(typeof e!="function")throw new Error;return this.tween(t,Tg(e))}function gc(){for(var e=this._name,t=this._id,o=Er(),n=this._groups,r=n.length,i=0;i<r;++i)for(var s=n[i],a=s.length,l,c=0;c<a;++c)if(l=s[c]){var d=Ce(l,t);Vt(l,e,o,c,s,{time:d.time+d.delay+d.duration,delay:0,duration:d.duration,ease:d.ease})}return new Be(n,this._parents,e,o)}function hc(){var e,t,o=this,n=o._id,r=o.size();return new Promise(function(i,s){var a={value:s},l={value:function(){--r===0&&i()}};o.each(function(){var c=ke(this,n),d=c.on;d!==e&&(t=(e=d).copy(),t._.cancel.push(a),t._.interrupt.push(a),t._.end.push(l)),c.on=t}),r===0&&i()})}var vg=0;function Be(e,t,o,n){this._groups=e,this._parents=t,this._name=o,this._id=n}function yc(e){return wt().transition(e)}function Er(){return++vg}var It=wt.prototype;Be.prototype=yc.prototype={constructor:Be,select:ac,selectAll:lc,selectChild:It.selectChild,selectChildren:It.selectChildren,filter:nc,merge:rc,selection:cc,transition:gc,call:It.call,nodes:It.nodes,node:It.node,size:It.size,empty:It.empty,each:It.each,on:ic,attr:Jl,attrTween:Ql,style:uc,styleTween:pc,text:fc,textTween:mc,remove:sc,tween:Zl,delay:jl,duration:ec,ease:tc,easeVarying:oc,end:hc,[Symbol.iterator]:It[Symbol.iterator]};function _r(e){return((e*=2)<=1?e*e*e:(e-=2)*e*e+2)/2}var Ng={time:null,delay:0,duration:250,ease:_r};function wg(e,t){for(var o;!(o=e.__transition)||!(o=o[t]);)if(!(e=e.parentNode))throw new Error(`transition ${t} not found`);return o}function xc(e){var t,o;e instanceof Be?(t=e._id,e=e._name):(t=Er(),(o=Ng).time=mn(),e=e==null?null:e+"");for(var n=this._groups,r=n.length,i=0;i<r;++i)for(var s=n[i],a=s.length,l,c=0;c<a;++c)(l=s[c])&&Vt(l,e,t,c,s,o||wg(l,t));return new Be(n,this._parents,e,t)}wt.prototype.interrupt=ql;wt.prototype.transition=xc;function Ht(e,t,o){this.k=e,this.x=t,this.y=o}Ht.prototype={constructor:Ht,scale:function(e){return e===1?this:new Ht(this.k*e,this.x,this.y)},translate:function(e,t){return e===0&t===0?this:new Ht(this.k,this.x+this.k*e,this.y+this.k*t)},apply:function(e){return[e[0]*this.k+this.x,e[1]*this.k+this.y]},applyX:function(e){return e*this.k+this.x},applyY:function(e){return e*this.k+this.y},invert:function(e){return[(e[0]-this.x)/this.k,(e[1]-this.y)/this.k]},invertX:function(e){return(e-this.x)/this.k},invertY:function(e){return(e-this.y)/this.k},rescaleX:function(e){return e.copy().domain(e.range().map(this.invertX,this).map(e.invert,e))},rescaleY:function(e){return e.copy().domain(e.range().map(this.invertY,this).map(e.invert,e))},toString:function(){return"translate("+this.x+","+this.y+") scale("+this.k+")"}};var br=new Ht(1,0,0);Tr.prototype=Ht.prototype;function Tr(e){for(;!e.__zoom;)if(!(e=e.parentNode))return br;return e.__zoom}var Ag=[[Number.NEGATIVE_INFINITY,Number.NEGATIVE_INFINITY],[Number.POSITIVE_INFINITY,Number.POSITIVE_INFINITY]];var Ec;(function(e){e.Strict="strict",e.Loose="loose"})(Ec||(Ec={}));var _c;(function(e){e.Free="free",e.Vertical="vertical",e.Horizontal="horizontal"})(_c||(_c={}));var bc;(function(e){e.Partial="partial",e.Full="full"})(bc||(bc={}));var Tc;(function(e){e.Bezier="default",e.Straight="straight",e.Step="step",e.SmoothStep="smoothstep",e.SimpleBezier="simplebezier"})(Tc||(Tc={}));var vc;(function(e){e.Arrow="arrow",e.ArrowClosed="arrowclosed"})(vc||(vc={}));var Ue;(function(e){e.Left="left",e.Top="top",e.Right="right",e.Bottom="bottom"})(Ue||(Ue={}));var NI={[Ue.Left]:Ue.Right,[Ue.Right]:Ue.Left,[Ue.Top]:Ue.Bottom,[Ue.Bottom]:Ue.Top};var Cg=e=>"id"in e&&"internals"in e&&!("source"in e)&&!("target"in e);var Sg=(e,t=[0,0])=>{var a;let{width:o,height:n}=Mg(e),r=(a=e.origin)!=null?a:t,i=o*r[0],s=n*r[1];return{x:e.position.x-i,y:e.position.y-s}};var vr=(e,t=[0,0])=>{var r,i,s,a,l,c,d,u;let{x:o,y:n}=Cg(e)?e.internals.positionAbsolute:Sg(e,t);return{x:o,y:n,x2:o+((a=(s=(i=(r=e.measured)==null?void 0:r.width)!=null?i:e.width)!=null?s:e.initialWidth)!=null?a:0),y2:n+((u=(d=(c=(l=e.measured)==null?void 0:l.height)!=null?c:e.height)!=null?d:e.initialHeight)!=null?u:0)}};function Mg(e){var t,o,n,r,i,s,a,l;return{width:(r=(n=(o=(t=e.measured)==null?void 0:t.width)!=null?o:e.width)!=null?n:e.initialWidth)!=null?r:0,height:(l=(a=(s=(i=e.measured)==null?void 0:i.height)!=null?s:e.height)!=null?a:e.initialHeight)!=null?l:0}}var wI={[Ue.Left]:{x:-1,y:0},[Ue.Right]:{x:1,y:0},[Ue.Top]:{x:0,y:-1},[Ue.Bottom]:{x:0,y:1}};var Pg={nodeOrigin:[0,0],nodeExtent:Ag,elevateNodesOnSelect:!0,defaults:{}},II=w(_({},Pg),{checkEquality:!0});var Nc;(function(e){e.Line="line",e.Handle="handle"})(Nc||(Nc={}));var Lg={width:0,height:0,x:0,y:0},AI=w(_({},Lg),{pointerX:0,pointerY:0,aspectRatio:1});var kg=(e,t)=>e.x<t.x2&&e.x2>t.x&&e.y<t.y2&&e.y2>t.y;function Rg(e,t){let o=Math.max(0,Math.min(e.x2,t.x2)-Math.max(e.x,t.x)),n=Math.max(0,Math.min(e.y2,t.y2)-Math.max(e.y,t.y));return o*n}function Dg(e,t){let o=Math.max(0,Math.max(e.x-t.x2,t.x-e.x2)),n=Math.max(0,Math.max(e.y-t.y2,t.y-e.y2));return Math.sqrt(o*o+n*n)}var Nr=class{constructor(){this.xLines=[];this.yLines=[]}initialize(t){this.xLines=t.filter(o=>o.orientation==="vertical"),this.yLines=t.filter(o=>o.orientation==="horizontal"),this.xLines.sort((o,n)=>o.position-n.position),this.yLines.sort((o,n)=>o.position-n.position),this.lastHorizontalLine=void 0,this.lastVerticalLine=void 0}search(t,o,n,r,i){let s=t==="horizontal"?this.yLines:this.xLines,[a,l]=t==="horizontal"?[r.y,r.y2]:[r.x,r.x2],c=[];for(let m of s){if(m.position<a)continue;if(m.position>l)break;if(i.has(m.node.id)||m.node.parentId&&i.has(m.node.parentId)||!kg(m.nodeBox,r))continue;let x=Math.abs(m.position-o);if(x>wr)continue;let g=Rg(m.nodeBox,n)>0?0:Dg(m.nodeBox,n);c.push({line:m,lineDist:x,nodeDist:g})}let d=.5,u=t==="horizontal"?this.lastHorizontalLine:this.lastVerticalLine;c.sort((m,x)=>{if(u){if(m.line===u&&x.line!==u)return-1;if(x.line===u&&m.line!==u)return 1}return Math.abs(m.lineDist-x.lineDist)<=d?m.nodeDist-x.nodeDist:m.lineDist-x.lineDist});let p=c.length>0?c[0].line:void 0;return p&&(t==="horizontal"?this.lastHorizontalLine=p:this.lastVerticalLine=p),p}};function wc(e,t=so,o){let n=[];return e==null||e.forEach(r=>{let i=o(r.id);if(!i)throw new Error(`Node with id ${r.id} not found in internal nodes.`);let s=vr(i);Object.entries(t).forEach(([a,l])=>{var c;n.push({position:l.resolve(r,s),color:(c=r.style)==null?void 0:c.backgroundColor,orientation:l.orientation,anchorName:a,nodeBox:s,node:r})})}),n}function Ic(e,t,o,n,r=Object.keys(so)){let i=[];for(let a of r){let l=so[a],c=l.resolve(null,o),d=e.search(l.orientation,c,o,t,n);d&&i.push({sourcePosition:c,anchorName:a,anchor:l,line:d})}let s={horizontal:void 0,vertical:void 0};for(let a of i){let l=s[a.anchor.orientation],c=Math.abs(a.sourcePosition-a.line.position);(!l||c<Math.abs(l.sourcePosition-l.line.position))&&(s[a.anchor.orientation]=a)}return s}function Ac(e,t,o){let n=0,r=0,i=!1,s=!1;if(t){let l=t.anchor.resolve(null,e)-t.line.position;Math.abs(l)<=wr&&(r=l,s=!0)}if(o){let l=o.anchor.resolve(null,e)-o.line.position;Math.abs(l)<=wr&&(n=l,i=!0)}return{deltaX:n,deltaY:r,snappedX:i,snappedY:s}}var wr=10,so={top:{orientation:"horizontal",resolve:(e,t)=>t.y},bottom:{orientation:"horizontal",resolve:(e,t)=>t.y2},left:{orientation:"vertical",resolve:(e,t)=>t.x},right:{orientation:"vertical",resolve:(e,t)=>t.x2},centerX:{orientation:"vertical",resolve:(e,t)=>(t.x+t.x2)/2},centerY:{orientation:"horizontal",resolve:(e,t)=>(t.y+t.y2)/2}};import{jsx as $g}from"react/jsx-runtime";var Yg=new Nr;function Fg(e,t,o,n){var d,u,p,m,x,E;let r=1/0,i=1/0,s=-1/0,a=-1/0,l=new Set;for(let g of e){let h=t.find(N=>N.id===g.id);if(!h)continue;l.add(h.id);let f=o(h.id);if(!f)continue;let y=f.parentId?o(f.parentId):void 0,T=g.position.x+((d=y==null?void 0:y.internals.positionAbsolute.x)!=null?d:0),b=g.position.y+((u=y==null?void 0:y.internals.positionAbsolute.y)!=null?u:0),I=(m=(p=h.measured)==null?void 0:p.width)!=null?m:0,v=(E=(x=h.measured)==null?void 0:x.height)!=null?E:0;r=Math.min(r,T),i=Math.min(i,b),s=Math.max(s,T+I),a=Math.max(a,b+v)}if(r===1/0)return null;let c=Object.keys(so);return{bounds:{x:r,y:i,x2:s,y2:a},excludedNodeIds:l,anchors:n?["top","left"]:c}}function Wg(e,t,o){var c,d,u,p,m,x,E,g;let n=t.find(h=>h.id===e.id);if(!n)return null;let r=o(n.id);if(!r)return null;let i=r.internals.positionAbsolute.x,s=r.internals.positionAbsolute.y,a=(p=(u=(c=e.dimensions)==null?void 0:c.width)!=null?u:(d=n.measured)==null?void 0:d.width)!=null?p:0,l=(g=(E=(m=e.dimensions)==null?void 0:m.height)!=null?E:(x=n.measured)==null?void 0:x.height)!=null?g:0;return{bounds:{x:i,y:s,x2:i+a,y2:s+l},excludedNodeIds:new Set([n.id]),anchors:["right","bottom"]}}function Xg(e,t,o,n){return e.length>0?Fg(e,o,n,!!t):t?Wg(t,o,n):null}function Sc(e,t,o,n){var r;e!=null&&e.dimensions&&(e.id===((r=t[0])==null?void 0:r.id)?e.dimensions[o]+=n:t.length||(e.dimensions[o]-=n))}function Ug(e,t,o,n,r,i){r&&(e.forEach(s=>{s.position&&(s.position.x-=o)}),Sc(t,e,"width",o)),i&&(e.forEach(s=>{s.position&&(s.position.y-=n)}),Sc(t,e,"height",n))}function Ir(){let[e,t]=Cc(void 0),[o,n]=Cc(void 0),{width:r,height:i}=Hg(g=>({width:g.width,height:g.height}),zg),s=Og(),a=Bg(Yg),{screenToFlowPosition:l,getInternalNode:c,getNodes:d}=Vg(),u=yn(()=>{t(void 0),n(void 0)},[]),p=yn(g=>{let h=g!=null?g:d();u();let f=wc(h,so,c);a.current.initialize(f)},[c,u,d]),m=yn(()=>{setTimeout(()=>{p()},100)},[p]);Gg(()=>{s&&p(d())},[s,p,d]);let x=yn((g,h)=>{if(!a.current||g.length===0)return;let f=g.filter(A=>A.type==="dimensions");if(f.length>1)return;u();let y=g.filter(A=>A.type==="position"&&!!A.position),T=f[0];if(y.length===0&&!T)return;let b=Xg(y,T,h,c);if(!b)return;let{x:I,y:v}=l({x:0,y:0}),{x:N,y:C}=l({x:r,y:i}),M={x:I,y:v,x2:N,y2:C},{horizontal:L,vertical:D}=Ic(a.current,M,b.bounds,b.excludedNodeIds,b.anchors),{deltaX:O,deltaY:V,snappedX:F,snappedY:j}=Ac(b.bounds,L,D);if(!F&&!j)return;let q=y.some(A=>A.dragging),$=!!(T!=null&&T.resizing);(q||$)&&(F&&n(D==null?void 0:D.line),j&&t(L==null?void 0:L.line)),Ug(y,T,O,V,F,j)},[l,c,r,i,t,n,u]),E=yn(()=>$g(Mc,{horizontal:e,vertical:o}),[e,o]);return{rebuildIndex:p,forceRebuildIndex:m,updateHelperLines:x,helperLineHorizontal:e,helperLineVertical:o,HelperLines:E}}import{reconnectEdge as nx,useReactFlow as rx}from"@xyflow/react";import{useCallback as mo,useRef as ix}from"react";var At=e=>new Map(e.map(t=>[t.id,t])),xn=(e,t,o)=>t.filter(n=>!(n.source!==e||o&&n.id===o)),Pc=(e,t,o)=>t.filter(n=>!(n.target!==e||o&&n.id===o)),as=e=>e.some(t=>t.type==="START_EVENT"),So=(e,t)=>e==="START_EVENT"?!as(t):!0,Lc=(e,t,o,n,r)=>{let i=At(o),s=i.get(e);if(!s||s.type!=="START_EVENT")return!1;let a=i.get(t);return(a==null?void 0:a.type)==="ANNOTATION"?!1:xn(e,n,r).filter(c=>{let d=i.get(c.target);return(d==null?void 0:d.type)!=="ANNOTATION"}).length>=1},kc=(e,t,o,n,r)=>{let i=At(o),s=i.get(t);if(!s||s.type!=="END_EVENT")return!1;let a=i.get(e);return(a==null?void 0:a.type)==="ANNOTATION"?!1:Pc(t,n,r).filter(c=>{let d=i.get(c.source);return(d==null?void 0:d.type)!=="ANNOTATION"}).length>=1},Ar=(e,t,o,n,r)=>{var c;let i=At(o),s=i.get(e);if(!s||s.type!=="GATEWAY"||((c=s.data)==null?void 0:c.variant)!=="EXCLUSIVE")return!1;let a=t?i.get(t):null;return(a==null?void 0:a.type)==="ANNOTATION"?!1:xn(e,n,r).filter(d=>{let u=i.get(d.target);return(u==null?void 0:u.type)!=="ANNOTATION"}).length>=2},Rc=(e,t,o)=>{var s,a,l,c;let n=At(o),r=n.get(e),i=n.get(t);return(r==null?void 0:r.type)!=="GATEWAY"||(i==null?void 0:i.type)!=="GATEWAY"||((s=r==null?void 0:r.data)==null?void 0:s.variant)==="EXCLUSIVE"&&((a=i==null?void 0:i.data)==null?void 0:a.variant)==="PARALLEL"||((l=r==null?void 0:r.data)==null?void 0:l.variant)==="COMPLEX"&&((c=i==null?void 0:i.data)==null?void 0:c.variant)==="PARALLEL"},Cr=(e,t)=>{var n;let o=t.find(r=>r.id===e);return!o||o.type!=="TASK"?!1:((n=o.data)==null?void 0:n.variant)==="SCRIPT"},Dc=(e,t)=>{var n;let o=t.find(r=>r.id===e);return!o||o.type!=="TASK"?!1:((n=o.data)==null?void 0:n.variant)==="SUBPROCESS"},En=(e,t)=>{var n;let o=t.find(r=>r.id===e);return!o||o.type!=="TASK"?!1:((n=o.data)==null?void 0:n.variant)==="SERVICE_TASK"},Sr=(e,t)=>{var n;let o=t.find(r=>r.id===e);return!o||o.type!=="TASK"?!1:((n=o.data)==null?void 0:n.attribute)==="LOOP"},ao=(e,t,o,n)=>{let r=At(t),i=r.get(e);return!i||i.type!=="TASK"?!1:Pc(e,o,n).some(a=>{let l=r.get(a.source);return(l==null?void 0:l.type)==="START_EVENT"})},_n=(e,t,o,n)=>{let r=At(t),i=r.get(e);return!i||i.type!=="TASK"?!1:xn(e,o,n).some(a=>{let l=r.get(a.target);return(l==null?void 0:l.type)==="END_EVENT"})},Oc=(e,t,o,n,r)=>{let i=At(o),s=i.get(e),a=i.get(t);return(s==null?void 0:s.type)==="START_EVENT"&&(a==null?void 0:a.type)==="TASK"?_n(t,o,n,r):(a==null?void 0:a.type)==="END_EVENT"&&(s==null?void 0:s.type)==="TASK"?ao(e,o,n,r):!1},Mr=(e,t,o)=>xn(e,t,o).length>0,Pr=(e,t,o,n,r)=>{let i=At(o),s=i.get(e);if(!s||s.type!=="TASK")return!1;let a=t?i.get(t):null;return(a==null?void 0:a.type)==="ANNOTATION"?!1:xn(e,n,r).filter(c=>{let d=i.get(c.target);return(d==null?void 0:d.type)!=="ANNOTATION"}).length>=2};var Vc=(e,t,o,n,r)=>{var a,l;let i=At(n),s=((a=i.get(e))==null?void 0:a.type)==="ANNOTATION"||((l=i.get(t))==null?void 0:l.type)==="ANNOTATION";return o.some(c=>r&&c.id===r?!1:!!(c.source===e&&c.target===t||s&&c.source===t&&c.target===e))};var Kg=[e=>({isValid:e.sourceNodeId!==e.targetNodeId,reason:"self_connection_not_allowed"}),e=>({isValid:!Vc(e.sourceNodeId,e.targetNodeId,e.edges,e.nodes,e.reconnectingEdgeId),reason:"duplicate_connection_not_allowed"}),e=>({isValid:!Lc(e.sourceNodeId,e.targetNodeId,e.nodes,e.edges,e.reconnectingEdgeId),reason:"start_event_limit_reached"}),e=>({isValid:!kc(e.sourceNodeId,e.targetNodeId,e.nodes,e.edges,e.reconnectingEdgeId),reason:"end_event_limit_reached"}),e=>({isValid:!Ar(e.sourceNodeId,e.targetNodeId,e.nodes,e.edges,e.reconnectingEdgeId),reason:"gateway_limit_reached"}),e=>({isValid:!Pr(e.sourceNodeId,e.targetNodeId,e.nodes,e.edges,e.reconnectingEdgeId),reason:"task_limit_reached"}),e=>({isValid:Rc(e.sourceNodeId,e.targetNodeId,e.nodes),reason:"gateway_to_gateway_not_allowed"}),e=>({isValid:!(e.sourceNodeType==="START_EVENT"&&e.targetNodeType==="END_EVENT"),reason:"start_to_end_not_allowed"}),e=>({isValid:!(e.sourceNodeType==="START_EVENT"&&Dc(e.targetNodeId,e.nodes)),reason:"start_event_to_subprocess_not_allowed"}),e=>({isValid:!(e.sourceNodeType==="START_EVENT"&&En(e.targetNodeId,e.nodes)),reason:"start_event_to_service_task_not_allowed"}),e=>({isValid:!(En(e.sourceNodeId,e.nodes)&&e.targetNodeType==="END_EVENT"),reason:"service_task_to_end_not_allowed"}),e=>({isValid:!(e.sourceNodeType==="GATEWAY"&&e.targetNodeType==="END_EVENT"),reason:"gateway_to_end_not_allowed"}),e=>({isValid:!(e.sourceNodeType==="START_EVENT"&&e.targetNodeType==="GATEWAY"),reason:"start_to_gateway_not_allowed"}),e=>({isValid:!(Cr(e.sourceNodeId,e.nodes)&&e.targetNodeType==="END_EVENT"),reason:"script_to_end_not_allowed"}),e=>({isValid:!(Sr(e.sourceNodeId,e.nodes)&&e.targetNodeType==="END_EVENT"),reason:"loop_to_end_not_allowed"}),e=>({isValid:!(ao(e.sourceNodeId,e.nodes,e.edges,e.reconnectingEdgeId)&&e.targetNodeType==="END_EVENT"),reason:"initial_activity_to_end_not_allowed"}),e=>({isValid:!Oc(e.sourceNodeId,e.targetNodeId,e.nodes,e.edges,e.reconnectingEdgeId),reason:"concurrent_initial_and_final_activity"}),e=>({isValid:!(_n(e.sourceNodeId,e.nodes,e.edges,e.reconnectingEdgeId)&&e.targetNodeType!=="ANNOTATION"),reason:"final_activity_cannot_connect"}),e=>({isValid:!(Mr(e.sourceNodeId,e.edges,e.reconnectingEdgeId)&&e.targetNodeType==="END_EVENT"),reason:"activity_has_outgoing_connections"}),e=>({isValid:({START_EVENT:["TASK","ANNOTATION"],END_EVENT:["ANNOTATION"],TASK:["TASK","END_EVENT","GATEWAY","ANNOTATION"],GATEWAY:["TASK","END_EVENT","ANNOTATION","GATEWAY"],LANE:["ANNOTATION"],ANNOTATION:["START_EVENT","END_EVENT","TASK","GATEWAY","LANE"],UNSUPPORTED:[]}[e.sourceNodeType]||[]).includes(e.targetNodeType),reason:"connection_type_not_allowed"})],ls=e=>{for(let t of Kg){let o=t(e);if(!o.isValid)return o}return{isValid:!0}};var qg=[{sourceTypes:["GATEWAY"],targetTypes:["TASK","GATEWAY"],validate:e=>({shouldDisable:Ar(e.sourceNodeId,null,e.nodes,e.edges)&&e.targetNodeType!=="ANNOTATION",reason:"gateway_limit_reached"})},{sourceTypes:["START_EVENT"],validate:e=>({shouldDisable:e.edges.some(o=>{if(o.source!==e.sourceNodeId)return!1;let n=e.nodes.find(r=>r.id===o.target);return(n==null?void 0:n.type)!=="ANNOTATION"})&&e.targetNodeType!=="ANNOTATION",reason:"start_event_limit_reached"})},{targetTypes:["START_EVENT"],validate:e=>({shouldDisable:as(e.nodes),reason:"start_event_already_exists"})},{sourceTypes:["TASK"],targetTypes:["END_EVENT"],validate:e=>({shouldDisable:Cr(e.sourceNodeId,e.nodes),reason:"script_to_end_not_allowed"})},{sourceTypes:["TASK"],targetTypes:["END_EVENT"],validate:e=>({shouldDisable:Sr(e.sourceNodeId,e.nodes),reason:"loop_to_end_not_allowed"})},{sourceTypes:["TASK"],targetTypes:["END_EVENT"],validate:e=>({shouldDisable:En(e.sourceNodeId,e.nodes),reason:"service_task_to_end_not_allowed"})},{sourceTypes:["TASK"],targetTypes:["END_EVENT"],validate:e=>({shouldDisable:ao(e.sourceNodeId,e.nodes,e.edges),reason:"initial_activity_to_end_not_allowed"})},{sourceTypes:["TASK"],validate:e=>({shouldDisable:_n(e.sourceNodeId,e.nodes,e.edges)&&e.targetNodeType!=="ANNOTATION",reason:"final_activity_cannot_connect"})},{targetTypes:["END_EVENT"],validate:e=>({shouldDisable:Mr(e.sourceNodeId,e.edges),reason:"activity_has_outgoing_connections"})},{sourceTypes:["TASK"],validate:e=>({shouldDisable:Pr(e.sourceNodeId,null,e.nodes,e.edges)&&e.targetNodeType!=="ANNOTATION",reason:"task_limit_reached"})}],Hc=e=>{let t=qg.filter(o=>{let n=!o.sourceTypes||o.sourceTypes.includes(e.sourceNodeType),r=!o.targetTypes||o.targetTypes.includes(e.targetNodeType);return n&&r});for(let o of t){let n=o.validate(e);if(n.shouldDisable)return n}return{shouldDisable:!1}};import{BaseEdge as Ih,EdgeLabelRenderer as Ah,getStraightPath as Ch,useInternalNode as Bc,useViewport as Sh}from"@xyflow/react";import{useCallback as Zg}from"react";import{useStore as Jg}from"@xyflow/react";function Et(){return Jg(Zg(e=>e.nodes.filter(o=>o.selected).length+e.edges.filter(o=>o.selected).length>=2,[]))}import{Button as jg,Tooltip as eh,TooltipContent as th,TooltipTrigger as oh,useTranslation as nh}from"@produto-lecom/lecom-ui";import{Settings as rh}from"lucide-react";import{getIncomers as Lr,getOutgoers as kr,useReactFlow as Qg}from"@xyflow/react";var Rr=()=>{let{getNode:e,getEdge:t,getNodes:o,getEdges:n}=Qg(),{selectElements:r}=yt(),i=g=>{let h=o(),f=n(),y=Lr(g,h,f),T=kr(g,h,f),b=y.some(v=>v.type==="START_EVENT"),I=T.some(v=>v.type==="END_EVENT");return b?"start":I?"end":"between"},s=(g,h,f)=>{var b,I,v,N,C;if(!g)return;let y={type:g.type,variant:(b=g.data)==null?void 0:b.variant,attribute:(I=g.data)==null?void 0:I.attribute},T={id:g.id,position:i(g),label:(v=g.data)==null?void 0:v.label,node:y};return g.type==="TASK"&&((N=g.data)==null?void 0:N.variant)==="SUBPROCESS"?w(_({},T),{type:"sub_process"}):g.type==="TASK"&&((C=g.data)==null?void 0:C.variant)==="SERVICE_TASK"?w(_({},T),{type:"service_task"}):g.type==="GATEWAY"?w(_({},T),{type:"gateway",variant:a(g,h,f)}):w(_({},T),{type:"activity"})},a=(g,h,f)=>{if(g.type!=="GATEWAY")return;let y=Lr(g,h,f),T=!1,b=!1;if(y.forEach(I=>{var v,N;I.type==="TASK"&&(((v=I.data)==null?void 0:v.variant)==="SCRIPT"&&(T=!0),((N=I.data)==null?void 0:N.attribute)==="LOOP"&&(b=!0))}),T&&b)return"script_loop";if(T)return"script";if(b)return"loop"},l=(g,h,f)=>{var v,N,C,M;let y=e(g.source),T=e(g.target);if(!y||!T)return"simple";if(kr(y,h,f).some(L=>L.type==="END_EVENT"))return"final";if(y.type==="GATEWAY")switch((v=y.data)==null?void 0:v.variant){case"PARALLEL":return"parallel";case"EXCLUSIVE":return"exclusive";case"COMPLEX":return"complex";default:return"simple"}if(y.type==="TASK"){let L=(N=y.data)==null?void 0:N.variant,D=(C=y.data)==null?void 0:C.attribute;if(L==="SUBPROCESS")return"from_sub_process";if(T.type==="TASK"&&((M=T.data)==null?void 0:M.variant)==="SUBPROCESS")return"to_sub_process";if(L==="SERVICE_TASK")return"from_service_task";let O=L==="SCRIPT",V=D==="LOOP";return O&&V?"script_loop":O?"script":V?"loop":"simple"}return"simple"},c=(g,h,f)=>{let y=[];function T(I,v,N=0){let C=s(I,h,f);if(C.depth=N,v.push(C),I.type==="TASK"){y.push([...v]),v.pop();return}let M=Lr(I,h,f);if(M.length)for(let L of M)T(L,v,N+1);v.pop()}let b=Lr(g,h,f);for(let I of b)T(I,[]);return y},d=(g,h,f)=>{let y=[];function T(I,v,N=0){let C=s(I,h,f);if(C.depth=N,v.push(C),I.type==="TASK"){y.push([...v]),v.pop();return}let M=kr(I,h,f);if(M.length)for(let L of M)T(L,v,N+1);v.pop()}let b=kr(g,h,f);for(let I of b)T(I,[]);return y},u=(g,h,f)=>(f=f.filter(T=>T.source===g.id),f.map(T=>{var v;let b=e(T.target),I;return b&&(I=s(b,h,f)),{id:T.id,type:"routing",variant:l(T,h,f),label:(v=T.data)==null?void 0:v.label,target:I}})),p=g=>{let h=e(g);if(!h)return;let f=o(),y=n(),T=s(h,f,y);return T.sources=c(h,f,y),T.targets=d(h,f,y),T.edgeTargets=u(h,f,y),h.type==="GATEWAY"&&(T.variant=a(h,f,y)),T},m=g=>{let h=t(g);if(!h)return;let f=o(),y=n(),T=l(h,f,y),I={id:h.id,type:"routing",variant:T,gatewayVariant:void 0},v=e(h.source);if(v){let C=s(v,f,y);I.source=C;let M=a(v,f,y);if(I.gatewayVariant=M,v.type==="TASK")I.sources=[[C]];else{let L=c(v,f,y);I.sources=L.length?L:[[C]]}}let N=e(h.target);if(N){let C=s(N,f,y);if(I.target=C,N.type==="TASK")I.targets=[[C]];else{let M=d(N,f,y);I.targets=M.length?M:[[C]]}}return I},x=g=>{let h=e(g);if(h)return p(h.id);let f=t(g);if(f)return m(f.id)};return{configureElement:g=>{let h=x(g);if(h)return r([g]),h},getConfigureElement:x,getNodeConfigure:p,getEdgeConfigure:m}};import{jsx as Dr,jsxs as sh}from"react/jsx-runtime";var ih={node:"editor.toolbar.configure_node",edge:"editor.toolbar.configure_edge",gateway:"editor.toolbar.configure_gateway"},Gt=({elementId:e,elementType:t="node"})=>{let{t:o}=nh(),{onConfigureElement:n}=U(),{getConfigureElement:r}=Rr();return sh(eh,{children:[Dr(oh,{asChild:!0,children:Dr(jg,{variant:"ghost",color:"grey",size:"small",iconButton:!0,onClick:()=>{let s=r(e);s&&(n==null||n(s))},children:Dr(rh,{size:16})})}),Dr(th,{color:"black",children:o(ih[t])})]})};import{Button as lh,Tooltip as ch,TooltipContent as dh,TooltipTrigger as uh,useTranslation as ph}from"@produto-lecom/lecom-ui";import{useReactFlow as fh}from"@xyflow/react";import{TrashIcon as mh}from"lucide-react";import{useNotificationToast as ah}from"@produto-lecom/lecom-ui";function Pe(){let{toast:e}=bn(),{toast:t}=ah();return{toast:e||t}}import{jsx as Or,jsxs as gh}from"react/jsx-runtime";var Vr=({elementId:e,elementType:t="node"})=>{let{t:o}=ph(),{toast:n}=Pe(),{deleteElements:r,getNodes:i}=fh(),{isRemovingElements:s}=U();return gh(ch,{children:[Or(uh,{asChild:!0,children:Or(lh,{variant:"ghost",color:"destructive",size:"small",iconButton:!0,onClick:()=>{if(!s)if(t==="node"){let l=i(),c=l.find(d=>d.id===e);if((c==null?void 0:c.type)==="LANE"&&l.some(u=>u.parentId===e)){n({variant:"error",title:o("validation.errors.title"),content:o("editor.toolbar.delete_pool_lane_error")});return}r({nodes:[{id:e}]})}else r({edges:[{id:e}]})},disabled:s,children:Or(mh,{size:16})})}),Or(dh,{color:"black",children:o(s?"editor.toolbar.deleting":"editor.toolbar.delete")})]})};import{Button as hh,Tooltip as yh,TooltipContent as xh,TooltipTrigger as Eh,useTranslation as _h}from"@produto-lecom/lecom-ui";import{MoveUpRightIcon as bh}from"lucide-react";import{useCallback as Th}from"react";import{jsx as Hr,jsxs as vh}from"react/jsx-runtime";var Mo=({nodeId:e,disabled:t=!1,tooltipMessage:o})=>{let{t:n}=_h(),r=Th(i=>{i.stopPropagation();let s=document.querySelectorAll(`.react-flow__handle.source[data-nodeid="${e}"]`);if(s.length===0)return;let a=Array.from(s).reduce((p,m)=>{let x=p.getBoundingClientRect(),E=m.getBoundingClientRect(),g=Math.hypot(i.clientX-(x.left+x.width/2),i.clientY-(x.top+x.height/2));return Math.hypot(i.clientX-(E.left+E.width/2),i.clientY-(E.top+E.height/2))<g?m:p}),l=a.getBoundingClientRect(),c=l.left+l.width/2,d=l.top+l.height/2,u=new MouseEvent("mousedown",{clientX:c,clientY:d,bubbles:!0,cancelable:!0});a.dispatchEvent(u)},[e]);return vh(yh,{children:[Hr(Eh,{asChild:!0,children:Hr(hh,{variant:"ghost",color:"grey",size:"small",iconButton:!0,disabled:t,className:t?"opacity-50 cursor-not-allowed":"",onMouseDown:t?void 0:r,children:Hr(bh,{size:16})})}),Hr(xh,{color:"black",children:o||n("editor.toolbar.connect_node")})]})};import{jsx as Tn}from"react/jsx-runtime";var Po=i=>{var s=i,{edgeId:e,edgeType:t,sourceNode:o,targetNode:n}=s,r=gt(s,["edgeId","edgeType","sourceNode","targetNode"]);let{mode:a}=U(),{isFromStartEvent:l,isGatewayToGateway:c,isActiviyToAndGateway:d,isToEndEvent:u}=$n(o,n),p=!l&&!c&&!d&&!u,m=[{component:Tn(Vr,{elementId:e,elementType:"edge"})}],x=()=>a==="view"?p?[{component:Tn(Gt,{elementId:e,elementType:"edge"})}]:[]:p?[{component:Tn(Gt,{elementId:e,elementType:"edge"})},...m]:m,g=(h=>{switch(h){case"SEQUENCE_EDGE":return x();case"MESSAGE_EDGE":return a==="view"?[]:[...m];case"ANNOTATION_EDGE":return a==="view"?[]:[...m];default:return[]}})(t);if(!(g.length===0||a==="readonly"))return Tn("div",w(_({className:"flex items-center gap-1 w-fit px-3 py-2 bg-white rounded-sm shadow-md"},r),{children:g.map((h,f)=>Tn("div",{children:h.component},f))}))};import{useViewport as Nh}from"@xyflow/react";import{useMemo as wh}from"react";import{jsx as Gc}from"react/jsx-runtime";var _t=12,Lo=({sx:e,sy:t,tx:o,ty:n,hasLabel:r=!1,children:i})=>{let{zoom:s}=Nh(),a=1/s,l=wh(()=>t===n?{bottom:`${_t}px`,transform:"translateX(-50%)"}:e===o?{left:`${_t}px`,transform:r?"translateY(-100%)":"translateY(-50%)"}:n>t&&o>e?{left:`${_t}px`,bottom:`${_t}px`}:n>t&&o<e?{right:`${_t}px`,bottom:`${_t}px`}:t>n&&o>e?{right:`${_t}px`,bottom:`${_t}px`}:{left:`${_t}px`,bottom:`${_t}px`},[e,t,o,n,r]);return Gc("div",{style:{transform:`scale(${a})`},children:Gc("div",{className:"absolute pointer-events-auto",style:_({},l),children:i})})};import{jsx as ko,jsxs as zc}from"react/jsx-runtime";var Ro={type:"ANNOTATION_EDGE",reconnectable:!0},Yc=({id:e,source:t,target:o,selected:n,data:r})=>{let{isReadOnly:i,edgeHighlight:s}=U(),a=Et(),{zoom:l}=Sh(),c=Bc(t),d=Bc(o);if(!c||!d)return null;let{sx:u,sy:p,tx:m,ty:x}=No(c,d),[E,g,h]=Ch({sourceX:u,sourceY:p,targetX:m,targetY:x}),f=s&&(n||(c==null?void 0:c.selected)||(d==null?void 0:d.selected));return zc("g",{className:G("group bpmn-edge",{"is-highlighted":f}),children:[ko("path",{d:E,fill:"none",stroke:"transparent",strokeWidth:Math.max(12,12/l),style:{pointerEvents:"stroke",cursor:"pointer"}}),zc("g",{className:G("text-grey-500 transition-colors duration-75",{"group-hover:text-grey-800":!i,"text-blue-500 group-hover:text-blue-600":f}),children:[ko(Ih,{id:e,path:E,interactionWidth:0,strokeDasharray:4,className:G("stroke-2 stroke-current transition-[stroke] duration-75 group-hover:stroke-[2.5px]",{"stroke-red-500 hover:stroke-red-600":r==null?void 0:r.hasError,"stroke-blue-500 hover:stroke-blue-600 stroke-[3px]":f&&!(r!=null&&r.hasError)})}),ko(Ah,{children:ko("div",{className:"absolute z-[3000] pointer-events-auto flex flex-col items-center gap-1",style:{transform:`translate(-50%, -50%) translate(${g}px, ${h}px)`},children:n&&!a&&ko(Lo,{sx:u,sy:p,tx:m,ty:x,children:ko(Po,{edgeId:e,edgeType:"ANNOTATION_EDGE"})})})})]})]})};import Uh,{useState as Qc,useCallback as $r,useMemo as Kr,useEffect as $h,useRef as us}from"react";import{BaseEdge as Kh,EdgeLabelRenderer as qh,MarkerType as jc,useInternalNode as ed,useReactFlow as Zh,useStore as td,useViewport as Jh,Position as Ho}from"@xyflow/react";import{useCallback as Mh,useEffect as cs,useRef as Fc,useState as Ph}from"react";import{jsx as Xc}from"react/jsx-runtime";var ds=/[a-zA-Z0-9À-ÖØ-öø-ÿ]/,Wc=["Backspace","Delete","ArrowLeft","ArrowRight","ArrowUp","ArrowDown","Home","End","Tab","Escape","Shift"],Oe=({value:e,maxLength:t,style:o,className:n,contentClassName:r,isEditing:i,onChange:s,onBlur:a,onInput:l,onInvalidFirstCharacter:c,skipFirstCharValidation:d})=>{let u=Fc(null),p=Fc(null),[m,x]=Ph(!1);cs(()=>()=>{p.current&&clearTimeout(p.current)},[]),cs(()=>{x(i!=null?i:!1)},[i]),cs(()=>{if(m&&u.current){u.current.focus();let b=document.createRange();b.selectNodeContents(u.current);let I=window.getSelection();I&&(I.removeAllRanges(),I.addRange(b))}},[m]);let E=Mh(()=>{p.current||(c==null||c(),p.current=setTimeout(()=>{p.current=null},500))},[c]),g=b=>{b.stopPropagation(),m||x(!0)},h=b=>{let I=b.currentTarget.innerText.replace(/\n$/,""),v=t&&I.length>=t,N=window.getSelection(),C=(N==null?void 0:N.toString())||"",M=C.length>0,L=(b.ctrlKey||b.metaKey)&&!b.altKey,D=L&&b.key==="a",O=L&&b.key==="c",V=L&&b.key==="x",F=L&&b.key==="v",j=I.length===0||M&&C.length===I.length;if(!d&&j&&!ds.test(b.key)&&!Wc.includes(b.key)&&!L){b.preventDefault(),E();return}v&&!M&&(Wc.includes(b.key)||D||O||V||F||b.preventDefault())},f=b=>{b.preventDefault();let I=b.clipboardData.getData("text/plain").replace(/\r\n/g,`
2
- `).replace(/\r/g,`
3
- `),v=b.currentTarget.innerText.replace(/\n$/,""),N=window.getSelection();if(!N||N.rangeCount===0)return;let C=N.toString(),M=v.length-C.length,L=t?Math.max(0,t-M):1/0;if(L<=0&&C.length===0)return;let D=I;if(D.length>L&&(D=D.substring(0,L)),!D&&C.length===0)return;let O=N.getRangeAt(0),V=O.startOffset===0&&(O.startContainer===b.currentTarget||O.startContainer.parentNode===b.currentTarget);if(!d&&V&&D.length>0&&!ds.test(D[0])){E();return}O.deleteContents();let F=document.createTextNode(D);O.insertNode(F),O.setStartAfter(F),O.collapse(!0),N.removeAllRanges(),N.addRange(O),l==null||l(b.currentTarget.innerText.replace(/\n$/,""))},y=b=>{let I=b.currentTarget,v=I.innerText.replace(/\n$/,"");if(!d&&v.length>0&&!ds.test(v[0])){let N=v.slice(1);if(I.innerText=N,N.length>0&&I.firstChild){let C=document.createRange(),M=window.getSelection();C.setStart(I.firstChild,0),C.collapse(!0),M==null||M.removeAllRanges(),M==null||M.addRange(C)}E(),l==null||l(N);return}l==null||l(v)},T=b=>{x(!1);let I=b.currentTarget.innerText.replace(/\r\n/g,`
4
- `).replace(/\r/g,`
5
- `).trim();t&&I.length>t&&(I=I.substring(0,t)),b.currentTarget.innerText=I,a==null||a(),I!==e&&(s==null||s(I))};return Xc("div",{className:G("flex-1 p-2 self-stretch flex items-center justify-center border border-transparent overflow-hidden text-ellipsis body-medium-400 text-center rounded-sm",{"border border-dashed border-grey-400 bg-white shadow-md":m,"bg-white":e.length>0},n),style:o,onDoubleClick:g,children:Xc("div",{ref:u,className:G("outline-none whitespace-pre-wrap overflow-hidden",r,{"nodrag nopan cursor-text":m}),contentEditable:m,suppressContentEditableWarning:!0,onKeyDown:h,onPaste:f,onInput:y,onBlur:T,children:e})})};import{Position as _C}from"@xyflow/react";var pe=(e,t,o,n=1)=>Math.abs(e[o]-t[o])<n,Do=(e,t)=>Math.sqrt((t.x-e.x)**2+(t.y-e.y)**2),Gr=(e,t)=>({x:(e.x+t.x)/2,y:(e.y+t.y)/2}),Lh=(e,t,o)=>{let n=o.x-t.x,r=o.y-t.y,i=n*n+r*r;if(i===0)return Do(e,t);let s=Math.max(0,Math.min(1,((e.x-t.x)*n+(e.y-t.y)*r)/i));return Do(e,{x:t.x+s*n,y:t.y+s*r})},Uc=(e,t)=>{let o=1/0;for(let n=0;n<t.length-1;n++)o=Math.min(o,Lh(e,t[n],t[n+1]));return o};import{Position as Br}from"@xyflow/react";var Bt={OFFSET:30,TOLERANCE:1,MOVE_THRESHOLD:5,MIN_SEGMENT_LENGTH:15,PARALLEL_OFFSET:15,MAX_LABEL_DISTANCE:80};var{TOLERANCE:ce}=Bt;function kh(e,t,o){return pe(e,t,"x",ce)&&pe(t,o,"x",ce)&&pe(e,o,"x",ce)}function Rh(e,t,o){return pe(e,t,"y",ce)&&pe(t,o,"y",ce)&&pe(e,o,"y",ce)}function Dh(e,t,o){if(!kh(e,t,o))return!1;let n=t.y-e.y,r=o.y-t.y;return Math.abs(n)<ce||Math.abs(r)<ce?!1:n*r<0}function Oh(e,t,o){if(!Rh(e,t,o))return!1;let n=t.x-e.x,r=o.x-t.x;return Math.abs(n)<ce||Math.abs(r)<ce?!1:n*r<0}function Vh(e,t,o,n){let r=t.x!==0,i=t.x===-n.x&&t.y===-n.y,s=t.x===n.x&&t.y===n.y,a=120;if(i)if(r){if((o.x-e.x)*t.x>=0)return[{x:(e.x+o.x)/2,y:e.y},{x:(e.x+o.x)/2,y:o.y}];{let l=(e.y+o.y)/2,c=Math.abs(e.y-o.y)<a?Math.max(e.y,o.y)+a:l;return[{x:e.x,y:c},{x:o.x,y:c}]}}else{if((o.y-e.y)*t.y>=0)return[{x:e.x,y:(e.y+o.y)/2},{x:o.x,y:(e.y+o.y)/2}];{let l=(e.x+o.x)/2,c=Math.abs(e.x-o.x)<a?Math.max(e.x,o.x)+a:l;return[{x:c,y:e.y},{x:c,y:o.y}]}}else if(s)if(r)if((o.x-e.x)*t.x>0&&Math.abs(e.y-o.y)<a){let l=Math.max(e.y,o.y)+a,c=o.x+t.x*(a/2);return[{x:e.x,y:l},{x:c,y:l},{x:c,y:o.y}]}else{let l=t.x>0?Math.max(e.x,o.x):Math.min(e.x,o.x);return[{x:l,y:e.y},{x:l,y:o.y}]}else if((o.y-e.y)*t.y>0&&Math.abs(e.x-o.x)<a){let l=Math.max(e.x,o.x)+a,c=o.y+t.y*(a/2);return[{x:l,y:e.y},{x:l,y:c},{x:o.x,y:c}]}else{let l=t.y>0?Math.max(e.y,o.y):Math.min(e.y,o.y);return[{x:e.x,y:l},{x:o.x,y:l}]}else{let l=t.x!==0?o.x:e.x,c=t.y!==0?o.y:e.y,d=t.x!==0?(l-e.x)*t.x:(c-e.y)*t.y,u=n.x!==0?(l-o.x)*n.x:(c-o.y)*n.y;return d>=0&&u>=0?[{x:l,y:c}]:r?[{x:e.x,y:o.y}]:[{x:o.x,y:e.y}]}}function $c(e){if(e.length<=2)return e;let t=[e[0]];for(let o=1;o<e.length-1;o++){let n=t[t.length-1],r=e[o],i=e[o+1];pe(n,r,"x",ce)&&pe(r,i,"x",ce)||pe(n,r,"y",ce)&&pe(r,i,"y",ce)||t.push(r)}return t.push(e[e.length-1]),t}function zr(e){let t=[];for(let o of e){let n=t[t.length-1];(!n||Math.abs(n.x-o.x)>=ce||Math.abs(n.y-o.y)>=ce)&&t.push(o)}return t}function Hh(e){let t=[...e],o=!0;for(;o;){o=!1;for(let n=1;n<t.length-1;n++){let r=t[n-1],i=t[n],s=t[n+1];if(Dh(r,i,s)||Oh(r,i,s)){t.splice(n,1),o=!0;break}}}return t}function Kc(e){let t=zr($c([...e]));return t=Hh(t),zr($c(t))}function Yr(e){switch(e){case Br.Left:return{x:-1,y:0};case Br.Right:return{x:1,y:0};case Br.Top:return{x:0,y:-1};case Br.Bottom:return{x:0,y:1};default:return{x:0,y:0}}}function qc(e,t,o,n){let r=Bt.OFFSET,i=Bt.OFFSET;if(t.x===-n.x&&t.y===-n.y)if(t.x!==0){let s=(o.x-e.x)*t.x;s>0&&s<2*Bt.OFFSET&&(r=s/2,i=s/2)}else{let s=(o.y-e.y)*t.y;s>0&&s<2*Bt.OFFSET&&(r=s/2,i=s/2)}return{sourceOffset:r,targetOffset:i}}function Gh(e,t,o,n,r,i,s=0){let a=Yr(r),l=Yr(i),c=a.x===0?s:0,d=a.y===0?s:0,u=l.x===0?s:0,p=l.y===0?s:0,m={x:e+c,y:t+d},x={x:o+u,y:n+p},{sourceOffset:E,targetOffset:g}=qc(m,a,x,l),h={x:m.x+a.x*E,y:m.y+a.y*E},f={x:x.x+l.x*g,y:x.y+l.y*g},y=Vh(h,a,f,l),T=[m,h,...y,f,x],b=Kc(T);if(b.length===2&&Fr(m,x)>ce){let I=pe(m,h,"x",ce)&&pe(h,f,"x",ce)&&pe(f,x,"x",ce),v=pe(m,h,"y",ce)&&pe(h,f,"y",ce)&&pe(f,x,"y",ce);if(I||v){let N=v&&(f.x-h.x)*a.x<0,C=I&&(f.y-h.y)*a.y<0;if(!N&&!C)return zr([m,h,f,x])}}return b}function Wr(e,t,o,n,r,i,s,a=0){if(!(s!=null&&s.length))return Gh(e,t,o,n,r,i,a);let l=Yr(r),c=Yr(i),d=l.x===0?a:0,u=l.y===0?a:0,p=c.x===0?a:0,m=c.y===0?a:0,x={x:e+d,y:t+u},E={x:o+p,y:n+m},{sourceOffset:g,targetOffset:h}=qc(x,l,E,c),f={x:x.x+l.x*g,y:x.y+l.y*g},y={x:E.x+c.x*h,y:E.y+c.y*h},T=[...s],b=T[0],I=l.y===0;I&&Math.abs(x.y-b.y)>ce?T.unshift({x:b.x,y:x.y}):!I&&Math.abs(x.x-b.x)>ce&&T.unshift({x:x.x,y:b.y});let v=T[T.length-1],N=c.y===0,C=[];(Math.abs(v.x-y.x)>ce||Math.abs(v.y-y.y)>ce)&&(N?C.push({x:y.x,y:v.y}):C.push({x:v.x,y:y.y})),C.push(y);let M=[x,...T,...C,E],L=Kc(M);if(L.length===2&&Fr(x,E)>ce){let D=pe(x,f,"x",ce)&&pe(f,y,"x",ce)&&pe(y,E,"x",ce),O=pe(x,f,"y",ce)&&pe(f,y,"y",ce)&&pe(y,E,"y",ce);if(D||O){let V=O&&(y.x-f.x)*l.x<0,F=D&&(y.y-f.y)*l.y<0;if(!V&&!F)return zr([x,f,y,E])}}return L}var Fr=(e,t)=>Math.sqrt(Math.pow(t.x-e.x,2)+Math.pow(t.y-e.y,2));function Bh(e,t,o){return pe(e,t,"x",ce)&&pe(t,o,"x",ce)||pe(e,t,"y",ce)&&pe(t,o,"y",ce)}function zh(e,t,o,n){if(Bh(e,t,o))return`L${t.x} ${t.y}`;let r=Fr(e,t),i=Fr(t,o),s=Math.min(r/2,i/2,n);if(s<1)return`L${t.x} ${t.y}`;let a=e.x-t.x,l=e.y-t.y,c=o.x-t.x,d=o.y-t.y,u={x:a/r,y:l/r},p={x:c/i,y:d/i},m={x:t.x+u.x*s,y:t.y+u.y*s},x={x:t.x+p.x*s,y:t.y+p.y*s},E=-u.x,g=-u.y,h=p.x,f=p.y,T=E*f-g*h>0?1:0;return`L${m.x} ${m.y}A${s} ${s} 0 0 ${T} ${x.x} ${x.y}`}var Zc=(e,t=5)=>e.length<2?"":e.reduce((o,n,r)=>{let i="";return r>0&&r<e.length-1?i=zh(e[r-1],n,e[r+1],t):i=`${r===0?"M":"L"}${n.x} ${n.y}`,o+=i,o},"");import{useCallback as Oo,useEffect as Xr,useRef as vn,useState as Vo}from"react";import{useReactFlow as Yh,useStore as Fh}from"@xyflow/react";var Wh=50,Jc=.1,Xh=.6,Ur=({edgeId:e,source:t,target:o,instanceId:n,isReadOnly:r})=>{let{setEdges:i,getNode:s,getNodes:a,getEdge:l,screenToFlowPosition:c}=Yh(),{setIsDragging:d,setReconnectingEdgeId:u}=U(),p=Fh(P=>P.isValidConnection),[m,x]=Vo(null),[E,g]=Vo(null),[h,f]=Vo(null),[y,T]=Vo(null),[b,I]=Vo(null),[v,N]=Vo(!1),C=vn(null),M=vn(null),L=vn(null),D=vn(t),O=vn(o);Xr(()=>{D.current=t,O.current=o},[t,o]),Xr(()=>{C.current=m},[m]),Xr(()=>{M.current=b},[b]);let V=Oo(P=>{let k=a(),S=k.find(H=>H.id===P);if(!S)return{x:0,y:0};let B=S.position.x,Y=S.position.y,R=S.parentId;for(;R;){let H=k.find(z=>z.id===R);if(!H)break;B+=H.position.x,Y+=H.position.y,R=H.parentId}return{x:B,y:Y}},[a]),F=Oo(P=>{var R,H,z,K,Z,W;let k=a(),S=null,B=Wh,Y=k.filter(X=>X.type!=="LANE"&&X.type!=="ANNOTATION");for(let X of Y){if(X.id===e)continue;let Q=V(X.id),ee=(z=(H=(R=X.measured)==null?void 0:R.width)!=null?H:X.width)!=null?z:0,te=(W=(Z=(K=X.measured)==null?void 0:K.height)!=null?Z:X.height)!=null?W:0;if(P.x>=Q.x&&P.x<=Q.x+ee&&P.y>=Q.y&&P.y<=Q.y+te)return X.id;let ue=Math.max(Q.x-P.x,0,P.x-(Q.x+ee)),le=Math.max(Q.y-P.y,0,P.y-(Q.y+te)),ge=Math.sqrt(ue*ue+le*le);ge<B&&(B=ge,S=X.id)}return S},[a,V,e]),j=Oo((P,k)=>{var ue,le,ge,be,Re,J;let S=s(P);if(!S)return null;let B=V(P),Y=(ge=(le=(ue=S.measured)==null?void 0:ue.width)!=null?le:S.width)!=null?ge:0,R=(J=(Re=(be=S.measured)==null?void 0:be.height)!=null?Re:S.height)!=null?J:0,H=Math.abs(B.x+Y-k.x),z=Math.abs(k.x-B.x),K=Math.abs(B.y+R-k.y),Z=Math.abs(k.y-B.y),W={right:H,left:z,bottom:K,top:Z},X=Object.entries(W).reduce((se,[oe,ae])=>ae<se[1]?[oe,ae]:se,["right",W.right])[0],Q=L.current;if(Q&&Q!==X){let se=W[X],oe=W[Q],ae=Math.abs(oe-se),he=Math.min(Math.abs(oe),Math.abs(se));ae<he*Xh&&(X=Q)}let ee=X,te,fe;if(ee==="right"||ee==="left"){let oe=(Math.max(B.y,Math.min(B.y+R,k.y))-B.y)/(R||1);Math.abs(oe-.5)<Jc&&(oe=.5),fe=oe,te={x:ee==="right"?B.x+Y:B.x,y:B.y+fe*R}}else{let oe=(Math.max(B.x,Math.min(B.x+Y,k.x))-B.x)/(Y||1);Math.abs(oe-.5)<Jc&&(oe=.5),fe=oe,te={x:B.x+fe*Y,y:ee==="bottom"?B.y+R:B.y}}return{side:ee,snapPosition:te,offset:fe}},[s,V]),q=Oo(P=>{var z,K,Z;let k=C.current;if(!k)return;let S=c({x:P.clientX,y:P.clientY}),B=F(S);f(B);let Y=S,R=null,H=null;if(B){let W=j(B,S);W&&(R=W.side,Y=W.snapPosition,H=W.offset,L.current=R);let X=l(e),Q={source:k==="source"?B:D.current,target:k==="target"?B:O.current,sourceHandle:k==="source"?R:(z=X==null?void 0:X.sourceHandle)!=null?z:null,targetHandle:k==="target"?R:(K=X==null?void 0:X.targetHandle)!=null?K:null},ee=(Z=p==null?void 0:p(Q))!=null?Z:!0;N(ee)}else L.current=null,N(!1);T(R),I(H),g(Y)},[F,j,l,e,c,p]),$=Oo(P=>{var R,H,z,K,Z;let k=C.current;if(!k)return;let S=c({x:P.clientX,y:P.clientY}),B=F(S);if(B){let W=j(B,S),X=(R=W==null?void 0:W.side)!=null?R:null,Q=(H=W==null?void 0:W.offset)!=null?H:.5,ee=l(e),te={source:k==="source"?B:D.current,target:k==="target"?B:O.current,sourceHandle:k==="source"?X:(z=ee==null?void 0:ee.sourceHandle)!=null?z:null,targetHandle:k==="target"?X:(K=ee==null?void 0:ee.targetHandle)!=null?K:null};((Z=p==null?void 0:p(te))==null||Z)&&i(fe=>fe.map(ue=>{var le,ge;return ue.id===e?w(_({},ue),{source:te.source,target:te.target,sourceHandle:te.sourceHandle,targetHandle:te.targetHandle,data:w(_({},ue.data),{points:void 0,sourceOffset:k==="source"?Q:(le=ue.data)==null?void 0:le.sourceOffset,targetOffset:k==="target"?Q:(ge=ue.data)==null?void 0:ge.targetOffset})}):ue}))}x(null),g(null),f(null),T(null),I(null),d(!1),N(!1),u(null),L.current=null,document.removeEventListener("mouseup",$),document.removeEventListener("mousemove",q);let Y=bt.get(n);Y==null||Y.clearReconnectingEdge()},[e,F,j,l,i,n,q,p,c,d,u]),A=Oo((P,k)=>{if(r||k.button!==0)return;k.stopPropagation(),k.preventDefault(),i(B=>B.map(Y=>Y.id===e?w(_({},Y),{data:w(_({},Y.data),{points:void 0})}):Y)),x(P),u(e);let S=bt.get(n);S==null||S.setReconnectingEdge(e),document.addEventListener("mousemove",q),document.addEventListener("mouseup",$)},[r,e,n,q,$,u,i]);return Xr(()=>()=>{if(C.current){document.removeEventListener("mousemove",q),document.removeEventListener("mouseup",$),u(null);let P=bt.get(n);P==null||P.clearReconnectingEdge()}},[n,q,$,u]),{reconnectingHandle:m,cursorPosition:E,hoveredNodeId:h,reconnectingSide:y,reconnectingOffset:b,isValidReconnection:v,handleReconnectStart:A}};import{Fragment as nd,jsx as Se,jsxs as zt}from"react/jsx-runtime";var st={type:"SEQUENCE_EDGE",reconnectable:!0,markerStart:{type:jc.ArrowClosed},markerEnd:{type:jc.Arrow},data:{label:""}},{MOVE_THRESHOLD:qr,MIN_SEGMENT_LENGTH:Qh,PARALLEL_OFFSET:od,MAX_LABEL_DISTANCE:jh}=Bt;function ey(e,t,o,n,r){if(r)return 0;let i=n.filter(l=>l.source===t&&l.target===o||l.source===o&&l.target===t);if(i.length<=1){let l=n.filter(u=>u.source===t);if(l.length<=1)return 0;let c=l.findIndex(u=>u.id===e);if(c<=0)return 0;let d=(l.length-1)/2;return(c-d)*od}let s=i.findIndex(l=>l.id===e),a=(i.length-1)/2;return(s-a)*od}var ps=Uh.memo(({id:e,source:t,target:o,data:n,selected:r,sourcePosition:i,targetPosition:s,sourceHandleId:a,targetHandleId:l})=>{var X,Q,ee,te,fe,ue,le,ge,be,Re;let{zoom:c}=Jh(),{updateEdgeData:d}=Zh(),{isReadOnly:u,mode:p,instanceId:m,edgeHighlight:x}=U(),E=Et(),g=td($r(J=>J.edges,[])),h=td($r(J=>{var se,oe;return((se=J.nodeLookup.get(t))==null?void 0:se.type)==="GATEWAY"||((oe=J.nodeLookup.get(o))==null?void 0:oe.type)==="GATEWAY"},[t,o])),f=Kr(()=>ey(e,t,o,g,h),[e,t,o,g,h]),[y,T]=Qc(!1),[b,I]=Qc(null),v=us(null),N=us(n==null?void 0:n.labelOffset),C=us(null),M=p!=="edit",{reconnectingHandle:L,cursorPosition:D,hoveredNodeId:O,reconnectingSide:V,isValidReconnection:F,handleReconnectStart:j}=Ur({edgeId:e,source:t,target:o,instanceId:m,isReadOnly:M}),q=ed(t),$=ed(o),{sx:A,sy:P,tx:k,ty:S,sourcePos:B,targetPos:Y}=Kr(()=>{var Ie,qe;let J=q&&$?No(q,$):{sx:0,sy:0,tx:0,ty:0,sourcePos:Ho.Right,targetPos:Ho.Left},se=a?i:J.sourcePos,oe=l?s:J.targetPos,ae=(Ze,ut,We)=>{var oa,na,ra,ia,sa,aa;let{x:Te,y:De}=Ze.internals.positionAbsolute,vt=(ra=(na=(oa=Ze.measured)==null?void 0:oa.width)!=null?na:Ze.width)!=null?ra:0,mt=(aa=(sa=(ia=Ze.measured)==null?void 0:ia.height)!=null?sa:Ze.height)!=null?aa:0;switch(ut){case Ho.Top:return{x:Te+vt*We,y:De};case Ho.Bottom:return{x:Te+vt*We,y:De+mt};case Ho.Left:return{x:Te,y:De+mt*We};case Ho.Right:return{x:Te+vt,y:De+mt*We};default:return{x:Te+vt/2,y:De+mt/2}}},he=(Ie=n==null?void 0:n.sourceOffset)!=null?Ie:.5,Ne=(qe=n==null?void 0:n.targetOffset)!=null?qe:.5,we=q?ae(q,se,he).x:J.sx,Fe=q?ae(q,se,he).y:J.sy,kt=$?ae($,oe,Ne).x:J.tx,ye=$?ae($,oe,Ne).y:J.ty;return L==="source"&&D?(we=D.x,Fe=D.y,V&&(se=V)):L==="target"&&D&&(kt=D.x,ye=D.y,V&&(oe=V)),{sx:we,sy:Fe,tx:kt,ty:ye,sourcePos:se,targetPos:oe}},[q,$,a,l,i,s,L,D,V,n==null?void 0:n.sourceOffset,n==null?void 0:n.targetOffset]);$h(()=>{var oe;if(!C.current){C.current={sx:A,sy:P,tx:k,ty:S,sourcePos:B,targetPos:Y};return}let J=C.current;if(Math.abs(A-J.sx)>qr||Math.abs(P-J.sy)>qr||Math.abs(k-J.tx)>qr||Math.abs(S-J.ty)>qr||J.sourcePos!==B||J.targetPos!==Y){let ae={};(oe=n==null?void 0:n.points)!=null&&oe.length&&(ae.points=void 0),n!=null&&n.labelOffset&&(ae.labelOffset=void 0),Object.keys(ae).length>0&&d(e,_(_({},n),ae))}C.current={sx:A,sy:P,tx:k,ty:S,sourcePos:B,targetPos:Y}},[A,P,k,S,B,Y,n,e,d,L]);let R=Kr(()=>Wr(A,P,k,S,B,Y,n==null?void 0:n.points,f),[A,P,k,S,B,Y,n==null?void 0:n.points,f]),H=Kr(()=>{if(R.length<2)return Gr({x:A,y:P},{x:k,y:S});let J=0;for(let ae=0;ae<R.length-1;ae++)J+=Do(R[ae],R[ae+1]);let se=J/2,oe=0;for(let ae=0;ae<R.length-1;ae++){let he=Do(R[ae],R[ae+1]);if(oe+he>=se){let Ne=(se-oe)/he,we=R[ae],Fe=R[ae+1];return{x:we.x+(Fe.x-we.x)*Ne,y:we.y+(Fe.y-we.y)*Ne}}oe+=he}return Gr({x:A,y:P},{x:k,y:S})},[R,A,P,k,S]),z=$r((J,se)=>{if(p!=="edit"||se.button!==0)return;se.stopPropagation(),se.preventDefault();let oe=R[J],ae=R[J+1],he=pe(oe,ae,"y"),Ne=he?oe.y:oe.x,we=[...R],Fe=we.length,kt=J,ye=J+1;I(J);let Ie=Ze=>{let ut=Ne+(he?Ze.clientY-se.clientY:Ze.clientX-se.clientX)/c;v.current=he?{x:(oe.x+ae.x)/2,y:ut}:{x:ut,y:(oe.y+ae.y)/2};let We=[];for(let Te=1;Te<Fe-1;Te++){let De=we[Te];Te===kt||Te===ye?he?We.push({x:De.x,y:ut}):We.push({x:ut,y:De.y}):We.push(_({},De))}d(e,w(_({},n),{points:We}))},qe=()=>{I(null),v.current=null,document.removeEventListener("mousemove",Ie),document.removeEventListener("mouseup",qe)};document.addEventListener("mousemove",Ie),document.addEventListener("mouseup",qe)},[p,R,c,n,e,d]),K=$r(J=>{var Ie,qe,Ze,ut,We;if(y||M||J.button!==0||!((Ie=n==null?void 0:n.label)!=null&&Ie.trim()))return;J.stopPropagation(),J.preventDefault();let se=J.clientX,oe=J.clientY,ae=(Ze=(qe=n==null?void 0:n.labelOffset)==null?void 0:qe.x)!=null?Ze:0,he=(We=(ut=n==null?void 0:n.labelOffset)==null?void 0:ut.y)!=null?We:0,Ne=[...R],we={x:H.x,y:H.y},Fe=!1,kt=Te=>{let De=(Te.clientX-se)/c,vt=(Te.clientY-oe)/c;if(!Fe&&Math.abs(De)<3&&Math.abs(vt)<3)return;Fe=!0;let mt={x:ae+De,y:he+vt};N.current=mt,d(e,w(_({},n),{labelOffset:mt}))},ye=()=>{document.removeEventListener("mousemove",kt),document.removeEventListener("mouseup",ye);let Te=N.current;if(!Te)return;let De={x:we.x+Te.x,y:we.y+Te.y};Uc(De,Ne)>jh&&(N.current=void 0,d(e,w(_({},n),{labelOffset:void 0})))};document.addEventListener("mousemove",kt),document.addEventListener("mouseup",ye)},[y,M,c,n,e,d,R,H]);if(!q||!$)return null;let Z=Zc(R),W=x&&(r||q.selected||$.selected);return zt(nd,{children:[zt("g",{className:G("group bpmn-arrow-edge",{"is-highlighted":W}),onDoubleClick:()=>!M&&T(!0),children:[Se("path",{d:Z,fill:"none",stroke:"transparent",strokeWidth:Math.max(12,12/c),className:G({"nopan nodrag":!y&&!M&&!!((X=n==null?void 0:n.label)!=null&&X.trim())}),style:{pointerEvents:"stroke",cursor:!y&&!M&&((Q=n==null?void 0:n.label)!=null&&Q.trim())?"move":"pointer"},onMouseDown:K}),zt("g",{className:G("text-grey-500 transition-colors duration-75",{"group-hover:text-grey-800":!u,"text-blue-500 group-hover:text-blue-600":W}),children:[Se(Kh,{id:e,path:Z,interactionWidth:0,markerEnd:`url(#${W?"sequence-edge-marker-highlighted":"sequence-edge-marker"})`,className:G("stroke-2 stroke-current transition-[stroke] duration-75",{"group-hover:stroke-[2.5px]":!u,"stroke-red-500 hover:stroke-red-600":(n==null?void 0:n.hasError)||L&&O&&!F,"stroke-green-500":L&&O&&F,"stroke-blue-500 hover:stroke-blue-600 stroke-[3px]":W&&!(n!=null&&n.hasError)&&!L})}),r&&!E&&!M&&Se("g",{children:R.slice(0,-1).map((J,se)=>{let oe=R[se+1];if(se===0||se===R.length-2||Do(J,oe)<Qh)return null;let ae=pe(J,oe,"y"),he=b===se,Ne=he&&v.current?v.current:Gr(J,oe);return zt("g",{children:[Se("line",{x1:J.x,y1:J.y,x2:oe.x,y2:oe.y,stroke:"transparent",strokeWidth:20/c,className:G("cursor-pointer",{"cursor-ns-resize":ae,"cursor-ew-resize":!ae}),onMouseDown:we=>z(se,we)}),Se("circle",{cx:Ne.x,cy:Ne.y,r:4/c,fill:he?"#3b82f6":"#fff",stroke:"#3b82f6",strokeWidth:2/c,className:"pointer-events-none"}),Se("circle",{cx:Ne.x,cy:Ne.y,r:6/c,fill:"none",stroke:"#3b82f6",strokeWidth:1/c,opacity:he?.6:.3,className:"pointer-events-none"})]},se)})})]})]}),zt(qh,{children:[Se("div",{className:"absolute z-[3000] pointer-events-none flex flex-col items-center gap-1",style:{transform:`translate(-50%, -50%) translate(${H.x}px, ${H.y}px)`},children:r&&!E&&Se(Lo,{sx:A,sy:P,tx:k,ty:S,hasLabel:!!((ee=n==null?void 0:n.label)!=null&&ee.trim()),children:Se(Po,{edgeId:e,edgeType:"SEQUENCE_EDGE",sourceNode:q,targetNode:$})})}),(y||((te=n==null?void 0:n.label)==null?void 0:te.trim()))&&Se("div",{className:G("absolute nodrag nopan",!y&&!M&&((fe=n==null?void 0:n.label)!=null&&fe.trim())?"z-[10001] pointer-events-auto":"z-[3000] pointer-events-none"),style:{transform:`translate(-50%, -50%) translate(${H.x+((le=(ue=n==null?void 0:n.labelOffset)==null?void 0:ue.x)!=null?le:0)}px, ${H.y+((be=(ge=n==null?void 0:n.labelOffset)==null?void 0:ge.y)!=null?be:0)}px)`,cursor:!y&&!M&&((Re=n==null?void 0:n.label)!=null&&Re.trim())?"move":void 0},onMouseDown:!y&&!M?K:void 0,onDoubleClick:J=>{M||(J.stopPropagation(),T(!0))},children:Se(Oe,{value:n==null?void 0:n.label,className:G("min-w-8 max-w-56 px-2 py-1 body-small-400",{"pointer-events-auto":y,"pointer-events-none":!y}),isEditing:y,onBlur:()=>T(!1),onChange:J=>d(e,{label:J.trim()})})}),r&&!E&&!M&&zt(nd,{children:[Se("div",{className:"absolute z-[10000] pointer-events-none",style:{transform:`translate(-50%, -50%) translate(${R[0].x}px, ${R[0].y}px)`},children:zt("svg",{width:12/c,height:12/c,style:{overflow:"visible",position:"absolute",left:"50%",top:"50%",transform:"translate(-50%, -50%)"},children:[Se("circle",{cx:6/c,cy:6/c,r:4/c,fill:L==="source"?"#3b82f6":"#fff",stroke:"#3b82f6",strokeWidth:2/c,className:"pointer-events-none"}),Se("circle",{cx:6/c,cy:6/c,r:6/c,fill:"none",stroke:"#3b82f6",strokeWidth:1/c,opacity:L==="source"?.6:.3,className:"pointer-events-none"}),Se("circle",{cx:6/c,cy:6/c,r:8/c,fill:"transparent",className:G("pointer-events-auto",{"cursor-move":!L||L!=="source","cursor-not-allowed":L==="source"&&O&&!F,"cursor-grabbing":L==="source"&&(!O||F)}),onMouseDown:J=>j("source",J.nativeEvent)})]})}),Se("div",{className:"absolute z-[10000] pointer-events-none",style:{transform:`translate(-50%, -50%) translate(${R[R.length-1].x}px, ${R[R.length-1].y}px)`},children:zt("svg",{width:12/c,height:12/c,style:{overflow:"visible",position:"absolute",left:"50%",top:"50%",transform:"translate(-50%, -50%)"},children:[Se("circle",{cx:6/c,cy:6/c,r:4/c,fill:L==="target"?"#3b82f6":"#fff",stroke:"#3b82f6",strokeWidth:2/c,className:"pointer-events-none"}),Se("circle",{cx:6/c,cy:6/c,r:6/c,fill:"none",stroke:"#3b82f6",strokeWidth:1/c,opacity:L==="target"?.6:.3,className:"pointer-events-none"}),Se("circle",{cx:6/c,cy:6/c,r:8/c,fill:"transparent",className:G("pointer-events-auto",{"cursor-move":!L||L!=="target","cursor-not-allowed":L==="target"&&O&&!F,"cursor-grabbing":L==="target"&&(!O||F)}),onMouseDown:J=>j("target",J.nativeEvent)})]})})]})]})]})});ps.displayName="SequenceEdge";import{Position as Ct}from"@xyflow/react";var ty={right:Ct.Right,left:Ct.Left,top:Ct.Top,bottom:Ct.Bottom},Zr=e=>{var t;return(t=ty[e!=null?e:""])!=null?t:Ct.Right},fs=(e,t,o=.5)=>{var l,c,d,u;let{x:n,y:r}=e.internals.positionAbsolute,i=(c=(l=e.measured)==null?void 0:l.width)!=null?c:0,s=(u=(d=e.measured)==null?void 0:d.height)!=null?u:0;switch(Zr(t)){case Ct.Right:return{x:n+i,y:r+s*o};case Ct.Left:return{x:n,y:r+s*o};case Ct.Top:return{x:n+i*o,y:r};case Ct.Bottom:return{x:n+i*o,y:r+s};default:return{x:n+i/2,y:r+s/2}}},rd=(e,t,o)=>{var d,u;let{position:{x:n,y:r},measured:i}=e,s=(d=i.width)!=null?d:0,a=(u=i.height)!=null?u:0;return[{id:"left",x:n,y:r+a/2},{id:"right",x:n+s,y:r+a/2},{id:"top",x:n+s/2,y:r},{id:"bottom",x:n+s/2,y:r+a}].reduce((p,m)=>{let x=Math.hypot(t-p.x,o-p.y);return Math.hypot(t-m.x,o-m.y)<x?m:p}).id};import{useCallback as Nu,useEffect as ex}from"react";import{useDebouncedCallback as tx}from"use-debounce";import{useReactFlow as j0}from"@xyflow/react";import{useCallback as vu}from"react";var Nn=(u=>(u.START_EVENT="start-event",u.END_EVENT_TERMINATE="end-event-terminate",u.TASK="task",u.TASK_SCRIPT="task-script",u.SUBPROCESS="subprocess-collapsed",u.GATEWAY_EXCLUSIVE="gateway-exclusive",u.GATEWAY_PARALLEL="gateway-parallel",u.GATEWAY_COMPLEX="gateway-complex",u.SERVICE_TASK="service-task",u.ANNOTATION="annotation",u.LANE="lane",u))(Nn||{});import cd from"@dagrejs/dagre";var Jr={MIN_WIDTH:36,MIN_HEIGHT:36},Qr={MIN_WIDTH:36,MIN_HEIGHT:36},Go={MIN_WIDTH:56,MIN_HEIGHT:56},Yt={MIN_WIDTH:176,MIN_HEIGHT:96},id={HEADER_WIDTH:40,MIN_WIDTH:840,MIN_HEIGHT:256},ie={HEADER_WIDTH:40,MIN_WIDTH:800,MIN_HEIGHT:256},Bo={MIN_WIDTH:176,MIN_HEIGHT:64},oy={MIN_WIDTH:128,MIN_HEIGHT:64},de={START_EVENT:Jr,END_EVENT:Qr,GATEWAY:Go,TASK:Yt,LANE:ie,ANNOTATION:Bo,UNSUPPORTED:oy};var ny=50,co=(e,t)=>{var p,m,x,E,g,h,f,y,T,b,I,v,N,C,M,L;let o=t.find(D=>D.id===e);if(!o)return t;let n=(m=(p=o.position)==null?void 0:p.x)!=null?m:0,r=(E=(x=o.position)==null?void 0:x.y)!=null?E:0,i=(h=(g=o.measured)==null?void 0:g.width)!=null?h:0,s=(y=(f=o.measured)==null?void 0:f.height)!=null?y:0,a=r+s,l=n+i,c=new Set,d=1/0;for(let D of t){if(D.id===e||D.parentId)continue;let O=(b=(T=D.position)==null?void 0:T.y)!=null?b:0,V=(v=(I=D.position)==null?void 0:I.x)!=null?v:0,F=(C=(N=D.measured)==null?void 0:N.width)!=null?C:0,j=(L=(M=D.measured)==null?void 0:M.height)!=null?L:0;V<l&&V+F>n&&O<a&&O+j>r&&(c.add(D.id),d=Math.min(d,O))}if(c.size===0)return t;let u=a+ny-d;return t.map(D=>{var V,F,j;if(!c.has(D.id))return D;let O=(F=(V=D.position)==null?void 0:V.y)!=null?F:0;return w(_({},D),{position:w(_({},(j=D.position)!=null?j:{x:0,y:0}),{y:O+u})})})},xe=15,uo=e=>[...e].sort((t,o)=>t.position.y-o.position.y),ry=e=>{var t,o,n;return e.position.x+((n=(o=(t=e.measured)==null?void 0:t.width)!=null?o:e.width)!=null?n:0)},iy=e=>{var t,o,n;return e.position.y+((n=(o=(t=e.measured)==null?void 0:t.height)!=null?o:e.height)!=null?n:0)},ms=(e,t,o)=>{var d,u,p,m,x,E,g,h,f,y,T,b,I,v,N;if(t.length===0)return e;let n=(p=(u=e.width)!=null?u:(d=e.measured)==null?void 0:d.width)!=null?p:0,r=(E=(x=e.height)!=null?x:(m=e.measured)==null?void 0:m.height)!=null?E:0,i=0,s=0;for(let C of t){let M=ry(C),L=iy(C);if(((h=(g=C.position)==null?void 0:g.y)!=null?h:0)<xe&&(o.set(C.id,w(_({},C),{position:w(_({},C.position),{y:xe})})),L=xe+((y=(f=C.measured)==null?void 0:f.height)!=null?y:0)),((b=(T=C.position)==null?void 0:T.x)!=null?b:0)<ie.HEADER_WIDTH+xe){let D=(I=o.get(C.id))!=null?I:C;o.set(C.id,w(_({},D),{position:w(_({},D.position),{x:ie.HEADER_WIDTH+xe})})),M=ie.HEADER_WIDTH+xe+((N=(v=C.measured)==null?void 0:v.width)!=null?N:0)}i=Math.max(i,M),s=Math.max(s,L)}let a=Math.max(n,ie.MIN_WIDTH),l=Math.max(r,ie.MIN_HEIGHT);i+xe>a&&(a=i+xe),s+xe>l&&(l=s+xe);let c=w(_({},e),{width:a,height:l,measured:w(_({},e.measured),{width:a,height:l})});return o.set(e.id,c),c},sd=(e,t,o)=>{var s,a;let n=uo(e),r=new Map;for(let l of o)l.parentId&&(r.has(l.parentId)||r.set(l.parentId,[]),r.get(l.parentId).push(l));let i=0;for(let l of n){let c=(s=r.get(l.id))!=null?s:[],d=ms(l,c,t);t.set(d.id,w(_({},d),{position:{x:ie.HEADER_WIDTH,y:i}})),i+=(a=d.height)!=null?a:0}},ad=(e,t)=>{var x,E,g,h;let o=[];for(let f of t.values())f.parentId===e.id&&o.push(f);let n=uo(o),r=((E=(x=e.measured)==null?void 0:x.width)!=null?E:0)-ie.HEADER_WIDTH,i=Pa(e.id,o)||ie.MIN_WIDTH,s=o.reduce((f,y)=>{var T;return f+((T=y.height)!=null?T:ie.MIN_HEIGHT)},0),a=Math.max(r,i),l=s,c=r>i,d=c?a:a+ie.HEADER_WIDTH,u=c?a-ie.HEADER_WIDTH:a,p=0;for(let f=0;f<n.length;f++){let y=n[f],T=Math.max(ie.MIN_HEIGHT,(g=y.height)!=null?g:ie.MIN_HEIGHT),b=w(_({},y),{width:u,height:T,measured:w(_({},y.measured),{width:u,height:T}),position:{x:ie.HEADER_WIDTH,y:p}});if(f===o.length-1){let I=Math.max(ie.MIN_HEIGHT,l-p);b=w(_({},b),{height:I,measured:w(_({},y.measured),{width:u,height:I})})}t.set(y.id,b),p+=(h=b.height)!=null?h:0}let m=Math.max(l,p);t.set(e.id,w(_({},e),{width:d,height:m,measured:w(_({},e.measured),{width:d,height:m})}))},ld=(e,t,o,n,r)=>{var x,E;let i=!e.parentId,s=i?e.id:e.parentId,a=n.filter(g=>g.type==="LANE"&&g.parentId===s);if(!a.length)return n;let l=uo(a),c=l.findIndex(g=>g.id===e.id),d=(E=(x=e.position)==null?void 0:x.y)!=null?E:0,u=!i&&r!==void 0&&c>0&&Math.abs(r-d)>.5,p=0,m=[...n];return l.forEach((g,h)=>{var I,v;let f=h===l.length-1,y=g.id===e.id,b=(v=(I=g.measured)==null?void 0:I.height)!=null?v:0;y?b=o:u&&h===c-1&&(b=Math.max(ie.MIN_HEIGHT,r-p)),f&&i&&(b=Math.max(ie.MIN_HEIGHT,o-p)),m=m.map(N=>{if(N.id===g.id){let C=i?t-ie.HEADER_WIDTH:t;return w(_({},N),{width:C,height:b,measured:w(_({},N.measured),{width:C,height:b}),position:{x:ie.HEADER_WIDTH,y:p}})}return N}),y&&u?p=r+o:p+=b}),m=m.map(g=>{if(g.id===s){let h=i?t:t+ie.HEADER_WIDTH;return w(_({},g),{width:h,height:i?o:p,measured:{width:h,height:i?o:p}})}return g}),m};var gs=(e,t,o)=>{var a,l,c,d,u,p,m,x;if(e.type==="LANE")return o;let n=(l=(a=t.measured)==null?void 0:a.width)!=null?l:0,r=(d=(c=t.measured)==null?void 0:c.height)!=null?d:0;e.position.y<xe&&(e.position.y=xe),e.position.x<ie.HEADER_WIDTH+xe&&(e.position.x=ie.HEADER_WIDTH+xe);let i=e.position.x+((p=(u=e.measured)==null?void 0:u.width)!=null?p:0),s=e.position.y+((x=(m=e.measured)==null?void 0:m.height)!=null?x:0);return i+xe>n&&(t.width=i+xe,t.measured.width=i+xe),s+xe>r&&(t.height=s+xe,t.measured.height=s+xe),o=o.map(E=>E.id===t.id?w(_({},E),{height:t.height,width:t.width,measured:t.measured}):E.id===e.id?w(_({},E),{position:e.position}):E),o};var jr=(e=[],t=[],o="LR")=>{let n=new cd.graphlib.Graph;return n.setDefaultEdgeLabel(()=>({})),n.setGraph({rankdir:o}),e.forEach(({id:i,width:s,height:a})=>n.setNode(i,{width:s,height:a})),t.forEach(i=>n.setEdge(i.source,i.target)),cd.layout(n),{nodes:e.map(i=>{let s=n.node(i.id);return w(_({},i),{position:{x:s.x-i.width/2,y:s.y-i.height/2}})}),edges:t}},St=e=>{let t=e.filter(n=>n.type==="LANE"&&!n.parentId);if(t.length===0)return e;let o=Ca(e);for(let n of t){let r=[...o.values()],i=r.filter(a=>a.parentId===n.id);if(i.length===0)continue;let s=i.filter(a=>a.type==="LANE");if(s.length>0){sd(s,o,r),ad(n,o);continue}ms(n,i,o)}return Sa(e,o)},dd=St,ud=()=>{let e=document.querySelector(".react-flow__viewport");return e||(console.error("Flow element (.react-flow__viewport) not found."),null)};var wn=1,pd=e=>`<mxGraphModel>
1
+ var Xp=Object.defineProperty,Up=Object.defineProperties;var $p=Object.getOwnPropertyDescriptors;var En=Object.getOwnPropertySymbols;var $s=Object.prototype.hasOwnProperty,Ks=Object.prototype.propertyIsEnumerable;var Us=(e,t,o)=>t in e?Xp(e,t,{enumerable:!0,configurable:!0,writable:!0,value:o}):e[t]=o,T=(e,t)=>{for(var o in t||(t={}))$s.call(t,o)&&Us(e,o,t[o]);if(En)for(var o of En(t))Ks.call(t,o)&&Us(e,o,t[o]);return e},I=(e,t)=>Up(e,$p(t));var Ue=(e,t)=>{var o={};for(var n in e)$s.call(e,n)&&t.indexOf(n)<0&&(o[n]=e[n]);if(e!=null&&En)for(var n of En(e))t.indexOf(n)<0&&Ks.call(e,n)&&(o[n]=e[n]);return o};var gi=e=>{if(typeof document=="undefined")return;let t=document.cookie.match(new RegExp(`(?:^|; )${e.replace(/([.$?*|{}()[\]\\/+^])/g,"\\$1")}=([^;]*)`));return t?decodeURIComponent(t[1]):void 0};import{initializeI18n as Kp,Translations as qp}from"@produto-lecom/lecom-ui";var qs={translations:{general:{layout:{title:"Modeler"}},editor:{toolbar:{delete:"Delete",deleting:"Deleting...",configure_node:"Configure activity",configure_edge:"Configure routing",configure_gateway:"Configure routing",initial_task:"Initial Activity",gateway_limit_reached:"Exclusive gateway cannot have more than 2 outgoing connections",task_limit_reached:"Task cannot have more than 2 outgoing connections",start_event_limit_reached:"Start event can only connect to a single element",gateway_to_gateway_not_allowed:"Gateways cannot connect directly to other gateways",start_event_already_exists:"A start event already exists. Delete the current event to add another",script_to_end_not_allowed:"Script activities cannot connect directly to the end event",loop_to_end_not_allowed:"Loop activities cannot connect directly to the end event",initial_activity_to_end_not_allowed:"Initial activity cannot connect directly to the end event",final_activity_cannot_connect:"Final activity cannot connect to other elements",activity_has_outgoing_connections:"Activity with outgoing connections cannot connect to end event",end_event_cannot_connect_to_initial_activity:"End event cannot connect to an initial activity",initial_activity_cannot_connect_to_start_event:"Initial activity cannot connect to start event",concurrent_initial_and_final_activity:"An activity cannot be connected to both start and end events",start_event_to_service_task_not_allowed:"Start event cannot connect to an automatic activity",service_task_to_end_not_allowed:"Automatic activities cannot connect to the end event",duplicate_connection_not_allowed:"A connection already exists between these elements",connect_node:"Connect element",connecting:"Connecting...",delete_pool_lane_error:"Cannot delete the pool or lane while there are elements inside it.",delete_elements_blocked:"One or more activities cannot be deleted because there are in-progress processes in the Workspace linked to them.",delete_elements_error:"An error occurred. Please try again later."},controls:{zoom:{fit:"Fit zoom",in:"Zoom in",out:"Zoom out",reset:"Reset zoom"},actions:{move_tool:"Select elements",hand_tool:"Navigate the diagram",check:"Check diagram",check_loading:"Validating diagram...",export:{title:"Export diagram",print:"Print",html:"Export as HTML",png:"Export as PNG",feedback:{empty:"Cannot export an empty diagram",error:"Error exporting diagram"}},import_governance:"Import diagram from Governance platform",import_mermaid:"Import Mermaid",import:{title:"Import",xml:"XML",mermaid:"Mermaid",governance:"Governance",feedback:{error:"Could not import the file. Check its content."}},organize:{title:"Align diagram",vertical:"Vertical (top-down)",horizontal:"Horizontal (left-right)",feedback:{pool_lane:"Diagrams with pools or lanes cannot be arranged automatically."}},minimap:{label:"Minimap",open:"Open minimap",close:"Hide minimap"}},history:{undo:"Undo",redo:"Redo"}},modals:{mermaid_import:{title:"Import diagram from Mermaid",description:"Paste the Mermaid text (in the format supported by the modeler) to generate the diagram.",generate:"Generate",cancel:"Cancel",error_empty:"Paste the diagram text before generating.",error_parse:"Could not generate the diagram. Check the pasted text."},delete_elements:{title:"Delete elements",callout:"When deleting, the activity and routing settings will be deleted.",content:"Are you sure you want to delete?",confirm:"Delete",cancel:"Cancel"}},task_menu:{loop_not_allowed_when_connected_to_end:"Cannot create loop on activity connected to end event",script_not_allowed_when_connected_to_end:"Cannot transform to Script activity connected to end event",loop_not_allowed_when_subprocess:"Cannot create loop on subprocess",loop_not_allowed_when_service_task:"Cannot create loop on automatic activity",loop:"Activity with loop"}},validation:{success:{title:"Validation Successful",message:"The diagram was validated successfully with no errors."},errors:{title:"The diagram contains errors",subtitle:"Please review the following:",task_label_length:"Task name exceeds the maximum character limit",multiple_start_event_not_allowed:"Multiple start events are not allowed",task_flows_limit_exceeds:"The number of output connections exceeds the limit of two",duplicate_task_name:"There are multiple activities with the same name",flows_on_end_tasks_not_allowed:"Activities connected to end events cannot have other connections",conditions_flows_limit_exceeds:"Exclusive gateway has too many output connections (maximum of two)",task_label_empty:"One or more activities have no name",activity_name_invalid:"Activity name is invalid",final_activity_has_loop:"Final activities cannot have loops",nested_gateway:"Connecting gateways directly is not allowed",concurrent_initial_and_final_event:"The same activity cannot have both initial and final events",gateway_flow_to_event:"Connecting a gateway to an output event is not allowed",gateway_missing_output_streams:"One or more gateways do not have the correct number of outputs",events_nested:"Connecting events directly is not allowed",event_to_condition:"Connecting an event directly to a gateway is not allowed",script_in_final_activity:"Final activity cannot be a script type",subprocess_not_configured:"The subprocess reference is not properly configured in one or more activities",cannot_validate_subprocess_reference:"Could not validate the subprocess reference in one or more activities",start_event_not_found:"A start event is required",end_event_not_found:"At least one end event is required",service_task_without_rejection_routing:"Automated activity (RPA) without rejection routing configured",service_task_without_automation:"Automated activity (RPA) without a configured robot",service_task_connector_inactive:"Automated activity (RPA) linked to an inactive connector",service_task_integration_suspended:"Automated activity (RPA) linked to a suspended integration",service_task_automation_status_unavailable:"Could not verify the automation (RPA) status",service_task_initial_or_final:"Automated activity (RPA) cannot be an initial, final or concentrator step",service_task_in_loop:"Automated activity (RPA) cannot be in a loop"}},bpmn:{start_event:{variant:{default:"Start event"}},end_event:{variant:{default:"End event"}},annotation:{variant:{default:"Annotation"}},gateway:{menu:{title:"Change gateway type"},variant:{default:"Gateway",exclusive:"Exclusive gateway",parallel:"Parallel gateway",complex:"Complex gateway"}},task:{menu:{title:"Change task type"},variant:{default:"Task",script:"Script task",subprocess:"Subprocess",service_task:"RPA"},attribute:{loop:"Task with loop"},label:{prefix:"Activity"},feedback:{label_empty:{prefix:"Activity name was automatically set to"},label_already_exists:{prefix:"The name",middle:"already exists. The name was changed to"},invalid_first_character:"Activity name must start with a letter or number"}},lane:{variant:{default:"Pool / Lane"}},unsupported:{variant:{default:"Unsupported element"}}},adapter:{governance:{error:{DEFAULT:"Error importing diagram",NO_FILE:"No file selected",EMPTY_FILE:"Empty file",INVALID_FILE:"Invalid file",CONTAIN_NO_CELLS:"No cells found to be imported",ALREADY_INITIALIZED:"Importing from the Governance platform is only allowed in diagrams without elements. To import, delete the current diagram"},success:{default:"The diagram was imported from the Governance platform successfully and without any incompatibility detected.",incompatible_cells:"The diagram was imported from the Governance platform with incompatibilities. To know more details, click on the button below."},report:{columns:{type:"Type",value:"Value",status:"Status"},status:{imported:"Imported",adapted:"Adapted",unsupported:"Unsupported"}},action:{download:"Download report"}}}}};var Zs={translations:{general:{layout:{title:"Modeler"}},editor:{toolbar:{delete:"Eliminar",deleting:"Eliminando...",configure_node:"Configurar actividad",configure_edge:"Configurar enrutamiento",configure_gateway:"Configurar enrutamiento",initial_task:"Actividad Inicial",gateway_limit_reached:"Compuerta exclusiva no puede tener m\xE1s de 2 conexiones de salida",task_limit_reached:"Actividad no puede tener m\xE1s de 2 conexiones de salida",start_event_limit_reached:"Evento inicial solo puede conectarse a un \xFAnico elemento",gateway_to_gateway_not_allowed:"Las compuertas no pueden conectarse directamente con otras compuertas",start_event_already_exists:"Ya existe un evento de inicio. Elimine el evento actual para agregar otro",script_to_end_not_allowed:"Las actividades Script no pueden conectarse directamente al evento final",loop_to_end_not_allowed:"Las actividades Loop no pueden conectarse directamente al evento final",initial_activity_to_end_not_allowed:"Actividad inicial no puede conectarse directamente al evento final",final_activity_cannot_connect:"Actividad final no puede conectarse a otros elementos",activity_has_outgoing_connections:"Actividad con conexiones de salida no puede conectarse al evento final",end_event_cannot_connect_to_initial_activity:"El evento final no puede conectarse a una actividad inicial",initial_activity_cannot_connect_to_start_event:"Actividad inicial no puede conectarse a evento de inicio",concurrent_initial_and_final_activity:"Una actividad no puede estar conectada al evento inicial y final al mismo tiempo",start_event_to_service_task_not_allowed:"El evento inicial no puede conectarse a una actividad autom\xE1tica",service_task_to_end_not_allowed:"Las actividades autom\xE1ticas no pueden conectarse al evento final",duplicate_connection_not_allowed:"Ya existe una conexi\xF3n entre estos elementos",connect_node:"Conectar elemento",connecting:"Conectando...",delete_pool_lane_error:"No se puede eliminar la piscina o carril mientras haya elementos dentro.",delete_elements_blocked:"No se pueden eliminar una o m\xE1s actividades porque existen procesos en curso en el Workspace vinculados a ellas.",delete_elements_error:"Ocurri\xF3 un error. Int\xE9ntelo de nuevo m\xE1s tarde."},controls:{zoom:{fit:"Ajustar zoom",in:"Acercar",out:"Alejar",reset:"Restablecer zoom"},actions:{move_tool:"Seleccionar elementos",hand_tool:"Navegar por el diagrama",check:"Validar diagrama",check_loading:"Validando diagrama...",export:{title:"Exportar diagrama",print:"Imprimir",html:"Exportar como HTML",png:"Exportar como PNG",feedback:{empty:"No es posible exportar un diagrama vac\xEDo",error:"Error al exportar diagrama"}},import_governance:"Importar diagrama de la plataforma Governance",import_mermaid:"Importar Mermaid",import:{title:"Importar",xml:"XML",mermaid:"Mermaid",governance:"Governance",feedback:{error:"No fue posible importar el archivo. Verifique el contenido."}},organize:{title:"Alinear diagrama",vertical:"Vertical (de arriba hacia abajo)",horizontal:"Horizontal (de izquierda a derecha)",feedback:{pool_lane:"No es posible ordenar autom\xE1ticamente diagramas con piscinas o carriles."}},minimap:{label:"Minimapa",open:"Abrir minimapa",close:"Ocultar minimapa"}},history:{undo:"Deshacer",redo:"Rehacer"}},modals:{mermaid_import:{title:"Importar diagrama a partir de Mermaid",description:"Pegue el texto Mermaid (en el formato compatible con el modelador) para generar el diagrama.",generate:"Generar",cancel:"Cancelar",error_empty:"Pegue el texto del diagrama antes de generar.",error_parse:"No fue posible generar el diagrama. Verifique el texto pegado."},delete_elements:{title:"Eliminar elementos",callout:"Al eliminar, las configuraciones de actividades y enrutamiento ser\xE1n eliminadas.",content:"\xBFEst\xE1s seguro de querer eliminar?",confirm:"Eliminar",cancel:"Cancelar"}},task_menu:{loop_not_allowed_when_connected_to_end:"No se puede crear bucle en actividad conectada al evento final",script_not_allowed_when_connected_to_end:"No se puede transformar a Script actividad conectada al evento final",loop_not_allowed_when_subprocess:"No se puede crear bucle en subproceso",loop_not_allowed_when_service_task:"No se puede crear bucle en actividad autom\xE1tica",loop:"Actividad con loop"}},validation:{success:{title:"Validaci\xF3n exitosa",message:"El diagrama ha sido validado correctamente sin errores."},errors:{title:"El diagrama contiene errores",subtitle:"Revise lo siguiente:",task_label_length:"El nombre de la actividad excede el l\xEDmite m\xE1ximo de caracteres",multiple_start_event_not_allowed:"No se permite tener m\xE1s de un evento de inicio",task_flows_limit_exceeds:"El n\xFAmero de conexiones de salida supera el l\xEDmite de dos",duplicate_task_name:"Hay varias actividades con el mismo nombre",flows_on_end_tasks_not_allowed:"Las actividades conectadas a eventos finales no pueden tener otras conexiones",conditions_flows_limit_exceeds:"Compuerta exclusiva con exceso de conexiones de salida (m\xE1ximo de dos)",task_label_empty:"El nombre de una o m\xE1s actividades no ha sido completado",activity_name_invalid:"El nombre de la actividad no es v\xE1lido",final_activity_has_loop:"Las actividades finales no pueden tener bucles",nested_gateway:"No se permite conectar compuertas directamente",concurrent_initial_and_final_event:"Una misma actividad no puede tener eventos iniciales y finales",gateway_flow_to_event:"No se permite conectar una compuerta a un evento de salida",gateway_missing_output_streams:"Una o m\xE1s compuertas no tienen el n\xFAmero correcto de salidas",events_nested:"No se permite conectar eventos directamente",event_to_condition:"No se permite conectar un evento directamente a una compuerta",script_in_final_activity:"La actividad final no puede ser de tipo script",subprocess_not_configured:"La referencia al subproceso no est\xE1 configurada correctamente en una o m\xE1s actividades",cannot_validate_subprocess_reference:"No fue posible validar la referencia al subproceso en una o m\xE1s actividades",start_event_not_found:"Es necesario tener un evento de inicio",end_event_not_found:"Es necesario tener al menos un evento final",service_task_without_rejection_routing:"Actividad autom\xE1tica (RPA) sin enrutamiento de rechazo configurado",service_task_without_automation:"Actividad autom\xE1tica (RPA) sin robot configurado",service_task_connector_inactive:"Actividad autom\xE1tica (RPA) vinculada a un conector inactivo",service_task_integration_suspended:"Actividad autom\xE1tica (RPA) vinculada a una integraci\xF3n suspendida",service_task_automation_status_unavailable:"No se pudo verificar el estado de la automatizaci\xF3n (RPA)",service_task_initial_or_final:"La actividad autom\xE1tica (RPA) no puede ser etapa inicial, final o concentradora",service_task_in_loop:"La actividad autom\xE1tica (RPA) no puede estar en un bucle"}},bpmn:{start_event:{variant:{default:"Evento de inicio"}},end_event:{variant:{default:"Evento final"}},annotation:{variant:{default:"Anotaci\xF3n"}},gateway:{menu:{title:"Cambiar tipo de compuerta"},variant:{default:"Compuerta",exclusive:"Compuerta exclusiva",parallel:"Compuerta paralela",complex:"Compuerta compleja"}},task:{menu:{title:"Cambiar tipo de tarea"},variant:{default:"Tarea",script:"Tarea de script",subprocess:"Subproceso",service_task:"RPA"},attribute:{loop:"Tarea con bucle"},label:{prefix:"Actividad"},feedback:{label_empty:{prefix:"El nombre de la actividad se estableci\xF3 autom\xE1ticamente como"},label_already_exists:{prefix:"El nombre",middle:"ya existe. El nombre fue cambiado a"},invalid_first_character:"El nombre de la actividad debe comenzar con una letra o n\xFAmero"}},lane:{variant:{default:"Piscina / Raia"}},unsupported:{variant:{default:"Elemento no soportado"}}},adapter:{governance:{error:{DEFAULT:"Error al importar diagrama",NO_FILE:"No se ha seleccionado ning\xFAn archivo",EMPTY_FILE:"Archivo vac\xEDo",INVALID_FILE:"Archivo inv\xE1lido",CONTAIN_NO_CELLS:"No se encontraron c\xE9lulas para importar",ALREADY_INITIALIZED:"La importaci\xF3n de la plataforma Governance solo se permite en diagramas sin elementos. Para importar, elimine el diagrama actual"},success:{default:"El diagrama se ha importado de la plataforma Governance correctamente y sin ninguna incompatibilidad detectada.",incompatible_cells:"El diagrama se ha importado de la plataforma Governance con incompatibilidades. Para saber m\xE1s detalles, haz click en el bot\xF3n de abajo."},report:{columns:{type:"Tipo",value:"Valor",status:"Estado"},status:{imported:"Importado",adapted:"Adaptado",unsupported:"No soportado"}},action:{download:"Descargar informe"}}}}};var Js={translations:{general:{layout:{title:"Modeler"}},editor:{toolbar:{delete:"Excluir",deleting:"Excluindo...",configure_node:"Configurar atividade",configure_edge:"Configurar roteamento",configure_gateway:"Configurar roteamento",initial_task:"Atividade Inicial",gateway_limit_reached:"Gateway exclusivo n\xE3o pode ter mais de 2 conex\xF5es de sa\xEDda",task_limit_reached:"Atividade n\xE3o pode ter mais de 2 conex\xF5es de sa\xEDda",start_event_limit_reached:"Evento inicial s\xF3 pode se conectar a um \xFAnico elemento",gateway_to_gateway_not_allowed:"Gateways n\xE3o podem se conectar diretamente com outros gateways",start_event_already_exists:"J\xE1 existe um evento de in\xEDcio. Exclua o evento atual para adicionar outro",script_to_end_not_allowed:"Atividades Script n\xE3o podem se conectar diretamente ao evento final",loop_to_end_not_allowed:"Atividades Loop n\xE3o podem se conectar diretamente ao evento final",initial_activity_to_end_not_allowed:"Atividade inicial n\xE3o pode se conectar diretamente ao evento final",final_activity_cannot_connect:"Atividade final n\xE3o pode se conectar a outros elementos",activity_has_outgoing_connections:"Atividade com conex\xF5es de sa\xEDda n\xE3o pode se conectar a um evento final",end_event_cannot_connect_to_initial_activity:"O evento final n\xE3o pode ser conectado a uma atividade inicial",initial_activity_cannot_connect_to_start_event:"Atividade inicial n\xE3o pode se conectar a evento de in\xEDcio",concurrent_initial_and_final_activity:"Uma atividade n\xE3o pode estar conectada ao evento inicial e final ao mesmo tempo",duplicate_connection_not_allowed:"J\xE1 existe uma conex\xE3o entre esses elementos",start_event_to_subprocess_not_allowed:"Evento inicial n\xE3o pode se conectar a um subprocesso",start_event_to_service_task_not_allowed:"Evento inicial n\xE3o pode se conectar a uma atividade autom\xE1tica",service_task_to_end_not_allowed:"Atividades autom\xE1ticas n\xE3o podem se conectar ao evento final",connect_node:"Conectar elemento",connecting:"Conectando...",delete_pool_lane_error:"N\xE3o \xE9 poss\xEDvel excluir a piscina ou raia enquanto houver elementos dentro dela.",delete_elements_blocked:"Uma ou mais atividades n\xE3o podem ser exclu\xEDdas porque existem processos em andamento no Workspace vinculados a elas.",delete_elements_error:"Ocorreu um erro. Tente novamente mais tarde."},controls:{zoom:{fit:"Ajustar o zoom",in:"Aumentar o zoom",out:"Diminuir o zoom",reset:"Resetar o zoom"},actions:{move_tool:"Selecionar elementos",hand_tool:"Navegar pelo diagrama",check:"Validar diagrama",check_loading:"Validando diagrama...",export:{title:"Exportar diagrama",print:"Imprimir",html:"Exportar como HTML",png:"Exportar como PNG",feedback:{empty:"N\xE3o \xE9 poss\xEDvel exportar um diagrama vazio",error:"Erro ao exportar o diagrama"}},import_governance:"Importar diagrama da plataforma Governance",import_mermaid:"Importar Mermaid",import:{title:"Importar",xml:"XML",mermaid:"Mermaid",governance:"Governance",feedback:{error:"N\xE3o foi poss\xEDvel importar o arquivo. Verifique o conte\xFAdo."}},organize:{title:"Alinhar diagrama",vertical:"Vertical (de cima para baixo)",horizontal:"Horizontal (da esquerda para a direita)",feedback:{pool_lane:"N\xE3o \xE9 poss\xEDvel ordenar automaticamente diagramas com piscinas ou raias."}},minimap:{label:"Minimapa",open:"Abrir minimapa",close:"Ocultar minimapa"}},history:{undo:"Desfazer",redo:"Refazer"}},modals:{mermaid_import:{title:"Importar diagrama a partir de Mermaid",description:"Cole o texto Mermaid (no formato suportado pelo modelador) para gerar o diagrama.",generate:"Gerar",cancel:"Cancelar",error_empty:"Cole o texto do diagrama antes de gerar.",error_parse:"N\xE3o foi poss\xEDvel gerar o diagrama. Verifique o texto colado."},delete_elements:{title:"Excluir elementos",callout:"Ao excluir, as configura\xE7\xF5es de atividades e roteamento ser\xE3o exclu\xEDdas.",content:"Deseja realmente excluir?",confirm:"Excluir",cancel:"Cancelar"}},task_menu:{loop_not_allowed_when_connected_to_end:"N\xE3o \xE9 poss\xEDvel criar loop em atividade conectada ao evento final",script_not_allowed_when_connected_to_end:"N\xE3o \xE9 poss\xEDvel transformar em Script atividade conectada ao evento final",loop_not_allowed_when_subprocess:"N\xE3o \xE9 poss\xEDvel criar loop em subprocesso",loop_not_allowed_when_service_task:"N\xE3o \xE9 poss\xEDvel criar loop em atividade autom\xE1tica",loop:"Atividade com loop"}},validation:{success:{title:"Diagrama validado com sucesso!",message:"Nenhum erro encontrado."},errors:{title:"O diagrama cont\xE9m erros",subtitle:"Veja abaixo o que precisa ser corrigido:",task_label_length:"O nome da atividade excede o limite m\xE1ximo de caracteres",multiple_start_event_not_allowed:"N\xE3o \xE9 permitido ter mais de um evento de in\xEDcio",task_flows_limit_exceeds:"O n\xFAmero de conex\xF5es de sa\xEDda ultrapassa o limite de dois",duplicate_task_name:"H\xE1 v\xE1rias atividades com o mesmo nome",flows_on_end_tasks_not_allowed:"Atividades conectadas a eventos finais n\xE3o podem ter outras conex\xF5es",conditions_flows_limit_exceeds:"Gateway exclusivo com excesso de conex\xF5es de sa\xEDda (m\xE1ximo de dois)",task_label_empty:"O nome de uma ou mais atividades n\xE3o foi preenchido",activity_name_invalid:"O nome da atividade n\xE3o \xE9 v\xE1lido",final_activity_has_loop:"Atividades finais n\xE3o podem ter loops",nested_gateway:"N\xE3o \xE9 permitido conectar gateways",concurrent_initial_and_final_event:"Uma mesma atividade n\xE3o pode ter eventos iniciais e finais",gateway_flow_to_event:"N\xE3o \xE9 permitido conectar um gateway a um evento de sa\xEDda",gateway_missing_output_streams:"Um ou mais gateways n\xE3o possuem o n\xFAmero correto de sa\xEDdas",events_nested:"N\xE3o \xE9 permitido conectar eventos",event_to_condition:"N\xE3o \xE9 permitido conectar um evento diretamente em um gateway",script_in_final_activity:"Atividade final n\xE3o pode ser do tipo script",subprocess_not_configured:"A refer\xEAncia ao subprocesso n\xE3o est\xE1 configurada corretamente em uma ou mais atividades",cannot_validate_subprocess_reference:"N\xE3o foi poss\xEDvel validar a refer\xEAncia ao subprocesso em uma ou mais atividades",start_event_not_found:"\xC9 necess\xE1rio ter um evento inicial",end_event_not_found:"\xC9 necess\xE1rio ter ao menos um evento final",service_task_without_rejection_routing:"Atividade autom\xE1tica (RPA) sem roteamento de rejei\xE7\xE3o configurado",service_task_without_automation:"Atividade autom\xE1tica (RPA) sem rob\xF4 configurado",service_task_connector_inactive:"Atividade autom\xE1tica (RPA) vinculada a um conector inativo",service_task_integration_suspended:"Atividade autom\xE1tica (RPA) vinculada a uma integra\xE7\xE3o suspensa",service_task_automation_status_unavailable:"N\xE3o foi poss\xEDvel verificar o status da automa\xE7\xE3o (RPA)",service_task_initial_or_final:"Atividade autom\xE1tica (RPA) n\xE3o pode ser etapa inicial, final ou concentradora",service_task_in_loop:"Atividade autom\xE1tica (RPA) n\xE3o pode estar em loop"}},bpmn:{start_event:{variant:{default:"Evento inicial"}},end_event:{variant:{default:"Evento final"}},annotation:{variant:{default:"Anota\xE7\xE3o"}},gateway:{menu:{title:"Alterar tipo de gateway"},variant:{default:"Gateway",exclusive:"Gateway exclusivo",parallel:"Gateway paralelo",complex:"Gateway complexo"}},task:{menu:{title:"Alterar tipo de atividade"},variant:{default:"Atividade",script:"Atividade de script",subprocess:"Subprocesso",service_task:"RPA"},attribute:{loop:"Atividade com loop"},label:{prefix:"Atividade"},feedback:{label_empty:{prefix:"O nome da atividade foi definido automaticamente como"},label_already_exists:{prefix:"O nome",middle:"j\xE1 existe. O nome foi alterado para"},invalid_first_character:"O nome da atividade deve come\xE7ar com uma letra ou n\xFAmero"}},lane:{variant:{default:"Piscina / Raia"}},unsupported:{variant:{default:"Elemento n\xE3o suportado"}}},adapter:{governance:{error:{DEFAULT:"Erro ao importar diagrama",NO_FILE:"Nenhum arquivo selecionado",EMPTY_FILE:"Arquivo vazio",INVALID_FILE:"Arquivo inv\xE1lido",CONTAIN_NO_CELLS:"N\xE3o foram encontradas c\xE9lulas para serem importadas",ALREADY_INITIALIZED:"A importa\xE7\xE3o da plataforma Governance s\xF3 \xE9 permitida em diagramas sem elementos. Para importar, apague o diagrama atual"},success:{default:"O diagrama foi importado da plataforma Governance com sucesso e sem nenhuma incompatibilidade detectada.",incompatible_cells:"O diagrama foi importado da plataforma Governance com incompatibilidades. Para saber mais detalhes, clique no bot\xE3o abaixo."},report:{columns:{type:"Tipo do elemento",value:"Valor",status:"Status"},status:{imported:"Importado",adapted:"Adaptado",unsupported:"N\xE3o suportado"}},action:{download:"Baixar relat\xF3rio"}}}}};var Qs={pt_BR:Js,en_US:qs,es_ES:Zs};var js,ea,Zp=(ea=(js=gi("LecomUserLanguage"))!=null?js:gi("org.springframework.web.servlet.i18n.CookieLocaleResolver.LOCALE"))!=null?ea:qp.PT_BR;Kp({lng:Zp,resources:Qs});var le=(n=>(n.EDIT="edit",n.VIEW="view",n.READONLY="readonly",n))(le||{});var _n=(i=>(i.ACTIVITY="activity",i.ROUTING="routing",i.GATEWAY="gateway",i.SUB_PROCESS="sub_process",i.SERVICE_TASK="service_task",i))(_n||{}),hi=(n=>(n.START="start",n.END="end",n.BETWEEN="between",n))(hi||{}),yi=(n=>(n.SCRIPT="script",n.LOOP="loop",n.SCRIPT_LOOP="script_loop",n))(yi||{}),xi=(u=>(u.SIMPLE="simple",u.LOOP="loop",u.SCRIPT="script",u.SCRIPT_LOOP="script_loop",u.COMPLEX="complex",u.EXCLUSIVE="exclusive",u.PARALLEL="parallel",u.FINAL="final",u.TO_SUB_PROCESS="to_sub_process",u.FROM_SUB_PROCESS="from_sub_process",u.FROM_SERVICE_TASK="from_service_task",u))(xi||{});import{Bot as cf,RotateCcw as df,ScrollText as uf,SquarePlus as pf}from"lucide-react";import{jsx as bn,jsxs as Jp}from"react/jsx-runtime";var Tn=({size:e=24,className:t})=>Jp("svg",{width:e,height:e,viewBox:"0 0 24 24",xmlns:"http://www.w3.org/2000/svg",fill:"currentColor",className:t,children:[bn("path",{strokeWidth:"2",d:"M16 3V3.5085V11.9998V20.4915V21H16.5411H21.4592H22V19.123H21.4592H17.9974V11.9998V4.8773H21.4592H22V3H21.4592H16.5411H16Z"}),bn("path",{d:"M4.41026 16.9999L2 18.7861L3.89693 21.1103L6.3072 19.324L4.41026 16.9999Z"}),bn("path",{d:"M8.41026 13.9999L6 15.7861L7.89693 18.1103L10.3072 16.324L8.41026 13.9999Z"}),bn("path",{d:"M12.4313 10.954L10.021 12.7402L11.9179 15.0644L14.3282 13.2781L12.4313 10.954Z"})]});import{jsx as ta}from"react/jsx-runtime";var Kt=({size:e=24,className:t})=>ta("svg",{width:e,height:e,viewBox:"0 0 24 24",xmlns:"http://www.w3.org/2000/svg",fill:"#ff6565",stroke:"#ec1616",strokeWidth:3,className:t,children:ta("path",{d:"M12 22C17.5228 22 22 17.5228 22 12C22 6.47715 17.5228 2 12 2C6.47715 2 2 6.47715 2 12C2 17.5228 6.47715 22 12 22Z",strokeLinecap:"round",strokeLinejoin:"round"})});import{jsx as Io,jsxs as Qp}from"react/jsx-runtime";var qt=({size:e=24,className:t})=>Qp("svg",{width:e,height:e,viewBox:"0 0 24 24",xmlns:"http://www.w3.org/2000/svg",fill:"white",stroke:"currentColor",strokeWidth:2,className:t,children:[Io("path",{d:"M2.69991 10.2997C2.47586 10.5235 2.29812 10.7893 2.17685 11.0818C2.05558 11.3744 1.99316 11.688 1.99316 12.0047C1.99316 12.3214 2.05558 12.635 2.17685 12.9275C2.29812 13.2201 2.47586 13.4859 2.69991 13.7097L10.2899 21.2997C10.5137 21.5237 10.7795 21.7015 11.0721 21.8227C11.3646 21.944 11.6782 22.0064 11.9949 22.0064C12.3116 22.0064 12.6252 21.944 12.9177 21.8227C13.2103 21.7015 13.4761 21.5237 13.6999 21.2997L21.2899 13.7097C21.514 13.4859 21.6917 13.2201 21.813 12.9275C21.9342 12.635 21.9967 12.3214 21.9967 12.0047C21.9967 11.688 21.9342 11.3744 21.813 11.0818C21.6917 10.7893 21.514 10.5235 21.2899 10.2997L13.6999 2.70968C13.4761 2.48562 13.2103 2.30788 12.9177 2.18662C12.6252 2.06535 12.3116 2.00293 11.9949 2.00293C11.6782 2.00293 11.3646 2.06535 11.0721 2.18662C10.7795 2.30788 10.5137 2.48562 10.2899 2.70968L2.69991 10.2997Z",strokeLinecap:"round",strokeLinejoin:"round"}),Io("path",{d:"M12 8V16",strokeLinecap:"round",strokeLinejoin:"round"}),Io("path",{d:"M8 12H16",strokeLinecap:"round",strokeLinejoin:"round"}),Io("path",{d:"M9.17139 9.17188L14.8282 14.8287",strokeLinecap:"round",strokeLinejoin:"round"}),Io("path",{d:"M14.8281 9.17188L9.17127 14.8287",strokeLinecap:"round",strokeLinejoin:"round"})]});import{jsx as Ei,jsxs as jp}from"react/jsx-runtime";var Zt=({size:e=24,className:t})=>jp("svg",{width:e,height:e,viewBox:"0 0 24 24",xmlns:"http://www.w3.org/2000/svg",fill:"white",stroke:"currentColor",strokeWidth:2,className:t,children:[Ei("path",{d:"M2.69991 10.2997C2.47586 10.5235 2.29812 10.7893 2.17685 11.0818C2.05558 11.3744 1.99316 11.688 1.99316 12.0047C1.99316 12.3214 2.05558 12.635 2.17685 12.9275C2.29812 13.2201 2.47586 13.4859 2.69991 13.7097L10.2899 21.2997C10.5137 21.5237 10.7795 21.7015 11.0721 21.8227C11.3646 21.944 11.6782 22.0064 11.9949 22.0064C12.3116 22.0064 12.6252 21.944 12.9177 21.8227C13.2103 21.7015 13.4761 21.5237 13.6999 21.2997L21.2899 13.7097C21.514 13.4859 21.6917 13.2201 21.813 12.9275C21.9342 12.635 21.9967 12.3214 21.9967 12.0047C21.9967 11.688 21.9342 11.3744 21.813 11.0818C21.6917 10.7893 21.514 10.5235 21.2899 10.2997L13.6999 2.70968C13.4761 2.48562 13.2103 2.30788 12.9177 2.18662C12.6252 2.06535 12.3116 2.00293 11.9949 2.00293C11.6782 2.00293 11.3646 2.06535 11.0721 2.18662C10.7795 2.30788 10.5137 2.48562 10.2899 2.70968L2.69991 10.2997Z",strokeLinecap:"round",strokeLinejoin:"round"}),Ei("path",{d:"M14.8286 9.17188L9.17176 14.8287",strokeLinecap:"round",strokeLinejoin:"round"}),Ei("path",{d:"M9.17139 9.17188L14.8282 14.8287",strokeLinecap:"round",strokeLinejoin:"round"})]});import{jsx as _i,jsxs as ef}from"react/jsx-runtime";var Jt=({size:e=24,className:t})=>ef("svg",{width:e,height:e,viewBox:"0 0 24 24",xmlns:"http://www.w3.org/2000/svg",fill:"white",stroke:"currentColor",strokeWidth:2,className:t,children:[_i("path",{d:"M2.69991 10.2997C2.47586 10.5235 2.29812 10.7893 2.17685 11.0818C2.05558 11.3744 1.99316 11.688 1.99316 12.0047C1.99316 12.3214 2.05558 12.635 2.17685 12.9275C2.29812 13.2201 2.47586 13.4859 2.69991 13.7097L10.2899 21.2997C10.5137 21.5237 10.7795 21.7015 11.0721 21.8227C11.3646 21.944 11.6782 22.0064 11.9949 22.0064C12.3116 22.0064 12.6252 21.944 12.9177 21.8227C13.2103 21.7015 13.4761 21.5237 13.6999 21.2997L21.2899 13.7097C21.514 13.4859 21.6917 13.2201 21.813 12.9275C21.9342 12.635 21.9967 12.3214 21.9967 12.0047C21.9967 11.688 21.9342 11.3744 21.813 11.0818C21.6917 10.7893 21.514 10.5235 21.2899 10.2997L13.6999 2.70968C13.4761 2.48562 13.2103 2.30788 12.9177 2.18662C12.6252 2.06535 12.3116 2.00293 11.9949 2.00293C11.6782 2.00293 11.3646 2.06535 11.0721 2.18662C10.7795 2.30788 10.5137 2.48562 10.2899 2.70968L2.69991 10.2997Z",strokeLinecap:"round",strokeLinejoin:"round"}),_i("path",{d:"M12 8V16",strokeLinecap:"round",strokeLinejoin:"round"}),_i("path",{d:"M8 12H16",strokeLinecap:"round",strokeLinejoin:"round"})]});import{jsx as bi,jsxs as tf}from"react/jsx-runtime";var oa=({size:e=24,className:t})=>bi("svg",{width:e,height:e,viewBox:"0 0 34 24",xmlns:"http://www.w3.org/2000/svg",fill:"currentColor",className:t,children:tf("g",{children:[bi("path",{d:"M8.6543 11.4141V15.2148C8.51302 15.4017 8.29199 15.6068 7.99121 15.8301C7.69499 16.0488 7.30078 16.238 6.80859 16.3975C6.31641 16.557 5.70345 16.6367 4.96973 16.6367C4.34538 16.6367 3.77344 16.5319 3.25391 16.3223C2.73438 16.1081 2.28548 15.7959 1.90723 15.3857C1.53353 14.9756 1.24414 14.4766 1.03906 13.8887C0.833984 13.2962 0.731445 12.6217 0.731445 11.8652V11.1748C0.731445 10.4229 0.82487 9.75293 1.01172 9.16504C1.20312 8.57259 1.47656 8.07129 1.83203 7.66113C2.1875 7.25098 2.61589 6.94108 3.11719 6.73145C3.62305 6.51725 4.19499 6.41016 4.83301 6.41016C5.64876 6.41016 6.32324 6.54688 6.85645 6.82031C7.39421 7.08919 7.80892 7.46289 8.10059 7.94141C8.39225 8.41992 8.57682 8.9668 8.6543 9.58203H6.97266C6.91797 9.23568 6.81087 8.92578 6.65137 8.65234C6.49642 8.37891 6.27311 8.16471 5.98145 8.00977C5.69434 7.85026 5.32064 7.77051 4.86035 7.77051C4.46387 7.77051 4.11523 7.8457 3.81445 7.99609C3.51367 8.14648 3.26302 8.36751 3.0625 8.65918C2.86654 8.95085 2.71842 9.30632 2.61816 9.72559C2.5179 10.1449 2.46777 10.6234 2.46777 11.1611V11.8652C2.46777 12.4121 2.52474 12.8975 2.63867 13.3213C2.75716 13.7451 2.92578 14.1029 3.14453 14.3945C3.36784 14.6862 3.639 14.9072 3.95801 15.0576C4.27702 15.2035 4.63704 15.2764 5.03809 15.2764C5.43001 15.2764 5.7513 15.2445 6.00195 15.1807C6.2526 15.1123 6.45085 15.0326 6.59668 14.9414C6.74707 14.8457 6.86328 14.7546 6.94531 14.668V12.6924H4.87402V11.4141H8.6543ZM17.0912 11.25V11.7969C17.0912 12.5488 16.9932 13.2233 16.7973 13.8203C16.6013 14.4173 16.321 14.9255 15.9564 15.3447C15.5964 15.764 15.1635 16.0853 14.6576 16.3086C14.1518 16.5273 13.5912 16.6367 12.976 16.6367C12.3653 16.6367 11.807 16.5273 11.3012 16.3086C10.7999 16.0853 10.3646 15.764 9.99551 15.3447C9.62637 14.9255 9.33926 14.4173 9.13418 13.8203C8.93366 13.2233 8.8334 12.5488 8.8334 11.7969V11.25C8.8334 10.498 8.93366 9.82585 9.13418 9.2334C9.3347 8.63639 9.61725 8.12826 9.98184 7.70898C10.351 7.28516 10.7862 6.96387 11.2875 6.74512C11.7934 6.52181 12.3516 6.41016 12.9623 6.41016C13.5775 6.41016 14.1381 6.52181 14.6439 6.74512C15.1498 6.96387 15.585 7.28516 15.9496 7.70898C16.3142 8.12826 16.5945 8.63639 16.7904 9.2334C16.991 9.82585 17.0912 10.498 17.0912 11.25ZM15.3754 11.7969V11.2363C15.3754 10.6803 15.3207 10.1904 15.2113 9.7666C15.1065 9.33822 14.9493 8.98047 14.7396 8.69336C14.5346 8.40169 14.2816 8.18294 13.9809 8.03711C13.6801 7.88672 13.3406 7.81152 12.9623 7.81152C12.584 7.81152 12.2468 7.88672 11.9506 8.03711C11.6544 8.18294 11.4014 8.40169 11.1918 8.69336C10.9867 8.98047 10.8295 9.33822 10.7201 9.7666C10.6107 10.1904 10.5561 10.6803 10.5561 11.2363V11.7969C10.5561 12.3529 10.6107 12.8451 10.7201 13.2734C10.8295 13.7018 10.989 14.0641 11.1986 14.3604C11.4128 14.652 11.668 14.873 11.9643 15.0234C12.2605 15.1693 12.5977 15.2422 12.976 15.2422C13.3588 15.2422 13.6983 15.1693 13.9945 15.0234C14.2908 14.873 14.5414 14.652 14.7465 14.3604C14.9516 14.0641 15.1065 13.7018 15.2113 13.2734C15.3207 12.8451 15.3754 12.3529 15.3754 11.7969ZM20.6678 14.6816L23.2859 6.54688H25.1795L21.6111 16.5H20.3328L20.6678 14.6816ZM18.2479 6.54688L20.8455 14.6816L21.201 16.5H19.9158L16.3611 6.54688H18.2479Z"}),bi("path",{d:"M24.5 4.5L28 1M28 1L31.5 4.5M28 1V8",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round"})]})});import{clsx as of}from"clsx";import{twMerge as nf}from"tailwind-merge";function F(...e){return nf(of(e))}var pt=(e=0,t=0)=>e<t?t:e,vn=(e=1e3)=>new Promise(t=>{setTimeout(t,e)});import{jsx as na,jsxs as rf}from"react/jsx-runtime";var ra=({size:e=24,className:t})=>rf("svg",{width:e,height:e,viewBox:"0 0 24 24",fill:"none",stroke:"#6b7280",strokeWidth:2,xmlns:"http://www.w3.org/2000/svg",className:F("stroke-2",t),children:[na("path",{d:"M19 3H5C3.89543 3 3 3.89543 3 5V19C3 20.1046 3.89543 21 5 21H19C20.1046 21 21 20.1046 21 19V5C21 3.89543 20.1046 3 19 3Z",strokeLinecap:"round",strokeLinejoin:"round"}),na("path",{d:"M9 3V21",strokeLinecap:"round",strokeLinejoin:"round"})]});import{jsx as Ti}from"react/jsx-runtime";var ia=({size:e=24,className:t})=>Ti("svg",{width:e,height:e,viewBox:"0 0 24 24",xmlns:"http://www.w3.org/2000/svg",stroke:"currentColor",className:t,children:Ti("g",{children:Ti("path",{d:"M4.85372 6.17472L5.31292 5.71552L5.31993 5.70863C6.88908 4.1924 8.98352 3.34122 11.1655 3.33301L11.1668 3.33301C11.167 3.33301 11.1673 3.33301 11.1675 3.33301C12.7165 3.33314 14.2308 3.79255 15.5188 4.65317C16.807 5.5139 17.811 6.7373 18.4039 8.16866C18.9968 9.60001 19.1519 11.175 18.8497 12.6945C18.5986 13.9567 18.0414 15.1334 17.232 16.1236L16.9457 16.4738L17.2655 16.7936L20.6617 20.1899L20.6617 20.1899C20.7919 20.3201 20.7919 20.5311 20.6617 20.6612L20.6616 20.6613C20.5316 20.7915 20.3205 20.7915 20.1903 20.6613L16.7941 17.265L16.4743 16.9452L16.1241 17.2315C15.1339 18.0409 13.9571 18.5981 12.695 18.8492C11.1755 19.1514 9.6005 18.9963 8.16915 18.4034C6.73778 17.8105 5.51439 16.8065 4.65365 15.5183C3.79291 14.2301 3.3335 12.7156 3.3335 11.1663C3.3335 10.9822 3.48273 10.833 3.66683 10.833C3.85093 10.833 4.00016 10.9822 4.00016 11.1663C4.00016 12.5838 4.42048 13.9694 5.20796 15.148C5.99545 16.3265 7.11474 17.245 8.42426 17.7874C9.73378 18.3299 11.1748 18.4719 12.565 18.1953C13.9552 17.9188 15.2321 17.2362 16.2344 16.234L16.2345 16.234C17.2367 15.2316 17.9193 13.9547 18.1958 12.5645C18.4724 11.1743 18.3304 9.7333 17.7879 8.42378C17.2455 7.11426 16.327 5.99497 15.1484 5.20748L14.8707 5.62322L15.1484 5.20748C13.9703 4.42031 12.5854 4.00001 11.1685 3.99968L11.1664 3.99969C9.15876 4.00767 7.23176 4.7903 5.78712 6.18424L5.78706 6.18418L5.78075 6.1905L5.32512 6.64613L4.47156 7.49968H5.67867H7.8335C8.01759 7.49968 8.16683 7.64892 8.16683 7.83302C8.16683 8.01711 8.01759 8.16635 7.8335 8.16635H3.66683C3.48274 8.16635 3.3335 8.01711 3.3335 7.83302V3.66635C3.3335 3.48225 3.48274 3.33302 3.66683 3.33302C3.85092 3.33302 4.00016 3.48225 4.00016 3.66635V5.82117V7.02827L4.85372 6.17472Z"})})});import{jsx as sa}from"react/jsx-runtime";var Nn=({size:e=24,className:t})=>sa("svg",{width:e,height:e,viewBox:"0 0 24 24",xmlns:"http://www.w3.org/2000/svg",fill:"#5fd9b0",stroke:"#1cad86",strokeWidth:"2",className:t,children:sa("path",{d:"M12 22C17.5228 22 22 17.5228 22 12C22 6.47715 17.5228 2 12 2C6.47715 2 2 6.47715 2 12C2 17.5228 6.47715 22 12 22Z",strokeLinecap:"round",strokeLinejoin:"round"})});import{jsx as aa}from"react/jsx-runtime";var Ao=({size:e=24,className:t})=>aa("svg",{width:e,height:e,viewBox:"0 0 24 24",xmlns:"http://www.w3.org/2000/svg",fill:"white",stroke:"currentColor",className:F("stroke-2",t),children:aa("path",{d:"M20 3H4C2.89543 3 2 4.34315 2 6V18C2 19.6569 2.89543 21 4 21H20C21.1046 21 22 19.6569 22 18V6C22 4.34315 21.1046 3 20 3Z",strokeLinecap:"round",strokeLinejoin:"round"})});import{jsx as vi,jsxs as sf}from"react/jsx-runtime";var la=({size:e=24,className:t})=>sf("svg",{width:e,height:e,viewBox:"0 0 24 24",xmlns:"http://www.w3.org/2000/svg",fill:"white",stroke:"#6b7280",strokeWidth:"2",className:t,children:[vi("path",{d:"M20 3H4C2.89543 3 2 4.34315 2 6V18C2 19.6569 2.89543 21 4 21H20C21.1046 21 22 19.6569 22 18V6C22 4.34315 21.1046 3 20 3Z",strokeLinecap:"round",strokeLinejoin:"round"}),vi("path",{d:"M7.5 12C7.5 12.89 7.76392 13.76 8.25839 14.5001C8.75285 15.2401 9.45566 15.8169 10.2779 16.1575C11.1002 16.4981 12.005 16.5872 12.8779 16.4135C13.7508 16.2399 14.5526 15.8113 15.182 15.182C15.8113 14.5526 16.2399 13.7508 16.4135 12.8779C16.5872 12.005 16.4981 11.1002 16.1575 10.2779C15.8169 9.45566 15.2401 8.75285 14.5001 8.25839C13.76 7.76392 12.89 7.5 12 7.5C10.742 7.50473 9.53448 7.99561 8.63 8.87L7.5 10",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round"}),vi("path",{d:"M7.5 7.5V10H10",strokeWidth:"1.5",fill:"none",strokeLinecap:"round",strokeLinejoin:"round"})]});import{jsx as Co,jsxs as af}from"react/jsx-runtime";var ca=({size:e=24,className:t})=>af("svg",{width:e,height:e,viewBox:"0 0 24 24",xmlns:"http://www.w3.org/2000/svg",fill:"white",stroke:"#6b7280",strokeWidth:"2",className:t,children:[Co("path",{d:"M20 3H4C2.89543 3 2 4.34315 2 6V18C2 19.6569 2.89543 21 4 21H20C21.1046 21 22 19.6569 22 18V6C22 4.34315 21.1046 3 20 3Z",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"}),Co("path",{d:"M15.5 14.5V8.5C15.5 8.23478 15.3946 7.98043 15.2071 7.79289C15.0196 7.60536 14.7652 7.5 14.5 7.5H8",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round"}),Co("path",{d:"M10 16.5H16C16.2652 16.5 16.5196 16.3946 16.7071 16.2071C16.8946 16.0196 17 15.7652 17 15.5V15C17 14.8674 16.9473 14.7402 16.8536 14.6464C16.7598 14.5527 16.6326 14.5 16.5 14.5H11.5C11.3674 14.5 11.2402 14.5527 11.1464 14.6464C11.0527 14.7402 11 14.8674 11 15V15.5C11 15.7652 10.8946 16.0196 10.7071 16.2071C10.5196 16.3946 10.2652 16.5 10 16.5ZM10 16.5C9.73478 16.5 9.48043 16.3946 9.29289 16.2071C9.10536 16.0196 9 15.7652 9 15.5V8.5C9 8.23478 8.89464 7.98043 8.70711 7.79289C8.51957 7.60536 8.26522 7.5 8 7.5C7.73478 7.5 7.48043 7.60536 7.29289 7.79289C7.10536 7.98043 7 8.23478 7 8.5V9.5C7 9.63261 7.05268 9.75979 7.14645 9.85355C7.24021 9.94732 7.36739 10 7.5 10H9",strokeWidth:"1",strokeLinecap:"round",strokeLinejoin:"round"}),Co("path",{d:"M13.5 12H11",strokeWidth:"1",strokeLinecap:"round",strokeLinejoin:"round"}),Co("path",{d:"M13.5 10H11",strokeWidth:"1",strokeLinecap:"round",strokeLinejoin:"round"})]});import{jsx as wn,jsxs as lf}from"react/jsx-runtime";var So=({size:e=24,className:t})=>lf("svg",{width:e,height:e,viewBox:"0 0 24 24",xmlns:"http://www.w3.org/2000/svg",fill:"white",stroke:"currentColor",strokeWidth:2,className:t,children:[wn("path",{d:"M20 3H4C2.89543 3 2 4.34315 2 6V18C2 19.6569 2.89543 21 4 21H20C21.1046 21 22 19.6569 22 18V6C22 4.34315 21.1046 3 20 3Z",strokeLinecap:"round",strokeLinejoin:"round"}),wn("path",{d:"M8 21V14C8 13.4477 8.44772 13 9 13H15C15.5523 13 16 13.4477 16 14V21",strokeWidth:"1",fill:"none"}),wn("path",{d:"M10.2222 17H13.7777",strokeWidth:"1",strokeLinecap:"round",strokeLinejoin:"round"}),wn("path",{d:"M12 15.2227V18.7782",strokeWidth:"1",strokeLinecap:"round",strokeLinejoin:"round"})]});var Q=(a=>(a.START_EVENT="START_EVENT",a.END_EVENT="END_EVENT",a.TASK="TASK",a.LANE="LANE",a.GATEWAY="GATEWAY",a.ANNOTATION="ANNOTATION",a.UNSUPPORTED="UNSUPPORTED",a))(Q||{}),Pe=(n=>(n.SCRIPT="SCRIPT",n.SUBPROCESS="SUBPROCESS",n.SERVICE_TASK="SERVICE_TASK",n))(Pe||{}),In={SCRIPT:{icon:uf},SUBPROCESS:{icon:pf},SERVICE_TASK:{icon:cf}},$e=(t=>(t.LOOP="LOOP",t))($e||{}),An={LOOP:{icon:df}},ke=(n=>(n.EXCLUSIVE="EXCLUSIVE",n.PARALLEL="PARALLEL",n.COMPLEX="COMPLEX",n))(ke||{}),Ni={EXCLUSIVE:{icon:Zt},PARALLEL:{icon:Jt},COMPLEX:{icon:qt}};import{useTranslation as Y1}from"@produto-lecom/lecom-ui";import{ReactFlowProvider as W1}from"@xyflow/react";import{createContext as X1,useContext as U1,useEffect as $1,useId as K1,useMemo as Hp,useRef as q1,useState as Fe}from"react";import{Background as E1,MiniMap as _1,ReactFlow as b1,SelectionMode as T1,useKeyPress as v1}from"@xyflow/react";import{forwardRef as N1,useImperativeHandle as w1,useRef as kp}from"react";import{useEdgesState as lE,useNodesState as cE,useReactFlow as dE,useStoreApi as uE}from"@xyflow/react";import{useCallback as Wt,useEffect as pE}from"react";import{Position as Mo}from"@xyflow/react";var ff={START_EVENT:"ellipse",END_EVENT:"ellipse",TASK:"rectangle",GATEWAY:"rectangle",LANE:"rectangle",ANNOTATION:"rectangle",UNSUPPORTED:"rectangle"};function et(e){var o,n,r,i,s,a,l;return{bounds:{x:e.internals.positionAbsolute.x,y:e.internals.positionAbsolute.y,width:(r=(n=(o=e.measured)==null?void 0:o.width)!=null?n:e.width)!=null?r:0,height:(a=(s=(i=e.measured)==null?void 0:i.height)!=null?s:e.height)!=null?a:0},perimeter:(l=ff[e.type])!=null?l:"rectangle"}}function Cn(e,t){let o=e==null?void 0:e.controlPoint;return o?I(T({},e),{controlPoint:{x:o.x+t,y:o.y+t}}):e}function da(e,t){var y,v,b,N;let{width:o=0,height:n=0}=e.measured||{width:0,height:0},r=e.internals.positionAbsolute,i=t.internals.positionAbsolute,s=o/2,a=n/2,l=r.x+s,c=r.y+a,d=i.x+((v=(y=t==null?void 0:t.measured)==null?void 0:y.width)!=null?v:0)/2,u=i.y+((N=(b=t==null?void 0:t.measured)==null?void 0:b.height)!=null?N:0)/2,p=(d-l)/(2*s)-(u-c)/(2*a),f=(d-l)/(2*s)+(u-c)/(2*a),x=1/(Math.abs(p)+Math.abs(f)||1),E=x*p,m=x*f,h=s*(E+m)+l,g=a*(-E+m)+c;return{x:h,y:g}}function ua(e,t){var c,d,u,p;let{positionAbsolute:o}=e.internals,n=(d=(c=e.measured)==null?void 0:c.width)!=null?d:0,r=(p=(u=e.measured)==null?void 0:u.height)!=null?p:0,i=Math.round(o.x),s=Math.round(o.y),a=Math.round(t.x),l=Math.round(t.y);return a<=i+1?Mo.Left:a>=i+n-1?Mo.Right:l<=s+1?Mo.Top:l>=s+r-1?Mo.Bottom:Mo.Top}function Sn(e,t){let o=da(e,t),n=da(t,e),r=ua(e,o),i=ua(t,n);return{sx:o.x,sy:o.y,tx:n.x,ty:n.y,sourcePos:r,targetPos:i}}function Mn(e,t){return{isFromStartEvent:(e==null?void 0:e.type)==="START_EVENT",isGatewayToGateway:(e==null?void 0:e.type)==="GATEWAY"&&(t==null?void 0:t.type)==="GATEWAY",isActiviyToAndGateway:(e==null?void 0:e.type)==="TASK"&&(t==null?void 0:t.type)==="GATEWAY",isToEndEvent:(t==null?void 0:t.type)==="END_EVENT"}}import{orderBy as mf}from"lodash";var Pn=e=>e.some(t=>t.type==="position"&&t.dragging),pa=e=>new Map(e.map(t=>[t.id,t])),wt=(e,t)=>{let o=e?t.find(s=>s.id===e):void 0;if(!o)return{x:0,y:0};let{x:n,y:r}=o.position,i=o.parentId;for(;i;){let s=t.find(a=>a.id===i);if(!s)break;n+=s.position.x,r+=s.position.y,i=s.parentId}return{x:n,y:r}},fa=(e,t)=>e.map(o=>{var n;return(n=t.get(o.id))!=null?n:o}),Re=e=>{var t,o,n,r,i,s,a,l;return{x:(o=(t=e.internals)==null?void 0:t.positionAbsolute.x)!=null?o:0,y:(r=(n=e.internals)==null?void 0:n.positionAbsolute.y)!=null?r:0,w:(s=(i=e.measured)==null?void 0:i.width)!=null?s:0,h:(l=(a=e.measured)==null?void 0:a.height)!=null?l:0}},It=e=>mf(e,[o=>{let n=o.type==="LANE";return n&&!o.parentId?0:n?1:2}],["asc"]),ma=(e,t)=>{let{x:o,y:n}=Re(e),{x:r,y:i}=Re(t);return{x:o-r,y:n-i}};var At=({parentId:e,nodes:t,includeTypes:o=[...Object.values(Q)],excludeTypes:n=[]})=>t.some(r=>r.parentId===e&&(!o.length||o.includes(r.type))&&!n.includes(r.type)),gf=(e,t)=>{let{x:o,y:n}=Re(e),{x:r,y:i}=Re(t),s=o-r,a=n-i;return Math.sqrt(s*s+a*a)},hf=(e,t)=>{let{x:o,y:n,w:r,h:i}=Re(e),{x:s,y:a,w:l,h:c}=Re(t),d=o+r/2,u=n+i/2;return d>=s&&d<=s+l&&u>=a&&u<=a+c},Qt=(e,t)=>{let o=null,n=1/0;for(let r of t)if(r.id!==e.id&&hf(e,r)){let i=gf(e,r);i<n&&(n=i,o=r)}return o},ga=(e,t)=>t.filter(o=>o.parentId===e).reduce((o,n)=>{var r,i;return Math.max(o,(i=(r=n.measured)==null?void 0:r.width)!=null?i:0)},0);var ha=e=>{let t=e.filter(s=>!s.parentId);if(t.length===0)return null;let o=1/0,n=1/0,r=-1/0,i=-1/0;for(let s of t){let{position:a,width:l,height:c}=s,d=a.x+(l||0),u=a.y+(c||0);a.x<o&&(o=a.x),a.y<n&&(n=a.y),d>r&&(r=d),u>i&&(i=u)}return{x:o,y:n,w:r-o,h:i-n}},ya=({bounds:e,canvasWidth:t,canvasHeight:o,minZoom:n=.5,maxZoom:r=5,offsetX:i=0,offsetY:s=0})=>{let a=t-i*2,l=o-s*2,c=Math.min(a/e.w,l/e.h),d=Math.min(1,c),u=Math.min(Math.max(d,n),r);return{x:-e.x*u+i,y:-e.y*u+s,zoom:u}};var wi=(e,t)=>{let o=t.find(s=>s.id===e);if(!o||o.type!=="LANE"||o.parentId)return!1;let n=Re(o),r=n.x+n.w,i=n.y+n.h;return t.some(s=>{if(s.id===e||s.parentId||s.type==="LANE")return!1;let a=Re(s);return a.x<r&&a.x+a.w>n.x&&a.y<i&&a.y+a.h>n.y})};import{useCallback as xf}from"react";import{create as Ef}from"zustand";import{useStoreApi as yf}from"@xyflow/react";var Ke=()=>{let e=yf();return{selectElements:n=>{let{edges:r,nodes:i,triggerEdgeChanges:s,triggerNodeChanges:a}=e.getState(),l=i.reduce((d,u)=>[...d,{id:u.id,type:"select",selected:n.includes(u.id)}],[]),c=r.reduce((d,u)=>[...d,{id:u.id,type:"select",selected:n.includes(u.id)}],[]);return a(l),s(c),!0},clearSelection:async()=>{let{unselectNodesAndEdges:n}=e.getState();return n(),await vn(),!0}}};var xa=()=>{let{selectElements:e}=Ke();return xf(()=>{let o=Ct.getState().pathEdgeIds;e(o)},[e])},Ct=Ef((e,t)=>({statusByNodeId:{},statusData:{},pathEdgeIds:[],setTaskStatuses:o=>{o!=null&&o.length&&e(n=>{let r=T({},n.statusByNodeId),i=T({},n.statusData),s=!1;return o.forEach(a=>{let l=`${a.diagramId}-${a.activityId}`;r[a.diagramId]!==a.status&&(r[a.diagramId]=a.status,i[l]=a,s=!0)}),s?{statusByNodeId:r,statusData:i}:n})},getTaskStatus:o=>t().statusByNodeId[o]||null,clearTaskStatuses:()=>e({statusByNodeId:{},statusData:{},pathEdgeIds:[]}),setPathEdges:o=>{e({pathEdgeIds:o})},getPathEdgeIds:()=>t().pathEdgeIds,clearPathEdges:()=>{e({pathEdgeIds:[]})},calculateFlowPath:(o,n)=>{if(!o.length||!n.length)return;t().clearPathEdges();let r=n.filter(d=>t().statusByNodeId[d]);if(r.length<=1)return;let i=[],s={};o.forEach(d=>{s[d.source]||(s[d.source]=[]),s[d.source].push({targetId:d.target,edgeId:d.id})});let a=r[0],l=r[r.length-1];o.forEach(d=>{d.target===a&&i.push(d.id)}),o.forEach(d=>{d.source===l&&i.push(d.id)});let c=(d,u)=>{let p=[],f=new Set;for(p.push({node:d,path:[]}),f.add(d);p.length>0;){let{node:x,path:E}=p.shift();if(x===u)return E;let m=s[x]||[];for(let{targetId:h,edgeId:g}of m)f.has(h)||(f.add(h),p.push({node:h,path:[...E,g]}))}return[]};for(let d=0;d<r.length-1;d++){let u=r[d],p=r[d+1],f=c(u,p);f.length>0&&i.push(...f)}i.length>0&&e({pathEdgeIds:i})}}));import{useNodesInitialized as kg,useReactFlow as Rg,useStore as Og}from"@xyflow/react";import{useCallback as Xo,useEffect as Vg,useRef as Hg,useState as pc}from"react";import{shallow as Gg}from"zustand/shallow";var _f={value:()=>{}};function _a(){for(var e=0,t=arguments.length,o={},n;e<t;++e){if(!(n=arguments[e]+"")||n in o||/[\s.]/.test(n))throw new Error("illegal type: "+n);o[n]=[]}return new Ln(o)}function Ln(e){this._=e}function bf(e,t){return e.trim().split(/^|\s+/).map(function(o){var n="",r=o.indexOf(".");if(r>=0&&(n=o.slice(r+1),o=o.slice(0,r)),o&&!t.hasOwnProperty(o))throw new Error("unknown type: "+o);return{type:o,name:n}})}Ln.prototype=_a.prototype={constructor:Ln,on:function(e,t){var o=this._,n=bf(e+"",o),r,i=-1,s=n.length;if(arguments.length<2){for(;++i<s;)if((r=(e=n[i]).type)&&(r=Tf(o[r],e.name)))return r;return}if(t!=null&&typeof t!="function")throw new Error("invalid callback: "+t);for(;++i<s;)if(r=(e=n[i]).type)o[r]=Ea(o[r],e.name,t);else if(t==null)for(r in o)o[r]=Ea(o[r],e.name,null);return this},copy:function(){var e={},t=this._;for(var o in t)e[o]=t[o].slice();return new Ln(e)},call:function(e,t){if((r=arguments.length-2)>0)for(var o=new Array(r),n=0,r,i;n<r;++n)o[n]=arguments[n+2];if(!this._.hasOwnProperty(e))throw new Error("unknown type: "+e);for(i=this._[e],n=0,r=i.length;n<r;++n)i[n].value.apply(t,o)},apply:function(e,t,o){if(!this._.hasOwnProperty(e))throw new Error("unknown type: "+e);for(var n=this._[e],r=0,i=n.length;r<i;++r)n[r].value.apply(t,o)}};function Tf(e,t){for(var o=0,n=e.length,r;o<n;++o)if((r=e[o]).name===t)return r.value}function Ea(e,t,o){for(var n=0,r=e.length;n<r;++n)if(e[n].name===t){e[n]=_f,e=e.slice(0,n).concat(e.slice(n+1));break}return o!=null&&e.push({name:t,value:o}),e}var Ii=_a;var Dn="http://www.w3.org/1999/xhtml",Ai={svg:"http://www.w3.org/2000/svg",xhtml:Dn,xlink:"http://www.w3.org/1999/xlink",xml:"http://www.w3.org/XML/1998/namespace",xmlns:"http://www.w3.org/2000/xmlns/"};function tt(e){var t=e+="",o=t.indexOf(":");return o>=0&&(t=e.slice(0,o))!=="xmlns"&&(e=e.slice(o+1)),Ai.hasOwnProperty(t)?{space:Ai[t],local:e}:e}function vf(e){return function(){var t=this.ownerDocument,o=this.namespaceURI;return o===Dn&&t.documentElement.namespaceURI===Dn?t.createElement(e):t.createElementNS(o,e)}}function Nf(e){return function(){return this.ownerDocument.createElementNS(e.space,e.local)}}function kn(e){var t=tt(e);return(t.local?Nf:vf)(t)}function wf(){}function St(e){return e==null?wf:function(){return this.querySelector(e)}}function ba(e){typeof e!="function"&&(e=St(e));for(var t=this._groups,o=t.length,n=new Array(o),r=0;r<o;++r)for(var i=t[r],s=i.length,a=n[r]=new Array(s),l,c,d=0;d<s;++d)(l=i[d])&&(c=e.call(l,l.__data__,d,i))&&("__data__"in l&&(c.__data__=l.__data__),a[d]=c);return new fe(n,this._parents)}function Ci(e){return e==null?[]:Array.isArray(e)?e:Array.from(e)}function If(){return[]}function Po(e){return e==null?If:function(){return this.querySelectorAll(e)}}function Af(e){return function(){return Ci(e.apply(this,arguments))}}function Ta(e){typeof e=="function"?e=Af(e):e=Po(e);for(var t=this._groups,o=t.length,n=[],r=[],i=0;i<o;++i)for(var s=t[i],a=s.length,l,c=0;c<a;++c)(l=s[c])&&(n.push(e.call(l,l.__data__,c,s)),r.push(l));return new fe(n,r)}function Lo(e){return function(){return this.matches(e)}}function Rn(e){return function(t){return t.matches(e)}}var Cf=Array.prototype.find;function Sf(e){return function(){return Cf.call(this.children,e)}}function Mf(){return this.firstElementChild}function va(e){return this.select(e==null?Mf:Sf(typeof e=="function"?e:Rn(e)))}var Pf=Array.prototype.filter;function Lf(){return Array.from(this.children)}function Df(e){return function(){return Pf.call(this.children,e)}}function Na(e){return this.selectAll(e==null?Lf:Df(typeof e=="function"?e:Rn(e)))}function wa(e){typeof e!="function"&&(e=Lo(e));for(var t=this._groups,o=t.length,n=new Array(o),r=0;r<o;++r)for(var i=t[r],s=i.length,a=n[r]=[],l,c=0;c<s;++c)(l=i[c])&&e.call(l,l.__data__,c,i)&&a.push(l);return new fe(n,this._parents)}function On(e){return new Array(e.length)}function Ia(){return new fe(this._enter||this._groups.map(On),this._parents)}function Do(e,t){this.ownerDocument=e.ownerDocument,this.namespaceURI=e.namespaceURI,this._next=null,this._parent=e,this.__data__=t}Do.prototype={constructor:Do,appendChild:function(e){return this._parent.insertBefore(e,this._next)},insertBefore:function(e,t){return this._parent.insertBefore(e,t)},querySelector:function(e){return this._parent.querySelector(e)},querySelectorAll:function(e){return this._parent.querySelectorAll(e)}};function Aa(e){return function(){return e}}function kf(e,t,o,n,r,i){for(var s=0,a,l=t.length,c=i.length;s<c;++s)(a=t[s])?(a.__data__=i[s],n[s]=a):o[s]=new Do(e,i[s]);for(;s<l;++s)(a=t[s])&&(r[s]=a)}function Rf(e,t,o,n,r,i,s){var a,l,c=new Map,d=t.length,u=i.length,p=new Array(d),f;for(a=0;a<d;++a)(l=t[a])&&(p[a]=f=s.call(l,l.__data__,a,t)+"",c.has(f)?r[a]=l:c.set(f,l));for(a=0;a<u;++a)f=s.call(e,i[a],a,i)+"",(l=c.get(f))?(n[a]=l,l.__data__=i[a],c.delete(f)):o[a]=new Do(e,i[a]);for(a=0;a<d;++a)(l=t[a])&&c.get(p[a])===l&&(r[a]=l)}function Of(e){return e.__data__}function Ca(e,t){if(!arguments.length)return Array.from(this,Of);var o=t?Rf:kf,n=this._parents,r=this._groups;typeof e!="function"&&(e=Aa(e));for(var i=r.length,s=new Array(i),a=new Array(i),l=new Array(i),c=0;c<i;++c){var d=n[c],u=r[c],p=u.length,f=Vf(e.call(d,d&&d.__data__,c,n)),x=f.length,E=a[c]=new Array(x),m=s[c]=new Array(x),h=l[c]=new Array(p);o(d,u,E,m,h,f,t);for(var g=0,y=0,v,b;g<x;++g)if(v=E[g]){for(g>=y&&(y=g+1);!(b=m[y])&&++y<x;);v._next=b||null}}return s=new fe(s,n),s._enter=a,s._exit=l,s}function Vf(e){return typeof e=="object"&&"length"in e?e:Array.from(e)}function Sa(){return new fe(this._exit||this._groups.map(On),this._parents)}function Ma(e,t,o){var n=this.enter(),r=this,i=this.exit();return typeof e=="function"?(n=e(n),n&&(n=n.selection())):n=n.append(e+""),t!=null&&(r=t(r),r&&(r=r.selection())),o==null?i.remove():o(i),n&&r?n.merge(r).order():r}function Pa(e){for(var t=e.selection?e.selection():e,o=this._groups,n=t._groups,r=o.length,i=n.length,s=Math.min(r,i),a=new Array(r),l=0;l<s;++l)for(var c=o[l],d=n[l],u=c.length,p=a[l]=new Array(u),f,x=0;x<u;++x)(f=c[x]||d[x])&&(p[x]=f);for(;l<r;++l)a[l]=o[l];return new fe(a,this._parents)}function La(){for(var e=this._groups,t=-1,o=e.length;++t<o;)for(var n=e[t],r=n.length-1,i=n[r],s;--r>=0;)(s=n[r])&&(i&&s.compareDocumentPosition(i)^4&&i.parentNode.insertBefore(s,i),i=s);return this}function Da(e){e||(e=Hf);function t(u,p){return u&&p?e(u.__data__,p.__data__):!u-!p}for(var o=this._groups,n=o.length,r=new Array(n),i=0;i<n;++i){for(var s=o[i],a=s.length,l=r[i]=new Array(a),c,d=0;d<a;++d)(c=s[d])&&(l[d]=c);l.sort(t)}return new fe(r,this._parents).order()}function Hf(e,t){return e<t?-1:e>t?1:e>=t?0:NaN}function ka(){var e=arguments[0];return arguments[0]=this,e.apply(null,arguments),this}function Ra(){return Array.from(this)}function Oa(){for(var e=this._groups,t=0,o=e.length;t<o;++t)for(var n=e[t],r=0,i=n.length;r<i;++r){var s=n[r];if(s)return s}return null}function Va(){let e=0;for(let t of this)++e;return e}function Ha(){return!this.node()}function Ga(e){for(var t=this._groups,o=0,n=t.length;o<n;++o)for(var r=t[o],i=0,s=r.length,a;i<s;++i)(a=r[i])&&e.call(a,a.__data__,i,r);return this}function Gf(e){return function(){this.removeAttribute(e)}}function Bf(e){return function(){this.removeAttributeNS(e.space,e.local)}}function zf(e,t){return function(){this.setAttribute(e,t)}}function Ff(e,t){return function(){this.setAttributeNS(e.space,e.local,t)}}function Yf(e,t){return function(){var o=t.apply(this,arguments);o==null?this.removeAttribute(e):this.setAttribute(e,o)}}function Wf(e,t){return function(){var o=t.apply(this,arguments);o==null?this.removeAttributeNS(e.space,e.local):this.setAttributeNS(e.space,e.local,o)}}function Ba(e,t){var o=tt(e);if(arguments.length<2){var n=this.node();return o.local?n.getAttributeNS(o.space,o.local):n.getAttribute(o)}return this.each((t==null?o.local?Bf:Gf:typeof t=="function"?o.local?Wf:Yf:o.local?Ff:zf)(o,t))}function Vn(e){return e.ownerDocument&&e.ownerDocument.defaultView||e.document&&e||e.defaultView}function Xf(e){return function(){this.style.removeProperty(e)}}function Uf(e,t,o){return function(){this.style.setProperty(e,t,o)}}function $f(e,t,o){return function(){var n=t.apply(this,arguments);n==null?this.style.removeProperty(e):this.style.setProperty(e,n,o)}}function za(e,t,o){return arguments.length>1?this.each((t==null?Xf:typeof t=="function"?$f:Uf)(e,t,o==null?"":o)):ft(this.node(),e)}function ft(e,t){return e.style.getPropertyValue(t)||Vn(e).getComputedStyle(e,null).getPropertyValue(t)}function Kf(e){return function(){delete this[e]}}function qf(e,t){return function(){this[e]=t}}function Zf(e,t){return function(){var o=t.apply(this,arguments);o==null?delete this[e]:this[e]=o}}function Fa(e,t){return arguments.length>1?this.each((t==null?Kf:typeof t=="function"?Zf:qf)(e,t)):this.node()[e]}function Ya(e){return e.trim().split(/^|\s+/)}function Si(e){return e.classList||new Wa(e)}function Wa(e){this._node=e,this._names=Ya(e.getAttribute("class")||"")}Wa.prototype={add:function(e){var t=this._names.indexOf(e);t<0&&(this._names.push(e),this._node.setAttribute("class",this._names.join(" ")))},remove:function(e){var t=this._names.indexOf(e);t>=0&&(this._names.splice(t,1),this._node.setAttribute("class",this._names.join(" ")))},contains:function(e){return this._names.indexOf(e)>=0}};function Xa(e,t){for(var o=Si(e),n=-1,r=t.length;++n<r;)o.add(t[n])}function Ua(e,t){for(var o=Si(e),n=-1,r=t.length;++n<r;)o.remove(t[n])}function Jf(e){return function(){Xa(this,e)}}function Qf(e){return function(){Ua(this,e)}}function jf(e,t){return function(){(t.apply(this,arguments)?Xa:Ua)(this,e)}}function $a(e,t){var o=Ya(e+"");if(arguments.length<2){for(var n=Si(this.node()),r=-1,i=o.length;++r<i;)if(!n.contains(o[r]))return!1;return!0}return this.each((typeof t=="function"?jf:t?Jf:Qf)(o,t))}function em(){this.textContent=""}function tm(e){return function(){this.textContent=e}}function om(e){return function(){var t=e.apply(this,arguments);this.textContent=t==null?"":t}}function Ka(e){return arguments.length?this.each(e==null?em:(typeof e=="function"?om:tm)(e)):this.node().textContent}function nm(){this.innerHTML=""}function rm(e){return function(){this.innerHTML=e}}function im(e){return function(){var t=e.apply(this,arguments);this.innerHTML=t==null?"":t}}function qa(e){return arguments.length?this.each(e==null?nm:(typeof e=="function"?im:rm)(e)):this.node().innerHTML}function sm(){this.nextSibling&&this.parentNode.appendChild(this)}function Za(){return this.each(sm)}function am(){this.previousSibling&&this.parentNode.insertBefore(this,this.parentNode.firstChild)}function Ja(){return this.each(am)}function Qa(e){var t=typeof e=="function"?e:kn(e);return this.select(function(){return this.appendChild(t.apply(this,arguments))})}function lm(){return null}function ja(e,t){var o=typeof e=="function"?e:kn(e),n=t==null?lm:typeof t=="function"?t:St(t);return this.select(function(){return this.insertBefore(o.apply(this,arguments),n.apply(this,arguments)||null)})}function cm(){var e=this.parentNode;e&&e.removeChild(this)}function el(){return this.each(cm)}function dm(){var e=this.cloneNode(!1),t=this.parentNode;return t?t.insertBefore(e,this.nextSibling):e}function um(){var e=this.cloneNode(!0),t=this.parentNode;return t?t.insertBefore(e,this.nextSibling):e}function tl(e){return this.select(e?um:dm)}function ol(e){return arguments.length?this.property("__data__",e):this.node().__data__}function pm(e){return function(t){e.call(this,t,this.__data__)}}function fm(e){return e.trim().split(/^|\s+/).map(function(t){var o="",n=t.indexOf(".");return n>=0&&(o=t.slice(n+1),t=t.slice(0,n)),{type:t,name:o}})}function mm(e){return function(){var t=this.__on;if(t){for(var o=0,n=-1,r=t.length,i;o<r;++o)i=t[o],(!e.type||i.type===e.type)&&i.name===e.name?this.removeEventListener(i.type,i.listener,i.options):t[++n]=i;++n?t.length=n:delete this.__on}}}function gm(e,t,o){return function(){var n=this.__on,r,i=pm(t);if(n){for(var s=0,a=n.length;s<a;++s)if((r=n[s]).type===e.type&&r.name===e.name){this.removeEventListener(r.type,r.listener,r.options),this.addEventListener(r.type,r.listener=i,r.options=o),r.value=t;return}}this.addEventListener(e.type,i,o),r={type:e.type,name:e.name,value:t,listener:i,options:o},n?n.push(r):this.__on=[r]}}function nl(e,t,o){var n=fm(e+""),r,i=n.length,s;if(arguments.length<2){var a=this.node().__on;if(a){for(var l=0,c=a.length,d;l<c;++l)for(r=0,d=a[l];r<i;++r)if((s=n[r]).type===d.type&&s.name===d.name)return d.value}return}for(a=t?gm:mm,r=0;r<i;++r)this.each(a(n[r],t,o));return this}function rl(e,t,o){var n=Vn(e),r=n.CustomEvent;typeof r=="function"?r=new r(t,o):(r=n.document.createEvent("Event"),o?(r.initEvent(t,o.bubbles,o.cancelable),r.detail=o.detail):r.initEvent(t,!1,!1)),e.dispatchEvent(r)}function hm(e,t){return function(){return rl(this,e,t)}}function ym(e,t){return function(){return rl(this,e,t.apply(this,arguments))}}function il(e,t){return this.each((typeof t=="function"?ym:hm)(e,t))}function*sl(){for(var e=this._groups,t=0,o=e.length;t<o;++t)for(var n=e[t],r=0,i=n.length,s;r<i;++r)(s=n[r])&&(yield s)}var xm=[null];function fe(e,t){this._groups=e,this._parents=t}function al(){return new fe([[document.documentElement]],xm)}function Em(){return this}fe.prototype=al.prototype={constructor:fe,select:ba,selectAll:Ta,selectChild:va,selectChildren:Na,filter:wa,data:Ca,enter:Ia,exit:Sa,join:Ma,merge:Pa,selection:Em,order:La,sort:Da,call:ka,nodes:Ra,node:Oa,size:Va,empty:Ha,each:Ga,attr:Ba,style:za,property:Fa,classed:$a,text:Ka,html:qa,raise:Za,lower:Ja,append:Qa,insert:ja,remove:el,clone:tl,datum:ol,on:nl,dispatch:il,[Symbol.iterator]:sl};var ot=al;function Hn(e,t,o){e.prototype=t.prototype=o,o.constructor=e}function Mi(e,t){var o=Object.create(e.prototype);for(var n in t)o[n]=t[n];return o}function Oo(){}var ko=.7,zn=1/ko,jt="\\s*([+-]?\\d+)\\s*",Ro="\\s*([+-]?(?:\\d*\\.)?\\d+(?:[eE][+-]?\\d+)?)\\s*",qe="\\s*([+-]?(?:\\d*\\.)?\\d+(?:[eE][+-]?\\d+)?)%\\s*",_m=/^#([0-9a-f]{3,8})$/,bm=new RegExp(`^rgb\\(${jt},${jt},${jt}\\)$`),Tm=new RegExp(`^rgb\\(${qe},${qe},${qe}\\)$`),vm=new RegExp(`^rgba\\(${jt},${jt},${jt},${Ro}\\)$`),Nm=new RegExp(`^rgba\\(${qe},${qe},${qe},${Ro}\\)$`),wm=new RegExp(`^hsl\\(${Ro},${qe},${qe}\\)$`),Im=new RegExp(`^hsla\\(${Ro},${qe},${qe},${Ro}\\)$`),ll={aliceblue:15792383,antiquewhite:16444375,aqua:65535,aquamarine:8388564,azure:15794175,beige:16119260,bisque:16770244,black:0,blanchedalmond:16772045,blue:255,blueviolet:9055202,brown:10824234,burlywood:14596231,cadetblue:6266528,chartreuse:8388352,chocolate:13789470,coral:16744272,cornflowerblue:6591981,cornsilk:16775388,crimson:14423100,cyan:65535,darkblue:139,darkcyan:35723,darkgoldenrod:12092939,darkgray:11119017,darkgreen:25600,darkgrey:11119017,darkkhaki:12433259,darkmagenta:9109643,darkolivegreen:5597999,darkorange:16747520,darkorchid:10040012,darkred:9109504,darksalmon:15308410,darkseagreen:9419919,darkslateblue:4734347,darkslategray:3100495,darkslategrey:3100495,darkturquoise:52945,darkviolet:9699539,deeppink:16716947,deepskyblue:49151,dimgray:6908265,dimgrey:6908265,dodgerblue:2003199,firebrick:11674146,floralwhite:16775920,forestgreen:2263842,fuchsia:16711935,gainsboro:14474460,ghostwhite:16316671,gold:16766720,goldenrod:14329120,gray:8421504,green:32768,greenyellow:11403055,grey:8421504,honeydew:15794160,hotpink:16738740,indianred:13458524,indigo:4915330,ivory:16777200,khaki:15787660,lavender:15132410,lavenderblush:16773365,lawngreen:8190976,lemonchiffon:16775885,lightblue:11393254,lightcoral:15761536,lightcyan:14745599,lightgoldenrodyellow:16448210,lightgray:13882323,lightgreen:9498256,lightgrey:13882323,lightpink:16758465,lightsalmon:16752762,lightseagreen:2142890,lightskyblue:8900346,lightslategray:7833753,lightslategrey:7833753,lightsteelblue:11584734,lightyellow:16777184,lime:65280,limegreen:3329330,linen:16445670,magenta:16711935,maroon:8388608,mediumaquamarine:6737322,mediumblue:205,mediumorchid:12211667,mediumpurple:9662683,mediumseagreen:3978097,mediumslateblue:8087790,mediumspringgreen:64154,mediumturquoise:4772300,mediumvioletred:13047173,midnightblue:1644912,mintcream:16121850,mistyrose:16770273,moccasin:16770229,navajowhite:16768685,navy:128,oldlace:16643558,olive:8421376,olivedrab:7048739,orange:16753920,orangered:16729344,orchid:14315734,palegoldenrod:15657130,palegreen:10025880,paleturquoise:11529966,palevioletred:14381203,papayawhip:16773077,peachpuff:16767673,peru:13468991,pink:16761035,plum:14524637,powderblue:11591910,purple:8388736,rebeccapurple:6697881,red:16711680,rosybrown:12357519,royalblue:4286945,saddlebrown:9127187,salmon:16416882,sandybrown:16032864,seagreen:3050327,seashell:16774638,sienna:10506797,silver:12632256,skyblue:8900331,slateblue:6970061,slategray:7372944,slategrey:7372944,snow:16775930,springgreen:65407,steelblue:4620980,tan:13808780,teal:32896,thistle:14204888,tomato:16737095,turquoise:4251856,violet:15631086,wheat:16113331,white:16777215,whitesmoke:16119285,yellow:16776960,yellowgreen:10145074};Hn(Oo,mt,{copy(e){return Object.assign(new this.constructor,this,e)},displayable(){return this.rgb().displayable()},hex:cl,formatHex:cl,formatHex8:Am,formatHsl:Cm,formatRgb:dl,toString:dl});function cl(){return this.rgb().formatHex()}function Am(){return this.rgb().formatHex8()}function Cm(){return hl(this).formatHsl()}function dl(){return this.rgb().formatRgb()}function mt(e){var t,o;return e=(e+"").trim().toLowerCase(),(t=_m.exec(e))?(o=t[1].length,t=parseInt(t[1],16),o===6?ul(t):o===3?new Ce(t>>8&15|t>>4&240,t>>4&15|t&240,(t&15)<<4|t&15,1):o===8?Gn(t>>24&255,t>>16&255,t>>8&255,(t&255)/255):o===4?Gn(t>>12&15|t>>8&240,t>>8&15|t>>4&240,t>>4&15|t&240,((t&15)<<4|t&15)/255):null):(t=bm.exec(e))?new Ce(t[1],t[2],t[3],1):(t=Tm.exec(e))?new Ce(t[1]*255/100,t[2]*255/100,t[3]*255/100,1):(t=vm.exec(e))?Gn(t[1],t[2],t[3],t[4]):(t=Nm.exec(e))?Gn(t[1]*255/100,t[2]*255/100,t[3]*255/100,t[4]):(t=wm.exec(e))?ml(t[1],t[2]/100,t[3]/100,1):(t=Im.exec(e))?ml(t[1],t[2]/100,t[3]/100,t[4]):ll.hasOwnProperty(e)?ul(ll[e]):e==="transparent"?new Ce(NaN,NaN,NaN,0):null}function ul(e){return new Ce(e>>16&255,e>>8&255,e&255,1)}function Gn(e,t,o,n){return n<=0&&(e=t=o=NaN),new Ce(e,t,o,n)}function Sm(e){return e instanceof Oo||(e=mt(e)),e?(e=e.rgb(),new Ce(e.r,e.g,e.b,e.opacity)):new Ce}function eo(e,t,o,n){return arguments.length===1?Sm(e):new Ce(e,t,o,n==null?1:n)}function Ce(e,t,o,n){this.r=+e,this.g=+t,this.b=+o,this.opacity=+n}Hn(Ce,eo,Mi(Oo,{brighter(e){return e=e==null?zn:Math.pow(zn,e),new Ce(this.r*e,this.g*e,this.b*e,this.opacity)},darker(e){return e=e==null?ko:Math.pow(ko,e),new Ce(this.r*e,this.g*e,this.b*e,this.opacity)},rgb(){return this},clamp(){return new Ce(Pt(this.r),Pt(this.g),Pt(this.b),Fn(this.opacity))},displayable(){return-.5<=this.r&&this.r<255.5&&-.5<=this.g&&this.g<255.5&&-.5<=this.b&&this.b<255.5&&0<=this.opacity&&this.opacity<=1},hex:pl,formatHex:pl,formatHex8:Mm,formatRgb:fl,toString:fl}));function pl(){return`#${Mt(this.r)}${Mt(this.g)}${Mt(this.b)}`}function Mm(){return`#${Mt(this.r)}${Mt(this.g)}${Mt(this.b)}${Mt((isNaN(this.opacity)?1:this.opacity)*255)}`}function fl(){let e=Fn(this.opacity);return`${e===1?"rgb(":"rgba("}${Pt(this.r)}, ${Pt(this.g)}, ${Pt(this.b)}${e===1?")":`, ${e})`}`}function Fn(e){return isNaN(e)?1:Math.max(0,Math.min(1,e))}function Pt(e){return Math.max(0,Math.min(255,Math.round(e)||0))}function Mt(e){return e=Pt(e),(e<16?"0":"")+e.toString(16)}function ml(e,t,o,n){return n<=0?e=t=o=NaN:o<=0||o>=1?e=t=NaN:t<=0&&(e=NaN),new We(e,t,o,n)}function hl(e){if(e instanceof We)return new We(e.h,e.s,e.l,e.opacity);if(e instanceof Oo||(e=mt(e)),!e)return new We;if(e instanceof We)return e;e=e.rgb();var t=e.r/255,o=e.g/255,n=e.b/255,r=Math.min(t,o,n),i=Math.max(t,o,n),s=NaN,a=i-r,l=(i+r)/2;return a?(t===i?s=(o-n)/a+(o<n)*6:o===i?s=(n-t)/a+2:s=(t-o)/a+4,a/=l<.5?i+r:2-i-r,s*=60):a=l>0&&l<1?0:s,new We(s,a,l,e.opacity)}function yl(e,t,o,n){return arguments.length===1?hl(e):new We(e,t,o,n==null?1:n)}function We(e,t,o,n){this.h=+e,this.s=+t,this.l=+o,this.opacity=+n}Hn(We,yl,Mi(Oo,{brighter(e){return e=e==null?zn:Math.pow(zn,e),new We(this.h,this.s,this.l*e,this.opacity)},darker(e){return e=e==null?ko:Math.pow(ko,e),new We(this.h,this.s,this.l*e,this.opacity)},rgb(){var e=this.h%360+(this.h<0)*360,t=isNaN(e)||isNaN(this.s)?0:this.s,o=this.l,n=o+(o<.5?o:1-o)*t,r=2*o-n;return new Ce(Pi(e>=240?e-240:e+120,r,n),Pi(e,r,n),Pi(e<120?e+240:e-120,r,n),this.opacity)},clamp(){return new We(gl(this.h),Bn(this.s),Bn(this.l),Fn(this.opacity))},displayable(){return(0<=this.s&&this.s<=1||isNaN(this.s))&&0<=this.l&&this.l<=1&&0<=this.opacity&&this.opacity<=1},formatHsl(){let e=Fn(this.opacity);return`${e===1?"hsl(":"hsla("}${gl(this.h)}, ${Bn(this.s)*100}%, ${Bn(this.l)*100}%${e===1?")":`, ${e})`}`}}));function gl(e){return e=(e||0)%360,e<0?e+360:e}function Bn(e){return Math.max(0,Math.min(1,e||0))}function Pi(e,t,o){return(e<60?t+(o-t)*e/60:e<180?o:e<240?t+(o-t)*(240-e)/60:t)*255}function Li(e,t,o,n,r){var i=e*e,s=i*e;return((1-3*e+3*i-s)*t+(4-6*i+3*s)*o+(1+3*e+3*i-3*s)*n+s*r)/6}function xl(e){var t=e.length-1;return function(o){var n=o<=0?o=0:o>=1?(o=1,t-1):Math.floor(o*t),r=e[n],i=e[n+1],s=n>0?e[n-1]:2*r-i,a=n<t-1?e[n+2]:2*i-r;return Li((o-n/t)*t,s,r,i,a)}}function El(e){var t=e.length;return function(o){var n=Math.floor(((o%=1)<0?++o:o)*t),r=e[(n+t-1)%t],i=e[n%t],s=e[(n+1)%t],a=e[(n+2)%t];return Li((o-n/t)*t,r,i,s,a)}}var Di=e=>()=>e;function Pm(e,t){return function(o){return e+o*t}}function Lm(e,t,o){return e=Math.pow(e,o),t=Math.pow(t,o)-e,o=1/o,function(n){return Math.pow(e+n*t,o)}}function _l(e){return(e=+e)==1?Yn:function(t,o){return o-t?Lm(t,o,e):Di(isNaN(t)?o:t)}}function Yn(e,t){var o=t-e;return o?Pm(e,o):Di(isNaN(e)?t:e)}var Wn=(function e(t){var o=_l(t);function n(r,i){var s=o((r=eo(r)).r,(i=eo(i)).r),a=o(r.g,i.g),l=o(r.b,i.b),c=Yn(r.opacity,i.opacity);return function(d){return r.r=s(d),r.g=a(d),r.b=l(d),r.opacity=c(d),r+""}}return n.gamma=e,n})(1);function bl(e){return function(t){var o=t.length,n=new Array(o),r=new Array(o),i=new Array(o),s,a;for(s=0;s<o;++s)a=eo(t[s]),n[s]=a.r||0,r[s]=a.g||0,i[s]=a.b||0;return n=e(n),r=e(r),i=e(i),a.opacity=1,function(l){return a.r=n(l),a.g=r(l),a.b=i(l),a+""}}}var Dm=bl(xl),km=bl(El);function Oe(e,t){return e=+e,t=+t,function(o){return e*(1-o)+t*o}}var Ri=/[-+]?(?:\d+\.?\d*|\.?\d+)(?:[eE][-+]?\d+)?/g,ki=new RegExp(Ri.source,"g");function Rm(e){return function(){return e}}function Om(e){return function(t){return e(t)+""}}function Oi(e,t){var o=Ri.lastIndex=ki.lastIndex=0,n,r,i,s=-1,a=[],l=[];for(e=e+"",t=t+"";(n=Ri.exec(e))&&(r=ki.exec(t));)(i=r.index)>o&&(i=t.slice(o,i),a[s]?a[s]+=i:a[++s]=i),(n=n[0])===(r=r[0])?a[s]?a[s]+=r:a[++s]=r:(a[++s]=null,l.push({i:s,x:Oe(n,r)})),o=ki.lastIndex;return o<t.length&&(i=t.slice(o),a[s]?a[s]+=i:a[++s]=i),a.length<2?l[0]?Om(l[0].x):Rm(t):(t=l.length,function(c){for(var d=0,u;d<t;++d)a[(u=l[d]).i]=u.x(c);return a.join("")})}var Tl=180/Math.PI,Xn={translateX:0,translateY:0,rotate:0,skewX:0,scaleX:1,scaleY:1};function Vi(e,t,o,n,r,i){var s,a,l;return(s=Math.sqrt(e*e+t*t))&&(e/=s,t/=s),(l=e*o+t*n)&&(o-=e*l,n-=t*l),(a=Math.sqrt(o*o+n*n))&&(o/=a,n/=a,l/=a),e*n<t*o&&(e=-e,t=-t,l=-l,s=-s),{translateX:r,translateY:i,rotate:Math.atan2(t,e)*Tl,skewX:Math.atan(l)*Tl,scaleX:s,scaleY:a}}var Un;function vl(e){let t=new(typeof DOMMatrix=="function"?DOMMatrix:WebKitCSSMatrix)(e+"");return t.isIdentity?Xn:Vi(t.a,t.b,t.c,t.d,t.e,t.f)}function Nl(e){return e==null?Xn:(Un||(Un=document.createElementNS("http://www.w3.org/2000/svg","g")),Un.setAttribute("transform",e),(e=Un.transform.baseVal.consolidate())?(e=e.matrix,Vi(e.a,e.b,e.c,e.d,e.e,e.f)):Xn)}function wl(e,t,o,n){function r(c){return c.length?c.pop()+" ":""}function i(c,d,u,p,f,x){if(c!==u||d!==p){var E=f.push("translate(",null,t,null,o);x.push({i:E-4,x:Oe(c,u)},{i:E-2,x:Oe(d,p)})}else(u||p)&&f.push("translate("+u+t+p+o)}function s(c,d,u,p){c!==d?(c-d>180?d+=360:d-c>180&&(c+=360),p.push({i:u.push(r(u)+"rotate(",null,n)-2,x:Oe(c,d)})):d&&u.push(r(u)+"rotate("+d+n)}function a(c,d,u,p){c!==d?p.push({i:u.push(r(u)+"skewX(",null,n)-2,x:Oe(c,d)}):d&&u.push(r(u)+"skewX("+d+n)}function l(c,d,u,p,f,x){if(c!==u||d!==p){var E=f.push(r(f)+"scale(",null,",",null,")");x.push({i:E-4,x:Oe(c,u)},{i:E-2,x:Oe(d,p)})}else(u!==1||p!==1)&&f.push(r(f)+"scale("+u+","+p+")")}return function(c,d){var u=[],p=[];return c=e(c),d=e(d),i(c.translateX,c.translateY,d.translateX,d.translateY,u,p),s(c.rotate,d.rotate,u,p),a(c.skewX,d.skewX,u,p),l(c.scaleX,c.scaleY,d.scaleX,d.scaleY,u,p),c=d=null,function(f){for(var x=-1,E=p.length,m;++x<E;)u[(m=p[x]).i]=m.x(f);return u.join("")}}}var Hi=wl(vl,"px, ","px)","deg)"),Gi=wl(Nl,", ",")",")");var to=0,Ho=0,Vo=0,Al=1e3,$n,Go,Kn=0,Lt=0,qn=0,Bo=typeof performance=="object"&&performance.now?performance:Date,Cl=typeof window=="object"&&window.requestAnimationFrame?window.requestAnimationFrame.bind(window):function(e){setTimeout(e,17)};function Fo(){return Lt||(Cl(Vm),Lt=Bo.now()+qn)}function Vm(){Lt=0}function zo(){this._call=this._time=this._next=null}zo.prototype=Zn.prototype={constructor:zo,restart:function(e,t,o){if(typeof e!="function")throw new TypeError("callback is not a function");o=(o==null?Fo():+o)+(t==null?0:+t),!this._next&&Go!==this&&(Go?Go._next=this:$n=this,Go=this),this._call=e,this._time=o,Bi()},stop:function(){this._call&&(this._call=null,this._time=1/0,Bi())}};function Zn(e,t,o){var n=new zo;return n.restart(e,t,o),n}function Sl(){Fo(),++to;for(var e=$n,t;e;)(t=Lt-e._time)>=0&&e._call.call(void 0,t),e=e._next;--to}function Il(){Lt=(Kn=Bo.now())+qn,to=Ho=0;try{Sl()}finally{to=0,Gm(),Lt=0}}function Hm(){var e=Bo.now(),t=e-Kn;t>Al&&(qn-=t,Kn=e)}function Gm(){for(var e,t=$n,o,n=1/0;t;)t._call?(n>t._time&&(n=t._time),e=t,t=t._next):(o=t._next,t._next=null,t=e?e._next=o:$n=o);Go=e,Bi(n)}function Bi(e){if(!to){Ho&&(Ho=clearTimeout(Ho));var t=e-Lt;t>24?(e<1/0&&(Ho=setTimeout(Il,e-Bo.now()-qn)),Vo&&(Vo=clearInterval(Vo))):(Vo||(Kn=Bo.now(),Vo=setInterval(Hm,Al)),to=1,Cl(Il))}}function Jn(e,t,o){var n=new zo;return t=t==null?0:+t,n.restart(r=>{n.stop(),e(r+t)},t,o),n}var Bm=Ii("start","end","cancel","interrupt"),zm=[],Ll=0,Ml=1,jn=2,Qn=3,Pl=4,er=5,Yo=6;function gt(e,t,o,n,r,i){var s=e.__transition;if(!s)e.__transition={};else if(o in s)return;Fm(e,o,{name:t,index:n,group:r,on:Bm,tween:zm,time:i.time,delay:i.delay,duration:i.duration,ease:i.ease,timer:null,state:Ll})}function Wo(e,t){var o=me(e,t);if(o.state>Ll)throw new Error("too late; already scheduled");return o}function _e(e,t){var o=me(e,t);if(o.state>Qn)throw new Error("too late; already running");return o}function me(e,t){var o=e.__transition;if(!o||!(o=o[t]))throw new Error("transition not found");return o}function Fm(e,t,o){var n=e.__transition,r;n[t]=o,o.timer=Zn(i,0,o.time);function i(c){o.state=Ml,o.timer.restart(s,o.delay,o.time),o.delay<=c&&s(c-o.delay)}function s(c){var d,u,p,f;if(o.state!==Ml)return l();for(d in n)if(f=n[d],f.name===o.name){if(f.state===Qn)return Jn(s);f.state===Pl?(f.state=Yo,f.timer.stop(),f.on.call("interrupt",e,e.__data__,f.index,f.group),delete n[d]):+d<t&&(f.state=Yo,f.timer.stop(),f.on.call("cancel",e,e.__data__,f.index,f.group),delete n[d])}if(Jn(function(){o.state===Qn&&(o.state=Pl,o.timer.restart(a,o.delay,o.time),a(c))}),o.state=jn,o.on.call("start",e,e.__data__,o.index,o.group),o.state===jn){for(o.state=Qn,r=new Array(p=o.tween.length),d=0,u=-1;d<p;++d)(f=o.tween[d].value.call(e,e.__data__,o.index,o.group))&&(r[++u]=f);r.length=u+1}}function a(c){for(var d=c<o.duration?o.ease.call(null,c/o.duration):(o.timer.restart(l),o.state=er,1),u=-1,p=r.length;++u<p;)r[u].call(e,d);o.state===er&&(o.on.call("end",e,e.__data__,o.index,o.group),l())}function l(){o.state=Yo,o.timer.stop(),delete n[t];for(var c in n)return;delete e.__transition}}function zi(e,t){var o=e.__transition,n,r,i=!0,s;if(o){t=t==null?null:t+"";for(s in o){if((n=o[s]).name!==t){i=!1;continue}r=n.state>jn&&n.state<er,n.state=Yo,n.timer.stop(),n.on.call(r?"interrupt":"cancel",e,e.__data__,n.index,n.group),delete o[s]}i&&delete e.__transition}}function Dl(e){return this.each(function(){zi(this,e)})}function Ym(e,t){var o,n;return function(){var r=_e(this,e),i=r.tween;if(i!==o){n=o=i;for(var s=0,a=n.length;s<a;++s)if(n[s].name===t){n=n.slice(),n.splice(s,1);break}}r.tween=n}}function Wm(e,t,o){var n,r;if(typeof o!="function")throw new Error;return function(){var i=_e(this,e),s=i.tween;if(s!==n){r=(n=s).slice();for(var a={name:t,value:o},l=0,c=r.length;l<c;++l)if(r[l].name===t){r[l]=a;break}l===c&&r.push(a)}i.tween=r}}function kl(e,t){var o=this._id;if(e+="",arguments.length<2){for(var n=me(this.node(),o).tween,r=0,i=n.length,s;r<i;++r)if((s=n[r]).name===e)return s.value;return null}return this.each((t==null?Ym:Wm)(o,e,t))}function oo(e,t,o){var n=e._id;return e.each(function(){var r=_e(this,n);(r.value||(r.value={}))[t]=o.apply(this,arguments)}),function(r){return me(r,n).value[t]}}function tr(e,t){var o;return(typeof t=="number"?Oe:t instanceof mt?Wn:(o=mt(t))?(t=o,Wn):Oi)(e,t)}function Xm(e){return function(){this.removeAttribute(e)}}function Um(e){return function(){this.removeAttributeNS(e.space,e.local)}}function $m(e,t,o){var n,r=o+"",i;return function(){var s=this.getAttribute(e);return s===r?null:s===n?i:i=t(n=s,o)}}function Km(e,t,o){var n,r=o+"",i;return function(){var s=this.getAttributeNS(e.space,e.local);return s===r?null:s===n?i:i=t(n=s,o)}}function qm(e,t,o){var n,r,i;return function(){var s,a=o(this),l;return a==null?void this.removeAttribute(e):(s=this.getAttribute(e),l=a+"",s===l?null:s===n&&l===r?i:(r=l,i=t(n=s,a)))}}function Zm(e,t,o){var n,r,i;return function(){var s,a=o(this),l;return a==null?void this.removeAttributeNS(e.space,e.local):(s=this.getAttributeNS(e.space,e.local),l=a+"",s===l?null:s===n&&l===r?i:(r=l,i=t(n=s,a)))}}function Rl(e,t){var o=tt(e),n=o==="transform"?Gi:tr;return this.attrTween(e,typeof t=="function"?(o.local?Zm:qm)(o,n,oo(this,"attr."+e,t)):t==null?(o.local?Um:Xm)(o):(o.local?Km:$m)(o,n,t))}function Jm(e,t){return function(o){this.setAttribute(e,t.call(this,o))}}function Qm(e,t){return function(o){this.setAttributeNS(e.space,e.local,t.call(this,o))}}function jm(e,t){var o,n;function r(){var i=t.apply(this,arguments);return i!==n&&(o=(n=i)&&Qm(e,i)),o}return r._value=t,r}function eg(e,t){var o,n;function r(){var i=t.apply(this,arguments);return i!==n&&(o=(n=i)&&Jm(e,i)),o}return r._value=t,r}function Ol(e,t){var o="attr."+e;if(arguments.length<2)return(o=this.tween(o))&&o._value;if(t==null)return this.tween(o,null);if(typeof t!="function")throw new Error;var n=tt(e);return this.tween(o,(n.local?jm:eg)(n,t))}function tg(e,t){return function(){Wo(this,e).delay=+t.apply(this,arguments)}}function og(e,t){return t=+t,function(){Wo(this,e).delay=t}}function Vl(e){var t=this._id;return arguments.length?this.each((typeof e=="function"?tg:og)(t,e)):me(this.node(),t).delay}function ng(e,t){return function(){_e(this,e).duration=+t.apply(this,arguments)}}function rg(e,t){return t=+t,function(){_e(this,e).duration=t}}function Hl(e){var t=this._id;return arguments.length?this.each((typeof e=="function"?ng:rg)(t,e)):me(this.node(),t).duration}function ig(e,t){if(typeof t!="function")throw new Error;return function(){_e(this,e).ease=t}}function Gl(e){var t=this._id;return arguments.length?this.each(ig(t,e)):me(this.node(),t).ease}function sg(e,t){return function(){var o=t.apply(this,arguments);if(typeof o!="function")throw new Error;_e(this,e).ease=o}}function Bl(e){if(typeof e!="function")throw new Error;return this.each(sg(this._id,e))}function zl(e){typeof e!="function"&&(e=Lo(e));for(var t=this._groups,o=t.length,n=new Array(o),r=0;r<o;++r)for(var i=t[r],s=i.length,a=n[r]=[],l,c=0;c<s;++c)(l=i[c])&&e.call(l,l.__data__,c,i)&&a.push(l);return new we(n,this._parents,this._name,this._id)}function Fl(e){if(e._id!==this._id)throw new Error;for(var t=this._groups,o=e._groups,n=t.length,r=o.length,i=Math.min(n,r),s=new Array(n),a=0;a<i;++a)for(var l=t[a],c=o[a],d=l.length,u=s[a]=new Array(d),p,f=0;f<d;++f)(p=l[f]||c[f])&&(u[f]=p);for(;a<n;++a)s[a]=t[a];return new we(s,this._parents,this._name,this._id)}function ag(e){return(e+"").trim().split(/^|\s+/).every(function(t){var o=t.indexOf(".");return o>=0&&(t=t.slice(0,o)),!t||t==="start"})}function lg(e,t,o){var n,r,i=ag(t)?Wo:_e;return function(){var s=i(this,e),a=s.on;a!==n&&(r=(n=a).copy()).on(t,o),s.on=r}}function Yl(e,t){var o=this._id;return arguments.length<2?me(this.node(),o).on.on(e):this.each(lg(o,e,t))}function cg(e){return function(){var t=this.parentNode;for(var o in this.__transition)if(+o!==e)return;t&&t.removeChild(this)}}function Wl(){return this.on("end.remove",cg(this._id))}function Xl(e){var t=this._name,o=this._id;typeof e!="function"&&(e=St(e));for(var n=this._groups,r=n.length,i=new Array(r),s=0;s<r;++s)for(var a=n[s],l=a.length,c=i[s]=new Array(l),d,u,p=0;p<l;++p)(d=a[p])&&(u=e.call(d,d.__data__,p,a))&&("__data__"in d&&(u.__data__=d.__data__),c[p]=u,gt(c[p],t,o,p,c,me(d,o)));return new we(i,this._parents,t,o)}function Ul(e){var t=this._name,o=this._id;typeof e!="function"&&(e=Po(e));for(var n=this._groups,r=n.length,i=[],s=[],a=0;a<r;++a)for(var l=n[a],c=l.length,d,u=0;u<c;++u)if(d=l[u]){for(var p=e.call(d,d.__data__,u,l),f,x=me(d,o),E=0,m=p.length;E<m;++E)(f=p[E])&&gt(f,t,o,E,p,x);i.push(p),s.push(d)}return new we(i,s,t,o)}var dg=ot.prototype.constructor;function $l(){return new dg(this._groups,this._parents)}function ug(e,t){var o,n,r;return function(){var i=ft(this,e),s=(this.style.removeProperty(e),ft(this,e));return i===s?null:i===o&&s===n?r:r=t(o=i,n=s)}}function Kl(e){return function(){this.style.removeProperty(e)}}function pg(e,t,o){var n,r=o+"",i;return function(){var s=ft(this,e);return s===r?null:s===n?i:i=t(n=s,o)}}function fg(e,t,o){var n,r,i;return function(){var s=ft(this,e),a=o(this),l=a+"";return a==null&&(l=a=(this.style.removeProperty(e),ft(this,e))),s===l?null:s===n&&l===r?i:(r=l,i=t(n=s,a))}}function mg(e,t){var o,n,r,i="style."+t,s="end."+i,a;return function(){var l=_e(this,e),c=l.on,d=l.value[i]==null?a||(a=Kl(t)):void 0;(c!==o||r!==d)&&(n=(o=c).copy()).on(s,r=d),l.on=n}}function ql(e,t,o){var n=(e+="")=="transform"?Hi:tr;return t==null?this.styleTween(e,ug(e,n)).on("end.style."+e,Kl(e)):typeof t=="function"?this.styleTween(e,fg(e,n,oo(this,"style."+e,t))).each(mg(this._id,e)):this.styleTween(e,pg(e,n,t),o).on("end.style."+e,null)}function gg(e,t,o){return function(n){this.style.setProperty(e,t.call(this,n),o)}}function hg(e,t,o){var n,r;function i(){var s=t.apply(this,arguments);return s!==r&&(n=(r=s)&&gg(e,s,o)),n}return i._value=t,i}function Zl(e,t,o){var n="style."+(e+="");if(arguments.length<2)return(n=this.tween(n))&&n._value;if(t==null)return this.tween(n,null);if(typeof t!="function")throw new Error;return this.tween(n,hg(e,t,o==null?"":o))}function yg(e){return function(){this.textContent=e}}function xg(e){return function(){var t=e(this);this.textContent=t==null?"":t}}function Jl(e){return this.tween("text",typeof e=="function"?xg(oo(this,"text",e)):yg(e==null?"":e+""))}function Eg(e){return function(t){this.textContent=e.call(this,t)}}function _g(e){var t,o;function n(){var r=e.apply(this,arguments);return r!==o&&(t=(o=r)&&Eg(r)),t}return n._value=e,n}function Ql(e){var t="text";if(arguments.length<1)return(t=this.tween(t))&&t._value;if(e==null)return this.tween(t,null);if(typeof e!="function")throw new Error;return this.tween(t,_g(e))}function jl(){for(var e=this._name,t=this._id,o=or(),n=this._groups,r=n.length,i=0;i<r;++i)for(var s=n[i],a=s.length,l,c=0;c<a;++c)if(l=s[c]){var d=me(l,t);gt(l,e,o,c,s,{time:d.time+d.delay+d.duration,delay:0,duration:d.duration,ease:d.ease})}return new we(n,this._parents,e,o)}function ec(){var e,t,o=this,n=o._id,r=o.size();return new Promise(function(i,s){var a={value:s},l={value:function(){--r===0&&i()}};o.each(function(){var c=_e(this,n),d=c.on;d!==e&&(t=(e=d).copy(),t._.cancel.push(a),t._.interrupt.push(a),t._.end.push(l)),c.on=t}),r===0&&i()})}var bg=0;function we(e,t,o,n){this._groups=e,this._parents=t,this._name=o,this._id=n}function tc(e){return ot().transition(e)}function or(){return++bg}var nt=ot.prototype;we.prototype=tc.prototype={constructor:we,select:Xl,selectAll:Ul,selectChild:nt.selectChild,selectChildren:nt.selectChildren,filter:zl,merge:Fl,selection:$l,transition:jl,call:nt.call,nodes:nt.nodes,node:nt.node,size:nt.size,empty:nt.empty,each:nt.each,on:Yl,attr:Rl,attrTween:Ol,style:ql,styleTween:Zl,text:Jl,textTween:Ql,remove:Wl,tween:kl,delay:Vl,duration:Hl,ease:Gl,easeVarying:Bl,end:ec,[Symbol.iterator]:nt[Symbol.iterator]};function nr(e){return((e*=2)<=1?e*e*e:(e-=2)*e*e+2)/2}var Tg={time:null,delay:0,duration:250,ease:nr};function vg(e,t){for(var o;!(o=e.__transition)||!(o=o[t]);)if(!(e=e.parentNode))throw new Error(`transition ${t} not found`);return o}function oc(e){var t,o;e instanceof we?(t=e._id,e=e._name):(t=or(),(o=Tg).time=Fo(),e=e==null?null:e+"");for(var n=this._groups,r=n.length,i=0;i<r;++i)for(var s=n[i],a=s.length,l,c=0;c<a;++c)(l=s[c])&&gt(l,e,t,c,s,o||vg(l,t));return new we(n,this._parents,e,t)}ot.prototype.interrupt=Dl;ot.prototype.transition=oc;function ht(e,t,o){this.k=e,this.x=t,this.y=o}ht.prototype={constructor:ht,scale:function(e){return e===1?this:new ht(this.k*e,this.x,this.y)},translate:function(e,t){return e===0&t===0?this:new ht(this.k,this.x+this.k*e,this.y+this.k*t)},apply:function(e){return[e[0]*this.k+this.x,e[1]*this.k+this.y]},applyX:function(e){return e*this.k+this.x},applyY:function(e){return e*this.k+this.y},invert:function(e){return[(e[0]-this.x)/this.k,(e[1]-this.y)/this.k]},invertX:function(e){return(e-this.x)/this.k},invertY:function(e){return(e-this.y)/this.k},rescaleX:function(e){return e.copy().domain(e.range().map(this.invertX,this).map(e.invert,e))},rescaleY:function(e){return e.copy().domain(e.range().map(this.invertY,this).map(e.invert,e))},toString:function(){return"translate("+this.x+","+this.y+") scale("+this.k+")"}};var rr=new ht(1,0,0);ir.prototype=ht.prototype;function ir(e){for(;!e.__zoom;)if(!(e=e.parentNode))return rr;return e.__zoom}var wg=[[Number.NEGATIVE_INFINITY,Number.NEGATIVE_INFINITY],[Number.POSITIVE_INFINITY,Number.POSITIVE_INFINITY]];var nc;(function(e){e.Strict="strict",e.Loose="loose"})(nc||(nc={}));var rc;(function(e){e.Free="free",e.Vertical="vertical",e.Horizontal="horizontal"})(rc||(rc={}));var ic;(function(e){e.Partial="partial",e.Full="full"})(ic||(ic={}));var sc;(function(e){e.Bezier="default",e.Straight="straight",e.Step="step",e.SmoothStep="smoothstep",e.SimpleBezier="simplebezier"})(sc||(sc={}));var ac;(function(e){e.Arrow="arrow",e.ArrowClosed="arrowclosed"})(ac||(ac={}));var Se;(function(e){e.Left="left",e.Top="top",e.Right="right",e.Bottom="bottom"})(Se||(Se={}));var HI={[Se.Left]:Se.Right,[Se.Right]:Se.Left,[Se.Top]:Se.Bottom,[Se.Bottom]:Se.Top};var Ig=e=>"id"in e&&"internals"in e&&!("source"in e)&&!("target"in e);var Ag=(e,t=[0,0])=>{var a;let{width:o,height:n}=Cg(e),r=(a=e.origin)!=null?a:t,i=o*r[0],s=n*r[1];return{x:e.position.x-i,y:e.position.y-s}};var sr=(e,t=[0,0])=>{var r,i,s,a,l,c,d,u;let{x:o,y:n}=Ig(e)?e.internals.positionAbsolute:Ag(e,t);return{x:o,y:n,x2:o+((a=(s=(i=(r=e.measured)==null?void 0:r.width)!=null?i:e.width)!=null?s:e.initialWidth)!=null?a:0),y2:n+((u=(d=(c=(l=e.measured)==null?void 0:l.height)!=null?c:e.height)!=null?d:e.initialHeight)!=null?u:0)}};function Cg(e){var t,o,n,r,i,s,a,l;return{width:(r=(n=(o=(t=e.measured)==null?void 0:t.width)!=null?o:e.width)!=null?n:e.initialWidth)!=null?r:0,height:(l=(a=(s=(i=e.measured)==null?void 0:i.height)!=null?s:e.height)!=null?a:e.initialHeight)!=null?l:0}}var GI={[Se.Left]:{x:-1,y:0},[Se.Right]:{x:1,y:0},[Se.Top]:{x:0,y:-1},[Se.Bottom]:{x:0,y:1}};var Sg={nodeOrigin:[0,0],nodeExtent:wg,elevateNodesOnSelect:!0,defaults:{}},BI=I(T({},Sg),{checkEquality:!0});var lc;(function(e){e.Line="line",e.Handle="handle"})(lc||(lc={}));var Mg={width:0,height:0,x:0,y:0},zI=I(T({},Mg),{pointerX:0,pointerY:0,aspectRatio:1});var Pg=(e,t)=>e.x<t.x2&&e.x2>t.x&&e.y<t.y2&&e.y2>t.y;function Lg(e,t){let o=Math.max(0,Math.min(e.x2,t.x2)-Math.max(e.x,t.x)),n=Math.max(0,Math.min(e.y2,t.y2)-Math.max(e.y,t.y));return o*n}function Dg(e,t){let o=Math.max(0,Math.max(e.x-t.x2,t.x-e.x2)),n=Math.max(0,Math.max(e.y-t.y2,t.y-e.y2));return Math.sqrt(o*o+n*n)}var ar=class{constructor(){this.xLines=[];this.yLines=[]}initialize(t){this.xLines=t.filter(o=>o.orientation==="vertical"),this.yLines=t.filter(o=>o.orientation==="horizontal"),this.xLines.sort((o,n)=>o.position-n.position),this.yLines.sort((o,n)=>o.position-n.position),this.lastHorizontalLine=void 0,this.lastVerticalLine=void 0}search(t,o,n,r,i){let s=t==="horizontal"?this.yLines:this.xLines,[a,l]=t==="horizontal"?[r.y,r.y2]:[r.x,r.x2],c=[];for(let f of s){if(f.position<a)continue;if(f.position>l)break;if(i.has(f.node.id)||f.node.parentId&&i.has(f.node.parentId)||!Pg(f.nodeBox,r))continue;let x=Math.abs(f.position-o);if(x>lr)continue;let m=Lg(f.nodeBox,n)>0?0:Dg(f.nodeBox,n);c.push({line:f,lineDist:x,nodeDist:m})}let d=.5,u=t==="horizontal"?this.lastHorizontalLine:this.lastVerticalLine;c.sort((f,x)=>{if(u){if(f.line===u&&x.line!==u)return-1;if(x.line===u&&f.line!==u)return 1}return Math.abs(f.lineDist-x.lineDist)<=d?f.nodeDist-x.nodeDist:f.lineDist-x.lineDist});let p=c.length>0?c[0].line:void 0;return p&&(t==="horizontal"?this.lastHorizontalLine=p:this.lastVerticalLine=p),p}};function cc(e,t=Dt,o){let n=[];return e==null||e.forEach(r=>{let i=o(r.id);if(!i)throw new Error(`Node with id ${r.id} not found in internal nodes.`);let s=sr(i);Object.entries(t).forEach(([a,l])=>{var c;n.push({position:l.resolve(r,s),color:(c=r.style)==null?void 0:c.backgroundColor,orientation:l.orientation,anchorName:a,nodeBox:s,node:r})})}),n}function dc(e,t,o,n,r=Object.keys(Dt)){let i=[];for(let a of r){let l=Dt[a],c=l.resolve(null,o),d=e.search(l.orientation,c,o,t,n);d&&i.push({sourcePosition:c,anchorName:a,anchor:l,line:d})}let s={horizontal:void 0,vertical:void 0};for(let a of i){let l=s[a.anchor.orientation],c=Math.abs(a.sourcePosition-a.line.position);(!l||c<Math.abs(l.sourcePosition-l.line.position))&&(s[a.anchor.orientation]=a)}return s}function uc(e,t,o){let n=0,r=0,i=!1,s=!1;if(t){let l=t.anchor.resolve(null,e)-t.line.position;Math.abs(l)<=lr&&(r=l,s=!0)}if(o){let l=o.anchor.resolve(null,e)-o.line.position;Math.abs(l)<=lr&&(n=l,i=!0)}return{deltaX:n,deltaY:r,snappedX:i,snappedY:s}}var lr=10,Dt={top:{orientation:"horizontal",resolve:(e,t)=>t.y},bottom:{orientation:"horizontal",resolve:(e,t)=>t.y2},left:{orientation:"vertical",resolve:(e,t)=>t.x},right:{orientation:"vertical",resolve:(e,t)=>t.x2},centerX:{orientation:"vertical",resolve:(e,t)=>(t.x+t.x2)/2},centerY:{orientation:"horizontal",resolve:(e,t)=>(t.y+t.y2)/2}};import{jsx as Xg}from"react/jsx-runtime";var Bg=new ar;function zg(e,t,o,n){var d,u,p,f,x,E;let r=1/0,i=1/0,s=-1/0,a=-1/0,l=new Set;for(let m of e){let h=t.find(w=>w.id===m.id);if(!h)continue;l.add(h.id);let g=o(h.id);if(!g)continue;let y=g.parentId?o(g.parentId):void 0,v=m.position.x+((d=y==null?void 0:y.internals.positionAbsolute.x)!=null?d:0),b=m.position.y+((u=y==null?void 0:y.internals.positionAbsolute.y)!=null?u:0),N=(f=(p=h.measured)==null?void 0:p.width)!=null?f:0,_=(E=(x=h.measured)==null?void 0:x.height)!=null?E:0;r=Math.min(r,v),i=Math.min(i,b),s=Math.max(s,v+N),a=Math.max(a,b+_)}if(r===1/0)return null;let c=Object.keys(Dt);return{bounds:{x:r,y:i,x2:s,y2:a},excludedNodeIds:l,anchors:n?["top","left"]:c}}function Fg(e,t,o){var c,d,u,p,f,x,E,m;let n=t.find(h=>h.id===e.id);if(!n)return null;let r=o(n.id);if(!r)return null;let i=r.internals.positionAbsolute.x,s=r.internals.positionAbsolute.y,a=(p=(u=(c=e.dimensions)==null?void 0:c.width)!=null?u:(d=n.measured)==null?void 0:d.width)!=null?p:0,l=(m=(E=(f=e.dimensions)==null?void 0:f.height)!=null?E:(x=n.measured)==null?void 0:x.height)!=null?m:0;return{bounds:{x:i,y:s,x2:i+a,y2:s+l},excludedNodeIds:new Set([n.id]),anchors:["right","bottom"]}}function Yg(e,t,o,n){return e.length>0?zg(e,o,n,!!t):t?Fg(t,o,n):null}function fc(e,t,o,n){var r;e!=null&&e.dimensions&&(e.id===((r=t[0])==null?void 0:r.id)?e.dimensions[o]+=n:t.length||(e.dimensions[o]-=n))}function Wg(e,t,o,n,r,i){r&&(e.forEach(s=>{s.position&&(s.position.x-=o)}),fc(t,e,"width",o)),i&&(e.forEach(s=>{s.position&&(s.position.y-=n)}),fc(t,e,"height",n))}function cr(){let[e,t]=pc(void 0),[o,n]=pc(void 0),{width:r,height:i}=Og(m=>({width:m.width,height:m.height}),Gg),s=kg(),a=Hg(Bg),{screenToFlowPosition:l,getInternalNode:c,getNodes:d}=Rg(),u=Xo(()=>{t(void 0),n(void 0)},[]),p=Xo(m=>{let h=m!=null?m:d();u();let g=cc(h,Dt,c);a.current.initialize(g)},[c,u,d]),f=Xo(()=>{setTimeout(()=>{p()},100)},[p]);Vg(()=>{s&&p(d())},[s,p,d]);let x=Xo((m,h)=>{if(!a.current||m.length===0)return;let g=m.filter(C=>C.type==="dimensions");if(g.length>1)return;u();let y=m.filter(C=>C.type==="position"&&!!C.position),v=g[0];if(y.length===0&&!v)return;let b=Yg(y,v,h,c);if(!b)return;let{x:N,y:_}=l({x:0,y:0}),{x:w,y:S}=l({x:r,y:i}),M={x:N,y:_,x2:w,y2:S},{horizontal:L,vertical:D}=dc(a.current,M,b.bounds,b.excludedNodeIds,b.anchors),{deltaX:O,deltaY:R,snappedX:V,snappedY:G}=uc(b.bounds,L,D);if(!V&&!G)return;let B=y.some(C=>C.dragging),A=!!(v!=null&&v.resizing);(B||A)&&(V&&n(D==null?void 0:D.line),G&&t(L==null?void 0:L.line)),Wg(y,v,O,R,V,G)},[l,c,r,i,t,n,u]),E=Xo(()=>Xg(mc,{horizontal:e,vertical:o}),[e,o]);return{rebuildIndex:p,forceRebuildIndex:f,updateHelperLines:x,helperLineHorizontal:e,helperLineVertical:o,HelperLines:E}}import{reconnectEdge as m0,useReactFlow as g0}from"@xyflow/react";import{useCallback as Ft,useRef as h0}from"react";var rt=e=>new Map(e.map(t=>[t.id,t])),Uo=(e,t,o)=>t.filter(n=>!(n.source!==e||o&&n.id===o)),gc=(e,t,o)=>t.filter(n=>!(n.target!==e||o&&n.id===o)),Fi=e=>e.some(t=>t.type==="START_EVENT"),no=(e,t)=>e==="START_EVENT"?!Fi(t):!0,hc=(e,t,o,n,r)=>{let i=rt(o),s=i.get(e);if(!s||s.type!=="START_EVENT")return!1;let a=i.get(t);return(a==null?void 0:a.type)==="ANNOTATION"?!1:Uo(e,n,r).filter(c=>{let d=i.get(c.target);return(d==null?void 0:d.type)!=="ANNOTATION"}).length>=1},yc=(e,t,o,n,r)=>{let i=rt(o),s=i.get(t);if(!s||s.type!=="END_EVENT")return!1;let a=i.get(e);return(a==null?void 0:a.type)==="ANNOTATION"?!1:gc(t,n,r).filter(c=>{let d=i.get(c.source);return(d==null?void 0:d.type)!=="ANNOTATION"}).length>=1},dr=(e,t,o,n,r)=>{var c;let i=rt(o),s=i.get(e);if(!s||s.type!=="GATEWAY"||((c=s.data)==null?void 0:c.variant)!=="EXCLUSIVE")return!1;let a=t?i.get(t):null;return(a==null?void 0:a.type)==="ANNOTATION"?!1:Uo(e,n,r).filter(d=>{let u=i.get(d.target);return(u==null?void 0:u.type)!=="ANNOTATION"}).length>=2},xc=(e,t,o)=>{var s,a,l,c;let n=rt(o),r=n.get(e),i=n.get(t);return(r==null?void 0:r.type)!=="GATEWAY"||(i==null?void 0:i.type)!=="GATEWAY"||((s=r==null?void 0:r.data)==null?void 0:s.variant)==="EXCLUSIVE"&&((a=i==null?void 0:i.data)==null?void 0:a.variant)==="PARALLEL"||((l=r==null?void 0:r.data)==null?void 0:l.variant)==="COMPLEX"&&((c=i==null?void 0:i.data)==null?void 0:c.variant)==="PARALLEL"},ur=(e,t)=>{var n;let o=t.find(r=>r.id===e);return!o||o.type!=="TASK"?!1:((n=o.data)==null?void 0:n.variant)==="SCRIPT"},Ec=(e,t)=>{var n;let o=t.find(r=>r.id===e);return!o||o.type!=="TASK"?!1:((n=o.data)==null?void 0:n.variant)==="SUBPROCESS"},$o=(e,t)=>{var n;let o=t.find(r=>r.id===e);return!o||o.type!=="TASK"?!1:((n=o.data)==null?void 0:n.variant)==="SERVICE_TASK"},pr=(e,t)=>{var n;let o=t.find(r=>r.id===e);return!o||o.type!=="TASK"?!1:((n=o.data)==null?void 0:n.attribute)==="LOOP"},kt=(e,t,o,n)=>{let r=rt(t),i=r.get(e);return!i||i.type!=="TASK"?!1:gc(e,o,n).some(a=>{let l=r.get(a.source);return(l==null?void 0:l.type)==="START_EVENT"})},Ko=(e,t,o,n)=>{let r=rt(t),i=r.get(e);return!i||i.type!=="TASK"?!1:Uo(e,o,n).some(a=>{let l=r.get(a.target);return(l==null?void 0:l.type)==="END_EVENT"})},_c=(e,t,o,n,r)=>{let i=rt(o),s=i.get(e),a=i.get(t);return(s==null?void 0:s.type)==="START_EVENT"&&(a==null?void 0:a.type)==="TASK"?Ko(t,o,n,r):(a==null?void 0:a.type)==="END_EVENT"&&(s==null?void 0:s.type)==="TASK"?kt(e,o,n,r):!1},fr=(e,t,o)=>Uo(e,t,o).length>0,mr=(e,t,o,n,r)=>{let i=rt(o),s=i.get(e);if(!s||s.type!=="TASK")return!1;let a=t?i.get(t):null;return(a==null?void 0:a.type)==="ANNOTATION"?!1:Uo(e,n,r).filter(c=>{let d=i.get(c.target);return(d==null?void 0:d.type)!=="ANNOTATION"}).length>=2};var bc=(e,t,o,n,r)=>{var a,l;let i=rt(n),s=((a=i.get(e))==null?void 0:a.type)==="ANNOTATION"||((l=i.get(t))==null?void 0:l.type)==="ANNOTATION";return o.some(c=>r&&c.id===r?!1:!!(c.source===e&&c.target===t||s&&c.source===t&&c.target===e))};var Ug=[e=>({isValid:e.sourceNodeId!==e.targetNodeId,reason:"self_connection_not_allowed"}),e=>({isValid:!bc(e.sourceNodeId,e.targetNodeId,e.edges,e.nodes,e.reconnectingEdgeId),reason:"duplicate_connection_not_allowed"}),e=>({isValid:!hc(e.sourceNodeId,e.targetNodeId,e.nodes,e.edges,e.reconnectingEdgeId),reason:"start_event_limit_reached"}),e=>({isValid:!yc(e.sourceNodeId,e.targetNodeId,e.nodes,e.edges,e.reconnectingEdgeId),reason:"end_event_limit_reached"}),e=>({isValid:!dr(e.sourceNodeId,e.targetNodeId,e.nodes,e.edges,e.reconnectingEdgeId),reason:"gateway_limit_reached"}),e=>({isValid:!mr(e.sourceNodeId,e.targetNodeId,e.nodes,e.edges,e.reconnectingEdgeId),reason:"task_limit_reached"}),e=>({isValid:xc(e.sourceNodeId,e.targetNodeId,e.nodes),reason:"gateway_to_gateway_not_allowed"}),e=>({isValid:!(e.sourceNodeType==="START_EVENT"&&e.targetNodeType==="END_EVENT"),reason:"start_to_end_not_allowed"}),e=>({isValid:!(e.sourceNodeType==="START_EVENT"&&Ec(e.targetNodeId,e.nodes)),reason:"start_event_to_subprocess_not_allowed"}),e=>({isValid:!(e.sourceNodeType==="START_EVENT"&&$o(e.targetNodeId,e.nodes)),reason:"start_event_to_service_task_not_allowed"}),e=>({isValid:!($o(e.sourceNodeId,e.nodes)&&e.targetNodeType==="END_EVENT"),reason:"service_task_to_end_not_allowed"}),e=>({isValid:!(e.sourceNodeType==="GATEWAY"&&e.targetNodeType==="END_EVENT"),reason:"gateway_to_end_not_allowed"}),e=>({isValid:!(e.sourceNodeType==="START_EVENT"&&e.targetNodeType==="GATEWAY"),reason:"start_to_gateway_not_allowed"}),e=>({isValid:!(ur(e.sourceNodeId,e.nodes)&&e.targetNodeType==="END_EVENT"),reason:"script_to_end_not_allowed"}),e=>({isValid:!(pr(e.sourceNodeId,e.nodes)&&e.targetNodeType==="END_EVENT"),reason:"loop_to_end_not_allowed"}),e=>({isValid:!(kt(e.sourceNodeId,e.nodes,e.edges,e.reconnectingEdgeId)&&e.targetNodeType==="END_EVENT"),reason:"initial_activity_to_end_not_allowed"}),e=>({isValid:!_c(e.sourceNodeId,e.targetNodeId,e.nodes,e.edges,e.reconnectingEdgeId),reason:"concurrent_initial_and_final_activity"}),e=>({isValid:!(Ko(e.sourceNodeId,e.nodes,e.edges,e.reconnectingEdgeId)&&e.targetNodeType!=="ANNOTATION"),reason:"final_activity_cannot_connect"}),e=>({isValid:!(fr(e.sourceNodeId,e.edges,e.reconnectingEdgeId)&&e.targetNodeType==="END_EVENT"),reason:"activity_has_outgoing_connections"}),e=>({isValid:({START_EVENT:["TASK","ANNOTATION"],END_EVENT:["ANNOTATION"],TASK:["TASK","END_EVENT","GATEWAY","ANNOTATION"],GATEWAY:["TASK","END_EVENT","ANNOTATION","GATEWAY"],LANE:["ANNOTATION"],ANNOTATION:["START_EVENT","END_EVENT","TASK","GATEWAY","LANE"],UNSUPPORTED:[]}[e.sourceNodeType]||[]).includes(e.targetNodeType),reason:"connection_type_not_allowed"})],Yi=e=>{for(let t of Ug){let o=t(e);if(!o.isValid)return o}return{isValid:!0}};var $g=[{sourceTypes:["GATEWAY"],targetTypes:["TASK","GATEWAY"],validate:e=>({shouldDisable:dr(e.sourceNodeId,null,e.nodes,e.edges)&&e.targetNodeType!=="ANNOTATION",reason:"gateway_limit_reached"})},{sourceTypes:["START_EVENT"],validate:e=>({shouldDisable:e.edges.some(o=>{if(o.source!==e.sourceNodeId)return!1;let n=e.nodes.find(r=>r.id===o.target);return(n==null?void 0:n.type)!=="ANNOTATION"})&&e.targetNodeType!=="ANNOTATION",reason:"start_event_limit_reached"})},{targetTypes:["START_EVENT"],validate:e=>({shouldDisable:Fi(e.nodes),reason:"start_event_already_exists"})},{sourceTypes:["TASK"],targetTypes:["END_EVENT"],validate:e=>({shouldDisable:ur(e.sourceNodeId,e.nodes),reason:"script_to_end_not_allowed"})},{sourceTypes:["TASK"],targetTypes:["END_EVENT"],validate:e=>({shouldDisable:pr(e.sourceNodeId,e.nodes),reason:"loop_to_end_not_allowed"})},{sourceTypes:["TASK"],targetTypes:["END_EVENT"],validate:e=>({shouldDisable:$o(e.sourceNodeId,e.nodes),reason:"service_task_to_end_not_allowed"})},{sourceTypes:["TASK"],targetTypes:["END_EVENT"],validate:e=>({shouldDisable:kt(e.sourceNodeId,e.nodes,e.edges),reason:"initial_activity_to_end_not_allowed"})},{sourceTypes:["TASK"],validate:e=>({shouldDisable:Ko(e.sourceNodeId,e.nodes,e.edges)&&e.targetNodeType!=="ANNOTATION",reason:"final_activity_cannot_connect"})},{targetTypes:["END_EVENT"],validate:e=>({shouldDisable:fr(e.sourceNodeId,e.edges),reason:"activity_has_outgoing_connections"})},{sourceTypes:["TASK"],validate:e=>({shouldDisable:mr(e.sourceNodeId,null,e.nodes,e.edges)&&e.targetNodeType!=="ANNOTATION",reason:"task_limit_reached"})}],Tc=e=>{let t=$g.filter(o=>{let n=!o.sourceTypes||o.sourceTypes.includes(e.sourceNodeType),r=!o.targetTypes||o.targetTypes.includes(e.targetNodeType);return n&&r});for(let o of t){let n=o.validate(e);if(n.shouldDisable)return n}return{shouldDisable:!1}};var Ve={type:"SEQUENCE_EDGE",reconnectable:!0,markerStart:{type:"arrowclosed"},markerEnd:{type:"arrow"},data:{label:""}},ro={type:"ANNOTATION_EDGE",reconnectable:!0,data:{label:""}};import{useCallback as hu,useEffect as u0}from"react";import{useDebouncedCallback as p0}from"use-debounce";import{useReactFlow as d0}from"@xyflow/react";import{useCallback as gu}from"react";var qo=(u=>(u.START_EVENT="start-event",u.END_EVENT_TERMINATE="end-event-terminate",u.TASK="task",u.TASK_SCRIPT="task-script",u.SUBPROCESS="subprocess-collapsed",u.GATEWAY_EXCLUSIVE="gateway-exclusive",u.GATEWAY_PARALLEL="gateway-parallel",u.GATEWAY_COMPLEX="gateway-complex",u.SERVICE_TASK="service-task",u.ANNOTATION="annotation",u.LANE="lane",u))(qo||{});import Cc from"@dagrejs/dagre";var gr={MIN_WIDTH:36,DEFAULT_WIDTH:36,MIN_HEIGHT:36,DEFAULT_HEIGHT:36},hr={MIN_WIDTH:36,DEFAULT_WIDTH:36,MIN_HEIGHT:36,DEFAULT_HEIGHT:36},io={MIN_WIDTH:40,DEFAULT_WIDTH:56,MIN_HEIGHT:40,DEFAULT_HEIGHT:56},it={MIN_WIDTH:60,DEFAULT_WIDTH:176,MIN_HEIGHT:60,DEFAULT_HEIGHT:96},vc={HEADER_WIDTH:40,MIN_WIDTH:150,DEFAULT_WIDTH:840,MIN_HEIGHT:150,DEFAULT_HEIGHT:256},J={HEADER_WIDTH:40,MIN_WIDTH:150,DEFAULT_WIDTH:800,MIN_HEIGHT:150,DEFAULT_HEIGHT:256},Rt={MIN_WIDTH:40,DEFAULT_WIDTH:176,MIN_HEIGHT:40,DEFAULT_HEIGHT:64},Kg={MIN_WIDTH:126,DEFAULT_WIDTH:128,MIN_HEIGHT:60,DEFAULT_HEIGHT:64},ee={START_EVENT:gr,END_EVENT:hr,GATEWAY:io,TASK:it,LANE:J,ANNOTATION:Rt,UNSUPPORTED:Kg};var qg=50,Ot=(e,t)=>{var p,f,x,E,m,h,g,y,v,b,N,_,w,S,M,L;let o=t.find(D=>D.id===e);if(!o)return t;let n=(f=(p=o.position)==null?void 0:p.x)!=null?f:0,r=(E=(x=o.position)==null?void 0:x.y)!=null?E:0,i=(h=(m=o.measured)==null?void 0:m.width)!=null?h:0,s=(y=(g=o.measured)==null?void 0:g.height)!=null?y:0,a=r+s,l=n+i,c=new Set,d=1/0;for(let D of t){if(D.id===e||D.parentId)continue;let O=(b=(v=D.position)==null?void 0:v.y)!=null?b:0,R=(_=(N=D.position)==null?void 0:N.x)!=null?_:0,V=(S=(w=D.measured)==null?void 0:w.width)!=null?S:0,G=(L=(M=D.measured)==null?void 0:M.height)!=null?L:0;R<l&&R+V>n&&O<a&&O+G>r&&(c.add(D.id),d=Math.min(d,O))}if(c.size===0)return t;let u=a+qg-d;return t.map(D=>{var R,V,G;if(!c.has(D.id))return D;let O=(V=(R=D.position)==null?void 0:R.y)!=null?V:0;return I(T({},D),{position:I(T({},(G=D.position)!=null?G:{x:0,y:0}),{y:O+u})})})},ce=15,Vt=e=>[...e].sort((t,o)=>t.position.y-o.position.y),Zg=e=>{var t,o,n;return e.position.x+((n=(o=(t=e.measured)==null?void 0:t.width)!=null?o:e.width)!=null?n:0)},Jg=e=>{var t,o,n;return e.position.y+((n=(o=(t=e.measured)==null?void 0:t.height)!=null?o:e.height)!=null?n:0)},Wi=(e,t,o)=>{var d,u,p,f,x,E,m,h,g,y,v,b,N,_,w,S,M,L,D,O,R;if(t.length===0){let V=I(T({},e),{width:(p=(u=e.width)!=null?u:(d=e.measured)==null?void 0:d.width)!=null?p:J.MIN_WIDTH,height:(E=(x=e.height)!=null?x:(f=e.measured)==null?void 0:f.height)!=null?E:J.MIN_HEIGHT});return o.set(e.id,V),V}let n=(g=(h=e.width)!=null?h:(m=e.measured)==null?void 0:m.width)!=null?g:0,r=(b=(v=e.height)!=null?v:(y=e.measured)==null?void 0:y.height)!=null?b:0,i=0,s=0;for(let V of t){let G=Zg(V),B=Jg(V);if(((_=(N=V.position)==null?void 0:N.y)!=null?_:0)<ce&&(o.set(V.id,I(T({},V),{position:I(T({},V.position),{y:ce})})),B=ce+((S=(w=V.measured)==null?void 0:w.height)!=null?S:0)),((L=(M=V.position)==null?void 0:M.x)!=null?L:0)<J.HEADER_WIDTH+ce){let A=(D=o.get(V.id))!=null?D:V;o.set(V.id,I(T({},A),{position:I(T({},A.position),{x:J.HEADER_WIDTH+ce})})),G=J.HEADER_WIDTH+ce+((R=(O=V.measured)==null?void 0:O.width)!=null?R:0)}i=Math.max(i,G),s=Math.max(s,B)}let a=Math.max(n,J.MIN_WIDTH),l=Math.max(r,J.MIN_HEIGHT);i+ce>a&&(a=i+ce),s+ce>l&&(l=s+ce);let c=I(T({},e),{width:a,height:l,measured:I(T({},e.measured),{width:a,height:l})});return o.set(e.id,c),c},Nc=(e,t,o)=>{var s,a,l,c;let n=Vt(e),r=new Map;for(let d of o)d.parentId&&(r.has(d.parentId)||r.set(d.parentId,[]),r.get(d.parentId).push(d));let i=0;for(let d of n){let u=(s=r.get(d.id))!=null?s:[],p=Wi(d,u,t);t.set(p.id,I(T({},p),{position:{x:J.HEADER_WIDTH,y:i}})),i+=(c=(l=p.height)!=null?l:(a=p.measured)==null?void 0:a.height)!=null?c:0}},wc=(e,t)=>{var x,E,m,h,g,y;let o=[];for(let v of t.values())v.parentId===e.id&&o.push(v);let n=Vt(o),r=((E=(x=e.measured)==null?void 0:x.width)!=null?E:0)-J.HEADER_WIDTH,i=ga(e.id,o)||J.MIN_WIDTH,s=o.reduce((v,b)=>{var N,_,w;return v+((w=(_=b.height)!=null?_:(N=b.measured)==null?void 0:N.height)!=null?w:J.MIN_HEIGHT)},0),a=Math.max(r,i),l=s,c=r>i,d=c?a:a+J.HEADER_WIDTH,u=c?a-J.HEADER_WIDTH:a,p=0;for(let v=0;v<n.length;v++){let b=n[v],N=Math.max(J.MIN_HEIGHT,(g=(h=b.height)!=null?h:(m=b.measured)==null?void 0:m.height)!=null?g:J.MIN_HEIGHT),_=I(T({},b),{width:u,height:N,measured:I(T({},b.measured),{width:u,height:N}),position:{x:J.HEADER_WIDTH,y:p}});if(v===o.length-1){let w=Math.max(J.MIN_HEIGHT,l-p);_=I(T({},_),{height:w,measured:I(T({},b.measured),{width:u,height:w})})}t.set(b.id,_),p+=(y=_.height)!=null?y:0}let f=Math.max(l,p);t.set(e.id,I(T({},e),{width:d,height:f,measured:I(T({},e.measured),{width:d,height:f})}))},Ic=(e,t,o,n,r)=>{var x,E;let i=!e.parentId,s=i?e.id:e.parentId,a=n.filter(m=>m.type==="LANE"&&m.parentId===s);if(!a.length)return n;let l=Vt(a),c=l.findIndex(m=>m.id===e.id),d=(E=(x=e.position)==null?void 0:x.y)!=null?E:0,u=!i&&r!==void 0&&c>0&&Math.abs(r-d)>.5,p=0,f=[...n];return l.forEach((m,h)=>{var N,_;let g=h===l.length-1,y=m.id===e.id,b=(_=(N=m.measured)==null?void 0:N.height)!=null?_:0;y?b=o:u&&h===c-1&&(b=Math.max(J.MIN_HEIGHT,r-p)),g&&i&&(b=Math.max(J.MIN_HEIGHT,o-p)),f=f.map(w=>{if(w.id===m.id){let S=i?t-J.HEADER_WIDTH:t;return I(T({},w),{width:S,height:b,measured:I(T({},w.measured),{width:S,height:b}),position:{x:J.HEADER_WIDTH,y:p}})}return w}),y&&u?p=r+o:p+=b}),f=f.map(m=>{if(m.id===s){let h=i?t:t+J.HEADER_WIDTH;return I(T({},m),{width:h,height:i?o:p,measured:{width:h,height:i?o:p}})}return m}),f};var Xi=(e,t,o)=>{var a,l,c,d,u,p,f,x;if(e.type==="LANE")return o;let n=(l=(a=t.measured)==null?void 0:a.width)!=null?l:0,r=(d=(c=t.measured)==null?void 0:c.height)!=null?d:0;e.position.y<ce&&(e.position.y=ce),e.position.x<J.HEADER_WIDTH+ce&&(e.position.x=J.HEADER_WIDTH+ce);let i=e.position.x+((p=(u=e.measured)==null?void 0:u.width)!=null?p:0),s=e.position.y+((x=(f=e.measured)==null?void 0:f.height)!=null?x:0);return i+ce>n&&(t.width=i+ce,t.measured.width=i+ce),s+ce>r&&(t.height=s+ce,t.measured.height=s+ce),o=o.map(E=>E.id===t.id?I(T({},E),{height:t.height,width:t.width,measured:t.measured}):E.id===e.id?I(T({},E),{position:e.position}):E),o},Ac=e=>{var i,s;let t=e.filter(a=>a.type==="LANE");if(t.length===0)return e;let o=new Map(e.map(a=>[a.id,wt(a.id,e)])),n=a=>{var p,f,x,E,m,h,g;let{x:l,y:c}=(p=o.get(a.id))!=null?p:{x:0,y:0},d=(E=(x=(f=a.measured)==null?void 0:f.width)!=null?x:a.width)!=null?E:0,u=(g=(h=(m=a.measured)==null?void 0:m.height)!=null?h:a.height)!=null?g:0;return{x1:l,y1:c,x2:l+d,y2:c+u,w:d,h:u}},r=new Map;for(let a of e){if(a.type==="LANE")continue;let{x1:l,y1:c,w:d,h:u}=n(a),p=l+d/2,f=c+u/2,x=t.filter(g=>{let{x1:y,x2:v,y1:b,y2:N}=n(g);return p>=y&&p<=v&&f>=b&&f<=N});if(x.length===0)continue;let E=x.reduce((g,y)=>{if(!g)return y;let v=!!g.parentId,b=!!y.parentId;if(b&&!v)return y;if(!b&&v)return g;let{x1:N,y1:_,w,h:S}=n(g),{x1:M,y1:L,w:D,h:O}=n(y),R=Math.hypot(N+w/2-p,_+S/2-f);return Math.hypot(M+D/2-p,L+O/2-f)<R?y:g},null);if(!E||a.parentId===E.id)continue;let m=(i=o.get(a.id))!=null?i:{x:0,y:0},h=(s=o.get(E.id))!=null?s:{x:0,y:0};r.set(a.id,{parentId:E.id,position:{x:m.x-h.x,y:m.y-h.y}})}return r.size===0?e:e.map(a=>{let l=r.get(a.id);return l?I(T({},a),{parentId:l.parentId,position:l.position}):a})};var yr=(e=[],t=[],o="LR")=>{let n=new Cc.graphlib.Graph;return n.setDefaultEdgeLabel(()=>({})),n.setGraph({rankdir:o}),e.forEach(({id:i,width:s,height:a})=>n.setNode(i,{width:s,height:a})),t.forEach(i=>n.setEdge(i.source,i.target)),Cc.layout(n),{nodes:e.map(i=>{let s=n.node(i.id);return I(T({},i),{position:{x:s.x-i.width/2,y:s.y-i.height/2}})}),edges:t}},st=e=>{let t=e.filter(n=>n.type==="LANE"&&!n.parentId);if(t.length===0)return e;let o=pa(e);for(let n of t){let r=[...o.values()],i=r.filter(a=>a.parentId===n.id);if(i.length===0)continue;let s=i.filter(a=>a.type==="LANE");if(s.length>0){Nc(s,o,r),wc(n,o);continue}Wi(n,i,o)}return fa(e,o)},Sc=st,Mc=()=>{let e=document.querySelector(".react-flow__viewport");return e||(console.error("Flow element (.react-flow__viewport) not found."),null)};var Zo=1,Pc=e=>`<mxGraphModel>
6
2
  <root version="1.1">
7
3
  <mxCell id="0" />
8
4
  <mxCell id="1" parent="0" />
@@ -35,17 +31,21 @@ var Kp=Object.defineProperty,qp=Object.defineProperties;var Zp=Object.getOwnProp
35
31
  <mxGeometry as="geometry" relative="1" />
36
32
  </mxCell>
37
33
  </root>
38
- </mxGraphModel>`,fd=(e,t)=>{if(!e.length&&!t.length)return wn;let o=[...e.map(r=>r.id),...t.map(r=>r.id)];return Math.max(...o.map(r=>Number(r)))};import{xml2json as sy,json2xml as ay}from"xml-js";var md={compact:!0,spaces:4},ly=e=>e.replace(/\n/g,"&#xA;");function ei(e,t=md){if(e)return JSON.parse(sy(e,t))}function gd(e,t=md){return e?ay(e,w(_({},t),{attributeValueFn:ly})):""}var hd={"attribute-loop":"LOOP"},yd={"task-script":"SCRIPT","subprocess-collapsed":"SUBPROCESS","service-task":"SERVICE_TASK"},xd={"gateway-exclusive":"EXCLUSIVE","gateway-parallel":"PARALLEL","gateway-complex":"COMPLEX"},Ed={SCRIPT:"task-script",SUBPROCESS:"subprocess-collapsed",SERVICE_TASK:"service-task"},_d={EXCLUSIVE:"gateway-exclusive",PARALLEL:"gateway-parallel",COMPLEX:"gateway-complex"};var zo=(e,t,o,n,r,i)=>{let s=e._attributes.width||0,a=e._attributes.height||0,l=0,c=0;if(n&&r!==void 0&&i!==void 0){let x=n.split(`
39
- `),E=x.length;l=x.reduce((h,f)=>Math.max(h,f.length),0)*7+r,c=E*20+i}let d=Math.max(Rt(Number(s),t),l),u=Math.max(Rt(Number(a),o),c);return{width:d,height:u,measured:{width:d,height:u}}},Yo=e=>{let{_attributes:t,mxGeometry:o}=e,{id:n,parent:r,value:i}=t,s={x:Number(o._attributes.x||0),y:Number(o._attributes.y||0)},a={id:n,position:s,className:void 0,data:{label:i||""}},l=r==="1"?void 0:r;return l&&(a.parentId=l),a},dy=e=>{let{mxGeometry:t}=e,o=Yo(e),n=zo(t,de.START_EVENT.MIN_WIDTH,de.START_EVENT.MIN_HEIGHT);return w(_(_({},o),n),{type:"START_EVENT"})},uy=e=>{let{mxGeometry:t}=e,o=Yo(e),n=zo(t,de.END_EVENT.MIN_WIDTH,de.END_EVENT.MIN_HEIGHT);return w(_(_({},o),n),{type:"END_EVENT"})},ti=(e,t)=>{let{_attributes:o,mxGeometry:n}=e,r=Yo(e),a=zo(n,de.TASK.MIN_WIDTH,de.TASK.MIN_HEIGHT,r.data.label,48,24),l=t==null?void 0:t.find(d=>{let{parent:u}=d._attributes;return u===e._attributes.id});if(l){let{style:d}=l._attributes,u=hd[d];u&&(r.data.attribute=u)}let c=yd[o.style];return c&&(r.data.variant=c),w(_(_({},r),a),{type:"TASK"})},hs=e=>{let{_attributes:t,mxGeometry:o}=e,{style:n}=t,r=Yo(e),i=zo(o,de.GATEWAY.MIN_WIDTH,de.GATEWAY.MIN_HEIGHT);return r.data.variant=xd[n],w(_(_({},r),i),{type:"GATEWAY"})},py=e=>{let{mxGeometry:t}=e,o=Yo(e),i=zo(t,de.ANNOTATION.MIN_WIDTH,de.ANNOTATION.MIN_HEIGHT,o.data.label,32,24);return w(_(_({},o),i),{type:"ANNOTATION"})},fy=e=>{let{mxGeometry:t}=e,o=Yo(e),n=zo(t,de.LANE.MIN_WIDTH,de.LANE.MIN_HEIGHT);return w(_(_({},o),n),{type:"LANE"})},bd={task:ti,"task-script":ti,"subprocess-collapsed":ti,"service-task":ti,"start-event":dy,"end-event-terminate":uy,"gateway-parallel":hs,"gateway-exclusive":hs,"gateway-complex":hs,annotation:py,lane:fy},my=e=>{if(e&&Array.isArray(e))return e.map(t=>({x:Number(t._attributes.x),y:Number(t._attributes.y)}))},Td=e=>{let{_attributes:t,mxGeometry:o}=e,{id:n,source:r,target:i,value:s,style:a,sourceHandle:l,targetHandle:c,sourceOffset:d,targetOffset:u,labelOffsetX:p,labelOffsetY:m}=t,x=my(o==null?void 0:o.Array),E=d!==void 0?Number(d):void 0,g=u!==void 0?Number(u):void 0,h=p!==void 0?Number(p):void 0,f=m!==void 0?Number(m):void 0,y=w(_(_({id:n,source:r,target:i},l?{sourceHandle:l}:{}),c?{targetHandle:c}:{}),{data:_(_(_(_({label:s||""},x&&x.length>0?{points:x}:{}),E!==void 0?{sourceOffset:E}:{}),g!==void 0?{targetOffset:g}:{}),h!==void 0&&f!==void 0?{labelOffset:{x:h,y:f}}:{})});return a.includes("association")&&a.includes('endArrow=""')?_(_({},Ro),y):_(_({},st),y)},vd=(e,t)=>{var m,x;let{id:o,type:n,source:r,target:i,sourceHandle:s,targetHandle:a,data:l}=e,c=t==null?void 0:t.find(E=>E.id===r),d="";n==="ANNOTATION_EDGE"&&(d='association;endArrow=""');let u={_attributes:{as:"geometry",relative:"1"}};return l!=null&&l.points&&Array.isArray(l.points)&&l.points.length>0&&(u.Array=l.points.map(E=>({_attributes:{as:"mxPoint",x:E.x,y:E.y}}))),{_attributes:{id:o,parent:(c==null?void 0:c.parentId)||"1",edge:"1",style:d,source:r,target:i,value:(l==null?void 0:l.label)||"",sourceHandle:s!=null?s:void 0,targetHandle:a!=null?a:void 0,sourceOffset:(l==null?void 0:l.sourceOffset)!==void 0?String(l.sourceOffset):void 0,targetOffset:(l==null?void 0:l.targetOffset)!==void 0?String(l.targetOffset):void 0,labelOffsetX:((m=l==null?void 0:l.labelOffset)==null?void 0:m.x)!==void 0?String(l.labelOffset.x):void 0,labelOffsetY:((x=l==null?void 0:l.labelOffset)==null?void 0:x.y)!==void 0?String(l.labelOffset.y):void 0},mxGeometry:u}},Fo=e=>{let{id:t,parentId:o,position:n,measured:r,data:i}=e;return{_attributes:{id:t,parent:o||"1",value:i.label,vertex:"1"},mxGeometry:{_attributes:{as:"geometry",width:(r==null?void 0:r.width)||0,height:(r==null?void 0:r.height)||0,x:n.x||0,y:n.y||0}}}},gy=e=>{let{variant:t}=e.data,o=Fo(e);return w(_({},o),{_attributes:w(_({},o._attributes),{style:Ed[t]||"task"})})},hy=e=>{let t=Fo(e);return w(_({},t),{_attributes:w(_({},t._attributes),{style:"start-event"})})},yy=e=>{let t=Fo(e);return w(_({},t),{_attributes:w(_({},t._attributes),{style:"end-event-terminate"})})},xy=e=>{let{variant:t}=e.data,o=Fo(e);return w(_({},o),{_attributes:w(_({},o._attributes),{style:_d[t]})})},Ey=e=>{let t=Fo(e);return w(_({},t),{_attributes:w(_({},t._attributes),{style:"lane"})})},_y=e=>{let t=Fo(e);return w(_({},t),{_attributes:w(_({},t._attributes),{style:"annotation"})})},Nd={TASK:gy,START_EVENT:hy,END_EVENT:yy,GATEWAY:xy,ANNOTATION:_y,LANE:Ey},wd=(e,t)=>{var s,a;let r=((s=e.measured)==null?void 0:s.width)||0,i=((a=e.measured)==null?void 0:a.height)||0;return{_attributes:{id:`${t+1}`,parent:e.id,style:"attribute-loop",connectable:"0"},mxGeometry:{_attributes:{as:"geometry",x:r/2-22/2,y:i-22,width:22,height:22}}}};var by=e=>{let t=Object.values(Nn),o=e.filter(i=>{var a;let s=(a=i._attributes)==null?void 0:a.style;return t.includes(s)}),n=e.filter(i=>{var a;let s=(a=i._attributes)==null?void 0:a.style;return["attribute-loop"].includes(s)}),r=[];for(let i of o){let{style:s}=i._attributes,a=bd[s],l=a==null?void 0:a(i,n);if(!l){console.warn(`Node ${s} not supported`);continue}r.push(l)}return r},Ty=(e,t)=>{let o=e.filter(r=>{var i;return(i=r._attributes)==null?void 0:i.edge}),n=[];for(let r of o){let i=Td(r),s=t.find(c=>c.id===i.source),a=t.find(c=>c.id===i.target);((s==null?void 0:s.type)==="LANE"||(a==null?void 0:a.type)==="LANE")&&i.type!=="ANNOTATION_EDGE"||n.push(i)}return n},vy=(e,t)=>{let o=[];return e.forEach(n=>{var s,a;let r=(a=(s=Nd)[n.type])==null?void 0:a.call(s,n);if(!r){console.warn(`Node ${n.type} not supported`);return}if(o.push(r),n.type==="TASK"&&n.data.attribute==="LOOP"){let l=wd(n,t);o.push(l)}}),o},Ny=(e,t)=>{let o=[];return e.forEach(n=>{let r=vd(n,t);o.push(r)}),o},wy=(e=[],t=[],o)=>{let n=vy(e,o),r=Ny(t,e);return{mxGraphModel:{root:{_attributes:{version:"1.1",lastId:o},mxCell:[{_attributes:{id:"0"}},{_attributes:{id:"1",parent:"0"}},...n,...r]}}}},Id=(e=[],t=[],o)=>{let n=wy(e,t,o);return gd(JSON.stringify(n),{compact:!0,spaces:0})},Ad=async e=>{var a,l,c,d,u;let t=await ei(e),o=((l=(a=t==null?void 0:t.mxGraphModel)==null?void 0:a.root)==null?void 0:l.mxCell)||[],n=Number(((u=(d=(c=t==null?void 0:t.mxGraphModel)==null?void 0:c.root)==null?void 0:d._attributes)==null?void 0:u.lastId)||wn),r=by(o),i=Ty(o,r),s=jt(dd(r));return{lastElementId:n,edges:i,nodes:s}};import{useReactFlow as q0,useStoreApi as Z0}from"@xyflow/react";import{useCallback as J0}from"react";import{Position as Ft,useConnection as c0,useReactFlow as d0}from"@xyflow/react";import{useCallback as _s}from"react";import{Handle as Cd,useReactFlow as Iy}from"@xyflow/react";import{jsx as Sd}from"react/jsx-runtime";var ne=i=>{var s=i,{type:e,position:t,className:o,nodeType:n}=s,r=gt(s,["type","position","className","nodeType"]);let a=n==="TASK";return Sd(Cd,_({type:e,position:t,className:G("size-2.5 border border-grey-400 bg-white relative",{"before:content-[''] before:absolute before:inset-[-16px] before:bg-transparent before:pointer-events-none":a,"before:content-[''] before:absolute before:inset-[-4px] before:bg-transparent before:pointer-events-none":!a},o)},r))},ze=a=>{var l=a,{nodeId:e,nodeType:t,gatewayVariant:o,type:n,position:r,className:i}=l,s=gt(l,["nodeId","nodeType","gatewayVariant","type","position","className"]);let{getEdges:c,getNodes:d}=Iy(),p=(()=>{if(n!=="source")return!1;let m=c();if(t==="TASK")return m.filter(E=>E.source===e).length>=2;if(t==="GATEWAY"&&o==="EXCLUSIVE")return m.filter(E=>E.source===e).length>=2;if(t==="START_EVENT"){let x=d();return m.filter(g=>{if(g.source!==e)return!1;let h=x.find(f=>f.id===g.target);return(h==null?void 0:h.type)!=="ANNOTATION"}).length>=1}return!1})();return Sd(Cd,_({type:n,position:r,className:G("size-2.5 border border-grey-400 bg-white transition-all duration-200 relative",{"before:content-[''] before:absolute before:inset-[-16px] before:bg-transparent before:pointer-events-none":t==="TASK","before:content-[''] before:absolute before:inset-[-4px] before:bg-transparent before:pointer-events-none":t!=="TASK","opacity-50 cursor-not-allowed pointer-events-none":p,"hover:border-grey-500":!p},i),style:{pointerEvents:p?"none":"auto"}},s))};import{useRef as Md}from"react";import{NodeResizeControl as Pd,ResizeControlVariant as Cy,useReactFlow as Sy,useStoreApi as My}from"@xyflow/react";import{useStoreApi as Ay}from"@xyflow/react";var oi=()=>{let e=Ay();return{getInternalNodes:()=>{let{nodeLookup:o}=e.getState();return Array.from(o.values())}}};import{Fragment as ky,jsxs as Ry}from"react/jsx-runtime";import{createElement as Ld}from"react";var Py=["top","right","bottom","left"],Ly=["top-left","top-middle","top-right","right-middle","bottom-left","left-middle","bottom-right","bottom-middle"],at=r=>{var i=r,{nodeId:e,isVisible:t,offset:o=8}=i,n=gt(i,["nodeId","isVisible","offset"]);let{getInternalNode:s,setNodes:a}=Sy(),{getInternalNodes:l}=oi(),c=Et(),d=My(),u=Md(0),p=Md([]),m=({y:h,width:f,height:y})=>{cancelAnimationFrame(u.current),u.current=requestAnimationFrame(()=>{var F,j;if(!e)return;let{nodeLookup:T,onNodesChange:b}=d.getState(),I=T.get(e);if(!I||I.type!=="LANE")return;let v=!I.parentId,N=v?I.id:I.parentId;if(!N)return;let C=Array.from(T.values()).filter(q=>q.type==="LANE"&&q.parentId===N);if(!C.length)return;p.current.length===0&&(p.current=uo(C).map(q=>q.id));let M=p.current.map(q=>C.find($=>$.id===q)).filter(Boolean),L=[],D=0,O=M.findIndex(q=>q.id===I.id),V=!v&&O>0&&Math.abs(h-I.position.y)>.5;for(let q=0;q<M.length;q++){let $=M[q],A=$.id===I.id,P=q===M.length-1;if(A){D=V?h+y:D+y;continue}let k=(j=(F=$.measured)==null?void 0:F.height)!=null?j:0,S=v?f-ie.HEADER_WIDTH:f,B=k;v&&P&&(B=Math.max(ie.MIN_HEIGHT,y-D)),V&&q===O-1&&(B=Math.max(ie.MIN_HEIGHT,h-D)),L.push({id:$.id,type:"dimensions",dimensions:{width:S,height:B},setAttributes:!0}),L.push({id:$.id,type:"position",position:{x:ie.HEADER_WIDTH,y:D}}),D+=B}v?L.push({id:N,type:"dimensions",dimensions:{width:f,height:y},setAttributes:!0}):L.push({id:N,type:"dimensions",dimensions:{width:f+ie.HEADER_WIDTH,height:D},setAttributes:!0}),b==null||b(L)})},x=({y:h,width:f,height:y})=>{var I;if(cancelAnimationFrame(u.current),p.current=[],!e)return;let T=s(e);if(!T||T.type!=="LANE"&&!T.parentId)return;let b=[...l()];if(T.type!=="LANE"){b=b.map(v=>v.id===e?w(_({},v),{width:f,height:y,measured:{width:f,height:y}}):v),b=St(b),a(b);return}b=ld(T,f,y,b,h),b=St(b),b=co((I=T.parentId)!=null?I:T.id,b),a(b)};if(!(!c&&t))return null;let g={"--resize-offset":`${o}px`};return Ry(ky,{children:[Py.map(h=>Ld(Pd,w(_({},n),{key:h,nodeId:e,position:h,variant:Cy.Line,className:"border-blue-400/90 border-dashed",style:g,onResize:(f,y)=>m(y),onResizeEnd:(f,y)=>x(y)}))),Ly.map(h=>Ld(Pd,w(_({},n),{key:h,nodeId:e,position:h,className:"size-1.5 bg-blue-400 relative before:content-[''] before:absolute before:w-5 before:h-5 before:left-1/2 before:top-1/2 before:-translate-x-1/2 before:-translate-y-1/2 before:cursor-[inherit]",style:g,onResize:(f,y)=>m(y),onResizeEnd:(f,y)=>x(y)})))]})};import{NodeToolbar as Qy,useReactFlow as jy,useStore as Vd}from"@xyflow/react";import{Button as e0,Tooltip as t0,TooltipContent as o0,TooltipTrigger as n0,useTranslation as r0}from"@produto-lecom/lecom-ui";import i0,{useCallback as An,useEffect as s0,useRef as ni,useState as a0}from"react";import{create as Dy}from"zustand";var Wo=Dy(e=>({draggableNode:null,setDraggableNode:t=>{e({draggableNode:t})}}));import{useEffect as Oy,useState as Vy}from"react";var kd=(e,t=!1)=>{let[o,n]=Vy({width:0,height:0});return Oy(()=>{if(e.current&&t){let r=e.current.getBoundingClientRect();n({width:r.width,height:r.height})}},[t,e]),{dimensions:o}};import{Position as In,useReactFlow as Hy}from"@xyflow/react";import{useMemo as Gy}from"react";var By=120,zy=12,Rd=(e,t=!1,o)=>{let{getNode:n,getViewport:r}=Hy(),{instanceId:i}=U();return Gy(()=>{var m,x;if(!t)return{position:In.Right,align:"start"};let s=n(e);if(!s)return{position:In.Right,align:"start"};let a=r(),l=s.position.x*a.zoom+a.x,c=(((m=s.measured)==null?void 0:m.width)||s.width||100)*a.zoom,d=(x=document.getElementById(`modeler-${i}`))==null?void 0:x.clientWidth;if(!d)return{position:In.Right,align:"start"};let u=(o==null?void 0:o.width)||By;return{position:l+c+u+zy>d?In.Left:In.Right}},[i,e,t,o,n,r])};import{Bot as Hd}from"lucide-react";import{useNodesData as Yy,useReactFlow as Fy}from"@xyflow/react";import{Button as Dd,DropdownMenu as Wy,DropdownMenuContent as Xy,DropdownMenuGroup as Uy,DropdownMenuItem as $y,DropdownMenuLabel as Ky,DropdownMenuTrigger as qy,Tooltip as ys,TooltipContent as xs,TooltipTrigger as Es,useTranslation as Zy}from"@produto-lecom/lecom-ui";import{WrenchIcon as Jy}from"lucide-react";import{jsx as Ve,jsxs as po}from"react/jsx-runtime";var Od=({nodeId:e})=>{let{t}=Zy(),{updateNodeData:o,getEdges:n,getNode:r}=Fy(),i=Yy(e),a=n().filter(x=>x.source===e).some(x=>{let E=r(x.target);return(E==null?void 0:E.type)==="END_EVENT"}),l=(i==null?void 0:i.data.variant)==="SUBPROCESS",c=(i==null?void 0:i.data.variant)==="SERVICE_TASK",d=p=>{o(e,{variant:(i==null?void 0:i.data.variant)===p?"":p})},u=p=>{o(e,{attribute:(i==null?void 0:i.data.attribute)===p?"":p})};return po(Wy,{children:[po(ys,{children:[Ve(Es,{asChild:!0,children:Ve(qy,{asChild:!0,children:Ve(Dd,{variant:"ghost",color:"grey",size:"small",iconButton:!0,children:Ve(Jy,{})})})}),Ve(xs,{color:"black",children:t("bpmn.task.menu.title")})]}),po(Xy,{align:"start",className:"w-60 bg-white text-grey-600",children:[po(Ky,{className:"flex items-center gap-1",children:[Ve("div",{className:"flex-1 body-medium-500",children:t("bpmn.task.menu.title")}),Ve("div",{className:"flex items-center gap-1",children:Object.entries(Un).map(([p,m])=>{let x=p==="LOOP"&&(a||l||c),g=(()=>{if(p==="LOOP"&&a)return t("editor.task_menu.loop_not_allowed_when_connected_to_end");if(p==="LOOP"&&l)return t("editor.task_menu.loop_not_allowed_when_subprocess");if(p==="LOOP"&&c)return t("editor.task_menu.loop_not_allowed_when_service_task");if(p==="LOOP")return t("editor.task_menu.loop")})();return po(ys,{children:[Ve(Es,{asChild:!0,children:Ve(Dd,{variant:"ghost",color:"grey",size:"small",iconButton:!0,disabled:x,className:G({"bg-grey-100 text-blue-500":(i==null?void 0:i.data.attribute)===p,"opacity-50 cursor-not-allowed":x}),onClick:x?void 0:()=>u(p),children:Ve(m.icon,{className:"stroke-inherit"})})}),g&&Ve(xs,{color:"black",children:g})]},p)})})]}),Ve(Uy,{children:po(ys,{children:[Ve(Es,{asChild:!0,children:Ve("div",{className:G({"cursor-not-allowed":a}),children:po($y,{className:G({"bg-grey-100 text-blue-500":(i==null?void 0:i.data.variant)==="SCRIPT","opacity-50":a}),disabled:a,onClick:()=>d("SCRIPT"),children:[Ve(Xn.SCRIPT.icon,{className:"stroke-current"}),t(`bpmn.task.variant.${"SCRIPT".toLowerCase()}`)]})})}),a&&Ve(xs,{color:"black",children:t("editor.task_menu.script_not_allowed_when_connected_to_end")})]})})]})]})};import{jsx as Me,jsxs as Gd}from"react/jsx-runtime";var Mt={START_EVENT:{type:"START_EVENT",icon:Jo,label:"bpmn.start_event.variant.default"},END_EVENT:{type:"END_EVENT",icon:_o,label:"bpmn.end_event.variant.default"},TASK:{type:"TASK",icon:Jo,label:"bpmn.task.variant.default"},ANNOTATION:{type:"ANNOTATION",icon:zn,label:"bpmn.annotation.variant.default"}},l0={EXCLUSIVE:{type:"GATEWAY",variant:"EXCLUSIVE",icon:To,label:"bpmn.gateway.variant.exclusive"},PARALLEL:{type:"GATEWAY",variant:"PARALLEL",icon:vo,label:"bpmn.gateway.variant.parallel"},COMPLEX:{type:"GATEWAY",variant:"COMPLEX",icon:bo,label:"bpmn.gateway.variant.complex"}},Ye=i0.memo(({nodeId:e,nodeType:t,nodeVariant:o,isChild:n})=>{let r=ni(null),i=ni(null),{t:s}=r0(),{setDraggableNode:a}=Wo(),{getEdges:l,getNodes:c,setNodes:d}=jy(),{setIsDragging:u,mode:p,isConnecting:m,isDragging:x}=U(),E=Et(),g=Vd(An(z=>{var K,Z;return(Z=(K=z.nodeLookup.get(e))==null?void 0:K.selected)!=null?Z:!1},[e])),h=Vd(An(z=>{var K,Z;return(Z=(K=z.nodeLookup.get(e))==null?void 0:K.dragging)!=null?Z:!1},[e])),f=g&&!h&&!m&&!x&&!E,{dimensions:y}=kd(r,f),{position:T}=Rd(e,f,y),[b,I]=a0(void 0),v=o==="SUBPROCESS",N=o==="SERVICE_TASK",C=ni(null),M=ni(!1),L=An(()=>{C.current!==null&&(clearTimeout(C.current),C.current=null),M.current=!1,u(!1),a(null),I(void 0),d(z=>z.map(K=>w(_({},K),{className:void 0})))},[u,a,d]);s0(()=>{let z=K=>{M.current&&K.buttons===0&&L()};return document.addEventListener("dragend",L),document.addEventListener("mousemove",z),()=>{document.removeEventListener("dragend",L),document.removeEventListener("mousemove",z)}},[L]);let D=An((z,K)=>{M.current=!0,u(!1),a({type:K.type,variant:K.variant,attribute:K.attribute,icon:K.icon}),K.icon&&I(Me(K.icon,{})),z.dataTransfer.effectAllowed="move",z.dataTransfer.setData("sourceId",e),i.current&&z.dataTransfer.setDragImage(i.current,10,10),C.current=setTimeout(()=>{C.current=null,u(!0)},100)},[e,a,u]),O=An(()=>{L()},[L]);if(!f)return null;let V=c(),F=l(),j=[{component:Me(Vr,{elementId:e})}],q=()=>{if(p==="view")return[];let z=!F.some(K=>{var Z;return K.source===e&&((Z=V.find(W=>W.id===K.target))==null?void 0:Z.type)!=="ANNOTATION"});return[{component:Me(Mo,{nodeId:e,disabled:!z,tooltipMessage:z?void 0:s("editor.toolbar.start_event_limit_reached")})},Mt.TASK,Mt.ANNOTATION,...j]},$=()=>p==="view"?[{component:Me(Gt,{elementId:e})}]:[{component:Me(Gt,{elementId:e})},...v||N?[]:[{component:Me(Od,{nodeId:e})}],{component:Me(Mo,{nodeId:e})},Mt.TASK,{type:"TASK",variant:"SUBPROCESS",icon:jo,label:"bpmn.task.variant.subprocess"},{type:"TASK",variant:"SERVICE_TASK",icon:Hd,label:"bpmn.task.variant.service_task"},Mt.ANNOTATION,...Object.values(l0),...ao(e,V,F)?[]:[Mt.END_EVENT],...j],A=()=>p==="view"?[{component:Me(Gt,{elementId:e,elementType:"gateway"})}]:[{component:Me(Gt,{elementId:e,elementType:"gateway"})},{component:Me(Mo,{nodeId:e})},Mt.TASK,{type:"TASK",variant:"SUBPROCESS",icon:jo,label:"bpmn.task.variant.subprocess"},{type:"TASK",variant:"SERVICE_TASK",icon:Hd,label:"bpmn.task.variant.service_task"},Mt.ANNOTATION,...j],P=()=>p==="view"?[]:[Mt.ANNOTATION,...j],k=()=>p==="view"?[]:[...n?[]:[{component:Me(Mo,{nodeId:e})}],Mt.ANNOTATION,...j],S=()=>p==="view"?[]:[{component:Me(Mo,{nodeId:e})},...j],B=()=>p==="view"?[]:[...j],R=(z=>{switch(z){case"START_EVENT":return q();case"TASK":return $();case"GATEWAY":return A();case"END_EVENT":return P();case"LANE":return k();case"ANNOTATION":return S();case"UNSUPPORTED":return B();default:return[]}})(t),H=R.length>6;if(!(R.length===0||p==="readonly"))return Gd(Qy,{position:T,align:"start",className:H?"-top-[4.5rem]":"-top-8",isVisible:f,children:[Me("div",{ref:r,className:`${H?"grid grid-cols-6":"flex"} gap-1 px-2 py-2 bg-white rounded-sm shadow-md`,children:R.map((z,K)=>{if(z.component)return Me("div",{children:z.component},K);let Z={sourceNodeType:t,targetNodeType:z.type,sourceNodeId:e,nodes:V,edges:F},W=Hc(Z),X={gateway_limit_reached:s("editor.toolbar.gateway_limit_reached"),start_event_limit_reached:s("editor.toolbar.start_event_limit_reached"),start_event_already_exists:s("editor.toolbar.start_event_already_exists"),script_to_end_not_allowed:s("editor.toolbar.script_to_end_not_allowed"),loop_to_end_not_allowed:s("editor.toolbar.loop_to_end_not_allowed"),initial_activity_to_end_not_allowed:s("editor.toolbar.initial_activity_to_end_not_allowed"),final_activity_cannot_connect:s("editor.toolbar.final_activity_cannot_connect"),activity_has_outgoing_connections:s("editor.toolbar.activity_has_outgoing_connections"),task_limit_reached:s("editor.toolbar.task_limit_reached"),start_event_to_service_task_not_allowed:s("editor.toolbar.start_event_to_service_task_not_allowed"),service_task_to_end_not_allowed:s("editor.toolbar.service_task_to_end_not_allowed")},Q=W.shouldDisable&&W.reason?X[W.reason]||s(z.label):s(z.label)||"";return Gd(t0,{children:[Me(n0,{asChild:!0,children:Me(e0,{variant:"ghost",color:"grey",size:"small",iconButton:!0,draggable:!W.shouldDisable,disabled:W.shouldDisable,className:W.shouldDisable?"opacity-50 cursor-not-allowed":"",onDragStart:W.shouldDisable?void 0:ee=>D(ee,z),onDragEnd:W.shouldDisable?void 0:O,children:z.icon&&Me(z.icon,{size:16})})}),Me(o0,{color:"black",children:Q})]},K)})}),Me("div",{ref:i,className:"absolute w-0 h-0 top-0 left-0 z-[-1] bg-transparent",children:b})]})});Ye.displayName="NodeToolbar";import{Fragment as Bd,jsx as ft,jsxs as bs}from"react/jsx-runtime";var zd=({id:e,data:t,selected:o,dragging:n})=>{let{updateNodeData:r,setNodes:i}=d0(),{inProgress:s,fromNode:a}=c0(),{mode:l,isReadOnly:c}=U(),d=s&&(a==null?void 0:a.id)!==e,u=_s(x=>{let y=x.split(`
40
- `),T=y.reduce((N,C)=>Math.max(N,C.length),0),b=y.length,I=Math.max(Bo.MIN_WIDTH,T*7+32),v=Math.max(Bo.MIN_HEIGHT,b*20+24);i(N=>N.map(C=>C.id===e?w(_({},C),{width:I,height:v,style:w(_({},C.style),{width:I,height:v})}):C))},[e,i]),p=_s(x=>{r(e,{label:x}),u(x)},[e,r,u]),m=_s(x=>{u(x)},[u]);return bs("div",{className:G("relative w-full h-full min-w-44 min-h-16 flex text-grey-400 hover:text-grey-500 bg-white rounded-sm border-l-2 border-current before:absolute before:top-0 before:left-0 before:w-4 before:border-t-2 before:border-current after:absolute after:bottom-0 after:left-0 after:w-4 after:border-t-2 after:border-current hover:shadow-md transition-colors duration-75",{"pointer-events-none":c,"text-blue-500 hover:text-blue-600 shadow-md":o&&!c,"border-red-500 border-l-[3px] shadow-[0_0_5px_rgba(255,0,0,0.5)] before:absolute before:top-0 before:left-0 before:w-4 before:border-t-2 before:border-red-500 after:absolute after:bottom-0 after:left-0 after:w-4 after:border-t-2 after:border-red-500":t.hasError}),children:[ft(Oe,{value:t.label,className:"m-1 text-grey-600 text-left",onChange:p,onInput:m,skipFirstCharValidation:!0}),ft(Ye,{nodeId:e,nodeType:"ANNOTATION"}),l==="edit"&&ft(at,{nodeId:e,minWidth:Bo.MIN_WIDTH,minHeight:Bo.MIN_HEIGHT,isVisible:!n&&o}),!s&&bs(Bd,{children:[ft(ne,{type:"source",position:Ft.Left,id:"left"}),ft(ne,{type:"source",position:Ft.Right,id:"right"}),ft(ne,{type:"source",position:Ft.Top,id:"top"}),ft(ne,{type:"source",position:Ft.Bottom,id:"bottom"})]}),(!s||d)&&bs(Bd,{children:[ft(ne,{type:"target",position:Ft.Left,id:"left",className:G({"annotation-handle":d})}),ft(ne,{type:"target",position:Ft.Right,id:"right",className:G({"annotation-handle":d})}),ft(ne,{type:"target",position:Ft.Top,id:"top",className:G({"annotation-handle":d})}),ft(ne,{type:"target",position:Ft.Bottom,id:"bottom",className:G({"annotation-handle":d})})]})]})};import{Position as Wt,useConnection as u0,useReactFlow as p0}from"@xyflow/react";import{useState as f0}from"react";import{Fragment as Yd,jsx as Qe,jsxs as Ts}from"react/jsx-runtime";var Fd=({id:e,data:t,selected:o,dragging:n})=>{let{updateNodeData:r}=p0(),{inProgress:i,fromNode:s}=u0(),{mode:a,isReadOnly:l,reconnectingEdgeId:c}=U(),[d,u]=f0(!1),p=i&&(s==null?void 0:s.id)!==e||!!c,m=g=>{r(e,{label:g})},x=()=>{u(!0)},E=()=>{u(!1)};return Ts("div",{className:"relative",onDoubleClick:x,children:[Qe(_o,{className:G("w-full h-full min-w-9 min-h-9 hover:stroke-[#d33b3b] transition-colors duration-75",{"pointer-events-none":l,"stroke-blue-500 hover:stroke-blue-600":o&&!l,"stroke-red-500 hover:stroke-red-600 drop-shadow-[0_0_3px_rgba(255,0,0,0.5)] fill-red-100":t.hasError})}),Qe("div",{className:"absolute mt-2 left-1/2 -translate-x-1/2 max-w-80 w-max",children:Qe(Oe,{value:t.label,isEditing:d,onBlur:E,onChange:m})}),Qe(Ye,{nodeId:e,nodeType:"END_EVENT"}),a==="edit"&&Qe(at,{nodeId:e,isVisible:!n&&o,minWidth:Qr.MIN_WIDTH,minHeight:Qr.MIN_HEIGHT,offset:4,keepAspectRatio:!0}),(!i||p)&&Ts(Yd,{children:[Qe(ne,{type:"target",position:Wt.Left,id:"left",className:G({"event-handle":p})}),Qe(ne,{type:"target",position:Wt.Right,id:"right",className:G({"event-handle":p})}),Qe(ne,{type:"target",position:Wt.Top,id:"top",className:G({"event-handle":p})}),Qe(ne,{type:"target",position:Wt.Bottom,id:"bottom",className:G({"event-handle":p})})]}),!i&&Ts(Yd,{children:[Qe(ne,{type:"source",position:Wt.Left,id:"left"}),Qe(ne,{type:"source",position:Wt.Right,id:"right"}),Qe(ne,{type:"source",position:Wt.Top,id:"top"}),Qe(ne,{type:"source",position:Wt.Bottom,id:"bottom"})]})]})};import{Position as Xt,useConnection as m0,useReactFlow as g0}from"@xyflow/react";import{memo as h0,useCallback as y0,useState as x0}from"react";import{Fragment as Wd,jsx as je,jsxs as vs}from"react/jsx-runtime";var Ns=h0(({id:e,data:t,width:o,height:n,selected:r,dragging:i})=>{let s=Fi[t.variant].icon,{updateNodeData:a}=g0(),{inProgress:l,fromNode:c}=m0(),{mode:d,isReadOnly:u,reconnectingEdgeId:p}=U(),[m,x]=x0(!1),E=l&&(c==null?void 0:c.id)!==e||!!p,g=y0(y=>{a(e,{label:y})},[e,a]),h=()=>{x(!0)},f=()=>{x(!1)};return vs("div",{className:"relative",style:{width:o!=null?o:Go.MIN_WIDTH,height:n!=null?n:Go.MIN_HEIGHT},onDoubleClick:h,children:[je(s,{className:G("w-full h-full min-w-14 min-h-14 stroke-1 stroke-grey-400 hover:stroke-grey-500 transition-colors duration-75",{"pointer-events-none":u,"stroke-blue-500 hover:stroke-blue-600":r&&!u,"stroke-red-500 hover:stroke-red-600 drop-shadow-[0_0_3px_rgba(255,0,0,0.5)]":t.hasError})}),je("div",{className:"absolute mt-2 left-1/2 -translate-x-1/2 max-w-80 w-max",children:je(Oe,{value:t.label,isEditing:m,onBlur:f,onChange:g})}),je(Ye,{nodeId:e,nodeType:"GATEWAY",nodeVariant:t.variant}),d==="edit"&&je(at,{nodeId:e,isVisible:!i&&r,minWidth:Go.MIN_WIDTH,minHeight:Go.MIN_HEIGHT,offset:2,keepAspectRatio:!0}),(!l||E)&&vs(Wd,{children:[je(ne,{type:"target",position:Xt.Left,id:"left",className:G({"gateway-handle":E})}),je(ne,{type:"target",position:Xt.Right,id:"right",className:G({"gateway-handle":E})}),je(ne,{type:"target",position:Xt.Top,id:"top",className:G({"gateway-handle":E})}),je(ne,{type:"target",position:Xt.Bottom,id:"bottom",className:G({"gateway-handle":E})})]}),!l&&vs(Wd,{children:[je(ze,{type:"source",position:Xt.Left,id:"left",nodeId:e,nodeType:"GATEWAY",gatewayVariant:t.variant}),je(ze,{type:"source",position:Xt.Right,id:"right",nodeId:e,nodeType:"GATEWAY",gatewayVariant:t.variant}),je(ze,{type:"source",position:Xt.Top,id:"top",nodeId:e,nodeType:"GATEWAY",gatewayVariant:t.variant}),je(ze,{type:"source",position:Xt.Bottom,id:"bottom",nodeId:e,nodeType:"GATEWAY",gatewayVariant:t.variant})]})]})});Ns.displayName="Gateway";import{useNodesData as aL,useReactFlow as lL}from"@xyflow/react";import{Button as dL,DropdownMenu as uL,DropdownMenuContent as pL,DropdownMenuGroup as fL,DropdownMenuItem as mL,DropdownMenuLabel as gL,DropdownMenuTrigger as hL,Tooltip as yL,TooltipContent as xL,TooltipTrigger as EL,useTranslation as _L}from"@produto-lecom/lecom-ui";import{WrenchIcon as TL}from"lucide-react";import{jsx as IL,jsxs as AL}from"react/jsx-runtime";import{Position as Ut,useConnection as E0,useReactFlow as _0}from"@xyflow/react";import{useState as b0}from"react";import{Fragment as Xd,jsx as et,jsxs as ws}from"react/jsx-runtime";var Ud=({id:e,data:t,selected:o,dragging:n})=>{let{updateNodeData:r}=_0(),{inProgress:i,fromNode:s}=E0(),{mode:a,isReadOnly:l,reconnectingEdgeId:c}=U(),[d,u]=b0(!1),p=i&&(s==null?void 0:s.id)!==e||!!c,m=g=>{r(e,{label:g})},x=()=>{u(!0)},E=()=>{u(!1)};return ws("div",{className:"relative",onDoubleClick:x,children:[et(Fn,{className:G("w-full h-full min-w-9 min-h-9 hover:stroke-[#54890b] transition-colors duration-75",{"pointer-events-none":l,"stroke-blue-500 hover:stroke-blue-600":o&&!l,"stroke-red-500 hover:stroke-red-600 drop-shadow-[0_0_3px_rgba(255,0,0,0.5)] fill-red-100":t.hasError})}),et("div",{className:"absolute mt-2 left-1/2 -translate-x-1/2 max-w-80 w-max",children:et(Oe,{value:t.label,isEditing:d,onBlur:E,onChange:m})}),et(Ye,{nodeId:e,nodeType:"START_EVENT"}),a==="edit"&&et(at,{nodeId:e,isVisible:!n&&o,minWidth:Jr.MIN_WIDTH,minHeight:Jr.MIN_HEIGHT,offset:4,keepAspectRatio:!0}),(!i||p)&&ws(Xd,{children:[et(ne,{type:"target",position:Ut.Left,id:"left",className:G({"event-handle":p})}),et(ne,{type:"target",position:Ut.Right,id:"right",className:G({"event-handle":p})}),et(ne,{type:"target",position:Ut.Top,id:"top",className:G({"event-handle":p})}),et(ne,{type:"target",position:Ut.Bottom,id:"bottom",className:G({"event-handle":p})})]}),!i&&ws(Xd,{children:[et(ze,{type:"source",position:Ut.Left,id:"left",nodeId:e,nodeType:"START_EVENT"}),et(ze,{type:"source",position:Ut.Right,id:"right",nodeId:e,nodeType:"START_EVENT"}),et(ze,{type:"source",position:Ut.Top,id:"top",nodeId:e,nodeType:"START_EVENT"}),et(ze,{type:"source",position:Ut.Bottom,id:"bottom",nodeId:e,nodeType:"START_EVENT"})]})]})};import{useTranslation as N0}from"@produto-lecom/lecom-ui";import{Position as $t,useConnection as w0,useReactFlow as I0}from"@xyflow/react";import{memo as A0,useCallback as ii}from"react";var Cn=60,ri=(e,t)=>{var s;let o=[],n=`${t} `;for(let a of e){if(!(a.type==="TASK"))continue;let c=(s=a.data)==null?void 0:s.label;if(c&&c.startsWith(n)){let d=c.substring(n.length);/^\d{1,15}$/.test(d)&&o.push(parseInt(d,10))}}let r=o.length>0?Math.max(...o)+1:1,i=`${t} ${r}`;return i.length<=Cn?i:i.substring(0,Cn).trim()},Xo=(e,t)=>{var a;let o=new Set;for(let l of t)l.type==="TASK"&&((a=l.data)!=null&&a.label)&&o.add(l.data.label);let n=e;if(n.length>Cn&&(n=n.substring(0,Cn).trim()),!o.has(n))return n;let r=n.replace(/\s+\(\d+\)$/,""),i=2,s=o.size+2;for(;i<=s;){let l=` (${i})`,c=Cn-l.length,u=`${r.substring(0,c).trim()}${l}`;if(!o.has(u))return u;i++}return n};import{jsx as $d,jsxs as T0}from"react/jsx-runtime";var Kd=e=>T0("svg",w(_({width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",xmlns:"http://www.w3.org/2000/svg"},e),{children:[$d("circle",{cx:"12",cy:"12",r:"10",fill:"#10B981"}),$d("path",{d:"M7 12L10 15L17 8",stroke:"white",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"})]}));import{jsx as qd}from"react/jsx-runtime";var Zd=e=>qd("svg",w(_({width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",xmlns:"http://www.w3.org/2000/svg"},e),{children:qd("path",{d:"M12 2C8.13 2 5 5.13 5 9C5 14.25 12 22 12 22C12 22 19 14.25 19 9C19 5.13 15.87 2 12 2ZM12 11.5C10.62 11.5 9.5 10.38 9.5 9C9.5 7.62 10.62 6.5 12 6.5C13.38 6.5 14.5 7.62 14.5 9C14.5 10.38 13.38 11.5 12 11.5Z",fill:"#38bdf8"})}));import{jsx as Jd,jsxs as v0}from"react/jsx-runtime";var Qd=e=>v0("svg",w(_({width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",xmlns:"http://www.w3.org/2000/svg"},e),{children:[Jd("circle",{cx:"12",cy:"12",r:"10",fill:"#EF4444"}),Jd("path",{d:"M8 8L16 16M8 16L16 8",stroke:"white",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"})]}));import{Fragment as si,jsx as Ee,jsxs as Sn}from"react/jsx-runtime";var C0={APROVADO:Kd,EM_ANDAMENTO:Zd,REJEITADO:Qd},Is={APROVADO:"border-green-500 hover:border-green-500 border-[3px] border-solid",EM_ANDAMENTO:"border-turquoise-400 hover:border-turquoise-400 border-[3px] border-solid",REJEITADO:"border-red-500 hover:border-red-500 border-[3px] border-solid",default:"border-grey-400 border-2 border-solid",error:"border-red-500 border-[3px] shadow-[0_0_5px_rgba(255,0,0,0.5)]"},S0={APROVADO:"bg-green-50",EM_ANDAMENTO:"bg-turquoise-50",REJEITADO:"bg-red-50"},As=A0(({id:e,data:t,width:o,height:n,selected:r,dragging:i})=>{let{t:s}=N0(),{toast:a}=Pe(),{updateNodeData:l,getNodes:c,setNodes:d}=I0(),{inProgress:u,fromNode:p}=w0(),{mode:m,isReadOnly:x,onSubprocessValidationClick:E,reconnectingEdgeId:g}=U(),{getTaskStatus:h}=to(),f=u&&(p==null?void 0:p.id)!==e||!!g,y=h(e),T=t.variant==="SUBPROCESS",b=t.variant==="SERVICE_TASK",I=!!t.variant&&!T&&!b||!!y,v=!!t.attribute||T||b,N=ii($=>{let S=I||v?80:40,B=$.split(`
41
- `),Y=B.reduce((K,Z)=>Math.max(K,Z.length),0),R=B.length,H=Math.max(Yt.MIN_WIDTH,Y*7+64),z=Math.max(Yt.MIN_HEIGHT,R*24+S);d(K=>K.map(Z=>Z.id===e?w(_({},Z),{width:H,height:z,style:w(_({},Z.style),{width:H,height:z})}):Z))},[e,d,I,v]),C=ii($=>{let A=$.trim(),P=t.label||"";if(A===P)return;let k=A,S=c();if(!(A&&A!=="")){k=ri(S,s("bpmn.task.label.prefix")),l(e,{label:k}),N(k),a({variant:"warning",content:Sn(si,{children:[s("bpmn.task.feedback.label_empty.prefix")," ",Ee("strong",{children:k})]})});return}let Y=Xo(k,S);Y===P||(l(e,{label:Y}),N(Y),Y!==k&&a({variant:"warning",content:Sn(si,{children:[s("bpmn.task.feedback.label_already_exists.prefix")," ",Ee("strong",{children:A})," ",s("bpmn.task.feedback.label_already_exists.middle")," ",Ee("strong",{children:Y})]})}))},[t.label,c,e,s,l,N,a]),M=ii($=>{N($)},[N]),L=ii(()=>{a({variant:"error",content:s("bpmn.task.feedback.invalid_first_character")})},[s,a]),D=y?C0[y]:null,O=t.variant?Xn[t.variant].icon:null,V=t.attribute?Un[t.attribute].icon:null,F=()=>t.hasError?Is.error:y?Is[y]:x?Is.default:"",j=()=>{var $;return r&&($=S0[y])!=null?$:""},q=()=>{E==null||E({id:e,type:"sub_process",label:t.label})};return Sn("div",{className:G("relative w-full h-full min-w-44 min-h-24 flex flex-col items-stretch justify-stretch bg-white border-2 border-grey-400 hover:border-grey-500 rounded-md hover:shadow-md transition-colors duration-75",F(),{"cursor-pointer":x,"border-blue-500 hover:border-blue-600 shadow-md":r&&!x&&!y,"border-red-500 hover:border-red-600 shadow-[0_0_5px_rgba(255,0,0,0.5)]":t.hasError}),style:{width:o!=null?o:Yt.MIN_WIDTH,height:n!=null?n:Yt.MIN_HEIGHT},children:[Ee("div",{className:"flex-1 flex items-stretch justify-stretch overflow-hidden",children:Ee(Oe,{value:t.label,maxLength:60,className:G(j(),{"py-10 px-8":I||v}),onChange:C,onInput:M,onInvalidFirstCharacter:L})}),O&&Ee("div",{className:G("absolute flex items-center p-1",T||b?"bottom-0 left-1/2 -translate-x-1/2":"top-0 left-0"),children:Ee(O,{size:b?20:16,className:G(t.hasError?"text-red-500":"text-grey-500",T&&"cursor-pointer"),onClick:T?q:void 0})}),V&&Ee("div",{className:"absolute bottom-0 left-0 w-full flex items-center justify-center",children:Ee("div",{className:G("flex items-center w-16 p-1",T||b?"justify-between":"justify-center"),children:Ee(V,{size:16,className:G(t.hasError?"text-red-500":"text-grey-500")})})}),D&&Ee("div",{className:"absolute top-0 right-0 flex items-center p-1",children:Ee(D,{})}),Ee(Ye,{nodeId:e,nodeType:"TASK",nodeVariant:t.variant}),m==="edit"&&Ee(at,{nodeId:e,isVisible:!i&&r,minWidth:Yt.MIN_WIDTH,minHeight:Yt.MIN_HEIGHT}),(!u||f)&&Sn(si,{children:[Ee(ne,{type:"target",position:$t.Left,id:"left",className:G({"task-handle":f})}),Ee(ne,{type:"target",position:$t.Right,id:"right",className:G({"task-handle":f})}),Ee(ne,{type:"target",position:$t.Top,id:"top",className:G({"task-handle":f})}),Ee(ne,{type:"target",position:$t.Bottom,id:"bottom",className:G({"task-handle":f})})]}),!u&&Sn(si,{children:[Ee(ze,{type:"source",position:$t.Left,id:"left",nodeId:e,nodeType:"TASK"}),Ee(ze,{type:"source",position:$t.Right,id:"right",nodeId:e,nodeType:"TASK"}),Ee(ze,{type:"source",position:$t.Top,id:"top",nodeId:e,nodeType:"TASK"}),Ee(ze,{type:"source",position:$t.Bottom,id:"bottom",nodeId:e,nodeType:"TASK"})]})]})});As.displayName="Task";import{Position as jd}from"@xyflow/react";import{Fragment as M0,jsx as ai,jsxs as P0}from"react/jsx-runtime";var eu=({id:e,data:t})=>P0(M0,{children:[ai("div",{className:"relative w-full h-full min-w-32 min-h-16 flex items-center justify-center bg-white border-2 border-red-400 rounded-sm overflow-hidden",children:t.label}),ai(Ye,{nodeId:e,nodeType:"UNSUPPORTED"}),ai(ne,{type:"source",position:jd.Right}),ai(ne,{type:"target",position:jd.Left})]});import{BaseEdge as L0,EdgeLabelRenderer as k0,getSmoothStepPath as R0,MarkerType as D0,useInternalNode as tu,useReactFlow as O0,useViewport as V0,Position as Uo}from"@xyflow/react";import{useState as H0,useMemo as G0}from"react";import{Fragment as B0,jsx as tt,jsxs as fo}from"react/jsx-runtime";var pk={type:"MESSAGE_EDGE",reconnectable:!0,markerEnd:{type:D0.Arrow},data:{label:""}},ou=({id:e,source:t,target:o,data:n,selected:r,sourcePosition:i,targetPosition:s,sourceHandleId:a,targetHandleId:l})=>{var B;let{zoom:c}=V0(),{updateEdgeData:d}=O0(),{mode:u,instanceId:p}=U(),m=Et(),x=u!=="edit",[E,g]=H0(!1),{reconnectingHandle:h,cursorPosition:f,hoveredNodeId:y,reconnectingSide:T,isValidReconnection:b,handleReconnectStart:I}=Ur({edgeId:e,source:t,target:o,instanceId:p,isReadOnly:x}),v=tu(t),N=tu(o),{sx:C,sy:M,tx:L,ty:D,sourcePos:O,targetPos:V}=G0(()=>{var te,fe;if(!v||!N)return{sx:0,sy:0,tx:0,ty:0,sourcePos:Uo.Left,targetPos:Uo.Right};let Y=No(v,N),R=a?i:Y.sourcePos,H=l?s:Y.targetPos,z=(ue,le,ge)=>{var oe,ae,he,Ne,we,Fe;let{x:be,y:Re}=ue.internals.positionAbsolute,J=(he=(ae=(oe=ue.measured)==null?void 0:oe.width)!=null?ae:ue.width)!=null?he:0,se=(Fe=(we=(Ne=ue.measured)==null?void 0:Ne.height)!=null?we:ue.height)!=null?Fe:0;switch(le){case Uo.Top:return{x:be+J*ge,y:Re};case Uo.Bottom:return{x:be+J*ge,y:Re+se};case Uo.Left:return{x:be,y:Re+se*ge};case Uo.Right:return{x:be+J,y:Re+se*ge};default:return{x:be+J/2,y:Re+se/2}}},K=(te=n==null?void 0:n.sourceOffset)!=null?te:.5,Z=(fe=n==null?void 0:n.targetOffset)!=null?fe:.5,W=v?z(v,R,K).x:Y.sx,X=v?z(v,R,K).y:Y.sy,Q=N?z(N,H,Z).x:Y.tx,ee=N?z(N,H,Z).y:Y.ty;return h==="source"&&f?(W=f.x,X=f.y,T&&(R=T)):h==="target"&&f&&(Q=f.x,ee=f.y,T&&(H=T)),{sx:W,sy:X,tx:Q,ty:ee,sourcePos:R,targetPos:H}},[v,N,a,l,i,s,h,f,T,n==null?void 0:n.sourceOffset,n==null?void 0:n.targetOffset]);if(!v||!N)return null;let[F,j,q]=R0({sourceX:C,sourceY:M,targetX:L,targetY:D,sourcePosition:O,targetPosition:V}),$=r||(v==null?void 0:v.selected)||(N==null?void 0:N.selected),A=$?"sequence-edge-marker-highlighted":"sequence-edge-marker",P=E||(n==null?void 0:n.label.trim().length)>0,k=()=>{g(!1)},S=Y=>{d(e,{label:Y.trim()})};return fo("g",{className:G("group bpmn-arrow-edge",{"is-highlighted":$}),onDoubleClick:()=>!x&&g(!0),children:[tt("path",{d:F,fill:"none",stroke:"transparent",strokeWidth:Math.max(12,12/c),style:{pointerEvents:"stroke",cursor:"pointer"}}),fo("g",{className:G("text-grey-500 transition-colors duration-75 group-hover:text-grey-800",{"text-blue-500 group-hover:text-blue-600":$}),children:[tt(L0,{id:e,path:F,interactionWidth:0,markerEnd:`url(#${A})`,strokeDasharray:4,className:G("stroke-2 stroke-current transition-[stroke] duration-75 group-hover:stroke-[2.5px]",{"stroke-red-500 hover:stroke-red-600":(n==null?void 0:n.hasError)||h&&y&&!b,"stroke-green-500":h&&y&&b,"stroke-blue-500 hover:stroke-blue-600 stroke-[3px]":$&&!(n!=null&&n.hasError)&&!h})}),fo(k0,{children:[fo("div",{className:"absolute z-[3000] pointer-events-auto flex flex-col items-center gap-1",style:{transform:`translate(-50%, -50%) translate(${j}px, ${q}px)`},children:[r&&!m&&tt(Lo,{sx:C,sy:M,tx:L,ty:D,hasLabel:!!((B=n==null?void 0:n.label)!=null&&B.trim()),children:tt(Po,{edgeId:e,edgeType:"MESSAGE_EDGE"})}),P&&tt(Oe,{value:n==null?void 0:n.label,className:"min-w-8 max-w-56 bg-white rounded-md px-2 py-1 text-xs",isEditing:E,onBlur:k,onChange:S})]}),r&&!m&&!x&&fo(B0,{children:[tt("div",{className:"absolute z-[1000] pointer-events-none",style:{transform:`translate(-50%, -50%) translate(${C}px, ${M}px)`},children:fo("svg",{width:12/c,height:12/c,style:{overflow:"visible",position:"absolute",left:"50%",top:"50%",transform:"translate(-50%, -50%)"},children:[tt("circle",{cx:6/c,cy:6/c,r:4/c,fill:h==="source"?"#3b82f6":"#fff",stroke:"#3b82f6",strokeWidth:2/c,className:"pointer-events-none"}),tt("circle",{cx:6/c,cy:6/c,r:6/c,fill:"none",stroke:"#3b82f6",strokeWidth:1/c,opacity:h==="source"?.6:.3,className:"pointer-events-none"}),tt("circle",{cx:6/c,cy:6/c,r:8/c,fill:"transparent",className:G("pointer-events-auto",{"cursor-move":!h||h!=="source","cursor-not-allowed":h==="source"&&y&&!b,"cursor-grabbing":h==="source"&&(!y||b)}),onMouseDown:Y=>I("source",Y.nativeEvent)})]})}),tt("div",{className:"absolute z-[1000] pointer-events-none",style:{transform:`translate(-50%, -50%) translate(${L}px, ${D}px)`},children:fo("svg",{width:12/c,height:12/c,style:{overflow:"visible",position:"absolute",left:"50%",top:"50%",transform:"translate(-50%, -50%)"},children:[tt("circle",{cx:6/c,cy:6/c,r:4/c,fill:h==="target"?"#3b82f6":"#fff",stroke:"#3b82f6",strokeWidth:2/c,className:"pointer-events-none"}),tt("circle",{cx:6/c,cy:6/c,r:6/c,fill:"none",stroke:"#3b82f6",strokeWidth:1/c,opacity:h==="target"?.6:.3,className:"pointer-events-none"}),tt("circle",{cx:6/c,cy:6/c,r:8/c,fill:"transparent",className:G("pointer-events-auto",{"cursor-move":!h||h!=="target","cursor-not-allowed":h==="target"&&y&&!b,"cursor-grabbing":h==="target"&&(!y||b)}),onMouseDown:Y=>I("target",Y.nativeEvent)})]})})]})]})]})]})};import{getStraightPath as z0,Position as li}from"@xyflow/react";import{jsx as nu,jsxs as Y0}from"react/jsx-runtime";var ru=({toX:e,toY:t,fromNode:o})=>{var u,p;if(!o)return null;let{internals:{positionAbsolute:{x:n,y:r}},measured:i}=o,s=(u=i.width)!=null?u:0,a=(p=i.height)!=null?p:0,c=[{x:n,y:r+a/2,pos:li.Left},{x:n+s,y:r+a/2,pos:li.Right},{x:n+s/2,y:r,pos:li.Top},{x:n+s/2,y:r+a,pos:li.Bottom}].reduce((m,x)=>{let E=Math.hypot(e-m.x,t-m.y);return Math.hypot(e-x.x,t-x.y)<E?x:m}),[d]=z0({sourceX:c.x,sourceY:c.y,targetX:e,targetY:t});return Y0("g",{className:"group",children:[nu("path",{fill:"none",className:"stroke-2 stroke-grey-500 animated transition-[stroke,filter] duration-75",d}),nu("circle",{cx:e,cy:t,fill:"none",r:4,className:"stroke-2 stroke-grey-600"})]})};import{Position as Kt,useConnection as F0,useReactFlow as W0}from"@xyflow/react";import{orderBy as X0}from"lodash";import{memo as U0,useMemo as iu,useState as $0}from"react";import{Fragment as Cs,jsx as $e,jsxs as ci}from"react/jsx-runtime";var Ss=U0(({id:e,data:t,selected:o,dragging:n,parentId:r})=>{var v;let{updateNodeData:i,getNodes:s}=W0(),{mode:a,isReadOnly:l}=U(),{inProgress:c,fromNode:d}=F0(),u=c&&(d==null?void 0:d.id)!==e,[p,m]=$0(!1),x=s(),E=!r,g=!E&&((v=x.find(N=>N.id===r))==null?void 0:v.selected),h=iu(()=>X0([...x.filter(N=>N.parentId===e&&N.type==="LANE")],"position.y","asc"),[x,e]),f=E?id.MIN_WIDTH:ie.MIN_WIDTH,y=iu(()=>{if(E&&h.length>1){let N=[...h];return N.pop(),N.reduce((M,L)=>{var D,O;return M+((O=(D=L.measured)==null?void 0:D.height)!=null?O:0)},0)+ie.MIN_HEIGHT}return ie.MIN_HEIGHT},[E,h]),T=N=>{i(e,{label:N})},b=()=>{m(!0)},I=()=>{m(!1)};return ci(Cs,{children:[ci("div",{className:G("flex h-full min-h-64 w-full min-w-[50rem] hover:shadow-md bg-white outline outline-2 outline-grey-400",{"pointer-events-none":l,"outline-offset-0 outline-blue-500 shadow-sm":(o||g)&&!l}),children:[$e("div",{className:G("flex align-items justify-center w-10 border-r-2 border-grey-400",{"border-blue-500":(o||g)&&!l}),onDoubleClick:b,children:$e("div",{className:"relative flex-1 [writing-mode:vertical-rl] [text-orientation:sideways] transform rotate-180",children:$e(Oe,{value:t.label,className:"w-full h-full self-auto",contentClassName:G({"whitespace-nowrap":p}),isEditing:p,onBlur:I,onChange:T})})}),$e("div",{className:"flex-1"})]}),$e(Ye,{nodeId:e,nodeType:"LANE",isChild:!E}),a==="edit"&&$e(at,{nodeId:e,isVisible:!n&&o,minWidth:f,minHeight:y,offset:10}),!c&&ci(Cs,{children:[$e(ne,{type:"source",position:Kt.Left,id:"left"}),$e(ne,{type:"source",position:Kt.Right,id:"right"}),$e(ne,{type:"source",position:Kt.Top,id:"top"}),$e(ne,{type:"source",position:Kt.Bottom,id:"bottom"})]}),(!c||u)&&ci(Cs,{children:[$e(ne,{type:"target",position:Kt.Left,id:"left",className:G({"annotation-handle":u})}),$e(ne,{type:"target",position:Kt.Right,id:"right",className:G({"annotation-handle":u})}),$e(ne,{type:"target",position:Kt.Top,id:"top",className:G({"annotation-handle":u})}),$e(ne,{type:"target",position:Kt.Bottom,id:"bottom",className:G({"annotation-handle":u})})]})]})});Ss.displayName="Lane";var su={START_EVENT:Ud,END_EVENT:Fd,TASK:As,GATEWAY:Ns,ANNOTATION:zd,LANE:Ss,UNSUPPORTED:eu},au={SEQUENCE_EDGE:ps,MESSAGE_EDGE:ou,ANNOTATION_EDGE:Yc},lu="#fafafa",cu="#bebebe",du=1,uu=10,pu="bottom-left",Ms=.05,fu=5,mu=150,gu=100,hu=Ms,yu=1,xu={x:0,y:0,zoom:.75},Eu=1,_u=2,K0={[Eu]:4,[_u]:2},Mn=[Eu,_u],bu=[0,1,2],Tu={hideAttribution:!0},Ps=Mn.reduce((e,t)=>e|K0[t],0);var qt=()=>{let{setViewport:e}=q0(),t=Z0();return{fitToNodes:J0(n=>{let{width:r,height:i}=t.getState();if(i<=0||r<=0)return;let s=La(n);if(!s)return;let a=ka({bounds:s,canvasHeight:i,canvasWidth:r,minZoom:hu,maxZoom:yu,offsetX:mu,offsetY:gu});e(a)},[t,e])}};import{useReactFlow as Q0}from"@xyflow/react";var lt=()=>{let{getEdges:e,getNodes:t}=Q0(),{lastElementId:o}=U(),n=()=>{let i=t(),s=e(),a=fd(i,s);return Math.max(a,o)};return{getLastId:n,getNextId:()=>n()+1}};var Zt=()=>{let{getNodes:e,getEdges:t,setNodes:o,setEdges:n}=j0(),{getLastId:r}=lt(),{fitToNodes:i}=qt(),{setLastElementId:s}=U(),a=vu(async(c="")=>{let{nodes:d,edges:u,lastElementId:p}=await Ad(c);i(d),o(d),n(u),s(p)},[o,n,s,i]),l=vu(()=>{let c=e(),d=t(),u=r();return Id(c,d,u)},[e,t,r]);return{importFromMxGraph:a,exportToMxGraph:l}};var ox=500,di=()=>{let{isInitialized:e,onElementChanges:t}=U(),{exportToMxGraph:o}=Zt(),n=tx(()=>{if(!e)return;let s=o();t==null||t(s)},ox);ex(()=>()=>{n.isPending()&&n.flush()},[n]);let r=Nu(s=>{s.every(c=>c.type==="select")||s.some(c=>c.type==="position"&&c.dragging)||n()},[n]),i=Nu(s=>{s.some(l=>l.type==="select")||n()},[n]);return{emitElementChanges:n,handleNodeChanges:r,handleEdgeChanges:i}};var wu=({setEdges:e,saveHistory:t})=>{let{getNode:o,getEdges:n,getNodes:r,getInternalNode:i}=rx(),{emitElementChanges:s}=di(),a=ix(null),{getNextId:l}=lt(),c=mo(g=>{var b;let h=o(g.source),f=o(g.target);if(!h||!f)return!1;let y={sourceNodeId:h.id,targetNodeId:f.id,sourceNodeType:h.type,targetNodeType:f.type,nodes:r(),edges:n(),reconnectingEdgeId:(b=a.current)!=null?b:void 0};return ls(y).isValid},[o,n,r]),d=mo(g=>{var y,T;let h=l(),f=i(g.source);if(f){let b=i(g.target),I=b?b.internals.positionAbsolute.x+((y=b.measured.width)!=null?y:0)/2:0,v=b?b.internals.positionAbsolute.y+((T=b.measured.height)!=null?T:0)/2:0,N=rd(f,I,v),C=(b==null?void 0:b.type)==="ANNOTATION"||(f==null?void 0:f.type)==="ANNOTATION",M=C?Ro:st,L;if(!C&&b&&g.targetHandle){let V=Zr(N),F=Zr(g.targetHandle),{x:j,y:q}=fs(f,N),{x:$,y:A}=fs(b,g.targetHandle),k=Wr(j,q,$,A,V,F).slice(1,-1);k.length>0&&(L=k)}let D=w(_(_({},g),M),{id:String(h),sourceHandle:N,data:_(_({},C?{}:st.data),L?{points:L}:{})}),O=n().concat(D);e(O),t("forceSave",{nodes:r(),edges:O}),s()}},[l,e,s,i,n,r,t]),u=mo((g,h)=>{a.current=h.id},[]),p=mo(()=>{a.current=null},[]),m=mo((g,h)=>{let f=o(h.source),y=o(h.target);if(!f||!y){a.current=null;return}let T={sourceNodeId:f.id,targetNodeId:y.id,sourceNodeType:f.type,targetNodeType:y.type,nodes:r(),edges:n(),reconnectingEdgeId:g.id};if(!ls(T).isValid){a.current=null;return}let I=nx(g,h,n()).map(v=>v.id===g.id?w(_({},v),{data:w(_({},v.data),{points:void 0})}):v);e(I),t("forceSave",{nodes:r(),edges:I}),a.current=null,s()},[o,r,n,e,s,t]),x=mo(g=>{a.current=g},[]),E=mo(()=>{a.current=null},[]);return{isValidConnection:c,onConnect:d,onReconnect:m,onReconnectStart:u,onReconnectEnd:p,setReconnectingEdge:x,clearReconnectingEdge:E}};import{Typography as Ru,useTranslation as ax}from"@produto-lecom/lecom-ui";import{useReactFlow as lx}from"@xyflow/react";import{useCallback as $o,useRef as Ls,useState as cx}from"react";var Pn=(e=[])=>e.filter(t=>t.type==="START_EVENT"),go=(e=[])=>e.filter(t=>t.type==="END_EVENT"),Jt=(e=[])=>e.filter(t=>t.type==="TASK")||[],Iu=(e=[])=>e.filter(t=>{var o;return t.type==="TASK"&&((o=t.properties)==null?void 0:o.variant)==="SCRIPT"});var ui=(e=[])=>e.filter(t=>t.type==="GATEWAY"),Au=(e=[])=>e.filter(t=>{var o;return t.type==="GATEWAY"&&((o=t.properties)==null?void 0:o.variant)==="EXCLUSIVE"}),ot=(e,t=[])=>t.filter(o=>o.source===e),Ln=(e,t=[])=>t.filter(o=>o.target===e),Cu=(e,t)=>{var n,r;let o=(n=t.nodes)==null?void 0:n.find(i=>i.id===e);return((r=o==null?void 0:o.properties)==null?void 0:r.attribute)==="LOOP"},Su=(e,t)=>{let o=ot(e,t.edges||[]);for(let n of o){let r=(t.nodes||[]).find(i=>i.id===n.target);if(r&&r.type==="END_EVENT")return!0}return!1},Mu=e=>e?/[^\s]/.test(e.trim()):!1,me=e=>{let{isValid:t,nodeIds:o,edgeIds:n}=e;return{isValid:t,nodeIds:!t&&o&&o.length>0?o:[],edgeIds:!t&&n&&n.length>0?n:[]}},Pt=(e=[],t)=>{if(!e||e.length===0)return{isValid:!0,invalidIds:[]};let o=e.filter(n=>!t(n));return{isValid:o.length===0,invalidIds:o.map(n=>n.id)}},sx=(e,t)=>{let o=new Set(e.filter(n=>n.type==="ANNOTATION").map(n=>n.id));return t.filter(n=>!o.has(n.source)&&!o.has(n.target))},Pu=(e=[],t=[])=>({nodes:e.map(o=>{var n;return{id:o.id,type:o.type||"",label:typeof((n=o.data)==null?void 0:n.label)=="string"?o.data.label:void 0,properties:o.data}}),edges:sx(e,t).map(o=>({id:o.id,source:o.source,target:o.target,type:o.type||"default"}))});var kn=[{id:"start_event_not_found",validate:e=>{let t=Pn(e.nodes);return me({isValid:t.length>=1})}},{id:"end_event_not_found",validate:e=>{let t=go(e.nodes);return me({isValid:t.length>=1})}},{id:"multiple_start_event_not_allowed",validate:e=>{let t=Pn(e.nodes),o=t.length===1;if(t.length===0)return me({isValid:!0});if(!o)return me({isValid:!1,nodeIds:t.map(i=>i.id)});let n=ot(t[0].id,e.edges);if(!(n.length<=1)){let i=[...t.map(s=>s.id),...n.map(s=>s.target)];return me({isValid:!1,nodeIds:[...new Set(i)]})}return me({isValid:!0})}},{id:"task_flows_limit_exceeds",validate:e=>{let t=Jt(e.nodes),o=Pt(t,n=>ot(n.id,e.edges).length<=2);return me({isValid:o.isValid,nodeIds:o.invalidIds})}},{id:"task_label_empty",highlightRelatedEdges:!1,validate:e=>{let t=Jt(e.nodes),o=Pt(t,n=>!!n.label&&n.label.trim()!=="");return me({isValid:o.isValid,nodeIds:o.invalidIds})}},{id:"task_label_length",highlightRelatedEdges:!1,validate:e=>{let o=Jt(e.nodes),n=Pt(o,r=>!r.label||r.label.length<=60);return me({isValid:n.isValid,nodeIds:n.invalidIds})}},{id:"duplicate_task_name",highlightRelatedEdges:!1,validate:e=>{let t=Jt(e.nodes),o=new Map;for(let r of t){if(!r.label)continue;let i=r.label.trim();i&&(o.has(i)||o.set(i,[]),o.get(i).push(r))}let n=[];for(let[,r]of o.entries())r.length>1&&r.forEach(i=>n.push(i.id));return me({isValid:n.length===0,nodeIds:n})}},{id:"nested_gateway",validate:e=>{var r,i,s,a;let t=ui(e.nodes),o=[],n=[];for(let l of t){let c=ot(l.id,e.edges);for(let d of c){let u=e.nodes.find(x=>x.id===d.target);if((u==null?void 0:u.type)!=="GATEWAY")continue;let p=((r=l.properties)==null?void 0:r.variant)==="EXCLUSIVE"&&((i=u==null?void 0:u.properties)==null?void 0:i.variant)==="PARALLEL",m=((s=l.properties)==null?void 0:s.variant)==="COMPLEX"&&((a=u==null?void 0:u.properties)==null?void 0:a.variant)==="PARALLEL";!p&&!m&&(o.push(l.id,u.id),n.push(d.id))}}return me({isValid:o.length===0,nodeIds:o.length>0?[...new Set(o)]:[],edgeIds:n})}},{id:"events_nested",validate:e=>{let t=[...Pn(e.nodes),...go(e.nodes)],o=[],n=[];for(let r of t){let i=ot(r.id,e.edges);for(let s of i){let a=e.nodes.find(l=>l.id===s.target);a&&(a.type==="START_EVENT"||a.type==="END_EVENT")&&(o.push(r.id,a.id),n.push(s.id))}}return me({isValid:o.length===0,nodeIds:o.length>0?[...new Set(o)]:[],edgeIds:n})}},{id:"flows_on_end_tasks_not_allowed",validate:e=>{let t=go(e.nodes),o=[],n=[];for(let r of t){let i=Ln(r.id,e.edges);for(let s of i){let a=e.nodes.find(l=>l.id===s.source);if(a&&a.type==="TASK"){let l=ot(a.id,e.edges);l.length>1&&(o.push(a.id),l.forEach(c=>n.push(c.id)))}}}return me({isValid:o.length===0,nodeIds:o,edgeIds:n})}},{id:"conditions_flows_limit_exceeds",validate:e=>{let t=Au(e.nodes),o=Pt(t,r=>ot(r.id,e.edges).length<=2),n=o.invalidIds.flatMap(r=>ot(r,e.edges).map(i=>i.id));return me({isValid:o.isValid,nodeIds:o.invalidIds,edgeIds:n})}},{id:"activity_name_invalid",validate:e=>{let t=Jt(e.nodes),o=Pt(t,n=>!n.label||Mu(n.label));return me({isValid:o.isValid,nodeIds:o.invalidIds})}},{id:"final_activity_has_loop",validate:e=>{var s,a;if(!((s=e==null?void 0:e.nodes)!=null&&s.length)||!((a=e==null?void 0:e.edges)!=null&&a.length))return me({isValid:!0});let t=go(e.nodes)[0];if(!t)return me({isValid:!0});let o=Ln(t.id,e.edges);if(!o.length)return me({isValid:!0});let r=Jt(e.nodes).filter(l=>o.some(c=>c.source===l.id)),i=Pt(r,l=>!Cu(l.id,e));return me({isValid:i.isValid,nodeIds:i.isValid?[]:[t.id,...i.invalidIds]})}},{id:"concurrent_initial_and_final_event",validate:e=>{let t=Jt(e.nodes),o=go(e.nodes)[0];if(!o)return me({isValid:!0});let n=t.filter(l=>{let c=Ln(l.id,e.edges),d=ot(l.id,e.edges),u=c.some(m=>{var x;return((x=e.nodes.find(E=>E.id===m.source))==null?void 0:x.type)==="START_EVENT"}),p=d.some(m=>{var x;return((x=e.nodes.find(E=>E.id===m.target))==null?void 0:x.type)==="END_EVENT"});return u&&p}),r=Ln(o.id,e.edges),i=r.length>1,s=r.map(l=>l.source),a={isValid:n.length===0&&!i,nodeIds:[...n.map(l=>l.id),...i?s:[]]};return me(a)}},{id:"gateway_flow_to_event",validate:e=>{let t=ui(e.nodes),o=[],n=[];for(let r of t){let i=ot(r.id,e.edges);for(let s of i){let a=e.nodes.find(l=>l.id===s.target);a&&a.type==="END_EVENT"&&(o.push(r.id,a.id),n.push(s.id))}}return me({isValid:o.length===0,nodeIds:o.length>0?[...new Set(o)]:[],edgeIds:n})}},{id:"gateway_missing_output_streams",validate:e=>{let t=ui(e.nodes),o=Pt(t,n=>ot(n.id,e.edges).length>=1);return me({isValid:o.isValid,nodeIds:o.invalidIds})}},{id:"event_to_condition",validate:e=>{let t=[...Pn(e.nodes),...go(e.nodes)],o=[],n=[];for(let r of t){let i=ot(r.id,e.edges);for(let s of i){let a=e.nodes.find(l=>l.id===s.target);a&&a.type==="GATEWAY"&&(o.push(r.id,a.id),n.push(s.id))}}return me({isValid:o.length===0,nodeIds:o.length>0?[...new Set(o)]:[],edgeIds:n})}},{id:"script_in_final_activity",validate:e=>{let t=Iu(e.nodes),o=Pt(t,n=>!Su(n.id,e));return me({isValid:o.isValid,nodeIds:o.invalidIds})}}];var Lu=e=>{e=e||{nodes:[],edges:[]},e.nodes=e.nodes||[],e.edges=e.edges||[];let t=[];for(let n of kn){let r=n.validate(e);r.isValid||t.push({id:n.id,message:n.id,nodeIds:r.nodeIds||[],edgeIds:r.edgeIds||[]})}return{isValid:t.length===0,errors:t}},ku=async(e,t)=>{var n;let o=[];try{let r=await e(),i=(n=r==null?void 0:r.filter(s=>s.area==="DIAGRAM"))!=null?n:[];return i.length===0?{isValid:!0,errors:[]}:(i.forEach(s=>{var l,c;let a=(c=(l=s==null?void 0:s.detail)==null?void 0:l.phases)==null?void 0:c.map(d=>d.diagramCellId);o.push({id:s.code,message:s.code,nodeIds:a,edgeIds:[]})}),{isValid:!1,errors:o})}catch(r){let i=[],s=(a,l)=>{let c=t.filter(d=>{var u;return((u=d.data)==null?void 0:u.variant)===a}).map(d=>d.id);c.length>0&&i.push({id:l,message:l,nodeIds:c,edgeIds:[]})};return s("SUBPROCESS","cannot_validate_subprocess_reference"),s("SERVICE_TASK","service_task_automation_status_unavailable"),{isValid:!1,errors:i}}};import{jsx as pi,jsxs as dx}from"react/jsx-runtime";var Du=()=>{let{t:e}=ax(),{toast:t}=Pe(),{setNodes:o,setEdges:n,getNodes:r,getEdges:i}=lx(),{validateCustomDiagram:s}=U(),[a,l]=cx(!1),c=Ls(!1),d=Ls(!1),u=Ls(!1),p=$o(async f=>{let y=Pu(f.nodes,f.edges),T=Lu(y),b=f.nodes.filter(({type:v,data:N})=>v==="TASK"&&((N==null?void 0:N.variant)==="SUBPROCESS"||(N==null?void 0:N.variant)==="SERVICE_TASK"));if(s&&b.length>0){let v=await ku(s,b);T={isValid:T.isValid&&v.isValid,errors:[...T.errors,...v.errors]}}let I=T.errors.map(v=>w(_({},v),{message:e(`validation.errors.${v.id}`)}));return a||l(!0),{isValid:T.isValid,errors:I}},[a,e,s]),m=$o((f,y=!0)=>{if(y&&f){let V=f.isValid?e("validation.success.title"):e("validation.errors.title"),F=f.isValid?e("validation.success.message"):e("validation.errors.subtitle");t({variant:f.isValid?"success":"error",duration:5e3,title:V,content:dx("div",{className:"flex flex-col gap-2",children:[pi(Ru,{variant:"body-medium-400",textColor:"text-grey-950",children:F}),!f.isValid&&pi("ul",{className:"list-disc list-inside max-h-[600px] overflow-y-auto",children:f.errors.map(j=>pi("li",{children:pi(Ru,{variant:"body-medium-400",textColor:"text-grey-950",children:j.message})},j.id))})]})})}if(!f)return;c.current=!0,d.current=!0,u.current=!0;let T=[],b=[];f.errors.forEach(V=>{V.nodeIds&&V.nodeIds.length>0&&V.nodeIds.forEach(F=>T.push(F)),V.edgeIds&&V.edgeIds.length>0&&V.edgeIds.forEach(F=>b.push(F))});let I=[...new Set(T)],v=r(),N=i(),C=new Set(I),M=new Set;f.errors.forEach(V=>{var q,$;let F=kn.find(A=>A.id===V.id);(F==null?void 0:F.highlightRelatedEdges)!==!1&&((q=V.edgeIds)==null||q.forEach(A=>M.add(A)),($=V.nodeIds)==null||$.forEach(A=>{N.forEach(P=>{(P.source===A||P.target===A)&&M.add(P.id)})}))});let L=new Set,D=new Set,O=new Set;v.forEach(V=>{V.type==="START_EVENT"?L.add(V.id):V.type==="END_EVENT"&&D.add(V.id)}),N.forEach(V=>{L.has(V.source)&&O.add(V.target),D.has(V.target)&&O.add(V.source)}),O.forEach(V=>{var F,j;if(C.has(V)){let q=(F=f.errors.find(A=>{var P;return(P=A.nodeIds)==null?void 0:P.includes(V)}))==null?void 0:F.id;((j=kn.find(A=>A.id===q))==null?void 0:j.highlightRelatedEdges)!==!1&&N.forEach(A=>{A.source===V&&D.has(A.target)&&(C.add(A.target),M.add(A.id)),A.target===V&&L.has(A.source)&&(C.add(A.source),M.add(A.id))})}}),o(V=>V.map(F=>w(_({},F),{data:w(_({},F.data),{hasError:C.has(F.id)})}))),n(V=>V.map(F=>w(_({},F),{data:w(_({},F.data),{hasError:M.has(F.id)})}))),setTimeout(()=>{d.current=!1,c.current=!1},0)},[e,i,r,n,o,t]),x=$o(()=>{l(!1),u.current=!1,o(f=>f.map(y=>w(_({},y),{data:w(_({},y.data),{hasError:!1})}))),n(f=>f.map(y=>w(_({},y),{data:w(_({},y.data),{hasError:!1})})))},[n,o]),E=$o(()=>{u.current&&(d.current=!0,u.current=!1,o(f=>f.map(y=>w(_({},y),{data:w(_({},y.data),{hasError:!1})}))),n(f=>f.map(y=>w(_({},y),{data:w(_({},y.data),{hasError:!1})}))),setTimeout(()=>{d.current=!1},0))},[n,o]),g=$o(()=>d.current,[]),h=$o(()=>c.current,[]);return{validateDiagram:p,handleValidationComplete:m,clearValidation:x,dismissValidationPanel:E,isAutoValidationEnabled:a,getIsClearingValidation:g,getIsValidating:h}};import{useReactFlow as ux}from"@xyflow/react";import{useTranslation as px}from"@produto-lecom/lecom-ui";import{useEffect as fx}from"react";var mx=15,Ou="bpmn:selection",gx=e=>{if(!e||!(e instanceof HTMLElement))return!1;let t=e.tagName.toLowerCase(),o=t==="input"||t==="textarea",n=e.isContentEditable,r=t==="select",i=e.closest('[contenteditable="true"], input, textarea, select')!==null;return o||n||r||i},Vu=e=>{if(!gx(e.target))return!0;let t=window.getSelection(),o=t&&t.toString().length>0;if(e.target instanceof HTMLInputElement||e.target instanceof HTMLTextAreaElement){let n=e.target;return n.selectionStart===n.selectionEnd&&!o}return!o},Hu=({offset:e=mx,saveHistory:t})=>{let{t:o}=px(),{getNodes:n,setNodes:r,getEdges:i,setEdges:s}=ux(),{getNextId:a}=lt(),{mode:l,containerRef:c}=U();fx(()=>{if(l!=="edit")return;let d=c.current;if(!d)return;let u=m=>{var b,I;if(!Vu(m)||!d.contains(document.activeElement))return;let E=n(),g=i(),h=E.filter(v=>v.selected);if(!h.length)return;m.preventDefault(),m.stopPropagation();let f=g.filter(v=>h.some(N=>N.id===v.source)&&h.some(N=>N.id===v.target)),T=JSON.stringify({nodes:h,edges:f});(b=m.clipboardData)==null||b.setData(Ou,T),(I=m.clipboardData)==null||I.setData("text/plain",`BPMN Selection: ${h.length} nodes`)},p=m=>{var L,D;if(!Vu(m)||!d.contains(document.activeElement))return;let E=(L=m.clipboardData)==null?void 0:L.getData(Ou);if(!E)return;m.preventDefault(),m.stopPropagation();let g;try{g=JSON.parse(E)}catch(O){return}if(!((D=g.nodes)!=null&&D.length))return;let h=new Map,f=n(),y=[],T=g.nodes.filter(O=>So(O.type,f));if(T.length===0)return;let b=a(),I=T.map(O=>{var j;let V=String(b++);h.set(O.id,V);let F=w(_({},O),{id:V,selected:!0,position:{x:O.position.x+e,y:O.position.y+e}});if(O.type==="TASK"){let q=(j=O.data)==null?void 0:j.label,$=Xo(q||o("bpmn.task.label.prefix"),[...f,...y]);F.data=w(_({},O.data),{label:$})}return y.push(F),F}),v=g.edges.map(O=>w(_({},O),{id:String(b++),selected:!0,source:h.get(O.source)||O.source,target:h.get(O.target)||O.target})),N=[...f.map(O=>w(_({},O),{selected:!1})),...I],M=[...i().map(O=>w(_({},O),{selected:!1})),...v];r(N),s(M),t("forceSave",{nodes:N,edges:M})};return d.addEventListener("copy",u,!0),d.addEventListener("paste",p,!0),()=>{d.removeEventListener("copy",u,!0),d.removeEventListener("paste",p,!0)}},[n,r,i,s,a,e,o,t,l,c])};import{useTranslation as hx}from"@produto-lecom/lecom-ui";import{useReactFlow as yx}from"@xyflow/react";import{useCallback as fi,useRef as xx}from"react";var Gu=({nodes:e,setNodes:t})=>{let{t:o}=hx(),{toast:n}=Pe(),{getNodes:r}=yx(),{setIsRemovingElements:i,validateDeleteElements:s}=U(),a=xx(!1),l=fi(async p=>{try{let{activitiesWithInstances:m}=await s(p);if(m.length)return a.current=!1,i(!1),n({variant:"warning",content:o("editor.toolbar.delete_elements_blocked")}),!1}catch(m){return a.current=!1,i(!1),n({variant:"error",content:o("editor.toolbar.delete_elements_error")}),!1}return!0},[o,n,s,i]),c=fi(async({nodes:p})=>{if(a.current)return!1;if(a.current=!0,i(!0),p.some(E=>E.type==="LANE"&&e.some(g=>g.parentId===E.id)))return a.current=!1,i(!1),n({variant:"error",title:o("validation.errors.title"),content:o("editor.toolbar.delete_pool_lane_error")}),!1;let x=p.filter(E=>E.type==="TASK");if(s&&x.length>0){let E=x.map(g=>g.id);return l(E)}return!0},[e,o,n,s,l,i]),d=fi(p=>{a.current=!1,i(!1);let m=new Set(p.filter(x=>x.type==="LANE"&&!!x.parentId).map(x=>x.parentId));m.size!==0&&setTimeout(()=>{var g,h;let x=r(),E=new Map(x.map(f=>[f.id,f]));for(let f of m){let y=uo(x.filter(I=>I.type==="LANE"&&I.parentId===f));if(y.length===0)continue;let T=0;for(let I of y)E.set(I.id,w(_({},I),{position:{x:ie.HEADER_WIDTH,y:T}})),T+=(h=(g=I.measured)==null?void 0:g.height)!=null?h:0;let b=E.get(f);b&&E.set(f,w(_({},b),{height:T,measured:w(_({},b.measured),{height:T})}))}t(x.map(f=>{var y;return(y=E.get(f.id))!=null?y:f}))},0)},[r,t,i]),u=fi(()=>{a.current=!1,i(!1)},[i]);return{onBeforeDelete:c,onNodesDelete:d,onEdgesDelete:u}};import{useTranslation as Ex}from"@produto-lecom/lecom-ui";import{useReactFlow as _x}from"@xyflow/react";import{useRef as bx,useState as Tx}from"react";var vx=50,Bu=({nodes:e,setNodes:t,setEdges:o,saveHistory:n})=>{let{draggableNode:r,setDraggableNode:i}=Wo(),{t:s}=Ex(),{getInternalNode:a,getNodes:l,getEdges:c,screenToFlowPosition:d}=_x(),{getNextId:u}=lt(),{setIsDragging:p}=U(),{getInternalNodes:m}=oi(),{rebuildIndex:x,forceRebuildIndex:E}=Ir(),[g,h]=Tx(null),f=bx(""),y=(A,P,k)=>{var R;if(A.parentId!==P)return null;let S=k.filter(H=>H.id!==A.id&&H.parentId===P&&H.type==="LANE").sort((H,z)=>H.position.y-z.position.y);if(S.length===0)return null;let B=(R=k.find(H=>H.id===A.id))!=null?R:A,Y=S.find(H=>B.position.y<H.position.y);return Y?{draggedLaneId:A.id,beforeLaneId:Y.id}:{draggedLaneId:A.id,afterLaneId:S[S.length-1].id}},T=(A,P=!1,k)=>{let S=P?"node-drop-target-error":"node-drop-target",B=P?"node-drop-target-lane-error":"node-drop-target-lane";t(Y=>{var K,Z,W,X;let R=(K=k==null?void 0:k(Y))!=null?K:null,H=[A!=null?A:"",P?"error":"valid",(Z=R==null?void 0:R.draggedLaneId)!=null?Z:"",(W=R==null?void 0:R.beforeLaneId)!=null?W:"",(X=R==null?void 0:R.afterLaneId)!=null?X:""].join(":"),z=Q=>{let ee=[];return Q.id===A&&ee.push(S),A!==void 0&&Q.parentId===A&&Q.type==="LANE"&&Q.id!==(R==null?void 0:R.draggedLaneId)&&ee.push(B),Q.id===(R==null?void 0:R.draggedLaneId)&&ee.push("lane-reorder-dragging"),Q.id===(R==null?void 0:R.beforeLaneId)&&ee.push("lane-reorder-before"),Q.id===(R==null?void 0:R.afterLaneId)&&ee.push("lane-reorder-after"),ee.join(" ")||void 0};return f.current===H?Y:(f.current=H,Y.map(Q=>{let ee=z(Q);return Q.className===ee?Q:w(_({},Q),{className:ee})}))})},b=(A,P)=>{let k=m();if(A.type==="LANE"){if(P){T();return}let H=k.filter(Z=>Z.id!==A.id&&Z.type==="LANE"&&!Z.parentId),z=tn(A,H);if(!z){T();return}if(eo({parentId:z.id,nodes:e,excludeTypes:["LANE"]})){T(z.id,!0);return}T(z.id,!1,Z=>y(A,z.id,Z));return}let B=k.filter(H=>H.id!==A.id&&H.type==="LANE"),Y=tn(A,B);if(!Y){T();return}if(eo({parentId:Y.id,nodes:e,includeTypes:["LANE"]})){T();return}T(Y.id)},I=A=>{let P=a(A.id),k=A.type==="LANE"&&eo({parentId:A.id,nodes:e,includeTypes:["LANE"]});b(P,k)},v=A=>(f.current="",A.map(P=>w(_({},P),{className:void 0}))),N=A=>A.some(k=>k.dragging)?A.map(k=>k.dragging?w(_({},k),{dragging:!1}):k):A,C=(A,P)=>{let k=0;for(let S of P){if(S.id===A||S.parentId||S.type==="LANE")continue;let B=rt(S),Y=B.y+B.h;k=Math.max(k,Y)}return k+vx},M=(A,P)=>{if(!Wi(A,P))return P;let k=C(A,P);return P.map(S=>S.id===A?w(_({},S),{position:w(_({},S.position),{y:k})}):S)},L=A=>{if(A.preventDefault(),A.dataTransfer.dropEffect="move",!(r!=null&&r.type))return;let P=d({x:A.clientX,y:A.clientY}),k={id:"__sidebar_drag__",type:r.type,position:P,measured:{width:1,height:1},internals:{positionAbsolute:P}};b(k,!1)},D=A=>{let P=A.relatedTarget;(!P||!A.currentTarget.contains(P))&&T()},O=(A,P)=>{A.preventDefault(),I(P)},V=(A,P,k)=>{var K,Z;let S=[...k],B=P.parentId?P.parentId:P.id;if(A.parentId===P.id)return S=gs(A,P,S),S=St(S),S=co(B,S),v(S);if(A.type==="LANE"){if(eo({parentId:P.id,nodes:S,excludeTypes:["LANE"]})){let te=vr(P),fe=50,ue=50;return S.map(le=>{var ge,be;return le.id===A.id?w(_({},le),{position:{x:(ge=g==null?void 0:g.x)!=null?ge:te.x+fe,y:(be=g==null?void 0:g.y)!=null?be:te.y2+ue}}):le})}let Q=S.filter(te=>te.parentId===P.id).reduce((te,fe)=>{var ue,le;return te+((le=(ue=fe.measured)==null?void 0:ue.height)!=null?le:0)},0),ee={x:ie.HEADER_WIDTH,y:Q};return S=S.map(te=>te.id===A.id?w(_({},te),{parentId:P.id,position:ee,className:void 0}):w(_({},te),{className:void 0})),S=St(S),S=M(B,S),S}if(eo({parentId:P.id,nodes:S,includeTypes:["LANE"]})){let W;if(A.parentId){let X=a(A.parentId),{x:Q,y:ee}=rt(X);W={x:Q+((K=A.position.x)!=null?K:0),y:ee+((Z=A.position.y)!=null?Z:0)}}return S=S.map(X=>X.id===A.id?w(_({},X),{position:W!=null?W:X.position,parentId:void 0,className:void 0}):w(_({},X),{className:void 0})),S=co(B,S),S}let H=Ma(A,P);S=S.map(W=>W.id===A.id?w(_({},W),{parentId:P.id,position:H,className:void 0}):w(_({},W),{className:void 0}));let z=S.find(W=>W.id===A.id);return S=gs(z,P,S),S=St(S),S=co(B,S),S},F=A=>{if(A.preventDefault(),!(r!=null&&r.type))return;if(!So(r.type,l())){p(!1),i(null);return}let P=d({x:A.clientX,y:A.clientY}),k={width:de[r.type].MIN_WIDTH,height:de[r.type].MIN_HEIGHT},S=u(),B={id:String(S),type:r.type,position:P,measured:k,data:{label:r.type==="TASK"?ri(e,s("bpmn.task.label.prefix")):"",variant:r.variant,attribute:r.attribute},selected:!0},Y=w(_({},B),{internals:{positionAbsolute:P}}),R=w(_({},Y),{measured:{width:1,height:1}}),H=m(),z=r.type==="LANE",K=H.filter(te=>z?te.type==="LANE"&&!te.parentId:te.type==="LANE"),Z=tn(R,K),W=[...H.map(te=>w(_({},te),{selected:!1})),Y];Z&&(W=V(Y,Z,W)),W=jt(W),z&&!Z&&(W=M(Y.id,W)),W=v(W),t(W),E();let X=A.dataTransfer.getData("sourceId"),Q=c(),ee=Q;if(X){let te={id:String(S+1),source:X,target:B.id},fe=r.type==="ANNOTATION"?_(_({},te),Ro):_(_({},te),st);ee=Q.concat(fe),o(ee)}n("forceSave",{nodes:W,edges:ee}),p(!1),i(null)},j=async(A,P,k)=>{let S=[...m()],B=new Set;k.forEach(H=>{let z=a(H.id),K=H.type==="LANE",Z=S.filter(X=>X.id!==H.id&&(K?X.type==="LANE"&&!X.parentId:X.type==="LANE")),W=tn(z,Z);if(W){if(K&&eo({parentId:H.id,nodes:S,includeTypes:["LANE"]})){H.parentId&&(S=$(H,S),B.add(H.id));return}S=V(z,W,S);return}H.parentId&&(S=$(H,S),H.type==="LANE"&&B.add(H.id))}),S=N(S);let Y=k.filter(H=>H.type==="LANE"&&!H.parentId).map(H=>H.id);for(let H of Y)Wi(H,S)&&g&&(S=S.map(z=>z.id===H?w(_({},z),{position:_({},g)}):z));for(let H of B)S=M(H,S);if(k.some(H=>H.type!=="LANE"&&!H.parentId)){let H=S.filter(z=>z.type==="LANE"&&!z.parentId).map(z=>z.id);for(let z of H)S=co(z,S)}S=jt(S),S=v(S),t(S),x(S),h(null)},q=(A,P)=>{h({x:P.position.x,y:P.position.y})},$=(A,P)=>{var Z,W,X,Q,ee,te,fe,ue;let k=a(A.parentId);if(!k)return P;let S=A.type==="LANE",B=P.filter(le=>le.parentId===k.id&&le.id!==A.id),Y=B.filter(le=>le.type==="LANE"),R;if(S&&Y.length===0)R=ie.MIN_HEIGHT;else if(S){let le=(W=(Z=A.measured)==null?void 0:Z.height)!=null?W:ie.MIN_HEIGHT;R=((Q=(X=k.measured)==null?void 0:X.height)!=null?Q:ie.MIN_HEIGHT)-le,R=Math.max(ie.MIN_HEIGHT,R)}else R=B.length>0?B.reduce((le,ge)=>{var be,Re;return le+((Re=(be=ge.measured)==null?void 0:be.height)!=null?Re:0)},0)+xe:Math.max(ie.MIN_HEIGHT,(te=(ee=k.measured)==null?void 0:ee.height)!=null?te:0);let{x:H,y:z}=rt(k),K={x:H+((fe=A.position.x)!=null?fe:0),y:z+((ue=A.position.y)!=null?ue:0)};return P=P.map(le=>le.id===A.id?w(_({},le),{position:K,parentId:void 0}):le.id===k.id?w(_({},le),{height:R,measured:w(_({},le.measured),{height:R})}):le),P=St(P),P};return{onDragOver:L,onDragLeave:D,onDrop:F,onNodeDrag:O,onNodeDragStart:q,onNodeDragStop:j}};import{useReactFlow as Nx}from"@xyflow/react";import{useTranslation as wx}from"@produto-lecom/lecom-ui";import{useEffect as Ix}from"react";var Ax=30,Cx=e=>{if(!e||!(e instanceof HTMLElement))return!1;let t=e.tagName.toLowerCase(),o=t==="input"||t==="textarea",n=e.isContentEditable,r=t==="select",i=e.closest('[contenteditable="true"], input, textarea, select')!==null;return o||n||r||i},Sx=e=>!Cx(e.target),zu=({offset:e=Ax,saveHistory:t})=>{let{t:o}=wx(),{getNodes:n,setNodes:r,getEdges:i,setEdges:s}=Nx(),{getNextId:a}=lt(),{mode:l,containerRef:c}=U();Ix(()=>{if(l!=="edit")return;let d=c.current;if(!d)return;let u=p=>{if(d.contains(document.activeElement)&&p.ctrlKey&&p.key.toLowerCase()==="d"&&Sx(p)){p.preventDefault(),p.stopPropagation();let x=n(),E=i(),g=x.filter(M=>M.selected);if(!g.length)return;let h=new Map,f=[],y=g.filter(M=>So(M.type,x));if(y.length===0)return;let T=E.filter(M=>y.some(L=>L.id===M.source)&&y.some(L=>L.id===M.target)),b=a(),I=y.map(M=>{var O;let L=String(b++);h.set(M.id,L);let D=w(_({},M),{id:L,selected:!0,position:{x:M.position.x+e,y:M.position.y+e}});if(M.type==="TASK"){let V=(O=M.data)==null?void 0:O.label,F=Xo(V||o("bpmn.task.label.prefix"),[...x,...f]);D.data=w(_({},M.data),{label:F})}return f.push(D),D}),v=T.map(M=>w(_({},M),{id:String(b++),selected:!0,source:h.get(M.source)||M.source,target:h.get(M.target)||M.target})),N=[...x.map(M=>w(_({},M),{selected:!1})),...I],C=[...E.map(M=>w(_({},M),{selected:!1})),...v];r(N),s(C),t("forceSave",{nodes:N,edges:C})}};return d.addEventListener("keydown",u,!0),()=>{d.removeEventListener("keydown",u,!0)}},[n,r,i,s,a,e,o,t,l,c])};import{useEffect as Mx,useRef as Yu}from"react";import{useReactFlow as Px}from"@xyflow/react";var Lx=20,kx=50,Rn={UP:"ArrowUp",DOWN:"ArrowDown",LEFT:"ArrowLeft",RIGHT:"ArrowRight"},Rx=e=>{if(!e||!(e instanceof HTMLElement))return!1;let t=e.tagName.toLowerCase(),o=t==="input"||t==="textarea",n=e.isContentEditable,r=t==="select",i=e.closest('[contenteditable="true"], input, textarea, select')!==null;return o||n||r||i},Fu=e=>{let{getNodes:t}=Px(),{mode:o,isMoveTool:n}=U(),r=Yu(0),i=Yu(new Map);Mx(()=>{let s=a=>{if(o!=="edit"||!n||Rx(a.target)||!Object.values(Rn).includes(a.key))return;let u=t().filter(f=>f.selected);if(u.length===0){i.current.clear();return}a.preventDefault();let p=Date.now(),m=p-r.current<500;r.current=p;let x=a.shiftKey?kx:Lx,E=0,g=0;switch(a.key){case Rn.UP:g=-x;break;case Rn.DOWN:g=x;break;case Rn.LEFT:E=-x;break;case Rn.RIGHT:E=x;break}let h=u.map(f=>{let y=i.current.get(f.id);(!m||!y)&&(y={x:f.position.x,y:f.position.y});let T={x:y.x+E,y:y.y+g};return i.current.set(f.id,T),{id:f.id,dragging:!1,type:"position",position:T}});e&&e(h)};return window.addEventListener("keydown",s),()=>{window.removeEventListener("keydown",s)}},[t,e,o,n])};import{useReactFlow as Ox}from"@xyflow/react";var Xu={"start-event":"START_EVENT","end-event":"END_EVENT",task:"TASK","gateway-exclusive":"GATEWAY","gateway-parallel":"GATEWAY","gateway-complex":"GATEWAY"},Uu={"start-event":"","end-event":"",task:"","gateway-exclusive":"EXCLUSIVE","gateway-parallel":"PARALLEL","gateway-complex":"COMPLEX"},Wu=(e,t)=>{if(!e){console.warn("Step not found");return}e=e.trim();let o=e.match(/(\<.*?\>)/)||[],n=e.match(/(\[.*?\])/)||[],r=e.match(/(\{.*?\})/)||[],i=e.match(/(--.*|\|.*?\|)/i)||[],s="",a="",l="";if(o.length){switch(o[1]){case"<start>":s="start-event";break;case"<end>":s="end-event";break}e=e.replace(o[1],"")}return n.length&&(s="task",a=n[1].replace(/\[|\]/g,""),e=e.replace(n[1],"")),r.length&&(a=r[1].replace(/\{|\}/g,""),a.charAt(0)==="+"?(s="gateway-parallel",a=a.slice(1)):a.charAt(0)==="*"?(s="gateway-complex",a=a.slice(1)):s="gateway-exclusive",e=e.replace(r[1],"")),s||(s="task",a=e),i.length&&(l=i[1].replace(/(\||--)/g,""),e=e.replace(i[1],"")),e=e.trim(),t[e]||(t[e]={type:s,label:a}),{step:e,type:s,label:a,edgeLabel:l}},Dx=e=>{e=e||"";let t=e.trim().split(`
42
- `),o={},n=[];return t.forEach(r=>{r=r||"";let i=r.trim().split("-->");if(i.length!==2){console.warn("Invalid number of steps");return}let s=Wu(i[0],o),a=Wu(i[1],o);s&&a&&n.push({sourceId:s.step,targetId:a.step,label:s.edgeLabel||a.edgeLabel||""})}),{components:o,connections:n}},$u=e=>{let{components:t,connections:o}=Dx(e);return{nodes:t,edges:o}};var Vx=7,Hx=48,Gx=340,Bx=(e,t)=>{let o=Hx+e.length*Vx;return Math.min(Gx,Math.max(t,o))},mi=()=>{let{setNodes:e,setEdges:t}=Ox(),{fitToNodes:o}=qt(),{getNextId:n}=lt();return{importFromLia:i=>{let s=typeof i=="string"?i:i.diagramXml||"",{nodes:a,edges:l}=$u(s),c=[],d=new Map,u=!1,p=n();for(let[f,y]of Object.entries(a)){let T=String(p++),b=Xu[y.type],I=Uu[y.type];b==="START_EVENT"&&(u=!0),d.set(f,T);let v=de[b].MIN_WIDTH,N=de[b].MIN_HEIGHT;c.push({id:T,type:b,data:{label:y.label||"",variant:I,attribute:""},position:{x:0,y:0},width:v,height:N,measured:{width:v,height:N}})}let m=[];for(let f of l){let y=w(_({},st),{id:String(p++),source:d.get(f.sourceId)||f.sourceId,target:d.get(f.targetId)||f.targetId});m.push(y)}if(!u&&c.length>0){let f=String(p++),y={id:f,type:"START_EVENT",data:{label:"",variant:"",attribute:""},position:{x:0,y:0},width:de.START_EVENT.MIN_WIDTH,height:de.START_EVENT.MIN_HEIGHT,measured:{width:de.START_EVENT.MIN_WIDTH,height:de.START_EVENT.MIN_HEIGHT}};c.unshift(y);let T=c[1];if(T){let b=w(_({},st),{id:String(p++),source:f,target:T.id});m.unshift(b)}}let x=c.map(f=>{var y,T;return f.type==="TASK"?w(_({},f),{width:Bx(String((T=(y=f.data)==null?void 0:y.label)!=null?T:""),de.TASK.MIN_WIDTH)}):f}),{nodes:E}=jr(x,m),g=new Map(E.map(f=>[f.id,f.position])),h=c.map(f=>{var y;return w(_({},f),{position:(y=g.get(f.id))!=null?y:f.position})});e(h),t(m),o(h)}}};import{useCallback as zx,useEffect as Yx}from"react";var Fx={origin:"*",debug:!1};function gi(e,t=Fx){let{origin:o,debug:n}=t,r=zx((i,s)=>{let a={event:i,data:s};window.parent.postMessage(a,o||"*")},[o]);return Yx(()=>{if(!e)return;let i=s=>{let a=s.data;if(!(a!=null&&a.event)||(a==null?void 0:a.data)===void 0)return;let{event:l,data:c}=a,d;if(Array.isArray(c)){let[,u]=c;d=u.data}else d=c;n&&(console.debug("[postMessage] received:",a),console.debug("[postMessage] eventData:",d)),l&&e[l]&&e[l](d)};return window.addEventListener("message",i),()=>window.removeEventListener("message",i)},[e,n]),{sendMessage:r}}import{useNodesInitialized as Xx}from"@xyflow/react";import{useEffect as ks,useRef as Ux}from"react";var Ku=()=>{let e=Xx(),{initialDiagram:t,isNewDiagram:o,isInitialized:n,setIsInitialized:r,onElementChanges:i}=U(),{importFromMxGraph:s,exportToMxGraph:a}=Zt(),{sendMessage:l}=gi(),c=Ux(!1);ks(()=>{t&&s(t)},[t,s]),ks(()=>{if(!n||!o||c.current)return;c.current=!0;let d=a();i==null||i(d)},[n,o,t,a,i]),ks(()=>{if(!e)return;(async()=>{await Yn(),r(!0),l("INIT_MODELER",t)})()},[e,t,r,l])};import{useReactFlow as $x}from"@xyflow/react";import{useCallback as qu}from"react";function Zu(){let{setTaskStatuses:e,clearTaskStatuses:t,calculateFlowPath:o}=to(),{getEdges:n}=$x(),r=qu(s=>{if(!(s!=null&&s.activities))return;e(s.activities);let a=s.activities.map(c=>c.diagramId),l=n();o(l,a)},[e,o,n]),i=qu(()=>{t()},[t]);return{handleTasksStatus:r,handleClearTaskStatus:i}}import{useReactFlow as Kx}from"@xyflow/react";import{useCallback as Lt,useState as qx,useEffect as Ju}from"react";import{useDebouncedCallback as Zx}from"use-debounce";var Jx=500,Qu=100,ju=(e=!1)=>{let{getNodes:t,getEdges:o,setNodes:n,setEdges:r}=Kx(),{mode:i,containerRef:s}=U(),[a,l]=qx({history:[],currentStep:0}),{history:c,currentStep:d}=a,u=d>0,p=d<c.length-1,m=Lt((v,N)=>{n(v[N].nodes),r(v[N].edges)},[n,r]),x=Lt(()=>{if(d>0){let v=d-1;l(N=>w(_({},N),{currentStep:v})),m(c,v)}},[d,c,m]),E=Lt(()=>{if(d<c.length-1){let v=d+1;l(N=>w(_({},N),{currentStep:v})),m(c,v)}},[c,d,m]),g=Lt(v=>{l(N=>{let C=N.history[N.currentStep];if(C&&JSON.stringify(C)===JSON.stringify(v))return N;let D=[...N.history.slice(0,N.currentStep+1),v],O=D.length>Qu?D.slice(D.length-Qu):D;return{history:O,currentStep:O.length-1}})},[]),h=Lt((v,N)=>{let C=v.map(L=>w(_({},L),{selected:!1,className:"",data:w(_({},L.data),{hasError:!1})})),M=N.map(L=>w(_({},L),{data:w(_({},L.data),{hasError:!1})}));return{nodes:jt(C),edges:M}},[]),f=Lt(()=>h(t(),o()),[t,o,h]),y=Zx(()=>{let v=f();g(v)},Jx),T=Lt((v,N)=>{if(!e)return;if(c.length===0){let M=f();l({history:[M],currentStep:0})}if(v==="forceSave"){if(N){g(h(N.nodes,N.edges));return}y();return}v.some(M=>M.type==="select")||Kn(v)||y()},[e,y,c.length,f,g,h]);Ju(()=>{if(e&&c.length===0){let v=f();l({history:[v],currentStep:0})}},[e,c.length,f]);let b=Lt(v=>{l({history:v||[],currentStep:0})},[]),I=Lt(()=>{l({history:[],currentStep:0})},[]);return Ju(()=>{if(i!=="edit")return;let v=s.current;if(!v)return;let N=C=>{if(!v.contains(document.activeElement)||!(C.ctrlKey||C.metaKey))return;let D=C.key.toLowerCase();if(C.shiftKey&&D==="z"){C.preventDefault(),E();return}D==="z"&&(C.preventDefault(),x())};return v.addEventListener("keydown",N),()=>{v.removeEventListener("keydown",N)}},[x,E,i,s]),{history:c,undo:x,redo:E,canUndo:u,canRedo:p,saveHistory:T,resetHistory:b,clearHistory:I}};var ep=()=>{let[e,t,o]=jx([]),[n,r,i]=Qx([]),{getNode:s}=eE(),a=tE(),{instanceId:l,isInitialized:c,setIsConnecting:d,onElementClick:u}=U(),{updateHelperLines:p,HelperLines:m}=Ir(),{undo:x,redo:E,canUndo:g,canRedo:h,saveHistory:f}=ju(c),{onNodeDrag:y,onDrop:T,onDragOver:b,onDragLeave:I,onNodeDragStop:v,onNodeDragStart:N}=Bu({nodes:e,setNodes:t,setEdges:r,saveHistory:f}),{isValidConnection:C,onConnect:M,onReconnect:L,onReconnectStart:D,onReconnectEnd:O,setReconnectingEdge:V,clearReconnectingEdge:F}=wu({setEdges:r,saveHistory:f}),{handleValidationComplete:j,clearValidation:q,dismissValidationPanel:$,validateDiagram:A,getIsValidating:P,getIsClearingValidation:k}=Du(),{importFromLia:S}=mi(),{handleTasksStatus:B,handleClearTaskStatus:Y}=Zu(),{clearPathEdges:R}=to(),{emitElementChanges:H,handleNodeChanges:z,handleEdgeChanges:K}=di(),Z=Ra();Hu({saveHistory:f}),zu({saveHistory:f}),Ku();let W=ho(()=>{t([]),r([]),R(),setTimeout(Z,0)},[t,r,R,Z]),{selectElements:X,clearSelection:Q}=yt(),{importFromMxGraph:ee,exportToMxGraph:te}=Zt(),{configureElement:fe,getConfigureElement:ue}=Rr(),le=ho(ye=>{ye!=null&&ye.id&&X([ye.id])},[X]),{sendMessage:ge}=gi({LIA_CREATE_DIAGRAM:S,CLEAR_DIAGRAM:W,TASKS_STATUS:B,CLEAR_TASKS_STATUS:Y,EXTERNAL_TASK_SELECT:le}),be=ho(()=>e.length+n.length,[e,n]);oE(()=>(bt.set(l,{importFromMxGraph:ee,exportToMxGraph:te,selectElements:X,clearSelection:Q,configureElement:fe,getConfigureElement:ue,getElementsCount:be,setReconnectingEdge:V,clearReconnectingEdge:F}),()=>{bt.delete(l)}),[l,ee,te,X,Q,fe,ue,be,V,F]);let Re=ho((ye,Ie)=>{if(Ie.type!=="TASK"&&Ie.type!=="GATEWAY")return;let qe=ue(Ie.id);qe&&(u==null||u(qe)),Ie.type==="TASK"&&ge("SELECT_TASK",{id:Ie.id})},[ue,u,ge]),J=ho((ye,Ie)=>{if(Ie.type!=="SEQUENCE_EDGE")return;let qe=s(Ie.source),Ze=s(Ie.target),{isFromStartEvent:ut,isGatewayToGateway:We,isActiviyToAndGateway:Te,isToEndEvent:De}=$n(qe,Ze);if(!(!ut&&!We&&!Te&&!De))return;let mt=ue(Ie.id);mt&&(u==null||u(mt))},[ue,s,u]),se=ho(ye=>{p(ye,e),o(ye),!Kn(ye)&&(f(ye),k()||$(),P()||z(ye))},[e,f,k,$,p,z,P,o]),oe=ho(ye=>{i(ye),f(ye),k()||$(),P()||K(ye)},[i,f,k,$,K,P]);Fu(se);let{onBeforeDelete:ae,onNodesDelete:he,onEdgesDelete:Ne}=Gu({nodes:e,setNodes:t});return{nodes:e,setNodes:t,edges:n,setEdges:r,events:{isValidConnection:C,onConnect:M,onReconnect:L,onReconnectStart:D,onReconnectEnd:O,onDrop:T,onDragOver:b,onDragLeave:I,onNodeDrag:y,onNodeDragStop:v,onNodeDragStart:N,onNodeClick:Re,onEdgeClick:J,onDropCapture:()=>{f("forceSave"),H(),$()},onConnectStart:()=>{d(!0)},onConnectEnd:()=>{d(!1),$()},onSelectionEnd:()=>setTimeout(()=>a.setState({nodesSelectionActive:!1}),0),onNodesChange:se,onEdgesChange:oe,onBeforeDelete:ae,onNodesDelete:he,onEdgesDelete:Ne},ui:{handleCloseValidationPanel:q},controls:{undo:x,redo:E,canUndo:g,canRedo:h},components:{HelperLines:m},actions:{saveHistory:f,selectElements:X,clearSelection:Q,exportToMxGraph:te,validateDiagram:A,handleValidationComplete:j,setReconnectingEdge:V,clearReconnectingEdge:F}}};import{useCallback as nE}from"react";import{useStore as rE}from"@xyflow/react";function hi(){return rE(nE(e=>e.nodes.length+e.edges.length>0,[]))}import{useReactFlow as iE}from"@xyflow/react";import{useCallback as sE,useEffect as aE,useRef as lE,useState as cE}from"react";var dE=".react-flow__node, .react-flow__edge, .react-flow__node-toolbar";function tp(e,t,o){let[n,r]=cE(!1),i=lE(null),{getViewport:s,setViewport:a}=iE(),l=sE(()=>{i.current=null,r(!1)},[]);return aE(()=>{let c=e.current;if(!c)return;let d=m=>{if(!Mn.some(E=>E===m.button)||t.current||o.current||(r(!0),!(m.target instanceof Element))||!m.target.closest(dE))return;m.preventDefault(),m.stopPropagation();let x=s();i.current={pointerX:m.clientX,pointerY:m.clientY,viewportX:x.x,viewportY:x.y,zoom:x.zoom}},u=m=>{let x=i.current;if(x){if((m.buttons&Ps)===0){l();return}a({x:x.viewportX+(m.clientX-x.pointerX),y:x.viewportY+(m.clientY-x.pointerY),zoom:x.zoom})}},p=m=>{(m.buttons&Ps)===0&&l()};return c.addEventListener("pointerdown",d,!0),window.addEventListener("pointermove",u),window.addEventListener("pointerup",p),window.addEventListener("pointercancel",l),window.addEventListener("blur",l),()=>{c.removeEventListener("pointerdown",d,!0),window.removeEventListener("pointermove",u),window.removeEventListener("pointerup",p),window.removeEventListener("pointercancel",l),window.removeEventListener("blur",l)}},[e,t,o,s,a,l]),n}import{jsx as op}from"react/jsx-runtime";var yi=({id:e,className:t})=>op("marker",{id:e,className:G("react-flow__arrowhead",t),viewBox:"0 0 10 10",refX:"9",refY:"5",markerWidth:"7",markerHeight:"7",orient:"auto",markerUnits:"userSpaceOnUse",fill:"currentColor",stroke:"currentColor",children:op("path",{d:"M 0 0 L 10 5 L 0 10 Z"})});import{jsx as xi,jsxs as uE}from"react/jsx-runtime";var np=()=>xi("svg",{style:{position:"absolute",top:0,left:0},children:uE("defs",{children:[xi(yi,{id:"sequence-edge-marker",className:"text-grey-500"}),xi(yi,{id:"sequence-edge-marker-hovered",className:"text-grey-800"}),xi(yi,{id:"sequence-edge-marker-highlighted",className:"text-blue-500"})]})});import{Tooltip as hb,TooltipContent as yb,TooltipTrigger as xb,useTranslation as Eb}from"@produto-lecom/lecom-ui";import{useKeyPress as Pp,useReactFlow as D_}from"@xyflow/react";import{Button as wi,Tooltip as Ii,TooltipContent as Ai,TooltipTrigger as Ci,useTranslation as O_}from"@produto-lecom/lecom-ui";import{HandIcon as V_,ListCheckIcon as H_,Loader2Icon as G_,MapIcon as B_,MousePointerIcon as z_}from"lucide-react";import Y_,{useCallback as Us,useEffect as Lp,useState as F_}from"react";import{Tooltip as PE,TooltipContent as LE,TooltipTrigger as kE,useTranslation as RE}from"@produto-lecom/lecom-ui";var Dn=(y=>(y.START_EVENT="START_EVENT",y.END_EVENT="END_EVENT",y.TASK="TASK",y.SUBPROCESS="SUBPROCESS",y.GATEWAY="GATEWAY",y.LANE="LANE",y.ANNOTATION="ANNOTATION",y.CONNECTION="CONNECTION",y.INTERMEDIATE_EVENT="INTERMEDIATE_EVENT",y.ACTIVITY="ACTIVITY",y.PROCESS_INTERFACE="PROCESS_INTERFACE",y.WORKFLOW_INTERFACE="WORKFLOW_INTERFACE",y.VARIANT_ACTIVITY="VARIANT_ACTIVITY",y.AUTO_ACTIVITY="AUTO_ACTIVITY",y.DATA_STORE="DATA_STORE",y.DATA_OBJECT="DATA_OBJECT",y.DATA_OUTPUT="DATA_OUTPUT",y.DATA_INPUT="DATA_INPUT",y.MARKER="MARKER",y))(Dn||{});import{Button as vE,useTranslation as NE}from"@produto-lecom/lecom-ui";import{useReactFlow as wE}from"@xyflow/react";var Ei=async e=>new Promise((t,o)=>{let n=new FileReader;n.onload=r=>{var i;t((i=r.target)==null?void 0:i.result)},n.onerror=r=>{var i;o((i=r.target)==null?void 0:i.error)},n.readAsText(e)});function rp({columns:e=[],rows:t=[],fileName:o="report"}){if(!e.length||!t.length)return;let r="data:text/csv;charset=utf-8,"+[e,...t].map(s=>s.join(",")).join(`
43
- `),i=encodeURI(r);_i(i,`${o}.csv`)}var _i=(e,t)=>{let o=document.createElement("a");o.setAttribute("download",t),o.setAttribute("href",e),document.body.appendChild(o),o.click(),document.body.removeChild(o)};function ip(e){return e==null?void 0:e.replaceAll("&#xA;"," ")}var WO={START_EVENT:"START_EVENT",END_EVENT:"END_EVENT",TASK:"TASK",GATEWAY:"GATEWAY",ANNOTATION:"ANNOTATION"},sp={script:"SCRIPT",subprocess:"SUBPROCESS"},ap={"marker-loop":"LOOP"},lp={complex:"COMPLEX",none:"EXCLUSIVE",exclusive:"EXCLUSIVE",parallel:"PARALLEL",inclusive:"EXCLUSIVE"};var yo=({cell:e,type:t,variant:o="",attribute:n=""})=>{let{_attributes:r,mxGeometry:i}=e,{value:s,parent:a}=r,l=Number(i._attributes.width),c=Number(i._attributes.height),d=a==="1"?void 0:a;return{id:r.id,parentId:d,type:t,data:{label:s||"",variant:o,attribute:n},position:{x:Number(i._attributes.x)||0,y:Number(i._attributes.y)||0},width:l,height:c,measured:{width:l,height:c}}},fE=e=>{let{subType:t,style:o}=e._attributes,n="imported";return["none"].includes(t)||(n="adapted"),e.mxGeometry._attributes.width=de.START_EVENT.MIN_WIDTH,e.mxGeometry._attributes.height=de.START_EVENT.MIN_HEIGHT,{node:yo({cell:e,type:"START_EVENT"}),status:n,originalType:o}},mE=e=>{let{subType:t,style:o}=e==null?void 0:e._attributes,n="imported";return["none"].includes(t)||(n="adapted"),e.mxGeometry._attributes.width=de.END_EVENT.MIN_WIDTH,e.mxGeometry._attributes.height=de.END_EVENT.MIN_HEIGHT,{node:yo({cell:e,type:"END_EVENT"}),status:n,originalType:o}},gE=(e,t)=>{let{id:o,subType:n,style:r}=e==null?void 0:e._attributes,i=sp[n],s=t.get(o)||"",a=ap[s]||"",l=a==="LOOP",c="imported";return!["script","none"].includes(n)&&!l&&(c="adapted"),e.mxGeometry._attributes.width=Rt(e.mxGeometry._attributes.width||0,de.TASK.MIN_WIDTH),e.mxGeometry._attributes.height=Rt(e.mxGeometry._attributes.height||0,de.TASK.MIN_HEIGHT),{node:yo({cell:e,type:"TASK",variant:i,attribute:a}),status:c,originalType:r}},hE=e=>{let{style:t,subType:o}=e==null?void 0:e._attributes,n=lp[o],r=["none","inclusive","event-based"],i="imported";return r.includes(o)&&(i="adapted"),e.mxGeometry._attributes.width=de.GATEWAY.MIN_WIDTH,e.mxGeometry._attributes.height=de.GATEWAY.MIN_HEIGHT,{node:yo({cell:e,type:"GATEWAY",variant:n}),status:i,originalType:t}},yE=e=>{let{style:t}=e==null?void 0:e._attributes;return{node:yo({cell:e,type:"LANE"}),status:"imported",originalType:t}},xE=e=>{let{style:t}=e==null?void 0:e._attributes;return e.mxGeometry._attributes.width=Rt(e.mxGeometry._attributes.width||0,de.ANNOTATION.MIN_WIDTH),e.mxGeometry._attributes.height=Rt(e.mxGeometry._attributes.height||0,de.ANNOTATION.MIN_HEIGHT),{node:yo({cell:e,type:"ANNOTATION"}),status:"imported",originalType:t}},cp=e=>{let{style:t}=e==null?void 0:e._attributes;return e.mxGeometry._attributes.width=de.UNSUPPORTED.MIN_WIDTH,e.mxGeometry._attributes.height=de.UNSUPPORTED.MIN_HEIGHT,{node:yo({cell:e,type:"UNSUPPORTED"}),status:"unsupported",originalType:t}},dp=(e,t)=>{let{id:o,source:n,target:r,value:i}=e._attributes;return w(_({},st),{id:o,source:t.get(n)||n,target:t.get(r)||r,data:{label:i||""}})},up={TASK:gE,GATEWAY:hE,START_EVENT:fE,END_EVENT:mE,LANE:yE,ANNOTATION:xE};var EE=e=>{let t=new Map,o=Object.values(Dn),n=[],r=new Map;e.forEach(a=>{var c;let l=(c=a._attributes)==null?void 0:c.type;if(l==="MARKER"){r.set(a._attributes.parent,a._attributes.style);return}if(o.includes(l)){n.push(a);return}});let i=[],s=[];for(let a of n){let{type:l}=a._attributes,c=up[l]||cp,{node:d,status:u,originalType:p}=c(a,r);s.push(d),i.push({originalType:p,type:d.type,variant:d.data.variant,value:ip(d.data.label),status:u})}return{nodes:s,governanceIdToNodeIdMap:t,summary:i}},_E=(e,t)=>e.filter(r=>{var i;return(i=r._attributes)==null?void 0:i.edge}).map(r=>dp(r,t)),bE=e=>{let{mxGraphModel:t}=e,{nodes:o,governanceIdToNodeIdMap:n,summary:r}=EE(t.root.mxCell),i=_E(t.root.mxCell,n);return{nodes:o,edges:i,summary:r}},TE=async e=>{let t=await Ei(e),o=ei(t);if(!o)throw new Error("EMPTY_FILE");let{metadata:n,mxGraphModel:r}=o.modeler||{},i=(n==null?void 0:n.app)&&(n==null?void 0:n.diagramType)&&(n==null?void 0:n.version),s=r==null?void 0:r.root;if(!i||!s)throw new Error("INVALID_FILE");if(!Object.keys(r.root.mxCell||{}).length)throw new Error("CONTAIN_NO_CELLS");return{metadata:n,mxGraphModel:r}},pp=async e=>{try{let t=await TE(e),{nodes:o,edges:n,summary:r}=bE(t)||{};return{nodes:o,edges:n,summary:r}}catch(t){throw t}};import{jsx as IE}from"react/jsx-runtime";var fp=()=>{let{t:e}=NE(),{toast:t}=Pe(),{setNodes:o,setEdges:n}=wE(),{fitToNodes:r}=qt(),i=a=>{let l=[e("adapter.governance.report.columns.type"),e("adapter.governance.report.columns.value"),e("adapter.governance.report.columns.status")],c=a.map(d=>[d.originalType,d.value,e(`adapter.governance.report.status.${d.status.toLowerCase()}`)]);t({variant:"warning",content:e("adapter.governance.success.incompatible_cells"),duration:1e3*60*1,action:IE(vE,{size:"small",variant:"ghost",onClick:()=>rp({columns:l,rows:c,fileName:"governance-imported-cells"}),children:e("adapter.governance.action.download")})})};return{importFromGovernance:async a=>{try{let{nodes:l,edges:c,summary:d}=await pp(a);if(o(p=>p.concat(l)),n(p=>p.concat(c)),r(l),d.some(p=>p.status==="unsupported")){i(d);return}t({variant:"success",content:e("adapter.governance.success.default")})}catch(l){let c=l instanceof Error?l.message:"DEFAULT";t({variant:"error",content:e(`adapter.governance.error.${c}`)})}}}};import{Button as AE}from"@produto-lecom/lecom-ui";import{useRef as CE}from"react";import{Fragment as SE,jsx as mp,jsxs as ME}from"react/jsx-runtime";var gp=a=>{var l=a,{children:e,accept:t="*",multiple:o=!1,disabled:n=!1,onClick:r,onFilesSelected:i}=l,s=gt(l,["children","accept","multiple","disabled","onClick","onFilesSelected"]);let c=CE(null),d=p=>{let m=p.target.files;m!=null&&m.length&&i(m),c.current&&(c.current.value="")};return ME(SE,{children:[mp(AE,w(_({disabled:n,onClick:p=>{var m;(m=c.current)==null||m.click(),r==null||r(p)}},s),{children:e})),mp("input",{type:"file",ref:c,className:"sr-only",accept:t,multiple:o,disabled:n,onChange:d})]})};import{jsx as bi,jsxs as DE}from"react/jsx-runtime";var hp=({disabled:e=!1})=>{let{t}=RE(),{toast:o}=Pe(),{importFromGovernance:n}=fp(),r=()=>{if(e){o({variant:"error",content:t("adapter.governance.error.ALREADY_INITIALIZED")});return}},i=s=>{let a=s[0];if(!a){o({variant:"error",content:t("adapter.governance.error.NO_FILE")});return}n(a)};return DE(PE,{children:[bi(kE,{asChild:!0,children:bi(gp,{className:"[&>svg]:size-7 p-0",variant:"ghost",size:"small",color:"grey",iconButton:!0,accept:".mdr",disabled:e,onClick:r,onFilesSelected:i,children:bi(xa,{})})}),bi(LE,{color:"black",children:t(e?"adapter.governance.error.ALREADY_INITIALIZED":"editor.controls.actions.import_governance")})]})};import{jsx as OE}from"react/jsx-runtime";var Rs=({shortcut:e})=>OE("span",{className:"min-h-7.5 inline-flex justify-center items-center py-0.5 px-1.5 bg-grey-100 border border-grey-300 font-mono text-gray-800 shadow-lg rounded-md text-grey-900",children:e});import{Button as KE,DropdownMenu as qE,DropdownMenuContent as ZE,DropdownMenuItem as Hs,DropdownMenuTrigger as JE,Tooltip as Ti,TooltipContent as vi,TooltipTrigger as Ni,useTranslation as QE}from"@produto-lecom/lecom-ui";import{FileCodeIcon as jE,FileImageIcon as e_,FolderOutputIcon as t_,PrinterIcon as o_}from"lucide-react";import{useState as n_}from"react";import{useTranslation as HE}from"@produto-lecom/lecom-ui";import{useReactFlow as GE}from"@xyflow/react";import{toPng as xp,toSvg as BE}from"html-to-image";import{useState as zE}from"react";import{getNodesBounds as VE}from"@xyflow/react";var yp=(e,t=0)=>{let o=VE(e),n=document.querySelectorAll(".react-flow__edge-path"),r=o.x,i=o.y,s=o.x+o.width,a=o.y+o.height;return n.forEach(l=>{let c=l.getBBox();r=Math.min(r,c.x),i=Math.min(i,c.y),s=Math.max(s,c.x+c.width),a=Math.max(a,c.y+c.height)}),{x:r,y:i,width:s-r+t*2,height:a-i+t*2}};var YE=3,Ds="diagram",Os=50,FE=e=>e instanceof Element&&e.closest("[data-export-hidden]")!==null,Vs=e=>!FE(e),WE=96,XE=25.4,UE="sequence-edge-marker",Ep=e=>e*XE/WE,$E=e=>{let t=document.getElementById(UE);if(!(t instanceof SVGElement)||!t.ownerSVGElement)return null;let n=t.ownerSVGElement.cloneNode(!0);return n.style.position="absolute",n.style.width="0",n.style.height="0",n.style.overflow="hidden",n.setAttribute("aria-hidden","true"),n.setAttribute("data-export-marker-defs","true"),e.prepend(n),n},_p=()=>{let{t:e}=HE(),{toast:t}=Pe(),{getEdges:o,getNodes:n}=GE(),{clearSelection:r}=yt(),{setIsExporting:i}=U(),[s,a]=zE({png:!1,html:!1,print:!1}),l=()=>{let{x:m,y:x,width:E,height:g}=yp(n(),Os),h=Os-m,f=Os-x;return{width:E,height:g,style:{width:`${E}px`,height:`${g}px`,transform:`translate(${h}px, ${f}px)`,transformOrigin:"top left"}}},c=async(m,x)=>{a(E=>w(_({},E),{[x]:!0})),i(!0),await r();try{let E=n(),g=o();if(E.length===0&&g.length===0){t({content:e("editor.controls.actions.export.feedback.empty"),variant:"warning"});return}let h=ud();if(!h)throw new Error("Flow element not found");let f=l(),y=$E(h);try{return await m(h,f)}finally{y==null||y.remove()}}catch(E){console.error("Diagram export failed",E),t({content:e("editor.controls.actions.export.feedback.error"),variant:"error"})}finally{i(!1),a(E=>w(_({},E),{[x]:!1}))}};return{exportAsPng:async(m=Ds)=>{await c(async(x,E)=>{let g=await xp(x,w(_({},E),{backgroundColor:"#fcfcfc",skipFonts:!0,filter:Vs}));_i(g,`${m}.png`)},"png")},exportAsHtml:async(m=Ds)=>{await c(async(x,E)=>{let g=await BE(x,w(_({},E),{backgroundColor:"#fcfcfc",skipFonts:!0,filter:Vs})),h=`
34
+ </mxGraphModel>`,Lc=(e,t)=>{if(!e.length&&!t.length)return Zo;let o=[...e.map(r=>r.id),...t.map(r=>r.id)];return Math.max(...o.map(r=>Number(r)))};import{xml2json as Qg,json2xml as jg}from"xml-js";var Dc={compact:!0,spaces:4},eh=e=>e.replace(/\n/g,"&#xA;");function xr(e,t=Dc){if(e)return JSON.parse(Qg(e,t))}function kc(e,t=Dc){return e?jg(e,I(T({},t),{attributeValueFn:eh})):""}var Ui=e=>({x:Number(e._attributes.x),y:Number(e._attributes.y)}),Rc=e=>{var t;if(e){if(!Array.isArray(e)&&"mxPoint"in e&&e.mxPoint)return{points:(Array.isArray(e.mxPoint)?e.mxPoint:[e.mxPoint]).map(Ui),space:"parent"};if(Array.isArray(e))return{points:e.map(Ui),space:"absolute"};if("_attributes"in e&&((t=e._attributes)==null?void 0:t.as)==="mxPoint")return{points:[Ui(e)],space:"absolute"}}};var Oc={"attribute-loop":"LOOP"},Vc={"task-script":"SCRIPT","subprocess-collapsed":"SUBPROCESS","service-task":"SERVICE_TASK"},Hc={"gateway-exclusive":"EXCLUSIVE","gateway-parallel":"PARALLEL","gateway-complex":"COMPLEX"},Gc={SCRIPT:"task-script",SUBPROCESS:"subprocess-collapsed",SERVICE_TASK:"service-task"},Bc={EXCLUSIVE:"gateway-exclusive",PARALLEL:"gateway-parallel",COMPLEX:"gateway-complex"};var so=(e,t,o,n,r,i)=>{let s=e._attributes.width||0,a=e._attributes.height||0,l=0,c=0;if(n&&r!==void 0&&i!==void 0){let x=n.split(`
35
+ `),E=x.length;l=x.reduce((h,g)=>Math.max(h,g.length),0)*7+r,c=E*20+i}let d=Math.max(pt(Number(s),t),l),u=Math.max(pt(Number(a),o),c);return{width:d,height:u,measured:{width:d,height:u}}},ao=e=>{let{_attributes:t,mxGeometry:o}=e,{id:n,parent:r,value:i}=t,s={x:Number(o._attributes.x||0),y:Number(o._attributes.y||0)},a={id:n,position:s,className:void 0,data:{label:i||""}},l=r==="1"?void 0:r;return l&&(a.parentId=l),a},oh=e=>{let{mxGeometry:t}=e,o=ao(e),n=so(t,ee.START_EVENT.MIN_WIDTH,ee.START_EVENT.MIN_HEIGHT);return I(T(T({},o),n),{type:"START_EVENT"})},nh=e=>{let{mxGeometry:t}=e,o=ao(e),n=so(t,ee.END_EVENT.MIN_WIDTH,ee.END_EVENT.MIN_HEIGHT);return I(T(T({},o),n),{type:"END_EVENT"})},Er=(e,t)=>{let{_attributes:o,mxGeometry:n}=e,r=ao(e),a=so(n,ee.TASK.MIN_WIDTH,ee.TASK.MIN_HEIGHT,r.data.label,48,24),l=t==null?void 0:t.find(d=>{let{parent:u}=d._attributes;return u===e._attributes.id});if(l){let{style:d}=l._attributes,u=Oc[d];u&&(r.data.attribute=u)}let c=Vc[o.style];return c&&(r.data.variant=c),I(T(T({},r),a),{type:"TASK"})},$i=e=>{let{_attributes:t,mxGeometry:o}=e,{style:n}=t,r=ao(e),i=so(o,ee.GATEWAY.MIN_WIDTH,ee.GATEWAY.MIN_HEIGHT);return r.data.variant=Hc[n],I(T(T({},r),i),{type:"GATEWAY"})},rh=e=>{let{mxGeometry:t}=e,o=ao(e),i=so(t,ee.ANNOTATION.MIN_WIDTH,ee.ANNOTATION.MIN_HEIGHT,o.data.label,32,24);return I(T(T({},o),i),{type:"ANNOTATION"})},ih=e=>{let{mxGeometry:t}=e,o=ao(e),n=so(t,ee.LANE.MIN_WIDTH,ee.LANE.MIN_HEIGHT);return I(T(T({},o),n),{type:"LANE"})},zc={task:Er,"task-script":Er,"subprocess-collapsed":Er,"service-task":Er,"start-event":oh,"end-event-terminate":nh,"gateway-parallel":$i,"gateway-exclusive":$i,"gateway-complex":$i,annotation:rh,lane:ih},Fc=(e,t)=>{let{_attributes:o,mxGeometry:n}=e,{id:r,source:i,target:s,value:a,style:l,parent:c,labelOffsetX:d,labelOffsetY:u}=o,p=Rc(n==null?void 0:n.Array),f;if(p!=null&&p.points.length){let[h]=p.points;if(p.space==="parent"){let g=wt(c==="1"?void 0:c,t!=null?t:[]);f={x:h.x+g.x,y:h.y+g.y}}else f=h}let x=d!==void 0?Number(d):void 0,E=u!==void 0?Number(u):void 0,m={id:r,source:i,target:s,data:T(T({label:a||""},f?{controlPoint:f}:{}),x!==void 0&&E!==void 0?{labelOffset:{x,y:E}}:{})};return l.includes("association")&&l.includes('endArrow=""')?T(T({},ro),m):T(T({},Ve),m)},Yc=(e,t)=>{let{id:o,type:n,source:r,target:i,data:s}=e,a=t==null?void 0:t.find(E=>E.id===r),l=t==null?void 0:t.find(E=>E.id===i),c="";n==="ANNOTATION_EDGE"&&(c='association;endArrow=""');let d=a!=null&&a.parentId&&a.parentId===(l==null?void 0:l.parentId)?a.parentId:"1",u={_attributes:{as:"geometry",relative:"1"}},p=s==null?void 0:s.controlPoint;if(p){let E=wt(d==="1"?void 0:d,t!=null?t:[]);u.Array={_attributes:{as:"points"},mxPoint:[{_attributes:{x:p.x-E.x,y:p.y-E.y}}]}}let f=s==null?void 0:s.labelOffset;return{_attributes:{id:o,parent:d,edge:"1",style:c,source:r,target:i,value:(s==null?void 0:s.label)||"",labelOffsetX:f?String(f.x):void 0,labelOffsetY:f?String(f.y):void 0},mxGeometry:u}},lo=e=>{let{id:t,parentId:o,position:n,measured:r,data:i}=e;return{_attributes:{id:t,parent:o||"1",value:i.label,vertex:"1"},mxGeometry:{_attributes:{as:"geometry",width:(r==null?void 0:r.width)||0,height:(r==null?void 0:r.height)||0,x:n.x||0,y:n.y||0}}}},sh=e=>{let{variant:t}=e.data,o=lo(e);return I(T({},o),{_attributes:I(T({},o._attributes),{style:Gc[t]||"task"})})},ah=e=>{let t=lo(e);return I(T({},t),{_attributes:I(T({},t._attributes),{style:"start-event"})})},lh=e=>{let t=lo(e);return I(T({},t),{_attributes:I(T({},t._attributes),{style:"end-event-terminate"})})},ch=e=>{let{variant:t}=e.data,o=lo(e);return I(T({},o),{_attributes:I(T({},o._attributes),{style:Bc[t]})})},dh=e=>{let t=lo(e);return I(T({},t),{_attributes:I(T({},t._attributes),{style:"lane"})})},uh=e=>{let t=lo(e);return I(T({},t),{_attributes:I(T({},t._attributes),{style:"annotation"})})},Wc={TASK:sh,START_EVENT:ah,END_EVENT:lh,GATEWAY:ch,ANNOTATION:uh,LANE:dh},Xc=(e,t)=>{var s,a;let r=((s=e.measured)==null?void 0:s.width)||0,i=((a=e.measured)==null?void 0:a.height)||0;return{_attributes:{id:`${t+1}`,parent:e.id,style:"attribute-loop",connectable:"0"},mxGeometry:{_attributes:{as:"geometry",x:r/2-22/2,y:i-22,width:22,height:22}}}};var ph=e=>{let t=Object.values(qo),o=e.filter(i=>{var a;let s=(a=i._attributes)==null?void 0:a.style;return t.includes(s)}),n=e.filter(i=>{var a;let s=(a=i._attributes)==null?void 0:a.style;return["attribute-loop"].includes(s)}),r=[];for(let i of o){let{style:s}=i._attributes,a=zc[s],l=a==null?void 0:a(i,n);if(!l){console.warn(`Node ${s} not supported`);continue}r.push(l)}return r},fh=(e,t)=>{let o=e.filter(r=>{var i;return(i=r._attributes)==null?void 0:i.edge}),n=[];for(let r of o){let i=Fc(r,t),s=t.find(c=>c.id===i.source),a=t.find(c=>c.id===i.target);((s==null?void 0:s.type)==="LANE"||(a==null?void 0:a.type)==="LANE")&&i.type!=="ANNOTATION_EDGE"||n.push(i)}return n},mh=(e,t)=>{let o=[];return e.forEach(n=>{var s,a;let r=(a=(s=Wc)[n.type])==null?void 0:a.call(s,n);if(!r){console.warn(`Node ${n.type} not supported`);return}if(o.push(r),n.type==="TASK"&&n.data.attribute==="LOOP"){let l=Xc(n,t);o.push(l)}}),o},gh=(e,t)=>{let o=[];return e.forEach(n=>{let r=Yc(n,t);o.push(r)}),o},hh=(e=[],t=[],o)=>{let n=mh(e,o),r=gh(t,e);return{mxGraphModel:{root:{_attributes:{version:"1.1",lastId:o},mxCell:[{_attributes:{id:"0"}},{_attributes:{id:"1",parent:"0"}},...n,...r]}}}},Uc=(e=[],t=[],o)=>{let n=hh(e,t,o);return kc(JSON.stringify(n),{compact:!0,spaces:0})},$c=async e=>{var s,a,l,c,d;let t=await xr(e),o=((a=(s=t==null?void 0:t.mxGraphModel)==null?void 0:s.root)==null?void 0:a.mxCell)||[],n=Number(((d=(c=(l=t==null?void 0:t.mxGraphModel)==null?void 0:l.root)==null?void 0:c._attributes)==null?void 0:d.lastId)||Zo),r=ph(o);r=Ac(r),r=Sc(r),r=It(r);let i=fh(o,r);return{lastElementId:n,nodes:r,edges:i}};import{useReactFlow as s0,useStoreApi as a0}from"@xyflow/react";import{useCallback as l0}from"react";import{useReactFlow as Gy}from"@xyflow/react";import{useCallback as ss}from"react";import{useCallback as yh,useEffect as Ki,useRef as Kc,useState as xh}from"react";import{jsx as Zc}from"react/jsx-runtime";var qi=/[a-zA-Z0-9À-ÖØ-öø-ÿ]/,qc=["Backspace","Delete","ArrowLeft","ArrowRight","ArrowUp","ArrowDown","Home","End","Tab","Escape","Shift"],ye=({value:e,maxLength:t,style:o,className:n,contentClassName:r,isEditing:i,onChange:s,onBlur:a,onInput:l,onInvalidFirstCharacter:c,skipFirstCharValidation:d})=>{let u=Kc(null),p=Kc(null),[f,x]=xh(!1);Ki(()=>()=>{p.current&&clearTimeout(p.current)},[]),Ki(()=>{x(i!=null?i:!1)},[i]),Ki(()=>{if(f&&u.current){u.current.focus();let b=document.createRange();b.selectNodeContents(u.current);let N=window.getSelection();N&&(N.removeAllRanges(),N.addRange(b))}},[f]);let E=yh(()=>{p.current||(c==null||c(),p.current=setTimeout(()=>{p.current=null},500))},[c]),m=b=>{b.stopPropagation(),f||x(!0)},h=b=>{let N=b.currentTarget.innerText.replace(/\n$/,""),_=t&&N.length>=t,w=window.getSelection(),S=(w==null?void 0:w.toString())||"",M=S.length>0,L=(b.ctrlKey||b.metaKey)&&!b.altKey,D=L&&b.key==="a",O=L&&b.key==="c",R=L&&b.key==="x",V=L&&b.key==="v",G=N.length===0||M&&S.length===N.length;if(!d&&G&&!qi.test(b.key)&&!qc.includes(b.key)&&!L){b.preventDefault(),E();return}_&&!M&&(qc.includes(b.key)||D||O||R||V||b.preventDefault())},g=b=>{b.preventDefault();let N=b.clipboardData.getData("text/plain").replace(/\r\n/g,`
36
+ `).replace(/\r/g,`
37
+ `),_=b.currentTarget.innerText.replace(/\n$/,""),w=window.getSelection();if(!w||w.rangeCount===0)return;let S=w.toString(),M=_.length-S.length,L=t?Math.max(0,t-M):1/0;if(L<=0&&S.length===0)return;let D=N;if(D.length>L&&(D=D.substring(0,L)),!D&&S.length===0)return;let O=w.getRangeAt(0),R=O.startOffset===0&&(O.startContainer===b.currentTarget||O.startContainer.parentNode===b.currentTarget);if(!d&&R&&D.length>0&&!qi.test(D[0])){E();return}O.deleteContents();let V=document.createTextNode(D);O.insertNode(V),O.setStartAfter(V),O.collapse(!0),w.removeAllRanges(),w.addRange(O),l==null||l(b.currentTarget.innerText.replace(/\n$/,""))},y=b=>{let N=b.currentTarget,_=N.innerText.replace(/\n$/,"");if(!d&&_.length>0&&!qi.test(_[0])){let w=_.slice(1);if(N.innerText=w,w.length>0&&N.firstChild){let S=document.createRange(),M=window.getSelection();S.setStart(N.firstChild,0),S.collapse(!0),M==null||M.removeAllRanges(),M==null||M.addRange(S)}E(),l==null||l(w);return}l==null||l(_)},v=b=>{x(!1);let N=b.currentTarget.innerText.replace(/\r\n/g,`
38
+ `).replace(/\r/g,`
39
+ `).trim();t&&N.length>t&&(N=N.substring(0,t)),b.currentTarget.innerText=N,a==null||a(),N!==e&&(s==null||s(N))};return Zc("div",{className:F("flex-1 p-2 self-stretch flex items-center justify-center border border-transparent overflow-hidden text-ellipsis body-medium-400 text-center rounded-sm",{"border border-dashed border-grey-400 bg-white shadow-md":f,"bg-white":e.length>0},n),style:o,onDoubleClick:m,children:Zc("div",{ref:u,className:F("outline-none whitespace-pre-wrap overflow-hidden",r,{"nodrag nopan cursor-text":f}),contentEditable:f,suppressContentEditableWarning:!0,onKeyDown:h,onPaste:g,onInput:y,onBlur:v,children:e})})};import{Position as br,useConnection as Ih}from"@xyflow/react";import{useConnection as vh,useInternalNode as nd}from"@xyflow/react";import{useMemo as Nh}from"react";function Zi(e,t,o){return e.x<=t&&e.x+e.width>=t&&e.y<=o&&e.y+e.height>=o}function Ji(e){return e.x+e.width/2}function Qi(e){return e.y+e.height/2}function _r(e){return{x:e.x,y:e.y,width:0,height:0}}function co(e,t,o,n){!Zi(t,n.x,n.y)&&!Zi(o,n.x,n.y)&&e.push(n)}function Jc(e,t,o,n,r){let i=[],s=o?_r(o):e,a=n?_r(n):t,l=Math.max(s.x,a.x),c=Math.min(s.x+s.width,a.x+a.width),d=r?r.x:Math.round(c+(l-c)/2),u=Qi(s),p=Qi(a);if(r&&(r.y>=s.y&&r.y<=s.y+s.height&&(u=r.y),r.y>=a.y&&r.y<=a.y+a.height&&(p=r.y)),co(i,a,s,{x:d,y:u}),co(i,a,s,{x:d,y:p}),i.length===0)if(r)co(i,a,s,{x:d,y:r.y});else{let f=Math.max(s.y,a.y),x=Math.min(s.y+s.height,a.y+a.height);i.push({x:d,y:f+(x-f)/2})}return i}function Qc(e,t,o,n,r){let i=[],s=o?_r(o):e,a=n?_r(n):t,l=Math.max(s.y,a.y),c=Math.min(s.y+s.height,a.y+a.height),d=Ji(s);r&&r.x>=s.x&&r.x<=s.x+s.width&&(d=r.x);let u=r?r.y:Math.round(c+(l-c)/2);if(co(i,a,s,{x:d,y:u}),r&&r.x>=a.x&&r.x<=a.x+a.width?d=r.x:d=Ji(a),co(i,a,s,{x:d,y:u}),i.length===0)if(r)co(i,a,s,{x:r.x,y:u});else{let p=Math.max(s.x,a.x),f=Math.min(s.x+s.width,a.x+a.width);i.push({x:p+(f-p)/2,y:u})}return i}function ji(e,t,o,n,r){let i=!1,s=!1;if(r){let a=Math.min(e.x,t.x),l=Math.max(e.x+e.width,t.x+t.width),c=Math.min(e.y,t.y),d=Math.max(e.y+e.height,t.y+t.height);i=r.y<c||r.y>d,s=r.x<a||r.x>l}else{let a=Math.max(e.x,t.x),l=Math.min(e.x+e.width,t.x+t.width);if(i=a===l,!i){let c=Math.max(e.y,t.y),d=Math.min(e.y+e.height,t.y+t.height);s=c===d}}return!s&&i?{waypoints:Qc(e,t,o,n,r),direction:"top-to-bottom"}:{waypoints:Jc(e,t,o,n,r),direction:"side-to-side"}}function Eh(e,t,o){return t.x>=o.x&&t.x<=o.x+o.width?e.x=t.x:t.y>=o.y&&t.y<=o.y+o.height&&(e.y=t.y),t.x<o.x?e.x=o.x:t.x>o.x+o.width&&(e.x=o.x+o.width),t.y<o.y?e.y=o.y:t.y>o.y+o.height&&(e.y=o.y+o.height),e}function jc(e,t,o,n=0){let r=n?{x:e.x-n,y:e.y-n,width:e.width+2*n,height:e.height+2*n}:e,i=r.x+r.width/2,s=r.y+r.height/2,a=t.x-i,l=t.y-s,c=Math.atan2(l,a),d={x:0,y:0},u=Math.PI,f=Math.PI/2-c,x=Math.atan2(r.height,r.width);return c<-u+x||c>u-x?(d.x=r.x,d.y=s-r.width*Math.tan(c)/2):c<-x?(d.y=r.y,d.x=i-r.height*Math.tan(f)/2):c<x?(d.x=r.x+r.width,d.y=s+r.width*Math.tan(c)/2):(d.y=r.y+r.height,d.x=i+r.height*Math.tan(f)/2),o?Eh(d,t,r):d}function _h(e,t,o,n,r,i){let s=e-o,a=t-n;if(i>=a&&i<=t+n){let l=i-t,c=Math.sqrt(o*o*(1-l*l/(n*n)))||0;return r<=s&&(c=-c),{x:e+c,y:i}}if(r>=s&&r<=e+o){let l=r-e,c=Math.sqrt(n*n*(1-l*l/(o*o)))||0;return i<=a&&(c=-c),{x:r,y:t+c}}}function ed(e,t,o,n=0){let r=e.x-n,i=e.y-n,s=e.width+2*n,a=e.height+2*n,l=s/2,c=a/2,d=r+l,u=i+c,p=t.x,f=t.y,x=Math.trunc(p-d),E=Math.trunc(f-u);if(x===0&&E!==0)return{x:d,y:u+c*E/Math.abs(E)};if(x===0&&E===0)return{x:p,y:f};if(o){let D=_h(d,u,l,c,p,f);if(D)return D}let m=E/x,h=u-m*d,g=l*l*m*m+c*c,y=-2*d*g,v=l*l*m*m*d*d+c*c*d*d-l*l*c*c,b=Math.sqrt(y*y-4*g*v),N=(-y+b)/(2*g),_=(-y-b)/(2*g),w=m*N+h,S=m*_+h,M=Math.sqrt(Math.pow(N-p,2)+Math.pow(w-f,2)),L=Math.sqrt(Math.pow(_-p,2)+Math.pow(S-f,2));return M<L?{x:N,y:w}:{x:_,y:S}}function es(e){return e==="ellipse"?ed:jc}function od(e){let{x:t,y:o,width:n,height:r}=e.bounds;return{x:t+n/2,y:o+r/2}}function bh(e,t,o){let n=null;if(e.length>=2){let r=e.length;n=e[o?Math.min(1,r-1):Math.max(0,r-2)]}return n!=null||(n=od(t)),n}function td(e,t,o,n){let r=bh(e,o,n);return t.bounds.width<=0&&t.bounds.height<=0?od(t):es(t.perimeter)(t.bounds,r,!0,0)}function at(e){var p;let{source:t,target:o,controlPoint:n=null,fixedSourcePoint:r=null,fixedTargetPoint:i=null}=e,s=r,a=i,{waypoints:l,direction:c}=ji(t.bounds,o.bounds,s,a,n),d=[s,...l,a];d.at(-1)==null&&(d[d.length-1]=td(d,o,t,!1)),(p=d[0])!=null||(d[0]=td(d,t,o,!0));let u=d;return{points:u,sourcePoint:u[0],targetPoint:u.at(-1),waypoints:l,direction:c}}function ts(e,t){let o=at({source:e,target:t});return Th(o.targetPoint,t.bounds)}function Th(e,t){if(Math.abs(e.x-t.x)<=1)return"left";if(Math.abs(e.x-(t.x+t.width))<=1)return"right";if(Math.abs(e.y-t.y)<=1)return"top";if(Math.abs(e.y-(t.y+t.height))<=1)return"bottom";let n=t.x+t.width/2,r=t.y+t.height/2,i=Math.abs(e.x-n),s=Math.abs(e.y-r);return i>=s?e.x<n?"left":"right":e.y<r?"top":"bottom"}function rd(e){var i;let{inProgress:t,fromNode:o}=vh(),n=nd(e),r=nd((i=o==null?void 0:o.id)!=null?i:"");return Nh(()=>!t||!r||r.id===e||!n?null:ts(et(r),et(n)),[t,r,e,n])}import{Handle as id,useReactFlow as wh}from"@xyflow/react";import{jsx as ad}from"react/jsx-runtime";var uo=i=>{var s=i,{type:e,position:t,className:o,nodeType:n}=s,r=Ue(s,["type","position","className","nodeType"]);let a=n==="TASK";return ad(id,T({type:e,position:t,className:F("size-2.5 border border-grey-400 bg-white relative",{"before:content-[''] before:absolute before:inset-[-16px] before:bg-transparent before:pointer-events-none":a,"before:content-[''] before:absolute before:inset-[-4px] before:bg-transparent before:pointer-events-none":!a},o)},r))},sd=a=>{var l=a,{nodeId:e,nodeType:t,gatewayVariant:o,type:n,position:r,className:i}=l,s=Ue(l,["nodeId","nodeType","gatewayVariant","type","position","className"]);let{getEdges:c,getNodes:d}=wh(),p=(()=>{if(n!=="source")return!1;let f=c();if(t==="TASK")return f.filter(E=>E.source===e).length>=2;if(t==="GATEWAY"&&o==="EXCLUSIVE")return f.filter(E=>E.source===e).length>=2;if(t==="START_EVENT"){let x=d();return f.filter(m=>{if(m.source!==e)return!1;let h=x.find(g=>g.id===m.target);return(h==null?void 0:h.type)!=="ANNOTATION"}).length>=1}return!1})();return ad(id,T({type:n,position:r,className:F("size-2.5 border border-grey-400 bg-white transition-all duration-200 relative",{"before:content-[''] before:absolute before:inset-[-16px] before:bg-transparent before:pointer-events-none":t==="TASK","before:content-[''] before:absolute before:inset-[-4px] before:bg-transparent before:pointer-events-none":t!=="TASK","opacity-50 cursor-not-allowed pointer-events-none":p,"hover:border-grey-500":!p},i),style:{pointerEvents:p?"none":"auto"}},s))};import{Fragment as Ah,jsx as os,jsxs as Ch}from"react/jsx-runtime";var ld=[{position:br.Left,side:"left"},{position:br.Right,side:"right"},{position:br.Top,side:"top"},{position:br.Bottom,side:"bottom"}],He=({nodeId:e,nodeType:t,gatewayVariant:o,targetHandleClassName:n,conditionalSource:r=!1})=>{let{inProgress:i,fromNode:s,toNode:a,isValid:l}=Ih(),{reconnectingEdgeId:c}=$(),d=rd(e),u=i&&(s==null?void 0:s.id)!==e||!!c,p=!i||u,f=!!a&&a.id===e;return Ch(Ah,{children:[p&&ld.map(({position:x,side:E})=>{let m=u&&(d===null||E===d);return os(uo,{type:"target",position:x,id:E,className:F(m&&n,m&&f&&(l?"valid":"connectingto"))},`target-${E}`)}),!i&&ld.map(({position:x,side:E})=>r?os(sd,{type:"source",position:x,id:E,nodeId:e,nodeType:t,gatewayVariant:o},`source-${E}`):os(uo,{type:"source",position:x,id:E},`source-${E}`))]})};import{useRef as cd}from"react";import{NodeResizeControl as dd,ResizeControlVariant as Lh,useReactFlow as Dh,useStoreApi as kh}from"@xyflow/react";import{useCallback as Sh}from"react";import{useStore as Mh}from"@xyflow/react";function Ze(){return Mh(Sh(e=>e.nodes.filter(o=>o.selected).length+e.edges.filter(o=>o.selected).length>=2,[]))}import{useStoreApi as Ph}from"@xyflow/react";var Tr=()=>{let e=Ph();return{getInternalNodes:()=>{let{nodeLookup:o}=e.getState();return Array.from(o.values())}}};import{Fragment as Vh,jsxs as Hh}from"react/jsx-runtime";import{createElement as ud}from"react";var Rh=["top","right","bottom","left"],Oh=["top-left","top-middle","top-right","right-middle","bottom-left","left-middle","bottom-right","bottom-middle"],Ge=r=>{var i=r,{nodeId:e,isVisible:t,offset:o=8}=i,n=Ue(i,["nodeId","isVisible","offset"]);let{getInternalNode:s,setNodes:a}=Dh(),{getInternalNodes:l}=Tr(),c=Ze(),d=kh(),u=cd(0),p=cd([]),f=({y:h,width:g,height:y})=>{cancelAnimationFrame(u.current),u.current=requestAnimationFrame(()=>{var V,G;if(!e)return;let{nodeLookup:v,onNodesChange:b}=d.getState(),N=v.get(e);if(!N||N.type!=="LANE")return;let _=!N.parentId,w=_?N.id:N.parentId;if(!w)return;let S=Array.from(v.values()).filter(B=>B.type==="LANE"&&B.parentId===w);if(!S.length)return;p.current.length===0&&(p.current=Vt(S).map(B=>B.id));let M=p.current.map(B=>S.find(A=>A.id===B)).filter(Boolean),L=[],D=0,O=M.findIndex(B=>B.id===N.id),R=!_&&O>0&&Math.abs(h-N.position.y)>.5;for(let B=0;B<M.length;B++){let A=M[B],C=A.id===N.id,k=B===M.length-1;if(C){D=R?h+y:D+y;continue}let P=(G=(V=A.measured)==null?void 0:V.height)!=null?G:0,K=_?g-J.HEADER_WIDTH:g,Z=P;_&&k&&(Z=Math.max(J.MIN_HEIGHT,y-D)),R&&B===O-1&&(Z=Math.max(J.MIN_HEIGHT,h-D)),L.push({id:A.id,type:"dimensions",dimensions:{width:K,height:Z},setAttributes:!0}),L.push({id:A.id,type:"position",position:{x:J.HEADER_WIDTH,y:D}}),D+=Z}_?L.push({id:w,type:"dimensions",dimensions:{width:g,height:y},setAttributes:!0}):L.push({id:w,type:"dimensions",dimensions:{width:g+J.HEADER_WIDTH,height:D},setAttributes:!0}),b==null||b(L)})},x=({y:h,width:g,height:y})=>{var N;if(cancelAnimationFrame(u.current),p.current=[],!e)return;let v=s(e);if(!v||v.type!=="LANE"&&!v.parentId)return;let b=[...l()];if(v.type!=="LANE"){b=b.map(_=>_.id===e?I(T({},_),{width:g,height:y,measured:{width:g,height:y}}):_),b=st(b),a(b);return}b=Ic(v,g,y,b,h),b=st(b),b=Ot((N=v.parentId)!=null?N:v.id,b),a(b)};if(!(!c&&t))return null;let m={"--resize-offset":`${o}px`};return Hh(Vh,{children:[Rh.map(h=>ud(dd,I(T({},n),{key:h,nodeId:e,position:h,variant:Lh.Line,className:"border-blue-400/90 border-dashed",style:m,onResize:(g,y)=>f(y),onResizeEnd:(g,y)=>x(y)}))),Oh.map(h=>ud(dd,I(T({},n),{key:h,nodeId:e,position:h,className:"size-1.5 bg-blue-400 relative before:content-[''] before:absolute before:w-5 before:h-5 before:left-1/2 before:top-1/2 before:-translate-x-1/2 before:-translate-y-1/2 before:cursor-[inherit]",style:m,onResize:(g,y)=>f(y),onResizeEnd:(g,y)=>x(y)})))]})};import{NodeToolbar as Cy,useReactFlow as Sy,useStore as hd}from"@xyflow/react";import{Button as My,Tooltip as Py,TooltipContent as Ly,TooltipTrigger as Dy,useTranslation as ky}from"@produto-lecom/lecom-ui";import Ry,{useCallback as jo,useEffect as Oy,useRef as Mr,useState as Vy}from"react";import{create as Gh}from"zustand";var po=Gh(e=>({draggableNode:null,setDraggableNode:t=>{e({draggableNode:t})}}));import{useEffect as Bh,useState as zh}from"react";var pd=(e,t=!1)=>{let[o,n]=zh({width:0,height:0});return Bh(()=>{if(e.current&&t){let r=e.current.getBoundingClientRect();n({width:r.width,height:r.height})}},[t,e]),{dimensions:o}};import{Position as Jo,useReactFlow as Fh}from"@xyflow/react";import{useMemo as Yh}from"react";var Wh=120,Xh=12,fd=(e,t=!1,o)=>{let{getNode:n,getViewport:r}=Fh(),{instanceId:i}=$();return Yh(()=>{var f,x;if(!t)return{position:Jo.Right,align:"start"};let s=n(e);if(!s)return{position:Jo.Right,align:"start"};let a=r(),l=s.position.x*a.zoom+a.x,c=(((f=s.measured)==null?void 0:f.width)||s.width||100)*a.zoom,d=(x=document.getElementById(`modeler-${i}`))==null?void 0:x.clientWidth;if(!d)return{position:Jo.Right,align:"start"};let u=(o==null?void 0:o.width)||Wh;return{position:l+c+u+Xh>d?Jo.Left:Jo.Right}},[i,e,t,o,n,r])};import{Bot as yd}from"lucide-react";import{useNodesData as Uh,useReactFlow as $h}from"@xyflow/react";import{Button as md,DropdownMenu as Kh,DropdownMenuContent as qh,DropdownMenuGroup as Zh,DropdownMenuItem as Jh,DropdownMenuLabel as Qh,DropdownMenuTrigger as jh,Tooltip as ns,TooltipContent as rs,TooltipTrigger as is,useTranslation as ey}from"@produto-lecom/lecom-ui";import{WrenchIcon as ty}from"lucide-react";import{jsx as Te,jsxs as Ht}from"react/jsx-runtime";var gd=({nodeId:e})=>{let{t}=ey(),{updateNodeData:o,getEdges:n,getNode:r}=$h(),i=Uh(e),a=n().filter(x=>x.source===e).some(x=>{let E=r(x.target);return(E==null?void 0:E.type)==="END_EVENT"}),l=(i==null?void 0:i.data.variant)==="SUBPROCESS",c=(i==null?void 0:i.data.variant)==="SERVICE_TASK",d=p=>{o(e,{variant:(i==null?void 0:i.data.variant)===p?"":p})},u=p=>{o(e,{attribute:(i==null?void 0:i.data.attribute)===p?"":p})};return Ht(Kh,{children:[Ht(ns,{children:[Te(is,{asChild:!0,children:Te(jh,{asChild:!0,children:Te(md,{variant:"ghost",color:"grey",size:"small",iconButton:!0,children:Te(ty,{})})})}),Te(rs,{color:"black",children:t("bpmn.task.menu.title")})]}),Ht(qh,{align:"start",className:"w-60 bg-white text-grey-600",children:[Ht(Qh,{className:"flex items-center gap-1",children:[Te("div",{className:"flex-1 body-medium-500",children:t("bpmn.task.menu.title")}),Te("div",{className:"flex items-center gap-1",children:Object.entries(An).map(([p,f])=>{let x=p==="LOOP"&&(a||l||c),m=(()=>{if(p==="LOOP"&&a)return t("editor.task_menu.loop_not_allowed_when_connected_to_end");if(p==="LOOP"&&l)return t("editor.task_menu.loop_not_allowed_when_subprocess");if(p==="LOOP"&&c)return t("editor.task_menu.loop_not_allowed_when_service_task");if(p==="LOOP")return t("editor.task_menu.loop")})();return Ht(ns,{children:[Te(is,{asChild:!0,children:Te(md,{variant:"ghost",color:"grey",size:"small",iconButton:!0,disabled:x,className:F({"bg-grey-100 text-blue-500":(i==null?void 0:i.data.attribute)===p,"opacity-50 cursor-not-allowed":x}),onClick:x?void 0:()=>u(p),children:Te(f.icon,{className:"stroke-inherit"})})}),m&&Te(rs,{color:"black",children:m})]},p)})})]}),Te(Zh,{children:Ht(ns,{children:[Te(is,{asChild:!0,children:Te("div",{className:F({"cursor-not-allowed":a}),children:Ht(Jh,{className:F({"bg-grey-100 text-blue-500":(i==null?void 0:i.data.variant)==="SCRIPT","opacity-50":a}),disabled:a,onClick:()=>d("SCRIPT"),children:[Te(In.SCRIPT.icon,{className:"stroke-current"}),t(`bpmn.task.variant.${"SCRIPT".toLowerCase()}`)]})})}),a&&Te(rs,{color:"black",children:t("editor.task_menu.script_not_allowed_when_connected_to_end")})]})})]})]})};import{Button as ny,Tooltip as ry,TooltipContent as iy,TooltipTrigger as sy,useTranslation as ay}from"@produto-lecom/lecom-ui";import{Settings as ly}from"lucide-react";import{getIncomers as vr,getOutgoers as Nr,useReactFlow as oy}from"@xyflow/react";var wr=()=>{let{getNode:e,getEdge:t,getNodes:o,getEdges:n}=oy(),{selectElements:r}=Ke(),i=m=>{let h=o(),g=n(),y=vr(m,h,g),v=Nr(m,h,g),b=y.some(_=>_.type==="START_EVENT"),N=v.some(_=>_.type==="END_EVENT");return b?"start":N?"end":"between"},s=(m,h,g)=>{var b,N,_,w,S;if(!m)return;let y={type:m.type,variant:(b=m.data)==null?void 0:b.variant,attribute:(N=m.data)==null?void 0:N.attribute},v={id:m.id,position:i(m),label:(_=m.data)==null?void 0:_.label,node:y};return m.type==="TASK"&&((w=m.data)==null?void 0:w.variant)==="SUBPROCESS"?I(T({},v),{type:"sub_process"}):m.type==="TASK"&&((S=m.data)==null?void 0:S.variant)==="SERVICE_TASK"?I(T({},v),{type:"service_task"}):m.type==="GATEWAY"?I(T({},v),{type:"gateway",variant:a(m,h,g)}):I(T({},v),{type:"activity"})},a=(m,h,g)=>{if(m.type!=="GATEWAY")return;let y=vr(m,h,g),v=!1,b=!1;if(y.forEach(N=>{var _,w;N.type==="TASK"&&(((_=N.data)==null?void 0:_.variant)==="SCRIPT"&&(v=!0),((w=N.data)==null?void 0:w.attribute)==="LOOP"&&(b=!0))}),v&&b)return"script_loop";if(v)return"script";if(b)return"loop"},l=(m,h,g)=>{var _,w,S,M;let y=e(m.source),v=e(m.target);if(!y||!v)return"simple";if(Nr(y,h,g).some(L=>L.type==="END_EVENT"))return"final";if(y.type==="GATEWAY")switch((_=y.data)==null?void 0:_.variant){case"PARALLEL":return"parallel";case"EXCLUSIVE":return"exclusive";case"COMPLEX":return"complex";default:return"simple"}if(y.type==="TASK"){let L=(w=y.data)==null?void 0:w.variant,D=(S=y.data)==null?void 0:S.attribute;if(L==="SUBPROCESS")return"from_sub_process";if(v.type==="TASK"&&((M=v.data)==null?void 0:M.variant)==="SUBPROCESS")return"to_sub_process";if(L==="SERVICE_TASK")return"from_service_task";let O=L==="SCRIPT",R=D==="LOOP";return O&&R?"script_loop":O?"script":R?"loop":"simple"}return"simple"},c=(m,h,g)=>{let y=[];function v(N,_,w=0){let S=s(N,h,g);if(S.depth=w,_.push(S),N.type==="TASK"){y.push([..._]),_.pop();return}let M=vr(N,h,g);if(M.length)for(let L of M)v(L,_,w+1);_.pop()}let b=vr(m,h,g);for(let N of b)v(N,[]);return y},d=(m,h,g)=>{let y=[];function v(N,_,w=0){let S=s(N,h,g);if(S.depth=w,_.push(S),N.type==="TASK"){y.push([..._]),_.pop();return}let M=Nr(N,h,g);if(M.length)for(let L of M)v(L,_,w+1);_.pop()}let b=Nr(m,h,g);for(let N of b)v(N,[]);return y},u=(m,h,g)=>(g=g.filter(v=>v.source===m.id),g.map(v=>{var _;let b=e(v.target),N;return b&&(N=s(b,h,g)),{id:v.id,type:"routing",variant:l(v,h,g),label:(_=v.data)==null?void 0:_.label,target:N}})),p=m=>{let h=e(m);if(!h)return;let g=o(),y=n(),v=s(h,g,y);return v.sources=c(h,g,y),v.targets=d(h,g,y),v.edgeTargets=u(h,g,y),h.type==="GATEWAY"&&(v.variant=a(h,g,y)),v},f=m=>{let h=t(m);if(!h)return;let g=o(),y=n(),v=l(h,g,y),N={id:h.id,type:"routing",variant:v,gatewayVariant:void 0},_=e(h.source);if(_){let S=s(_,g,y);N.source=S;let M=a(_,g,y);if(N.gatewayVariant=M,_.type==="TASK")N.sources=[[S]];else{let L=c(_,g,y);N.sources=L.length?L:[[S]]}}let w=e(h.target);if(w){let S=s(w,g,y);if(N.target=S,w.type==="TASK")N.targets=[[S]];else{let M=d(w,g,y);N.targets=M.length?M:[[S]]}}return N},x=m=>{let h=e(m);if(h)return p(h.id);let g=t(m);if(g)return f(g.id)};return{configureElement:m=>{let h=x(m);if(h)return r([m]),h},getConfigureElement:x,getNodeConfigure:p,getEdgeConfigure:f}};import{jsx as Ir,jsxs as dy}from"react/jsx-runtime";var cy={node:"editor.toolbar.configure_node",edge:"editor.toolbar.configure_edge",gateway:"editor.toolbar.configure_gateway"},xt=({elementId:e,elementType:t="node"})=>{let{t:o}=ay(),{onConfigureElement:n}=$(),{getConfigureElement:r}=wr();return dy(ry,{children:[Ir(sy,{asChild:!0,children:Ir(ny,{variant:"ghost",color:"grey",size:"small",iconButton:!0,onClick:()=>{let s=r(e);s&&(n==null||n(s))},children:Ir(ly,{size:16})})}),Ir(iy,{color:"black",children:o(cy[t])})]})};import{Button as py,Tooltip as fy,TooltipContent as my,TooltipTrigger as gy,useTranslation as hy}from"@produto-lecom/lecom-ui";import{useReactFlow as yy}from"@xyflow/react";import{TrashIcon as xy}from"lucide-react";import{useNotificationToast as uy}from"@produto-lecom/lecom-ui";function xe(){let{toast:e}=Qo(),{toast:t}=uy();return{toast:e||t}}import{jsx as Ar,jsxs as Ey}from"react/jsx-runtime";var Cr=({elementId:e,elementType:t="node"})=>{let{t:o}=hy(),{toast:n}=xe(),{deleteElements:r,getNodes:i}=yy(),{isRemovingElements:s}=$();return Ey(fy,{children:[Ar(gy,{asChild:!0,children:Ar(py,{variant:"ghost",color:"destructive",size:"small",iconButton:!0,onClick:()=>{if(!s)if(t==="node"){let l=i(),c=l.find(d=>d.id===e);if((c==null?void 0:c.type)==="LANE"&&l.some(u=>u.parentId===e)){n({variant:"error",title:o("validation.errors.title"),content:o("editor.toolbar.delete_pool_lane_error")});return}r({nodes:[{id:e}]})}else r({edges:[{id:e}]})},disabled:s,children:Ar(xy,{size:16})})}),Ar(my,{color:"black",children:o(s?"editor.toolbar.deleting":"editor.toolbar.delete")})]})};import{Button as _y,Tooltip as by,TooltipContent as Ty,TooltipTrigger as vy,useTranslation as Ny}from"@produto-lecom/lecom-ui";import{MoveUpRightIcon as wy}from"lucide-react";import{useCallback as Iy}from"react";import{jsx as Sr,jsxs as Ay}from"react/jsx-runtime";var fo=({nodeId:e,disabled:t=!1,tooltipMessage:o})=>{let{t:n}=Ny(),r=Iy(i=>{i.stopPropagation();let s=document.querySelectorAll(`.react-flow__handle.source[data-nodeid="${e}"]`);if(s.length===0)return;let a=Array.from(s).reduce((p,f)=>{let x=p.getBoundingClientRect(),E=f.getBoundingClientRect(),m=Math.hypot(i.clientX-(x.left+x.width/2),i.clientY-(x.top+x.height/2));return Math.hypot(i.clientX-(E.left+E.width/2),i.clientY-(E.top+E.height/2))<m?f:p}),l=a.getBoundingClientRect(),c=l.left+l.width/2,d=l.top+l.height/2,u=new MouseEvent("mousedown",{clientX:c,clientY:d,bubbles:!0,cancelable:!0});a.dispatchEvent(u)},[e]);return Ay(by,{children:[Sr(vy,{asChild:!0,children:Sr(_y,{variant:"ghost",color:"grey",size:"small",iconButton:!0,disabled:t,className:t?"opacity-50 cursor-not-allowed":"",onMouseDown:t?void 0:r,children:Sr(wy,{size:16})})}),Sr(Ty,{color:"black",children:o||n("editor.toolbar.connect_node")})]})};import{jsx as ge,jsxs as xd}from"react/jsx-runtime";var lt={START_EVENT:{type:"START_EVENT",icon:Ao,label:"bpmn.start_event.variant.default"},END_EVENT:{type:"END_EVENT",icon:Kt,label:"bpmn.end_event.variant.default"},TASK:{type:"TASK",icon:Ao,label:"bpmn.task.variant.default"},ANNOTATION:{type:"ANNOTATION",icon:Tn,label:"bpmn.annotation.variant.default"}},Hy={EXCLUSIVE:{type:"GATEWAY",variant:"EXCLUSIVE",icon:Zt,label:"bpmn.gateway.variant.exclusive"},PARALLEL:{type:"GATEWAY",variant:"PARALLEL",icon:Jt,label:"bpmn.gateway.variant.parallel"},COMPLEX:{type:"GATEWAY",variant:"COMPLEX",icon:qt,label:"bpmn.gateway.variant.complex"}},Ie=Ry.memo(({nodeId:e,nodeType:t,nodeVariant:o,isChild:n})=>{let r=Mr(null),i=Mr(null),{t:s}=ky(),{setDraggableNode:a}=po(),{getEdges:l,getNodes:c,setNodes:d}=Sy(),{setIsDragging:u,mode:p,isConnecting:f,isDragging:x}=$(),E=Ze(),m=hd(jo(z=>{var X,U;return(U=(X=z.nodeLookup.get(e))==null?void 0:X.selected)!=null?U:!1},[e])),h=hd(jo(z=>{var X,U;return(U=(X=z.nodeLookup.get(e))==null?void 0:X.dragging)!=null?U:!1},[e])),g=m&&!h&&!f&&!x&&!E,{dimensions:y}=pd(r,g),{position:v}=fd(e,g,y),[b,N]=Vy(void 0),_=o==="SUBPROCESS",w=o==="SERVICE_TASK",S=Mr(null),M=Mr(!1),L=jo(()=>{S.current!==null&&(clearTimeout(S.current),S.current=null),M.current=!1,u(!1),a(null),N(void 0),d(z=>z.map(X=>I(T({},X),{className:void 0})))},[u,a,d]);Oy(()=>{let z=X=>{M.current&&X.buttons===0&&L()};return document.addEventListener("dragend",L),document.addEventListener("mousemove",z),()=>{document.removeEventListener("dragend",L),document.removeEventListener("mousemove",z)}},[L]);let D=jo((z,X)=>{M.current=!0,u(!1),a({type:X.type,variant:X.variant,attribute:X.attribute,icon:X.icon}),X.icon&&N(ge(X.icon,{})),z.dataTransfer.effectAllowed="move",z.dataTransfer.setData("sourceId",e),i.current&&z.dataTransfer.setDragImage(i.current,10,10),S.current=setTimeout(()=>{S.current=null,u(!0)},100)},[e,a,u]),O=jo(()=>{L()},[L]);if(!g)return null;let R=c(),V=l(),G=[{component:ge(Cr,{elementId:e})}],B=()=>{if(p==="view")return[];let z=!V.some(X=>{var U;return X.source===e&&((U=R.find(W=>W.id===X.target))==null?void 0:U.type)!=="ANNOTATION"});return[{component:ge(fo,{nodeId:e,disabled:!z,tooltipMessage:z?void 0:s("editor.toolbar.start_event_limit_reached")})},lt.TASK,lt.ANNOTATION,...G]},A=()=>p==="view"?[{component:ge(xt,{elementId:e})}]:[{component:ge(xt,{elementId:e})},..._||w?[]:[{component:ge(gd,{nodeId:e})}],{component:ge(fo,{nodeId:e})},lt.TASK,{type:"TASK",variant:"SUBPROCESS",icon:So,label:"bpmn.task.variant.subprocess"},{type:"TASK",variant:"SERVICE_TASK",icon:yd,label:"bpmn.task.variant.service_task"},lt.ANNOTATION,...Object.values(Hy),...kt(e,R,V)?[]:[lt.END_EVENT],...G],C=()=>p==="view"?[{component:ge(xt,{elementId:e,elementType:"gateway"})}]:[{component:ge(xt,{elementId:e,elementType:"gateway"})},{component:ge(fo,{nodeId:e})},lt.TASK,{type:"TASK",variant:"SUBPROCESS",icon:So,label:"bpmn.task.variant.subprocess"},{type:"TASK",variant:"SERVICE_TASK",icon:yd,label:"bpmn.task.variant.service_task"},lt.ANNOTATION,...G],k=()=>p==="view"?[]:[lt.ANNOTATION,...G],P=()=>p==="view"?[]:[...n?[]:[{component:ge(fo,{nodeId:e})}],lt.ANNOTATION,...G],K=()=>p==="view"?[]:[{component:ge(fo,{nodeId:e})},...G],Z=()=>p==="view"?[]:[...G],H=(z=>{switch(z){case"START_EVENT":return B();case"TASK":return A();case"GATEWAY":return C();case"END_EVENT":return k();case"LANE":return P();case"ANNOTATION":return K();case"UNSUPPORTED":return Z();default:return[]}})(t),q=H.length>6;if(!(H.length===0||p==="readonly"))return xd(Cy,{position:v,align:"start",className:q?"-top-[4.5rem]":"-top-8",isVisible:g,children:[ge("div",{ref:r,className:`${q?"grid grid-cols-6":"flex"} gap-1 px-2 py-2 bg-white rounded-sm shadow-md`,children:H.map((z,X)=>{if(z.component)return ge("div",{children:z.component},X);let U={sourceNodeType:t,targetNodeType:z.type,sourceNodeId:e,nodes:R,edges:V},W=Tc(U),oe={gateway_limit_reached:s("editor.toolbar.gateway_limit_reached"),start_event_limit_reached:s("editor.toolbar.start_event_limit_reached"),start_event_already_exists:s("editor.toolbar.start_event_already_exists"),script_to_end_not_allowed:s("editor.toolbar.script_to_end_not_allowed"),loop_to_end_not_allowed:s("editor.toolbar.loop_to_end_not_allowed"),initial_activity_to_end_not_allowed:s("editor.toolbar.initial_activity_to_end_not_allowed"),final_activity_cannot_connect:s("editor.toolbar.final_activity_cannot_connect"),activity_has_outgoing_connections:s("editor.toolbar.activity_has_outgoing_connections"),task_limit_reached:s("editor.toolbar.task_limit_reached"),start_event_to_service_task_not_allowed:s("editor.toolbar.start_event_to_service_task_not_allowed"),service_task_to_end_not_allowed:s("editor.toolbar.service_task_to_end_not_allowed")},ie=W.shouldDisable&&W.reason?oe[W.reason]||s(z.label):s(z.label)||"";return xd(Py,{children:[ge(Dy,{asChild:!0,children:ge(My,{variant:"ghost",color:"grey",size:"small",iconButton:!0,draggable:!W.shouldDisable,disabled:W.shouldDisable,className:W.shouldDisable?"opacity-50 cursor-not-allowed":"",onDragStart:W.shouldDisable?void 0:te=>D(te,z),onDragEnd:W.shouldDisable?void 0:O,children:z.icon&&ge(z.icon,{size:16})})}),ge(Ly,{color:"black",children:ie})]},X)})}),ge("div",{ref:i,className:"absolute w-0 h-0 top-0 left-0 z-[-1] bg-transparent",children:b})]})});Ie.displayName="NodeToolbar";import{jsx as Pr,jsxs as By}from"react/jsx-runtime";var Ed=({id:e,data:t,width:o,height:n,selected:r,dragging:i})=>{let{updateNodeData:s,setNodes:a}=Gy(),{mode:l,isReadOnly:c}=$(),d=ss(f=>{let g=f.split(`
40
+ `),y=g.reduce((_,w)=>Math.max(_,w.length),0),v=g.length,b=Math.max(Rt.MIN_WIDTH,y*7+32),N=Math.max(Rt.MIN_HEIGHT,v*20+24);a(_=>_.map(w=>{var S;if(w.id===e){let M=Math.max((S=w.height)!=null?S:Rt.MIN_HEIGHT,N);return I(T({},w),{width:b,height:M,style:I(T({},w.style),{width:b,height:M})})}return w}))},[e,a]),u=ss(f=>{s(e,{label:f}),d(f)},[e,s,d]),p=ss(f=>{d(f)},[d]);return By("div",{className:F("relative w-full h-full flex text-grey-400 hover:text-grey-500 bg-white rounded-sm border-l-2 border-current before:absolute before:top-0 before:left-0 before:w-4 before:border-t-2 before:border-current after:absolute after:bottom-0 after:left-0 after:w-4 after:border-t-2 after:border-current hover:shadow-md transition-colors duration-75",{"pointer-events-none":c,"text-blue-500 hover:text-blue-600 shadow-md":r&&!c,"border-red-500 border-l-[3px] shadow-[0_0_5px_rgba(255,0,0,0.5)] before:absolute before:top-0 before:left-0 before:w-4 before:border-t-2 before:border-red-500 after:absolute after:bottom-0 after:left-0 after:w-4 after:border-t-2 after:border-red-500":t.hasError}),style:{width:o,height:n},children:[Pr(ye,{value:t.label,className:"m-1 text-grey-600 text-left",onChange:u,onInput:p,skipFirstCharValidation:!0}),Pr(Ie,{nodeId:e,nodeType:"ANNOTATION"}),l==="edit"&&Pr(Ge,{nodeId:e,minWidth:Rt.MIN_WIDTH,minHeight:Rt.MIN_HEIGHT,isVisible:!i&&r}),Pr(He,{nodeId:e,nodeType:"ANNOTATION",targetHandleClassName:"annotation-handle"})]})};import{useReactFlow as zy}from"@xyflow/react";import{useState as Fy}from"react";import{jsx as mo,jsxs as Yy}from"react/jsx-runtime";var _d=({id:e,data:t,selected:o,dragging:n})=>{let{updateNodeData:r}=zy(),{mode:i,isReadOnly:s}=$(),[a,l]=Fy(!1),c=p=>{r(e,{label:p})},d=()=>{l(!0)},u=()=>{l(!1)};return Yy("div",{className:"relative",onDoubleClick:d,children:[mo(Kt,{className:F("w-full h-full hover:stroke-[#d33b3b] transition-colors duration-75",{"pointer-events-none":s,"stroke-blue-500 hover:stroke-blue-600":o&&!s,"stroke-red-500 hover:stroke-red-600 drop-shadow-[0_0_3px_rgba(255,0,0,0.5)] fill-red-100":t.hasError})}),mo("div",{className:"absolute mt-2 left-1/2 -translate-x-1/2 max-w-80 w-max",children:mo(ye,{value:t.label,isEditing:a,onBlur:u,onChange:c})}),mo(Ie,{nodeId:e,nodeType:"END_EVENT"}),i==="edit"&&mo(Ge,{nodeId:e,isVisible:!n&&o,minWidth:hr.MIN_WIDTH,minHeight:hr.MIN_HEIGHT,offset:4,keepAspectRatio:!0}),mo(He,{nodeId:e,nodeType:"END_EVENT",targetHandleClassName:"event-handle"})]})};import{useReactFlow as Wy}from"@xyflow/react";import{memo as Xy,useCallback as Uy,useState as $y}from"react";import{jsx as go,jsxs as Ky}from"react/jsx-runtime";var as=Xy(({id:e,data:t,width:o,height:n,selected:r,dragging:i})=>{let s=Ni[t.variant].icon,{updateNodeData:a}=Wy(),{mode:l,isReadOnly:c}=$(),[d,u]=$y(!1),p=Uy(E=>{a(e,{label:E})},[e,a]),f=()=>{u(!0)},x=()=>{u(!1)};return Ky("div",{className:"relative",style:{width:o!=null?o:io.MIN_WIDTH,height:n!=null?n:io.MIN_HEIGHT},onDoubleClick:f,children:[go(s,{className:F("w-full h-full stroke-1 stroke-grey-400 hover:stroke-grey-500 transition-colors duration-75",{"pointer-events-none":c,"stroke-blue-500 hover:stroke-blue-600":r&&!c,"stroke-red-500 hover:stroke-red-600 drop-shadow-[0_0_3px_rgba(255,0,0,0.5)]":t.hasError})}),go("div",{className:"absolute mt-2 left-1/2 -translate-x-1/2 max-w-80 w-max",children:go(ye,{value:t.label,isEditing:d,onBlur:x,onChange:p})}),go(Ie,{nodeId:e,nodeType:"GATEWAY",nodeVariant:t.variant}),l==="edit"&&go(Ge,{nodeId:e,isVisible:!i&&r,minWidth:io.MIN_WIDTH,minHeight:io.MIN_HEIGHT,offset:2,keepAspectRatio:!0}),go(He,{nodeId:e,nodeType:"GATEWAY",gatewayVariant:t.variant,targetHandleClassName:"gateway-handle",conditionalSource:!0})]})});as.displayName="Gateway";import{useNodesData as XP,useReactFlow as UP}from"@xyflow/react";import{Button as KP,DropdownMenu as qP,DropdownMenuContent as ZP,DropdownMenuGroup as JP,DropdownMenuItem as QP,DropdownMenuLabel as jP,DropdownMenuTrigger as eL,Tooltip as tL,TooltipContent as oL,TooltipTrigger as nL,useTranslation as rL}from"@produto-lecom/lecom-ui";import{WrenchIcon as sL}from"lucide-react";import{jsx as dL,jsxs as uL}from"react/jsx-runtime";import{useReactFlow as qy}from"@xyflow/react";import{useState as Zy}from"react";import{jsx as ho,jsxs as Jy}from"react/jsx-runtime";var bd=({id:e,data:t,selected:o,dragging:n})=>{let{updateNodeData:r}=qy(),{mode:i,isReadOnly:s}=$(),[a,l]=Zy(!1),c=p=>{r(e,{label:p})},d=()=>{l(!0)},u=()=>{l(!1)};return Jy("div",{className:"relative",onDoubleClick:d,children:[ho(Nn,{className:F("w-full h-full hover:stroke-[#54890b] transition-colors duration-75",{"pointer-events-none":s,"stroke-blue-500 hover:stroke-blue-600":o&&!s,"stroke-red-500 hover:stroke-red-600 drop-shadow-[0_0_3px_rgba(255,0,0,0.5)] fill-red-100":t.hasError})}),ho("div",{className:"absolute mt-2 left-1/2 -translate-x-1/2 max-w-80 w-max",children:ho(ye,{value:t.label,isEditing:a,onBlur:u,onChange:c})}),ho(Ie,{nodeId:e,nodeType:"START_EVENT"}),i==="edit"&&ho(Ge,{nodeId:e,isVisible:!n&&o,minWidth:gr.MIN_WIDTH,minHeight:gr.MIN_HEIGHT,offset:4,keepAspectRatio:!0}),ho(He,{nodeId:e,nodeType:"START_EVENT",targetHandleClassName:"event-handle",conditionalSource:!0})]})};import{useTranslation as ex}from"@produto-lecom/lecom-ui";import{useReactFlow as tx}from"@xyflow/react";import{memo as ox,useCallback as Dr}from"react";var en=60,Lr=(e,t)=>{var s;let o=[],n=`${t} `;for(let a of e){if(!(a.type==="TASK"))continue;let c=(s=a.data)==null?void 0:s.label;if(c&&c.startsWith(n)){let d=c.substring(n.length);/^\d{1,15}$/.test(d)&&o.push(parseInt(d,10))}}let r=o.length>0?Math.max(...o)+1:1,i=`${t} ${r}`;return i.length<=en?i:i.substring(0,en).trim()},yo=(e,t)=>{var a;let o=new Set;for(let l of t)l.type==="TASK"&&((a=l.data)!=null&&a.label)&&o.add(l.data.label);let n=e;if(n.length>en&&(n=n.substring(0,en).trim()),!o.has(n))return n;let r=n.replace(/\s+\(\d+\)$/,""),i=2,s=o.size+2;for(;i<=s;){let l=` (${i})`,c=en-l.length,u=`${r.substring(0,c).trim()}${l}`;if(!o.has(u))return u;i++}return n};import{jsx as Td,jsxs as Qy}from"react/jsx-runtime";var vd=e=>Qy("svg",I(T({width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",xmlns:"http://www.w3.org/2000/svg"},e),{children:[Td("circle",{cx:"12",cy:"12",r:"10",fill:"#10B981"}),Td("path",{d:"M7 12L10 15L17 8",stroke:"white",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"})]}));import{jsx as Nd}from"react/jsx-runtime";var wd=e=>Nd("svg",I(T({width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",xmlns:"http://www.w3.org/2000/svg"},e),{children:Nd("path",{d:"M12 2C8.13 2 5 5.13 5 9C5 14.25 12 22 12 22C12 22 19 14.25 19 9C19 5.13 15.87 2 12 2ZM12 11.5C10.62 11.5 9.5 10.38 9.5 9C9.5 7.62 10.62 6.5 12 6.5C13.38 6.5 14.5 7.62 14.5 9C14.5 10.38 13.38 11.5 12 11.5Z",fill:"#38bdf8"})}));import{jsx as Id,jsxs as jy}from"react/jsx-runtime";var Ad=e=>jy("svg",I(T({width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",xmlns:"http://www.w3.org/2000/svg"},e),{children:[Id("circle",{cx:"12",cy:"12",r:"10",fill:"#EF4444"}),Id("path",{d:"M8 8L16 16M8 16L16 8",stroke:"white",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"})]}));import{Fragment as Cd,jsx as Ae,jsxs as cs}from"react/jsx-runtime";var nx={APROVADO:vd,EM_ANDAMENTO:wd,REJEITADO:Ad},ls={APROVADO:"border-green-500 hover:border-green-500 border-[3px] border-solid",EM_ANDAMENTO:"border-turquoise-400 hover:border-turquoise-400 border-[3px] border-solid",REJEITADO:"border-red-500 hover:border-red-500 border-[3px] border-solid",default:"border-grey-400 border-2 border-solid",error:"border-red-500 border-[3px] shadow-[0_0_5px_rgba(255,0,0,0.5)]"},rx={APROVADO:"bg-green-50",EM_ANDAMENTO:"bg-turquoise-50",REJEITADO:"bg-red-50"},ds=ox(({id:e,data:t,width:o,height:n,selected:r,dragging:i})=>{let{t:s}=ex(),{toast:a}=xe(),{updateNodeData:l,getNodes:c,setNodes:d}=tx(),{mode:u,isReadOnly:p,onSubprocessValidationClick:f}=$(),{getTaskStatus:x}=Ct(),E=x(e),m=t.variant==="SUBPROCESS",h=t.variant==="SERVICE_TASK",g=!!t.variant&&!m&&!h||!!E,y=!!t.attribute||m||h,v=Dr(R=>{let A=g||y?80:40,C=R.split(`
41
+ `),k=C.reduce((Y,H)=>Math.max(Y,H.length),0),P=C.length,K=Math.max(it.MIN_WIDTH,k*7+64),Z=Math.max(it.MIN_HEIGHT,P*24+A);d(Y=>Y.map(H=>{var q;if(H.id===e){let z=Math.max((q=H.height)!=null?q:it.MIN_HEIGHT,Z);return I(T({},H),{width:K,height:z,style:I(T({},H.style),{width:K,height:z})})}return H}))},[e,d,g,y]),b=Dr(R=>{let V=R.trim(),G=t.label||"";if(V===G)return;let B=V,A=c();if(!(V&&V!=="")){B=Lr(A,s("bpmn.task.label.prefix")),l(e,{label:B}),v(B),a({variant:"warning",content:cs(Cd,{children:[s("bpmn.task.feedback.label_empty.prefix")," ",Ae("strong",{children:B})]})});return}let k=yo(B,A);k===G||(l(e,{label:k}),v(k),k!==B&&a({variant:"warning",content:cs(Cd,{children:[s("bpmn.task.feedback.label_already_exists.prefix")," ",Ae("strong",{children:V})," ",s("bpmn.task.feedback.label_already_exists.middle")," ",Ae("strong",{children:k})]})}))},[t.label,c,e,s,l,v,a]),N=Dr(R=>{v(R)},[v]),_=Dr(()=>{a({variant:"error",content:s("bpmn.task.feedback.invalid_first_character")})},[s,a]),w=E?nx[E]:null,S=t.variant?In[t.variant].icon:null,M=t.attribute?An[t.attribute].icon:null,L=()=>t.hasError?ls.error:E?ls[E]:p?ls.default:"",D=()=>{var R;return r&&(R=rx[E])!=null?R:""},O=()=>{f==null||f({id:e,type:"sub_process",label:t.label})};return cs("div",{className:F("relative w-full h-full flex flex-col items-stretch justify-stretch bg-white border-2 border-grey-400 hover:border-grey-500 rounded-md hover:shadow-md transition-colors duration-75",L(),{"cursor-pointer":p,"border-blue-500 hover:border-blue-600 shadow-md":r&&!p&&!E,"border-red-500 hover:border-red-600 shadow-[0_0_5px_rgba(255,0,0,0.5)]":t.hasError}),style:{width:o!=null?o:it.MIN_WIDTH,height:n!=null?n:it.MIN_HEIGHT},children:[Ae("div",{className:"flex-1 flex items-stretch justify-stretch overflow-hidden",children:Ae(ye,{value:t.label,maxLength:60,className:F("bg-white/10",D(),{"py-10 px-8":g||y}),onChange:b,onInput:N,onInvalidFirstCharacter:_})}),S&&Ae("div",{className:F("absolute flex items-center p-1",m||h?"bottom-0 left-1/2 -translate-x-1/2":"top-0 left-0"),children:Ae(S,{size:h?20:16,className:F(t.hasError?"text-red-500":"text-grey-500",m&&"cursor-pointer"),onClick:m?O:void 0})}),M&&Ae("div",{className:"absolute bottom-0 left-0 w-full flex items-center justify-center",children:Ae("div",{className:F("flex items-center w-16 p-1",m||h?"justify-between":"justify-center"),children:Ae(M,{size:16,className:F(t.hasError?"text-red-500":"text-grey-500")})})}),w&&Ae("div",{className:"absolute top-0 right-0 flex items-center p-1",children:Ae(w,{})}),Ae(Ie,{nodeId:e,nodeType:"TASK",nodeVariant:t.variant}),u==="edit"&&Ae(Ge,{nodeId:e,isVisible:!i&&r,minWidth:it.MIN_WIDTH,minHeight:it.MIN_HEIGHT}),Ae(He,{nodeId:e,nodeType:"TASK",targetHandleClassName:"task-handle",conditionalSource:!0})]})});ds.displayName="Task";import{useReactFlow as ix}from"@xyflow/react";import{orderBy as sx}from"lodash";import{memo as ax,useMemo as Sd,useState as lx}from"react";import{Fragment as cx,jsx as Gt,jsxs as Md}from"react/jsx-runtime";var us=ax(({id:e,data:t,selected:o,dragging:n,parentId:r,width:i,height:s})=>{var N;let{updateNodeData:a,getNodes:l}=ix(),{mode:c,isReadOnly:d}=$(),[u,p]=lx(!1),f=l(),x=!r,E=!x&&((N=f.find(_=>_.id===r))==null?void 0:N.selected),m=Sd(()=>sx(f.filter(_=>_.parentId===e&&_.type==="LANE"),"position.y","asc"),[f,e]),h=x?vc.MIN_WIDTH:J.MIN_WIDTH,g=Sd(()=>{if(x&&m.length>1){let _=[...m];return _.pop(),_.reduce((S,M)=>{var L,D;return S+((D=(L=M.measured)==null?void 0:L.height)!=null?D:0)},0)+J.MIN_HEIGHT}return J.MIN_HEIGHT},[x,m]),y=_=>{a(e,{label:_})},v=()=>{p(!0)},b=()=>{p(!1)};return Md(cx,{children:[Md("div",{className:F("flex h-full w-full hover:shadow-md outline outline-2 outline-grey-400",{"pointer-events-none":d,"outline-offset-0 outline-blue-500 shadow-sm":(o||E)&&!d}),style:{width:i!=null?i:J.MIN_WIDTH,height:s!=null?s:J.MIN_HEIGHT},children:[Gt("div",{className:F("flex align-items justify-center w-10 border-r-2 border-grey-400 bg-white",{"border-blue-500":(o||E)&&!d}),onDoubleClick:v,children:Gt("div",{className:"relative flex-1 [writing-mode:vertical-rl] [text-orientation:sideways] transform rotate-180",children:Gt(ye,{value:t.label,className:"w-full h-full self-auto",contentClassName:F({"whitespace-nowrap":u}),isEditing:u,onBlur:b,onChange:y})})}),Gt("div",{className:F("flex-1",{"bg-white":!r||n})})]}),Gt(Ie,{nodeId:e,nodeType:"LANE",isChild:!x}),c==="edit"&&Gt(Ge,{nodeId:e,isVisible:!n&&o,minWidth:h,minHeight:g,offset:10}),Gt(He,{nodeId:e,nodeType:"LANE",targetHandleClassName:"annotation-handle"})]})});us.displayName="Lane";import{Position as Pd}from"@xyflow/react";import{Fragment as dx,jsx as kr,jsxs as ux}from"react/jsx-runtime";var Ld=({id:e,data:t})=>ux(dx,{children:[kr("div",{className:"relative w-full h-full flex items-center justify-center bg-white border-2 border-red-400 rounded-sm overflow-hidden",children:t.label}),kr(Ie,{nodeId:e,nodeType:"UNSUPPORTED"}),kr(uo,{type:"source",position:Pd.Right}),kr(uo,{type:"target",position:Pd.Left})]});import{BaseEdge as Lx,EdgeLabelRenderer as Dx,useViewport as kx}from"@xyflow/react";import Rx,{useMemo as Ox,useState as Vx}from"react";import{useCallback as xo,useEffect as ps,useRef as Rr,useState as tn}from"react";import{useReactFlow as px,useStore as fx}from"@xyflow/react";var mx=50,Dd=.1,gx=.6,Or=({edgeId:e,source:t,target:o,instanceId:n,isReadOnly:r})=>{let{setEdges:i,getNode:s,getNodes:a,screenToFlowPosition:l}=px(),{setIsDragging:c,setReconnectingEdgeId:d}=$(),u=fx(G=>G.isValidConnection),[p,f]=tn(null),[x,E]=tn(null),[m,h]=tn(null),[g,y]=tn(null),[v,b]=tn(!1),N=Rr(null),_=Rr(null),w=Rr(t),S=Rr(o);ps(()=>{w.current=t,S.current=o},[t,o]),ps(()=>{N.current=p},[p]);let M=xo(G=>wt(G,a()),[a]),L=xo(G=>{var P,K,Z,Y,H,q;let B=a(),A=null,C=mx,k=B.filter(z=>z.type!=="LANE"&&z.type!=="ANNOTATION");for(let z of k){if(z.id===e)continue;let X=M(z.id),U=(Z=(K=(P=z.measured)==null?void 0:P.width)!=null?K:z.width)!=null?Z:0,W=(q=(H=(Y=z.measured)==null?void 0:Y.height)!=null?H:z.height)!=null?q:0;if(G.x>=X.x&&G.x<=X.x+U&&G.y>=X.y&&G.y<=X.y+W)return z.id;let ie=Math.max(X.x-G.x,0,G.x-(X.x+U)),te=Math.max(X.y-G.y,0,G.y-(X.y+W)),ne=Math.sqrt(ie*ie+te*te);ne<C&&(C=ne,A=z.id)}return A},[a,M,e]),D=xo((G,B)=>{var ie,te,ne,de,re,pe;let A=s(G);if(!A)return null;let C=M(G),k=(ne=(te=(ie=A.measured)==null?void 0:ie.width)!=null?te:A.width)!=null?ne:0,P=(pe=(re=(de=A.measured)==null?void 0:de.height)!=null?re:A.height)!=null?pe:0,K=Math.abs(C.x+k-B.x),Z=Math.abs(B.x-C.x),Y=Math.abs(C.y+P-B.y),H=Math.abs(B.y-C.y),q={right:K,left:Z,bottom:Y,top:H},z=Object.entries(q).reduce((j,[se,he])=>he<j[1]?[se,he]:j,["right",q.right])[0],X=_.current;if(X&&X!==z){let j=q[z],se=q[X],he=Math.abs(se-j),Ye=Math.min(Math.abs(se),Math.abs(j));he<Ye*gx&&(z=X)}let U=z,W,oe;if(U==="right"||U==="left"){let se=(Math.max(C.y,Math.min(C.y+P,B.y))-C.y)/(P||1);Math.abs(se-.5)<Dd&&(se=.5),oe=se,W={x:U==="right"?C.x+k:C.x,y:C.y+oe*P}}else{let se=(Math.max(C.x,Math.min(C.x+k,B.x))-C.x)/(k||1);Math.abs(se-.5)<Dd&&(se=.5),oe=se,W={x:C.x+oe*k,y:U==="bottom"?C.y+P:C.y}}return{side:U,snapPosition:W,offset:oe}},[s,M]),O=xo(G=>{var K;let B=N.current;if(!B)return;let A=l({x:G.clientX,y:G.clientY}),C=L(A);h(C);let k=A,P=null;if(C){let Z=D(C,A);Z&&(P=Z.side,k=Z.snapPosition,_.current=P);let Y={source:B==="source"?C:w.current,target:B==="target"?C:S.current,sourceHandle:null,targetHandle:null},H=(K=u==null?void 0:u(Y))!=null?K:!0;b(H)}else _.current=null,b(!1);y(P),E(k)},[L,D,l,u]),R=xo(G=>{var P;let B=N.current;if(!B)return;let A=l({x:G.clientX,y:G.clientY}),C=L(A);if(C){let K={source:B==="source"?C:w.current,target:B==="target"?C:S.current,sourceHandle:null,targetHandle:null};((P=u==null?void 0:u(K))==null||P)&&i(Z=>Z.map(Y=>Y.id===e?I(T({},Y),{source:K.source,target:K.target,sourceHandle:void 0,targetHandle:void 0,data:I(T({},Y.data),{controlPoint:void 0})}):Y))}f(null),E(null),h(null),y(null),c(!1),b(!1),d(null),_.current=null,document.removeEventListener("mouseup",R),document.removeEventListener("mousemove",O);let k=Je.get(n);k==null||k.clearReconnectingEdge()},[e,L,i,n,O,u,l,c,d]),V=xo((G,B)=>{if(r||B.button!==0)return;B.stopPropagation(),B.preventDefault(),f(G),d(e);let A=Je.get(n);A==null||A.setReconnectingEdge(e),document.addEventListener("mousemove",O),document.addEventListener("mouseup",R)},[r,e,n,O,R,d]);return ps(()=>()=>{if(N.current){document.removeEventListener("mousemove",O),document.removeEventListener("mouseup",R),d(null);let G=Je.get(n);G==null||G.clearReconnectingEdge()}},[n,O,R,d]),{reconnectingHandle:p,cursorPosition:x,hoveredNodeId:m,reconnectingSide:g,isValidReconnection:v,handleReconnectStart:V}};import{useReactFlow as yx}from"@xyflow/react";import{useCallback as xx,useRef as Ex}from"react";var Et={TOLERANCE:1,MAX_LABEL_DISTANCE:80,BEND_HANDLE_HIT_RADIUS:24};import{Position as cD}from"@xyflow/react";var on=(e,t,o,n=1)=>Math.abs(e[o]-t[o])<n,Vr=(e,t)=>Math.sqrt((t.x-e.x)**2+(t.y-e.y)**2),fs=(e,t)=>({x:(e.x+t.x)/2,y:(e.y+t.y)/2}),hx=(e,t,o)=>{let n=o.x-t.x,r=o.y-t.y,i=n*n+r*r;if(i===0)return Vr(e,t);let s=Math.max(0,Math.min(1,((e.x-t.x)*n+(e.y-t.y)*r)/i));return Vr(e,{x:t.x+s*n,y:t.y+s*r})},Hr=(e,t)=>{let o=1/0;for(let n=0;n<t.length-1;n++)o=Math.min(o,hx(e,t[n],t[n+1]));return o},kd=e=>{let t=0;for(let r=0;r<e.length-1;r++)t+=Vr(e[r],e[r+1]);let o=t/2,n=0;for(let r=0;r<e.length-1;r++){let i=Vr(e[r],e[r+1]);if(n+i>=o){let s=i===0?0:(o-n)/i,a=e[r],l=e[r+1];return{x:a.x+(l.x-a.x)*s,y:a.y+(l.y-a.y)*s}}n+=i}return fs(e[0],e.at(-1))};var{MAX_LABEL_DISTANCE:_x}=Et,Rd=3;function Od({edgeId:e,isEditing:t,isViewOrReadOnly:o,zoom:n,label:r,labelOffset:i,pathPoints:s,pathCenter:a}){let{updateEdgeData:l}=yx(),c=Ex(i);return xx(d=>{var v,b;if(t||o||d.button!==0||!(r!=null&&r.trim()))return;d.stopPropagation(),d.preventDefault();let u=d.clientX,p=d.clientY,f=(v=i==null?void 0:i.x)!=null?v:0,x=(b=i==null?void 0:i.y)!=null?b:0,E=[...s],m={x:a.x,y:a.y},h=!1,g=N=>{let _=(N.clientX-u)/n,w=(N.clientY-p)/n;if(!h&&Math.abs(_)<Rd&&Math.abs(w)<Rd)return;h=!0;let S={x:f+_,y:x+w};c.current=S,l(e,{labelOffset:S})},y=()=>{document.removeEventListener("mousemove",g),document.removeEventListener("mouseup",y);let N=c.current;if(!N)return;let _={x:m.x+N.x,y:m.y+N.y};Hr(_,E)>_x&&(c.current=void 0,l(e,{labelOffset:void 0}))};document.addEventListener("mousemove",g),document.addEventListener("mouseup",y)},[t,o,n,r,i,e,l,s,a])}import{useInternalNode as Hd,useReactFlow as vx}from"@xyflow/react";import{useCallback as Nx,useMemo as Gd,useState as wx}from"react";var{TOLERANCE:Gr}=Et,Vd=(e,t)=>Math.sqrt(Math.pow(t.x-e.x,2)+Math.pow(t.y-e.y,2));function bx(e,t,o){return on(e,t,"x",Gr)&&on(t,o,"x",Gr)||on(e,t,"y",Gr)&&on(t,o,"y",Gr)}function Tx(e,t,o,n){if(bx(e,t,o))return`L${t.x} ${t.y}`;let r=Vd(e,t),i=Vd(t,o),s=Math.min(r/2,i/2,n);if(s<1)return`L${t.x} ${t.y}`;let a=e.x-t.x,l=e.y-t.y,c=o.x-t.x,d=o.y-t.y,u={x:a/r,y:l/r},p={x:c/i,y:d/i},f={x:t.x+u.x*s,y:t.y+u.y*s},x={x:t.x+p.x*s,y:t.y+p.y*s},E=-u.x,m=-u.y,h=p.x,g=p.y,v=E*g-m*h>0?1:0;return`L${f.x} ${f.y}A${s} ${s} 0 0 ${v} ${x.x} ${x.y}`}var Br=(e,t=5)=>e.length<2?"":e.reduce((o,n,r)=>{let i="";return r>0&&r<e.length-1?i=Tx(e[r-1],n,e[r+1],t):i=`${r===0?"M":"L"}${n.x} ${n.y}`,o+=i,o},"");var Bd=({id:e,source:t,target:o,controlPoint:n,fixedSourcePoint:r,fixedTargetPoint:i})=>{let s=Hd(t),a=Hd(o),{updateEdgeData:l,screenToFlowPosition:c}=vx(),{mode:d}=$(),[u,p]=wx(!1),f=Nx(E=>{if(d!=="edit"||E.button!==0)return;E.stopPropagation(),E.preventDefault(),p(!0);let m=g=>{let y=c({x:g.clientX,y:g.clientY});l(e,{controlPoint:{x:Math.round(y.x),y:Math.round(y.y)}})},h=()=>{p(!1),document.removeEventListener("mousemove",m),document.removeEventListener("mouseup",h)};document.addEventListener("mousemove",m),document.addEventListener("mouseup",h)},[d,c,e,l]),x=Gd(()=>{if(!s||!a)return null;let E=at({source:et(s),target:et(a),controlPoint:n,fixedSourcePoint:r,fixedTargetPoint:i}),{points:m}=E,h=m[1],g=m.at(-2);return{sourceNode:s,targetNode:a,points:m,svgPath:Br(m),sourcePoint:E.sourcePoint,targetPoint:E.targetPoint,direction:E.direction,bendPoint:fs(h,g),pathCenter:kd(m)}},[s,a,n,r,i]);return Gd(()=>x?I(T({},x),{isDraggingBend:u,onBendDragStart:f}):null,[x,u,f])};import{jsx as ms,jsxs as Ax}from"react/jsx-runtime";var{BEND_HANDLE_HIT_RADIUS:Ix}=Et,zd=({bendPoint:e,zoom:t,isDragging:o,onMouseDown:n})=>Ax("g",{className:"pointer-events-auto cursor-move",onMouseDown:n,children:[ms("circle",{cx:e.x,cy:e.y,r:Ix/t,fill:"transparent"}),ms("circle",{cx:e.x,cy:e.y,r:4/t,fill:o?"#3b82f6":"#fff",stroke:"#3b82f6",strokeWidth:2/t,className:"pointer-events-none"}),ms("circle",{cx:e.x,cy:e.y,r:6/t,fill:"none",stroke:"#3b82f6",strokeWidth:1/t,opacity:o?.6:.3,className:"pointer-events-none"})]});import{jsx as nn}from"react/jsx-runtime";var Eo=i=>{var s=i,{edgeId:e,edgeType:t,sourceNode:o,targetNode:n}=s,r=Ue(s,["edgeId","edgeType","sourceNode","targetNode"]);let{mode:a}=$(),{isFromStartEvent:l,isGatewayToGateway:c,isActiviyToAndGateway:d,isToEndEvent:u}=Mn(o,n),p=!l&&!c&&!d&&!u,f=[{component:nn(Cr,{elementId:e,elementType:"edge"})}],x=()=>a==="view"?p?[{component:nn(xt,{elementId:e,elementType:"edge"})}]:[]:p?[{component:nn(xt,{elementId:e,elementType:"edge"})},...f]:f,m=(h=>{switch(h){case"SEQUENCE_EDGE":return x();case"MESSAGE_EDGE":return a==="view"?[]:[...f];case"ANNOTATION_EDGE":return a==="view"?[]:[...f];default:return[]}})(t);if(!(m.length===0||a==="readonly"))return nn("div",I(T({className:"flex items-center gap-1 w-fit px-3 py-2 bg-white rounded-sm shadow-md"},r),{children:m.map((h,g)=>nn("div",{children:h.component},g))}))};import{useViewport as Cx}from"@xyflow/react";import{useMemo as Sx}from"react";import{jsx as Fd}from"react/jsx-runtime";var Qe=12,_o=({sx:e,sy:t,tx:o,ty:n,hasLabel:r=!1,children:i})=>{let{zoom:s}=Cx(),a=1/s,l=Sx(()=>t===n?{bottom:`${Qe}px`,transform:"translateX(-50%)"}:e===o?{left:`${Qe}px`,transform:r?"translateY(-100%)":"translateY(-50%)"}:n>t&&o>e?{left:`${Qe}px`,bottom:`${Qe}px`}:n>t&&o<e?{right:`${Qe}px`,bottom:`${Qe}px`}:t>n&&o>e?{right:`${Qe}px`,bottom:`${Qe}px`}:{left:`${Qe}px`,bottom:`${Qe}px`},[e,t,o,n,r]);return Fd("div",{style:{transform:`scale(${a})`},children:Fd("div",{className:"absolute pointer-events-auto",style:T({},l),children:i})})};import{jsx as zr,jsxs as Mx}from"react/jsx-runtime";var gs=({x:e,y:t,zoom:o,handleType:n,reconnectingHandle:r,hoveredNodeId:i,isValidReconnection:s,onMouseDown:a})=>{let l=r===n,c=l?i&&!s?"cursor-not-allowed":"cursor-grabbing":"cursor-move";return zr("div",{className:"absolute z-[10000] pointer-events-none",style:{transform:`translate(-50%, -50%) translate(${e}px, ${t}px)`},children:Mx("svg",{width:12/o,height:12/o,style:{overflow:"visible",position:"absolute",left:"50%",top:"50%",transform:"translate(-50%, -50%)"},children:[zr("circle",{cx:6/o,cy:6/o,r:4/o,fill:l?"#3b82f6":"#fff",stroke:"#3b82f6",strokeWidth:2/o,className:"pointer-events-none"}),zr("circle",{cx:6/o,cy:6/o,r:6/o,fill:"none",stroke:"#3b82f6",strokeWidth:1/o,opacity:l?.6:.3,className:"pointer-events-none"}),zr("circle",{cx:6/o,cy:6/o,r:8/o,fill:"transparent",className:F("pointer-events-auto",c),onMouseDown:a})]})})};import{useReactFlow as Px}from"@xyflow/react";import{jsx as Yd}from"react/jsx-runtime";var Wd=({edgeId:e,label:t,labelOffset:o,pathCenter:n,isEditing:r,isViewOrReadOnly:i,onSetEditing:s,onLabelDragStart:a})=>{var d,u;let{updateEdgeData:l}=Px(),c=!r&&!i&&!!(t!=null&&t.trim());return!r&&!(t!=null&&t.trim())?null:Yd("div",{className:F("absolute nodrag nopan",c?"z-[10001] pointer-events-auto":"z-[3000] pointer-events-none"),style:{transform:`translate(-50%, -50%) translate(${n.x+((d=o==null?void 0:o.x)!=null?d:0)}px, ${n.y+((u=o==null?void 0:o.y)!=null?u:0)}px)`,cursor:c?"move":void 0},onMouseDown:c?a:void 0,onDoubleClick:p=>{i||(p.stopPropagation(),s(!0))},children:Yd(ye,{value:t,className:F("min-w-8 max-w-56 px-2 py-1 body-small-400",{"pointer-events-auto":r,"pointer-events-none":!r}),isEditing:r,onBlur:()=>s(!1),onChange:p=>l(e,{label:p.trim()})})})};import{Fragment as Xd,jsx as ct,jsxs as rn}from"react/jsx-runtime";var Hx={x:0,y:0};function Gx(e,t,o,n,r){return F("stroke-2 stroke-current transition-[stroke] duration-75",{"group-hover:stroke-[2.5px]":!e,"stroke-red-500 hover:stroke-red-600":o||n,"stroke-green-500":r,"stroke-blue-500 hover:stroke-blue-600 stroke-[3px]":t&&!o})}var hs=Rx.memo(({id:e,source:t,target:o,data:n,selected:r})=>{var A,C;let{zoom:i}=kx(),{isReadOnly:s,mode:a,instanceId:l,edgeHighlight:c}=$(),d=Ze(),[u,p]=Vx(!1),f=a!=="edit",{reconnectingHandle:x,cursorPosition:E,hoveredNodeId:m,isValidReconnection:h,handleReconnectStart:g}=Or({edgeId:e,source:t,target:o,instanceId:l,isReadOnly:f}),y=Bd({id:e,source:t,target:o,controlPoint:n==null?void 0:n.controlPoint,fixedSourcePoint:x==="source"?E:void 0,fixedTargetPoint:x==="target"?E:void 0}),v=Ox(()=>{var k;return(k=y==null?void 0:y.points)!=null?k:[]},[y]),b=(A=y==null?void 0:y.pathCenter)!=null?A:Hx,N=Od({edgeId:e,isEditing:u,isViewOrReadOnly:f,zoom:i,label:n==null?void 0:n.label,labelOffset:n==null?void 0:n.labelOffset,pathPoints:v,pathCenter:b});if(!y)return null;let{sourceNode:_,targetNode:w,svgPath:S,sourcePoint:M,targetPoint:L}=y,D=c&&(r||_.selected||w.selected),O=r&&!d&&!f,R=!!((C=n==null?void 0:n.label)!=null&&C.trim()),V=!u&&!f&&R,G=!!x&&!!m&&!h,B=!!x&&!!m&&h;return rn(Xd,{children:[rn("g",{className:F("group bpmn-arrow-edge",{"is-highlighted":D}),onDoubleClick:()=>!f&&p(!0),children:[ct("path",{d:S,fill:"none",stroke:"transparent",strokeWidth:Math.max(12,12/i),className:F({"nopan nodrag":V}),style:{pointerEvents:"stroke",cursor:V?"move":"pointer"},onMouseDown:N}),rn("g",{className:F("text-grey-500 transition-colors duration-75",{"group-hover:text-grey-800":!s,"text-blue-500 group-hover:text-blue-600":D}),children:[ct(Lx,{id:e,path:S,interactionWidth:0,markerEnd:`url(#${D?"sequence-edge-marker-highlighted":"sequence-edge-marker"})`,className:Gx(s,!!D,n==null?void 0:n.hasError,G,B)}),O&&!x&&ct(zd,{bendPoint:y.bendPoint,zoom:i,isDragging:y.isDraggingBend,onMouseDown:y.onBendDragStart})]})]}),rn(Dx,{children:[ct("div",{className:"absolute z-[3000] pointer-events-none flex flex-col items-center gap-1",style:{transform:`translate(-50%, -50%) translate(${b.x}px, ${b.y}px)`},children:r&&!d&&ct(_o,{sx:M.x,sy:M.y,tx:L.x,ty:L.y,hasLabel:R,children:ct(Eo,{edgeId:e,edgeType:"SEQUENCE_EDGE",sourceNode:_,targetNode:w})})}),ct(Wd,{edgeId:e,label:n==null?void 0:n.label,labelOffset:n==null?void 0:n.labelOffset,pathCenter:b,isEditing:u,isViewOrReadOnly:f,onSetEditing:p,onLabelDragStart:N}),O&&rn(Xd,{children:[ct(gs,{x:M.x,y:M.y,zoom:i,handleType:"source",reconnectingHandle:x,hoveredNodeId:m,isValidReconnection:h,onMouseDown:k=>g("source",k.nativeEvent)}),ct(gs,{x:L.x,y:L.y,zoom:i,handleType:"target",reconnectingHandle:x,hoveredNodeId:m,isValidReconnection:h,onMouseDown:k=>g("target",k.nativeEvent)})]})]})]})});hs.displayName="SequenceEdge";import{BaseEdge as Bx,EdgeLabelRenderer as zx,getSmoothStepPath as Fx,MarkerType as Yx,useInternalNode as Ud,useReactFlow as Wx,useViewport as Xx,Position as bo}from"@xyflow/react";import{useState as Ux,useMemo as $x}from"react";import{Fragment as Kx,jsx as Le,jsxs as Bt}from"react/jsx-runtime";var Ck={type:"MESSAGE_EDGE",reconnectable:!0,markerEnd:{type:Yx.Arrow},data:{label:""}},$d=({id:e,source:t,target:o,data:n,selected:r,sourcePosition:i,targetPosition:s,sourceHandleId:a,targetHandleId:l})=>{var Z;let{zoom:c}=Xx(),{updateEdgeData:d}=Wx(),{mode:u,instanceId:p}=$(),f=Ze(),x=u!=="edit",[E,m]=Ux(!1),{reconnectingHandle:h,cursorPosition:g,hoveredNodeId:y,reconnectingSide:v,isValidReconnection:b,handleReconnectStart:N}=Or({edgeId:e,source:t,target:o,instanceId:p,isReadOnly:x}),_=Ud(t),w=Ud(o),{sx:S,sy:M,tx:L,ty:D,sourcePos:O,targetPos:R}=$x(()=>{var ne,de;if(!_||!w)return{sx:0,sy:0,tx:0,ty:0,sourcePos:bo.Left,targetPos:bo.Right};let Y=Sn(_,w),H=a?i:Y.sourcePos,q=l?s:Y.targetPos,z=(re,pe,j)=>{var mn,gn,hn,yn,fi,mi;let{x:se,y:he}=re.internals.positionAbsolute,Ye=(hn=(gn=(mn=re.measured)==null?void 0:mn.width)!=null?gn:re.width)!=null?hn:0,Nt=(mi=(fi=(yn=re.measured)==null?void 0:yn.height)!=null?fi:re.height)!=null?mi:0;switch(pe){case bo.Top:return{x:se+Ye*j,y:he};case bo.Bottom:return{x:se+Ye*j,y:he+Nt};case bo.Left:return{x:se,y:he+Nt*j};case bo.Right:return{x:se+Ye,y:he+Nt*j};default:return{x:se+Ye/2,y:he+Nt/2}}},X=(ne=n==null?void 0:n.sourceOffset)!=null?ne:.5,U=(de=n==null?void 0:n.targetOffset)!=null?de:.5,W=_?z(_,H,X).x:Y.sx,oe=_?z(_,H,X).y:Y.sy,ie=w?z(w,q,U).x:Y.tx,te=w?z(w,q,U).y:Y.ty;return h==="source"&&g?(W=g.x,oe=g.y,v&&(H=v)):h==="target"&&g&&(ie=g.x,te=g.y,v&&(q=v)),{sx:W,sy:oe,tx:ie,ty:te,sourcePos:H,targetPos:q}},[_,w,a,l,i,s,h,g,v,n==null?void 0:n.sourceOffset,n==null?void 0:n.targetOffset]);if(!_||!w)return null;let[V,G,B]=Fx({sourceX:S,sourceY:M,targetX:L,targetY:D,sourcePosition:O,targetPosition:R}),A=r||(_==null?void 0:_.selected)||(w==null?void 0:w.selected),C=A?"sequence-edge-marker-highlighted":"sequence-edge-marker",k=E||(n==null?void 0:n.label.trim().length)>0,P=()=>{m(!1)},K=Y=>{d(e,{label:Y.trim()})};return Bt("g",{className:F("group bpmn-arrow-edge",{"is-highlighted":A}),onDoubleClick:()=>!x&&m(!0),children:[Le("path",{d:V,fill:"none",stroke:"transparent",strokeWidth:Math.max(12,12/c),style:{pointerEvents:"stroke",cursor:"pointer"}}),Bt("g",{className:F("text-grey-500 transition-colors duration-75 group-hover:text-grey-800",{"text-blue-500 group-hover:text-blue-600":A}),children:[Le(Bx,{id:e,path:V,interactionWidth:0,markerEnd:`url(#${C})`,strokeDasharray:4,className:F("stroke-2 stroke-current transition-[stroke] duration-75 group-hover:stroke-[2.5px]",{"stroke-red-500 hover:stroke-red-600":(n==null?void 0:n.hasError)||h&&y&&!b,"stroke-green-500":h&&y&&b,"stroke-blue-500 hover:stroke-blue-600 stroke-[3px]":A&&!(n!=null&&n.hasError)&&!h})}),Bt(zx,{children:[Bt("div",{className:"absolute z-[3000] pointer-events-auto flex flex-col items-center gap-1",style:{transform:`translate(-50%, -50%) translate(${G}px, ${B}px)`},children:[r&&!f&&Le(_o,{sx:S,sy:M,tx:L,ty:D,hasLabel:!!((Z=n==null?void 0:n.label)!=null&&Z.trim()),children:Le(Eo,{edgeId:e,edgeType:"MESSAGE_EDGE"})}),k&&Le(ye,{value:n==null?void 0:n.label,className:"min-w-8 max-w-56 bg-white rounded-md px-2 py-1 text-xs",isEditing:E,onBlur:P,onChange:K})]}),r&&!f&&!x&&Bt(Kx,{children:[Le("div",{className:"absolute z-[1000] pointer-events-none",style:{transform:`translate(-50%, -50%) translate(${S}px, ${M}px)`},children:Bt("svg",{width:12/c,height:12/c,style:{overflow:"visible",position:"absolute",left:"50%",top:"50%",transform:"translate(-50%, -50%)"},children:[Le("circle",{cx:6/c,cy:6/c,r:4/c,fill:h==="source"?"#3b82f6":"#fff",stroke:"#3b82f6",strokeWidth:2/c,className:"pointer-events-none"}),Le("circle",{cx:6/c,cy:6/c,r:6/c,fill:"none",stroke:"#3b82f6",strokeWidth:1/c,opacity:h==="source"?.6:.3,className:"pointer-events-none"}),Le("circle",{cx:6/c,cy:6/c,r:8/c,fill:"transparent",className:F("pointer-events-auto",{"cursor-move":!h||h!=="source","cursor-not-allowed":h==="source"&&y&&!b,"cursor-grabbing":h==="source"&&(!y||b)}),onMouseDown:Y=>N("source",Y.nativeEvent)})]})}),Le("div",{className:"absolute z-[1000] pointer-events-none",style:{transform:`translate(-50%, -50%) translate(${L}px, ${D}px)`},children:Bt("svg",{width:12/c,height:12/c,style:{overflow:"visible",position:"absolute",left:"50%",top:"50%",transform:"translate(-50%, -50%)"},children:[Le("circle",{cx:6/c,cy:6/c,r:4/c,fill:h==="target"?"#3b82f6":"#fff",stroke:"#3b82f6",strokeWidth:2/c,className:"pointer-events-none"}),Le("circle",{cx:6/c,cy:6/c,r:6/c,fill:"none",stroke:"#3b82f6",strokeWidth:1/c,opacity:h==="target"?.6:.3,className:"pointer-events-none"}),Le("circle",{cx:6/c,cy:6/c,r:8/c,fill:"transparent",className:F("pointer-events-auto",{"cursor-move":!h||h!=="target","cursor-not-allowed":h==="target"&&y&&!b,"cursor-grabbing":h==="target"&&(!y||b)}),onMouseDown:Y=>N("target",Y.nativeEvent)})]})})]})]})]})]})};import{BaseEdge as qx,EdgeLabelRenderer as Zx,getStraightPath as Jx,useInternalNode as Kd,useReactFlow as Qx,useViewport as jx}from"@xyflow/react";import{useCallback as e0,useMemo as Fr,useRef as t0,useState as o0}from"react";import{jsx as zt,jsxs as ys}from"react/jsx-runtime";var{MAX_LABEL_DISTANCE:n0}=Et,qd=({id:e,source:t,target:o,selected:n,data:r})=>{var D,O,R,V,G,B,A,C,k,P;let{isReadOnly:i,edgeHighlight:s,mode:a}=$(),l=Ze(),{zoom:c}=jx(),{updateEdgeData:d}=Qx(),[u,p]=o0(!1),f=t0(r==null?void 0:r.labelOffset),x=a!=="edit",E=Kd(t),m=Kd(o),{sx:h,sy:g,tx:y,ty:v}=Fr(()=>E&&m?Sn(E,m):{sx:0,sy:0,tx:0,ty:0},[E,m]),[b,N,_]=Fr(()=>Jx({sourceX:h,sourceY:g,targetX:y,targetY:v}),[h,g,y,v]),w=Fr(()=>[{x:h,y:g},{x:y,y:v}],[h,g,y,v]),S=Fr(()=>({x:N,y:_}),[N,_]),M=e0(K=>{var ie,te,ne,de,re;if(u||x||K.button!==0||!((ie=r==null?void 0:r.label)!=null&&ie.trim()))return;K.stopPropagation(),K.preventDefault();let Z=K.clientX,Y=K.clientY,H=(ne=(te=r==null?void 0:r.labelOffset)==null?void 0:te.x)!=null?ne:0,q=(re=(de=r==null?void 0:r.labelOffset)==null?void 0:de.y)!=null?re:0,z=[...w],X={x:S.x,y:S.y},U=!1,W=pe=>{let j=(pe.clientX-Z)/c,se=(pe.clientY-Y)/c;if(!U&&Math.abs(j)<3&&Math.abs(se)<3)return;U=!0;let he={x:H+j,y:q+se};f.current=he,d(e,{labelOffset:he})},oe=()=>{document.removeEventListener("mousemove",W),document.removeEventListener("mouseup",oe);let pe=f.current;if(!pe)return;let j={x:X.x+pe.x,y:X.y+pe.y};Hr(j,z)>n0&&(f.current=void 0,d(e,{labelOffset:void 0}))};document.addEventListener("mousemove",W),document.addEventListener("mouseup",oe)},[u,x,c,r,e,d,w,S]);if(!E||!m)return null;let L=s&&(n||(E==null?void 0:E.selected)||(m==null?void 0:m.selected));return ys("g",{className:F("group bpmn-edge",{"is-highlighted":L}),onDoubleClick:()=>!x&&p(!0),children:[zt("path",{d:b,fill:"none",stroke:"transparent",strokeWidth:Math.max(12,12/c),className:F({"nopan nodrag":!u&&!x&&!!((D=r==null?void 0:r.label)!=null&&D.trim())}),style:{pointerEvents:"stroke",cursor:!u&&!x&&((O=r==null?void 0:r.label)!=null&&O.trim())?"move":"pointer"},onMouseDown:M}),ys("g",{className:F("text-grey-500 transition-colors duration-75",{"group-hover:text-grey-800":!i,"text-blue-500 group-hover:text-blue-600":L}),children:[zt(qx,{id:e,path:b,interactionWidth:0,strokeDasharray:4,className:F("stroke-2 stroke-current transition-[stroke] duration-75 group-hover:stroke-[2.5px]",{"stroke-red-500 hover:stroke-red-600":r==null?void 0:r.hasError,"stroke-blue-500 hover:stroke-blue-600 stroke-[3px]":L&&!(r!=null&&r.hasError)})}),ys(Zx,{children:[zt("div",{className:"absolute z-[3000] pointer-events-none flex flex-col items-center gap-1",style:{transform:`translate(-50%, -50%) translate(${N}px, ${_}px)`},children:n&&!l&&zt(_o,{sx:h,sy:g,tx:y,ty:v,children:zt(Eo,{edgeId:e,edgeType:"ANNOTATION_EDGE"})})}),(u||((R=r==null?void 0:r.label)==null?void 0:R.trim()))&&zt("div",{className:F("absolute nodrag nopan",!u&&!x&&((V=r==null?void 0:r.label)!=null&&V.trim())?"z-[10001] pointer-events-auto":"z-[3000] pointer-events-none"),style:{transform:`translate(-50%, -50%) translate(${S.x+((B=(G=r==null?void 0:r.labelOffset)==null?void 0:G.x)!=null?B:0)}px, ${S.y+((C=(A=r==null?void 0:r.labelOffset)==null?void 0:A.y)!=null?C:0)}px)`,cursor:!u&&!x&&((k=r==null?void 0:r.label)!=null&&k.trim())?"move":void 0},onMouseDown:!u&&!x?M:void 0,onDoubleClick:K=>{x||(K.stopPropagation(),p(!0))},children:zt(ye,{value:(P=r==null?void 0:r.label)!=null?P:"",className:F("min-w-8 max-w-56 px-2 py-1 body-small-400",{"pointer-events-auto":u,"pointer-events-none":!u}),isEditing:u,onBlur:()=>p(!1),onChange:K=>d(e,{label:K.trim()})})})]})]})]})};import{getStraightPath as Zd,useReactFlow as r0}from"@xyflow/react";import{jsx as To,jsxs as xs}from"react/jsx-runtime";var Jd=({toX:e,toY:t,fromNode:o})=>{let{getNodes:n,getInternalNode:r}=r0();if(!o)return null;let i=et(o),s=n().map(u=>r(u.id)).filter(u=>u!=null).find(u=>{var m,h,g,y;let{x:p,y:f}=u.internals.positionAbsolute,x=(h=(m=u.measured)==null?void 0:m.width)!=null?h:0,E=(y=(g=u.measured)==null?void 0:g.height)!=null?y:0;return e>=p&&e<=p+x&&t>=f&&t<=f+E});if(!s){let u=at({source:i,target:{bounds:{x:e,y:t,width:0,height:0},perimeter:"rectangle"}}),[p]=Zd({sourceX:u.sourcePoint.x,sourceY:u.sourcePoint.y,targetX:e,targetY:t});return xs("g",{className:"group",children:[To("path",{fill:"none",className:"stroke-2 stroke-grey-500 animated transition-[stroke,filter] duration-75",d:p}),To("circle",{cx:e,cy:t,fill:"none",r:4,className:"stroke-2 stroke-grey-600"})]})}let a=et(s);if(o.type==="ANNOTATION"||s.type==="ANNOTATION"){let u=at({source:i,target:a}),[p]=Zd({sourceX:u.sourcePoint.x,sourceY:u.sourcePoint.y,targetX:u.targetPoint.x,targetY:u.targetPoint.y});return xs("g",{className:"group",children:[To("path",{fill:"none",strokeDasharray:4,className:"stroke-2 stroke-grey-500 animated transition-[stroke,filter] duration-75",d:p}),To("circle",{cx:u.targetPoint.x,cy:u.targetPoint.y,fill:"none",r:4,className:"stroke-2 stroke-grey-600"})]})}let c=at({source:i,target:a}),d=Br(c.points);return xs("g",{className:"group",children:[To("path",{fill:"none",className:"stroke-2 stroke-grey-500 animated transition-[stroke,filter] duration-75",d}),To("circle",{cx:c.targetPoint.x,cy:c.targetPoint.y,fill:"none",r:4,className:"stroke-2 stroke-grey-600"})]})};var Qd={START_EVENT:bd,END_EVENT:_d,TASK:ds,GATEWAY:as,ANNOTATION:Ed,LANE:us,UNSUPPORTED:Ld},jd={SEQUENCE_EDGE:hs,MESSAGE_EDGE:$d,ANNOTATION_EDGE:qd},eu="#fafafa",tu="#bebebe",ou=1,nu=10,ru="bottom-left",Es=.05,iu=5,su=150,au=100,lu=Es,cu=1,du={x:0,y:0,zoom:.75},uu=1,pu=2,i0={[uu]:4,[pu]:2},sn=[uu,pu],fu=[0,1,2],mu={hideAttribution:!0},_s=sn.reduce((e,t)=>e|i0[t],0);var _t=()=>{let{setViewport:e}=s0(),t=a0();return{fitToNodes:l0(n=>{let{width:r,height:i}=t.getState();if(i<=0||r<=0)return;let s=ha(n);if(!s)return;let a=ya({bounds:s,canvasHeight:i,canvasWidth:r,minZoom:lu,maxZoom:cu,offsetX:su,offsetY:au});e(a)},[t,e])}};import{useReactFlow as c0}from"@xyflow/react";var Be=()=>{let{getEdges:e,getNodes:t}=c0(),{lastElementId:o}=$(),n=()=>{let i=t(),s=e(),a=Lc(i,s);return Math.max(a,o)};return{getLastId:n,getNextId:()=>n()+1}};var bt=()=>{let{getNodes:e,getEdges:t,setNodes:o,setEdges:n}=d0(),{getLastId:r}=Be(),{fitToNodes:i}=_t(),{setLastElementId:s}=$(),a=gu(async(c="")=>{let{nodes:d,edges:u,lastElementId:p}=await $c(c);i(d),o(d),n(u),s(p)},[o,n,s,i]),l=gu(()=>{let c=e(),d=t(),u=r();return Uc(c,d,u)},[e,t,r]);return{importFromMxGraph:a,exportToMxGraph:l}};var f0=500,Yr=()=>{let{isInitialized:e,onElementChanges:t}=$(),{exportToMxGraph:o}=bt(),n=p0(()=>{if(!e)return;let s=o();t==null||t(s)},f0);u0(()=>()=>{n.isPending()&&n.flush()},[n]);let r=hu(s=>{s.every(c=>c.type==="select")||s.some(c=>c.type==="position"&&c.dragging)||n()},[n]),i=hu(s=>{s.some(l=>l.type==="select")||n()},[n]);return{emitElementChanges:n,handleNodeChanges:r,handleEdgeChanges:i}};var yu=({setEdges:e,saveHistory:t})=>{let{getNode:o,getEdges:n,getNodes:r,getInternalNode:i}=g0(),{emitElementChanges:s}=Yr(),a=h0(null),{getNextId:l}=Be(),c=Ft(m=>{var b;let h=o(m.source),g=o(m.target);if(!h||!g)return!1;let y={sourceNodeId:h.id,targetNodeId:g.id,sourceNodeType:h.type,targetNodeType:g.type,nodes:r(),edges:n(),reconnectingEdgeId:(b=a.current)!=null?b:void 0};return Yi(y).isValid},[o,n,r]),d=Ft(m=>{let h=l(),g=i(m.source);if(g){let y=i(m.target),v=(y==null?void 0:y.type)==="ANNOTATION"||(g==null?void 0:g.type)==="ANNOTATION",b=v?ro:Ve,N=I(T(T({},m),b),{id:String(h),sourceHandle:void 0,targetHandle:void 0,data:T({},v?{}:Ve.data)}),_=n().concat(N);e(_),t("forceSave",{nodes:r(),edges:_}),s()}},[l,e,s,i,n,r,t]),u=Ft((m,h)=>{a.current=h.id},[]),p=Ft(()=>{a.current=null},[]),f=Ft((m,h)=>{let g=o(h.source),y=o(h.target);if(!g||!y){a.current=null;return}let v={sourceNodeId:g.id,targetNodeId:y.id,sourceNodeType:g.type,targetNodeType:y.type,nodes:r(),edges:n(),reconnectingEdgeId:m.id};if(!Yi(v).isValid){a.current=null;return}let N=m0(m,h,n()).map(_=>_.id===m.id?I(T({},_),{data:I(T({},_.data),{controlPoint:void 0})}):_);e(N),t("forceSave",{nodes:r(),edges:N}),a.current=null,s()},[o,r,n,e,s,t]),x=Ft(m=>{a.current=m},[]),E=Ft(()=>{a.current=null},[]);return{isValidConnection:c,onConnect:d,onReconnect:f,onReconnectStart:u,onReconnectEnd:p,setReconnectingEdge:x,clearReconnectingEdge:E}};import{Typography as Iu,useTranslation as x0}from"@produto-lecom/lecom-ui";import{useReactFlow as E0}from"@xyflow/react";import{useCallback as vo,useRef as bs,useState as _0}from"react";var an=(e=[])=>e.filter(t=>t.type==="START_EVENT"),Yt=(e=[])=>e.filter(t=>t.type==="END_EVENT"),Tt=(e=[])=>e.filter(t=>t.type==="TASK")||[],xu=(e=[])=>e.filter(t=>{var o;return t.type==="TASK"&&((o=t.properties)==null?void 0:o.variant)==="SCRIPT"});var Wr=(e=[])=>e.filter(t=>t.type==="GATEWAY"),Eu=(e=[])=>e.filter(t=>{var o;return t.type==="GATEWAY"&&((o=t.properties)==null?void 0:o.variant)==="EXCLUSIVE"}),De=(e,t=[])=>t.filter(o=>o.source===e),ln=(e,t=[])=>t.filter(o=>o.target===e),_u=(e,t)=>{var n,r;let o=(n=t.nodes)==null?void 0:n.find(i=>i.id===e);return((r=o==null?void 0:o.properties)==null?void 0:r.attribute)==="LOOP"},bu=(e,t)=>{let o=De(e,t.edges||[]);for(let n of o){let r=(t.nodes||[]).find(i=>i.id===n.target);if(r&&r.type==="END_EVENT")return!0}return!1},Tu=e=>e?/[^\s]/.test(e.trim()):!1,ae=e=>{let{isValid:t,nodeIds:o,edgeIds:n}=e;return{isValid:t,nodeIds:!t&&o&&o.length>0?o:[],edgeIds:!t&&n&&n.length>0?n:[]}},dt=(e=[],t)=>{if(!e||e.length===0)return{isValid:!0,invalidIds:[]};let o=e.filter(n=>!t(n));return{isValid:o.length===0,invalidIds:o.map(n=>n.id)}},y0=(e,t)=>{let o=new Set(e.filter(n=>n.type==="ANNOTATION").map(n=>n.id));return t.filter(n=>!o.has(n.source)&&!o.has(n.target))},vu=(e=[],t=[])=>({nodes:e.map(o=>{var n;return{id:o.id,type:o.type||"",label:typeof((n=o.data)==null?void 0:n.label)=="string"?o.data.label:void 0,properties:o.data}}),edges:y0(e,t).map(o=>({id:o.id,source:o.source,target:o.target,type:o.type||"default"}))});var cn=[{id:"start_event_not_found",validate:e=>{let t=an(e.nodes);return ae({isValid:t.length>=1})}},{id:"end_event_not_found",validate:e=>{let t=Yt(e.nodes);return ae({isValid:t.length>=1})}},{id:"multiple_start_event_not_allowed",validate:e=>{let t=an(e.nodes),o=t.length===1;if(t.length===0)return ae({isValid:!0});if(!o)return ae({isValid:!1,nodeIds:t.map(i=>i.id)});let n=De(t[0].id,e.edges);if(!(n.length<=1)){let i=[...t.map(s=>s.id),...n.map(s=>s.target)];return ae({isValid:!1,nodeIds:[...new Set(i)]})}return ae({isValid:!0})}},{id:"task_flows_limit_exceeds",validate:e=>{let t=Tt(e.nodes),o=dt(t,n=>De(n.id,e.edges).length<=2);return ae({isValid:o.isValid,nodeIds:o.invalidIds})}},{id:"task_label_empty",highlightRelatedEdges:!1,validate:e=>{let t=Tt(e.nodes),o=dt(t,n=>!!n.label&&n.label.trim()!=="");return ae({isValid:o.isValid,nodeIds:o.invalidIds})}},{id:"task_label_length",highlightRelatedEdges:!1,validate:e=>{let o=Tt(e.nodes),n=dt(o,r=>!r.label||r.label.length<=60);return ae({isValid:n.isValid,nodeIds:n.invalidIds})}},{id:"duplicate_task_name",highlightRelatedEdges:!1,validate:e=>{let t=Tt(e.nodes),o=new Map;for(let r of t){if(!r.label)continue;let i=r.label.trim();i&&(o.has(i)||o.set(i,[]),o.get(i).push(r))}let n=[];for(let[,r]of o.entries())r.length>1&&r.forEach(i=>n.push(i.id));return ae({isValid:n.length===0,nodeIds:n})}},{id:"nested_gateway",validate:e=>{var r,i,s,a;let t=Wr(e.nodes),o=[],n=[];for(let l of t){let c=De(l.id,e.edges);for(let d of c){let u=e.nodes.find(x=>x.id===d.target);if((u==null?void 0:u.type)!=="GATEWAY")continue;let p=((r=l.properties)==null?void 0:r.variant)==="EXCLUSIVE"&&((i=u==null?void 0:u.properties)==null?void 0:i.variant)==="PARALLEL",f=((s=l.properties)==null?void 0:s.variant)==="COMPLEX"&&((a=u==null?void 0:u.properties)==null?void 0:a.variant)==="PARALLEL";!p&&!f&&(o.push(l.id,u.id),n.push(d.id))}}return ae({isValid:o.length===0,nodeIds:o.length>0?[...new Set(o)]:[],edgeIds:n})}},{id:"events_nested",validate:e=>{let t=[...an(e.nodes),...Yt(e.nodes)],o=[],n=[];for(let r of t){let i=De(r.id,e.edges);for(let s of i){let a=e.nodes.find(l=>l.id===s.target);a&&(a.type==="START_EVENT"||a.type==="END_EVENT")&&(o.push(r.id,a.id),n.push(s.id))}}return ae({isValid:o.length===0,nodeIds:o.length>0?[...new Set(o)]:[],edgeIds:n})}},{id:"flows_on_end_tasks_not_allowed",validate:e=>{let t=Yt(e.nodes),o=[],n=[];for(let r of t){let i=ln(r.id,e.edges);for(let s of i){let a=e.nodes.find(l=>l.id===s.source);if(a&&a.type==="TASK"){let l=De(a.id,e.edges);l.length>1&&(o.push(a.id),l.forEach(c=>n.push(c.id)))}}}return ae({isValid:o.length===0,nodeIds:o,edgeIds:n})}},{id:"conditions_flows_limit_exceeds",validate:e=>{let t=Eu(e.nodes),o=dt(t,r=>De(r.id,e.edges).length<=2),n=o.invalidIds.flatMap(r=>De(r,e.edges).map(i=>i.id));return ae({isValid:o.isValid,nodeIds:o.invalidIds,edgeIds:n})}},{id:"activity_name_invalid",validate:e=>{let t=Tt(e.nodes),o=dt(t,n=>!n.label||Tu(n.label));return ae({isValid:o.isValid,nodeIds:o.invalidIds})}},{id:"final_activity_has_loop",validate:e=>{var s,a;if(!((s=e==null?void 0:e.nodes)!=null&&s.length)||!((a=e==null?void 0:e.edges)!=null&&a.length))return ae({isValid:!0});let t=Yt(e.nodes)[0];if(!t)return ae({isValid:!0});let o=ln(t.id,e.edges);if(!o.length)return ae({isValid:!0});let r=Tt(e.nodes).filter(l=>o.some(c=>c.source===l.id)),i=dt(r,l=>!_u(l.id,e));return ae({isValid:i.isValid,nodeIds:i.isValid?[]:[t.id,...i.invalidIds]})}},{id:"concurrent_initial_and_final_event",validate:e=>{let t=Tt(e.nodes),o=Yt(e.nodes)[0];if(!o)return ae({isValid:!0});let n=t.filter(l=>{let c=ln(l.id,e.edges),d=De(l.id,e.edges),u=c.some(f=>{var x;return((x=e.nodes.find(E=>E.id===f.source))==null?void 0:x.type)==="START_EVENT"}),p=d.some(f=>{var x;return((x=e.nodes.find(E=>E.id===f.target))==null?void 0:x.type)==="END_EVENT"});return u&&p}),r=ln(o.id,e.edges),i=r.length>1,s=r.map(l=>l.source),a={isValid:n.length===0&&!i,nodeIds:[...n.map(l=>l.id),...i?s:[]]};return ae(a)}},{id:"gateway_flow_to_event",validate:e=>{let t=Wr(e.nodes),o=[],n=[];for(let r of t){let i=De(r.id,e.edges);for(let s of i){let a=e.nodes.find(l=>l.id===s.target);a&&a.type==="END_EVENT"&&(o.push(r.id,a.id),n.push(s.id))}}return ae({isValid:o.length===0,nodeIds:o.length>0?[...new Set(o)]:[],edgeIds:n})}},{id:"gateway_missing_output_streams",validate:e=>{let t=Wr(e.nodes),o=dt(t,n=>De(n.id,e.edges).length>=1);return ae({isValid:o.isValid,nodeIds:o.invalidIds})}},{id:"event_to_condition",validate:e=>{let t=[...an(e.nodes),...Yt(e.nodes)],o=[],n=[];for(let r of t){let i=De(r.id,e.edges);for(let s of i){let a=e.nodes.find(l=>l.id===s.target);a&&a.type==="GATEWAY"&&(o.push(r.id,a.id),n.push(s.id))}}return ae({isValid:o.length===0,nodeIds:o.length>0?[...new Set(o)]:[],edgeIds:n})}},{id:"script_in_final_activity",validate:e=>{let t=xu(e.nodes),o=dt(t,n=>!bu(n.id,e));return ae({isValid:o.isValid,nodeIds:o.invalidIds})}}];var Nu=e=>{e=e||{nodes:[],edges:[]},e.nodes=e.nodes||[],e.edges=e.edges||[];let t=[];for(let n of cn){let r=n.validate(e);r.isValid||t.push({id:n.id,message:n.id,nodeIds:r.nodeIds||[],edgeIds:r.edgeIds||[]})}return{isValid:t.length===0,errors:t}},wu=async(e,t)=>{var n;let o=[];try{let r=await e(),i=(n=r==null?void 0:r.filter(s=>s.area==="DIAGRAM"))!=null?n:[];return i.length===0?{isValid:!0,errors:[]}:(i.forEach(s=>{var l,c;let a=(c=(l=s==null?void 0:s.detail)==null?void 0:l.phases)==null?void 0:c.map(d=>d.diagramCellId);o.push({id:s.code,message:s.code,nodeIds:a,edgeIds:[]})}),{isValid:!1,errors:o})}catch(r){let i=[],s=(a,l)=>{let c=t.filter(d=>{var u;return((u=d.data)==null?void 0:u.variant)===a}).map(d=>d.id);c.length>0&&i.push({id:l,message:l,nodeIds:c,edgeIds:[]})};return s("SUBPROCESS","cannot_validate_subprocess_reference"),s("SERVICE_TASK","service_task_automation_status_unavailable"),{isValid:!1,errors:i}}};import{jsx as Xr,jsxs as b0}from"react/jsx-runtime";var Au=()=>{let{t:e}=x0(),{toast:t}=xe(),{setNodes:o,setEdges:n,getNodes:r,getEdges:i}=E0(),{validateCustomDiagram:s}=$(),[a,l]=_0(!1),c=bs(!1),d=bs(!1),u=bs(!1),p=vo(async g=>{let y=vu(g.nodes,g.edges),v=Nu(y),b=g.nodes.filter(({type:_,data:w})=>_==="TASK"&&((w==null?void 0:w.variant)==="SUBPROCESS"||(w==null?void 0:w.variant)==="SERVICE_TASK"));if(s&&b.length>0){let _=await wu(s,b);v={isValid:v.isValid&&_.isValid,errors:[...v.errors,..._.errors]}}let N=v.errors.map(_=>I(T({},_),{message:e(`validation.errors.${_.id}`)}));return a||l(!0),{isValid:v.isValid,errors:N}},[a,e,s]),f=vo((g,y=!0)=>{if(y&&g){let R=g.isValid?e("validation.success.title"):e("validation.errors.title"),V=g.isValid?e("validation.success.message"):e("validation.errors.subtitle");t({variant:g.isValid?"success":"error",duration:5e3,title:R,content:b0("div",{className:"flex flex-col gap-2",children:[Xr(Iu,{variant:"body-medium-400",textColor:"text-grey-950",children:V}),!g.isValid&&Xr("ul",{className:"list-disc list-inside max-h-[600px] overflow-y-auto",children:g.errors.map(G=>Xr("li",{children:Xr(Iu,{variant:"body-medium-400",textColor:"text-grey-950",children:G.message})},G.id))})]})})}if(!g)return;c.current=!0,d.current=!0,u.current=!0;let v=[],b=[];g.errors.forEach(R=>{R.nodeIds&&R.nodeIds.length>0&&R.nodeIds.forEach(V=>v.push(V)),R.edgeIds&&R.edgeIds.length>0&&R.edgeIds.forEach(V=>b.push(V))});let N=[...new Set(v)],_=r(),w=i(),S=new Set(N),M=new Set;g.errors.forEach(R=>{var B,A;let V=cn.find(C=>C.id===R.id);(V==null?void 0:V.highlightRelatedEdges)!==!1&&((B=R.edgeIds)==null||B.forEach(C=>M.add(C)),(A=R.nodeIds)==null||A.forEach(C=>{w.forEach(k=>{(k.source===C||k.target===C)&&M.add(k.id)})}))});let L=new Set,D=new Set,O=new Set;_.forEach(R=>{R.type==="START_EVENT"?L.add(R.id):R.type==="END_EVENT"&&D.add(R.id)}),w.forEach(R=>{L.has(R.source)&&O.add(R.target),D.has(R.target)&&O.add(R.source)}),O.forEach(R=>{var V,G;if(S.has(R)){let B=(V=g.errors.find(C=>{var k;return(k=C.nodeIds)==null?void 0:k.includes(R)}))==null?void 0:V.id;((G=cn.find(C=>C.id===B))==null?void 0:G.highlightRelatedEdges)!==!1&&w.forEach(C=>{C.source===R&&D.has(C.target)&&(S.add(C.target),M.add(C.id)),C.target===R&&L.has(C.source)&&(S.add(C.source),M.add(C.id))})}}),o(R=>R.map(V=>I(T({},V),{data:I(T({},V.data),{hasError:S.has(V.id)})}))),n(R=>R.map(V=>I(T({},V),{data:I(T({},V.data),{hasError:M.has(V.id)})}))),setTimeout(()=>{d.current=!1,c.current=!1},0)},[e,i,r,n,o,t]),x=vo(()=>{l(!1),u.current=!1,o(g=>g.map(y=>I(T({},y),{data:I(T({},y.data),{hasError:!1})}))),n(g=>g.map(y=>I(T({},y),{data:I(T({},y.data),{hasError:!1})})))},[n,o]),E=vo(()=>{u.current&&(d.current=!0,u.current=!1,o(g=>g.map(y=>I(T({},y),{data:I(T({},y.data),{hasError:!1})}))),n(g=>g.map(y=>I(T({},y),{data:I(T({},y.data),{hasError:!1})}))),setTimeout(()=>{d.current=!1},0))},[n,o]),m=vo(()=>d.current,[]),h=vo(()=>c.current,[]);return{validateDiagram:p,handleValidationComplete:f,clearValidation:x,dismissValidationPanel:E,isAutoValidationEnabled:a,getIsClearingValidation:m,getIsValidating:h}};import{useTranslation as T0}from"@produto-lecom/lecom-ui";import{useReactFlow as v0}from"@xyflow/react";import{useEffect as N0}from"react";var w0=15,Cu="bpmn:selection",I0=e=>{if(!e||!(e instanceof HTMLElement))return!1;let t=e.tagName.toLowerCase(),o=t==="input"||t==="textarea",n=e.isContentEditable,r=t==="select",i=e.closest('[contenteditable="true"], input, textarea, select')!==null;return o||n||r||i},Su=e=>{if(!I0(e.target))return!0;let t=window.getSelection(),o=t&&t.toString().length>0;if(e.target instanceof HTMLInputElement||e.target instanceof HTMLTextAreaElement){let n=e.target;return n.selectionStart===n.selectionEnd&&!o}return!o},Mu=({offset:e=w0,saveHistory:t})=>{let{t:o}=T0(),{getNodes:n,setNodes:r,getEdges:i,setEdges:s}=v0(),{getNextId:a}=Be(),{mode:l,containerRef:c}=$();N0(()=>{if(l!=="edit")return;let d=c.current;if(!d)return;let u=f=>{var b,N;if(!Su(f)||!d.contains(document.activeElement))return;let E=n(),m=i(),h=E.filter(_=>_.selected);if(!h.length)return;f.preventDefault(),f.stopPropagation();let g=m.filter(_=>h.some(w=>w.id===_.source)&&h.some(w=>w.id===_.target)),v=JSON.stringify({nodes:h,edges:g});(b=f.clipboardData)==null||b.setData(Cu,v),(N=f.clipboardData)==null||N.setData("text/plain",`BPMN Selection: ${h.length} nodes`)},p=f=>{var L,D;if(!Su(f)||!d.contains(document.activeElement))return;let E=(L=f.clipboardData)==null?void 0:L.getData(Cu);if(!E)return;f.preventDefault(),f.stopPropagation();let m;try{m=JSON.parse(E)}catch(O){return}if(!((D=m.nodes)!=null&&D.length))return;let h=new Map,g=n(),y=[],v=m.nodes.filter(O=>no(O.type,g));if(v.length===0)return;let b=a(),N=v.map(O=>{var G;let R=String(b++);h.set(O.id,R);let V=I(T({},O),{id:R,selected:!0,position:{x:O.position.x+e,y:O.position.y+e}});if(O.type==="TASK"){let B=(G=O.data)==null?void 0:G.label,A=yo(B||o("bpmn.task.label.prefix"),[...g,...y]);V.data=I(T({},O.data),{label:A})}return y.push(V),V}),_=m.edges.map(O=>I(T({},O),{id:String(b++),selected:!0,source:h.get(O.source)||O.source,target:h.get(O.target)||O.target,data:Cn(O.data,e)})),w=[...g.map(O=>I(T({},O),{selected:!1})),...N],M=[...i().map(O=>I(T({},O),{selected:!1})),..._];r(w),s(M),t("forceSave",{nodes:w,edges:M})};return d.addEventListener("copy",u,!0),d.addEventListener("paste",p,!0),()=>{d.removeEventListener("copy",u,!0),d.removeEventListener("paste",p,!0)}},[n,r,i,s,a,e,o,t,l,c])};import{useTranslation as A0}from"@produto-lecom/lecom-ui";import{useReactFlow as C0}from"@xyflow/react";import{useCallback as Ur,useRef as S0}from"react";var Pu=({nodes:e,setNodes:t})=>{let{t:o}=A0(),{toast:n}=xe(),{getNodes:r}=C0(),{setIsRemovingElements:i,validateDeleteElements:s}=$(),a=S0(!1),l=Ur(async p=>{try{let{activitiesWithInstances:f}=await s(p);if(f.length)return a.current=!1,i(!1),n({variant:"warning",content:o("editor.toolbar.delete_elements_blocked")}),!1}catch(f){return a.current=!1,i(!1),n({variant:"error",content:o("editor.toolbar.delete_elements_error")}),!1}return!0},[o,n,s,i]),c=Ur(async({nodes:p})=>{if(a.current)return!1;if(a.current=!0,i(!0),p.some(E=>E.type==="LANE"&&e.some(m=>m.parentId===E.id)))return a.current=!1,i(!1),n({variant:"error",title:o("validation.errors.title"),content:o("editor.toolbar.delete_pool_lane_error")}),!1;let x=p.filter(E=>E.type==="TASK");if(s&&x.length>0){let E=x.map(m=>m.id);return l(E)}return!0},[e,o,n,s,l,i]),d=Ur(p=>{a.current=!1,i(!1);let f=new Set(p.filter(x=>x.type==="LANE"&&!!x.parentId).map(x=>x.parentId));f.size!==0&&setTimeout(()=>{var m,h;let x=r(),E=new Map(x.map(g=>[g.id,g]));for(let g of f){let y=Vt(x.filter(N=>N.type==="LANE"&&N.parentId===g));if(y.length===0)continue;let v=0;for(let N of y)E.set(N.id,I(T({},N),{position:{x:J.HEADER_WIDTH,y:v}})),v+=(h=(m=N.measured)==null?void 0:m.height)!=null?h:0;let b=E.get(g);b&&E.set(g,I(T({},b),{height:v,measured:I(T({},b.measured),{height:v})}))}t(x.map(g=>{var y;return(y=E.get(g.id))!=null?y:g}))},0)},[r,t,i]),u=Ur(()=>{a.current=!1,i(!1)},[i]);return{onBeforeDelete:c,onNodesDelete:d,onEdgesDelete:u}};import{useTranslation as M0}from"@produto-lecom/lecom-ui";import{useReactFlow as P0}from"@xyflow/react";import{useState as L0}from"react";var D0=50,Lu=({nodes:e,setNodes:t,setEdges:o,saveHistory:n})=>{let{draggableNode:r,setDraggableNode:i}=po(),{t:s}=M0(),{getInternalNode:a,getNodes:l,getEdges:c,screenToFlowPosition:d}=P0(),{getNextId:u}=Be(),{setIsDragging:p}=$(),{getInternalNodes:f}=Tr(),{rebuildIndex:x,forceRebuildIndex:E}=cr(),[m,h]=L0(null),g=(A,C,k)=>{var Y;if(A.parentId!==C)return null;let P=k.filter(H=>H.id!==A.id&&H.parentId===C&&H.type==="LANE").sort((H,q)=>H.position.y-q.position.y);if(P.length===0)return null;let K=(Y=k.find(H=>H.id===A.id))!=null?Y:A,Z=P.find(H=>K.position.y<H.position.y);return Z?{draggedLaneId:A.id,beforeLaneId:Z.id}:{draggedLaneId:A.id,afterLaneId:P[P.length-1].id}},y=(A,C=!1,k)=>{let P=C?"node-drop-target-error":"node-drop-target",K=C?"node-drop-target-lane-error":"node-drop-target-lane";t(Z=>{var X;let Y=(X=k==null?void 0:k(Z))!=null?X:null,H=U=>{let W=[];return U.id===A&&W.push(P),A!==void 0&&U.parentId===A&&U.type==="LANE"&&U.id!==(Y==null?void 0:Y.draggedLaneId)&&W.push(K),U.id===(Y==null?void 0:Y.draggedLaneId)&&W.push("lane-reorder-dragging"),U.id===(Y==null?void 0:Y.beforeLaneId)&&W.push("lane-reorder-before"),U.id===(Y==null?void 0:Y.afterLaneId)&&W.push("lane-reorder-after"),W.join(" ")||void 0},q=!1,z=Z.map(U=>{let W=H(U);return U.className===W?U:(q=!0,I(T({},U),{className:W}))});return q?z:Z})},v=(A,C)=>{let k=f();if(A.type==="LANE"){if(C){let X=k.filter(W=>W.id!==A.id&&W.parentId!==A.id&&W.type==="LANE"),U=Qt(A,X);U?y(U.id,!0):y();return}let H=k.filter(X=>X.id!==A.id&&X.type==="LANE"&&!X.parentId),q=Qt(A,H);if(!q){y();return}if(At({parentId:q.id,nodes:e,excludeTypes:["LANE"]})){y(q.id,!0);return}y(q.id,!1,X=>g(A,q.id,X));return}let K=k.filter(H=>H.id!==A.id&&H.type==="LANE"),Z=Qt(A,K);if(!Z){y();return}if(At({parentId:Z.id,nodes:e,includeTypes:["LANE"]})){y(Z.id,!0);return}y(Z.id)},b=A=>{let C=a(A.id),k=A.type==="LANE"&&At({parentId:A.id,nodes:e,includeTypes:["LANE"]});v(C,k)},N=A=>A.map(C=>I(T({},C),{className:void 0})),_=A=>A.some(k=>k.dragging)?A.map(k=>k.dragging?I(T({},k),{dragging:!1}):k):A,w=(A,C)=>{let k=0;for(let P of C){if(P.id===A||P.parentId||P.type==="LANE")continue;let K=Re(P),Z=K.y+K.h;k=Math.max(k,Z)}return k+D0},S=(A,C)=>{if(!wi(A,C))return C;let k=w(A,C);return C.map(P=>P.id===A?I(T({},P),{position:I(T({},P.position),{y:k})}):P)},M=A=>{if(A.preventDefault(),A.dataTransfer.dropEffect="move",!(r!=null&&r.type))return;let C=d({x:A.clientX,y:A.clientY}),k={id:"__sidebar_drag__",type:r.type,position:C,measured:{width:1,height:1},internals:{positionAbsolute:C}};v(k,!1)},L=A=>{let C=A.relatedTarget;(!C||!A.currentTarget.contains(C))&&y()},D=(A,C)=>{A.preventDefault(),b(C)},O=(A,C,k)=>{var z,X;let P=[...k],K=C.parentId?C.parentId:C.id;if(A.parentId===C.id)return P=Xi(A,C,P),P=st(P),P=Ot(K,P),N(P);if(A.type==="LANE"){if(At({parentId:C.id,nodes:P,excludeTypes:["LANE"]})){let te=sr(C),ne=50,de=50;return P.map(re=>{var pe,j;return re.id===A.id?I(T({},re),{position:{x:(pe=m==null?void 0:m.x)!=null?pe:te.x+ne,y:(j=m==null?void 0:m.y)!=null?j:te.y2+de}}):re})}let oe=P.filter(te=>te.parentId===C.id).reduce((te,ne)=>{var de,re;return te+((re=(de=ne.measured)==null?void 0:de.height)!=null?re:0)},0),ie={x:J.HEADER_WIDTH,y:oe};return P=P.map(te=>te.id===A.id?I(T({},te),{parentId:C.id,position:ie,className:void 0}):I(T({},te),{className:void 0})),P=st(P),P=S(K,P),P}if(At({parentId:C.id,nodes:P,includeTypes:["LANE"]})){let U;if(A.parentId){let W=a(A.parentId),{x:oe,y:ie}=Re(W);U={x:oe+((z=A.position.x)!=null?z:0),y:ie+((X=A.position.y)!=null?X:0)}}return P=P.map(W=>W.id===A.id?I(T({},W),{position:U!=null?U:W.position,parentId:void 0,className:void 0}):I(T({},W),{className:void 0})),P=Ot(K,P),P}let H=ma(A,C);P=P.map(U=>U.id===A.id?I(T({},U),{parentId:C.id,position:H,className:void 0}):I(T({},U),{className:void 0}));let q=P.find(U=>U.id===A.id);return P=Xi(q,C,P),P=st(P),P=Ot(K,P),P},R=A=>{if(A.preventDefault(),!(r!=null&&r.type))return;if(!no(r.type,l())){p(!1),i(null);return}let C=d({x:A.clientX,y:A.clientY}),k=ee[r.type],P={width:k.DEFAULT_WIDTH,height:k.DEFAULT_HEIGHT},K=u(),Z={id:String(K),type:r.type,position:C,width:k.DEFAULT_WIDTH,height:k.DEFAULT_HEIGHT,measured:P,data:{label:r.type==="TASK"?Lr(e,s("bpmn.task.label.prefix")):"",variant:r.variant,attribute:r.attribute},selected:!0},Y=I(T({},Z),{internals:{positionAbsolute:C}}),H=I(T({},Y),{measured:{width:1,height:1}}),q=f(),z=r.type==="LANE",X=q.filter(ne=>z?ne.type==="LANE"&&!ne.parentId:ne.type==="LANE"),U=Qt(H,X),W=[...q.map(ne=>I(T({},ne),{selected:!1})),Y];U&&(W=O(Y,U,W)),W=It(W),z&&!U&&(W=S(Y.id,W)),W=N(W),t(W),E();let oe=A.dataTransfer.getData("sourceId"),ie=c(),te=ie;if(oe){let ne={id:String(K+1),source:oe,target:Z.id},de=r.type==="ANNOTATION"?T(T({},ne),ro):T(T({},ne),Ve);te=ie.concat(de),o(te)}n("forceSave",{nodes:W,edges:te}),p(!1),i(null)},V=async(A,C,k)=>{let P=[...f()],K=new Set;k.forEach(H=>{let q=a(H.id),z=H.type==="LANE",X=P.filter(W=>W.id!==H.id&&(z?W.type==="LANE"&&!W.parentId:W.type==="LANE")),U=Qt(q,X);if(U){if(z&&At({parentId:H.id,nodes:P,includeTypes:["LANE"]})){H.parentId&&(P=B(H,P),K.add(H.id));return}P=O(q,U,P);return}H.parentId&&(P=B(H,P),H.type==="LANE"&&K.add(H.id))}),P=_(P);let Z=k.filter(H=>H.type==="LANE"&&!H.parentId).map(H=>H.id);for(let H of Z)wi(H,P)&&m&&(P=P.map(q=>q.id===H?I(T({},q),{position:T({},m)}):q));for(let H of K)P=S(H,P);if(k.some(H=>H.type!=="LANE"&&!H.parentId)){let H=P.filter(q=>q.type==="LANE"&&!q.parentId).map(q=>q.id);for(let q of H)P=Ot(q,P)}P=It(P),P=N(P),t(P),x(P),h(null)},G=(A,C)=>{h({x:C.position.x,y:C.position.y})},B=(A,C)=>{var X,U,W,oe,ie,te,ne,de,re,pe;let k=a(A.parentId);if(!k)return C;let P=A.type==="LANE",K=C.filter(j=>j.parentId===k.id&&j.id!==A.id),Z=K.filter(j=>j.type==="LANE"),Y;if(P&&Z.length===0)Y=(U=(X=k.measured)==null?void 0:X.height)!=null?U:J.DEFAULT_HEIGHT;else if(P){let j=(oe=(W=A.measured)==null?void 0:W.height)!=null?oe:J.MIN_HEIGHT;Y=((te=(ie=k.measured)==null?void 0:ie.height)!=null?te:J.MIN_HEIGHT)-j,Y=Math.max(J.MIN_HEIGHT,Y)}else Y=K.length>0?K.reduce((j,se)=>{var he,Ye;return j+((Ye=(he=se.measured)==null?void 0:he.height)!=null?Ye:0)},0)+ce:Math.max(J.MIN_HEIGHT,(de=(ne=k.measured)==null?void 0:ne.height)!=null?de:0);let{x:H,y:q}=Re(k),z={x:H+((re=A.position.x)!=null?re:0),y:q+((pe=A.position.y)!=null?pe:0)};return C=C.map(j=>j.id===A.id?I(T({},j),{position:z,parentId:void 0}):j.id===k.id?I(T({},j),{height:Y,measured:I(T({},j.measured),{height:Y})}):j),C=st(C),C};return{onDragOver:M,onDragLeave:L,onDrop:R,onNodeDrag:D,onNodeDragStart:G,onNodeDragStop:V}};import{useTranslation as k0}from"@produto-lecom/lecom-ui";import{useReactFlow as R0}from"@xyflow/react";import{useEffect as O0}from"react";var V0=30,H0=e=>{if(!e||!(e instanceof HTMLElement))return!1;let t=e.tagName.toLowerCase(),o=t==="input"||t==="textarea",n=e.isContentEditable,r=t==="select",i=e.closest('[contenteditable="true"], input, textarea, select')!==null;return o||n||r||i},G0=e=>!H0(e.target),Du=({offset:e=V0,saveHistory:t})=>{let{t:o}=k0(),{getNodes:n,setNodes:r,getEdges:i,setEdges:s}=R0(),{getNextId:a}=Be(),{mode:l,containerRef:c}=$();O0(()=>{if(l!=="edit")return;let d=c.current;if(!d)return;let u=p=>{if(d.contains(document.activeElement)&&p.ctrlKey&&p.key.toLowerCase()==="d"&&G0(p)){p.preventDefault(),p.stopPropagation();let x=n(),E=i(),m=x.filter(M=>M.selected);if(!m.length)return;let h=new Map,g=[],y=m.filter(M=>no(M.type,x));if(y.length===0)return;let v=E.filter(M=>y.some(L=>L.id===M.source)&&y.some(L=>L.id===M.target)),b=a(),N=y.map(M=>{var O;let L=String(b++);h.set(M.id,L);let D=I(T({},M),{id:L,selected:!0,position:{x:M.position.x+e,y:M.position.y+e}});if(M.type==="TASK"){let R=(O=M.data)==null?void 0:O.label,V=yo(R||o("bpmn.task.label.prefix"),[...x,...g]);D.data=I(T({},M.data),{label:V})}return g.push(D),D}),_=v.map(M=>I(T({},M),{id:String(b++),selected:!0,source:h.get(M.source)||M.source,target:h.get(M.target)||M.target,data:Cn(M.data,e)})),w=[...x.map(M=>I(T({},M),{selected:!1})),...N],S=[...E.map(M=>I(T({},M),{selected:!1})),..._];r(w),s(S),t("forceSave",{nodes:w,edges:S})}};return d.addEventListener("keydown",u,!0),()=>{d.removeEventListener("keydown",u,!0)}},[n,r,i,s,a,e,o,t,l,c])};import{useEffect as B0,useRef as ku}from"react";import{useReactFlow as z0}from"@xyflow/react";var F0=20,Y0=50,dn={UP:"ArrowUp",DOWN:"ArrowDown",LEFT:"ArrowLeft",RIGHT:"ArrowRight"},W0=e=>{if(!e||!(e instanceof HTMLElement))return!1;let t=e.tagName.toLowerCase(),o=t==="input"||t==="textarea",n=e.isContentEditable,r=t==="select",i=e.closest('[contenteditable="true"], input, textarea, select')!==null;return o||n||r||i},Ru=e=>{let{getNodes:t}=z0(),{mode:o,isMoveTool:n}=$(),r=ku(0),i=ku(new Map);B0(()=>{let s=a=>{if(o!=="edit"||!n||W0(a.target)||!Object.values(dn).includes(a.key))return;let u=t().filter(g=>g.selected);if(u.length===0){i.current.clear();return}a.preventDefault();let p=Date.now(),f=p-r.current<500;r.current=p;let x=a.shiftKey?Y0:F0,E=0,m=0;switch(a.key){case dn.UP:m=-x;break;case dn.DOWN:m=x;break;case dn.LEFT:E=-x;break;case dn.RIGHT:E=x;break}let h=u.map(g=>{let y=i.current.get(g.id);(!f||!y)&&(y={x:g.position.x,y:g.position.y});let v={x:y.x+E,y:y.y+m};return i.current.set(g.id,v),{id:g.id,dragging:!1,type:"position",position:v}});e&&e(h)};return window.addEventListener("keydown",s),()=>{window.removeEventListener("keydown",s)}},[t,e,o,n])};import{useReactFlow as U0}from"@xyflow/react";var Vu={"start-event":"START_EVENT","end-event":"END_EVENT",task:"TASK","gateway-exclusive":"GATEWAY","gateway-parallel":"GATEWAY","gateway-complex":"GATEWAY"},Hu={"start-event":"","end-event":"",task:"","gateway-exclusive":"EXCLUSIVE","gateway-parallel":"PARALLEL","gateway-complex":"COMPLEX"},Ou=(e,t)=>{if(!e){console.warn("Step not found");return}e=e.trim();let o=e.match(/(\<.*?\>)/)||[],n=e.match(/(\[.*?\])/)||[],r=e.match(/(\{.*?\})/)||[],i=e.match(/(--.*|\|.*?\|)/i)||[],s="",a="",l="";if(o.length){switch(o[1]){case"<start>":s="start-event";break;case"<end>":s="end-event";break}e=e.replace(o[1],"")}return n.length&&(s="task",a=n[1].replace(/\[|\]/g,""),e=e.replace(n[1],"")),r.length&&(a=r[1].replace(/\{|\}/g,""),a.charAt(0)==="+"?(s="gateway-parallel",a=a.slice(1)):a.charAt(0)==="*"?(s="gateway-complex",a=a.slice(1)):s="gateway-exclusive",e=e.replace(r[1],"")),s||(s="task",a=e),i.length&&(l=i[1].replace(/(\||--)/g,""),e=e.replace(i[1],"")),e=e.trim(),t[e]||(t[e]={type:s,label:a}),{step:e,type:s,label:a,edgeLabel:l}},X0=e=>{e=e||"";let t=e.trim().split(`
42
+ `),o={},n=[];return t.forEach(r=>{r=r||"";let i=r.trim().split("-->");if(i.length!==2){console.warn("Invalid number of steps");return}let s=Ou(i[0],o),a=Ou(i[1],o);s&&a&&n.push({sourceId:s.step,targetId:a.step,label:s.edgeLabel||a.edgeLabel||""})}),{components:o,connections:n}},Gu=e=>{let{components:t,connections:o}=X0(e);return{nodes:t,edges:o}};var $0=7,K0=48,q0=340,Z0=(e,t)=>{let o=K0+e.length*$0;return Math.min(q0,Math.max(t,o))},$r=()=>{let{setNodes:e,setEdges:t}=U0(),{fitToNodes:o}=_t(),{getNextId:n}=Be();return{importFromLia:i=>{let s=typeof i=="string"?i:i.diagramXml||"",{nodes:a,edges:l}=Gu(s),c=[],d=new Map,u=!1,p=n();for(let[g,y]of Object.entries(a)){let v=String(p++),b=Vu[y.type],N=Hu[y.type];b==="START_EVENT"&&(u=!0),d.set(g,v);let _=ee[b].MIN_WIDTH,w=ee[b].MIN_HEIGHT;c.push({id:v,type:b,data:{label:y.label||"",variant:N,attribute:""},position:{x:0,y:0},width:_,height:w,measured:{width:_,height:w}})}let f=[];for(let g of l){let y=I(T({},Ve),{id:String(p++),source:d.get(g.sourceId)||g.sourceId,target:d.get(g.targetId)||g.targetId});f.push(y)}if(!u&&c.length>0){let g=String(p++),y={id:g,type:"START_EVENT",data:{label:"",variant:"",attribute:""},position:{x:0,y:0},width:ee.START_EVENT.MIN_WIDTH,height:ee.START_EVENT.MIN_HEIGHT,measured:{width:ee.START_EVENT.MIN_WIDTH,height:ee.START_EVENT.MIN_HEIGHT}};c.unshift(y);let v=c[1];if(v){let b=I(T({},Ve),{id:String(p++),source:g,target:v.id});f.unshift(b)}}let x=c.map(g=>{var y,v;return g.type==="TASK"?I(T({},g),{width:Z0(String((v=(y=g.data)==null?void 0:y.label)!=null?v:""),ee.TASK.MIN_WIDTH)}):g}),{nodes:E}=yr(x,f),m=new Map(E.map(g=>[g.id,g.position])),h=c.map(g=>{var y;return I(T({},g),{position:(y=m.get(g.id))!=null?y:g.position})});e(h),t(f),o(h)}}};import{useCallback as J0,useEffect as Q0}from"react";var j0={origin:"*",debug:!1};function Kr(e,t=j0){let{origin:o,debug:n}=t,r=J0((i,s)=>{let a={event:i,data:s};window.parent.postMessage(a,o||"*")},[o]);return Q0(()=>{if(!e)return;let i=s=>{let a=s.data;if(!(a!=null&&a.event)||(a==null?void 0:a.data)===void 0)return;let{event:l,data:c}=a,d;if(Array.isArray(c)){let[,u]=c;d=u.data}else d=c;n&&(console.debug("[postMessage] received:",a),console.debug("[postMessage] eventData:",d)),l&&e[l]&&e[l](d)};return window.addEventListener("message",i),()=>window.removeEventListener("message",i)},[e,n]),{sendMessage:r}}import{useNodesInitialized as tE}from"@xyflow/react";import{useEffect as Ts,useRef as oE}from"react";var Bu=()=>{let e=tE(),{initialDiagram:t,isNewDiagram:o,isInitialized:n,setIsInitialized:r,onElementChanges:i}=$(),{importFromMxGraph:s,exportToMxGraph:a}=bt(),{sendMessage:l}=Kr(),c=oE(!1);Ts(()=>{t&&s(t)},[t,s]),Ts(()=>{if(!n||!o||c.current)return;c.current=!0;let d=a();i==null||i(d)},[n,o,t,a,i]),Ts(()=>{if(!e)return;(async()=>{await vn(),r(!0),l("INIT_MODELER",t)})()},[e,t,r,l])};import{useReactFlow as nE}from"@xyflow/react";import{useCallback as zu}from"react";function Fu(){let{setTaskStatuses:e,clearTaskStatuses:t,calculateFlowPath:o}=Ct(),{getEdges:n}=nE(),r=zu(s=>{if(!(s!=null&&s.activities))return;e(s.activities);let a=s.activities.map(c=>c.diagramId),l=n();o(l,a)},[e,o,n]),i=zu(()=>{t()},[t]);return{handleTasksStatus:r,handleClearTaskStatus:i}}import{useReactFlow as rE}from"@xyflow/react";import{useCallback as ut,useState as iE,useEffect as Yu}from"react";import{useDebouncedCallback as sE}from"use-debounce";var aE=500,Wu=100,Xu=(e=!1)=>{let{getNodes:t,getEdges:o,setNodes:n,setEdges:r}=rE(),{mode:i,containerRef:s}=$(),[a,l]=iE({history:[],currentStep:0}),{history:c,currentStep:d}=a,u=d>0,p=d<c.length-1,f=ut((_,w)=>{n(_[w].nodes),r(_[w].edges)},[n,r]),x=ut(()=>{if(d>0){let _=d-1;l(w=>I(T({},w),{currentStep:_})),f(c,_)}},[d,c,f]),E=ut(()=>{if(d<c.length-1){let _=d+1;l(w=>I(T({},w),{currentStep:_})),f(c,_)}},[c,d,f]),m=ut(_=>{l(w=>{let S=w.history[w.currentStep];if(S&&JSON.stringify(S)===JSON.stringify(_))return w;let D=[...w.history.slice(0,w.currentStep+1),_],O=D.length>Wu?D.slice(D.length-Wu):D;return{history:O,currentStep:O.length-1}})},[]),h=ut((_,w)=>{let S=_.map(L=>I(T({},L),{selected:!1,className:"",data:I(T({},L.data),{hasError:!1})})),M=w.map(L=>I(T({},L),{data:I(T({},L.data),{hasError:!1})}));return{nodes:It(S),edges:M}},[]),g=ut(()=>h(t(),o()),[t,o,h]),y=sE(()=>{let _=g();m(_)},aE),v=ut((_,w)=>{if(!e)return;if(c.length===0){let M=g();l({history:[M],currentStep:0})}if(_==="forceSave"){if(w){m(h(w.nodes,w.edges));return}y();return}_.some(M=>M.type==="select")||Pn(_)||y()},[e,y,c.length,g,m,h]);Yu(()=>{if(e&&c.length===0){let _=g();l({history:[_],currentStep:0})}},[e,c.length,g]);let b=ut(_=>{l({history:_||[],currentStep:0})},[]),N=ut(()=>{l({history:[],currentStep:0})},[]);return Yu(()=>{if(i!=="edit")return;let _=s.current;if(!_)return;let w=S=>{if(!_.contains(document.activeElement)||!(S.ctrlKey||S.metaKey))return;let D=S.key.toLowerCase();if(S.shiftKey&&D==="z"){S.preventDefault(),E();return}D==="z"&&(S.preventDefault(),x())};return _.addEventListener("keydown",w),()=>{_.removeEventListener("keydown",w)}},[x,E,i,s]),{history:c,undo:x,redo:E,canUndo:u,canRedo:p,saveHistory:v,resetHistory:b,clearHistory:N}};var Uu=()=>{let[e,t,o]=cE([]),[n,r,i]=lE([]),{getNode:s}=dE(),a=uE(),{instanceId:l,isInitialized:c,setIsConnecting:d,onElementClick:u}=$(),{updateHelperLines:p,HelperLines:f}=cr(),{undo:x,redo:E,canUndo:m,canRedo:h,saveHistory:g}=Xu(c),{onNodeDrag:y,onDrop:v,onDragOver:b,onDragLeave:N,onNodeDragStop:_,onNodeDragStart:w}=Lu({nodes:e,setNodes:t,setEdges:r,saveHistory:g}),{isValidConnection:S,onConnect:M,onReconnect:L,onReconnectStart:D,onReconnectEnd:O,setReconnectingEdge:R,clearReconnectingEdge:V}=yu({setEdges:r,saveHistory:g}),{handleValidationComplete:G,clearValidation:B,dismissValidationPanel:A,validateDiagram:C,getIsValidating:k,getIsClearingValidation:P}=Au(),{importFromLia:K}=$r(),{handleTasksStatus:Z,handleClearTaskStatus:Y}=Fu(),{clearPathEdges:H}=Ct(),{emitElementChanges:q,handleNodeChanges:z,handleEdgeChanges:X}=Yr(),U=xa();Mu({saveHistory:g}),Du({saveHistory:g}),Bu();let W=Wt(()=>{t([]),r([]),H(),setTimeout(U,0)},[t,r,H,U]),{selectElements:oe,clearSelection:ie}=Ke(),{importFromMxGraph:te,exportToMxGraph:ne}=bt(),{configureElement:de,getConfigureElement:re}=wr(),pe=Wt(be=>{be!=null&&be.id&&oe([be.id])},[oe]),{sendMessage:j}=Kr({LIA_CREATE_DIAGRAM:K,CLEAR_DIAGRAM:W,TASKS_STATUS:Z,CLEAR_TASKS_STATUS:Y,EXTERNAL_TASK_SELECT:pe}),se=Wt(()=>e.length+n.length,[e,n]);pE(()=>(Je.set(l,{importFromMxGraph:te,exportToMxGraph:ne,selectElements:oe,clearSelection:ie,configureElement:de,getConfigureElement:re,getElementsCount:se,setReconnectingEdge:R,clearReconnectingEdge:V}),()=>{Je.delete(l)}),[l,te,ne,oe,ie,de,re,se,R,V]);let he=Wt((be,Xe)=>{if(Xe.type!=="TASK"&&Xe.type!=="GATEWAY")return;let xn=re(Xe.id);xn&&(u==null||u(xn)),Xe.type==="TASK"&&j("SELECT_TASK",{id:Xe.id})},[re,u,j]),Ye=Wt((be,Xe)=>{if(Xe.type!=="SEQUENCE_EDGE")return;let xn=s(Xe.source),Bp=s(Xe.target),{isFromStartEvent:zp,isGatewayToGateway:Fp,isActiviyToAndGateway:Yp,isToEndEvent:Wp}=Mn(xn,Bp);if(!(!zp&&!Fp&&!Yp&&!Wp))return;let Xs=re(Xe.id);Xs&&(u==null||u(Xs))},[re,s,u]),Nt=Wt(be=>{p(be,e),o(be),!Pn(be)&&(g(be),P()||A(),k()||z(be))},[e,g,P,A,p,z,k,o]),mn=Wt(be=>{i(be),g(be),P()||A(),k()||X(be)},[i,g,P,A,X,k]);Ru(Nt);let{onBeforeDelete:gn,onNodesDelete:hn,onEdgesDelete:yn}=Pu({nodes:e,setNodes:t});return{nodes:e,setNodes:t,edges:n,setEdges:r,events:{isValidConnection:S,onConnect:M,onReconnect:L,onReconnectStart:D,onReconnectEnd:O,onDrop:v,onDragOver:b,onDragLeave:N,onNodeDrag:y,onNodeDragStop:_,onNodeDragStart:w,onNodeClick:he,onEdgeClick:Ye,onDropCapture:()=>{g("forceSave"),q(),A()},onConnectStart:()=>{d(!0)},onConnectEnd:()=>{d(!1),A()},onSelectionEnd:()=>setTimeout(()=>a.setState({nodesSelectionActive:!1}),0),onNodesChange:Nt,onEdgesChange:mn,onBeforeDelete:gn,onNodesDelete:hn,onEdgesDelete:yn},ui:{handleCloseValidationPanel:B},controls:{undo:x,redo:E,canUndo:m,canRedo:h},components:{HelperLines:f},actions:{saveHistory:g,selectElements:oe,clearSelection:ie,exportToMxGraph:ne,validateDiagram:C,handleValidationComplete:G,setReconnectingEdge:R,clearReconnectingEdge:V}}};import{useCallback as fE}from"react";import{useStore as mE}from"@xyflow/react";function qr(){return mE(fE(e=>e.nodes.length+e.edges.length>0,[]))}import{useReactFlow as gE}from"@xyflow/react";import{useCallback as hE,useEffect as yE,useRef as xE,useState as EE}from"react";var _E=".react-flow__node, .react-flow__edge, .react-flow__node-toolbar";function $u(e,t,o){let[n,r]=EE(!1),i=xE(null),{getViewport:s,setViewport:a}=gE(),l=hE(()=>{i.current=null,r(!1)},[]);return yE(()=>{let c=e.current;if(!c)return;let d=f=>{if(!sn.some(E=>E===f.button)||t.current||o.current||(r(!0),!(f.target instanceof Element))||!f.target.closest(_E))return;f.preventDefault(),f.stopPropagation();let x=s();i.current={pointerX:f.clientX,pointerY:f.clientY,viewportX:x.x,viewportY:x.y,zoom:x.zoom}},u=f=>{let x=i.current;if(x){if((f.buttons&_s)===0){l();return}a({x:x.viewportX+(f.clientX-x.pointerX),y:x.viewportY+(f.clientY-x.pointerY),zoom:x.zoom})}},p=f=>{(f.buttons&_s)===0&&l()};return c.addEventListener("pointerdown",d,!0),window.addEventListener("pointermove",u),window.addEventListener("pointerup",p),window.addEventListener("pointercancel",l),window.addEventListener("blur",l),()=>{c.removeEventListener("pointerdown",d,!0),window.removeEventListener("pointermove",u),window.removeEventListener("pointerup",p),window.removeEventListener("pointercancel",l),window.removeEventListener("blur",l)}},[e,t,o,s,a,l]),n}import{jsx as Ku}from"react/jsx-runtime";var Zr=({id:e,className:t})=>Ku("marker",{id:e,className:F("react-flow__arrowhead",t),viewBox:"0 0 10 10",refX:"9",refY:"5",markerWidth:"7",markerHeight:"7",orient:"auto",markerUnits:"userSpaceOnUse",fill:"currentColor",stroke:"currentColor",children:Ku("path",{d:"M 0 0 L 10 5 L 0 10 Z"})});import{jsx as Jr,jsxs as bE}from"react/jsx-runtime";var qu=()=>Jr("svg",{style:{position:"absolute",top:0,left:0},children:bE("defs",{children:[Jr(Zr,{id:"sequence-edge-marker",className:"text-grey-500"}),Jr(Zr,{id:"sequence-edge-marker-hovered",className:"text-grey-800"}),Jr(Zr,{id:"sequence-edge-marker-highlighted",className:"text-blue-500"})]})});import{Tooltip as I1,TooltipContent as A1,TooltipTrigger as C1,useTranslation as S1}from"@produto-lecom/lecom-ui";import{useKeyPress as vp,useReactFlow as X_}from"@xyflow/react";import{Button as ri,Tooltip as ii,TooltipContent as si,TooltipTrigger as ai,useTranslation as U_}from"@produto-lecom/lecom-ui";import{HandIcon as $_,ListCheckIcon as K_,Loader2Icon as q_,MapIcon as Z_,MousePointerIcon as J_}from"lucide-react";import Q_,{useCallback as Rs,useEffect as Np,useState as j_}from"react";import{Tooltip as zE,TooltipContent as FE,TooltipTrigger as YE,useTranslation as WE}from"@produto-lecom/lecom-ui";var un=(y=>(y.START_EVENT="START_EVENT",y.END_EVENT="END_EVENT",y.TASK="TASK",y.SUBPROCESS="SUBPROCESS",y.GATEWAY="GATEWAY",y.LANE="LANE",y.ANNOTATION="ANNOTATION",y.CONNECTION="CONNECTION",y.INTERMEDIATE_EVENT="INTERMEDIATE_EVENT",y.ACTIVITY="ACTIVITY",y.PROCESS_INTERFACE="PROCESS_INTERFACE",y.WORKFLOW_INTERFACE="WORKFLOW_INTERFACE",y.VARIANT_ACTIVITY="VARIANT_ACTIVITY",y.AUTO_ACTIVITY="AUTO_ACTIVITY",y.DATA_STORE="DATA_STORE",y.DATA_OBJECT="DATA_OBJECT",y.DATA_OUTPUT="DATA_OUTPUT",y.DATA_INPUT="DATA_INPUT",y.MARKER="MARKER",y))(un||{});import{Button as DE,useTranslation as kE}from"@produto-lecom/lecom-ui";import{useReactFlow as RE}from"@xyflow/react";var Qr=async e=>new Promise((t,o)=>{let n=new FileReader;n.onload=r=>{var i;t((i=r.target)==null?void 0:i.result)},n.onerror=r=>{var i;o((i=r.target)==null?void 0:i.error)},n.readAsText(e)});function Zu({columns:e=[],rows:t=[],fileName:o="report"}){if(!e.length||!t.length)return;let r="data:text/csv;charset=utf-8,"+[e,...t].map(s=>s.join(",")).join(`
43
+ `),i=encodeURI(r);jr(i,`${o}.csv`)}var jr=(e,t)=>{let o=document.createElement("a");o.setAttribute("download",t),o.setAttribute("href",e),document.body.appendChild(o),o.click(),document.body.removeChild(o)};function Ju(e){return e==null?void 0:e.replaceAll("&#xA;"," ")}var rO={START_EVENT:"START_EVENT",END_EVENT:"END_EVENT",TASK:"TASK",GATEWAY:"GATEWAY",ANNOTATION:"ANNOTATION"},Qu={script:"SCRIPT",subprocess:"SUBPROCESS"},ju={"marker-loop":"LOOP"},ep={complex:"COMPLEX",none:"EXCLUSIVE",exclusive:"EXCLUSIVE",parallel:"PARALLEL",inclusive:"EXCLUSIVE"};var Xt=({cell:e,type:t,variant:o="",attribute:n=""})=>{let{_attributes:r,mxGeometry:i}=e,{value:s,parent:a}=r,l=Number(i._attributes.width),c=Number(i._attributes.height),d=a==="1"?void 0:a;return{id:r.id,parentId:d,type:t,data:{label:s||"",variant:o,attribute:n},position:{x:Number(i._attributes.x)||0,y:Number(i._attributes.y)||0},width:l,height:c,measured:{width:l,height:c}}},vE=e=>{let{subType:t,style:o}=e._attributes,n="imported";return["none"].includes(t)||(n="adapted"),e.mxGeometry._attributes.width=ee.START_EVENT.MIN_WIDTH,e.mxGeometry._attributes.height=ee.START_EVENT.MIN_HEIGHT,{node:Xt({cell:e,type:"START_EVENT"}),status:n,originalType:o}},NE=e=>{let{subType:t,style:o}=e==null?void 0:e._attributes,n="imported";return["none"].includes(t)||(n="adapted"),e.mxGeometry._attributes.width=ee.END_EVENT.MIN_WIDTH,e.mxGeometry._attributes.height=ee.END_EVENT.MIN_HEIGHT,{node:Xt({cell:e,type:"END_EVENT"}),status:n,originalType:o}},wE=(e,t)=>{let{id:o,subType:n,style:r}=e==null?void 0:e._attributes,i=Qu[n],s=t.get(o)||"",a=ju[s]||"",l=a==="LOOP",c="imported";return!["script","none"].includes(n)&&!l&&(c="adapted"),e.mxGeometry._attributes.width=pt(e.mxGeometry._attributes.width||0,ee.TASK.MIN_WIDTH),e.mxGeometry._attributes.height=pt(e.mxGeometry._attributes.height||0,ee.TASK.MIN_HEIGHT),{node:Xt({cell:e,type:"TASK",variant:i,attribute:a}),status:c,originalType:r}},IE=e=>{let{style:t,subType:o}=e==null?void 0:e._attributes,n=ep[o],r=["none","inclusive","event-based"],i="imported";return r.includes(o)&&(i="adapted"),e.mxGeometry._attributes.width=ee.GATEWAY.MIN_WIDTH,e.mxGeometry._attributes.height=ee.GATEWAY.MIN_HEIGHT,{node:Xt({cell:e,type:"GATEWAY",variant:n}),status:i,originalType:t}},AE=e=>{let{style:t}=e==null?void 0:e._attributes;return{node:Xt({cell:e,type:"LANE"}),status:"imported",originalType:t}},CE=e=>{let{style:t}=e==null?void 0:e._attributes;return e.mxGeometry._attributes.width=pt(e.mxGeometry._attributes.width||0,ee.ANNOTATION.MIN_WIDTH),e.mxGeometry._attributes.height=pt(e.mxGeometry._attributes.height||0,ee.ANNOTATION.MIN_HEIGHT),{node:Xt({cell:e,type:"ANNOTATION"}),status:"imported",originalType:t}},tp=e=>{let{style:t}=e==null?void 0:e._attributes;return e.mxGeometry._attributes.width=ee.UNSUPPORTED.MIN_WIDTH,e.mxGeometry._attributes.height=ee.UNSUPPORTED.MIN_HEIGHT,{node:Xt({cell:e,type:"UNSUPPORTED"}),status:"unsupported",originalType:t}},op=(e,t)=>{let{id:o,source:n,target:r,value:i}=e._attributes;return I(T({},Ve),{id:o,source:t.get(n)||n,target:t.get(r)||r,data:{label:i||""}})},np={TASK:wE,GATEWAY:IE,START_EVENT:vE,END_EVENT:NE,LANE:AE,ANNOTATION:CE};var SE=e=>{let t=new Map,o=Object.values(un),n=[],r=new Map;e.forEach(a=>{var c;let l=(c=a._attributes)==null?void 0:c.type;if(l==="MARKER"){r.set(a._attributes.parent,a._attributes.style);return}if(o.includes(l)){n.push(a);return}});let i=[],s=[];for(let a of n){let{type:l}=a._attributes,c=np[l]||tp,{node:d,status:u,originalType:p}=c(a,r);s.push(d),i.push({originalType:p,type:d.type,variant:d.data.variant,value:Ju(d.data.label),status:u})}return{nodes:s,governanceIdToNodeIdMap:t,summary:i}},ME=(e,t)=>e.filter(r=>{var i;return(i=r._attributes)==null?void 0:i.edge}).map(r=>op(r,t)),PE=e=>{let{mxGraphModel:t}=e,{nodes:o,governanceIdToNodeIdMap:n,summary:r}=SE(t.root.mxCell),i=ME(t.root.mxCell,n);return{nodes:o,edges:i,summary:r}},LE=async e=>{let t=await Qr(e),o=xr(t);if(!o)throw new Error("EMPTY_FILE");let{metadata:n,mxGraphModel:r}=o.modeler||{},i=(n==null?void 0:n.app)&&(n==null?void 0:n.diagramType)&&(n==null?void 0:n.version),s=r==null?void 0:r.root;if(!i||!s)throw new Error("INVALID_FILE");if(!Object.keys(r.root.mxCell||{}).length)throw new Error("CONTAIN_NO_CELLS");return{metadata:n,mxGraphModel:r}},rp=async e=>{try{let t=await LE(e),{nodes:o,edges:n,summary:r}=PE(t)||{};return{nodes:o,edges:n,summary:r}}catch(t){throw t}};import{jsx as OE}from"react/jsx-runtime";var ip=()=>{let{t:e}=kE(),{toast:t}=xe(),{setNodes:o,setEdges:n}=RE(),{fitToNodes:r}=_t(),i=a=>{let l=[e("adapter.governance.report.columns.type"),e("adapter.governance.report.columns.value"),e("adapter.governance.report.columns.status")],c=a.map(d=>[d.originalType,d.value,e(`adapter.governance.report.status.${d.status.toLowerCase()}`)]);t({variant:"warning",content:e("adapter.governance.success.incompatible_cells"),duration:1e3*60*1,action:OE(DE,{size:"small",variant:"ghost",onClick:()=>Zu({columns:l,rows:c,fileName:"governance-imported-cells"}),children:e("adapter.governance.action.download")})})};return{importFromGovernance:async a=>{try{let{nodes:l,edges:c,summary:d}=await rp(a);if(o(p=>p.concat(l)),n(p=>p.concat(c)),r(l),d.some(p=>p.status==="unsupported")){i(d);return}t({variant:"success",content:e("adapter.governance.success.default")})}catch(l){let c=l instanceof Error?l.message:"DEFAULT";t({variant:"error",content:e(`adapter.governance.error.${c}`)})}}}};import{Button as VE}from"@produto-lecom/lecom-ui";import{useRef as HE}from"react";import{Fragment as GE,jsx as sp,jsxs as BE}from"react/jsx-runtime";var ap=a=>{var l=a,{children:e,accept:t="*",multiple:o=!1,disabled:n=!1,onClick:r,onFilesSelected:i}=l,s=Ue(l,["children","accept","multiple","disabled","onClick","onFilesSelected"]);let c=HE(null),d=p=>{let f=p.target.files;f!=null&&f.length&&i(f),c.current&&(c.current.value="")};return BE(GE,{children:[sp(VE,I(T({disabled:n,onClick:p=>{var f;(f=c.current)==null||f.click(),r==null||r(p)}},s),{children:e})),sp("input",{type:"file",ref:c,className:"sr-only",accept:t,multiple:o,disabled:n,onChange:d})]})};import{jsx as ei,jsxs as XE}from"react/jsx-runtime";var lp=({disabled:e=!1})=>{let{t}=WE(),{toast:o}=xe(),{importFromGovernance:n}=ip(),r=()=>{if(e){o({variant:"error",content:t("adapter.governance.error.ALREADY_INITIALIZED")});return}},i=s=>{let a=s[0];if(!a){o({variant:"error",content:t("adapter.governance.error.NO_FILE")});return}n(a)};return XE(zE,{children:[ei(YE,{asChild:!0,children:ei(ap,{className:"[&>svg]:size-7 p-0",variant:"ghost",size:"small",color:"grey",iconButton:!0,accept:".mdr",disabled:e,onClick:r,onFilesSelected:i,children:ei(oa,{})})}),ei(FE,{color:"black",children:t(e?"adapter.governance.error.ALREADY_INITIALIZED":"editor.controls.actions.import_governance")})]})};import{jsx as UE}from"react/jsx-runtime";var vs=({shortcut:e})=>UE("span",{className:"min-h-7.5 inline-flex justify-center items-center py-0.5 px-1.5 bg-grey-100 border border-grey-300 font-mono text-gray-800 shadow-lg rounded-md text-grey-900",children:e});import{Button as r_,DropdownMenu as i_,DropdownMenuContent as s_,DropdownMenuItem as As,DropdownMenuTrigger as a_,Tooltip as ti,TooltipContent as oi,TooltipTrigger as ni,useTranslation as l_}from"@produto-lecom/lecom-ui";import{FileCodeIcon as c_,FileImageIcon as d_,FolderOutputIcon as u_,PrinterIcon as p_}from"lucide-react";import{useState as f_}from"react";import{useTranslation as KE}from"@produto-lecom/lecom-ui";import{useReactFlow as qE}from"@xyflow/react";import{toPng as dp,toSvg as ZE}from"html-to-image";import{useState as JE}from"react";import{getNodesBounds as $E}from"@xyflow/react";var cp=(e,t=0)=>{let o=$E(e),n=document.querySelectorAll(".react-flow__edge-path"),r=o.x,i=o.y,s=o.x+o.width,a=o.y+o.height;return n.forEach(l=>{let c=l.getBBox();r=Math.min(r,c.x),i=Math.min(i,c.y),s=Math.max(s,c.x+c.width),a=Math.max(a,c.y+c.height)}),{x:r,y:i,width:s-r+t*2,height:a-i+t*2}};var QE=3,Ns="diagram",ws=50,jE=e=>e instanceof Element&&e.closest("[data-export-hidden]")!==null,Is=e=>!jE(e),e_=96,t_=25.4,o_="sequence-edge-marker",up=e=>e*t_/e_,n_=e=>{let t=document.getElementById(o_);if(!(t instanceof SVGElement)||!t.ownerSVGElement)return null;let n=t.ownerSVGElement.cloneNode(!0);return n.style.position="absolute",n.style.width="0",n.style.height="0",n.style.overflow="hidden",n.setAttribute("aria-hidden","true"),n.setAttribute("data-export-marker-defs","true"),e.prepend(n),n},pp=()=>{let{t:e}=KE(),{toast:t}=xe(),{getEdges:o,getNodes:n}=qE(),{clearSelection:r}=Ke(),{setIsExporting:i}=$(),[s,a]=JE({png:!1,html:!1,print:!1}),l=()=>{let{x:f,y:x,width:E,height:m}=cp(n(),ws),h=ws-f,g=ws-x;return{width:E,height:m,style:{width:`${E}px`,height:`${m}px`,transform:`translate(${h}px, ${g}px)`,transformOrigin:"top left"}}},c=async(f,x)=>{a(E=>I(T({},E),{[x]:!0})),i(!0),await r();try{let E=n(),m=o();if(E.length===0&&m.length===0){t({content:e("editor.controls.actions.export.feedback.empty"),variant:"warning"});return}let h=Mc();if(!h)throw new Error("Flow element not found");let g=l(),y=n_(h);try{return await f(h,g)}finally{y==null||y.remove()}}catch(E){console.error("Diagram export failed",E),t({content:e("editor.controls.actions.export.feedback.error"),variant:"error"})}finally{i(!1),a(E=>I(T({},E),{[x]:!1}))}};return{exportAsPng:async(f=Ns)=>{await c(async(x,E)=>{let m=await dp(x,I(T({},E),{backgroundColor:"#fcfcfc",skipFonts:!0,filter:Is}));jr(m,`${f}.png`)},"png")},exportAsHtml:async(f=Ns)=>{await c(async(x,E)=>{let m=await ZE(x,I(T({},E),{backgroundColor:"#fcfcfc",skipFonts:!0,filter:Is})),h=`
44
44
  <!DOCTYPE html>
45
45
  <html>
46
46
  <head>
47
47
  <meta charset="utf-8" />
48
- <title>${m}</title>
48
+ <title>${f}</title>
49
49
  <style>
50
50
  html, body {
51
51
  margin: 0;
@@ -65,11 +65,11 @@ var Kp=Object.defineProperty,qp=Object.defineProperties;var Zp=Object.getOwnProp
65
65
  </style>
66
66
  </head>
67
67
  <body>
68
- <img src="${g}" alt="${m}" />
68
+ <img src="${m}" alt="${f}" />
69
69
  </body>
70
- </html>`,f=new Blob([h],{type:"text/html"}),y=URL.createObjectURL(f);_i(y,`${m}.html`),window.setTimeout(()=>URL.revokeObjectURL(y),1e4)},"html")},printDiagram:async(m=Ds)=>{await c(async(x,E)=>{var C;let g=await xp(x,w(_({},E),{backgroundColor:"#fcfcfc",pixelRatio:YE,skipFonts:!0,filter:Vs})),h=document.createElement("iframe");h.style.position="fixed",h.style.right="0",h.style.bottom="0",h.style.width="0",h.style.height="0",h.style.border="0",document.body.appendChild(h);let f=(C=h.contentWindow)==null?void 0:C.document;if(!f)throw document.body.removeChild(h),new Error("Unable to access print iframe document");let y=Ep(E.width).toFixed(2),T=Ep(E.height).toFixed(2),b=f.createElement("style");b.textContent=`
70
+ </html>`,g=new Blob([h],{type:"text/html"}),y=URL.createObjectURL(g);jr(y,`${f}.html`),window.setTimeout(()=>URL.revokeObjectURL(y),1e4)},"html")},printDiagram:async(f=Ns)=>{await c(async(x,E)=>{var S;let m=await dp(x,I(T({},E),{backgroundColor:"#fcfcfc",pixelRatio:QE,skipFonts:!0,filter:Is})),h=document.createElement("iframe");h.style.position="fixed",h.style.right="0",h.style.bottom="0",h.style.width="0",h.style.height="0",h.style.border="0",document.body.appendChild(h);let g=(S=h.contentWindow)==null?void 0:S.document;if(!g)throw document.body.removeChild(h),new Error("Unable to access print iframe document");let y=up(E.width).toFixed(2),v=up(E.height).toFixed(2),b=g.createElement("style");b.textContent=`
71
71
  @page {
72
- size: ${y}mm ${T}mm;
72
+ size: ${y}mm ${v}mm;
73
73
  margin: 0;
74
74
  }
75
75
  html, body {
@@ -83,11 +83,11 @@ var Kp=Object.defineProperty,qp=Object.defineProperties;var Zp=Object.getOwnProp
83
83
  height: 100%;
84
84
  object-fit: contain;
85
85
  }
86
- `,f.head.appendChild(b),f.title=m;let I=f.createElement("img");I.alt="Diagram",f.body.appendChild(I),await new Promise((M,L)=>{let D=!1,O=V=>{D||(D=!0,V?L(V):M())};I.onload=()=>O(),I.onerror=()=>O(new Error("Failed to load print image")),I.src=g,I.complete&&I.naturalWidth>0&&O()});let v=h.contentWindow;if(!v)throw document.body.removeChild(h),new Error("Unable to access print iframe window");let N=()=>{h.parentNode&&document.body.removeChild(h)};v.addEventListener("afterprint",N,{once:!0}),window.setTimeout(N,6e4),v.focus(),v.print()},"print")},isPrintingPng:s.png,isPrintingHtml:s.html,isPrinting:s.print}};import{jsx as Le,jsxs as Ko}from"react/jsx-runtime";function bp(){let{t:e}=QE(),{exportAsPng:t,exportAsHtml:o,printDiagram:n,isPrinting:r,isPrintingPng:i,isPrintingHtml:s}=_p(),[a,l]=n_(!1);return Ko(qE,{modal:!1,open:a,onOpenChange:l,children:[Le(JE,{asChild:!0,children:Le("div",{children:Ko(Ti,{children:[Le(Ni,{asChild:!0,children:Le(KE,{size:"small",variant:"ghost",color:"grey",iconButton:!0,children:Le(t_,{})})}),!a&&Le(vi,{color:"black",children:e("editor.controls.actions.export.title")})]})})}),Ko(ZE,{align:"center",side:"top",sideOffset:16,className:"min-w-0 flex flex-col gap-2 p-2 shadow-sm",children:[Ko(Ti,{children:[Le(Ni,{asChild:!0,children:Le(Hs,{className:"p-1.5",disabled:i,onClick:()=>t(),children:Le(e_,{})})}),Le(vi,{side:"right",color:"black",children:e("editor.controls.actions.export.png")})]}),Ko(Ti,{children:[Le(Ni,{asChild:!0,children:Le(Hs,{className:"p-1.5",disabled:s,onClick:()=>o(),children:Le(jE,{})})}),Le(vi,{side:"right",color:"black",children:e("editor.controls.actions.export.html")})]}),Ko(Ti,{children:[Le(Ni,{asChild:!0,children:Le(Hs,{className:"p-1.5",disabled:r,onClick:()=>n(),children:Le(o_,{})})}),Le(vi,{side:"right",color:"black",children:e("editor.controls.actions.export.print")})]})]})]})}import{Button as f_,DropdownMenu as m_,DropdownMenuContent as g_,DropdownMenuItem as Ip,DropdownMenuTrigger as h_,Tooltip as Bs,TooltipContent as zs,TooltipTrigger as Ys,useTranslation as y_}from"@produto-lecom/lecom-ui";import{CircleIcon as x_,ClipboardPasteIcon as E_,FileCodeIcon as __}from"lucide-react";import{useRef as b_,useState as Ap}from"react";import{useState as vp}from"react";import{Button as Np,Dialog as r_,DialogContent as i_,DialogDescription as s_,DialogFooter as a_,DialogHeader as l_,DialogTitle as c_,Textarea as d_,useTranslation as u_}from"@produto-lecom/lecom-ui";var Tp=e=>{if(!e)return"";let t=e.trim();return t=t.replace(/```[a-zA-Z]*\s*/g,"").replace(/```/g,""),t=t.replace(/^\s*(graph|flowchart)\s+[A-Za-z]{1,2}\s*\r?\n/i,""),t.trim()};import{jsx as xo,jsxs as Gs}from"react/jsx-runtime";var p_=`Um passo (A --> B) por linha, com um ID antes de cada n\xF3. Ex.:
86
+ `,g.head.appendChild(b),g.title=f;let N=g.createElement("img");N.alt="Diagram",g.body.appendChild(N),await new Promise((M,L)=>{let D=!1,O=R=>{D||(D=!0,R?L(R):M())};N.onload=()=>O(),N.onerror=()=>O(new Error("Failed to load print image")),N.src=m,N.complete&&N.naturalWidth>0&&O()});let _=h.contentWindow;if(!_)throw document.body.removeChild(h),new Error("Unable to access print iframe window");let w=()=>{h.parentNode&&document.body.removeChild(h)};_.addEventListener("afterprint",w,{once:!0}),window.setTimeout(w,6e4),_.focus(),_.print()},"print")},isPrintingPng:s.png,isPrintingHtml:s.html,isPrinting:s.print}};import{jsx as Ee,jsxs as No}from"react/jsx-runtime";function fp(){let{t:e}=l_(),{exportAsPng:t,exportAsHtml:o,printDiagram:n,isPrinting:r,isPrintingPng:i,isPrintingHtml:s}=pp(),[a,l]=f_(!1);return No(i_,{modal:!1,open:a,onOpenChange:l,children:[Ee(a_,{asChild:!0,children:Ee("div",{children:No(ti,{children:[Ee(ni,{asChild:!0,children:Ee(r_,{size:"small",variant:"ghost",color:"grey",iconButton:!0,children:Ee(u_,{})})}),!a&&Ee(oi,{color:"black",children:e("editor.controls.actions.export.title")})]})})}),No(s_,{align:"center",side:"top",sideOffset:16,className:"min-w-0 flex flex-col gap-2 p-2 shadow-sm",children:[No(ti,{children:[Ee(ni,{asChild:!0,children:Ee(As,{className:"p-1.5",disabled:i,onClick:()=>t(),children:Ee(d_,{})})}),Ee(oi,{side:"right",color:"black",children:e("editor.controls.actions.export.png")})]}),No(ti,{children:[Ee(ni,{asChild:!0,children:Ee(As,{className:"p-1.5",disabled:s,onClick:()=>o(),children:Ee(c_,{})})}),Ee(oi,{side:"right",color:"black",children:e("editor.controls.actions.export.html")})]}),No(ti,{children:[Ee(ni,{asChild:!0,children:Ee(As,{className:"p-1.5",disabled:r,onClick:()=>n(),children:Ee(p_,{})})}),Ee(oi,{side:"right",color:"black",children:e("editor.controls.actions.export.print")})]})]})]})}import{Button as v_,DropdownMenu as N_,DropdownMenuContent as w_,DropdownMenuItem as xp,DropdownMenuTrigger as I_,Tooltip as Ss,TooltipContent as Ms,TooltipTrigger as Ps,useTranslation as A_}from"@produto-lecom/lecom-ui";import{CircleIcon as C_,ClipboardPasteIcon as S_,FileCodeIcon as M_}from"lucide-react";import{useRef as P_,useState as Ep}from"react";import{useState as gp}from"react";import{Button as hp,Dialog as m_,DialogContent as g_,DialogDescription as h_,DialogFooter as y_,DialogHeader as x_,DialogTitle as E_,Textarea as __,useTranslation as b_}from"@produto-lecom/lecom-ui";var mp=e=>{if(!e)return"";let t=e.trim();return t=t.replace(/```[a-zA-Z]*\s*/g,"").replace(/```/g,""),t=t.replace(/^\s*(graph|flowchart)\s+[A-Za-z]{1,2}\s*\r?\n/i,""),t.trim()};import{jsx as Ut,jsxs as Cs}from"react/jsx-runtime";var T_=`Um passo (A --> B) por linha, com um ID antes de cada n\xF3. Ex.:
87
87
 
88
88
  A<start> --> B[Analisar pedido]
89
89
  B --> C{Aprovado?}
90
90
  C -- Sim --> D[Liberar pedido]
91
91
  C -- N\xE3o --> E[Recusar pedido]
92
92
  D --> F<end>
93
- E --> F<end>`,wp=({open:e,onOpenChange:t})=>{let{t:o}=u_(),{importFromLia:n}=mi(),[r,i]=vp(""),[s,a]=vp(null),l=d=>{d||(i(""),a(null)),t(d)},c=()=>{let d=Tp(r);if(!d){a(o("editor.modals.mermaid_import.error_empty"));return}try{n(d),l(!1)}catch(u){console.error("Falha ao gerar o diagrama a partir de Mermaid:",u),a(o("editor.modals.mermaid_import.error_parse"))}};return xo(r_,{open:e,onOpenChange:l,children:Gs(i_,{className:"w-[90vw] max-w-4xl",children:[Gs(l_,{children:[xo(c_,{children:o("editor.modals.mermaid_import.title")}),xo(s_,{children:o("editor.modals.mermaid_import.description")})]}),xo(d_,{value:r,onChange:d=>{i(d.target.value),s&&a(null)},placeholder:p_,rows:16,className:"max-h-[60vh] min-h-[360px] resize-y font-mono"}),s&&xo("p",{className:"text-sm text-red-500",children:s}),Gs(a_,{children:[xo(Np,{variant:"ghost",color:"grey",onClick:()=>l(!1),children:o("editor.modals.mermaid_import.cancel")}),xo(Np,{variant:"filled",color:"blue",onClick:c,children:o("editor.modals.mermaid_import.generate")})]})]})})};import{Fragment as v_,jsx as He,jsxs as qo}from"react/jsx-runtime";var T_=".xml,text/xml,application/xml";function Cp(){let{t:e}=y_(),{importFromMxGraph:t}=Zt(),{toast:o}=Pe(),[n,r]=Ap(!1),[i,s]=Ap(!1),a=b_(null),l=async c=>{var u;let d=(u=c.target.files)==null?void 0:u[0];if(c.target.value="",!!d)try{let p=await Ei(d);await t(p)}catch(p){console.error("Falha ao importar o XML:",p),o({variant:"error",content:e("editor.controls.actions.import.feedback.error")})}};return qo(v_,{children:[qo(m_,{modal:!1,open:n,onOpenChange:r,children:[He(h_,{asChild:!0,children:He("div",{children:qo(Bs,{children:[He(Ys,{asChild:!0,children:He(f_,{size:"small",variant:"ghost",color:"grey",iconButton:!0,children:He(E_,{})})}),!n&&He(zs,{color:"black",children:e("editor.controls.actions.import.title")})]})})}),qo(g_,{align:"center",side:"top",sideOffset:16,className:"min-w-0 flex flex-col gap-2 p-2 shadow-sm",children:[qo(Bs,{children:[He(Ys,{asChild:!0,children:He(Ip,{className:"p-1.5",onClick:()=>{var c;return(c=a.current)==null?void 0:c.click()},children:He(__,{})})}),He(zs,{side:"right",color:"black",children:e("editor.controls.actions.import.xml")})]}),qo(Bs,{children:[He(Ys,{asChild:!0,children:He(Ip,{className:"p-1.5",onClick:()=>s(!0),children:He(x_,{})})}),He(zs,{side:"right",color:"black",children:e("editor.controls.actions.import.mermaid")})]})]})]}),He("input",{ref:a,type:"file",className:"sr-only",accept:T_,onChange:l}),He(wp,{open:i,onOpenChange:s})]})}import{useCallback as N_,useState as w_}from"react";import{Button as I_,DropdownMenu as A_,DropdownMenuContent as C_,DropdownMenuItem as Sp,DropdownMenuTrigger as S_,Tooltip as Fs,TooltipContent as Ws,TooltipTrigger as Xs,useTranslation as M_}from"@produto-lecom/lecom-ui";import{useReactFlow as P_}from"@xyflow/react";import{AlignHorizontalJustifyStartIcon as L_,AlignVerticalJustifyStartIcon as k_,NetworkIcon as R_}from"lucide-react";import{jsx as Ke,jsxs as On}from"react/jsx-runtime";function Mp(){let{t:e}=M_(),{getNodes:t,getEdges:o,setNodes:n}=P_(),{fitToNodes:r}=qt(),{toast:i}=Pe(),[s,a]=w_(!1),l=N_(c=>{let d=t();if(d.length===0)return;if(d.some(g=>g.parentId)){i({content:e("editor.controls.actions.organize.feedback.pool_lane"),variant:"warning"});return}let p=d.map(g=>{var h,f,y,T;return w(_({},g),{width:(f=g.width)!=null?f:(h=g.measured)==null?void 0:h.width,height:(T=g.height)!=null?T:(y=g.measured)==null?void 0:y.height})}),{nodes:m}=jr(p,o(),c),x=new Map(m.map(g=>[g.id,g.position])),E=d.map(g=>{var h;return w(_({},g),{position:(h=x.get(g.id))!=null?h:g.position})});n(E),r(E)},[t,o,n,r,i,e]);return On(A_,{modal:!1,open:s,onOpenChange:a,children:[Ke(S_,{asChild:!0,children:Ke("div",{children:On(Fs,{children:[Ke(Xs,{asChild:!0,children:Ke(I_,{size:"small",variant:"ghost",color:"grey",iconButton:!0,children:Ke(R_,{})})}),!s&&Ke(Ws,{color:"black",children:e("editor.controls.actions.organize.title")})]})})}),On(C_,{align:"center",side:"top",sideOffset:16,className:"min-w-0 flex flex-col gap-2 p-2 shadow-sm",children:[On(Fs,{children:[Ke(Xs,{asChild:!0,children:Ke(Sp,{className:"p-1.5",onClick:()=>l("TB"),children:Ke(k_,{})})}),Ke(Ws,{side:"right",color:"black",children:e("editor.controls.actions.organize.vertical")})]}),On(Fs,{children:[Ke(Xs,{asChild:!0,children:Ke(Sp,{className:"p-1.5",onClick:()=>l("LR"),children:Ke(L_,{})})}),Ke(Ws,{side:"right",color:"black",children:e("editor.controls.actions.organize.horizontal")})]})]})]})}import{Fragment as $s,jsx as _e,jsxs as Tt}from"react/jsx-runtime";var Ks=Y_.memo(({hasContent:e,validateDiagram:t,handleValidationComplete:o})=>{let{t:n}=O_(),{clearSelection:r}=yt(),{mode:i,containerRef:s,featureFlags:a,isMinimapOpen:l,setIsMinimapOpen:c,isMoveTool:d,isHandTool:u,setIsMoveTool:p,setIsHandTool:m}=U(),{getNodes:x,getEdges:E}=D_(),g=Pp(["v","V"],{target:s==null?void 0:s.current}),h=Pp(["h","H"],{target:s==null?void 0:s.current}),f=Us(()=>{r(),m(!0),p(!1)},[r,m,p]),y=Us(()=>{p(!0),m(!1)},[p,m]),[T,b]=F_(!1),I=Us(async()=>{b(!0);try{let v=x(),N=E(),C=await t({nodes:v,edges:N});o(C)}finally{b(!1)}},[x,E,t,o]);return Lp(()=>{g&&!d&&i==="edit"&&y()},[g,y,d,i]),Lp(()=>{h&&!u&&i==="edit"&&f()},[h,f,u,i]),Tt("div",{className:"flex items-center gap-2 px-3 py-2 bg-white rounded-sm shadow-md",children:[i==="edit"&&Tt($s,{children:[Tt(Ii,{children:[_e(Ci,{asChild:!0,children:_e(wi,{size:"small",variant:"ghost",color:"grey",className:G(d&&"bg-grey-400"),iconButton:!0,onClick:y,children:_e(z_,{})})}),Tt(Ai,{color:"black",className:"flex items-center gap-2",children:[n("editor.controls.actions.move_tool"),_e(Rs,{shortcut:"V"})]})]}),Tt(Ii,{children:[_e(Ci,{asChild:!0,children:_e(wi,{size:"small",variant:"ghost",color:"grey",className:G(u&&"bg-grey-400"),iconButton:!0,onClick:f,children:_e(V_,{})})}),Tt(Ai,{color:"black",className:"flex items-center gap-2",children:[n("editor.controls.actions.hand_tool")," ",_e(Rs,{shortcut:"H"})]})]})]}),_e(bp,{}),i==="edit"&&Tt($s,{children:[(a==null?void 0:a.importDiagramMermaidEnabled)&&Tt($s,{children:[_e(Cp,{}),_e(Mp,{})]}),Tt(Ii,{children:[_e(Ci,{asChild:!0,children:_e(wi,{size:"small",variant:"ghost",color:"grey",iconButton:!0,disabled:T,onClick:I,children:T?_e(G_,{className:"animate-spin"}):_e(H_,{})})}),_e(Ai,{color:"black",children:n(T?"editor.controls.actions.check_loading":"editor.controls.actions.check")})]}),_e(hp,{disabled:e})]}),Tt(Ii,{children:[_e(Ci,{asChild:!0,children:_e(wi,{size:"small",variant:"ghost",color:"grey",className:G(l&&"bg-grey-400"),iconButton:!0,onClick:()=>c(!l),children:_e(B_,{})})}),_e(Ai,{color:"black",children:n(l?"editor.controls.actions.minimap.close":"editor.controls.actions.minimap.open")})]})]})});Ks.displayName="ActionsControl";import W_ from"react";import{Button as kp,Tooltip as Rp,TooltipContent as Dp,TooltipTrigger as Op,useTranslation as X_}from"@produto-lecom/lecom-ui";import{RedoIcon as U_,UndoIcon as $_}from"lucide-react";import{jsx as Qt,jsxs as qs}from"react/jsx-runtime";var Zs=W_.memo(({undo:e,redo:t,canUndo:o,canRedo:n})=>{let{t:r}=X_();return qs("div",{className:"flex items-center gap-2 px-3 py-2 bg-white rounded-sm shadow-md",children:[qs(Rp,{children:[Qt(Op,{asChild:!0,children:Qt(kp,{size:"small",variant:"ghost",color:"grey",iconButton:!0,disabled:!o,onClick:e,children:Qt($_,{})})}),Qt(Dp,{color:"black",children:r("editor.controls.history.undo")})]}),qs(Rp,{children:[Qt(Op,{asChild:!0,children:Qt(kp,{size:"small",variant:"ghost",color:"grey",iconButton:!0,disabled:!n,onClick:t,children:Qt(U_,{})})}),Qt(Dp,{color:"black",children:r("editor.controls.history.redo")})]})]})});Zs.displayName="HistoryControl";import{useReactFlow as K_}from"@xyflow/react";import{Button as Si,Tooltip as Mi,TooltipContent as Pi,TooltipTrigger as Li,useTranslation as q_}from"@produto-lecom/lecom-ui";import{ScanIcon as Z_,ZoomIn as J_,ZoomOut as Q_}from"lucide-react";import{jsx as Ge,jsxs as Vn}from"react/jsx-runtime";var Vp=()=>{let{t:e}=q_(),t=!hi(),{zoomIn:o,zoomOut:n,zoomTo:r,fitView:i}=K_();return Vn("div",{className:"flex items-center gap-2 px-3 py-2 bg-white rounded-sm shadow-md",children:[Vn(Mi,{children:[Ge(Li,{asChild:!0,children:Ge(Si,{iconButton:!0,size:"small",color:"grey",variant:"ghost",disabled:t,onClick:()=>i(),children:Ge(Z_,{})})}),Ge(Pi,{color:"black",children:e("editor.controls.zoom.fit")})]}),Vn(Mi,{children:[Ge(Li,{asChild:!0,children:Ge(Si,{iconButton:!0,size:"small",color:"grey",variant:"ghost",disabled:t,onClick:()=>n(),children:Ge(Q_,{})})}),Ge(Pi,{color:"black",children:e("editor.controls.zoom.out")})]}),Vn(Mi,{children:[Ge(Li,{asChild:!0,children:Ge(Si,{iconButton:!0,size:"small",color:"grey",variant:"ghost",disabled:t,onClick:()=>r(1),children:Ge(ba,{})})}),Ge(Pi,{color:"black",children:e("editor.controls.zoom.reset")})]}),Vn(Mi,{children:[Ge(Li,{asChild:!0,children:Ge(Si,{iconButton:!0,size:"small",color:"grey",variant:"ghost",disabled:t,onClick:()=>o(),children:Ge(J_,{})})}),Ge(Pi,{color:"black",children:e("editor.controls.zoom.in")})]})]})};import{ViewportPortal as j_}from"@xyflow/react";import{jsx as Js,jsxs as Hp}from"react/jsx-runtime";var Gp=()=>Hp(j_,{children:[Hp("svg",{"data-export-hidden":!0,width:"20",height:"20",viewBox:"0 0 20 20",className:"text-grey-400 -translate-x-1/2 -translate-y-1/2 pointer-events-none",children:[Js("line",{x1:"0",y1:"10",x2:"20",y2:"10",stroke:"currentcolor",strokeWidth:"1.5",strokeDasharray:"2 1"}),Js("line",{x1:"10",y1:"0",x2:"10",y2:"20",stroke:"currentcolor",strokeWidth:"1.5",strokeDasharray:"2 1"})]}),Js("div",{"data-export-hidden":!0,className:"absolute top-1 left-1 text-xs font-medium text-grey-400 bg-white/70 px-1 rounded-sm pointer-events-none",children:"0,0"})]});import{useStore as eb}from"@xyflow/react";import{Button as tb,Tooltip as ob,TooltipContent as nb,TooltipTrigger as rb,useTranslation as ib}from"@produto-lecom/lecom-ui";import{useRef as sb,useState as ab}from"react";import{Bot as lb}from"lucide-react";import{jsx as Eo,jsxs as Bp}from"react/jsx-runtime";var zp=()=>{let e=sb(null),{t}=ib(),{setDraggableNode:o}=Wo(),n=eb(c=>c.nodes.some(d=>d.type==="START_EVENT")),{setIsDragging:r}=U(),[i,s]=ab(void 0),a=[{type:"START_EVENT",icon:Fn,label:t("bpmn.start_event.variant.default")},{type:"END_EVENT",icon:_o,label:t("bpmn.end_event.variant.default")},{type:"TASK",icon:Jo,label:t("bpmn.task.variant.default")},{type:"TASK",variant:"SUBPROCESS",icon:jo,label:t("bpmn.task.variant.subprocess")},{type:"TASK",variant:"SERVICE_TASK",icon:lb,label:t("bpmn.task.variant.service_task")},{type:"TASK",variant:"SCRIPT",icon:wa,label:t("bpmn.task.variant.script")},{type:"TASK",attribute:"LOOP",icon:Na,label:t("bpmn.task.attribute.loop")},{type:"GATEWAY",variant:"EXCLUSIVE",icon:To,label:t("bpmn.gateway.variant.exclusive")},{type:"GATEWAY",variant:"PARALLEL",icon:vo,label:t("bpmn.gateway.variant.parallel")},{type:"GATEWAY",variant:"COMPLEX",icon:bo,label:t("bpmn.gateway.variant.complex")},{type:"LANE",icon:_a,label:t("bpmn.lane.variant.default")},{type:"ANNOTATION",icon:zn,label:t("bpmn.annotation.variant.default")}],l=(c,d)=>{o({type:d.type,variant:d.variant,attribute:d.attribute,icon:d.icon}),s(Eo(d.icon,{})),c.dataTransfer.effectAllowed="move",e.current&&c.dataTransfer.setDragImage(e.current,10,10),setTimeout(()=>{r(!0)},100)};return Bp("aside",{className:"sidebar absolute z-[1] top-4 left-4",children:[Eo("div",{className:"grid grid-cols-1 gap-2 p-2 bg-white rounded-md shadow-md",children:a.map((c,d)=>{let u=c.type==="START_EVENT"&&n,p=u?t("editor.toolbar.start_event_already_exists"):c.label;return Bp(ob,{children:[Eo(rb,{asChild:!0,children:Eo(tb,{className:G("[&>svg]:size-6",{"opacity-50 cursor-not-allowed":u}),size:"small",variant:"ghost",color:"grey",draggable:!u,disabled:u,iconButton:!0,onDragStart:u?void 0:m=>l(m,c),children:Eo(c.icon,{})},d)}),Eo(nb,{color:"black",side:"right",children:p})]},d)})}),Eo("div",{ref:e,className:"absolute w-0 h-0 top-0 left-0 z-[-1] bg-transparent",children:i})]})};import{jsx as ct,jsxs as ki}from"react/jsx-runtime";var Qs=e=>e.preventDefault(),js=mb((e,t)=>{let{instanceId:o,containerRef:n,mode:r,isMinimapOpen:i,isMoveTool:s,isHandTool:a,isExporting:l}=U(),c=fb("Space",{target:n==null?void 0:n.current}),d=Yp(a),u=Yp(c),{nodes:p,edges:m,actions:x,events:E,components:g,controls:h}=ep(),{t:f}=Eb(),y=hi();d.current=a,u.current=c;let T=tp(n,d,u);gb(t,()=>({selectElements:x.selectElements,clearSelection:x.clearSelection}));let b=a||c||r!=="edit",I=b?bu:Mn,v=a||c||T,N=s&&!c&&!T,C=r==="edit"&&N,M=!b&&!T,L=r==="view"||N;return ki("div",{ref:n,className:"w-full h-full outline-none",tabIndex:0,children:[r==="edit"&&ct(zp,{}),ct(np,{}),ki(ub,w(_({},E),{id:`modeler-${o}`,className:G(r.toLowerCase(),{"is-hand-tool":v,"is-pan-tool-active":v}),edges:m,nodes:p,nodeTypes:su,edgeTypes:au,onlyRenderVisibleElements:!l,minZoom:Ms,maxZoom:fu,panOnDrag:I,panOnScroll:!0,selectionOnDrag:M,elevateEdgesOnSelect:!0,elevateNodesOnSelect:!0,elementsSelectable:L,nodesConnectable:C,nodesDraggable:C,connectionLineComponent:ru,selectionMode:pb.Partial,multiSelectionKeyCode:["Control","Meta"],deleteKeyCode:C?"Delete":null,selectionKeyCode:null,defaultViewport:xu,connectOnClick:!1,connectionRadius:50,onPaneContextMenu:Qs,onNodeContextMenu:Qs,onEdgeContextMenu:Qs,proOptions:Tu,children:[ct(cb,{gap:uu,size:du,color:cu,bgColor:lu}),ct(Gp,{}),i&&ki(hb,{children:[ct(xb,{asChild:!0,children:ct("div",{className:"absolute bottom-[0px] left-[0px] z-[5]",children:ct(db,{pannable:!0,zoomable:!0,position:pu,className:"shadow-md rounded-md",ariaLabel:"",style:{pointerEvents:"all",position:"relative"}})})}),ct(yb,{color:"black",children:f("editor.controls.actions.minimap.label")})]}),ki("div",{className:"absolute z-10 bottom-4 left-1/2 -translate-x-1/2 flex gap-4",children:[r==="edit"&&ct(Zs,_({},h)),r!=="readonly"&&ct(Ks,{hasContent:y,validateDiagram:x.validateDiagram,handleValidationComplete:x.handleValidationComplete}),ct(Vp,{})]}),ct(g.HelperLines,{})]}))]})});js.displayName="Editor";import{useStore as _b}from"@xyflow/react";import{useEffect as bb,useRef as Fp}from"react";import{jsx as vb}from"react/jsx-runtime";var Tb=e=>({width:e.width,height:e.height,transform:e.transform}),ea="rgba(51, 103, 217, 0.4)",Mc=({horizontal:e,vertical:t})=>{let{width:o,height:n,transform:r}=_b(Tb),i=Fp(null),s=Fp(1);return bb(()=>{let a=i.current,l=a==null?void 0:a.getContext("2d");if(!l||!a)return;let c=Math.min(window.devicePixelRatio||1,2),d=Math.ceil(o*c),u=Math.ceil(n*c);(a.width!==d||a.height!==u)&&(a.width=d,a.height=u,s.current=c),l.setTransform(s.current,0,0,s.current,0,0),l.clearRect(0,0,o,n),l.strokeStyle=ea,t&&(l.beginPath(),l.strokeStyle=t.color||ea,l.moveTo(t.position*r[2]+r[0],0),l.lineTo(t.position*r[2]+r[0],n),l.stroke()),e&&(l.beginPath(),l.strokeStyle=e.color||ea,l.moveTo(0,e.position*r[2]+r[1]),l.lineTo(o,e.position*r[2]+r[1]),l.stroke())},[o,n,r,e,t]),vb("canvas",{ref:i,className:"w-full h-full absolute z-10 pointer-events-none"})};import{i18n as Nb,Notification as wb,TooltipProvider as Ib}from"@produto-lecom/lecom-ui";import{createContext as Ab,useContext as Cb,useEffect as Sb,useState as Mb}from"react";import{jsx as Wp,jsxs as Lb}from"react/jsx-runtime";var bt=new Map,Xp=Ab(null),bn=()=>{let e=Cb(Xp);if(!e)throw new Error("useModeler must be used within an <ModelerProvider />");return e},Pb=({locale:e,defaultMode:t="view",featureFlags:o,toast:n,children:r})=>{let[i,s]=Mb(e||"pt_BR");Sb(()=>{e&&(s(e),Nb.changeLanguage(e))},[e]);let a=E=>{let g=bt.size;if(g===0)throw new Error("No modeler instances found");if(g===1||!E){let[f]=bt.values();return f}let h=bt.get(E);if(!h)throw new Error(`Modeler instance with ID "${E}" not found`);return h},l=(E,g)=>{let h=a(g);return h==null?void 0:h.selectElements(E)},c=async E=>{let g=a(E);return g==null?void 0:g.clearSelection()},d=(E,g)=>{let h=a(g);return h==null?void 0:h.configureElement(E)},u=(E,g)=>{let h=a(g);return h==null?void 0:h.getConfigureElement(E)},p=async(E,g)=>{let h=a(g);await(h==null?void 0:h.importFromMxGraph(E))},m=E=>{let g=a(E);return g==null?void 0:g.exportToMxGraph()},x=E=>{let g=a(E);return(g==null?void 0:g.getElementsCount())||0};return Wp(Xp.Provider,{value:{defaultMode:t,locale:i,featureFlags:o,selectElements:l,clearSelection:c,configureElement:d,getConfigureElement:u,importDiagram:p,exportDiagram:m,getElementsCount:x,toast:n},children:Lb(Ib,{children:[!n&&Wp(wb,{type:"toast",placement:"topRight",enableClose:!0,showProgress:!0,pauseOnHover:!0}),r]})})};import{jsx as ta}from"react/jsx-runtime";var $p=Db(null),U=()=>{let e=Ob($p);if(!e)throw new Error("useModelerInstance must be used within an <Modeler />");return e},Bb=({selectorRef:e,initialDiagram:t,instanceId:o,mode:n,edgeHighlight:r=!0,validateCustomDiagram:i,validateDeleteElements:s,onElementChanges:a,onConfigureElement:l,onElementClick:c,onSubprocessValidationClick:d})=>{let u=Gb(null),{t:p}=kb(),{defaultMode:m,featureFlags:x}=bn(),E=Hb(),[g]=dt(o||E),[h,f]=dt(n||m||"edit"),[y,T]=dt(wn),[b,I]=dt(!1),[v,N]=dt(!0),[C,M]=dt(!1),[L,D]=dt(!1),[O,V]=dt(!1),[F,j]=dt(!1),[q,$]=dt(!1),[A,P]=dt(!1),[k,S]=dt(null);Vb(()=>{n&&f(n)},[n]);let B=!t,Y=Up(()=>t||pd(p),[t,p]),R=Up(()=>({instanceId:g,containerRef:u,initialDiagram:Y,mode:h,featureFlags:x,edgeHighlight:r,isEdit:h==="edit",isView:h==="view",isReadOnly:h==="readonly",isNewDiagram:B,lastElementId:y,isInitialized:b,isMinimapOpen:L,isMoveTool:v,isHandTool:C,isDragging:O,isConnecting:F,isRemovingElements:q,isExporting:A,setLastElementId:T,setIsInitialized:I,reconnectingEdgeId:k,setIsMinimapOpen:D,setIsMoveTool:N,setIsHandTool:M,setIsDragging:V,setIsConnecting:j,setIsRemovingElements:$,setIsExporting:P,setReconnectingEdgeId:S,validateCustomDiagram:i,validateDeleteElements:s,onElementChanges:a,onConfigureElement:l,onElementClick:c,onSubprocessValidationClick:d}),[g,u,Y,h,x,r,B,y,b,L,v,C,O,F,q,A,k,i,s,a,l,c,d]);return ta(Rb,{children:ta($p.Provider,{value:R,children:ta(js,{ref:e})})})};export{ve as EditorMode,Di as ElementPosition,Gn as ElementType,Oi as GatewayElementVariant,nt as GatewayVariant,Bb as Modeler,Pb as ModelerProvider,ht as NodeAttribute,re as NodeType,Je as NodeVariant,Vi as RoutingVariant,bn as useModeler};
93
+ E --> F<end>`,yp=({open:e,onOpenChange:t})=>{let{t:o}=b_(),{importFromLia:n}=$r(),[r,i]=gp(""),[s,a]=gp(null),l=d=>{d||(i(""),a(null)),t(d)},c=()=>{let d=mp(r);if(!d){a(o("editor.modals.mermaid_import.error_empty"));return}try{n(d),l(!1)}catch(u){console.error("Falha ao gerar o diagrama a partir de Mermaid:",u),a(o("editor.modals.mermaid_import.error_parse"))}};return Ut(m_,{open:e,onOpenChange:l,children:Cs(g_,{className:"w-[90vw] max-w-4xl",children:[Cs(x_,{children:[Ut(E_,{children:o("editor.modals.mermaid_import.title")}),Ut(h_,{children:o("editor.modals.mermaid_import.description")})]}),Ut(__,{value:r,onChange:d=>{i(d.target.value),s&&a(null)},placeholder:T_,rows:16,className:"max-h-[60vh] min-h-[360px] resize-y font-mono"}),s&&Ut("p",{className:"text-sm text-red-500",children:s}),Cs(y_,{children:[Ut(hp,{variant:"ghost",color:"grey",onClick:()=>l(!1),children:o("editor.modals.mermaid_import.cancel")}),Ut(hp,{variant:"filled",color:"blue",onClick:c,children:o("editor.modals.mermaid_import.generate")})]})]})})};import{Fragment as D_,jsx as ve,jsxs as wo}from"react/jsx-runtime";var L_=".xml,text/xml,application/xml";function _p(){let{t:e}=A_(),{importFromMxGraph:t}=bt(),{toast:o}=xe(),[n,r]=Ep(!1),[i,s]=Ep(!1),a=P_(null),l=async c=>{var u;let d=(u=c.target.files)==null?void 0:u[0];if(c.target.value="",!!d)try{let p=await Qr(d);await t(p)}catch(p){console.error("Falha ao importar o XML:",p),o({variant:"error",content:e("editor.controls.actions.import.feedback.error")})}};return wo(D_,{children:[wo(N_,{modal:!1,open:n,onOpenChange:r,children:[ve(I_,{asChild:!0,children:ve("div",{children:wo(Ss,{children:[ve(Ps,{asChild:!0,children:ve(v_,{size:"small",variant:"ghost",color:"grey",iconButton:!0,children:ve(S_,{})})}),!n&&ve(Ms,{color:"black",children:e("editor.controls.actions.import.title")})]})})}),wo(w_,{align:"center",side:"top",sideOffset:16,className:"min-w-0 flex flex-col gap-2 p-2 shadow-sm",children:[wo(Ss,{children:[ve(Ps,{asChild:!0,children:ve(xp,{className:"p-1.5",onClick:()=>{var c;return(c=a.current)==null?void 0:c.click()},children:ve(M_,{})})}),ve(Ms,{side:"right",color:"black",children:e("editor.controls.actions.import.xml")})]}),wo(Ss,{children:[ve(Ps,{asChild:!0,children:ve(xp,{className:"p-1.5",onClick:()=>s(!0),children:ve(C_,{})})}),ve(Ms,{side:"right",color:"black",children:e("editor.controls.actions.import.mermaid")})]})]})]}),ve("input",{ref:a,type:"file",className:"sr-only",accept:L_,onChange:l}),ve(yp,{open:i,onOpenChange:s})]})}import{useCallback as k_,useState as R_}from"react";import{Button as O_,DropdownMenu as V_,DropdownMenuContent as H_,DropdownMenuItem as bp,DropdownMenuTrigger as G_,Tooltip as Ls,TooltipContent as Ds,TooltipTrigger as ks,useTranslation as B_}from"@produto-lecom/lecom-ui";import{useReactFlow as z_}from"@xyflow/react";import{AlignHorizontalJustifyStartIcon as F_,AlignVerticalJustifyStartIcon as Y_,NetworkIcon as W_}from"lucide-react";import{jsx as Me,jsxs as pn}from"react/jsx-runtime";function Tp(){let{t:e}=B_(),{getNodes:t,getEdges:o,setNodes:n}=z_(),{fitToNodes:r}=_t(),{toast:i}=xe(),[s,a]=R_(!1),l=k_(c=>{let d=t();if(d.length===0)return;if(d.some(m=>m.parentId)){i({content:e("editor.controls.actions.organize.feedback.pool_lane"),variant:"warning"});return}let p=d.map(m=>{var h,g,y,v;return I(T({},m),{width:(g=m.width)!=null?g:(h=m.measured)==null?void 0:h.width,height:(v=m.height)!=null?v:(y=m.measured)==null?void 0:y.height})}),{nodes:f}=yr(p,o(),c),x=new Map(f.map(m=>[m.id,m.position])),E=d.map(m=>{var h;return I(T({},m),{position:(h=x.get(m.id))!=null?h:m.position})});n(E),r(E)},[t,o,n,r,i,e]);return pn(V_,{modal:!1,open:s,onOpenChange:a,children:[Me(G_,{asChild:!0,children:Me("div",{children:pn(Ls,{children:[Me(ks,{asChild:!0,children:Me(O_,{size:"small",variant:"ghost",color:"grey",iconButton:!0,children:Me(W_,{})})}),!s&&Me(Ds,{color:"black",children:e("editor.controls.actions.organize.title")})]})})}),pn(H_,{align:"center",side:"top",sideOffset:16,className:"min-w-0 flex flex-col gap-2 p-2 shadow-sm",children:[pn(Ls,{children:[Me(ks,{asChild:!0,children:Me(bp,{className:"p-1.5",onClick:()=>l("TB"),children:Me(Y_,{})})}),Me(Ds,{side:"right",color:"black",children:e("editor.controls.actions.organize.vertical")})]}),pn(Ls,{children:[Me(ks,{asChild:!0,children:Me(bp,{className:"p-1.5",onClick:()=>l("LR"),children:Me(F_,{})})}),Me(Ds,{side:"right",color:"black",children:e("editor.controls.actions.organize.horizontal")})]})]})]})}import{Fragment as Os,jsx as ue,jsxs as je}from"react/jsx-runtime";var Vs=Q_.memo(({hasContent:e,validateDiagram:t,handleValidationComplete:o})=>{let{t:n}=U_(),{clearSelection:r}=Ke(),{mode:i,containerRef:s,featureFlags:a,isMinimapOpen:l,setIsMinimapOpen:c,isMoveTool:d,isHandTool:u,setIsMoveTool:p,setIsHandTool:f}=$(),{getNodes:x,getEdges:E}=X_(),m=vp(["v","V"],{target:s==null?void 0:s.current}),h=vp(["h","H"],{target:s==null?void 0:s.current}),g=Rs(()=>{r(),f(!0),p(!1)},[r,f,p]),y=Rs(()=>{p(!0),f(!1)},[p,f]),[v,b]=j_(!1),N=Rs(async()=>{b(!0);try{let _=x(),w=E(),S=await t({nodes:_,edges:w});o(S)}finally{b(!1)}},[x,E,t,o]);return Np(()=>{m&&!d&&i==="edit"&&y()},[m,y,d,i]),Np(()=>{h&&!u&&i==="edit"&&g()},[h,g,u,i]),je("div",{className:"flex items-center gap-2 px-3 py-2 bg-white rounded-sm shadow-md",children:[i==="edit"&&je(Os,{children:[je(ii,{children:[ue(ai,{asChild:!0,children:ue(ri,{size:"small",variant:"ghost",color:"grey",className:F(d&&"bg-grey-400"),iconButton:!0,onClick:y,children:ue(J_,{})})}),je(si,{color:"black",className:"flex items-center gap-2",children:[n("editor.controls.actions.move_tool"),ue(vs,{shortcut:"V"})]})]}),je(ii,{children:[ue(ai,{asChild:!0,children:ue(ri,{size:"small",variant:"ghost",color:"grey",className:F(u&&"bg-grey-400"),iconButton:!0,onClick:g,children:ue($_,{})})}),je(si,{color:"black",className:"flex items-center gap-2",children:[n("editor.controls.actions.hand_tool")," ",ue(vs,{shortcut:"H"})]})]})]}),ue(fp,{}),i==="edit"&&je(Os,{children:[(a==null?void 0:a.importDiagramMermaidEnabled)&&je(Os,{children:[ue(_p,{}),ue(Tp,{})]}),je(ii,{children:[ue(ai,{asChild:!0,children:ue(ri,{size:"small",variant:"ghost",color:"grey",iconButton:!0,disabled:v,onClick:N,children:v?ue(q_,{className:"animate-spin"}):ue(K_,{})})}),ue(si,{color:"black",children:n(v?"editor.controls.actions.check_loading":"editor.controls.actions.check")})]}),ue(lp,{disabled:e})]}),je(ii,{children:[ue(ai,{asChild:!0,children:ue(ri,{size:"small",variant:"ghost",color:"grey",className:F(l&&"bg-grey-400"),iconButton:!0,onClick:()=>c(!l),children:ue(Z_,{})})}),ue(si,{color:"black",children:n(l?"editor.controls.actions.minimap.close":"editor.controls.actions.minimap.open")})]})]})});Vs.displayName="ActionsControl";import e1 from"react";import{Button as wp,Tooltip as Ip,TooltipContent as Ap,TooltipTrigger as Cp,useTranslation as t1}from"@produto-lecom/lecom-ui";import{RedoIcon as o1,UndoIcon as n1}from"lucide-react";import{jsx as vt,jsxs as Hs}from"react/jsx-runtime";var Gs=e1.memo(({undo:e,redo:t,canUndo:o,canRedo:n})=>{let{t:r}=t1();return Hs("div",{className:"flex items-center gap-2 px-3 py-2 bg-white rounded-sm shadow-md",children:[Hs(Ip,{children:[vt(Cp,{asChild:!0,children:vt(wp,{size:"small",variant:"ghost",color:"grey",iconButton:!0,disabled:!o,onClick:e,children:vt(n1,{})})}),vt(Ap,{color:"black",children:r("editor.controls.history.undo")})]}),Hs(Ip,{children:[vt(Cp,{asChild:!0,children:vt(wp,{size:"small",variant:"ghost",color:"grey",iconButton:!0,disabled:!n,onClick:t,children:vt(o1,{})})}),vt(Ap,{color:"black",children:r("editor.controls.history.redo")})]})]})});Gs.displayName="HistoryControl";import{useReactFlow as r1}from"@xyflow/react";import{Button as li,Tooltip as ci,TooltipContent as di,TooltipTrigger as ui,useTranslation as i1}from"@produto-lecom/lecom-ui";import{ScanIcon as s1,ZoomIn as a1,ZoomOut as l1}from"lucide-react";import{jsx as Ne,jsxs as fn}from"react/jsx-runtime";var Sp=()=>{let{t:e}=i1(),t=!qr(),{zoomIn:o,zoomOut:n,zoomTo:r,fitView:i}=r1();return fn("div",{className:"flex items-center gap-2 px-3 py-2 bg-white rounded-sm shadow-md",children:[fn(ci,{children:[Ne(ui,{asChild:!0,children:Ne(li,{iconButton:!0,size:"small",color:"grey",variant:"ghost",disabled:t,onClick:()=>i(),children:Ne(s1,{})})}),Ne(di,{color:"black",children:e("editor.controls.zoom.fit")})]}),fn(ci,{children:[Ne(ui,{asChild:!0,children:Ne(li,{iconButton:!0,size:"small",color:"grey",variant:"ghost",disabled:t,onClick:()=>n(),children:Ne(l1,{})})}),Ne(di,{color:"black",children:e("editor.controls.zoom.out")})]}),fn(ci,{children:[Ne(ui,{asChild:!0,children:Ne(li,{iconButton:!0,size:"small",color:"grey",variant:"ghost",disabled:t,onClick:()=>r(1),children:Ne(ia,{})})}),Ne(di,{color:"black",children:e("editor.controls.zoom.reset")})]}),fn(ci,{children:[Ne(ui,{asChild:!0,children:Ne(li,{iconButton:!0,size:"small",color:"grey",variant:"ghost",disabled:t,onClick:()=>o(),children:Ne(a1,{})})}),Ne(di,{color:"black",children:e("editor.controls.zoom.in")})]})]})};import{ViewportPortal as c1}from"@xyflow/react";import{jsx as Bs,jsxs as Mp}from"react/jsx-runtime";var Pp=()=>Mp(c1,{children:[Mp("svg",{"data-export-hidden":!0,width:"20",height:"20",viewBox:"0 0 20 20",className:"text-grey-400 -translate-x-1/2 -translate-y-1/2 pointer-events-none",children:[Bs("line",{x1:"0",y1:"10",x2:"20",y2:"10",stroke:"currentcolor",strokeWidth:"1.5",strokeDasharray:"2 1"}),Bs("line",{x1:"10",y1:"0",x2:"10",y2:"20",stroke:"currentcolor",strokeWidth:"1.5",strokeDasharray:"2 1"})]}),Bs("div",{"data-export-hidden":!0,className:"absolute top-1 left-1 text-xs font-medium text-grey-400 bg-white/70 px-1 rounded-sm pointer-events-none",children:"0,0"})]});import{useStore as d1}from"@xyflow/react";import{Button as u1,Tooltip as p1,TooltipContent as f1,TooltipTrigger as m1,useTranslation as g1}from"@produto-lecom/lecom-ui";import{useRef as h1,useState as y1}from"react";import{Bot as x1}from"lucide-react";import{jsx as $t,jsxs as Lp}from"react/jsx-runtime";var Dp=()=>{let e=h1(null),{t}=g1(),{setDraggableNode:o}=po(),n=d1(c=>c.nodes.some(d=>d.type==="START_EVENT")),{setIsDragging:r}=$(),[i,s]=y1(void 0),a=[{type:"START_EVENT",icon:Nn,label:t("bpmn.start_event.variant.default")},{type:"END_EVENT",icon:Kt,label:t("bpmn.end_event.variant.default")},{type:"TASK",icon:Ao,label:t("bpmn.task.variant.default")},{type:"TASK",variant:"SUBPROCESS",icon:So,label:t("bpmn.task.variant.subprocess")},{type:"TASK",variant:"SERVICE_TASK",icon:x1,label:t("bpmn.task.variant.service_task")},{type:"TASK",variant:"SCRIPT",icon:ca,label:t("bpmn.task.variant.script")},{type:"TASK",attribute:"LOOP",icon:la,label:t("bpmn.task.attribute.loop")},{type:"GATEWAY",variant:"EXCLUSIVE",icon:Zt,label:t("bpmn.gateway.variant.exclusive")},{type:"GATEWAY",variant:"PARALLEL",icon:Jt,label:t("bpmn.gateway.variant.parallel")},{type:"GATEWAY",variant:"COMPLEX",icon:qt,label:t("bpmn.gateway.variant.complex")},{type:"LANE",icon:ra,label:t("bpmn.lane.variant.default")},{type:"ANNOTATION",icon:Tn,label:t("bpmn.annotation.variant.default")}],l=(c,d)=>{o({type:d.type,variant:d.variant,attribute:d.attribute,icon:d.icon}),s($t(d.icon,{})),c.dataTransfer.effectAllowed="move",e.current&&c.dataTransfer.setDragImage(e.current,10,10),setTimeout(()=>{r(!0)},100)};return Lp("aside",{className:"sidebar absolute z-[1] top-4 left-4",children:[$t("div",{className:"grid grid-cols-1 gap-2 p-2 bg-white rounded-md shadow-md",children:a.map((c,d)=>{let u=c.type==="START_EVENT"&&n,p=u?t("editor.toolbar.start_event_already_exists"):c.label;return Lp(p1,{children:[$t(m1,{asChild:!0,children:$t(u1,{className:F("[&>svg]:size-6",{"opacity-50 cursor-not-allowed":u}),size:"small",variant:"ghost",color:"grey",draggable:!u,disabled:u,iconButton:!0,onDragStart:u?void 0:f=>l(f,c),children:$t(c.icon,{})},d)}),$t(f1,{color:"black",side:"right",children:p})]},d)})}),$t("div",{ref:e,className:"absolute w-0 h-0 top-0 left-0 z-[-1] bg-transparent",children:i})]})};import{jsx as ze,jsxs as pi}from"react/jsx-runtime";var zs=e=>e.preventDefault(),Fs=N1((e,t)=>{let{instanceId:o,containerRef:n,mode:r,isMinimapOpen:i,isMoveTool:s,isHandTool:a,isExporting:l}=$(),c=v1("Space",{target:n==null?void 0:n.current}),d=kp(a),u=kp(c),{nodes:p,edges:f,actions:x,events:E,components:m,controls:h}=Uu(),{t:g}=S1(),y=qr();d.current=a,u.current=c;let v=$u(n,d,u);w1(t,()=>({selectElements:x.selectElements,clearSelection:x.clearSelection}));let b=a||c||r!=="edit",N=b?fu:sn,_=a||c||v,w=s&&!c&&!v,S=r==="edit"&&w,M=!b&&!v,L=r==="view"||w;return pi("div",{ref:n,className:"w-full h-full outline-none",tabIndex:0,children:[r==="edit"&&ze(Dp,{}),ze(qu,{}),pi(b1,I(T({},E),{id:`modeler-${o}`,className:F(r.toLowerCase(),{"is-hand-tool":_,"is-pan-tool-active":_}),edges:f,nodes:p,nodeTypes:Qd,edgeTypes:jd,onlyRenderVisibleElements:!l,minZoom:Es,maxZoom:iu,panOnDrag:N,panOnScroll:!0,selectionOnDrag:M,elevateEdgesOnSelect:!0,elevateNodesOnSelect:!0,elementsSelectable:L,nodesConnectable:S,nodesDraggable:S,connectionLineComponent:Jd,selectionMode:T1.Partial,multiSelectionKeyCode:["Control","Meta"],deleteKeyCode:S?"Delete":null,selectionKeyCode:null,defaultViewport:du,connectOnClick:!1,connectionRadius:50,onPaneContextMenu:zs,onNodeContextMenu:zs,onEdgeContextMenu:zs,proOptions:mu,children:[ze(E1,{gap:nu,size:ou,color:tu,bgColor:eu}),ze(Pp,{}),i&&pi(I1,{children:[ze(C1,{asChild:!0,children:ze("div",{className:"absolute bottom-[0px] left-[0px] z-[5]",children:ze(_1,{pannable:!0,zoomable:!0,position:ru,className:"shadow-md rounded-md",ariaLabel:"",style:{pointerEvents:"all",position:"relative"}})})}),ze(A1,{color:"black",children:g("editor.controls.actions.minimap.label")})]}),pi("div",{className:"absolute z-10 bottom-4 left-1/2 -translate-x-1/2 flex gap-4",children:[r==="edit"&&ze(Gs,T({},h)),r!=="readonly"&&ze(Vs,{hasContent:y,validateDiagram:x.validateDiagram,handleValidationComplete:x.handleValidationComplete}),ze(Sp,{})]}),ze(m.HelperLines,{})]}))]})});Fs.displayName="Editor";import{useStore as M1}from"@xyflow/react";import{useEffect as P1,useRef as Rp}from"react";import{jsx as D1}from"react/jsx-runtime";var L1=e=>({width:e.width,height:e.height,transform:e.transform}),Ys="rgba(51, 103, 217, 0.4)",mc=({horizontal:e,vertical:t})=>{let{width:o,height:n,transform:r}=M1(L1),i=Rp(null),s=Rp(1);return P1(()=>{let a=i.current,l=a==null?void 0:a.getContext("2d");if(!l||!a)return;let c=Math.min(window.devicePixelRatio||1,2),d=Math.ceil(o*c),u=Math.ceil(n*c);(a.width!==d||a.height!==u)&&(a.width=d,a.height=u,s.current=c),l.setTransform(s.current,0,0,s.current,0,0),l.clearRect(0,0,o,n),l.strokeStyle=Ys,t&&(l.beginPath(),l.strokeStyle=t.color||Ys,l.moveTo(t.position*r[2]+r[0],0),l.lineTo(t.position*r[2]+r[0],n),l.stroke()),e&&(l.beginPath(),l.strokeStyle=e.color||Ys,l.moveTo(0,e.position*r[2]+r[1]),l.lineTo(o,e.position*r[2]+r[1]),l.stroke())},[o,n,r,e,t]),D1("canvas",{ref:i,className:"w-full h-full absolute z-10 pointer-events-none"})};import{i18n as k1,Notification as R1,TooltipProvider as O1}from"@produto-lecom/lecom-ui";import{createContext as V1,useContext as H1,useEffect as G1,useState as B1}from"react";import{jsx as Op,jsxs as F1}from"react/jsx-runtime";var Je=new Map,Vp=V1(null),Qo=()=>{let e=H1(Vp);if(!e)throw new Error("useModeler must be used within an <ModelerProvider />");return e},z1=({locale:e,defaultMode:t="view",featureFlags:o,toast:n,children:r})=>{let[i,s]=B1(e||"pt_BR");G1(()=>{e&&(s(e),k1.changeLanguage(e))},[e]);let a=E=>{let m=Je.size;if(m===0)throw new Error("No modeler instances found");if(m===1||!E){let[g]=Je.values();return g}let h=Je.get(E);if(!h)throw new Error(`Modeler instance with ID "${E}" not found`);return h},l=(E,m)=>{let h=a(m);return h==null?void 0:h.selectElements(E)},c=async E=>{let m=a(E);return m==null?void 0:m.clearSelection()},d=(E,m)=>{let h=a(m);return h==null?void 0:h.configureElement(E)},u=(E,m)=>{let h=a(m);return h==null?void 0:h.getConfigureElement(E)},p=async(E,m)=>{let h=a(m);await(h==null?void 0:h.importFromMxGraph(E))},f=E=>{let m=a(E);return m==null?void 0:m.exportToMxGraph()},x=E=>{let m=a(E);return(m==null?void 0:m.getElementsCount())||0};return Op(Vp.Provider,{value:{defaultMode:t,locale:i,featureFlags:o,selectElements:l,clearSelection:c,configureElement:d,getConfigureElement:u,importDiagram:p,exportDiagram:f,getElementsCount:x,toast:n},children:F1(O1,{children:[!n&&Op(R1,{type:"toast",placement:"topRight",enableClose:!0,showProgress:!0,pauseOnHover:!0}),r]})})};import{jsx as Ws}from"react/jsx-runtime";var Gp=X1(null),$=()=>{let e=U1(Gp);if(!e)throw new Error("useModelerInstance must be used within an <Modeler />");return e},Z1=({selectorRef:e,initialDiagram:t,instanceId:o,mode:n,edgeHighlight:r=!0,validateCustomDiagram:i,validateDeleteElements:s,onElementChanges:a,onConfigureElement:l,onElementClick:c,onSubprocessValidationClick:d})=>{let u=q1(null),{t:p}=Y1(),{defaultMode:f,featureFlags:x}=Qo(),E=K1(),[m]=Fe(o||E),[h,g]=Fe(n||f||"edit"),[y,v]=Fe(Zo),[b,N]=Fe(!1),[_,w]=Fe(!0),[S,M]=Fe(!1),[L,D]=Fe(!1),[O,R]=Fe(!1),[V,G]=Fe(!1),[B,A]=Fe(!1),[C,k]=Fe(!1),[P,K]=Fe(null);$1(()=>{n&&g(n)},[n]);let Z=!t,Y=Hp(()=>t||Pc(p),[t,p]),H=Hp(()=>({instanceId:m,containerRef:u,initialDiagram:Y,mode:h,featureFlags:x,edgeHighlight:r,isEdit:h==="edit",isView:h==="view",isReadOnly:h==="readonly",isNewDiagram:Z,lastElementId:y,isInitialized:b,isMinimapOpen:L,isMoveTool:_,isHandTool:S,isDragging:O,isConnecting:V,isRemovingElements:B,isExporting:C,setLastElementId:v,setIsInitialized:N,reconnectingEdgeId:P,setIsMinimapOpen:D,setIsMoveTool:w,setIsHandTool:M,setIsDragging:R,setIsConnecting:G,setIsRemovingElements:A,setIsExporting:k,setReconnectingEdgeId:K,validateCustomDiagram:i,validateDeleteElements:s,onElementChanges:a,onConfigureElement:l,onElementClick:c,onSubprocessValidationClick:d}),[m,u,Y,h,x,r,Z,y,b,L,_,S,O,V,B,C,P,i,s,a,l,c,d]);return Ws(W1,{children:Ws(Gp.Provider,{value:H,children:Ws(Fs,{ref:e})})})};export{le as EditorMode,hi as ElementPosition,_n as ElementType,yi as GatewayElementVariant,ke as GatewayVariant,Z1 as Modeler,z1 as ModelerProvider,$e as NodeAttribute,Q as NodeType,Pe as NodeVariant,xi as RoutingVariant,Qo as useModeler};