lecom-modeler 0.26.0 → 0.26.1

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,9 +1,9 @@
1
- var Pu=Object.defineProperty,Lu=Object.defineProperties;var ku=Object.getOwnPropertyDescriptors;var En=Object.getOwnPropertySymbols;var ds=Object.prototype.hasOwnProperty,us=Object.prototype.propertyIsEnumerable;var cs=(e,t,o)=>t in e?Pu(e,t,{enumerable:!0,configurable:!0,writable:!0,value:o}):e[t]=o,T=(e,t)=>{for(var o in t||(t={}))ds.call(t,o)&&cs(e,o,t[o]);if(En)for(var o of En(t))us.call(t,o)&&cs(e,o,t[o]);return e},v=(e,t)=>Lu(e,ku(t));var tt=(e,t)=>{var o={};for(var n in e)ds.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&&us.call(e,n)&&(o[n]=e[n]);return o};var ii=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 Ru,Translations as Du}from"@produto-lecom/lecom-ui";var ps={translations:{general:{layout:{title:"Modeler"}},editor:{toolbar:{delete:"Delete",configure_node:"Configure activity",configure_edge:"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",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."},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",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",minimap:{label:"Minimap",open:"Open minimap",close:"Hide minimap"}},history:{undo:"Undo",redo:"Redo"}},modals:{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:"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:"The gateway does 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_referenced_not_configured:"The subprocess reference is not properly configured",start_event_not_found:"At least one start event is required",end_event_not_found:"At least one end event is required"}},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"},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:"It is not possible to import the diagram from the Governance platform, since the diagram has already been initialized"},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 fs={translations:{general:{layout:{title:"Modeler"}},editor:{toolbar:{delete:"Eliminar",configure_node:"Configurar actividad",configure_edge:"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",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."},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",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",minimap:{label:"Minimapa",open:"Abrir minimapa",close:"Ocultar minimapa"}},history:{undo:"Deshacer",redo:"Rehacer"}},modals:{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:"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:"La compuerta no tiene 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_referenced_not_configured:"La referencia al subproceso no est\xE1 configurada correctamente",start_event_not_found:"Es necesario tener al menos un evento de inicio",end_event_not_found:"Es necesario tener al menos un evento final"}},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"},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:"No es posible importar el diagrama de la plataforma Governance, ya que el diagrama ya ha sido iniciado"},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 ms={translations:{general:{layout:{title:"Modeler"}},editor:{toolbar:{delete:"Excluir",configure_node:"Configurar atividade",configure_edge:"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",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."},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",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",minimap:{label:"Minimapa",open:"Abrir minimapa",close:"Ocultar minimapa"}},history:{undo:"Desfazer",redo:"Refazer"}},modals:{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:"Atividade com loop"}},validation:{success:{title:"Diagrama v\xE1lidado 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:"O gateway n\xE3o possui 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_referenced_not_configured:"A refer\xEAncia ao subprocesso n\xE3o est\xE1 configurada corretamente",start_event_not_found:"\xC9 necess\xE1rio ter ao menos um evento inicial",end_event_not_found:"\xC9 necess\xE1rio ter ao menos um evento final"}},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"},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:"N\xE3o \xE9 poss\xEDvel importar o diagrama da plataforma Governance, pois o diagrama j\xE1 foi iniciado"},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 gs={pt_BR:ms,en_US:ps,es_ES:fs};var hs,ys,Ou=(ys=(hs=ii("LecomUserLanguage"))!=null?hs:ii("org.springframework.web.servlet.i18n.CookieLocaleResolver.LOCALE"))!=null?ys:Du.PT_BR;Ru({lng:Ou,resources:gs});var Re=(n=>(n.EDIT="edit",n.VIEW="view",n.READONLY="readonly",n))(Re||{});var bn=(r=>(r.ACTIVITY="activity",r.ROUTING="routing",r.GATEWAY="gateway",r.SUB_PROCESS="sub_process",r))(bn||{}),si=(n=>(n.START="start",n.END="end",n.BETWEEN="between",n))(si||{}),ai=(n=>(n.SCRIPT="script",n.LOOP="loop",n.SCRIPT_LOOP="script_loop",n))(ai||{}),li=(d=>(d.SIMPLE="simple",d.LOOP="loop",d.SCRIPT="script",d.SCRIPT_LOOP="script_loop",d.COMPLEX="complex",d.EXCLUSIVE="exclusive",d.PARALLEL="parallel",d.FINAL="final",d.TO_SUB_PROCESS="to_sub_process",d.FROM_SUB_PROCESS="from_sub_process",d))(li||{});import{RotateCcw as Ku,ScrollText as qu,SquarePlus as Zu}from"lucide-react";import{jsx as _n,jsxs as Vu}from"react/jsx-runtime";var Tn=({size:e=24,className:t})=>Vu("svg",{width:e,height:e,viewBox:"0 0 24 24",xmlns:"http://www.w3.org/2000/svg",fill:"#6b7280",className:t,children:[_n("path",{strokeWidth:"2",d:"M16 3V3.5085V11.9998V20.4915V21H16.5411H21.4592H22V19.123H21.4592H17.9974V11.9998V4.8773H21.4592H22V3H21.4592H16.5411H16Z"}),_n("path",{d:"M4.41026 16.9999L2 18.7861L3.89693 21.1103L6.3072 19.324L4.41026 16.9999Z"}),_n("path",{d:"M8.41026 13.9999L6 15.7861L7.89693 18.1103L10.3072 16.324L8.41026 13.9999Z"}),_n("path",{d:"M12.4313 10.954L10.021 12.7402L11.9179 15.0644L14.3282 13.2781L12.4313 10.954Z"})]});import{jsx as xs}from"react/jsx-runtime";var jt=({size:e=24,className:t})=>xs("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:xs("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 Lo,jsxs as Hu}from"react/jsx-runtime";var eo=({size:e=24,className:t})=>Hu("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:[Lo("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"}),Lo("path",{d:"M12 8V16",strokeLinecap:"round",strokeLinejoin:"round"}),Lo("path",{d:"M8 12H16",strokeLinecap:"round",strokeLinejoin:"round"}),Lo("path",{d:"M9.17139 9.17188L14.8282 14.8287",strokeLinecap:"round",strokeLinejoin:"round"}),Lo("path",{d:"M14.8281 9.17188L9.17127 14.8287",strokeLinecap:"round",strokeLinejoin:"round"})]});import{jsx as ci,jsxs as Gu}from"react/jsx-runtime";var to=({size:e=24,className:t})=>Gu("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:[ci("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"}),ci("path",{d:"M14.8286 9.17188L9.17176 14.8287",strokeLinecap:"round",strokeLinejoin:"round"}),ci("path",{d:"M9.17139 9.17188L14.8282 14.8287",strokeLinecap:"round",strokeLinejoin:"round"})]});import{jsx as di,jsxs as Bu}from"react/jsx-runtime";var oo=({size:e=24,className:t})=>Bu("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:[di("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"}),di("path",{d:"M12 8V16",strokeLinecap:"round",strokeLinejoin:"round"}),di("path",{d:"M8 12H16",strokeLinecap:"round",strokeLinejoin:"round"})]});import{jsx as ui,jsxs as zu}from"react/jsx-runtime";var Es=({size:e=24,className:t})=>ui("svg",{width:e,height:e,viewBox:"0 0 34 24",xmlns:"http://www.w3.org/2000/svg",fill:"currentColor",className:t,children:zu("g",{children:[ui("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"}),ui("path",{d:"M24.5 4.5L28 1M28 1L31.5 4.5M28 1V8",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round"})]})});import{clsx as Yu}from"clsx";import{twMerge as Fu}from"tailwind-merge";function D(...e){return Fu(Yu(e))}var xt=(e=0,t=0)=>e<t?t:e,Nn=(e=1e3)=>new Promise(t=>{setTimeout(t,e)});import{jsx as bs,jsxs as Wu}from"react/jsx-runtime";var _s=({size:e=24,className:t})=>Wu("svg",{width:e,height:e,viewBox:"0 0 24 24",fill:"none",stroke:"#6b7280",strokeWidth:2,xmlns:"http://www.w3.org/2000/svg",className:D("stroke-2",t),children:[bs("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"}),bs("path",{d:"M9 3V21",strokeLinecap:"round",strokeLinejoin:"round"})]});import{jsx as pi}from"react/jsx-runtime";var Ts=({size:e=24,className:t})=>pi("svg",{width:e,height:e,viewBox:"0 0 24 24",xmlns:"http://www.w3.org/2000/svg",stroke:"currentColor",className:t,children:pi("g",{children:pi("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 Ns}from"react/jsx-runtime";var vn=({size:e=24,className:t})=>Ns("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:Ns("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 vs}from"react/jsx-runtime";var ko=({size:e=24,className:t})=>vs("svg",{width:e,height:e,viewBox:"0 0 24 24",xmlns:"http://www.w3.org/2000/svg",fill:"white",stroke:"#6b7280",className:D("stroke-2",t),children:vs("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 fi,jsxs as Xu}from"react/jsx-runtime";var ws=({size:e=24,className:t})=>Xu("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:[fi("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"}),fi("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"}),fi("path",{d:"M7.5 7.5V10H10",strokeWidth:"1.5",fill:"none",strokeLinecap:"round",strokeLinejoin:"round"})]});import{jsx as Ro,jsxs as Uu}from"react/jsx-runtime";var As=({size:e=24,className:t})=>Uu("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:[Ro("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"}),Ro("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"}),Ro("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"}),Ro("path",{d:"M13.5 12H11",strokeWidth:"1",strokeLinecap:"round",strokeLinejoin:"round"}),Ro("path",{d:"M13.5 10H11",strokeWidth:"1",strokeLinecap:"round",strokeLinejoin:"round"})]});import{jsx as wn,jsxs as $u}from"react/jsx-runtime";var Is=({size:e=24,className:t})=>$u("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:[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 oe=(s=>(s.START_EVENT="START_EVENT",s.END_EVENT="END_EVENT",s.TASK="TASK",s.LANE="LANE",s.GATEWAY="GATEWAY",s.ANNOTATION="ANNOTATION",s.UNSUPPORTED="UNSUPPORTED",s))(oe||{}),Ke=(o=>(o.SCRIPT="SCRIPT",o.SUBPROCESS="SUBPROCESS",o))(Ke||{}),An={SCRIPT:{icon:qu},SUBPROCESS:{icon:Zu}},ot=(t=>(t.LOOP="LOOP",t))(ot||{}),In={LOOP:{icon:Ku}},qe=(n=>(n.EXCLUSIVE="EXCLUSIVE",n.PARALLEL="PARALLEL",n.COMPLEX="COMPLEX",n))(qe||{}),mi={EXCLUSIVE:{icon:to},PARALLEL:{icon:oo},COMPLEX:{icon:eo}};import{ReactFlowProvider as jx}from"@xyflow/react";import{createContext as eE,useContext as tE,useEffect as oE,useId as nE,useMemo as rE,useState as je}from"react";import{Background as Ax,MiniMap as Ix,ReactFlow as Cx,SelectionMode as Sx,useKeyPress as Mx}from"@xyflow/react";import{forwardRef as Px,useEffect as vu,useImperativeHandle as Lx,useRef as kx,useState as Rx}from"react";import{useTranslation as s0}from"@produto-lecom/lecom-ui";import{useEdgesState as a0,useNodesState as l0,useOnSelectionChange as c0,useReactFlow as d0,useStoreApi as u0}from"@xyflow/react";import{useCallback as Rt,useEffect as p0}from"react";import{Position as Do}from"@xyflow/react";function Cs(e,t){var E,w,b,x;let{width:o=0,height:n=0}=e.measured||{width:0,height:0},r=e.internals.positionAbsolute,i=t.internals.positionAbsolute,a=o/2,s=n/2,l=r.x+a,c=r.y+s,d=i.x+((w=(E=t==null?void 0:t.measured)==null?void 0:E.width)!=null?w:0)/2,u=i.y+((x=(b=t==null?void 0:t.measured)==null?void 0:b.height)!=null?x:0)/2,f=(d-l)/(2*a)-(u-c)/(2*s),p=(d-l)/(2*a)+(u-c)/(2*s),g=1/(Math.abs(f)+Math.abs(p)||1),y=g*f,m=g*p,_=a*(y+m)+l,h=s*(-y+m)+c;return{x:_,y:h}}function Ss(e,t){var c,d,u,f;let{positionAbsolute:o}=e.internals,n=(d=(c=e.measured)==null?void 0:c.width)!=null?d:0,r=(f=(u=e.measured)==null?void 0:u.height)!=null?f:0,i=Math.round(o.x),a=Math.round(o.y),s=Math.round(t.x),l=Math.round(t.y);return s<=i+1?Do.Left:s>=i+n-1?Do.Right:l<=a+1?Do.Top:l>=a+r-1?Do.Bottom:Do.Top}function no(e,t){let o=Cs(e,t),n=Cs(t,e),r=Ss(e,o),i=Ss(t,n);return{sx:o.x,sy:o.y,tx:n.x,ty:n.y,sourcePos:r,targetPos:i}}function Cn(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"}}import{create as Ju}from"zustand";import{useReactFlow as Qu}from"@xyflow/react";import{useCallback as ju}from"react";var Sn=()=>{let{setEdges:e}=Qu();return ju(()=>{let o=Ot.getState().pathEdgeIds;e(n=>n.map(r=>v(T({},r),{selected:o.includes(r.id)})))},[e])},Ot=Ju((e,t)=>({statusByNodeId:{},statusData:{},pathEdgeIds:[],setTaskStatuses:o=>{o!=null&&o.length&&e(n=>{let r=T({},n.statusByNodeId),i=T({},n.statusData),a=!1;return o.forEach(s=>{let l=`${s.diagramId}-${s.activityId}`;r[s.diagramId]!==s.status&&(r[s.diagramId]=s.status,i[l]=s,a=!0)}),a?{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=[],a={};o.forEach(d=>{a[d.source]||(a[d.source]=[]),a[d.source].push({targetId:d.target,edgeId:d.id})});let s=r[0],l=r[r.length-1];o.forEach(d=>{d.target===s&&i.push(d.id)}),o.forEach(d=>{d.source===l&&i.push(d.id)});let c=(d,u)=>{let f=[],p=new Set;for(f.push({node:d,path:[]}),p.add(d);f.length>0;){let{node:g,path:y}=f.shift();if(g===u)return y;let m=a[g]||[];for(let{targetId:_,edgeId:h}of m)p.has(_)||(p.add(_),f.push({node:_,path:[...y,h]}))}return[]};for(let d=0;d<r.length-1;d++){let u=r[d],f=r[d+1],p=c(u,f);p.length>0&&i.push(...p)}i.length>0&&e({pathEdgeIds:i})}}));import{useNodesInitialized as gm,useReactFlow as hm,useStore as ym}from"@xyflow/react";import{useCallback as Zo,useEffect as xm,useRef as Em,useState as Nl}from"react";import{shallow as bm}from"zustand/shallow";var ep={value:()=>{}};function Ps(){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 Mn(o)}function Mn(e){this._=e}function tp(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}})}Mn.prototype=Ps.prototype={constructor:Mn,on:function(e,t){var o=this._,n=tp(e+"",o),r,i=-1,a=n.length;if(arguments.length<2){for(;++i<a;)if((r=(e=n[i]).type)&&(r=op(o[r],e.name)))return r;return}if(t!=null&&typeof t!="function")throw new Error("invalid callback: "+t);for(;++i<a;)if(r=(e=n[i]).type)o[r]=Ms(o[r],e.name,t);else if(t==null)for(r in o)o[r]=Ms(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 Mn(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 op(e,t){for(var o=0,n=e.length,r;o<n;++o)if((r=e[o]).name===t)return r.value}function Ms(e,t,o){for(var n=0,r=e.length;n<r;++n)if(e[n].name===t){e[n]=ep,e=e.slice(0,n).concat(e.slice(n+1));break}return o!=null&&e.push({name:t,value:o}),e}var gi=Ps;var Pn="http://www.w3.org/1999/xhtml",hi={svg:"http://www.w3.org/2000/svg",xhtml:Pn,xlink:"http://www.w3.org/1999/xlink",xml:"http://www.w3.org/XML/1998/namespace",xmlns:"http://www.w3.org/2000/xmlns/"};function at(e){var t=e+="",o=t.indexOf(":");return o>=0&&(t=e.slice(0,o))!=="xmlns"&&(e=e.slice(o+1)),hi.hasOwnProperty(t)?{space:hi[t],local:e}:e}function np(e){return function(){var t=this.ownerDocument,o=this.namespaceURI;return o===Pn&&t.documentElement.namespaceURI===Pn?t.createElement(e):t.createElementNS(o,e)}}function rp(e){return function(){return this.ownerDocument.createElementNS(e.space,e.local)}}function Ln(e){var t=at(e);return(t.local?rp:np)(t)}function ip(){}function Vt(e){return e==null?ip:function(){return this.querySelector(e)}}function Ls(e){typeof e!="function"&&(e=Vt(e));for(var t=this._groups,o=t.length,n=new Array(o),r=0;r<o;++r)for(var i=t[r],a=i.length,s=n[r]=new Array(a),l,c,d=0;d<a;++d)(l=i[d])&&(c=e.call(l,l.__data__,d,i))&&("__data__"in l&&(c.__data__=l.__data__),s[d]=c);return new be(n,this._parents)}function yi(e){return e==null?[]:Array.isArray(e)?e:Array.from(e)}function sp(){return[]}function Oo(e){return e==null?sp:function(){return this.querySelectorAll(e)}}function ap(e){return function(){return yi(e.apply(this,arguments))}}function ks(e){typeof e=="function"?e=ap(e):e=Oo(e);for(var t=this._groups,o=t.length,n=[],r=[],i=0;i<o;++i)for(var a=t[i],s=a.length,l,c=0;c<s;++c)(l=a[c])&&(n.push(e.call(l,l.__data__,c,a)),r.push(l));return new be(n,r)}function Vo(e){return function(){return this.matches(e)}}function kn(e){return function(t){return t.matches(e)}}var lp=Array.prototype.find;function cp(e){return function(){return lp.call(this.children,e)}}function dp(){return this.firstElementChild}function Rs(e){return this.select(e==null?dp:cp(typeof e=="function"?e:kn(e)))}var up=Array.prototype.filter;function pp(){return Array.from(this.children)}function fp(e){return function(){return up.call(this.children,e)}}function Ds(e){return this.selectAll(e==null?pp:fp(typeof e=="function"?e:kn(e)))}function Os(e){typeof e!="function"&&(e=Vo(e));for(var t=this._groups,o=t.length,n=new Array(o),r=0;r<o;++r)for(var i=t[r],a=i.length,s=n[r]=[],l,c=0;c<a;++c)(l=i[c])&&e.call(l,l.__data__,c,i)&&s.push(l);return new be(n,this._parents)}function Rn(e){return new Array(e.length)}function Vs(){return new be(this._enter||this._groups.map(Rn),this._parents)}function Ho(e,t){this.ownerDocument=e.ownerDocument,this.namespaceURI=e.namespaceURI,this._next=null,this._parent=e,this.__data__=t}Ho.prototype={constructor:Ho,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 Hs(e){return function(){return e}}function mp(e,t,o,n,r,i){for(var a=0,s,l=t.length,c=i.length;a<c;++a)(s=t[a])?(s.__data__=i[a],n[a]=s):o[a]=new Ho(e,i[a]);for(;a<l;++a)(s=t[a])&&(r[a]=s)}function gp(e,t,o,n,r,i,a){var s,l,c=new Map,d=t.length,u=i.length,f=new Array(d),p;for(s=0;s<d;++s)(l=t[s])&&(f[s]=p=a.call(l,l.__data__,s,t)+"",c.has(p)?r[s]=l:c.set(p,l));for(s=0;s<u;++s)p=a.call(e,i[s],s,i)+"",(l=c.get(p))?(n[s]=l,l.__data__=i[s],c.delete(p)):o[s]=new Ho(e,i[s]);for(s=0;s<d;++s)(l=t[s])&&c.get(f[s])===l&&(r[s]=l)}function hp(e){return e.__data__}function Gs(e,t){if(!arguments.length)return Array.from(this,hp);var o=t?gp:mp,n=this._parents,r=this._groups;typeof e!="function"&&(e=Hs(e));for(var i=r.length,a=new Array(i),s=new Array(i),l=new Array(i),c=0;c<i;++c){var d=n[c],u=r[c],f=u.length,p=yp(e.call(d,d&&d.__data__,c,n)),g=p.length,y=s[c]=new Array(g),m=a[c]=new Array(g),_=l[c]=new Array(f);o(d,u,y,m,_,p,t);for(var h=0,E=0,w,b;h<g;++h)if(w=y[h]){for(h>=E&&(E=h+1);!(b=m[E])&&++E<g;);w._next=b||null}}return a=new be(a,n),a._enter=s,a._exit=l,a}function yp(e){return typeof e=="object"&&"length"in e?e:Array.from(e)}function Bs(){return new be(this._exit||this._groups.map(Rn),this._parents)}function zs(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 Ys(e){for(var t=e.selection?e.selection():e,o=this._groups,n=t._groups,r=o.length,i=n.length,a=Math.min(r,i),s=new Array(r),l=0;l<a;++l)for(var c=o[l],d=n[l],u=c.length,f=s[l]=new Array(u),p,g=0;g<u;++g)(p=c[g]||d[g])&&(f[g]=p);for(;l<r;++l)s[l]=o[l];return new be(s,this._parents)}function Fs(){for(var e=this._groups,t=-1,o=e.length;++t<o;)for(var n=e[t],r=n.length-1,i=n[r],a;--r>=0;)(a=n[r])&&(i&&a.compareDocumentPosition(i)^4&&i.parentNode.insertBefore(a,i),i=a);return this}function Ws(e){e||(e=xp);function t(u,f){return u&&f?e(u.__data__,f.__data__):!u-!f}for(var o=this._groups,n=o.length,r=new Array(n),i=0;i<n;++i){for(var a=o[i],s=a.length,l=r[i]=new Array(s),c,d=0;d<s;++d)(c=a[d])&&(l[d]=c);l.sort(t)}return new be(r,this._parents).order()}function xp(e,t){return e<t?-1:e>t?1:e>=t?0:NaN}function Xs(){var e=arguments[0];return arguments[0]=this,e.apply(null,arguments),this}function Us(){return Array.from(this)}function $s(){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 a=n[r];if(a)return a}return null}function Ks(){let e=0;for(let t of this)++e;return e}function qs(){return!this.node()}function Zs(e){for(var t=this._groups,o=0,n=t.length;o<n;++o)for(var r=t[o],i=0,a=r.length,s;i<a;++i)(s=r[i])&&e.call(s,s.__data__,i,r);return this}function Ep(e){return function(){this.removeAttribute(e)}}function bp(e){return function(){this.removeAttributeNS(e.space,e.local)}}function _p(e,t){return function(){this.setAttribute(e,t)}}function Tp(e,t){return function(){this.setAttributeNS(e.space,e.local,t)}}function Np(e,t){return function(){var o=t.apply(this,arguments);o==null?this.removeAttribute(e):this.setAttribute(e,o)}}function vp(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 Js(e,t){var o=at(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?bp:Ep:typeof t=="function"?o.local?vp:Np:o.local?Tp:_p)(o,t))}function Dn(e){return e.ownerDocument&&e.ownerDocument.defaultView||e.document&&e||e.defaultView}function wp(e){return function(){this.style.removeProperty(e)}}function Ap(e,t,o){return function(){this.style.setProperty(e,t,o)}}function Ip(e,t,o){return function(){var n=t.apply(this,arguments);n==null?this.style.removeProperty(e):this.style.setProperty(e,n,o)}}function Qs(e,t,o){return arguments.length>1?this.each((t==null?wp:typeof t=="function"?Ip:Ap)(e,t,o==null?"":o)):Et(this.node(),e)}function Et(e,t){return e.style.getPropertyValue(t)||Dn(e).getComputedStyle(e,null).getPropertyValue(t)}function Cp(e){return function(){delete this[e]}}function Sp(e,t){return function(){this[e]=t}}function Mp(e,t){return function(){var o=t.apply(this,arguments);o==null?delete this[e]:this[e]=o}}function js(e,t){return arguments.length>1?this.each((t==null?Cp:typeof t=="function"?Mp:Sp)(e,t)):this.node()[e]}function ea(e){return e.trim().split(/^|\s+/)}function xi(e){return e.classList||new ta(e)}function ta(e){this._node=e,this._names=ea(e.getAttribute("class")||"")}ta.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 oa(e,t){for(var o=xi(e),n=-1,r=t.length;++n<r;)o.add(t[n])}function na(e,t){for(var o=xi(e),n=-1,r=t.length;++n<r;)o.remove(t[n])}function Pp(e){return function(){oa(this,e)}}function Lp(e){return function(){na(this,e)}}function kp(e,t){return function(){(t.apply(this,arguments)?oa:na)(this,e)}}function ra(e,t){var o=ea(e+"");if(arguments.length<2){for(var n=xi(this.node()),r=-1,i=o.length;++r<i;)if(!n.contains(o[r]))return!1;return!0}return this.each((typeof t=="function"?kp:t?Pp:Lp)(o,t))}function Rp(){this.textContent=""}function Dp(e){return function(){this.textContent=e}}function Op(e){return function(){var t=e.apply(this,arguments);this.textContent=t==null?"":t}}function ia(e){return arguments.length?this.each(e==null?Rp:(typeof e=="function"?Op:Dp)(e)):this.node().textContent}function Vp(){this.innerHTML=""}function Hp(e){return function(){this.innerHTML=e}}function Gp(e){return function(){var t=e.apply(this,arguments);this.innerHTML=t==null?"":t}}function sa(e){return arguments.length?this.each(e==null?Vp:(typeof e=="function"?Gp:Hp)(e)):this.node().innerHTML}function Bp(){this.nextSibling&&this.parentNode.appendChild(this)}function aa(){return this.each(Bp)}function zp(){this.previousSibling&&this.parentNode.insertBefore(this,this.parentNode.firstChild)}function la(){return this.each(zp)}function ca(e){var t=typeof e=="function"?e:Ln(e);return this.select(function(){return this.appendChild(t.apply(this,arguments))})}function Yp(){return null}function da(e,t){var o=typeof e=="function"?e:Ln(e),n=t==null?Yp:typeof t=="function"?t:Vt(t);return this.select(function(){return this.insertBefore(o.apply(this,arguments),n.apply(this,arguments)||null)})}function Fp(){var e=this.parentNode;e&&e.removeChild(this)}function ua(){return this.each(Fp)}function Wp(){var e=this.cloneNode(!1),t=this.parentNode;return t?t.insertBefore(e,this.nextSibling):e}function Xp(){var e=this.cloneNode(!0),t=this.parentNode;return t?t.insertBefore(e,this.nextSibling):e}function pa(e){return this.select(e?Xp:Wp)}function fa(e){return arguments.length?this.property("__data__",e):this.node().__data__}function Up(e){return function(t){e.call(this,t,this.__data__)}}function $p(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 Kp(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 qp(e,t,o){return function(){var n=this.__on,r,i=Up(t);if(n){for(var a=0,s=n.length;a<s;++a)if((r=n[a]).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 ma(e,t,o){var n=$p(e+""),r,i=n.length,a;if(arguments.length<2){var s=this.node().__on;if(s){for(var l=0,c=s.length,d;l<c;++l)for(r=0,d=s[l];r<i;++r)if((a=n[r]).type===d.type&&a.name===d.name)return d.value}return}for(s=t?qp:Kp,r=0;r<i;++r)this.each(s(n[r],t,o));return this}function ga(e,t,o){var n=Dn(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 Zp(e,t){return function(){return ga(this,e,t)}}function Jp(e,t){return function(){return ga(this,e,t.apply(this,arguments))}}function ha(e,t){return this.each((typeof t=="function"?Jp:Zp)(e,t))}function*ya(){for(var e=this._groups,t=0,o=e.length;t<o;++t)for(var n=e[t],r=0,i=n.length,a;r<i;++r)(a=n[r])&&(yield a)}var Qp=[null];function be(e,t){this._groups=e,this._parents=t}function xa(){return new be([[document.documentElement]],Qp)}function jp(){return this}be.prototype=xa.prototype={constructor:be,select:Ls,selectAll:ks,selectChild:Rs,selectChildren:Ds,filter:Os,data:Gs,enter:Vs,exit:Bs,join:zs,merge:Ys,selection:jp,order:Fs,sort:Ws,call:Xs,nodes:Us,node:$s,size:Ks,empty:qs,each:Zs,attr:Js,style:Qs,property:js,classed:ra,text:ia,html:sa,raise:aa,lower:la,append:ca,insert:da,remove:ua,clone:pa,datum:fa,on:ma,dispatch:ha,[Symbol.iterator]:ya};var lt=xa;function On(e,t,o){e.prototype=t.prototype=o,o.constructor=e}function Ei(e,t){var o=Object.create(e.prototype);for(var n in t)o[n]=t[n];return o}function zo(){}var Go=.7,Gn=1/Go,ro="\\s*([+-]?\\d+)\\s*",Bo="\\s*([+-]?(?:\\d*\\.)?\\d+(?:[eE][+-]?\\d+)?)\\s*",nt="\\s*([+-]?(?:\\d*\\.)?\\d+(?:[eE][+-]?\\d+)?)%\\s*",ef=/^#([0-9a-f]{3,8})$/,tf=new RegExp(`^rgb\\(${ro},${ro},${ro}\\)$`),of=new RegExp(`^rgb\\(${nt},${nt},${nt}\\)$`),nf=new RegExp(`^rgba\\(${ro},${ro},${ro},${Bo}\\)$`),rf=new RegExp(`^rgba\\(${nt},${nt},${nt},${Bo}\\)$`),sf=new RegExp(`^hsl\\(${Bo},${nt},${nt}\\)$`),af=new RegExp(`^hsla\\(${Bo},${nt},${nt},${Bo}\\)$`),Ea={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};On(zo,bt,{copy(e){return Object.assign(new this.constructor,this,e)},displayable(){return this.rgb().displayable()},hex:ba,formatHex:ba,formatHex8:lf,formatHsl:cf,formatRgb:_a,toString:_a});function ba(){return this.rgb().formatHex()}function lf(){return this.rgb().formatHex8()}function cf(){return Ia(this).formatHsl()}function _a(){return this.rgb().formatRgb()}function bt(e){var t,o;return e=(e+"").trim().toLowerCase(),(t=ef.exec(e))?(o=t[1].length,t=parseInt(t[1],16),o===6?Ta(t):o===3?new De(t>>8&15|t>>4&240,t>>4&15|t&240,(t&15)<<4|t&15,1):o===8?Vn(t>>24&255,t>>16&255,t>>8&255,(t&255)/255):o===4?Vn(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=tf.exec(e))?new De(t[1],t[2],t[3],1):(t=of.exec(e))?new De(t[1]*255/100,t[2]*255/100,t[3]*255/100,1):(t=nf.exec(e))?Vn(t[1],t[2],t[3],t[4]):(t=rf.exec(e))?Vn(t[1]*255/100,t[2]*255/100,t[3]*255/100,t[4]):(t=sf.exec(e))?wa(t[1],t[2]/100,t[3]/100,1):(t=af.exec(e))?wa(t[1],t[2]/100,t[3]/100,t[4]):Ea.hasOwnProperty(e)?Ta(Ea[e]):e==="transparent"?new De(NaN,NaN,NaN,0):null}function Ta(e){return new De(e>>16&255,e>>8&255,e&255,1)}function Vn(e,t,o,n){return n<=0&&(e=t=o=NaN),new De(e,t,o,n)}function df(e){return e instanceof zo||(e=bt(e)),e?(e=e.rgb(),new De(e.r,e.g,e.b,e.opacity)):new De}function io(e,t,o,n){return arguments.length===1?df(e):new De(e,t,o,n==null?1:n)}function De(e,t,o,n){this.r=+e,this.g=+t,this.b=+o,this.opacity=+n}On(De,io,Ei(zo,{brighter(e){return e=e==null?Gn:Math.pow(Gn,e),new De(this.r*e,this.g*e,this.b*e,this.opacity)},darker(e){return e=e==null?Go:Math.pow(Go,e),new De(this.r*e,this.g*e,this.b*e,this.opacity)},rgb(){return this},clamp(){return new De(Gt(this.r),Gt(this.g),Gt(this.b),Bn(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:Na,formatHex:Na,formatHex8:uf,formatRgb:va,toString:va}));function Na(){return`#${Ht(this.r)}${Ht(this.g)}${Ht(this.b)}`}function uf(){return`#${Ht(this.r)}${Ht(this.g)}${Ht(this.b)}${Ht((isNaN(this.opacity)?1:this.opacity)*255)}`}function va(){let e=Bn(this.opacity);return`${e===1?"rgb(":"rgba("}${Gt(this.r)}, ${Gt(this.g)}, ${Gt(this.b)}${e===1?")":`, ${e})`}`}function Bn(e){return isNaN(e)?1:Math.max(0,Math.min(1,e))}function Gt(e){return Math.max(0,Math.min(255,Math.round(e)||0))}function Ht(e){return e=Gt(e),(e<16?"0":"")+e.toString(16)}function wa(e,t,o,n){return n<=0?e=t=o=NaN:o<=0||o>=1?e=t=NaN:t<=0&&(e=NaN),new Ze(e,t,o,n)}function Ia(e){if(e instanceof Ze)return new Ze(e.h,e.s,e.l,e.opacity);if(e instanceof zo||(e=bt(e)),!e)return new Ze;if(e instanceof Ze)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),a=NaN,s=i-r,l=(i+r)/2;return s?(t===i?a=(o-n)/s+(o<n)*6:o===i?a=(n-t)/s+2:a=(t-o)/s+4,s/=l<.5?i+r:2-i-r,a*=60):s=l>0&&l<1?0:a,new Ze(a,s,l,e.opacity)}function Ca(e,t,o,n){return arguments.length===1?Ia(e):new Ze(e,t,o,n==null?1:n)}function Ze(e,t,o,n){this.h=+e,this.s=+t,this.l=+o,this.opacity=+n}On(Ze,Ca,Ei(zo,{brighter(e){return e=e==null?Gn:Math.pow(Gn,e),new Ze(this.h,this.s,this.l*e,this.opacity)},darker(e){return e=e==null?Go:Math.pow(Go,e),new Ze(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 De(bi(e>=240?e-240:e+120,r,n),bi(e,r,n),bi(e<120?e+240:e-120,r,n),this.opacity)},clamp(){return new Ze(Aa(this.h),Hn(this.s),Hn(this.l),Bn(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=Bn(this.opacity);return`${e===1?"hsl(":"hsla("}${Aa(this.h)}, ${Hn(this.s)*100}%, ${Hn(this.l)*100}%${e===1?")":`, ${e})`}`}}));function Aa(e){return e=(e||0)%360,e<0?e+360:e}function Hn(e){return Math.max(0,Math.min(1,e||0))}function bi(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 _i(e,t,o,n,r){var i=e*e,a=i*e;return((1-3*e+3*i-a)*t+(4-6*i+3*a)*o+(1+3*e+3*i-3*a)*n+a*r)/6}function Sa(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],a=n>0?e[n-1]:2*r-i,s=n<t-1?e[n+2]:2*i-r;return _i((o-n/t)*t,a,r,i,s)}}function Ma(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],a=e[(n+1)%t],s=e[(n+2)%t];return _i((o-n/t)*t,r,i,a,s)}}var Ti=e=>()=>e;function pf(e,t){return function(o){return e+o*t}}function ff(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 Pa(e){return(e=+e)==1?zn:function(t,o){return o-t?ff(t,o,e):Ti(isNaN(t)?o:t)}}function zn(e,t){var o=t-e;return o?pf(e,o):Ti(isNaN(e)?t:e)}var Yn=function e(t){var o=Pa(t);function n(r,i){var a=o((r=io(r)).r,(i=io(i)).r),s=o(r.g,i.g),l=o(r.b,i.b),c=zn(r.opacity,i.opacity);return function(d){return r.r=a(d),r.g=s(d),r.b=l(d),r.opacity=c(d),r+""}}return n.gamma=e,n}(1);function La(e){return function(t){var o=t.length,n=new Array(o),r=new Array(o),i=new Array(o),a,s;for(a=0;a<o;++a)s=io(t[a]),n[a]=s.r||0,r[a]=s.g||0,i[a]=s.b||0;return n=e(n),r=e(r),i=e(i),s.opacity=1,function(l){return s.r=n(l),s.g=r(l),s.b=i(l),s+""}}}var mf=La(Sa),gf=La(Ma);function Ye(e,t){return e=+e,t=+t,function(o){return e*(1-o)+t*o}}var vi=/[-+]?(?:\d+\.?\d*|\.?\d+)(?:[eE][-+]?\d+)?/g,Ni=new RegExp(vi.source,"g");function hf(e){return function(){return e}}function yf(e){return function(t){return e(t)+""}}function wi(e,t){var o=vi.lastIndex=Ni.lastIndex=0,n,r,i,a=-1,s=[],l=[];for(e=e+"",t=t+"";(n=vi.exec(e))&&(r=Ni.exec(t));)(i=r.index)>o&&(i=t.slice(o,i),s[a]?s[a]+=i:s[++a]=i),(n=n[0])===(r=r[0])?s[a]?s[a]+=r:s[++a]=r:(s[++a]=null,l.push({i:a,x:Ye(n,r)})),o=Ni.lastIndex;return o<t.length&&(i=t.slice(o),s[a]?s[a]+=i:s[++a]=i),s.length<2?l[0]?yf(l[0].x):hf(t):(t=l.length,function(c){for(var d=0,u;d<t;++d)s[(u=l[d]).i]=u.x(c);return s.join("")})}var ka=180/Math.PI,Fn={translateX:0,translateY:0,rotate:0,skewX:0,scaleX:1,scaleY:1};function Ai(e,t,o,n,r,i){var a,s,l;return(a=Math.sqrt(e*e+t*t))&&(e/=a,t/=a),(l=e*o+t*n)&&(o-=e*l,n-=t*l),(s=Math.sqrt(o*o+n*n))&&(o/=s,n/=s,l/=s),e*n<t*o&&(e=-e,t=-t,l=-l,a=-a),{translateX:r,translateY:i,rotate:Math.atan2(t,e)*ka,skewX:Math.atan(l)*ka,scaleX:a,scaleY:s}}var Wn;function Ra(e){let t=new(typeof DOMMatrix=="function"?DOMMatrix:WebKitCSSMatrix)(e+"");return t.isIdentity?Fn:Ai(t.a,t.b,t.c,t.d,t.e,t.f)}function Da(e){return e==null?Fn:(Wn||(Wn=document.createElementNS("http://www.w3.org/2000/svg","g")),Wn.setAttribute("transform",e),(e=Wn.transform.baseVal.consolidate())?(e=e.matrix,Ai(e.a,e.b,e.c,e.d,e.e,e.f)):Fn)}function Oa(e,t,o,n){function r(c){return c.length?c.pop()+" ":""}function i(c,d,u,f,p,g){if(c!==u||d!==f){var y=p.push("translate(",null,t,null,o);g.push({i:y-4,x:Ye(c,u)},{i:y-2,x:Ye(d,f)})}else(u||f)&&p.push("translate("+u+t+f+o)}function a(c,d,u,f){c!==d?(c-d>180?d+=360:d-c>180&&(c+=360),f.push({i:u.push(r(u)+"rotate(",null,n)-2,x:Ye(c,d)})):d&&u.push(r(u)+"rotate("+d+n)}function s(c,d,u,f){c!==d?f.push({i:u.push(r(u)+"skewX(",null,n)-2,x:Ye(c,d)}):d&&u.push(r(u)+"skewX("+d+n)}function l(c,d,u,f,p,g){if(c!==u||d!==f){var y=p.push(r(p)+"scale(",null,",",null,")");g.push({i:y-4,x:Ye(c,u)},{i:y-2,x:Ye(d,f)})}else(u!==1||f!==1)&&p.push(r(p)+"scale("+u+","+f+")")}return function(c,d){var u=[],f=[];return c=e(c),d=e(d),i(c.translateX,c.translateY,d.translateX,d.translateY,u,f),a(c.rotate,d.rotate,u,f),s(c.skewX,d.skewX,u,f),l(c.scaleX,c.scaleY,d.scaleX,d.scaleY,u,f),c=d=null,function(p){for(var g=-1,y=f.length,m;++g<y;)u[(m=f[g]).i]=m.x(p);return u.join("")}}}var Ii=Oa(Ra,"px, ","px)","deg)"),Ci=Oa(Da,", ",")",")");var so=0,Fo=0,Yo=0,Ha=1e3,Xn,Wo,Un=0,Bt=0,$n=0,Xo=typeof performance=="object"&&performance.now?performance:Date,Ga=typeof window=="object"&&window.requestAnimationFrame?window.requestAnimationFrame.bind(window):function(e){setTimeout(e,17)};function $o(){return Bt||(Ga(xf),Bt=Xo.now()+$n)}function xf(){Bt=0}function Uo(){this._call=this._time=this._next=null}Uo.prototype=Kn.prototype={constructor:Uo,restart:function(e,t,o){if(typeof e!="function")throw new TypeError("callback is not a function");o=(o==null?$o():+o)+(t==null?0:+t),!this._next&&Wo!==this&&(Wo?Wo._next=this:Xn=this,Wo=this),this._call=e,this._time=o,Si()},stop:function(){this._call&&(this._call=null,this._time=1/0,Si())}};function Kn(e,t,o){var n=new Uo;return n.restart(e,t,o),n}function Ba(){$o(),++so;for(var e=Xn,t;e;)(t=Bt-e._time)>=0&&e._call.call(void 0,t),e=e._next;--so}function Va(){Bt=(Un=Xo.now())+$n,so=Fo=0;try{Ba()}finally{so=0,bf(),Bt=0}}function Ef(){var e=Xo.now(),t=e-Un;t>Ha&&($n-=t,Un=e)}function bf(){for(var e,t=Xn,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:Xn=o);Wo=e,Si(n)}function Si(e){if(!so){Fo&&(Fo=clearTimeout(Fo));var t=e-Bt;t>24?(e<1/0&&(Fo=setTimeout(Va,e-Xo.now()-$n)),Yo&&(Yo=clearInterval(Yo))):(Yo||(Un=Xo.now(),Yo=setInterval(Ef,Ha)),so=1,Ga(Va))}}function qn(e,t,o){var n=new Uo;return t=t==null?0:+t,n.restart(r=>{n.stop(),e(r+t)},t,o),n}var _f=gi("start","end","cancel","interrupt"),Tf=[],Fa=0,za=1,Jn=2,Zn=3,Ya=4,Qn=5,Ko=6;function _t(e,t,o,n,r,i){var a=e.__transition;if(!a)e.__transition={};else if(o in a)return;Nf(e,o,{name:t,index:n,group:r,on:_f,tween:Tf,time:i.time,delay:i.delay,duration:i.duration,ease:i.ease,timer:null,state:Fa})}function qo(e,t){var o=_e(e,t);if(o.state>Fa)throw new Error("too late; already scheduled");return o}function we(e,t){var o=_e(e,t);if(o.state>Zn)throw new Error("too late; already running");return o}function _e(e,t){var o=e.__transition;if(!o||!(o=o[t]))throw new Error("transition not found");return o}function Nf(e,t,o){var n=e.__transition,r;n[t]=o,o.timer=Kn(i,0,o.time);function i(c){o.state=za,o.timer.restart(a,o.delay,o.time),o.delay<=c&&a(c-o.delay)}function a(c){var d,u,f,p;if(o.state!==za)return l();for(d in n)if(p=n[d],p.name===o.name){if(p.state===Zn)return qn(a);p.state===Ya?(p.state=Ko,p.timer.stop(),p.on.call("interrupt",e,e.__data__,p.index,p.group),delete n[d]):+d<t&&(p.state=Ko,p.timer.stop(),p.on.call("cancel",e,e.__data__,p.index,p.group),delete n[d])}if(qn(function(){o.state===Zn&&(o.state=Ya,o.timer.restart(s,o.delay,o.time),s(c))}),o.state=Jn,o.on.call("start",e,e.__data__,o.index,o.group),o.state===Jn){for(o.state=Zn,r=new Array(f=o.tween.length),d=0,u=-1;d<f;++d)(p=o.tween[d].value.call(e,e.__data__,o.index,o.group))&&(r[++u]=p);r.length=u+1}}function s(c){for(var d=c<o.duration?o.ease.call(null,c/o.duration):(o.timer.restart(l),o.state=Qn,1),u=-1,f=r.length;++u<f;)r[u].call(e,d);o.state===Qn&&(o.on.call("end",e,e.__data__,o.index,o.group),l())}function l(){o.state=Ko,o.timer.stop(),delete n[t];for(var c in n)return;delete e.__transition}}function Mi(e,t){var o=e.__transition,n,r,i=!0,a;if(o){t=t==null?null:t+"";for(a in o){if((n=o[a]).name!==t){i=!1;continue}r=n.state>Jn&&n.state<Qn,n.state=Ko,n.timer.stop(),n.on.call(r?"interrupt":"cancel",e,e.__data__,n.index,n.group),delete o[a]}i&&delete e.__transition}}function Wa(e){return this.each(function(){Mi(this,e)})}function vf(e,t){var o,n;return function(){var r=we(this,e),i=r.tween;if(i!==o){n=o=i;for(var a=0,s=n.length;a<s;++a)if(n[a].name===t){n=n.slice(),n.splice(a,1);break}}r.tween=n}}function wf(e,t,o){var n,r;if(typeof o!="function")throw new Error;return function(){var i=we(this,e),a=i.tween;if(a!==n){r=(n=a).slice();for(var s={name:t,value:o},l=0,c=r.length;l<c;++l)if(r[l].name===t){r[l]=s;break}l===c&&r.push(s)}i.tween=r}}function Xa(e,t){var o=this._id;if(e+="",arguments.length<2){for(var n=_e(this.node(),o).tween,r=0,i=n.length,a;r<i;++r)if((a=n[r]).name===e)return a.value;return null}return this.each((t==null?vf:wf)(o,e,t))}function ao(e,t,o){var n=e._id;return e.each(function(){var r=we(this,n);(r.value||(r.value={}))[t]=o.apply(this,arguments)}),function(r){return _e(r,n).value[t]}}function jn(e,t){var o;return(typeof t=="number"?Ye:t instanceof bt?Yn:(o=bt(t))?(t=o,Yn):wi)(e,t)}function Af(e){return function(){this.removeAttribute(e)}}function If(e){return function(){this.removeAttributeNS(e.space,e.local)}}function Cf(e,t,o){var n,r=o+"",i;return function(){var a=this.getAttribute(e);return a===r?null:a===n?i:i=t(n=a,o)}}function Sf(e,t,o){var n,r=o+"",i;return function(){var a=this.getAttributeNS(e.space,e.local);return a===r?null:a===n?i:i=t(n=a,o)}}function Mf(e,t,o){var n,r,i;return function(){var a,s=o(this),l;return s==null?void this.removeAttribute(e):(a=this.getAttribute(e),l=s+"",a===l?null:a===n&&l===r?i:(r=l,i=t(n=a,s)))}}function Pf(e,t,o){var n,r,i;return function(){var a,s=o(this),l;return s==null?void this.removeAttributeNS(e.space,e.local):(a=this.getAttributeNS(e.space,e.local),l=s+"",a===l?null:a===n&&l===r?i:(r=l,i=t(n=a,s)))}}function Ua(e,t){var o=at(e),n=o==="transform"?Ci:jn;return this.attrTween(e,typeof t=="function"?(o.local?Pf:Mf)(o,n,ao(this,"attr."+e,t)):t==null?(o.local?If:Af)(o):(o.local?Sf:Cf)(o,n,t))}function Lf(e,t){return function(o){this.setAttribute(e,t.call(this,o))}}function kf(e,t){return function(o){this.setAttributeNS(e.space,e.local,t.call(this,o))}}function Rf(e,t){var o,n;function r(){var i=t.apply(this,arguments);return i!==n&&(o=(n=i)&&kf(e,i)),o}return r._value=t,r}function Df(e,t){var o,n;function r(){var i=t.apply(this,arguments);return i!==n&&(o=(n=i)&&Lf(e,i)),o}return r._value=t,r}function $a(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=at(e);return this.tween(o,(n.local?Rf:Df)(n,t))}function Of(e,t){return function(){qo(this,e).delay=+t.apply(this,arguments)}}function Vf(e,t){return t=+t,function(){qo(this,e).delay=t}}function Ka(e){var t=this._id;return arguments.length?this.each((typeof e=="function"?Of:Vf)(t,e)):_e(this.node(),t).delay}function Hf(e,t){return function(){we(this,e).duration=+t.apply(this,arguments)}}function Gf(e,t){return t=+t,function(){we(this,e).duration=t}}function qa(e){var t=this._id;return arguments.length?this.each((typeof e=="function"?Hf:Gf)(t,e)):_e(this.node(),t).duration}function Bf(e,t){if(typeof t!="function")throw new Error;return function(){we(this,e).ease=t}}function Za(e){var t=this._id;return arguments.length?this.each(Bf(t,e)):_e(this.node(),t).ease}function zf(e,t){return function(){var o=t.apply(this,arguments);if(typeof o!="function")throw new Error;we(this,e).ease=o}}function Ja(e){if(typeof e!="function")throw new Error;return this.each(zf(this._id,e))}function Qa(e){typeof e!="function"&&(e=Vo(e));for(var t=this._groups,o=t.length,n=new Array(o),r=0;r<o;++r)for(var i=t[r],a=i.length,s=n[r]=[],l,c=0;c<a;++c)(l=i[c])&&e.call(l,l.__data__,c,i)&&s.push(l);return new Pe(n,this._parents,this._name,this._id)}function ja(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),a=new Array(n),s=0;s<i;++s)for(var l=t[s],c=o[s],d=l.length,u=a[s]=new Array(d),f,p=0;p<d;++p)(f=l[p]||c[p])&&(u[p]=f);for(;s<n;++s)a[s]=t[s];return new Pe(a,this._parents,this._name,this._id)}function Yf(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 Ff(e,t,o){var n,r,i=Yf(t)?qo:we;return function(){var a=i(this,e),s=a.on;s!==n&&(r=(n=s).copy()).on(t,o),a.on=r}}function el(e,t){var o=this._id;return arguments.length<2?_e(this.node(),o).on.on(e):this.each(Ff(o,e,t))}function Wf(e){return function(){var t=this.parentNode;for(var o in this.__transition)if(+o!==e)return;t&&t.removeChild(this)}}function tl(){return this.on("end.remove",Wf(this._id))}function ol(e){var t=this._name,o=this._id;typeof e!="function"&&(e=Vt(e));for(var n=this._groups,r=n.length,i=new Array(r),a=0;a<r;++a)for(var s=n[a],l=s.length,c=i[a]=new Array(l),d,u,f=0;f<l;++f)(d=s[f])&&(u=e.call(d,d.__data__,f,s))&&("__data__"in d&&(u.__data__=d.__data__),c[f]=u,_t(c[f],t,o,f,c,_e(d,o)));return new Pe(i,this._parents,t,o)}function nl(e){var t=this._name,o=this._id;typeof e!="function"&&(e=Oo(e));for(var n=this._groups,r=n.length,i=[],a=[],s=0;s<r;++s)for(var l=n[s],c=l.length,d,u=0;u<c;++u)if(d=l[u]){for(var f=e.call(d,d.__data__,u,l),p,g=_e(d,o),y=0,m=f.length;y<m;++y)(p=f[y])&&_t(p,t,o,y,f,g);i.push(f),a.push(d)}return new Pe(i,a,t,o)}var Xf=lt.prototype.constructor;function rl(){return new Xf(this._groups,this._parents)}function Uf(e,t){var o,n,r;return function(){var i=Et(this,e),a=(this.style.removeProperty(e),Et(this,e));return i===a?null:i===o&&a===n?r:r=t(o=i,n=a)}}function il(e){return function(){this.style.removeProperty(e)}}function $f(e,t,o){var n,r=o+"",i;return function(){var a=Et(this,e);return a===r?null:a===n?i:i=t(n=a,o)}}function Kf(e,t,o){var n,r,i;return function(){var a=Et(this,e),s=o(this),l=s+"";return s==null&&(l=s=(this.style.removeProperty(e),Et(this,e))),a===l?null:a===n&&l===r?i:(r=l,i=t(n=a,s))}}function qf(e,t){var o,n,r,i="style."+t,a="end."+i,s;return function(){var l=we(this,e),c=l.on,d=l.value[i]==null?s||(s=il(t)):void 0;(c!==o||r!==d)&&(n=(o=c).copy()).on(a,r=d),l.on=n}}function sl(e,t,o){var n=(e+="")=="transform"?Ii:jn;return t==null?this.styleTween(e,Uf(e,n)).on("end.style."+e,il(e)):typeof t=="function"?this.styleTween(e,Kf(e,n,ao(this,"style."+e,t))).each(qf(this._id,e)):this.styleTween(e,$f(e,n,t),o).on("end.style."+e,null)}function Zf(e,t,o){return function(n){this.style.setProperty(e,t.call(this,n),o)}}function Jf(e,t,o){var n,r;function i(){var a=t.apply(this,arguments);return a!==r&&(n=(r=a)&&Zf(e,a,o)),n}return i._value=t,i}function al(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,Jf(e,t,o==null?"":o))}function Qf(e){return function(){this.textContent=e}}function jf(e){return function(){var t=e(this);this.textContent=t==null?"":t}}function ll(e){return this.tween("text",typeof e=="function"?jf(ao(this,"text",e)):Qf(e==null?"":e+""))}function em(e){return function(t){this.textContent=e.call(this,t)}}function tm(e){var t,o;function n(){var r=e.apply(this,arguments);return r!==o&&(t=(o=r)&&em(r)),t}return n._value=e,n}function cl(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,tm(e))}function dl(){for(var e=this._name,t=this._id,o=er(),n=this._groups,r=n.length,i=0;i<r;++i)for(var a=n[i],s=a.length,l,c=0;c<s;++c)if(l=a[c]){var d=_e(l,t);_t(l,e,o,c,a,{time:d.time+d.delay+d.duration,delay:0,duration:d.duration,ease:d.ease})}return new Pe(n,this._parents,e,o)}function ul(){var e,t,o=this,n=o._id,r=o.size();return new Promise(function(i,a){var s={value:a},l={value:function(){--r===0&&i()}};o.each(function(){var c=we(this,n),d=c.on;d!==e&&(t=(e=d).copy(),t._.cancel.push(s),t._.interrupt.push(s),t._.end.push(l)),c.on=t}),r===0&&i()})}var om=0;function Pe(e,t,o,n){this._groups=e,this._parents=t,this._name=o,this._id=n}function pl(e){return lt().transition(e)}function er(){return++om}var ct=lt.prototype;Pe.prototype=pl.prototype={constructor:Pe,select:ol,selectAll:nl,selectChild:ct.selectChild,selectChildren:ct.selectChildren,filter:Qa,merge:ja,selection:rl,transition:dl,call:ct.call,nodes:ct.nodes,node:ct.node,size:ct.size,empty:ct.empty,each:ct.each,on:el,attr:Ua,attrTween:$a,style:sl,styleTween:al,text:ll,textTween:cl,remove:tl,tween:Xa,delay:Ka,duration:qa,ease:Za,easeVarying:Ja,end:ul,[Symbol.iterator]:ct[Symbol.iterator]};function tr(e){return((e*=2)<=1?e*e*e:(e-=2)*e*e+2)/2}var nm={time:null,delay:0,duration:250,ease:tr};function rm(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 fl(e){var t,o;e instanceof Pe?(t=e._id,e=e._name):(t=er(),(o=nm).time=$o(),e=e==null?null:e+"");for(var n=this._groups,r=n.length,i=0;i<r;++i)for(var a=n[i],s=a.length,l,c=0;c<s;++c)(l=a[c])&&_t(l,e,t,c,a,o||rm(l,t));return new Pe(n,this._parents,e,t)}lt.prototype.interrupt=Wa;lt.prototype.transition=fl;function Tt(e,t,o){this.k=e,this.x=t,this.y=o}Tt.prototype={constructor:Tt,scale:function(e){return e===1?this:new Tt(this.k*e,this.x,this.y)},translate:function(e,t){return e===0&t===0?this:new Tt(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 or=new Tt(1,0,0);nr.prototype=Tt.prototype;function nr(e){for(;!e.__zoom;)if(!(e=e.parentNode))return or;return e.__zoom}var sm=[[Number.NEGATIVE_INFINITY,Number.NEGATIVE_INFINITY],[Number.POSITIVE_INFINITY,Number.POSITIVE_INFINITY]];var ml;(function(e){e.Strict="strict",e.Loose="loose"})(ml||(ml={}));var gl;(function(e){e.Free="free",e.Vertical="vertical",e.Horizontal="horizontal"})(gl||(gl={}));var hl;(function(e){e.Partial="partial",e.Full="full"})(hl||(hl={}));var yl;(function(e){e.Bezier="default",e.Straight="straight",e.Step="step",e.SmoothStep="smoothstep",e.SimpleBezier="simplebezier"})(yl||(yl={}));var xl;(function(e){e.Arrow="arrow",e.ArrowClosed="arrowclosed"})(xl||(xl={}));var Oe;(function(e){e.Left="left",e.Top="top",e.Right="right",e.Bottom="bottom"})(Oe||(Oe={}));var Vv={[Oe.Left]:Oe.Right,[Oe.Right]:Oe.Left,[Oe.Top]:Oe.Bottom,[Oe.Bottom]:Oe.Top};var am=e=>"id"in e&&"internals"in e&&!("source"in e)&&!("target"in e);var lm=(e,t=[0,0])=>{var s;let{width:o,height:n}=cm(e),r=(s=e.origin)!=null?s:t,i=o*r[0],a=n*r[1];return{x:e.position.x-i,y:e.position.y-a}};var dt=(e,t=[0,0])=>{var r,i,a,s,l,c,d,u;let{x:o,y:n}=am(e)?e.internals.positionAbsolute:lm(e,t);return{x:o,y:n,x2:o+((s=(a=(i=(r=e.measured)==null?void 0:r.width)!=null?i:e.width)!=null?a:e.initialWidth)!=null?s: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 cm(e){var t,o,n,r,i,a,s,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=(s=(a=(i=e.measured)==null?void 0:i.height)!=null?a:e.height)!=null?s:e.initialHeight)!=null?l:0}}var Hv={[Oe.Left]:{x:-1,y:0},[Oe.Right]:{x:1,y:0},[Oe.Top]:{x:0,y:-1},[Oe.Bottom]:{x:0,y:1}};var dm={nodeOrigin:[0,0],nodeExtent:sm,elevateNodesOnSelect:!0,defaults:{}},Gv=v(T({},dm),{checkEquality:!0});var El;(function(e){e.Line="line",e.Handle="handle"})(El||(El={}));var um={width:0,height:0,x:0,y:0},Bv=v(T({},um),{pointerX:0,pointerY:0,aspectRatio:1});var pm=(e,t)=>e.x<t.x2&&e.x2>t.x&&e.y<t.y2&&e.y2>t.y;function fm(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 mm(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 rr=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 a=t==="horizontal"?this.yLines:this.xLines,[s,l]=t==="horizontal"?[r.y,r.y2]:[r.x,r.x2],c=[];for(let p of a){if(p.position<s)continue;if(p.position>l)break;if(i.has(p.node.id)||p.node.parentId&&i.has(p.node.parentId)||!pm(p.nodeBox,r))continue;let g=Math.abs(p.position-o);if(g>ir)continue;let m=fm(p.nodeBox,n)>0?0:mm(p.nodeBox,n);c.push({line:p,lineDist:g,nodeDist:m})}let d=.5,u=t==="horizontal"?this.lastHorizontalLine:this.lastVerticalLine;c.sort((p,g)=>{if(u){if(p.line===u&&g.line!==u)return-1;if(g.line===u&&p.line!==u)return 1}return Math.abs(p.lineDist-g.lineDist)<=d?p.nodeDist-g.nodeDist:p.lineDist-g.lineDist});let f=c.length>0?c[0].line:void 0;return f&&(t==="horizontal"?this.lastHorizontalLine=f:this.lastVerticalLine=f),f}};function bl(e,t=zt,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 a=dt(i);Object.entries(t).forEach(([s,l])=>{var c;n.push({position:l.resolve(r,a),color:(c=r.style)==null?void 0:c.backgroundColor,orientation:l.orientation,anchorName:s,nodeBox:a,node:r})})}),n}function _l(e,t,o,n,r=Object.keys(zt)){let i=[];for(let s of r){let l=zt[s],c=l.resolve(null,o),d=e.search(l.orientation,c,o,t,n);d&&i.push({sourcePosition:c,anchorName:s,anchor:l,line:d})}let a={horizontal:void 0,vertical:void 0};for(let s of i){let l=a[s.anchor.orientation],c=Math.abs(s.sourcePosition-s.line.position);(!l||c<Math.abs(l.sourcePosition-l.line.position))&&(a[s.anchor.orientation]=s)}return a}function Tl(e,t,o){let n=0,r=0,i=!1,a=!1;if(t){let l=t.anchor.resolve(null,e)-t.line.position;Math.abs(l)<=ir&&(r=l,a=!0)}if(o){let l=o.anchor.resolve(null,e)-o.line.position;Math.abs(l)<=ir&&(n=l,i=!0)}return{deltaX:n,deltaY:r,snappedX:i,snappedY:a}}var ir=10,zt={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 Tm}from"react/jsx-runtime";var _m=new rr;function sr(){let[e,t]=Nl(void 0),[o,n]=Nl(void 0),{width:r,height:i}=ym(m=>({width:m.width,height:m.height}),bm),a=gm(),s=Em(_m),{screenToFlowPosition:l,getInternalNode:c,getNodes:d}=hm(),u=Zo(()=>{t(void 0),n(void 0)},[]),f=Zo(m=>{let _=m!=null?m:d();u();let h=bl(_,zt,c);s.current.initialize(h)},[c,u,d]),p=Zo(()=>{setTimeout(()=>{f()},100)},[f]);xm(()=>{a&&f(d())},[a,f,d]);let g=Zo((m,_)=>{var K,L,H,F,Y,O,J,U,X,z;if(!s.current||m.length===0)return m;u();let h=m.filter(W=>W.type==="position"&&!!W.position),E=m.find(W=>W.type==="dimensions");if(h.length===0&&!E)return m;let w=Object.keys(zt),b=new Set,x=1/0,N=1/0,I=-1/0,A=-1/0;if(h.length>0)h.forEach(W=>{var he,fe,se,ie,ve,ke;let Z=_.find(yt=>yt.id===W.id);if(!Z)return;b.add(Z.id);let ee=c(Z.id);if(!ee)return;let le=ee.parentId?c(ee.parentId):void 0,ce=W.position.x+((he=le==null?void 0:le.internals.positionAbsolute.x)!=null?he:0),de=W.position.y+((fe=le==null?void 0:le.internals.positionAbsolute.y)!=null?fe:0),ue=(ie=(se=Z.measured)==null?void 0:se.width)!=null?ie:0,ge=(ke=(ve=Z.measured)==null?void 0:ve.height)!=null?ke:0;x=Math.min(x,ce),N=Math.min(N,de),I=Math.max(I,ce+ue),A=Math.max(A,de+ge)}),E&&(w=["top","left"]);else if(E){let W=_.find(ue=>ue.id===E.id);if(!W)return m;b.add(W.id);let Z=c(W.id);if(!Z)return m;let ee=Z.internals.positionAbsolute.x,le=Z.internals.positionAbsolute.y,ce=(F=(H=(K=E.dimensions)==null?void 0:K.width)!=null?H:(L=W.measured)==null?void 0:L.width)!=null?F:0,de=(U=(J=(Y=E.dimensions)==null?void 0:Y.height)!=null?J:(O=W.measured)==null?void 0:O.height)!=null?U:0;x=ee,N=le,I=ee+ce,A=le+de,w=["right","bottom"]}if(x===1/0)return m;let M={x,y:N,x2:I,y2:A},{x:S,y:k}=l({x:0,y:0}),{x:B,y:q}=l({x:r,y:i}),j={x:S,y:k,x2:B,y2:q},{horizontal:C,vertical:P}=_l(s.current,j,M,b,w),{deltaX:$,deltaY:V,snappedX:R,snappedY:G}=Tl(M,C,P);if(R||G){let W=h.some(ee=>ee.dragging),Z=!!(E!=null&&E.resizing);(W||Z)&&(R&&n(P==null?void 0:P.line),G&&t(C==null?void 0:C.line)),R&&(h.forEach(ee=>{ee.position&&(ee.position.x-=$)}),(E==null?void 0:E.id)===((X=h[0])==null?void 0:X.id)?E.dimensions&&(E.dimensions.width+=$):E&&!h.length&&E.dimensions&&(E.dimensions.width-=$)),G&&(h.forEach(ee=>{ee.position&&(ee.position.y-=V)}),(E==null?void 0:E.id)===((z=h[0])==null?void 0:z.id)?E.dimensions&&(E.dimensions.height+=V):E&&!h.length&&E.dimensions&&(E.dimensions.height-=V))}return m},[l,c,r,i,t,n,u]),y=Zo(()=>Tm(vl,{horizontal:e,vertical:o}),[e,o]);return{rebuildIndex:f,forceRebuildIndex:p,updateHelperLines:g,helperLineHorizontal:e,helperLineVertical:o,HelperLines:y}}import{reconnectEdge as Ty,useReactFlow as Ny}from"@xyflow/react";import{useCallback as $t,useRef as vy}from"react";var ut=e=>new Map(e.map(t=>[t.id,t])),Jo=(e,t,o)=>t.filter(n=>!(n.source!==e||o&&n.id===o)),wl=(e,t,o)=>t.filter(n=>!(n.target!==e||o&&n.id===o)),Pi=e=>e.some(t=>t.type==="START_EVENT"),Nt=(e,t)=>e==="START_EVENT"?!Pi(t):!0,Al=(e,t,o,n,r)=>{let i=ut(o),a=i.get(e);if(!a||a.type!=="START_EVENT")return!1;let s=i.get(t);return(s==null?void 0:s.type)==="ANNOTATION"?!1:Jo(e,n,r).filter(c=>{let d=i.get(c.target);return(d==null?void 0:d.type)!=="ANNOTATION"}).length>=1},Il=(e,t,o,n,r)=>{let i=ut(o),a=i.get(t);if(!a||a.type!=="END_EVENT")return!1;let s=i.get(e);return(s==null?void 0:s.type)==="ANNOTATION"?!1:wl(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=ut(o),a=i.get(e);if(!a||a.type!=="GATEWAY"||((c=a.data)==null?void 0:c.variant)!=="EXCLUSIVE")return!1;let s=t?i.get(t):null;return(s==null?void 0:s.type)==="ANNOTATION"?!1:Jo(e,n,r).filter(d=>{let u=i.get(d.target);return(u==null?void 0:u.type)!=="ANNOTATION"}).length>=2},Cl=(e,t,o)=>{var a,s,l,c;let n=ut(o),r=n.get(e),i=n.get(t);return(r==null?void 0:r.type)!=="GATEWAY"||(i==null?void 0:i.type)!=="GATEWAY"||((a=r==null?void 0:r.data)==null?void 0:a.variant)==="EXCLUSIVE"&&((s=i==null?void 0:i.data)==null?void 0:s.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"},lr=(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"},Sl=(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"},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.attribute)==="LOOP"},Qo=(e,t,o,n)=>{let r=ut(t),i=r.get(e);return!i||i.type!=="TASK"?!1:wl(e,o,n).some(s=>{let l=r.get(s.source);return(l==null?void 0:l.type)==="START_EVENT"})},jo=(e,t,o,n)=>{let r=ut(t),i=r.get(e);return!i||i.type!=="TASK"?!1:Jo(e,o,n).some(s=>{let l=r.get(s.target);return(l==null?void 0:l.type)==="END_EVENT"})},Ml=(e,t,o,n,r)=>{let i=ut(o),a=i.get(e),s=i.get(t);return(a==null?void 0:a.type)==="START_EVENT"&&(s==null?void 0:s.type)==="TASK"?jo(t,o,n,r):(s==null?void 0:s.type)==="END_EVENT"&&(a==null?void 0:a.type)==="TASK"?Qo(e,o,n,r):!1},dr=(e,t,o)=>Jo(e,t,o).length>0,ur=(e,t,o,n,r)=>{let i=ut(o),a=i.get(e);if(!a||a.type!=="TASK")return!1;let s=t?i.get(t):null;return(s==null?void 0:s.type)==="ANNOTATION"?!1:Jo(e,n,r).filter(c=>{let d=i.get(c.target);return(d==null?void 0:d.type)!=="ANNOTATION"}).length>=2};var Pl=(e,t,o,n,r)=>{var s,l;let i=ut(n),a=((s=i.get(e))==null?void 0:s.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||a&&c.source===t&&c.target===e))};var Nm=[e=>({isValid:e.sourceNodeId!==e.targetNodeId,reason:"self_connection_not_allowed"}),e=>({isValid:!Pl(e.sourceNodeId,e.targetNodeId,e.edges,e.nodes,e.reconnectingEdgeId),reason:"duplicate_connection_not_allowed"}),e=>({isValid:!Al(e.sourceNodeId,e.targetNodeId,e.nodes,e.edges,e.reconnectingEdgeId),reason:"start_event_limit_reached"}),e=>({isValid:!Il(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:!ur(e.sourceNodeId,e.targetNodeId,e.nodes,e.edges,e.reconnectingEdgeId),reason:"task_limit_reached"}),e=>({isValid:Cl(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"&&Sl(e.targetNodeId,e.nodes)),reason:"start_event_to_subprocess_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:!(lr(e.sourceNodeId,e.nodes)&&e.targetNodeType==="END_EVENT"),reason:"script_to_end_not_allowed"}),e=>({isValid:!(cr(e.sourceNodeId,e.nodes)&&e.targetNodeType==="END_EVENT"),reason:"loop_to_end_not_allowed"}),e=>({isValid:!(Qo(e.sourceNodeId,e.nodes,e.edges,e.reconnectingEdgeId)&&e.targetNodeType==="END_EVENT"),reason:"initial_activity_to_end_not_allowed"}),e=>({isValid:!Ml(e.sourceNodeId,e.targetNodeId,e.nodes,e.edges,e.reconnectingEdgeId),reason:"concurrent_initial_and_final_activity"}),e=>({isValid:!(jo(e.sourceNodeId,e.nodes,e.edges,e.reconnectingEdgeId)&&e.targetNodeType!=="ANNOTATION"),reason:"final_activity_cannot_connect"}),e=>({isValid:!(dr(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"})],Li=e=>{for(let t of Nm){let o=t(e);if(!o.isValid)return o}return{isValid:!0}};var vm=[{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:Pi(e.nodes),reason:"start_event_already_exists"})},{sourceTypes:["TASK"],targetTypes:["END_EVENT"],validate:e=>({shouldDisable:lr(e.sourceNodeId,e.nodes),reason:"script_to_end_not_allowed"})},{sourceTypes:["TASK"],targetTypes:["END_EVENT"],validate:e=>({shouldDisable:cr(e.sourceNodeId,e.nodes),reason:"loop_to_end_not_allowed"})},{sourceTypes:["TASK"],targetTypes:["END_EVENT"],validate:e=>({shouldDisable:Qo(e.sourceNodeId,e.nodes,e.edges),reason:"initial_activity_to_end_not_allowed"})},{sourceTypes:["TASK"],validate:e=>({shouldDisable:jo(e.sourceNodeId,e.nodes,e.edges)&&e.targetNodeType!=="ANNOTATION",reason:"final_activity_cannot_connect"})},{targetTypes:["END_EVENT"],validate:e=>({shouldDisable:dr(e.sourceNodeId,e.edges),reason:"activity_has_outgoing_connections"})},{sourceTypes:["TASK"],validate:e=>({shouldDisable:ur(e.sourceNodeId,null,e.nodes,e.edges)&&e.targetNodeType!=="ANNOTATION",reason:"task_limit_reached"})}],Ll=e=>{let t=vm.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 jm,EdgeLabelRenderer as eg,getStraightPath as tg,useInternalNode as Rl,useViewport as og}from"@xyflow/react";import{Button as Im,Tooltip as Cm,TooltipContent as Sm,TooltipTrigger as Mm,useTranslation as Pm}from"@produto-lecom/lecom-ui";import{Settings as Lm}from"lucide-react";import{getIncomers as pr,getOutgoers as fr,useReactFlow as Am}from"@xyflow/react";import{useStoreApi as wm}from"@xyflow/react";var vt=()=>{let e=wm();return{selectElements:n=>{let{edges:r,nodes:i,triggerEdgeChanges:a,triggerNodeChanges:s}=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 s(l),a(c),!0},clearSelection:async()=>{let{unselectNodesAndEdges:n}=e.getState();return n(),await Nn(),!0}}};var mr=()=>{let{getNode:e,getEdge:t,getNodes:o,getEdges:n}=Am(),{selectElements:r}=vt(),i=m=>{let _=o(),h=n(),E=pr(m,_,h),w=fr(m,_,h),b=E.some(N=>N.type==="START_EVENT"),x=w.some(N=>N.type==="END_EVENT");return b?"start":x?"end":"between"},a=(m,_,h)=>{var b,x,N,I;if(!m)return;let E={type:m.type,variant:(b=m.data)==null?void 0:b.variant,attribute:(x=m.data)==null?void 0:x.attribute},w={id:m.id,position:i(m),label:(N=m.data)==null?void 0:N.label,node:E};return m.type==="TASK"&&((I=m.data)==null?void 0:I.variant)==="SUBPROCESS"?v(T({},w),{type:"sub_process"}):m.type==="GATEWAY"?v(T({},w),{type:"gateway",variant:s(m,_,h)}):v(T({},w),{type:"activity"})},s=(m,_,h)=>{if(m.type!=="GATEWAY")return;let E=pr(m,_,h),w=!1,b=!1;if(E.forEach(x=>{var N,I;x.type==="TASK"&&(((N=x.data)==null?void 0:N.variant)==="SCRIPT"&&(w=!0),((I=x.data)==null?void 0:I.attribute)==="LOOP"&&(b=!0))}),w&&b)return"script_loop";if(w)return"script";if(b)return"loop"},l=(m,_,h)=>{var N,I,A,M;let E=e(m.source),w=e(m.target);if(!E||!w)return"simple";if(fr(E,_,h).some(S=>S.type==="END_EVENT"))return"final";if(E.type==="GATEWAY")switch((N=E.data)==null?void 0:N.variant){case"PARALLEL":return"parallel";case"EXCLUSIVE":return"exclusive";case"COMPLEX":return"complex";default:return"simple"}if(E.type==="TASK"){let S=(I=E.data)==null?void 0:I.variant,k=(A=E.data)==null?void 0:A.attribute;if(S==="SUBPROCESS")return"from_sub_process";if(w.type==="TASK"&&((M=w.data)==null?void 0:M.variant)==="SUBPROCESS")return"to_sub_process";let B=S==="SCRIPT",q=k==="LOOP";return B&&q?"script_loop":B?"script":q?"loop":"simple"}return"simple"},c=(m,_,h)=>{let E=[];function w(x,N,I=0){let A=a(x,_,h);if(A.depth=I,N.push(A),x.type==="TASK"){E.push([...N]),N.pop();return}let M=pr(x,_,h);if(M.length)for(let S of M)w(S,N,I+1);N.pop()}let b=pr(m,_,h);for(let x of b)w(x,[]);return E},d=(m,_,h)=>{let E=[];function w(x,N,I=0){let A=a(x,_,h);if(A.depth=I,N.push(A),x.type==="TASK"){E.push([...N]),N.pop();return}let M=fr(x,_,h);if(M.length)for(let S of M)w(S,N,I+1);N.pop()}let b=fr(m,_,h);for(let x of b)w(x,[]);return E},u=(m,_,h)=>(h=h.filter(w=>w.source===m.id),h.map(w=>{var N;let b=e(w.target),x;return b&&(x=a(b,_,h)),{id:w.id,type:"routing",variant:l(w,_,h),label:(N=w.data)==null?void 0:N.label,target:x}})),f=m=>{let _=e(m);if(!_)return;let h=o(),E=n(),w=a(_,h,E);return w.sources=c(_,h,E),w.targets=d(_,h,E),w.edgeTargets=u(_,h,E),_.type==="GATEWAY"&&(w.variant=s(_,h,E)),w},p=m=>{let _=t(m);if(!_)return;let h=o(),E=n(),w=l(_,h,E),x={id:_.id,type:"routing",variant:w,gatewayVariant:void 0},N=e(_.source);if(N){let A=a(N,h,E);x.source=A;let M=s(N,h,E);if(x.gatewayVariant=M,N.type==="TASK")x.sources=[[A]];else{let S=c(N,h,E);x.sources=S.length?S:[[A]]}}let I=e(_.target);if(I){let A=a(I,h,E);if(x.target=A,I.type==="TASK")x.targets=[[A]];else{let M=d(I,h,E);x.targets=M.length?M:[[A]]}}return x},g=m=>{let _=e(m);if(_)return f(_.id);let h=t(m);if(h)return p(h.id)};return{configureElement:m=>{let _=g(m);if(_)return r([m]),_},getConfigureElement:g,getNodeConfigure:f,getEdgeConfigure:p}};import{jsx as gr,jsxs as km}from"react/jsx-runtime";var wt=({elementId:e,elementType:t="node"})=>{let{t:o}=Pm(),{onConfigureElement:n}=Q(),{getConfigureElement:r}=mr();return km(Cm,{children:[gr(Mm,{asChild:!0,children:gr(Im,{variant:"ghost",color:"grey",size:"small",iconButton:!0,onClick:()=>{let a=r(e);a&&(n==null||n(a))},children:gr(Lm,{size:16})})}),gr(Sm,{color:"black",children:o(t==="node"?"editor.toolbar.configure_node":"editor.toolbar.configure_edge")})]})};import{Button as Dm,Tooltip as Om,TooltipContent as Vm,TooltipTrigger as Hm,useTranslation as Gm}from"@produto-lecom/lecom-ui";import{useReactFlow as Bm}from"@xyflow/react";import{TrashIcon as zm}from"lucide-react";import{useNotificationToast as Rm}from"@produto-lecom/lecom-ui";function Ve(){let{toast:e}=en(),{toast:t}=Rm();return{toast:e||t}}import{jsx as hr,jsxs as Ym}from"react/jsx-runtime";var yr=({elementId:e,elementType:t="node"})=>{let{t:o}=Gm(),{toast:n}=Ve(),{deleteElements:r,getNodes:i}=Bm();return Ym(Om,{children:[hr(Hm,{asChild:!0,children:hr(Dm,{variant:"ghost",color:"destructive",size:"small",iconButton:!0,onClick:()=>{if(t==="node"){let s=i(),l=s.find(c=>c.id===e);if((l==null?void 0:l.type)==="LANE"&&s.some(d=>d.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}]})},children:hr(zm,{size:16})})}),hr(Vm,{color:"black",children:o("editor.toolbar.delete")})]})};import{Button as Fm,Tooltip as Wm,TooltipContent as Xm,TooltipTrigger as Um,useTranslation as $m}from"@produto-lecom/lecom-ui";import{MoveUpRightIcon as Km}from"lucide-react";import{useCallback as qm}from"react";import{jsx as xr,jsxs as Zm}from"react/jsx-runtime";var Yt=({nodeId:e,disabled:t=!1,tooltipMessage:o})=>{let{t:n}=$m(),r=qm(i=>{i.stopPropagation();let a=document.querySelectorAll(`.react-flow__handle.source[data-nodeid="${e}"]`);if(a.length===0)return;let s=Array.from(a).reduce((f,p)=>{let g=f.getBoundingClientRect(),y=p.getBoundingClientRect(),m=Math.hypot(i.clientX-(g.left+g.width/2),i.clientY-(g.top+g.height/2));return Math.hypot(i.clientX-(y.left+y.width/2),i.clientY-(y.top+y.height/2))<m?p:f}),l=s.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});s.dispatchEvent(u)},[e]);return Zm(Wm,{children:[xr(Um,{asChild:!0,children:xr(Fm,{variant:"ghost",color:"grey",size:"small",iconButton:!0,disabled:t,className:t?"opacity-50 cursor-not-allowed":"",onMouseDown:t?void 0:r,children:xr(Km,{size:16})})}),xr(Xm,{color:"black",children:o||n("editor.toolbar.connect_node")})]})};import{jsx as tn}from"react/jsx-runtime";var co=i=>{var a=i,{edgeId:e,edgeType:t,sourceNode:o,targetNode:n}=a,r=tt(a,["edgeId","edgeType","sourceNode","targetNode"]);let{mode:s}=Q(),{isFromStartEvent:l,isGatewayToGateway:c,isActiviyToAndGateway:d}=Cn(o,n),u=!l&&!c&&!d,f=[{component:tn(yr,{elementId:e,elementType:"edge"})}],p=()=>s==="view"?u?[{component:tn(wt,{elementId:e,elementType:"edge"})}]:[]:u?[{component:tn(wt,{elementId:e,elementType:"edge"})},...f]:f,y=(m=>{switch(m){case"SEQUENCE_EDGE":return p();case"MESSAGE_EDGE":return s==="view"?[]:[...f];case"ANNOTATION_EDGE":return s==="view"?[]:[...f];default:return[]}})(t);if(!(y.length===0||s==="view"))return tn("div",v(T({className:"flex items-center gap-1 w-fit px-3 py-2 bg-white rounded-sm shadow-md"},r),{children:y.map((m,_)=>tn("div",{children:m.component},_))}))};import{useViewport as Jm}from"@xyflow/react";import{useMemo as Qm}from"react";import{jsx as kl}from"react/jsx-runtime";var rt=12,uo=({sx:e,sy:t,tx:o,ty:n,hasLabel:r=!1,children:i})=>{let{zoom:a}=Jm(),s=1/a,l=Qm(()=>t===n?{bottom:`${rt}px`,transform:"translateX(-50%)"}:e===o?{left:`${rt}px`,transform:r?"translateY(-100%)":"translateY(-50%)"}:n>t&&o>e?{left:`${rt}px`,bottom:`${rt}px`}:n>t&&o<e?{right:`${rt}px`,bottom:`${rt}px`}:t>n&&o>e?{right:`${rt}px`,bottom:`${rt}px`}:{left:`${rt}px`,bottom:`${rt}px`},[e,t,o,n,r]);return kl("div",{style:{transform:`scale(${s})`},children:kl("div",{className:"absolute pointer-events-auto",style:T({},l),children:i})})};import{Fragment as ng,jsx as po,jsxs as Dl}from"react/jsx-runtime";var fo={type:"ANNOTATION_EDGE",reconnectable:!0},Ol=({id:e,source:t,target:o,selected:n,data:r})=>{let{isMultipleSelection:i}=Q(),{zoom:a}=og(),s=Rl(t),l=Rl(o);if(!s||!l)return null;let{sx:c,sy:d,tx:u,ty:f}=no(s,l),[p,g,y]=tg({sourceX:c,sourceY:d,targetX:u,targetY:f}),m=n||(s==null?void 0:s.selected)||(l==null?void 0:l.selected);return Dl(ng,{children:[po("path",{d:p,fill:"none",stroke:"transparent",strokeWidth:Math.max(12,12/a),style:{pointerEvents:"stroke",cursor:"pointer"}}),Dl("g",{className:D("text-grey-500 hover:text-grey-600",{"text-blue-500 hover:text-blue-600":m}),children:[po(jm,{id:e,path:p,interactionWidth:0,strokeDasharray:4,className:D("stroke-2 stroke-current transition-colors duration-75",{"stroke-red-500 hover:stroke-red-600":r==null?void 0:r.hasError,"stroke-blue-500 hover:stroke-blue-600 drop-shadow-[0_0_3px_rgba(59,130,246,0.5)]":m&&!(r!=null&&r.hasError)})}),po(eg,{children:po("div",{className:"absolute z-[3000] pointer-events-auto flex flex-col items-center gap-1",style:{transform:`translate(-50%, -50%) translate(${g}px, ${y}px)`},children:n&&!i&&po(uo,{sx:c,sy:d,tx:u,ty:f,children:po(co,{edgeId:e,edgeType:"ANNOTATION_EDGE"})})})})]})]})};import{useState as Xl,useCallback as Eg,useMemo as Di,useEffect as bg,useRef as Ul}from"react";import{BaseEdge as _g,EdgeLabelRenderer as Tg,MarkerType as $l,useInternalNode as Kl,useReactFlow as Ng,useViewport as vg,useEdges as wg,Position as ho}from"@xyflow/react";import{useCallback as rg,useEffect as ki,useRef as Vl,useState as ig}from"react";import{jsx as Gl}from"react/jsx-runtime";var Ri=/[a-zA-Z0-9À-ÖØ-öø-ÿ]/,Hl=["Backspace","Delete","ArrowLeft","ArrowRight","ArrowUp","ArrowDown","Home","End","Tab","Escape","Shift"],Ce=({value:e,maxLength:t,style:o,className:n,contentClassName:r,isEditing:i,onChange:a,onBlur:s,onInput:l,onInvalidFirstCharacter:c,skipFirstCharValidation:d})=>{let u=Vl(null),f=Vl(null),[p,g]=ig(!1);ki(()=>()=>{f.current&&clearTimeout(f.current)},[]),ki(()=>{g(i!=null?i:!1)},[i]),ki(()=>{if(p&&u.current){u.current.focus();let b=document.createRange();b.selectNodeContents(u.current);let x=window.getSelection();x&&(x.removeAllRanges(),x.addRange(b))}},[p]);let y=rg(()=>{f.current||(c==null||c(),f.current=setTimeout(()=>{f.current=null},500))},[c]),m=b=>{b.stopPropagation(),p||g(!0)},_=b=>{let x=b.currentTarget.innerText.replace(/\n$/,""),N=t&&x.length>=t,I=window.getSelection(),A=(I==null?void 0:I.toString())||"",M=A.length>0,S=(b.ctrlKey||b.metaKey)&&!b.altKey,k=S&&b.key==="a",B=S&&b.key==="c",q=S&&b.key==="x",j=S&&b.key==="v",C=x.length===0||M&&A.length===x.length;if(!d&&C&&!Ri.test(b.key)&&!Hl.includes(b.key)&&!S){b.preventDefault(),y();return}N&&!M&&(Hl.includes(b.key)||k||B||q||j||b.preventDefault())},h=b=>{b.preventDefault();let x=b.clipboardData.getData("text/plain").replace(/\r\n/g,`
1
+ var Pu=Object.defineProperty,Lu=Object.defineProperties;var ku=Object.getOwnPropertyDescriptors;var En=Object.getOwnPropertySymbols;var ds=Object.prototype.hasOwnProperty,us=Object.prototype.propertyIsEnumerable;var cs=(e,t,o)=>t in e?Pu(e,t,{enumerable:!0,configurable:!0,writable:!0,value:o}):e[t]=o,T=(e,t)=>{for(var o in t||(t={}))ds.call(t,o)&&cs(e,o,t[o]);if(En)for(var o of En(t))us.call(t,o)&&cs(e,o,t[o]);return e},v=(e,t)=>Lu(e,ku(t));var tt=(e,t)=>{var o={};for(var n in e)ds.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&&us.call(e,n)&&(o[n]=e[n]);return o};var ai=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 Ru,Translations as Du}from"@produto-lecom/lecom-ui";var ps={translations:{general:{layout:{title:"Modeler"}},editor:{toolbar:{delete:"Delete",configure_node:"Configure activity",configure_edge:"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",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."},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",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",minimap:{label:"Minimap",open:"Open minimap",close:"Hide minimap"}},history:{undo:"Undo",redo:"Redo"}},modals:{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:"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:"The gateway does 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_referenced_not_configured:"The subprocess reference is not properly configured",start_event_not_found:"At least one start event is required",end_event_not_found:"At least one end event is required"}},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"},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:"It is not possible to import the diagram from the Governance platform, since the diagram has already been initialized"},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 fs={translations:{general:{layout:{title:"Modeler"}},editor:{toolbar:{delete:"Eliminar",configure_node:"Configurar actividad",configure_edge:"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",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."},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",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",minimap:{label:"Minimapa",open:"Abrir minimapa",close:"Ocultar minimapa"}},history:{undo:"Deshacer",redo:"Rehacer"}},modals:{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:"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:"La compuerta no tiene 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_referenced_not_configured:"La referencia al subproceso no est\xE1 configurada correctamente",start_event_not_found:"Es necesario tener al menos un evento de inicio",end_event_not_found:"Es necesario tener al menos un evento final"}},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"},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:"No es posible importar el diagrama de la plataforma Governance, ya que el diagrama ya ha sido iniciado"},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 ms={translations:{general:{layout:{title:"Modeler"}},editor:{toolbar:{delete:"Excluir",configure_node:"Configurar atividade",configure_edge:"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",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."},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",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",minimap:{label:"Minimapa",open:"Abrir minimapa",close:"Ocultar minimapa"}},history:{undo:"Desfazer",redo:"Refazer"}},modals:{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:"Atividade com loop"}},validation:{success:{title:"Diagrama v\xE1lidado 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:"O gateway n\xE3o possui 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_referenced_not_configured:"A refer\xEAncia ao subprocesso n\xE3o est\xE1 configurada corretamente",start_event_not_found:"\xC9 necess\xE1rio ter ao menos um evento inicial",end_event_not_found:"\xC9 necess\xE1rio ter ao menos um evento final"}},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"},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:"N\xE3o \xE9 poss\xEDvel importar o diagrama da plataforma Governance, pois o diagrama j\xE1 foi iniciado"},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 gs={pt_BR:ms,en_US:ps,es_ES:fs};var hs,ys,Ou=(ys=(hs=ai("LecomUserLanguage"))!=null?hs:ai("org.springframework.web.servlet.i18n.CookieLocaleResolver.LOCALE"))!=null?ys:Du.PT_BR;Ru({lng:Ou,resources:gs});var Re=(n=>(n.EDIT="edit",n.VIEW="view",n.READONLY="readonly",n))(Re||{});var bn=(r=>(r.ACTIVITY="activity",r.ROUTING="routing",r.GATEWAY="gateway",r.SUB_PROCESS="sub_process",r))(bn||{}),li=(n=>(n.START="start",n.END="end",n.BETWEEN="between",n))(li||{}),ci=(n=>(n.SCRIPT="script",n.LOOP="loop",n.SCRIPT_LOOP="script_loop",n))(ci||{}),di=(d=>(d.SIMPLE="simple",d.LOOP="loop",d.SCRIPT="script",d.SCRIPT_LOOP="script_loop",d.COMPLEX="complex",d.EXCLUSIVE="exclusive",d.PARALLEL="parallel",d.FINAL="final",d.TO_SUB_PROCESS="to_sub_process",d.FROM_SUB_PROCESS="from_sub_process",d))(di||{});import{RotateCcw as Ku,ScrollText as qu,SquarePlus as Zu}from"lucide-react";import{jsx as _n,jsxs as Vu}from"react/jsx-runtime";var Tn=({size:e=24,className:t})=>Vu("svg",{width:e,height:e,viewBox:"0 0 24 24",xmlns:"http://www.w3.org/2000/svg",fill:"#6b7280",className:t,children:[_n("path",{strokeWidth:"2",d:"M16 3V3.5085V11.9998V20.4915V21H16.5411H21.4592H22V19.123H21.4592H17.9974V11.9998V4.8773H21.4592H22V3H21.4592H16.5411H16Z"}),_n("path",{d:"M4.41026 16.9999L2 18.7861L3.89693 21.1103L6.3072 19.324L4.41026 16.9999Z"}),_n("path",{d:"M8.41026 13.9999L6 15.7861L7.89693 18.1103L10.3072 16.324L8.41026 13.9999Z"}),_n("path",{d:"M12.4313 10.954L10.021 12.7402L11.9179 15.0644L14.3282 13.2781L12.4313 10.954Z"})]});import{jsx as xs}from"react/jsx-runtime";var jt=({size:e=24,className:t})=>xs("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:xs("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 Lo,jsxs as Hu}from"react/jsx-runtime";var eo=({size:e=24,className:t})=>Hu("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:[Lo("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"}),Lo("path",{d:"M12 8V16",strokeLinecap:"round",strokeLinejoin:"round"}),Lo("path",{d:"M8 12H16",strokeLinecap:"round",strokeLinejoin:"round"}),Lo("path",{d:"M9.17139 9.17188L14.8282 14.8287",strokeLinecap:"round",strokeLinejoin:"round"}),Lo("path",{d:"M14.8281 9.17188L9.17127 14.8287",strokeLinecap:"round",strokeLinejoin:"round"})]});import{jsx as ui,jsxs as Gu}from"react/jsx-runtime";var to=({size:e=24,className:t})=>Gu("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:[ui("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"}),ui("path",{d:"M14.8286 9.17188L9.17176 14.8287",strokeLinecap:"round",strokeLinejoin:"round"}),ui("path",{d:"M9.17139 9.17188L14.8282 14.8287",strokeLinecap:"round",strokeLinejoin:"round"})]});import{jsx as pi,jsxs as Bu}from"react/jsx-runtime";var oo=({size:e=24,className:t})=>Bu("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:[pi("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"}),pi("path",{d:"M12 8V16",strokeLinecap:"round",strokeLinejoin:"round"}),pi("path",{d:"M8 12H16",strokeLinecap:"round",strokeLinejoin:"round"})]});import{jsx as fi,jsxs as zu}from"react/jsx-runtime";var Es=({size:e=24,className:t})=>fi("svg",{width:e,height:e,viewBox:"0 0 34 24",xmlns:"http://www.w3.org/2000/svg",fill:"currentColor",className:t,children:zu("g",{children:[fi("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"}),fi("path",{d:"M24.5 4.5L28 1M28 1L31.5 4.5M28 1V8",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round"})]})});import{clsx as Yu}from"clsx";import{twMerge as Fu}from"tailwind-merge";function R(...e){return Fu(Yu(e))}var xt=(e=0,t=0)=>e<t?t:e,Nn=(e=1e3)=>new Promise(t=>{setTimeout(t,e)});import{jsx as bs,jsxs as Wu}from"react/jsx-runtime";var _s=({size:e=24,className:t})=>Wu("svg",{width:e,height:e,viewBox:"0 0 24 24",fill:"none",stroke:"#6b7280",strokeWidth:2,xmlns:"http://www.w3.org/2000/svg",className:R("stroke-2",t),children:[bs("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"}),bs("path",{d:"M9 3V21",strokeLinecap:"round",strokeLinejoin:"round"})]});import{jsx as mi}from"react/jsx-runtime";var Ts=({size:e=24,className:t})=>mi("svg",{width:e,height:e,viewBox:"0 0 24 24",xmlns:"http://www.w3.org/2000/svg",stroke:"currentColor",className:t,children:mi("g",{children:mi("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 Ns}from"react/jsx-runtime";var vn=({size:e=24,className:t})=>Ns("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:Ns("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 vs}from"react/jsx-runtime";var ko=({size:e=24,className:t})=>vs("svg",{width:e,height:e,viewBox:"0 0 24 24",xmlns:"http://www.w3.org/2000/svg",fill:"white",stroke:"#6b7280",className:R("stroke-2",t),children:vs("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 gi,jsxs as Xu}from"react/jsx-runtime";var ws=({size:e=24,className:t})=>Xu("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:[gi("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"}),gi("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"}),gi("path",{d:"M7.5 7.5V10H10",strokeWidth:"1.5",fill:"none",strokeLinecap:"round",strokeLinejoin:"round"})]});import{jsx as Ro,jsxs as Uu}from"react/jsx-runtime";var As=({size:e=24,className:t})=>Uu("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:[Ro("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"}),Ro("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"}),Ro("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"}),Ro("path",{d:"M13.5 12H11",strokeWidth:"1",strokeLinecap:"round",strokeLinejoin:"round"}),Ro("path",{d:"M13.5 10H11",strokeWidth:"1",strokeLinecap:"round",strokeLinejoin:"round"})]});import{jsx as wn,jsxs as $u}from"react/jsx-runtime";var Is=({size:e=24,className:t})=>$u("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:[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 oe=(s=>(s.START_EVENT="START_EVENT",s.END_EVENT="END_EVENT",s.TASK="TASK",s.LANE="LANE",s.GATEWAY="GATEWAY",s.ANNOTATION="ANNOTATION",s.UNSUPPORTED="UNSUPPORTED",s))(oe||{}),Ke=(o=>(o.SCRIPT="SCRIPT",o.SUBPROCESS="SUBPROCESS",o))(Ke||{}),An={SCRIPT:{icon:qu},SUBPROCESS:{icon:Zu}},ot=(t=>(t.LOOP="LOOP",t))(ot||{}),In={LOOP:{icon:Ku}},qe=(n=>(n.EXCLUSIVE="EXCLUSIVE",n.PARALLEL="PARALLEL",n.COMPLEX="COMPLEX",n))(qe||{}),hi={EXCLUSIVE:{icon:to},PARALLEL:{icon:oo},COMPLEX:{icon:eo}};import{ReactFlowProvider as jx}from"@xyflow/react";import{createContext as eE,useContext as tE,useEffect as oE,useId as nE,useMemo as rE,useState as je}from"react";import{Background as Ax,MiniMap as Ix,ReactFlow as Cx,SelectionMode as Sx,useKeyPress as Mx}from"@xyflow/react";import{forwardRef as Px,useEffect as vu,useImperativeHandle as Lx,useRef as kx,useState as Rx}from"react";import{useTranslation as s0}from"@produto-lecom/lecom-ui";import{useEdgesState as a0,useNodesState as l0,useOnSelectionChange as c0,useReactFlow as d0,useStoreApi as u0}from"@xyflow/react";import{useCallback as Rt,useEffect as p0}from"react";import{Position as Do}from"@xyflow/react";function Cs(e,t){var E,w,_,x;let{width:o=0,height:n=0}=e.measured||{width:0,height:0},r=e.internals.positionAbsolute,i=t.internals.positionAbsolute,a=o/2,s=n/2,l=r.x+a,c=r.y+s,d=i.x+((w=(E=t==null?void 0:t.measured)==null?void 0:E.width)!=null?w:0)/2,u=i.y+((x=(_=t==null?void 0:t.measured)==null?void 0:_.height)!=null?x:0)/2,f=(d-l)/(2*a)-(u-c)/(2*s),p=(d-l)/(2*a)+(u-c)/(2*s),g=1/(Math.abs(f)+Math.abs(p)||1),y=g*f,m=g*p,b=a*(y+m)+l,h=s*(-y+m)+c;return{x:b,y:h}}function Ss(e,t){var c,d,u,f;let{positionAbsolute:o}=e.internals,n=(d=(c=e.measured)==null?void 0:c.width)!=null?d:0,r=(f=(u=e.measured)==null?void 0:u.height)!=null?f:0,i=Math.round(o.x),a=Math.round(o.y),s=Math.round(t.x),l=Math.round(t.y);return s<=i+1?Do.Left:s>=i+n-1?Do.Right:l<=a+1?Do.Top:l>=a+r-1?Do.Bottom:Do.Top}function no(e,t){let o=Cs(e,t),n=Cs(t,e),r=Ss(e,o),i=Ss(t,n);return{sx:o.x,sy:o.y,tx:n.x,ty:n.y,sourcePos:r,targetPos:i}}function Cn(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{create as Ju}from"zustand";import{useReactFlow as Qu}from"@xyflow/react";import{useCallback as ju}from"react";var Sn=()=>{let{setEdges:e}=Qu();return ju(()=>{let o=Ot.getState().pathEdgeIds;e(n=>n.map(r=>v(T({},r),{selected:o.includes(r.id)})))},[e])},Ot=Ju((e,t)=>({statusByNodeId:{},statusData:{},pathEdgeIds:[],setTaskStatuses:o=>{o!=null&&o.length&&e(n=>{let r=T({},n.statusByNodeId),i=T({},n.statusData),a=!1;return o.forEach(s=>{let l=`${s.diagramId}-${s.activityId}`;r[s.diagramId]!==s.status&&(r[s.diagramId]=s.status,i[l]=s,a=!0)}),a?{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=[],a={};o.forEach(d=>{a[d.source]||(a[d.source]=[]),a[d.source].push({targetId:d.target,edgeId:d.id})});let s=r[0],l=r[r.length-1];o.forEach(d=>{d.target===s&&i.push(d.id)}),o.forEach(d=>{d.source===l&&i.push(d.id)});let c=(d,u)=>{let f=[],p=new Set;for(f.push({node:d,path:[]}),p.add(d);f.length>0;){let{node:g,path:y}=f.shift();if(g===u)return y;let m=a[g]||[];for(let{targetId:b,edgeId:h}of m)p.has(b)||(p.add(b),f.push({node:b,path:[...y,h]}))}return[]};for(let d=0;d<r.length-1;d++){let u=r[d],f=r[d+1],p=c(u,f);p.length>0&&i.push(...p)}i.length>0&&e({pathEdgeIds:i})}}));import{useNodesInitialized as gm,useReactFlow as hm,useStore as ym}from"@xyflow/react";import{useCallback as Zo,useEffect as xm,useRef as Em,useState as Nl}from"react";import{shallow as bm}from"zustand/shallow";var ep={value:()=>{}};function Ps(){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 Mn(o)}function Mn(e){this._=e}function tp(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}})}Mn.prototype=Ps.prototype={constructor:Mn,on:function(e,t){var o=this._,n=tp(e+"",o),r,i=-1,a=n.length;if(arguments.length<2){for(;++i<a;)if((r=(e=n[i]).type)&&(r=op(o[r],e.name)))return r;return}if(t!=null&&typeof t!="function")throw new Error("invalid callback: "+t);for(;++i<a;)if(r=(e=n[i]).type)o[r]=Ms(o[r],e.name,t);else if(t==null)for(r in o)o[r]=Ms(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 Mn(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 op(e,t){for(var o=0,n=e.length,r;o<n;++o)if((r=e[o]).name===t)return r.value}function Ms(e,t,o){for(var n=0,r=e.length;n<r;++n)if(e[n].name===t){e[n]=ep,e=e.slice(0,n).concat(e.slice(n+1));break}return o!=null&&e.push({name:t,value:o}),e}var yi=Ps;var Pn="http://www.w3.org/1999/xhtml",xi={svg:"http://www.w3.org/2000/svg",xhtml:Pn,xlink:"http://www.w3.org/1999/xlink",xml:"http://www.w3.org/XML/1998/namespace",xmlns:"http://www.w3.org/2000/xmlns/"};function at(e){var t=e+="",o=t.indexOf(":");return o>=0&&(t=e.slice(0,o))!=="xmlns"&&(e=e.slice(o+1)),xi.hasOwnProperty(t)?{space:xi[t],local:e}:e}function np(e){return function(){var t=this.ownerDocument,o=this.namespaceURI;return o===Pn&&t.documentElement.namespaceURI===Pn?t.createElement(e):t.createElementNS(o,e)}}function rp(e){return function(){return this.ownerDocument.createElementNS(e.space,e.local)}}function Ln(e){var t=at(e);return(t.local?rp:np)(t)}function ip(){}function Vt(e){return e==null?ip:function(){return this.querySelector(e)}}function Ls(e){typeof e!="function"&&(e=Vt(e));for(var t=this._groups,o=t.length,n=new Array(o),r=0;r<o;++r)for(var i=t[r],a=i.length,s=n[r]=new Array(a),l,c,d=0;d<a;++d)(l=i[d])&&(c=e.call(l,l.__data__,d,i))&&("__data__"in l&&(c.__data__=l.__data__),s[d]=c);return new Ee(n,this._parents)}function Ei(e){return e==null?[]:Array.isArray(e)?e:Array.from(e)}function sp(){return[]}function Oo(e){return e==null?sp:function(){return this.querySelectorAll(e)}}function ap(e){return function(){return Ei(e.apply(this,arguments))}}function ks(e){typeof e=="function"?e=ap(e):e=Oo(e);for(var t=this._groups,o=t.length,n=[],r=[],i=0;i<o;++i)for(var a=t[i],s=a.length,l,c=0;c<s;++c)(l=a[c])&&(n.push(e.call(l,l.__data__,c,a)),r.push(l));return new Ee(n,r)}function Vo(e){return function(){return this.matches(e)}}function kn(e){return function(t){return t.matches(e)}}var lp=Array.prototype.find;function cp(e){return function(){return lp.call(this.children,e)}}function dp(){return this.firstElementChild}function Rs(e){return this.select(e==null?dp:cp(typeof e=="function"?e:kn(e)))}var up=Array.prototype.filter;function pp(){return Array.from(this.children)}function fp(e){return function(){return up.call(this.children,e)}}function Ds(e){return this.selectAll(e==null?pp:fp(typeof e=="function"?e:kn(e)))}function Os(e){typeof e!="function"&&(e=Vo(e));for(var t=this._groups,o=t.length,n=new Array(o),r=0;r<o;++r)for(var i=t[r],a=i.length,s=n[r]=[],l,c=0;c<a;++c)(l=i[c])&&e.call(l,l.__data__,c,i)&&s.push(l);return new Ee(n,this._parents)}function Rn(e){return new Array(e.length)}function Vs(){return new Ee(this._enter||this._groups.map(Rn),this._parents)}function Ho(e,t){this.ownerDocument=e.ownerDocument,this.namespaceURI=e.namespaceURI,this._next=null,this._parent=e,this.__data__=t}Ho.prototype={constructor:Ho,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 Hs(e){return function(){return e}}function mp(e,t,o,n,r,i){for(var a=0,s,l=t.length,c=i.length;a<c;++a)(s=t[a])?(s.__data__=i[a],n[a]=s):o[a]=new Ho(e,i[a]);for(;a<l;++a)(s=t[a])&&(r[a]=s)}function gp(e,t,o,n,r,i,a){var s,l,c=new Map,d=t.length,u=i.length,f=new Array(d),p;for(s=0;s<d;++s)(l=t[s])&&(f[s]=p=a.call(l,l.__data__,s,t)+"",c.has(p)?r[s]=l:c.set(p,l));for(s=0;s<u;++s)p=a.call(e,i[s],s,i)+"",(l=c.get(p))?(n[s]=l,l.__data__=i[s],c.delete(p)):o[s]=new Ho(e,i[s]);for(s=0;s<d;++s)(l=t[s])&&c.get(f[s])===l&&(r[s]=l)}function hp(e){return e.__data__}function Gs(e,t){if(!arguments.length)return Array.from(this,hp);var o=t?gp:mp,n=this._parents,r=this._groups;typeof e!="function"&&(e=Hs(e));for(var i=r.length,a=new Array(i),s=new Array(i),l=new Array(i),c=0;c<i;++c){var d=n[c],u=r[c],f=u.length,p=yp(e.call(d,d&&d.__data__,c,n)),g=p.length,y=s[c]=new Array(g),m=a[c]=new Array(g),b=l[c]=new Array(f);o(d,u,y,m,b,p,t);for(var h=0,E=0,w,_;h<g;++h)if(w=y[h]){for(h>=E&&(E=h+1);!(_=m[E])&&++E<g;);w._next=_||null}}return a=new Ee(a,n),a._enter=s,a._exit=l,a}function yp(e){return typeof e=="object"&&"length"in e?e:Array.from(e)}function Bs(){return new Ee(this._exit||this._groups.map(Rn),this._parents)}function zs(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 Ys(e){for(var t=e.selection?e.selection():e,o=this._groups,n=t._groups,r=o.length,i=n.length,a=Math.min(r,i),s=new Array(r),l=0;l<a;++l)for(var c=o[l],d=n[l],u=c.length,f=s[l]=new Array(u),p,g=0;g<u;++g)(p=c[g]||d[g])&&(f[g]=p);for(;l<r;++l)s[l]=o[l];return new Ee(s,this._parents)}function Fs(){for(var e=this._groups,t=-1,o=e.length;++t<o;)for(var n=e[t],r=n.length-1,i=n[r],a;--r>=0;)(a=n[r])&&(i&&a.compareDocumentPosition(i)^4&&i.parentNode.insertBefore(a,i),i=a);return this}function Ws(e){e||(e=xp);function t(u,f){return u&&f?e(u.__data__,f.__data__):!u-!f}for(var o=this._groups,n=o.length,r=new Array(n),i=0;i<n;++i){for(var a=o[i],s=a.length,l=r[i]=new Array(s),c,d=0;d<s;++d)(c=a[d])&&(l[d]=c);l.sort(t)}return new Ee(r,this._parents).order()}function xp(e,t){return e<t?-1:e>t?1:e>=t?0:NaN}function Xs(){var e=arguments[0];return arguments[0]=this,e.apply(null,arguments),this}function Us(){return Array.from(this)}function $s(){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 a=n[r];if(a)return a}return null}function Ks(){let e=0;for(let t of this)++e;return e}function qs(){return!this.node()}function Zs(e){for(var t=this._groups,o=0,n=t.length;o<n;++o)for(var r=t[o],i=0,a=r.length,s;i<a;++i)(s=r[i])&&e.call(s,s.__data__,i,r);return this}function Ep(e){return function(){this.removeAttribute(e)}}function bp(e){return function(){this.removeAttributeNS(e.space,e.local)}}function _p(e,t){return function(){this.setAttribute(e,t)}}function Tp(e,t){return function(){this.setAttributeNS(e.space,e.local,t)}}function Np(e,t){return function(){var o=t.apply(this,arguments);o==null?this.removeAttribute(e):this.setAttribute(e,o)}}function vp(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 Js(e,t){var o=at(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?bp:Ep:typeof t=="function"?o.local?vp:Np:o.local?Tp:_p)(o,t))}function Dn(e){return e.ownerDocument&&e.ownerDocument.defaultView||e.document&&e||e.defaultView}function wp(e){return function(){this.style.removeProperty(e)}}function Ap(e,t,o){return function(){this.style.setProperty(e,t,o)}}function Ip(e,t,o){return function(){var n=t.apply(this,arguments);n==null?this.style.removeProperty(e):this.style.setProperty(e,n,o)}}function Qs(e,t,o){return arguments.length>1?this.each((t==null?wp:typeof t=="function"?Ip:Ap)(e,t,o==null?"":o)):Et(this.node(),e)}function Et(e,t){return e.style.getPropertyValue(t)||Dn(e).getComputedStyle(e,null).getPropertyValue(t)}function Cp(e){return function(){delete this[e]}}function Sp(e,t){return function(){this[e]=t}}function Mp(e,t){return function(){var o=t.apply(this,arguments);o==null?delete this[e]:this[e]=o}}function js(e,t){return arguments.length>1?this.each((t==null?Cp:typeof t=="function"?Mp:Sp)(e,t)):this.node()[e]}function ea(e){return e.trim().split(/^|\s+/)}function bi(e){return e.classList||new ta(e)}function ta(e){this._node=e,this._names=ea(e.getAttribute("class")||"")}ta.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 oa(e,t){for(var o=bi(e),n=-1,r=t.length;++n<r;)o.add(t[n])}function na(e,t){for(var o=bi(e),n=-1,r=t.length;++n<r;)o.remove(t[n])}function Pp(e){return function(){oa(this,e)}}function Lp(e){return function(){na(this,e)}}function kp(e,t){return function(){(t.apply(this,arguments)?oa:na)(this,e)}}function ra(e,t){var o=ea(e+"");if(arguments.length<2){for(var n=bi(this.node()),r=-1,i=o.length;++r<i;)if(!n.contains(o[r]))return!1;return!0}return this.each((typeof t=="function"?kp:t?Pp:Lp)(o,t))}function Rp(){this.textContent=""}function Dp(e){return function(){this.textContent=e}}function Op(e){return function(){var t=e.apply(this,arguments);this.textContent=t==null?"":t}}function ia(e){return arguments.length?this.each(e==null?Rp:(typeof e=="function"?Op:Dp)(e)):this.node().textContent}function Vp(){this.innerHTML=""}function Hp(e){return function(){this.innerHTML=e}}function Gp(e){return function(){var t=e.apply(this,arguments);this.innerHTML=t==null?"":t}}function sa(e){return arguments.length?this.each(e==null?Vp:(typeof e=="function"?Gp:Hp)(e)):this.node().innerHTML}function Bp(){this.nextSibling&&this.parentNode.appendChild(this)}function aa(){return this.each(Bp)}function zp(){this.previousSibling&&this.parentNode.insertBefore(this,this.parentNode.firstChild)}function la(){return this.each(zp)}function ca(e){var t=typeof e=="function"?e:Ln(e);return this.select(function(){return this.appendChild(t.apply(this,arguments))})}function Yp(){return null}function da(e,t){var o=typeof e=="function"?e:Ln(e),n=t==null?Yp:typeof t=="function"?t:Vt(t);return this.select(function(){return this.insertBefore(o.apply(this,arguments),n.apply(this,arguments)||null)})}function Fp(){var e=this.parentNode;e&&e.removeChild(this)}function ua(){return this.each(Fp)}function Wp(){var e=this.cloneNode(!1),t=this.parentNode;return t?t.insertBefore(e,this.nextSibling):e}function Xp(){var e=this.cloneNode(!0),t=this.parentNode;return t?t.insertBefore(e,this.nextSibling):e}function pa(e){return this.select(e?Xp:Wp)}function fa(e){return arguments.length?this.property("__data__",e):this.node().__data__}function Up(e){return function(t){e.call(this,t,this.__data__)}}function $p(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 Kp(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 qp(e,t,o){return function(){var n=this.__on,r,i=Up(t);if(n){for(var a=0,s=n.length;a<s;++a)if((r=n[a]).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 ma(e,t,o){var n=$p(e+""),r,i=n.length,a;if(arguments.length<2){var s=this.node().__on;if(s){for(var l=0,c=s.length,d;l<c;++l)for(r=0,d=s[l];r<i;++r)if((a=n[r]).type===d.type&&a.name===d.name)return d.value}return}for(s=t?qp:Kp,r=0;r<i;++r)this.each(s(n[r],t,o));return this}function ga(e,t,o){var n=Dn(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 Zp(e,t){return function(){return ga(this,e,t)}}function Jp(e,t){return function(){return ga(this,e,t.apply(this,arguments))}}function ha(e,t){return this.each((typeof t=="function"?Jp:Zp)(e,t))}function*ya(){for(var e=this._groups,t=0,o=e.length;t<o;++t)for(var n=e[t],r=0,i=n.length,a;r<i;++r)(a=n[r])&&(yield a)}var Qp=[null];function Ee(e,t){this._groups=e,this._parents=t}function xa(){return new Ee([[document.documentElement]],Qp)}function jp(){return this}Ee.prototype=xa.prototype={constructor:Ee,select:Ls,selectAll:ks,selectChild:Rs,selectChildren:Ds,filter:Os,data:Gs,enter:Vs,exit:Bs,join:zs,merge:Ys,selection:jp,order:Fs,sort:Ws,call:Xs,nodes:Us,node:$s,size:Ks,empty:qs,each:Zs,attr:Js,style:Qs,property:js,classed:ra,text:ia,html:sa,raise:aa,lower:la,append:ca,insert:da,remove:ua,clone:pa,datum:fa,on:ma,dispatch:ha,[Symbol.iterator]:ya};var lt=xa;function On(e,t,o){e.prototype=t.prototype=o,o.constructor=e}function _i(e,t){var o=Object.create(e.prototype);for(var n in t)o[n]=t[n];return o}function zo(){}var Go=.7,Gn=1/Go,ro="\\s*([+-]?\\d+)\\s*",Bo="\\s*([+-]?(?:\\d*\\.)?\\d+(?:[eE][+-]?\\d+)?)\\s*",nt="\\s*([+-]?(?:\\d*\\.)?\\d+(?:[eE][+-]?\\d+)?)%\\s*",ef=/^#([0-9a-f]{3,8})$/,tf=new RegExp(`^rgb\\(${ro},${ro},${ro}\\)$`),of=new RegExp(`^rgb\\(${nt},${nt},${nt}\\)$`),nf=new RegExp(`^rgba\\(${ro},${ro},${ro},${Bo}\\)$`),rf=new RegExp(`^rgba\\(${nt},${nt},${nt},${Bo}\\)$`),sf=new RegExp(`^hsl\\(${Bo},${nt},${nt}\\)$`),af=new RegExp(`^hsla\\(${Bo},${nt},${nt},${Bo}\\)$`),Ea={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};On(zo,bt,{copy(e){return Object.assign(new this.constructor,this,e)},displayable(){return this.rgb().displayable()},hex:ba,formatHex:ba,formatHex8:lf,formatHsl:cf,formatRgb:_a,toString:_a});function ba(){return this.rgb().formatHex()}function lf(){return this.rgb().formatHex8()}function cf(){return Ia(this).formatHsl()}function _a(){return this.rgb().formatRgb()}function bt(e){var t,o;return e=(e+"").trim().toLowerCase(),(t=ef.exec(e))?(o=t[1].length,t=parseInt(t[1],16),o===6?Ta(t):o===3?new De(t>>8&15|t>>4&240,t>>4&15|t&240,(t&15)<<4|t&15,1):o===8?Vn(t>>24&255,t>>16&255,t>>8&255,(t&255)/255):o===4?Vn(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=tf.exec(e))?new De(t[1],t[2],t[3],1):(t=of.exec(e))?new De(t[1]*255/100,t[2]*255/100,t[3]*255/100,1):(t=nf.exec(e))?Vn(t[1],t[2],t[3],t[4]):(t=rf.exec(e))?Vn(t[1]*255/100,t[2]*255/100,t[3]*255/100,t[4]):(t=sf.exec(e))?wa(t[1],t[2]/100,t[3]/100,1):(t=af.exec(e))?wa(t[1],t[2]/100,t[3]/100,t[4]):Ea.hasOwnProperty(e)?Ta(Ea[e]):e==="transparent"?new De(NaN,NaN,NaN,0):null}function Ta(e){return new De(e>>16&255,e>>8&255,e&255,1)}function Vn(e,t,o,n){return n<=0&&(e=t=o=NaN),new De(e,t,o,n)}function df(e){return e instanceof zo||(e=bt(e)),e?(e=e.rgb(),new De(e.r,e.g,e.b,e.opacity)):new De}function io(e,t,o,n){return arguments.length===1?df(e):new De(e,t,o,n==null?1:n)}function De(e,t,o,n){this.r=+e,this.g=+t,this.b=+o,this.opacity=+n}On(De,io,_i(zo,{brighter(e){return e=e==null?Gn:Math.pow(Gn,e),new De(this.r*e,this.g*e,this.b*e,this.opacity)},darker(e){return e=e==null?Go:Math.pow(Go,e),new De(this.r*e,this.g*e,this.b*e,this.opacity)},rgb(){return this},clamp(){return new De(Gt(this.r),Gt(this.g),Gt(this.b),Bn(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:Na,formatHex:Na,formatHex8:uf,formatRgb:va,toString:va}));function Na(){return`#${Ht(this.r)}${Ht(this.g)}${Ht(this.b)}`}function uf(){return`#${Ht(this.r)}${Ht(this.g)}${Ht(this.b)}${Ht((isNaN(this.opacity)?1:this.opacity)*255)}`}function va(){let e=Bn(this.opacity);return`${e===1?"rgb(":"rgba("}${Gt(this.r)}, ${Gt(this.g)}, ${Gt(this.b)}${e===1?")":`, ${e})`}`}function Bn(e){return isNaN(e)?1:Math.max(0,Math.min(1,e))}function Gt(e){return Math.max(0,Math.min(255,Math.round(e)||0))}function Ht(e){return e=Gt(e),(e<16?"0":"")+e.toString(16)}function wa(e,t,o,n){return n<=0?e=t=o=NaN:o<=0||o>=1?e=t=NaN:t<=0&&(e=NaN),new Ze(e,t,o,n)}function Ia(e){if(e instanceof Ze)return new Ze(e.h,e.s,e.l,e.opacity);if(e instanceof zo||(e=bt(e)),!e)return new Ze;if(e instanceof Ze)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),a=NaN,s=i-r,l=(i+r)/2;return s?(t===i?a=(o-n)/s+(o<n)*6:o===i?a=(n-t)/s+2:a=(t-o)/s+4,s/=l<.5?i+r:2-i-r,a*=60):s=l>0&&l<1?0:a,new Ze(a,s,l,e.opacity)}function Ca(e,t,o,n){return arguments.length===1?Ia(e):new Ze(e,t,o,n==null?1:n)}function Ze(e,t,o,n){this.h=+e,this.s=+t,this.l=+o,this.opacity=+n}On(Ze,Ca,_i(zo,{brighter(e){return e=e==null?Gn:Math.pow(Gn,e),new Ze(this.h,this.s,this.l*e,this.opacity)},darker(e){return e=e==null?Go:Math.pow(Go,e),new Ze(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 De(Ti(e>=240?e-240:e+120,r,n),Ti(e,r,n),Ti(e<120?e+240:e-120,r,n),this.opacity)},clamp(){return new Ze(Aa(this.h),Hn(this.s),Hn(this.l),Bn(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=Bn(this.opacity);return`${e===1?"hsl(":"hsla("}${Aa(this.h)}, ${Hn(this.s)*100}%, ${Hn(this.l)*100}%${e===1?")":`, ${e})`}`}}));function Aa(e){return e=(e||0)%360,e<0?e+360:e}function Hn(e){return Math.max(0,Math.min(1,e||0))}function Ti(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 Ni(e,t,o,n,r){var i=e*e,a=i*e;return((1-3*e+3*i-a)*t+(4-6*i+3*a)*o+(1+3*e+3*i-3*a)*n+a*r)/6}function Sa(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],a=n>0?e[n-1]:2*r-i,s=n<t-1?e[n+2]:2*i-r;return Ni((o-n/t)*t,a,r,i,s)}}function Ma(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],a=e[(n+1)%t],s=e[(n+2)%t];return Ni((o-n/t)*t,r,i,a,s)}}var vi=e=>()=>e;function pf(e,t){return function(o){return e+o*t}}function ff(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 Pa(e){return(e=+e)==1?zn:function(t,o){return o-t?ff(t,o,e):vi(isNaN(t)?o:t)}}function zn(e,t){var o=t-e;return o?pf(e,o):vi(isNaN(e)?t:e)}var Yn=function e(t){var o=Pa(t);function n(r,i){var a=o((r=io(r)).r,(i=io(i)).r),s=o(r.g,i.g),l=o(r.b,i.b),c=zn(r.opacity,i.opacity);return function(d){return r.r=a(d),r.g=s(d),r.b=l(d),r.opacity=c(d),r+""}}return n.gamma=e,n}(1);function La(e){return function(t){var o=t.length,n=new Array(o),r=new Array(o),i=new Array(o),a,s;for(a=0;a<o;++a)s=io(t[a]),n[a]=s.r||0,r[a]=s.g||0,i[a]=s.b||0;return n=e(n),r=e(r),i=e(i),s.opacity=1,function(l){return s.r=n(l),s.g=r(l),s.b=i(l),s+""}}}var mf=La(Sa),gf=La(Ma);function Ye(e,t){return e=+e,t=+t,function(o){return e*(1-o)+t*o}}var Ai=/[-+]?(?:\d+\.?\d*|\.?\d+)(?:[eE][-+]?\d+)?/g,wi=new RegExp(Ai.source,"g");function hf(e){return function(){return e}}function yf(e){return function(t){return e(t)+""}}function Ii(e,t){var o=Ai.lastIndex=wi.lastIndex=0,n,r,i,a=-1,s=[],l=[];for(e=e+"",t=t+"";(n=Ai.exec(e))&&(r=wi.exec(t));)(i=r.index)>o&&(i=t.slice(o,i),s[a]?s[a]+=i:s[++a]=i),(n=n[0])===(r=r[0])?s[a]?s[a]+=r:s[++a]=r:(s[++a]=null,l.push({i:a,x:Ye(n,r)})),o=wi.lastIndex;return o<t.length&&(i=t.slice(o),s[a]?s[a]+=i:s[++a]=i),s.length<2?l[0]?yf(l[0].x):hf(t):(t=l.length,function(c){for(var d=0,u;d<t;++d)s[(u=l[d]).i]=u.x(c);return s.join("")})}var ka=180/Math.PI,Fn={translateX:0,translateY:0,rotate:0,skewX:0,scaleX:1,scaleY:1};function Ci(e,t,o,n,r,i){var a,s,l;return(a=Math.sqrt(e*e+t*t))&&(e/=a,t/=a),(l=e*o+t*n)&&(o-=e*l,n-=t*l),(s=Math.sqrt(o*o+n*n))&&(o/=s,n/=s,l/=s),e*n<t*o&&(e=-e,t=-t,l=-l,a=-a),{translateX:r,translateY:i,rotate:Math.atan2(t,e)*ka,skewX:Math.atan(l)*ka,scaleX:a,scaleY:s}}var Wn;function Ra(e){let t=new(typeof DOMMatrix=="function"?DOMMatrix:WebKitCSSMatrix)(e+"");return t.isIdentity?Fn:Ci(t.a,t.b,t.c,t.d,t.e,t.f)}function Da(e){return e==null?Fn:(Wn||(Wn=document.createElementNS("http://www.w3.org/2000/svg","g")),Wn.setAttribute("transform",e),(e=Wn.transform.baseVal.consolidate())?(e=e.matrix,Ci(e.a,e.b,e.c,e.d,e.e,e.f)):Fn)}function Oa(e,t,o,n){function r(c){return c.length?c.pop()+" ":""}function i(c,d,u,f,p,g){if(c!==u||d!==f){var y=p.push("translate(",null,t,null,o);g.push({i:y-4,x:Ye(c,u)},{i:y-2,x:Ye(d,f)})}else(u||f)&&p.push("translate("+u+t+f+o)}function a(c,d,u,f){c!==d?(c-d>180?d+=360:d-c>180&&(c+=360),f.push({i:u.push(r(u)+"rotate(",null,n)-2,x:Ye(c,d)})):d&&u.push(r(u)+"rotate("+d+n)}function s(c,d,u,f){c!==d?f.push({i:u.push(r(u)+"skewX(",null,n)-2,x:Ye(c,d)}):d&&u.push(r(u)+"skewX("+d+n)}function l(c,d,u,f,p,g){if(c!==u||d!==f){var y=p.push(r(p)+"scale(",null,",",null,")");g.push({i:y-4,x:Ye(c,u)},{i:y-2,x:Ye(d,f)})}else(u!==1||f!==1)&&p.push(r(p)+"scale("+u+","+f+")")}return function(c,d){var u=[],f=[];return c=e(c),d=e(d),i(c.translateX,c.translateY,d.translateX,d.translateY,u,f),a(c.rotate,d.rotate,u,f),s(c.skewX,d.skewX,u,f),l(c.scaleX,c.scaleY,d.scaleX,d.scaleY,u,f),c=d=null,function(p){for(var g=-1,y=f.length,m;++g<y;)u[(m=f[g]).i]=m.x(p);return u.join("")}}}var Si=Oa(Ra,"px, ","px)","deg)"),Mi=Oa(Da,", ",")",")");var so=0,Fo=0,Yo=0,Ha=1e3,Xn,Wo,Un=0,Bt=0,$n=0,Xo=typeof performance=="object"&&performance.now?performance:Date,Ga=typeof window=="object"&&window.requestAnimationFrame?window.requestAnimationFrame.bind(window):function(e){setTimeout(e,17)};function $o(){return Bt||(Ga(xf),Bt=Xo.now()+$n)}function xf(){Bt=0}function Uo(){this._call=this._time=this._next=null}Uo.prototype=Kn.prototype={constructor:Uo,restart:function(e,t,o){if(typeof e!="function")throw new TypeError("callback is not a function");o=(o==null?$o():+o)+(t==null?0:+t),!this._next&&Wo!==this&&(Wo?Wo._next=this:Xn=this,Wo=this),this._call=e,this._time=o,Pi()},stop:function(){this._call&&(this._call=null,this._time=1/0,Pi())}};function Kn(e,t,o){var n=new Uo;return n.restart(e,t,o),n}function Ba(){$o(),++so;for(var e=Xn,t;e;)(t=Bt-e._time)>=0&&e._call.call(void 0,t),e=e._next;--so}function Va(){Bt=(Un=Xo.now())+$n,so=Fo=0;try{Ba()}finally{so=0,bf(),Bt=0}}function Ef(){var e=Xo.now(),t=e-Un;t>Ha&&($n-=t,Un=e)}function bf(){for(var e,t=Xn,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:Xn=o);Wo=e,Pi(n)}function Pi(e){if(!so){Fo&&(Fo=clearTimeout(Fo));var t=e-Bt;t>24?(e<1/0&&(Fo=setTimeout(Va,e-Xo.now()-$n)),Yo&&(Yo=clearInterval(Yo))):(Yo||(Un=Xo.now(),Yo=setInterval(Ef,Ha)),so=1,Ga(Va))}}function qn(e,t,o){var n=new Uo;return t=t==null?0:+t,n.restart(r=>{n.stop(),e(r+t)},t,o),n}var _f=yi("start","end","cancel","interrupt"),Tf=[],Fa=0,za=1,Jn=2,Zn=3,Ya=4,Qn=5,Ko=6;function _t(e,t,o,n,r,i){var a=e.__transition;if(!a)e.__transition={};else if(o in a)return;Nf(e,o,{name:t,index:n,group:r,on:_f,tween:Tf,time:i.time,delay:i.delay,duration:i.duration,ease:i.ease,timer:null,state:Fa})}function qo(e,t){var o=be(e,t);if(o.state>Fa)throw new Error("too late; already scheduled");return o}function we(e,t){var o=be(e,t);if(o.state>Zn)throw new Error("too late; already running");return o}function be(e,t){var o=e.__transition;if(!o||!(o=o[t]))throw new Error("transition not found");return o}function Nf(e,t,o){var n=e.__transition,r;n[t]=o,o.timer=Kn(i,0,o.time);function i(c){o.state=za,o.timer.restart(a,o.delay,o.time),o.delay<=c&&a(c-o.delay)}function a(c){var d,u,f,p;if(o.state!==za)return l();for(d in n)if(p=n[d],p.name===o.name){if(p.state===Zn)return qn(a);p.state===Ya?(p.state=Ko,p.timer.stop(),p.on.call("interrupt",e,e.__data__,p.index,p.group),delete n[d]):+d<t&&(p.state=Ko,p.timer.stop(),p.on.call("cancel",e,e.__data__,p.index,p.group),delete n[d])}if(qn(function(){o.state===Zn&&(o.state=Ya,o.timer.restart(s,o.delay,o.time),s(c))}),o.state=Jn,o.on.call("start",e,e.__data__,o.index,o.group),o.state===Jn){for(o.state=Zn,r=new Array(f=o.tween.length),d=0,u=-1;d<f;++d)(p=o.tween[d].value.call(e,e.__data__,o.index,o.group))&&(r[++u]=p);r.length=u+1}}function s(c){for(var d=c<o.duration?o.ease.call(null,c/o.duration):(o.timer.restart(l),o.state=Qn,1),u=-1,f=r.length;++u<f;)r[u].call(e,d);o.state===Qn&&(o.on.call("end",e,e.__data__,o.index,o.group),l())}function l(){o.state=Ko,o.timer.stop(),delete n[t];for(var c in n)return;delete e.__transition}}function Li(e,t){var o=e.__transition,n,r,i=!0,a;if(o){t=t==null?null:t+"";for(a in o){if((n=o[a]).name!==t){i=!1;continue}r=n.state>Jn&&n.state<Qn,n.state=Ko,n.timer.stop(),n.on.call(r?"interrupt":"cancel",e,e.__data__,n.index,n.group),delete o[a]}i&&delete e.__transition}}function Wa(e){return this.each(function(){Li(this,e)})}function vf(e,t){var o,n;return function(){var r=we(this,e),i=r.tween;if(i!==o){n=o=i;for(var a=0,s=n.length;a<s;++a)if(n[a].name===t){n=n.slice(),n.splice(a,1);break}}r.tween=n}}function wf(e,t,o){var n,r;if(typeof o!="function")throw new Error;return function(){var i=we(this,e),a=i.tween;if(a!==n){r=(n=a).slice();for(var s={name:t,value:o},l=0,c=r.length;l<c;++l)if(r[l].name===t){r[l]=s;break}l===c&&r.push(s)}i.tween=r}}function Xa(e,t){var o=this._id;if(e+="",arguments.length<2){for(var n=be(this.node(),o).tween,r=0,i=n.length,a;r<i;++r)if((a=n[r]).name===e)return a.value;return null}return this.each((t==null?vf:wf)(o,e,t))}function ao(e,t,o){var n=e._id;return e.each(function(){var r=we(this,n);(r.value||(r.value={}))[t]=o.apply(this,arguments)}),function(r){return be(r,n).value[t]}}function jn(e,t){var o;return(typeof t=="number"?Ye:t instanceof bt?Yn:(o=bt(t))?(t=o,Yn):Ii)(e,t)}function Af(e){return function(){this.removeAttribute(e)}}function If(e){return function(){this.removeAttributeNS(e.space,e.local)}}function Cf(e,t,o){var n,r=o+"",i;return function(){var a=this.getAttribute(e);return a===r?null:a===n?i:i=t(n=a,o)}}function Sf(e,t,o){var n,r=o+"",i;return function(){var a=this.getAttributeNS(e.space,e.local);return a===r?null:a===n?i:i=t(n=a,o)}}function Mf(e,t,o){var n,r,i;return function(){var a,s=o(this),l;return s==null?void this.removeAttribute(e):(a=this.getAttribute(e),l=s+"",a===l?null:a===n&&l===r?i:(r=l,i=t(n=a,s)))}}function Pf(e,t,o){var n,r,i;return function(){var a,s=o(this),l;return s==null?void this.removeAttributeNS(e.space,e.local):(a=this.getAttributeNS(e.space,e.local),l=s+"",a===l?null:a===n&&l===r?i:(r=l,i=t(n=a,s)))}}function Ua(e,t){var o=at(e),n=o==="transform"?Mi:jn;return this.attrTween(e,typeof t=="function"?(o.local?Pf:Mf)(o,n,ao(this,"attr."+e,t)):t==null?(o.local?If:Af)(o):(o.local?Sf:Cf)(o,n,t))}function Lf(e,t){return function(o){this.setAttribute(e,t.call(this,o))}}function kf(e,t){return function(o){this.setAttributeNS(e.space,e.local,t.call(this,o))}}function Rf(e,t){var o,n;function r(){var i=t.apply(this,arguments);return i!==n&&(o=(n=i)&&kf(e,i)),o}return r._value=t,r}function Df(e,t){var o,n;function r(){var i=t.apply(this,arguments);return i!==n&&(o=(n=i)&&Lf(e,i)),o}return r._value=t,r}function $a(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=at(e);return this.tween(o,(n.local?Rf:Df)(n,t))}function Of(e,t){return function(){qo(this,e).delay=+t.apply(this,arguments)}}function Vf(e,t){return t=+t,function(){qo(this,e).delay=t}}function Ka(e){var t=this._id;return arguments.length?this.each((typeof e=="function"?Of:Vf)(t,e)):be(this.node(),t).delay}function Hf(e,t){return function(){we(this,e).duration=+t.apply(this,arguments)}}function Gf(e,t){return t=+t,function(){we(this,e).duration=t}}function qa(e){var t=this._id;return arguments.length?this.each((typeof e=="function"?Hf:Gf)(t,e)):be(this.node(),t).duration}function Bf(e,t){if(typeof t!="function")throw new Error;return function(){we(this,e).ease=t}}function Za(e){var t=this._id;return arguments.length?this.each(Bf(t,e)):be(this.node(),t).ease}function zf(e,t){return function(){var o=t.apply(this,arguments);if(typeof o!="function")throw new Error;we(this,e).ease=o}}function Ja(e){if(typeof e!="function")throw new Error;return this.each(zf(this._id,e))}function Qa(e){typeof e!="function"&&(e=Vo(e));for(var t=this._groups,o=t.length,n=new Array(o),r=0;r<o;++r)for(var i=t[r],a=i.length,s=n[r]=[],l,c=0;c<a;++c)(l=i[c])&&e.call(l,l.__data__,c,i)&&s.push(l);return new Pe(n,this._parents,this._name,this._id)}function ja(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),a=new Array(n),s=0;s<i;++s)for(var l=t[s],c=o[s],d=l.length,u=a[s]=new Array(d),f,p=0;p<d;++p)(f=l[p]||c[p])&&(u[p]=f);for(;s<n;++s)a[s]=t[s];return new Pe(a,this._parents,this._name,this._id)}function Yf(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 Ff(e,t,o){var n,r,i=Yf(t)?qo:we;return function(){var a=i(this,e),s=a.on;s!==n&&(r=(n=s).copy()).on(t,o),a.on=r}}function el(e,t){var o=this._id;return arguments.length<2?be(this.node(),o).on.on(e):this.each(Ff(o,e,t))}function Wf(e){return function(){var t=this.parentNode;for(var o in this.__transition)if(+o!==e)return;t&&t.removeChild(this)}}function tl(){return this.on("end.remove",Wf(this._id))}function ol(e){var t=this._name,o=this._id;typeof e!="function"&&(e=Vt(e));for(var n=this._groups,r=n.length,i=new Array(r),a=0;a<r;++a)for(var s=n[a],l=s.length,c=i[a]=new Array(l),d,u,f=0;f<l;++f)(d=s[f])&&(u=e.call(d,d.__data__,f,s))&&("__data__"in d&&(u.__data__=d.__data__),c[f]=u,_t(c[f],t,o,f,c,be(d,o)));return new Pe(i,this._parents,t,o)}function nl(e){var t=this._name,o=this._id;typeof e!="function"&&(e=Oo(e));for(var n=this._groups,r=n.length,i=[],a=[],s=0;s<r;++s)for(var l=n[s],c=l.length,d,u=0;u<c;++u)if(d=l[u]){for(var f=e.call(d,d.__data__,u,l),p,g=be(d,o),y=0,m=f.length;y<m;++y)(p=f[y])&&_t(p,t,o,y,f,g);i.push(f),a.push(d)}return new Pe(i,a,t,o)}var Xf=lt.prototype.constructor;function rl(){return new Xf(this._groups,this._parents)}function Uf(e,t){var o,n,r;return function(){var i=Et(this,e),a=(this.style.removeProperty(e),Et(this,e));return i===a?null:i===o&&a===n?r:r=t(o=i,n=a)}}function il(e){return function(){this.style.removeProperty(e)}}function $f(e,t,o){var n,r=o+"",i;return function(){var a=Et(this,e);return a===r?null:a===n?i:i=t(n=a,o)}}function Kf(e,t,o){var n,r,i;return function(){var a=Et(this,e),s=o(this),l=s+"";return s==null&&(l=s=(this.style.removeProperty(e),Et(this,e))),a===l?null:a===n&&l===r?i:(r=l,i=t(n=a,s))}}function qf(e,t){var o,n,r,i="style."+t,a="end."+i,s;return function(){var l=we(this,e),c=l.on,d=l.value[i]==null?s||(s=il(t)):void 0;(c!==o||r!==d)&&(n=(o=c).copy()).on(a,r=d),l.on=n}}function sl(e,t,o){var n=(e+="")=="transform"?Si:jn;return t==null?this.styleTween(e,Uf(e,n)).on("end.style."+e,il(e)):typeof t=="function"?this.styleTween(e,Kf(e,n,ao(this,"style."+e,t))).each(qf(this._id,e)):this.styleTween(e,$f(e,n,t),o).on("end.style."+e,null)}function Zf(e,t,o){return function(n){this.style.setProperty(e,t.call(this,n),o)}}function Jf(e,t,o){var n,r;function i(){var a=t.apply(this,arguments);return a!==r&&(n=(r=a)&&Zf(e,a,o)),n}return i._value=t,i}function al(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,Jf(e,t,o==null?"":o))}function Qf(e){return function(){this.textContent=e}}function jf(e){return function(){var t=e(this);this.textContent=t==null?"":t}}function ll(e){return this.tween("text",typeof e=="function"?jf(ao(this,"text",e)):Qf(e==null?"":e+""))}function em(e){return function(t){this.textContent=e.call(this,t)}}function tm(e){var t,o;function n(){var r=e.apply(this,arguments);return r!==o&&(t=(o=r)&&em(r)),t}return n._value=e,n}function cl(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,tm(e))}function dl(){for(var e=this._name,t=this._id,o=er(),n=this._groups,r=n.length,i=0;i<r;++i)for(var a=n[i],s=a.length,l,c=0;c<s;++c)if(l=a[c]){var d=be(l,t);_t(l,e,o,c,a,{time:d.time+d.delay+d.duration,delay:0,duration:d.duration,ease:d.ease})}return new Pe(n,this._parents,e,o)}function ul(){var e,t,o=this,n=o._id,r=o.size();return new Promise(function(i,a){var s={value:a},l={value:function(){--r===0&&i()}};o.each(function(){var c=we(this,n),d=c.on;d!==e&&(t=(e=d).copy(),t._.cancel.push(s),t._.interrupt.push(s),t._.end.push(l)),c.on=t}),r===0&&i()})}var om=0;function Pe(e,t,o,n){this._groups=e,this._parents=t,this._name=o,this._id=n}function pl(e){return lt().transition(e)}function er(){return++om}var ct=lt.prototype;Pe.prototype=pl.prototype={constructor:Pe,select:ol,selectAll:nl,selectChild:ct.selectChild,selectChildren:ct.selectChildren,filter:Qa,merge:ja,selection:rl,transition:dl,call:ct.call,nodes:ct.nodes,node:ct.node,size:ct.size,empty:ct.empty,each:ct.each,on:el,attr:Ua,attrTween:$a,style:sl,styleTween:al,text:ll,textTween:cl,remove:tl,tween:Xa,delay:Ka,duration:qa,ease:Za,easeVarying:Ja,end:ul,[Symbol.iterator]:ct[Symbol.iterator]};function tr(e){return((e*=2)<=1?e*e*e:(e-=2)*e*e+2)/2}var nm={time:null,delay:0,duration:250,ease:tr};function rm(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 fl(e){var t,o;e instanceof Pe?(t=e._id,e=e._name):(t=er(),(o=nm).time=$o(),e=e==null?null:e+"");for(var n=this._groups,r=n.length,i=0;i<r;++i)for(var a=n[i],s=a.length,l,c=0;c<s;++c)(l=a[c])&&_t(l,e,t,c,a,o||rm(l,t));return new Pe(n,this._parents,e,t)}lt.prototype.interrupt=Wa;lt.prototype.transition=fl;function Tt(e,t,o){this.k=e,this.x=t,this.y=o}Tt.prototype={constructor:Tt,scale:function(e){return e===1?this:new Tt(this.k*e,this.x,this.y)},translate:function(e,t){return e===0&t===0?this:new Tt(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 or=new Tt(1,0,0);nr.prototype=Tt.prototype;function nr(e){for(;!e.__zoom;)if(!(e=e.parentNode))return or;return e.__zoom}var sm=[[Number.NEGATIVE_INFINITY,Number.NEGATIVE_INFINITY],[Number.POSITIVE_INFINITY,Number.POSITIVE_INFINITY]];var ml;(function(e){e.Strict="strict",e.Loose="loose"})(ml||(ml={}));var gl;(function(e){e.Free="free",e.Vertical="vertical",e.Horizontal="horizontal"})(gl||(gl={}));var hl;(function(e){e.Partial="partial",e.Full="full"})(hl||(hl={}));var yl;(function(e){e.Bezier="default",e.Straight="straight",e.Step="step",e.SmoothStep="smoothstep",e.SimpleBezier="simplebezier"})(yl||(yl={}));var xl;(function(e){e.Arrow="arrow",e.ArrowClosed="arrowclosed"})(xl||(xl={}));var Oe;(function(e){e.Left="left",e.Top="top",e.Right="right",e.Bottom="bottom"})(Oe||(Oe={}));var Vv={[Oe.Left]:Oe.Right,[Oe.Right]:Oe.Left,[Oe.Top]:Oe.Bottom,[Oe.Bottom]:Oe.Top};var am=e=>"id"in e&&"internals"in e&&!("source"in e)&&!("target"in e);var lm=(e,t=[0,0])=>{var s;let{width:o,height:n}=cm(e),r=(s=e.origin)!=null?s:t,i=o*r[0],a=n*r[1];return{x:e.position.x-i,y:e.position.y-a}};var dt=(e,t=[0,0])=>{var r,i,a,s,l,c,d,u;let{x:o,y:n}=am(e)?e.internals.positionAbsolute:lm(e,t);return{x:o,y:n,x2:o+((s=(a=(i=(r=e.measured)==null?void 0:r.width)!=null?i:e.width)!=null?a:e.initialWidth)!=null?s: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 cm(e){var t,o,n,r,i,a,s,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=(s=(a=(i=e.measured)==null?void 0:i.height)!=null?a:e.height)!=null?s:e.initialHeight)!=null?l:0}}var Hv={[Oe.Left]:{x:-1,y:0},[Oe.Right]:{x:1,y:0},[Oe.Top]:{x:0,y:-1},[Oe.Bottom]:{x:0,y:1}};var dm={nodeOrigin:[0,0],nodeExtent:sm,elevateNodesOnSelect:!0,defaults:{}},Gv=v(T({},dm),{checkEquality:!0});var El;(function(e){e.Line="line",e.Handle="handle"})(El||(El={}));var um={width:0,height:0,x:0,y:0},Bv=v(T({},um),{pointerX:0,pointerY:0,aspectRatio:1});var pm=(e,t)=>e.x<t.x2&&e.x2>t.x&&e.y<t.y2&&e.y2>t.y;function fm(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 mm(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 rr=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 a=t==="horizontal"?this.yLines:this.xLines,[s,l]=t==="horizontal"?[r.y,r.y2]:[r.x,r.x2],c=[];for(let p of a){if(p.position<s)continue;if(p.position>l)break;if(i.has(p.node.id)||p.node.parentId&&i.has(p.node.parentId)||!pm(p.nodeBox,r))continue;let g=Math.abs(p.position-o);if(g>ir)continue;let m=fm(p.nodeBox,n)>0?0:mm(p.nodeBox,n);c.push({line:p,lineDist:g,nodeDist:m})}let d=.5,u=t==="horizontal"?this.lastHorizontalLine:this.lastVerticalLine;c.sort((p,g)=>{if(u){if(p.line===u&&g.line!==u)return-1;if(g.line===u&&p.line!==u)return 1}return Math.abs(p.lineDist-g.lineDist)<=d?p.nodeDist-g.nodeDist:p.lineDist-g.lineDist});let f=c.length>0?c[0].line:void 0;return f&&(t==="horizontal"?this.lastHorizontalLine=f:this.lastVerticalLine=f),f}};function bl(e,t=zt,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 a=dt(i);Object.entries(t).forEach(([s,l])=>{var c;n.push({position:l.resolve(r,a),color:(c=r.style)==null?void 0:c.backgroundColor,orientation:l.orientation,anchorName:s,nodeBox:a,node:r})})}),n}function _l(e,t,o,n,r=Object.keys(zt)){let i=[];for(let s of r){let l=zt[s],c=l.resolve(null,o),d=e.search(l.orientation,c,o,t,n);d&&i.push({sourcePosition:c,anchorName:s,anchor:l,line:d})}let a={horizontal:void 0,vertical:void 0};for(let s of i){let l=a[s.anchor.orientation],c=Math.abs(s.sourcePosition-s.line.position);(!l||c<Math.abs(l.sourcePosition-l.line.position))&&(a[s.anchor.orientation]=s)}return a}function Tl(e,t,o){let n=0,r=0,i=!1,a=!1;if(t){let l=t.anchor.resolve(null,e)-t.line.position;Math.abs(l)<=ir&&(r=l,a=!0)}if(o){let l=o.anchor.resolve(null,e)-o.line.position;Math.abs(l)<=ir&&(n=l,i=!0)}return{deltaX:n,deltaY:r,snappedX:i,snappedY:a}}var ir=10,zt={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 Tm}from"react/jsx-runtime";var _m=new rr;function sr(){let[e,t]=Nl(void 0),[o,n]=Nl(void 0),{width:r,height:i}=ym(m=>({width:m.width,height:m.height}),bm),a=gm(),s=Em(_m),{screenToFlowPosition:l,getInternalNode:c,getNodes:d}=hm(),u=Zo(()=>{t(void 0),n(void 0)},[]),f=Zo(m=>{let b=m!=null?m:d();u();let h=bl(b,zt,c);s.current.initialize(h)},[c,u,d]),p=Zo(()=>{setTimeout(()=>{f()},100)},[f]);xm(()=>{a&&f(d())},[a,f,d]);let g=Zo((m,b)=>{var K,L,V,F,Y,O,J,U,X,z;if(!s.current||m.length===0)return m;u();let h=m.filter(W=>W.type==="position"&&!!W.position),E=m.find(W=>W.type==="dimensions");if(h.length===0&&!E)return m;let w=Object.keys(zt),_=new Set,x=1/0,N=1/0,I=-1/0,A=-1/0;if(h.length>0)h.forEach(W=>{var he,fe,se,ie,ve,ke;let Z=b.find(yt=>yt.id===W.id);if(!Z)return;_.add(Z.id);let ee=c(Z.id);if(!ee)return;let le=ee.parentId?c(ee.parentId):void 0,ce=W.position.x+((he=le==null?void 0:le.internals.positionAbsolute.x)!=null?he:0),de=W.position.y+((fe=le==null?void 0:le.internals.positionAbsolute.y)!=null?fe:0),ue=(ie=(se=Z.measured)==null?void 0:se.width)!=null?ie:0,ge=(ke=(ve=Z.measured)==null?void 0:ve.height)!=null?ke:0;x=Math.min(x,ce),N=Math.min(N,de),I=Math.max(I,ce+ue),A=Math.max(A,de+ge)}),E&&(w=["top","left"]);else if(E){let W=b.find(ue=>ue.id===E.id);if(!W)return m;_.add(W.id);let Z=c(W.id);if(!Z)return m;let ee=Z.internals.positionAbsolute.x,le=Z.internals.positionAbsolute.y,ce=(F=(V=(K=E.dimensions)==null?void 0:K.width)!=null?V:(L=W.measured)==null?void 0:L.width)!=null?F:0,de=(U=(J=(Y=E.dimensions)==null?void 0:Y.height)!=null?J:(O=W.measured)==null?void 0:O.height)!=null?U:0;x=ee,N=le,I=ee+ce,A=le+de,w=["right","bottom"]}if(x===1/0)return m;let M={x,y:N,x2:I,y2:A},{x:S,y:k}=l({x:0,y:0}),{x:B,y:q}=l({x:r,y:i}),j={x:S,y:k,x2:B,y2:q},{horizontal:C,vertical:P}=_l(s.current,j,M,_,w),{deltaX:$,deltaY:H,snappedX:D,snappedY:G}=Tl(M,C,P);if(D||G){let W=h.some(ee=>ee.dragging),Z=!!(E!=null&&E.resizing);(W||Z)&&(D&&n(P==null?void 0:P.line),G&&t(C==null?void 0:C.line)),D&&(h.forEach(ee=>{ee.position&&(ee.position.x-=$)}),(E==null?void 0:E.id)===((X=h[0])==null?void 0:X.id)?E.dimensions&&(E.dimensions.width+=$):E&&!h.length&&E.dimensions&&(E.dimensions.width-=$)),G&&(h.forEach(ee=>{ee.position&&(ee.position.y-=H)}),(E==null?void 0:E.id)===((z=h[0])==null?void 0:z.id)?E.dimensions&&(E.dimensions.height+=H):E&&!h.length&&E.dimensions&&(E.dimensions.height-=H))}return m},[l,c,r,i,t,n,u]),y=Zo(()=>Tm(vl,{horizontal:e,vertical:o}),[e,o]);return{rebuildIndex:f,forceRebuildIndex:p,updateHelperLines:g,helperLineHorizontal:e,helperLineVertical:o,HelperLines:y}}import{reconnectEdge as Ty,useReactFlow as Ny}from"@xyflow/react";import{useCallback as $t,useRef as vy}from"react";var ut=e=>new Map(e.map(t=>[t.id,t])),Jo=(e,t,o)=>t.filter(n=>!(n.source!==e||o&&n.id===o)),wl=(e,t,o)=>t.filter(n=>!(n.target!==e||o&&n.id===o)),ki=e=>e.some(t=>t.type==="START_EVENT"),Nt=(e,t)=>e==="START_EVENT"?!ki(t):!0,Al=(e,t,o,n,r)=>{let i=ut(o),a=i.get(e);if(!a||a.type!=="START_EVENT")return!1;let s=i.get(t);return(s==null?void 0:s.type)==="ANNOTATION"?!1:Jo(e,n,r).filter(c=>{let d=i.get(c.target);return(d==null?void 0:d.type)!=="ANNOTATION"}).length>=1},Il=(e,t,o,n,r)=>{let i=ut(o),a=i.get(t);if(!a||a.type!=="END_EVENT")return!1;let s=i.get(e);return(s==null?void 0:s.type)==="ANNOTATION"?!1:wl(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=ut(o),a=i.get(e);if(!a||a.type!=="GATEWAY"||((c=a.data)==null?void 0:c.variant)!=="EXCLUSIVE")return!1;let s=t?i.get(t):null;return(s==null?void 0:s.type)==="ANNOTATION"?!1:Jo(e,n,r).filter(d=>{let u=i.get(d.target);return(u==null?void 0:u.type)!=="ANNOTATION"}).length>=2},Cl=(e,t,o)=>{var a,s,l,c;let n=ut(o),r=n.get(e),i=n.get(t);return(r==null?void 0:r.type)!=="GATEWAY"||(i==null?void 0:i.type)!=="GATEWAY"||((a=r==null?void 0:r.data)==null?void 0:a.variant)==="EXCLUSIVE"&&((s=i==null?void 0:i.data)==null?void 0:s.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"},lr=(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"},Sl=(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"},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.attribute)==="LOOP"},Qo=(e,t,o,n)=>{let r=ut(t),i=r.get(e);return!i||i.type!=="TASK"?!1:wl(e,o,n).some(s=>{let l=r.get(s.source);return(l==null?void 0:l.type)==="START_EVENT"})},jo=(e,t,o,n)=>{let r=ut(t),i=r.get(e);return!i||i.type!=="TASK"?!1:Jo(e,o,n).some(s=>{let l=r.get(s.target);return(l==null?void 0:l.type)==="END_EVENT"})},Ml=(e,t,o,n,r)=>{let i=ut(o),a=i.get(e),s=i.get(t);return(a==null?void 0:a.type)==="START_EVENT"&&(s==null?void 0:s.type)==="TASK"?jo(t,o,n,r):(s==null?void 0:s.type)==="END_EVENT"&&(a==null?void 0:a.type)==="TASK"?Qo(e,o,n,r):!1},dr=(e,t,o)=>Jo(e,t,o).length>0,ur=(e,t,o,n,r)=>{let i=ut(o),a=i.get(e);if(!a||a.type!=="TASK")return!1;let s=t?i.get(t):null;return(s==null?void 0:s.type)==="ANNOTATION"?!1:Jo(e,n,r).filter(c=>{let d=i.get(c.target);return(d==null?void 0:d.type)!=="ANNOTATION"}).length>=2};var Pl=(e,t,o,n,r)=>{var s,l;let i=ut(n),a=((s=i.get(e))==null?void 0:s.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||a&&c.source===t&&c.target===e))};var Nm=[e=>({isValid:e.sourceNodeId!==e.targetNodeId,reason:"self_connection_not_allowed"}),e=>({isValid:!Pl(e.sourceNodeId,e.targetNodeId,e.edges,e.nodes,e.reconnectingEdgeId),reason:"duplicate_connection_not_allowed"}),e=>({isValid:!Al(e.sourceNodeId,e.targetNodeId,e.nodes,e.edges,e.reconnectingEdgeId),reason:"start_event_limit_reached"}),e=>({isValid:!Il(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:!ur(e.sourceNodeId,e.targetNodeId,e.nodes,e.edges,e.reconnectingEdgeId),reason:"task_limit_reached"}),e=>({isValid:Cl(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"&&Sl(e.targetNodeId,e.nodes)),reason:"start_event_to_subprocess_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:!(lr(e.sourceNodeId,e.nodes)&&e.targetNodeType==="END_EVENT"),reason:"script_to_end_not_allowed"}),e=>({isValid:!(cr(e.sourceNodeId,e.nodes)&&e.targetNodeType==="END_EVENT"),reason:"loop_to_end_not_allowed"}),e=>({isValid:!(Qo(e.sourceNodeId,e.nodes,e.edges,e.reconnectingEdgeId)&&e.targetNodeType==="END_EVENT"),reason:"initial_activity_to_end_not_allowed"}),e=>({isValid:!Ml(e.sourceNodeId,e.targetNodeId,e.nodes,e.edges,e.reconnectingEdgeId),reason:"concurrent_initial_and_final_activity"}),e=>({isValid:!(jo(e.sourceNodeId,e.nodes,e.edges,e.reconnectingEdgeId)&&e.targetNodeType!=="ANNOTATION"),reason:"final_activity_cannot_connect"}),e=>({isValid:!(dr(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"})],Ri=e=>{for(let t of Nm){let o=t(e);if(!o.isValid)return o}return{isValid:!0}};var vm=[{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:ki(e.nodes),reason:"start_event_already_exists"})},{sourceTypes:["TASK"],targetTypes:["END_EVENT"],validate:e=>({shouldDisable:lr(e.sourceNodeId,e.nodes),reason:"script_to_end_not_allowed"})},{sourceTypes:["TASK"],targetTypes:["END_EVENT"],validate:e=>({shouldDisable:cr(e.sourceNodeId,e.nodes),reason:"loop_to_end_not_allowed"})},{sourceTypes:["TASK"],targetTypes:["END_EVENT"],validate:e=>({shouldDisable:Qo(e.sourceNodeId,e.nodes,e.edges),reason:"initial_activity_to_end_not_allowed"})},{sourceTypes:["TASK"],validate:e=>({shouldDisable:jo(e.sourceNodeId,e.nodes,e.edges)&&e.targetNodeType!=="ANNOTATION",reason:"final_activity_cannot_connect"})},{targetTypes:["END_EVENT"],validate:e=>({shouldDisable:dr(e.sourceNodeId,e.edges),reason:"activity_has_outgoing_connections"})},{sourceTypes:["TASK"],validate:e=>({shouldDisable:ur(e.sourceNodeId,null,e.nodes,e.edges)&&e.targetNodeType!=="ANNOTATION",reason:"task_limit_reached"})}],Ll=e=>{let t=vm.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 jm,EdgeLabelRenderer as eg,getStraightPath as tg,useInternalNode as Rl,useViewport as og}from"@xyflow/react";import{Button as Im,Tooltip as Cm,TooltipContent as Sm,TooltipTrigger as Mm,useTranslation as Pm}from"@produto-lecom/lecom-ui";import{Settings as Lm}from"lucide-react";import{getIncomers as pr,getOutgoers as fr,useReactFlow as Am}from"@xyflow/react";import{useStoreApi as wm}from"@xyflow/react";var vt=()=>{let e=wm();return{selectElements:n=>{let{edges:r,nodes:i,triggerEdgeChanges:a,triggerNodeChanges:s}=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 s(l),a(c),!0},clearSelection:async()=>{let{unselectNodesAndEdges:n}=e.getState();return n(),await Nn(),!0}}};var mr=()=>{let{getNode:e,getEdge:t,getNodes:o,getEdges:n}=Am(),{selectElements:r}=vt(),i=m=>{let b=o(),h=n(),E=pr(m,b,h),w=fr(m,b,h),_=E.some(N=>N.type==="START_EVENT"),x=w.some(N=>N.type==="END_EVENT");return _?"start":x?"end":"between"},a=(m,b,h)=>{var _,x,N,I;if(!m)return;let E={type:m.type,variant:(_=m.data)==null?void 0:_.variant,attribute:(x=m.data)==null?void 0:x.attribute},w={id:m.id,position:i(m),label:(N=m.data)==null?void 0:N.label,node:E};return m.type==="TASK"&&((I=m.data)==null?void 0:I.variant)==="SUBPROCESS"?v(T({},w),{type:"sub_process"}):m.type==="GATEWAY"?v(T({},w),{type:"gateway",variant:s(m,b,h)}):v(T({},w),{type:"activity"})},s=(m,b,h)=>{if(m.type!=="GATEWAY")return;let E=pr(m,b,h),w=!1,_=!1;if(E.forEach(x=>{var N,I;x.type==="TASK"&&(((N=x.data)==null?void 0:N.variant)==="SCRIPT"&&(w=!0),((I=x.data)==null?void 0:I.attribute)==="LOOP"&&(_=!0))}),w&&_)return"script_loop";if(w)return"script";if(_)return"loop"},l=(m,b,h)=>{var N,I,A,M;let E=e(m.source),w=e(m.target);if(!E||!w)return"simple";if(fr(E,b,h).some(S=>S.type==="END_EVENT"))return"final";if(E.type==="GATEWAY")switch((N=E.data)==null?void 0:N.variant){case"PARALLEL":return"parallel";case"EXCLUSIVE":return"exclusive";case"COMPLEX":return"complex";default:return"simple"}if(E.type==="TASK"){let S=(I=E.data)==null?void 0:I.variant,k=(A=E.data)==null?void 0:A.attribute;if(S==="SUBPROCESS")return"from_sub_process";if(w.type==="TASK"&&((M=w.data)==null?void 0:M.variant)==="SUBPROCESS")return"to_sub_process";let B=S==="SCRIPT",q=k==="LOOP";return B&&q?"script_loop":B?"script":q?"loop":"simple"}return"simple"},c=(m,b,h)=>{let E=[];function w(x,N,I=0){let A=a(x,b,h);if(A.depth=I,N.push(A),x.type==="TASK"){E.push([...N]),N.pop();return}let M=pr(x,b,h);if(M.length)for(let S of M)w(S,N,I+1);N.pop()}let _=pr(m,b,h);for(let x of _)w(x,[]);return E},d=(m,b,h)=>{let E=[];function w(x,N,I=0){let A=a(x,b,h);if(A.depth=I,N.push(A),x.type==="TASK"){E.push([...N]),N.pop();return}let M=fr(x,b,h);if(M.length)for(let S of M)w(S,N,I+1);N.pop()}let _=fr(m,b,h);for(let x of _)w(x,[]);return E},u=(m,b,h)=>(h=h.filter(w=>w.source===m.id),h.map(w=>{var N;let _=e(w.target),x;return _&&(x=a(_,b,h)),{id:w.id,type:"routing",variant:l(w,b,h),label:(N=w.data)==null?void 0:N.label,target:x}})),f=m=>{let b=e(m);if(!b)return;let h=o(),E=n(),w=a(b,h,E);return w.sources=c(b,h,E),w.targets=d(b,h,E),w.edgeTargets=u(b,h,E),b.type==="GATEWAY"&&(w.variant=s(b,h,E)),w},p=m=>{let b=t(m);if(!b)return;let h=o(),E=n(),w=l(b,h,E),x={id:b.id,type:"routing",variant:w,gatewayVariant:void 0},N=e(b.source);if(N){let A=a(N,h,E);x.source=A;let M=s(N,h,E);if(x.gatewayVariant=M,N.type==="TASK")x.sources=[[A]];else{let S=c(N,h,E);x.sources=S.length?S:[[A]]}}let I=e(b.target);if(I){let A=a(I,h,E);if(x.target=A,I.type==="TASK")x.targets=[[A]];else{let M=d(I,h,E);x.targets=M.length?M:[[A]]}}return x},g=m=>{let b=e(m);if(b)return f(b.id);let h=t(m);if(h)return p(h.id)};return{configureElement:m=>{let b=g(m);if(b)return r([m]),b},getConfigureElement:g,getNodeConfigure:f,getEdgeConfigure:p}};import{jsx as gr,jsxs as km}from"react/jsx-runtime";var wt=({elementId:e,elementType:t="node"})=>{let{t:o}=Pm(),{onConfigureElement:n}=Q(),{getConfigureElement:r}=mr();return km(Cm,{children:[gr(Mm,{asChild:!0,children:gr(Im,{variant:"ghost",color:"grey",size:"small",iconButton:!0,onClick:()=>{let a=r(e);a&&(n==null||n(a))},children:gr(Lm,{size:16})})}),gr(Sm,{color:"black",children:o(t==="node"?"editor.toolbar.configure_node":"editor.toolbar.configure_edge")})]})};import{Button as Dm,Tooltip as Om,TooltipContent as Vm,TooltipTrigger as Hm,useTranslation as Gm}from"@produto-lecom/lecom-ui";import{useReactFlow as Bm}from"@xyflow/react";import{TrashIcon as zm}from"lucide-react";import{useNotificationToast as Rm}from"@produto-lecom/lecom-ui";function Ve(){let{toast:e}=en(),{toast:t}=Rm();return{toast:e||t}}import{jsx as hr,jsxs as Ym}from"react/jsx-runtime";var yr=({elementId:e,elementType:t="node"})=>{let{t:o}=Gm(),{toast:n}=Ve(),{deleteElements:r,getNodes:i}=Bm();return Ym(Om,{children:[hr(Hm,{asChild:!0,children:hr(Dm,{variant:"ghost",color:"destructive",size:"small",iconButton:!0,onClick:()=>{if(t==="node"){let s=i(),l=s.find(c=>c.id===e);if((l==null?void 0:l.type)==="LANE"&&s.some(d=>d.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}]})},children:hr(zm,{size:16})})}),hr(Vm,{color:"black",children:o("editor.toolbar.delete")})]})};import{Button as Fm,Tooltip as Wm,TooltipContent as Xm,TooltipTrigger as Um,useTranslation as $m}from"@produto-lecom/lecom-ui";import{MoveUpRightIcon as Km}from"lucide-react";import{useCallback as qm}from"react";import{jsx as xr,jsxs as Zm}from"react/jsx-runtime";var lo=({nodeId:e,disabled:t=!1,tooltipMessage:o})=>{let{t:n}=$m(),r=qm(i=>{i.stopPropagation();let a=document.querySelectorAll(`.react-flow__handle.source[data-nodeid="${e}"]`);if(a.length===0)return;let s=Array.from(a).reduce((f,p)=>{let g=f.getBoundingClientRect(),y=p.getBoundingClientRect(),m=Math.hypot(i.clientX-(g.left+g.width/2),i.clientY-(g.top+g.height/2));return Math.hypot(i.clientX-(y.left+y.width/2),i.clientY-(y.top+y.height/2))<m?p:f}),l=s.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});s.dispatchEvent(u)},[e]);return Zm(Wm,{children:[xr(Um,{asChild:!0,children:xr(Fm,{variant:"ghost",color:"grey",size:"small",iconButton:!0,disabled:t,className:t?"opacity-50 cursor-not-allowed":"",onMouseDown:t?void 0:r,children:xr(Km,{size:16})})}),xr(Xm,{color:"black",children:o||n("editor.toolbar.connect_node")})]})};import{jsx as tn}from"react/jsx-runtime";var uo=i=>{var a=i,{edgeId:e,edgeType:t,sourceNode:o,targetNode:n}=a,r=tt(a,["edgeId","edgeType","sourceNode","targetNode"]);let{mode:s}=Q(),{isFromStartEvent:l,isGatewayToGateway:c,isActiviyToAndGateway:d,isToEndEvent:u}=Cn(o,n),f=!l&&!c&&!d&&!u,p=[{component:tn(yr,{elementId:e,elementType:"edge"})}],g=()=>s==="view"?f?[{component:tn(wt,{elementId:e,elementType:"edge"})}]:[]:f?[{component:tn(wt,{elementId:e,elementType:"edge"})},...p]:p,m=(b=>{switch(b){case"SEQUENCE_EDGE":return g();case"MESSAGE_EDGE":return s==="view"?[]:[...p];case"ANNOTATION_EDGE":return s==="view"?[]:[...p];default:return[]}})(t);if(!(m.length===0||s==="view"))return tn("div",v(T({className:"flex items-center gap-1 w-fit px-3 py-2 bg-white rounded-sm shadow-md"},r),{children:m.map((b,h)=>tn("div",{children:b.component},h))}))};import{useViewport as Jm}from"@xyflow/react";import{useMemo as Qm}from"react";import{jsx as kl}from"react/jsx-runtime";var rt=12,po=({sx:e,sy:t,tx:o,ty:n,hasLabel:r=!1,children:i})=>{let{zoom:a}=Jm(),s=1/a,l=Qm(()=>t===n?{bottom:`${rt}px`,transform:"translateX(-50%)"}:e===o?{left:`${rt}px`,transform:r?"translateY(-100%)":"translateY(-50%)"}:n>t&&o>e?{left:`${rt}px`,bottom:`${rt}px`}:n>t&&o<e?{right:`${rt}px`,bottom:`${rt}px`}:t>n&&o>e?{right:`${rt}px`,bottom:`${rt}px`}:{left:`${rt}px`,bottom:`${rt}px`},[e,t,o,n,r]);return kl("div",{style:{transform:`scale(${s})`},children:kl("div",{className:"absolute pointer-events-auto",style:T({},l),children:i})})};import{Fragment as ng,jsx as Yt,jsxs as Dl}from"react/jsx-runtime";var fo={type:"ANNOTATION_EDGE",reconnectable:!0},Ol=({id:e,source:t,target:o,selected:n,data:r})=>{let{isMultipleSelection:i}=Q(),{zoom:a}=og(),s=Rl(t),l=Rl(o);if(!s||!l)return null;let{sx:c,sy:d,tx:u,ty:f}=no(s,l),[p,g,y]=tg({sourceX:c,sourceY:d,targetX:u,targetY:f}),m=n||(s==null?void 0:s.selected)||(l==null?void 0:l.selected);return Yt(ng,{children:Dl("g",{className:R("group bpmn-edge",{"is-highlighted":m}),children:[Yt("path",{d:p,fill:"none",stroke:"transparent",strokeWidth:Math.max(12,12/a),style:{pointerEvents:"stroke",cursor:"pointer"}}),Dl("g",{className:R("text-grey-500 transition-colors duration-75 group-hover:text-grey-800",{"text-blue-500 group-hover:text-blue-600":m}),children:[Yt(jm,{id:e,path:p,interactionWidth:0,strokeDasharray:4,className:R("stroke-2 stroke-current transition-[stroke,filter] duration-75 group-hover:drop-shadow-[0_0_3px_rgba(0,0,0,0.2)]",{"stroke-red-500 hover:stroke-red-600":r==null?void 0:r.hasError,"stroke-blue-500 hover:stroke-blue-600 drop-shadow-[0_0_3px_rgba(59,130,246,0.5)]":m&&!(r!=null&&r.hasError)})}),Yt(eg,{children:Yt("div",{className:"absolute z-[3000] pointer-events-auto flex flex-col items-center gap-1",style:{transform:`translate(-50%, -50%) translate(${g}px, ${y}px)`},children:n&&!i&&Yt(po,{sx:c,sy:d,tx:u,ty:f,children:Yt(uo,{edgeId:e,edgeType:"ANNOTATION_EDGE"})})})})]})]})})};import{useState as Xl,useCallback as Eg,useMemo as Vi,useEffect as bg,useRef as Ul}from"react";import{BaseEdge as _g,EdgeLabelRenderer as Tg,MarkerType as $l,useInternalNode as Kl,useReactFlow as Ng,useViewport as vg,useEdges as wg,Position as ho}from"@xyflow/react";import{useCallback as rg,useEffect as Di,useRef as Vl,useState as ig}from"react";import{jsx as Gl}from"react/jsx-runtime";var Oi=/[a-zA-Z0-9À-ÖØ-öø-ÿ]/,Hl=["Backspace","Delete","ArrowLeft","ArrowRight","ArrowUp","ArrowDown","Home","End","Tab","Escape","Shift"],Ce=({value:e,maxLength:t,style:o,className:n,contentClassName:r,isEditing:i,onChange:a,onBlur:s,onInput:l,onInvalidFirstCharacter:c,skipFirstCharValidation:d})=>{let u=Vl(null),f=Vl(null),[p,g]=ig(!1);Di(()=>()=>{f.current&&clearTimeout(f.current)},[]),Di(()=>{g(i!=null?i:!1)},[i]),Di(()=>{if(p&&u.current){u.current.focus();let _=document.createRange();_.selectNodeContents(u.current);let x=window.getSelection();x&&(x.removeAllRanges(),x.addRange(_))}},[p]);let y=rg(()=>{f.current||(c==null||c(),f.current=setTimeout(()=>{f.current=null},500))},[c]),m=_=>{_.stopPropagation(),p||g(!0)},b=_=>{let x=_.currentTarget.innerText.replace(/\n$/,""),N=t&&x.length>=t,I=window.getSelection(),A=(I==null?void 0:I.toString())||"",M=A.length>0,S=(_.ctrlKey||_.metaKey)&&!_.altKey,k=S&&_.key==="a",B=S&&_.key==="c",q=S&&_.key==="x",j=S&&_.key==="v",C=x.length===0||M&&A.length===x.length;if(!d&&C&&!Oi.test(_.key)&&!Hl.includes(_.key)&&!S){_.preventDefault(),y();return}N&&!M&&(Hl.includes(_.key)||k||B||q||j||_.preventDefault())},h=_=>{_.preventDefault();let x=_.clipboardData.getData("text/plain").replace(/\r\n/g,`
2
2
  `).replace(/\r/g,`
3
- `),N=b.currentTarget.innerText.replace(/\n$/,""),I=window.getSelection();if(!I||I.rangeCount===0)return;let A=I.toString(),M=N.length-A.length,S=t?Math.max(0,t-M):1/0;if(S<=0&&A.length===0)return;let k=x;if(k.length>S&&(k=k.substring(0,S)),!k&&A.length===0)return;let B=I.getRangeAt(0),q=B.startOffset===0&&(B.startContainer===b.currentTarget||B.startContainer.parentNode===b.currentTarget);if(!d&&q&&k.length>0&&!Ri.test(k[0])){y();return}B.deleteContents();let j=document.createTextNode(k);B.insertNode(j),B.setStartAfter(j),B.collapse(!0),I.removeAllRanges(),I.addRange(B),l==null||l(b.currentTarget.innerText.replace(/\n$/,""))},E=b=>{let x=b.currentTarget,N=x.innerText.replace(/\n$/,"");if(!d&&N.length>0&&!Ri.test(N[0])){let I=N.slice(1);if(x.innerText=I,I.length>0&&x.firstChild){let A=document.createRange(),M=window.getSelection();A.setStart(x.firstChild,0),A.collapse(!0),M==null||M.removeAllRanges(),M==null||M.addRange(A)}y(),l==null||l(I);return}l==null||l(N)},w=b=>{g(!1);let x=b.currentTarget.innerText.replace(/\r\n/g,`
3
+ `),N=_.currentTarget.innerText.replace(/\n$/,""),I=window.getSelection();if(!I||I.rangeCount===0)return;let A=I.toString(),M=N.length-A.length,S=t?Math.max(0,t-M):1/0;if(S<=0&&A.length===0)return;let k=x;if(k.length>S&&(k=k.substring(0,S)),!k&&A.length===0)return;let B=I.getRangeAt(0),q=B.startOffset===0&&(B.startContainer===_.currentTarget||B.startContainer.parentNode===_.currentTarget);if(!d&&q&&k.length>0&&!Oi.test(k[0])){y();return}B.deleteContents();let j=document.createTextNode(k);B.insertNode(j),B.setStartAfter(j),B.collapse(!0),I.removeAllRanges(),I.addRange(B),l==null||l(_.currentTarget.innerText.replace(/\n$/,""))},E=_=>{let x=_.currentTarget,N=x.innerText.replace(/\n$/,"");if(!d&&N.length>0&&!Oi.test(N[0])){let I=N.slice(1);if(x.innerText=I,I.length>0&&x.firstChild){let A=document.createRange(),M=window.getSelection();A.setStart(x.firstChild,0),A.collapse(!0),M==null||M.removeAllRanges(),M==null||M.addRange(A)}y(),l==null||l(I);return}l==null||l(N)},w=_=>{g(!1);let x=_.currentTarget.innerText.replace(/\r\n/g,`
4
4
  `).replace(/\r/g,`
5
- `).trim();t&&x.length>t&&(x=x.substring(0,t)),b.currentTarget.innerText=x,s==null||s(),x!==e&&(a==null||a(x))};return Gl("div",{className:D("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":p,"bg-white":e.length>0},n),style:o,onDoubleClick:m,children:Gl("div",{ref:u,className:D("outline-none whitespace-pre-wrap overflow-hidden",r,{"nodrag nopan cursor-text":p}),contentEditable:p,suppressContentEditableWarning:!0,onKeyDown:_,onPaste:h,onInput:E,onBlur:w,children:e})})};import{Position as L2}from"@xyflow/react";var ae=(e,t,o,n=1)=>Math.abs(e[o]-t[o])<n,Er=(e,t)=>Math.sqrt((t.x-e.x)**2+(t.y-e.y)**2),br=(e,t)=>({x:(e.x+t.x)/2,y:(e.y+t.y)/2});import{Position as _r}from"@xyflow/react";var At={OFFSET:30,TOLERANCE:1,MOVE_THRESHOLD:5,MIN_SEGMENT_LENGTH:15,PARALLEL_OFFSET:15};var{TOLERANCE:ne}=At;function sg(e,t,o){return ae(e,t,"x",ne)&&ae(t,o,"x",ne)&&ae(e,o,"x",ne)}function ag(e,t,o){return ae(e,t,"y",ne)&&ae(t,o,"y",ne)&&ae(e,o,"y",ne)}function lg(e,t,o){if(!sg(e,t,o))return!1;let n=t.y-e.y,r=o.y-t.y;return Math.abs(n)<ne||Math.abs(r)<ne?!1:n*r<0}function cg(e,t,o){if(!ag(e,t,o))return!1;let n=t.x-e.x,r=o.x-t.x;return Math.abs(n)<ne||Math.abs(r)<ne?!1:n*r<0}function dg(e,t,o,n){let r=t.x!==0,i=t.x===-n.x&&t.y===-n.y,a=t.x===n.x&&t.y===n.y,s=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)<s?Math.max(e.y,o.y)+s: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)<s?Math.max(e.x,o.x)+s:l;return[{x:c,y:e.y},{x:c,y:o.y}]}}else if(a)if(r)if((o.x-e.x)*t.x>0&&Math.abs(e.y-o.y)<s){let l=Math.max(e.y,o.y)+s,c=o.x+t.x*(s/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)<s){let l=Math.max(e.x,o.x)+s,c=o.y+t.y*(s/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 Bl(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];ae(n,r,"x",ne)&&ae(r,i,"x",ne)||ae(n,r,"y",ne)&&ae(r,i,"y",ne)||t.push(r)}return t.push(e[e.length-1]),t}function Tr(e){let t=[];for(let o of e){let n=t[t.length-1];(!n||Math.abs(n.x-o.x)>=ne||Math.abs(n.y-o.y)>=ne)&&t.push(o)}return t}function ug(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],a=t[n+1];if(lg(r,i,a)||cg(r,i,a)){t.splice(n,1),o=!0;break}}}return t}function zl(e){let t=Tr(Bl([...e]));return t=ug(t),Tr(Bl(t))}function Nr(e){switch(e){case _r.Left:return{x:-1,y:0};case _r.Right:return{x:1,y:0};case _r.Top:return{x:0,y:-1};case _r.Bottom:return{x:0,y:1};default:return{x:0,y:0}}}function Yl(e,t,o,n){let r=At.OFFSET,i=At.OFFSET;if(t.x===-n.x&&t.y===-n.y)if(t.x!==0){let a=(o.x-e.x)*t.x;a>0&&a<2*At.OFFSET&&(r=a/2,i=a/2)}else{let a=(o.y-e.y)*t.y;a>0&&a<2*At.OFFSET&&(r=a/2,i=a/2)}return{sourceOffset:r,targetOffset:i}}function pg(e,t,o,n,r,i,a=0){let s=Nr(r),l=Nr(i),c=s.x===0?a:0,d=s.y===0?a:0,u=l.x===0?a:0,f=l.y===0?a:0,p={x:e+c,y:t+d},g={x:o+u,y:n+f},{sourceOffset:y,targetOffset:m}=Yl(p,s,g,l),_={x:p.x+s.x*y,y:p.y+s.y*y},h={x:g.x+l.x*m,y:g.y+l.y*m},E=dg(_,s,h,l),w=[p,_,...E,h,g],b=zl(w);if(b.length===2&&vr(p,g)>ne){let x=ae(p,_,"x",ne)&&ae(_,h,"x",ne)&&ae(h,g,"x",ne),N=ae(p,_,"y",ne)&&ae(_,h,"y",ne)&&ae(h,g,"y",ne);if(x||N){let I=N&&(h.x-_.x)*s.x<0,A=x&&(h.y-_.y)*s.y<0;if(!I&&!A)return Tr([p,_,h,g])}}return b}function wr(e,t,o,n,r,i,a,s=0){if(!(a!=null&&a.length))return pg(e,t,o,n,r,i,s);let l=Nr(r),c=Nr(i),d=l.x===0?s:0,u=l.y===0?s:0,f=c.x===0?s:0,p=c.y===0?s:0,g={x:e+d,y:t+u},y={x:o+f,y:n+p},{sourceOffset:m,targetOffset:_}=Yl(g,l,y,c),h={x:g.x+l.x*m,y:g.y+l.y*m},E={x:y.x+c.x*_,y:y.y+c.y*_},w=[...a],b=w[0],x=l.y===0;x&&Math.abs(g.y-b.y)>ne?w.unshift({x:b.x,y:g.y}):!x&&Math.abs(g.x-b.x)>ne&&w.unshift({x:g.x,y:b.y});let N=w[w.length-1],I=c.y===0,A=[];(Math.abs(N.x-E.x)>ne||Math.abs(N.y-E.y)>ne)&&(I?A.push({x:E.x,y:N.y}):A.push({x:N.x,y:E.y})),A.push(E);let M=[g,...w,...A,y],S=zl(M);if(S.length===2&&vr(g,y)>ne){let k=ae(g,h,"x",ne)&&ae(h,E,"x",ne)&&ae(E,y,"x",ne),B=ae(g,h,"y",ne)&&ae(h,E,"y",ne)&&ae(E,y,"y",ne);if(k||B){let q=B&&(E.x-h.x)*l.x<0,j=k&&(E.y-h.y)*l.y<0;if(!q&&!j)return Tr([g,h,E,y])}}return S}var vr=(e,t)=>Math.sqrt(Math.pow(t.x-e.x,2)+Math.pow(t.y-e.y,2));function fg(e,t,o){return ae(e,t,"x",ne)&&ae(t,o,"x",ne)||ae(e,t,"y",ne)&&ae(t,o,"y",ne)}function mg(e,t,o,n){if(fg(e,t,o))return`L${t.x} ${t.y}`;let r=vr(e,t),i=vr(t,o),a=Math.min(r/2,i/2,n);if(a<1)return`L${t.x} ${t.y}`;let s=e.x-t.x,l=e.y-t.y,c=o.x-t.x,d=o.y-t.y,u={x:s/r,y:l/r},f={x:c/i,y:d/i},p={x:t.x+u.x*a,y:t.y+u.y*a},g={x:t.x+f.x*a,y:t.y+f.y*a},y=-u.x,m=-u.y,_=f.x,h=f.y,w=y*h-m*_>0?1:0;return`L${p.x} ${p.y}A${a} ${a} 0 0 ${w} ${g.x} ${g.y}`}var Fl=(e,t=5)=>e.length<2?"":e.reduce((o,n,r)=>{let i="";return r>0&&r<e.length-1?i=mg(e[r-1],n,e[r+1],t):i=`${r===0?"M":"L"}${n.x} ${n.y}`,o+=i,o},"");import{useCallback as mo,useEffect as Ar,useRef as on,useState as go}from"react";import{useReactFlow as gg,useStore as hg}from"@xyflow/react";var yg=50,Wl=.1,xg=.6,Ir=({edgeId:e,source:t,target:o,instanceId:n,isReadOnly:r})=>{let{setEdges:i,getNode:a,getNodes:s,getEdge:l,screenToFlowPosition:c}=gg(),{setIsDragging:d,setReconnectingEdgeId:u}=Q(),f=hg(R=>R.isValidConnection),[p,g]=go(null),[y,m]=go(null),[_,h]=go(null),[E,w]=go(null),[b,x]=go(null),[N,I]=go(!1),A=on(null),M=on(null),S=on(null),k=on(t),B=on(o);Ar(()=>{k.current=t,B.current=o},[t,o]),Ar(()=>{A.current=p},[p]),Ar(()=>{M.current=b},[b]);let q=mo(R=>{let G=s(),K=G.find(Y=>Y.id===R);if(!K)return{x:0,y:0};let L=K.position.x,H=K.position.y,F=K.parentId;for(;F;){let Y=G.find(O=>O.id===F);if(!Y)break;L+=Y.position.x,H+=Y.position.y,F=Y.parentId}return{x:L,y:H}},[s]),j=mo(R=>{var F,Y,O,J,U,X;let G=s(),K=null,L=yg,H=G.filter(z=>z.type!=="LANE"&&z.type!=="ANNOTATION");for(let z of H){if(z.id===e)continue;let W=q(z.id),Z=(O=(Y=(F=z.measured)==null?void 0:F.width)!=null?Y:z.width)!=null?O:0,ee=(X=(U=(J=z.measured)==null?void 0:J.height)!=null?U:z.height)!=null?X:0;if(R.x>=W.x&&R.x<=W.x+Z&&R.y>=W.y&&R.y<=W.y+ee)return z.id;let ce=Math.max(W.x-R.x,0,R.x-(W.x+Z)),de=Math.max(W.y-R.y,0,R.y-(W.y+ee)),ue=Math.sqrt(ce*ce+de*de);ue<L&&(L=ue,K=z.id)}return K},[s,q,e]),C=mo((R,G)=>{var ce,de,ue,ge,he,fe;let K=a(R);if(!K)return null;let L=q(R),H=(ue=(de=(ce=K.measured)==null?void 0:ce.width)!=null?de:K.width)!=null?ue:0,F=(fe=(he=(ge=K.measured)==null?void 0:ge.height)!=null?he:K.height)!=null?fe:0,Y=Math.abs(L.x+H-G.x),O=Math.abs(G.x-L.x),J=Math.abs(L.y+F-G.y),U=Math.abs(G.y-L.y),X={right:Y,left:O,bottom:J,top:U},z=Object.entries(X).reduce((se,[ie,ve])=>ve<se[1]?[ie,ve]:se,["right",X.right])[0],W=S.current;if(W&&W!==z){let se=X[z],ie=X[W],ve=Math.abs(ie-se),ke=Math.min(Math.abs(ie),Math.abs(se));ve<ke*xg&&(z=W)}let Z=z,ee,le;if(Z==="right"||Z==="left"){let ie=(Math.max(L.y,Math.min(L.y+F,G.y))-L.y)/(F||1);Math.abs(ie-.5)<Wl&&(ie=.5),le=ie,ee={x:Z==="right"?L.x+H:L.x,y:L.y+le*F}}else{let ie=(Math.max(L.x,Math.min(L.x+H,G.x))-L.x)/(H||1);Math.abs(ie-.5)<Wl&&(ie=.5),le=ie,ee={x:L.x+le*H,y:Z==="bottom"?L.y+F:L.y}}return{side:Z,snapPosition:ee,offset:le}},[a,q]),P=mo(R=>{var O,J,U;let G=A.current;if(!G)return;let K=c({x:R.clientX,y:R.clientY}),L=j(K);h(L);let H=K,F=null,Y=null;if(L){let X=C(L,K);X&&(F=X.side,H=X.snapPosition,Y=X.offset,S.current=F);let z=l(e),W={source:G==="source"?L:k.current,target:G==="target"?L:B.current,sourceHandle:G==="source"?F:(O=z==null?void 0:z.sourceHandle)!=null?O:null,targetHandle:G==="target"?F:(J=z==null?void 0:z.targetHandle)!=null?J:null},Z=(U=f==null?void 0:f(W))!=null?U:!0;I(Z)}else S.current=null,I(!1);w(F),x(Y),m(H)},[j,C,l,e,c,f]),$=mo(R=>{var F,Y,O,J,U;let G=A.current;if(!G)return;let K=c({x:R.clientX,y:R.clientY}),L=j(K);if(L){let X=C(L,K),z=(F=X==null?void 0:X.side)!=null?F:null,W=(Y=X==null?void 0:X.offset)!=null?Y:.5,Z=l(e),ee={source:G==="source"?L:k.current,target:G==="target"?L:B.current,sourceHandle:G==="source"?z:(O=Z==null?void 0:Z.sourceHandle)!=null?O:null,targetHandle:G==="target"?z:(J=Z==null?void 0:Z.targetHandle)!=null?J:null};((U=f==null?void 0:f(ee))==null||U)&&i(le=>le.map(ce=>{var de,ue;return ce.id===e?v(T({},ce),{source:ee.source,target:ee.target,sourceHandle:ee.sourceHandle,targetHandle:ee.targetHandle,data:v(T({},ce.data),{points:void 0,sourceOffset:G==="source"?W:(de=ce.data)==null?void 0:de.sourceOffset,targetOffset:G==="target"?W:(ue=ce.data)==null?void 0:ue.targetOffset})}):ce}))}g(null),m(null),h(null),w(null),x(null),d(!1),I(!1),u(null),S.current=null,document.removeEventListener("mouseup",$),document.removeEventListener("mousemove",P);let H=it.get(n);H==null||H.clearReconnectingEdge()},[e,j,C,l,i,n,P,f,c,d,u]),V=mo((R,G)=>{if(r||G.button!==0)return;G.stopPropagation(),G.preventDefault(),i(L=>L.map(H=>H.id===e?v(T({},H),{data:v(T({},H.data),{points:void 0})}):H)),g(R),u(e);let K=it.get(n);K==null||K.setReconnectingEdge(e),document.addEventListener("mousemove",P),document.addEventListener("mouseup",$)},[r,e,n,P,$,u,i]);return Ar(()=>()=>{if(A.current){document.removeEventListener("mousemove",P),document.removeEventListener("mouseup",$),u(null);let R=it.get(n);R==null||R.clearReconnectingEdge()}},[n,P,$,u]),{reconnectingHandle:p,cursorPosition:y,hoveredNodeId:_,reconnectingSide:E,reconnectingOffset:b,isValidReconnection:N,handleReconnectStart:V}};import{Fragment as Zl,jsx as Ae,jsxs as pt}from"react/jsx-runtime";var Fe={type:"SEQUENCE_EDGE",reconnectable:!0,markerStart:{type:$l.ArrowClosed},markerEnd:{type:$l.Arrow},data:{label:""}},{MOVE_THRESHOLD:Cr,MIN_SEGMENT_LENGTH:Ag,PARALLEL_OFFSET:ql}=At;function Ig(e,t,o,n){let r=n.filter(s=>s.source===t&&s.target===o||s.source===o&&s.target===t);if(r.length<=1){let s=n.filter(d=>d.source===t);if(s.length<=1)return 0;let l=s.findIndex(d=>d.id===e);if(l<=0)return 0;let c=(s.length-1)/2;return(l-c)*ql}let i=r.findIndex(s=>s.id===e),a=(r.length-1)/2;return(i-a)*ql}var Jl=({id:e,source:t,target:o,data:n,selected:r,sourcePosition:i,targetPosition:a,sourceHandleId:s,targetHandleId:l})=>{var F,Y;let{zoom:c}=vg(),{updateEdgeData:d}=Ng(),u=wg(),{isMultipleSelection:f,mode:p,instanceId:g}=Q(),[y,m]=Xl(!1),[_,h]=Xl(null),E=Ul(null),w=Ul(null),b=p!=="edit",{reconnectingHandle:x,cursorPosition:N,hoveredNodeId:I,reconnectingSide:A,isValidReconnection:M,handleReconnectStart:S}=Ir({edgeId:e,source:t,target:o,instanceId:g,isReadOnly:b}),k=Kl(t),B=Kl(o),{sx:q,sy:j,tx:C,ty:P,sourcePos:$,targetPos:V}=Di(()=>{var de,ue;let O=k&&B?no(k,B):{sx:0,sy:0,tx:0,ty:0,sourcePos:ho.Right,targetPos:ho.Left},J=s?i:O.sourcePos,U=l?a:O.targetPos,X=(ge,he,fe)=>{var yt,Jt,Qt,Ee,Ie,et;let{x:se,y:ie}=ge.internals.positionAbsolute,ve=(Qt=(Jt=(yt=ge.measured)==null?void 0:yt.width)!=null?Jt:ge.width)!=null?Qt:0,ke=(et=(Ie=(Ee=ge.measured)==null?void 0:Ee.height)!=null?Ie:ge.height)!=null?et:0;switch(he){case ho.Top:return{x:se+ve*fe,y:ie};case ho.Bottom:return{x:se+ve*fe,y:ie+ke};case ho.Left:return{x:se,y:ie+ke*fe};case ho.Right:return{x:se+ve,y:ie+ke*fe};default:return{x:se+ve/2,y:ie+ke/2}}},z=(de=n==null?void 0:n.sourceOffset)!=null?de:.5,W=(ue=n==null?void 0:n.targetOffset)!=null?ue:.5,Z=k?X(k,J,z).x:O.sx,ee=k?X(k,J,z).y:O.sy,le=B?X(B,U,W).x:O.tx,ce=B?X(B,U,W).y:O.ty;return x==="source"&&N?(Z=N.x,ee=N.y,A&&(J=A)):x==="target"&&N&&(le=N.x,ce=N.y,A&&(U=A)),{sx:Z,sy:ee,tx:le,ty:ce,sourcePos:J,targetPos:U}},[k,B,s,l,i,a,x,N,A,n==null?void 0:n.sourceOffset,n==null?void 0:n.targetOffset]);bg(()=>{var U;if(!w.current){w.current={sx:q,sy:j,tx:C,ty:P,sourcePos:$,targetPos:V};return}let O=w.current;(Math.abs(q-O.sx)>Cr||Math.abs(j-O.sy)>Cr||Math.abs(C-O.tx)>Cr||Math.abs(P-O.ty)>Cr||O.sourcePos!==$||O.targetPos!==V)&&((U=n==null?void 0:n.points)!=null&&U.length)&&d(e,v(T({},n),{points:void 0})),w.current={sx:q,sy:j,tx:C,ty:P,sourcePos:$,targetPos:V}},[q,j,C,P,$,V,n,e,d,x]);let R=Di(()=>{let O=Ig(e,t,o,u);return wr(q,j,C,P,$,V,n==null?void 0:n.points,O)},[q,j,C,P,$,V,n==null?void 0:n.points,u,e,t,o]),G=Di(()=>{if(R.length<2)return br({x:q,y:j},{x:C,y:P});let O=0;for(let X=0;X<R.length-1;X++)O+=Er(R[X],R[X+1]);let J=O/2,U=0;for(let X=0;X<R.length-1;X++){let z=Er(R[X],R[X+1]);if(U+z>=J){let W=(J-U)/z,Z=R[X],ee=R[X+1];return{x:Z.x+(ee.x-Z.x)*W,y:Z.y+(ee.y-Z.y)*W}}U+=z}return br({x:q,y:j},{x:C,y:P})},[R,q,j,C,P]),K=Eg((O,J)=>{if(p!=="edit"||J.button!==0)return;J.stopPropagation(),J.preventDefault();let U=R[O],X=R[O+1],z=ae(U,X,"y"),W=z?U.y:U.x,Z=[...R],ee=Z.length,le=O,ce=O+1;h(O);let de=ge=>{let he=W+(z?ge.clientY-J.clientY:ge.clientX-J.clientX)/c;E.current=z?{x:(U.x+X.x)/2,y:he}:{x:he,y:(U.y+X.y)/2};let fe=[];for(let se=1;se<ee-1;se++){let ie=Z[se];se===le||se===ce?z?fe.push({x:ie.x,y:he}):fe.push({x:he,y:ie.y}):fe.push(T({},ie))}d(e,v(T({},n),{points:fe}))},ue=()=>{h(null),E.current=null,document.removeEventListener("mousemove",de),document.removeEventListener("mouseup",ue)};document.addEventListener("mousemove",de),document.addEventListener("mouseup",ue)},[p,R,c,n,e,d]);if(!k||!B)return null;let L=Fl(R),H=r||k.selected||B.selected;return pt(Zl,{children:[pt("g",{onDoubleClick:()=>m(!0),children:[Ae("path",{d:L,fill:"none",stroke:"transparent",strokeWidth:Math.max(12,12/c),style:{pointerEvents:"stroke",cursor:"pointer"}}),pt("g",{className:D("text-grey-500 hover:text-grey-600",{"text-blue-500 hover:text-blue-600":H}),children:[Ae(_g,{id:e,path:L,interactionWidth:0,markerEnd:`url(#${H?"sequence-edge-marker-highlighted":"sequence-edge-marker"})`,className:D("stroke-2 stroke-current transition-colors duration-75",{"stroke-red-500 hover:stroke-red-600":(n==null?void 0:n.hasError)||x&&I&&!M,"stroke-green-500":x&&I&&M,"stroke-blue-500 hover:stroke-blue-600 drop-shadow-[0_0_3px_rgba(59,130,246,0.5)]":H&&!(n!=null&&n.hasError)&&!x})}),r&&!f&&!b&&Ae("g",{children:R.slice(0,-1).map((O,J)=>{let U=R[J+1];if(J===0||J===R.length-2||Er(O,U)<Ag)return null;let X=ae(O,U,"y"),z=_===J,W=z&&E.current?E.current:br(O,U);return pt("g",{children:[Ae("line",{x1:O.x,y1:O.y,x2:U.x,y2:U.y,stroke:"transparent",strokeWidth:20/c,className:D("cursor-pointer",{"cursor-ns-resize":X,"cursor-ew-resize":!X}),onMouseDown:Z=>K(J,Z)}),Ae("circle",{cx:W.x,cy:W.y,r:4/c,fill:z?"#3b82f6":"#fff",stroke:"#3b82f6",strokeWidth:2/c,className:"pointer-events-none"}),Ae("circle",{cx:W.x,cy:W.y,r:6/c,fill:"none",stroke:"#3b82f6",strokeWidth:1/c,opacity:z?.6:.3,className:"pointer-events-none"})]},J)})})]})]}),pt(Tg,{children:[pt("div",{className:"absolute z-[3000] pointer-events-none flex flex-col items-center gap-1",style:{transform:`translate(-50%, -50%) translate(${G.x}px, ${G.y}px)`},children:[r&&!f&&Ae(uo,{sx:q,sy:j,tx:C,ty:P,hasLabel:!!((F=n==null?void 0:n.label)!=null&&F.trim()),children:Ae(co,{edgeId:e,edgeType:"SEQUENCE_EDGE",sourceNode:k,targetNode:B})}),(y||((Y=n==null?void 0:n.label)==null?void 0:Y.trim()))&&Ae(Ce,{value:n==null?void 0:n.label,className:D("min-w-8 max-w-56 px-2 py-1 body-small-400",{"pointer-events-auto":y,"pointer-events-none":!y}),isEditing:y,onBlur:()=>m(!1),onChange:O=>d(e,{label:O.trim()})})]}),r&&!f&&!b&&pt(Zl,{children:[Ae("div",{className:"absolute z-[10000] pointer-events-none",style:{transform:`translate(-50%, -50%) translate(${R[0].x}px, ${R[0].y}px)`},children:pt("svg",{width:12/c,height:12/c,style:{overflow:"visible",position:"absolute",left:"50%",top:"50%",transform:"translate(-50%, -50%)"},children:[Ae("circle",{cx:6/c,cy:6/c,r:4/c,fill:x==="source"?"#3b82f6":"#fff",stroke:"#3b82f6",strokeWidth:2/c,className:"pointer-events-none"}),Ae("circle",{cx:6/c,cy:6/c,r:6/c,fill:"none",stroke:"#3b82f6",strokeWidth:1/c,opacity:x==="source"?.6:.3,className:"pointer-events-none"}),Ae("circle",{cx:6/c,cy:6/c,r:8/c,fill:"transparent",className:D("pointer-events-auto",{"cursor-move":!x||x!=="source","cursor-not-allowed":x==="source"&&I&&!M,"cursor-grabbing":x==="source"&&(!I||M)}),onMouseDown:O=>S("source",O.nativeEvent)})]})}),Ae("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:pt("svg",{width:12/c,height:12/c,style:{overflow:"visible",position:"absolute",left:"50%",top:"50%",transform:"translate(-50%, -50%)"},children:[Ae("circle",{cx:6/c,cy:6/c,r:4/c,fill:x==="target"?"#3b82f6":"#fff",stroke:"#3b82f6",strokeWidth:2/c,className:"pointer-events-none"}),Ae("circle",{cx:6/c,cy:6/c,r:6/c,fill:"none",stroke:"#3b82f6",strokeWidth:1/c,opacity:x==="target"?.6:.3,className:"pointer-events-none"}),Ae("circle",{cx:6/c,cy:6/c,r:8/c,fill:"transparent",className:D("pointer-events-auto",{"cursor-move":!x||x!=="target","cursor-not-allowed":x==="target"&&I&&!M,"cursor-grabbing":x==="target"&&(!I||M)}),onMouseDown:O=>S("target",O.nativeEvent)})]})})]})]})]})};import{Position as ft}from"@xyflow/react";var Cg={right:ft.Right,left:ft.Left,top:ft.Top,bottom:ft.Bottom},Sr=e=>{var t;return(t=Cg[e!=null?e:""])!=null?t:ft.Right},Oi=(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,a=(u=(d=e.measured)==null?void 0:d.height)!=null?u:0;switch(Sr(t)){case ft.Right:return{x:n+i,y:r+a*o};case ft.Left:return{x:n,y:r+a*o};case ft.Top:return{x:n+i*o,y:r};case ft.Bottom:return{x:n+i*o,y:r+a};default:return{x:n+i/2,y:r+a/2}}},Ql=(e,t,o)=>{var d,u;let{position:{x:n,y:r},measured:i}=e,a=(d=i.width)!=null?d:0,s=(u=i.height)!=null?u:0;return[{id:"left",x:n,y:r+s/2},{id:"right",x:n+a,y:r+s/2},{id:"top",x:n+a/2,y:r},{id:"bottom",x:n+a/2,y:r+s}].reduce((f,p)=>{let g=Math.hypot(t-f.x,o-f.y);return Math.hypot(t-p.x,o-p.y)<g?p:f}).id};import{useDebouncedCallback as by}from"use-debounce";import{getViewportForBounds as yy,useReactFlow as xy,useStoreApi as Ey}from"@xyflow/react";import{useCallback as pd}from"react";var nn=(d=>(d.START_EVENT="start-event",d.END_EVENT_TERMINATE="end-event-terminate",d.TASK="task",d.TASK_SCRIPT="task-script",d.SUBPROCESS="subprocess-collapsed",d.GATEWAY_EXCLUSIVE="gateway-exclusive",d.GATEWAY_PARALLEL="gateway-parallel",d.GATEWAY_COMPLEX="gateway-complex",d.ANNOTATION="annotation",d.LANE="lane",d))(nn||{});import{xml2json as Sg,json2xml as Mg}from"xml-js";var jl={compact:!0,spaces:4},Pg=e=>e.replace(/\n/g,"&#xA;");function Mr(e,t=jl){if(e)return JSON.parse(Sg(e,t))}function ec(e,t=jl){return e?Mg(e,v(T({},t),{attributeValueFn:Pg})):""}var Lg={MIN_WIDTH:36,MIN_HEIGHT:36},kg={MIN_WIDTH:36,MIN_HEIGHT:36},Rg={MIN_WIDTH:56,MIN_HEIGHT:56},yo={MIN_WIDTH:176,MIN_HEIGHT:96},Pr={HEADER_WIDTH:40,MIN_WIDTH:840,MIN_HEIGHT:256},ye={HEADER_WIDTH:40,MIN_WIDTH:800,MIN_HEIGHT:256},xo={MIN_WIDTH:176,MIN_HEIGHT:64},Dg={MIN_WIDTH:128,MIN_HEIGHT:64},re={START_EVENT:Lg,END_EVENT:kg,GATEWAY:Rg,TASK:yo,LANE:ye,ANNOTATION:xo,UNSUPPORTED:Dg};var tc={"attribute-loop":"LOOP"},oc={"task-script":"SCRIPT","subprocess-collapsed":"SUBPROCESS"},nc={"gateway-exclusive":"EXCLUSIVE","gateway-parallel":"PARALLEL","gateway-complex":"COMPLEX"},rc={SCRIPT:"task-script",SUBPROCESS:"subprocess-collapsed"},ic={EXCLUSIVE:"gateway-exclusive",PARALLEL:"gateway-parallel",COMPLEX:"gateway-complex"};var Eo=(e,t,o,n,r,i)=>{let a=e._attributes.width||0,s=e._attributes.height||0,l=0,c=0;if(n&&r!==void 0&&i!==void 0){let g=n.split(`
6
- `),y=g.length;l=g.reduce((_,h)=>Math.max(_,h.length),0)*7+r,c=y*20+i}let d=Math.max(xt(Number(a),t),l),u=Math.max(xt(Number(s),o),c);return{width:d,height:u,measured:{width:d,height:u}}},bo=e=>{let{_attributes:t,mxGeometry:o}=e,{id:n,parent:r,value:i}=t,a={x:Number(o._attributes.x||0),y:Number(o._attributes.y||0)},s={id:n,position:a,data:{label:i||""}},l=r==="1"?void 0:r;return l&&(s.parentId=l),s},Vg=e=>{let{mxGeometry:t}=e,o=bo(e),n=Eo(t,re.START_EVENT.MIN_WIDTH,re.START_EVENT.MIN_HEIGHT);return v(T(T({},o),n),{type:"START_EVENT"})},Hg=e=>{let{mxGeometry:t}=e,o=bo(e),n=Eo(t,re.END_EVENT.MIN_WIDTH,re.END_EVENT.MIN_HEIGHT);return v(T(T({},o),n),{type:"END_EVENT"})},Vi=(e,t)=>{let{_attributes:o,mxGeometry:n}=e,r=bo(e),s=Eo(n,re.TASK.MIN_WIDTH,re.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=tc[d];u&&(r.data.attribute=u)}let c=oc[o.style];return c&&(r.data.variant=c),v(T(T({},r),s),{type:"TASK"})},Hi=e=>{let{_attributes:t,mxGeometry:o}=e,{style:n}=t,r=bo(e),i=Eo(o,re.GATEWAY.MIN_WIDTH,re.GATEWAY.MIN_HEIGHT);return r.data.variant=nc[n],v(T(T({},r),i),{type:"GATEWAY"})},Gg=e=>{let{mxGeometry:t}=e,o=bo(e),i=Eo(t,re.ANNOTATION.MIN_WIDTH,re.ANNOTATION.MIN_HEIGHT,o.data.label,32,24);return v(T(T({},o),i),{type:"ANNOTATION"})},Bg=e=>{let{mxGeometry:t}=e,o=bo(e),n=Eo(t,re.LANE.MIN_WIDTH,re.LANE.MIN_HEIGHT);return v(T(T({},o),n),{type:"LANE"})},sc={task:Vi,"task-script":Vi,"subprocess-collapsed":Vi,"start-event":Vg,"end-event-terminate":Hg,"gateway-parallel":Hi,"gateway-exclusive":Hi,"gateway-complex":Hi,annotation:Gg,lane:Bg},zg=e=>{if(e&&Array.isArray(e))return e.map(t=>({x:Number(t._attributes.x),y:Number(t._attributes.y)}))},ac=e=>{let{_attributes:t,mxGeometry:o}=e,{id:n,source:r,target:i,value:a,style:s,sourceHandle:l,targetHandle:c,sourceOffset:d,targetOffset:u}=t,f=zg(o==null?void 0:o.Array),p=d!==void 0?Number(d):void 0,g=u!==void 0?Number(u):void 0,y=v(T(T({id:n,source:r,target:i},l?{sourceHandle:l}:{}),c?{targetHandle:c}:{}),{data:T(T(T({label:a||""},f&&f.length>0?{points:f}:{}),p!==void 0?{sourceOffset:p}:{}),g!==void 0?{targetOffset:g}:{})});return s.includes("association")&&s.includes('endArrow=""')?T(T({},fo),y):T(T({},Fe),y)},lc=(e,t)=>{let{id:o,type:n,source:r,target:i,sourceHandle:a,targetHandle:s,data:l}=e,c=t==null?void 0:t.find(p=>p.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(p=>({_attributes:{as:"mxPoint",x:p.x,y:p.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:a!=null?a:void 0,targetHandle:s!=null?s: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},mxGeometry:u}},_o=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}}}},Yg=e=>{let{variant:t}=e.data,o=_o(e);return v(T({},o),{_attributes:v(T({},o._attributes),{style:rc[t]||"task"})})},Fg=e=>{let t=_o(e);return v(T({},t),{_attributes:v(T({},t._attributes),{style:"start-event"})})},Wg=e=>{let t=_o(e);return v(T({},t),{_attributes:v(T({},t._attributes),{style:"end-event-terminate"})})},Xg=e=>{let{variant:t}=e.data,o=_o(e);return v(T({},o),{_attributes:v(T({},o._attributes),{style:ic[t]})})},Ug=e=>{let t=_o(e);return v(T({},t),{_attributes:v(T({},t._attributes),{style:"lane"})})},$g=e=>{let t=_o(e);return v(T({},t),{_attributes:v(T({},t._attributes),{style:"annotation"})})},cc={TASK:Yg,START_EVENT:Fg,END_EVENT:Wg,GATEWAY:Xg,ANNOTATION:$g,LANE:Ug},dc=(e,t)=>{var a,s;let r=((a=e.measured)==null?void 0:a.width)||0,i=((s=e.measured)==null?void 0:s.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}}}};import gc from"@dagrejs/dagre";import{orderBy as Jg}from"lodash";import{orderBy as Kg}from"lodash";var mt=e=>{var t,o,n,r,i,a,s,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:(a=(i=e.measured)==null?void 0:i.width)!=null?a:0,h:(l=(s=e.measured)==null?void 0:s.height)!=null?l:0}},Ft=e=>Kg(e,[o=>{let n=o.type==="LANE";return n&&!o.parentId?0:n?1:2}],["asc"]),uc=(e,t)=>{let{x:o,y:n}=mt(e),{x:r,y:i}=mt(t);return{x:o-r,y:n-i}};var To=({parentId:e,nodes:t,includeTypes:o=[...Object.values(oe)],excludeTypes:n=[]})=>t.some(r=>r.parentId===e&&(!o.length||o.includes(r.type))&&!n.includes(r.type)),qg=(e,t)=>{let{x:o,y:n}=mt(e),{x:r,y:i}=mt(t),a=o-r,s=n-i;return Math.sqrt(a*a+s*s)},Zg=(e,t)=>{let{x:o,y:n,w:r,h:i}=mt(e),{x:a,y:s,w:l,h:c}=mt(t),d=o+r/2,u=n+i/2;return d>=a&&d<=a+l&&u>=s&&u<=s+c},rn=(e,t)=>{let o=null,n=1/0;for(let r of t)if(r.id!==e.id&&Zg(e,r)){let i=qg(e,r);i<n&&(n=i,o=r)}return o},pc=(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),fc=(e,t)=>{let o=e.filter(c=>!c.parentId);if(o.length===0)return{nodes:e,edges:t};let n=o.filter(c=>c.type==="LANE"),r=n.length>0?n:o,i=Math.min(...r.map(c=>c.position.x||0)),a=Math.min(...r.map(c=>c.position.y||0)),s=e.map(c=>c.parentId?c:v(T({},c),{position:{x:c.position.x-i,y:c.position.y-a}})),l=t.map(c=>{let d=c.data;return d!=null&&d.points?v(T({},c),{data:v(T({},d),{points:d.points.map(u=>({x:u.x-i,y:u.y-a}))})}):c});return{nodes:s,edges:l}},mc=e=>{var l,c;let t=e.filter(d=>!d.parentId),o=t.filter(d=>d.type==="LANE"),n=o.length>0?o:t;if(n.length===0)return null;let r=1/0,i=1/0,a=-1/0,s=-1/0;for(let d of n){let u=d.position.x+((l=d.width)!=null?l:0),f=d.position.y+((c=d.height)!=null?c:0);d.position.x<r&&(r=d.position.x),d.position.y<i&&(i=d.position.y),u>a&&(a=u),f>s&&(s=f)}return{x:r,y:i,width:a-r,height:s-i}};var hc=(e=[],t=[],o="LR")=>{let n=new gc.graphlib.Graph;return n.setDefaultEdgeLabel(()=>({})),n.setGraph({rankdir:o}),e.forEach(({id:i,width:a,height:s})=>n.setNode(i,{width:a,height:s})),t.forEach(i=>n.setEdge(i.source,i.target)),gc.layout(n),{nodes:e.map(i=>{let a=n.node(i.id);return v(T({},i),{position:{x:a.x-i.width/2,y:a.y-i.height/2}})}),edges:t}},sn=e=>{let t=e.filter(n=>n.type==="LANE"&&!n.parentId),o=[...e];return t.forEach(n=>{o=an(n.id,o)}),o},an=(e,t)=>{var m,_;let o=[...t],n=o.find(h=>h.id===e);if(!n)return o;let r=o.filter(h=>h.parentId===e&&h.type==="LANE");if(r.length===0)return o;let i=Jg(r,["position.y"]),a=Math.max((_=(m=n.measured)==null?void 0:m.width)!=null?_:0,Pr.MIN_WIDTH),s=pc(e,i)||ye.MIN_WIDTH,l=Math.max(a,s),c=a-ye.HEADER_WIDTH>=s,d=new Map(t.map(h=>[h.id,h])),u=0,f=i.map((h,E)=>{var N,I,A,M,S,k;let w=(I=(N=d.get(h.id))==null?void 0:N.position.y)!=null?I:0,b=E<i.length-1&&(M=(A=d.get(i[E+1].id))==null?void 0:A.position.y)!=null?M:1/0,x={id:h.id,originalLaneY:w,nextLaneOriginalY:b,targetY:u,deltaY:u-w};return u+=(k=(S=h.measured)==null?void 0:S.height)!=null?k:0,x}),p=u,g=c?l-ye.HEADER_WIDTH:l;o=o.map(h=>{var b,x;if(h.id===e){let N=c?l:l+ye.HEADER_WIDTH;return v(T({},h),{height:p,width:N,measured:v(T({},h.measured),{height:p,width:N})})}let w=f.find(N=>N.id===h.id);if(w)return v(T({},h),{width:g,measured:v(T({},h.measured),{width:g}),position:{x:ye.HEADER_WIDTH,y:w.targetY}});if(h.parentId===e&&h.type!=="LANE"){let N=(x=(b=d.get(h.id))==null?void 0:b.position.y)!=null?x:0,I=f.find(A=>N>=A.originalLaneY&&N<A.nextLaneOriginalY);if(I)return v(T({},h),{position:v(T({},h.position),{y:N+I.deltaY})})}return h});let y=o.find(h=>h.id===e);return y!=null&&y.parentId&&(o=an(y.parentId,o)),o},yc=(e,t,o)=>{if(e.type==="LANE")return o;let n=dt(t),r=dt(e);return r.y<n.y&&(e.position.y=0),r.x<n.x+ye.HEADER_WIDTH&&(e.position.x=ye.HEADER_WIDTH),r.y2>n.y2&&(t.height=r.y2-n.y,t.measured.height=r.y2-n.y),r.x2>n.x2&&(t.width=r.x2-n.x,t.measured.width=r.x2-n.x),o=o.map(i=>i.id===t.id?v(T({},i),{height:t.height,width:t.width,measured:t.measured}):i.id===e.id?v(T({},i),{position:e.position}):i),o},xc=()=>{let e=document.querySelector(".react-flow__viewport");return e||(console.error("Flow element (.react-flow__viewport) not found."),null)},Qg=e=>e.type==="LANE"&&!e.parentId,Gi=e=>{var i;let t=e.filter(Qg);if(t.length===0)return e;let o=new Map;for(let a of e){if(!a.parentId)continue;let s=(i=o.get(a.parentId))!=null?i:[];s.push(a.id),o.set(a.parentId,s)}let n=new Set,r=t.map(a=>a.id);for(;r.length>0;){let a=r.pop();if(!a||n.has(a))continue;n.add(a);let s=o.get(a);if(s)for(let l of s)n.has(l)||r.push(l)}return e.filter(a=>n.has(a.id))};var ln=1,Ec=e=>`<mxGraphModel>
5
+ `).trim();t&&x.length>t&&(x=x.substring(0,t)),_.currentTarget.innerText=x,s==null||s(),x!==e&&(a==null||a(x))};return Gl("div",{className:R("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":p,"bg-white":e.length>0},n),style:o,onDoubleClick:m,children:Gl("div",{ref:u,className:R("outline-none whitespace-pre-wrap overflow-hidden",r,{"nodrag nopan cursor-text":p}),contentEditable:p,suppressContentEditableWarning:!0,onKeyDown:b,onPaste:h,onInput:E,onBlur:w,children:e})})};import{Position as L2}from"@xyflow/react";var ae=(e,t,o,n=1)=>Math.abs(e[o]-t[o])<n,Er=(e,t)=>Math.sqrt((t.x-e.x)**2+(t.y-e.y)**2),br=(e,t)=>({x:(e.x+t.x)/2,y:(e.y+t.y)/2});import{Position as _r}from"@xyflow/react";var At={OFFSET:30,TOLERANCE:1,MOVE_THRESHOLD:5,MIN_SEGMENT_LENGTH:15,PARALLEL_OFFSET:15};var{TOLERANCE:ne}=At;function sg(e,t,o){return ae(e,t,"x",ne)&&ae(t,o,"x",ne)&&ae(e,o,"x",ne)}function ag(e,t,o){return ae(e,t,"y",ne)&&ae(t,o,"y",ne)&&ae(e,o,"y",ne)}function lg(e,t,o){if(!sg(e,t,o))return!1;let n=t.y-e.y,r=o.y-t.y;return Math.abs(n)<ne||Math.abs(r)<ne?!1:n*r<0}function cg(e,t,o){if(!ag(e,t,o))return!1;let n=t.x-e.x,r=o.x-t.x;return Math.abs(n)<ne||Math.abs(r)<ne?!1:n*r<0}function dg(e,t,o,n){let r=t.x!==0,i=t.x===-n.x&&t.y===-n.y,a=t.x===n.x&&t.y===n.y,s=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)<s?Math.max(e.y,o.y)+s: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)<s?Math.max(e.x,o.x)+s:l;return[{x:c,y:e.y},{x:c,y:o.y}]}}else if(a)if(r)if((o.x-e.x)*t.x>0&&Math.abs(e.y-o.y)<s){let l=Math.max(e.y,o.y)+s,c=o.x+t.x*(s/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)<s){let l=Math.max(e.x,o.x)+s,c=o.y+t.y*(s/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 Bl(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];ae(n,r,"x",ne)&&ae(r,i,"x",ne)||ae(n,r,"y",ne)&&ae(r,i,"y",ne)||t.push(r)}return t.push(e[e.length-1]),t}function Tr(e){let t=[];for(let o of e){let n=t[t.length-1];(!n||Math.abs(n.x-o.x)>=ne||Math.abs(n.y-o.y)>=ne)&&t.push(o)}return t}function ug(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],a=t[n+1];if(lg(r,i,a)||cg(r,i,a)){t.splice(n,1),o=!0;break}}}return t}function zl(e){let t=Tr(Bl([...e]));return t=ug(t),Tr(Bl(t))}function Nr(e){switch(e){case _r.Left:return{x:-1,y:0};case _r.Right:return{x:1,y:0};case _r.Top:return{x:0,y:-1};case _r.Bottom:return{x:0,y:1};default:return{x:0,y:0}}}function Yl(e,t,o,n){let r=At.OFFSET,i=At.OFFSET;if(t.x===-n.x&&t.y===-n.y)if(t.x!==0){let a=(o.x-e.x)*t.x;a>0&&a<2*At.OFFSET&&(r=a/2,i=a/2)}else{let a=(o.y-e.y)*t.y;a>0&&a<2*At.OFFSET&&(r=a/2,i=a/2)}return{sourceOffset:r,targetOffset:i}}function pg(e,t,o,n,r,i,a=0){let s=Nr(r),l=Nr(i),c=s.x===0?a:0,d=s.y===0?a:0,u=l.x===0?a:0,f=l.y===0?a:0,p={x:e+c,y:t+d},g={x:o+u,y:n+f},{sourceOffset:y,targetOffset:m}=Yl(p,s,g,l),b={x:p.x+s.x*y,y:p.y+s.y*y},h={x:g.x+l.x*m,y:g.y+l.y*m},E=dg(b,s,h,l),w=[p,b,...E,h,g],_=zl(w);if(_.length===2&&vr(p,g)>ne){let x=ae(p,b,"x",ne)&&ae(b,h,"x",ne)&&ae(h,g,"x",ne),N=ae(p,b,"y",ne)&&ae(b,h,"y",ne)&&ae(h,g,"y",ne);if(x||N){let I=N&&(h.x-b.x)*s.x<0,A=x&&(h.y-b.y)*s.y<0;if(!I&&!A)return Tr([p,b,h,g])}}return _}function wr(e,t,o,n,r,i,a,s=0){if(!(a!=null&&a.length))return pg(e,t,o,n,r,i,s);let l=Nr(r),c=Nr(i),d=l.x===0?s:0,u=l.y===0?s:0,f=c.x===0?s:0,p=c.y===0?s:0,g={x:e+d,y:t+u},y={x:o+f,y:n+p},{sourceOffset:m,targetOffset:b}=Yl(g,l,y,c),h={x:g.x+l.x*m,y:g.y+l.y*m},E={x:y.x+c.x*b,y:y.y+c.y*b},w=[...a],_=w[0],x=l.y===0;x&&Math.abs(g.y-_.y)>ne?w.unshift({x:_.x,y:g.y}):!x&&Math.abs(g.x-_.x)>ne&&w.unshift({x:g.x,y:_.y});let N=w[w.length-1],I=c.y===0,A=[];(Math.abs(N.x-E.x)>ne||Math.abs(N.y-E.y)>ne)&&(I?A.push({x:E.x,y:N.y}):A.push({x:N.x,y:E.y})),A.push(E);let M=[g,...w,...A,y],S=zl(M);if(S.length===2&&vr(g,y)>ne){let k=ae(g,h,"x",ne)&&ae(h,E,"x",ne)&&ae(E,y,"x",ne),B=ae(g,h,"y",ne)&&ae(h,E,"y",ne)&&ae(E,y,"y",ne);if(k||B){let q=B&&(E.x-h.x)*l.x<0,j=k&&(E.y-h.y)*l.y<0;if(!q&&!j)return Tr([g,h,E,y])}}return S}var vr=(e,t)=>Math.sqrt(Math.pow(t.x-e.x,2)+Math.pow(t.y-e.y,2));function fg(e,t,o){return ae(e,t,"x",ne)&&ae(t,o,"x",ne)||ae(e,t,"y",ne)&&ae(t,o,"y",ne)}function mg(e,t,o,n){if(fg(e,t,o))return`L${t.x} ${t.y}`;let r=vr(e,t),i=vr(t,o),a=Math.min(r/2,i/2,n);if(a<1)return`L${t.x} ${t.y}`;let s=e.x-t.x,l=e.y-t.y,c=o.x-t.x,d=o.y-t.y,u={x:s/r,y:l/r},f={x:c/i,y:d/i},p={x:t.x+u.x*a,y:t.y+u.y*a},g={x:t.x+f.x*a,y:t.y+f.y*a},y=-u.x,m=-u.y,b=f.x,h=f.y,w=y*h-m*b>0?1:0;return`L${p.x} ${p.y}A${a} ${a} 0 0 ${w} ${g.x} ${g.y}`}var Fl=(e,t=5)=>e.length<2?"":e.reduce((o,n,r)=>{let i="";return r>0&&r<e.length-1?i=mg(e[r-1],n,e[r+1],t):i=`${r===0?"M":"L"}${n.x} ${n.y}`,o+=i,o},"");import{useCallback as mo,useEffect as Ar,useRef as on,useState as go}from"react";import{useReactFlow as gg,useStore as hg}from"@xyflow/react";var yg=50,Wl=.1,xg=.6,Ir=({edgeId:e,source:t,target:o,instanceId:n,isReadOnly:r})=>{let{setEdges:i,getNode:a,getNodes:s,getEdge:l,screenToFlowPosition:c}=gg(),{setIsDragging:d,setReconnectingEdgeId:u}=Q(),f=hg(D=>D.isValidConnection),[p,g]=go(null),[y,m]=go(null),[b,h]=go(null),[E,w]=go(null),[_,x]=go(null),[N,I]=go(!1),A=on(null),M=on(null),S=on(null),k=on(t),B=on(o);Ar(()=>{k.current=t,B.current=o},[t,o]),Ar(()=>{A.current=p},[p]),Ar(()=>{M.current=_},[_]);let q=mo(D=>{let G=s(),K=G.find(Y=>Y.id===D);if(!K)return{x:0,y:0};let L=K.position.x,V=K.position.y,F=K.parentId;for(;F;){let Y=G.find(O=>O.id===F);if(!Y)break;L+=Y.position.x,V+=Y.position.y,F=Y.parentId}return{x:L,y:V}},[s]),j=mo(D=>{var F,Y,O,J,U,X;let G=s(),K=null,L=yg,V=G.filter(z=>z.type!=="LANE"&&z.type!=="ANNOTATION");for(let z of V){if(z.id===e)continue;let W=q(z.id),Z=(O=(Y=(F=z.measured)==null?void 0:F.width)!=null?Y:z.width)!=null?O:0,ee=(X=(U=(J=z.measured)==null?void 0:J.height)!=null?U:z.height)!=null?X:0;if(D.x>=W.x&&D.x<=W.x+Z&&D.y>=W.y&&D.y<=W.y+ee)return z.id;let ce=Math.max(W.x-D.x,0,D.x-(W.x+Z)),de=Math.max(W.y-D.y,0,D.y-(W.y+ee)),ue=Math.sqrt(ce*ce+de*de);ue<L&&(L=ue,K=z.id)}return K},[s,q,e]),C=mo((D,G)=>{var ce,de,ue,ge,he,fe;let K=a(D);if(!K)return null;let L=q(D),V=(ue=(de=(ce=K.measured)==null?void 0:ce.width)!=null?de:K.width)!=null?ue:0,F=(fe=(he=(ge=K.measured)==null?void 0:ge.height)!=null?he:K.height)!=null?fe:0,Y=Math.abs(L.x+V-G.x),O=Math.abs(G.x-L.x),J=Math.abs(L.y+F-G.y),U=Math.abs(G.y-L.y),X={right:Y,left:O,bottom:J,top:U},z=Object.entries(X).reduce((se,[ie,ve])=>ve<se[1]?[ie,ve]:se,["right",X.right])[0],W=S.current;if(W&&W!==z){let se=X[z],ie=X[W],ve=Math.abs(ie-se),ke=Math.min(Math.abs(ie),Math.abs(se));ve<ke*xg&&(z=W)}let Z=z,ee,le;if(Z==="right"||Z==="left"){let ie=(Math.max(L.y,Math.min(L.y+F,G.y))-L.y)/(F||1);Math.abs(ie-.5)<Wl&&(ie=.5),le=ie,ee={x:Z==="right"?L.x+V:L.x,y:L.y+le*F}}else{let ie=(Math.max(L.x,Math.min(L.x+V,G.x))-L.x)/(V||1);Math.abs(ie-.5)<Wl&&(ie=.5),le=ie,ee={x:L.x+le*V,y:Z==="bottom"?L.y+F:L.y}}return{side:Z,snapPosition:ee,offset:le}},[a,q]),P=mo(D=>{var O,J,U;let G=A.current;if(!G)return;let K=c({x:D.clientX,y:D.clientY}),L=j(K);h(L);let V=K,F=null,Y=null;if(L){let X=C(L,K);X&&(F=X.side,V=X.snapPosition,Y=X.offset,S.current=F);let z=l(e),W={source:G==="source"?L:k.current,target:G==="target"?L:B.current,sourceHandle:G==="source"?F:(O=z==null?void 0:z.sourceHandle)!=null?O:null,targetHandle:G==="target"?F:(J=z==null?void 0:z.targetHandle)!=null?J:null},Z=(U=f==null?void 0:f(W))!=null?U:!0;I(Z)}else S.current=null,I(!1);w(F),x(Y),m(V)},[j,C,l,e,c,f]),$=mo(D=>{var F,Y,O,J,U;let G=A.current;if(!G)return;let K=c({x:D.clientX,y:D.clientY}),L=j(K);if(L){let X=C(L,K),z=(F=X==null?void 0:X.side)!=null?F:null,W=(Y=X==null?void 0:X.offset)!=null?Y:.5,Z=l(e),ee={source:G==="source"?L:k.current,target:G==="target"?L:B.current,sourceHandle:G==="source"?z:(O=Z==null?void 0:Z.sourceHandle)!=null?O:null,targetHandle:G==="target"?z:(J=Z==null?void 0:Z.targetHandle)!=null?J:null};((U=f==null?void 0:f(ee))==null||U)&&i(le=>le.map(ce=>{var de,ue;return ce.id===e?v(T({},ce),{source:ee.source,target:ee.target,sourceHandle:ee.sourceHandle,targetHandle:ee.targetHandle,data:v(T({},ce.data),{points:void 0,sourceOffset:G==="source"?W:(de=ce.data)==null?void 0:de.sourceOffset,targetOffset:G==="target"?W:(ue=ce.data)==null?void 0:ue.targetOffset})}):ce}))}g(null),m(null),h(null),w(null),x(null),d(!1),I(!1),u(null),S.current=null,document.removeEventListener("mouseup",$),document.removeEventListener("mousemove",P);let V=it.get(n);V==null||V.clearReconnectingEdge()},[e,j,C,l,i,n,P,f,c,d,u]),H=mo((D,G)=>{if(r||G.button!==0)return;G.stopPropagation(),G.preventDefault(),i(L=>L.map(V=>V.id===e?v(T({},V),{data:v(T({},V.data),{points:void 0})}):V)),g(D),u(e);let K=it.get(n);K==null||K.setReconnectingEdge(e),document.addEventListener("mousemove",P),document.addEventListener("mouseup",$)},[r,e,n,P,$,u,i]);return Ar(()=>()=>{if(A.current){document.removeEventListener("mousemove",P),document.removeEventListener("mouseup",$),u(null);let D=it.get(n);D==null||D.clearReconnectingEdge()}},[n,P,$,u]),{reconnectingHandle:p,cursorPosition:y,hoveredNodeId:b,reconnectingSide:E,reconnectingOffset:_,isValidReconnection:N,handleReconnectStart:H}};import{Fragment as Zl,jsx as Ae,jsxs as pt}from"react/jsx-runtime";var Fe={type:"SEQUENCE_EDGE",reconnectable:!0,markerStart:{type:$l.ArrowClosed},markerEnd:{type:$l.Arrow},data:{label:""}},{MOVE_THRESHOLD:Cr,MIN_SEGMENT_LENGTH:Ag,PARALLEL_OFFSET:ql}=At;function Ig(e,t,o,n){let r=n.filter(s=>s.source===t&&s.target===o||s.source===o&&s.target===t);if(r.length<=1){let s=n.filter(d=>d.source===t);if(s.length<=1)return 0;let l=s.findIndex(d=>d.id===e);if(l<=0)return 0;let c=(s.length-1)/2;return(l-c)*ql}let i=r.findIndex(s=>s.id===e),a=(r.length-1)/2;return(i-a)*ql}var Jl=({id:e,source:t,target:o,data:n,selected:r,sourcePosition:i,targetPosition:a,sourceHandleId:s,targetHandleId:l})=>{var F,Y;let{zoom:c}=vg(),{updateEdgeData:d}=Ng(),u=wg(),{isMultipleSelection:f,mode:p,instanceId:g}=Q(),[y,m]=Xl(!1),[b,h]=Xl(null),E=Ul(null),w=Ul(null),_=p!=="edit",{reconnectingHandle:x,cursorPosition:N,hoveredNodeId:I,reconnectingSide:A,isValidReconnection:M,handleReconnectStart:S}=Ir({edgeId:e,source:t,target:o,instanceId:g,isReadOnly:_}),k=Kl(t),B=Kl(o),{sx:q,sy:j,tx:C,ty:P,sourcePos:$,targetPos:H}=Vi(()=>{var de,ue;let O=k&&B?no(k,B):{sx:0,sy:0,tx:0,ty:0,sourcePos:ho.Right,targetPos:ho.Left},J=s?i:O.sourcePos,U=l?a:O.targetPos,X=(ge,he,fe)=>{var yt,Jt,Qt,xe,Ie,et;let{x:se,y:ie}=ge.internals.positionAbsolute,ve=(Qt=(Jt=(yt=ge.measured)==null?void 0:yt.width)!=null?Jt:ge.width)!=null?Qt:0,ke=(et=(Ie=(xe=ge.measured)==null?void 0:xe.height)!=null?Ie:ge.height)!=null?et:0;switch(he){case ho.Top:return{x:se+ve*fe,y:ie};case ho.Bottom:return{x:se+ve*fe,y:ie+ke};case ho.Left:return{x:se,y:ie+ke*fe};case ho.Right:return{x:se+ve,y:ie+ke*fe};default:return{x:se+ve/2,y:ie+ke/2}}},z=(de=n==null?void 0:n.sourceOffset)!=null?de:.5,W=(ue=n==null?void 0:n.targetOffset)!=null?ue:.5,Z=k?X(k,J,z).x:O.sx,ee=k?X(k,J,z).y:O.sy,le=B?X(B,U,W).x:O.tx,ce=B?X(B,U,W).y:O.ty;return x==="source"&&N?(Z=N.x,ee=N.y,A&&(J=A)):x==="target"&&N&&(le=N.x,ce=N.y,A&&(U=A)),{sx:Z,sy:ee,tx:le,ty:ce,sourcePos:J,targetPos:U}},[k,B,s,l,i,a,x,N,A,n==null?void 0:n.sourceOffset,n==null?void 0:n.targetOffset]);bg(()=>{var U;if(!w.current){w.current={sx:q,sy:j,tx:C,ty:P,sourcePos:$,targetPos:H};return}let O=w.current;(Math.abs(q-O.sx)>Cr||Math.abs(j-O.sy)>Cr||Math.abs(C-O.tx)>Cr||Math.abs(P-O.ty)>Cr||O.sourcePos!==$||O.targetPos!==H)&&((U=n==null?void 0:n.points)!=null&&U.length)&&d(e,v(T({},n),{points:void 0})),w.current={sx:q,sy:j,tx:C,ty:P,sourcePos:$,targetPos:H}},[q,j,C,P,$,H,n,e,d,x]);let D=Vi(()=>{let O=Ig(e,t,o,u);return wr(q,j,C,P,$,H,n==null?void 0:n.points,O)},[q,j,C,P,$,H,n==null?void 0:n.points,u,e,t,o]),G=Vi(()=>{if(D.length<2)return br({x:q,y:j},{x:C,y:P});let O=0;for(let X=0;X<D.length-1;X++)O+=Er(D[X],D[X+1]);let J=O/2,U=0;for(let X=0;X<D.length-1;X++){let z=Er(D[X],D[X+1]);if(U+z>=J){let W=(J-U)/z,Z=D[X],ee=D[X+1];return{x:Z.x+(ee.x-Z.x)*W,y:Z.y+(ee.y-Z.y)*W}}U+=z}return br({x:q,y:j},{x:C,y:P})},[D,q,j,C,P]),K=Eg((O,J)=>{if(p!=="edit"||J.button!==0)return;J.stopPropagation(),J.preventDefault();let U=D[O],X=D[O+1],z=ae(U,X,"y"),W=z?U.y:U.x,Z=[...D],ee=Z.length,le=O,ce=O+1;h(O);let de=ge=>{let he=W+(z?ge.clientY-J.clientY:ge.clientX-J.clientX)/c;E.current=z?{x:(U.x+X.x)/2,y:he}:{x:he,y:(U.y+X.y)/2};let fe=[];for(let se=1;se<ee-1;se++){let ie=Z[se];se===le||se===ce?z?fe.push({x:ie.x,y:he}):fe.push({x:he,y:ie.y}):fe.push(T({},ie))}d(e,v(T({},n),{points:fe}))},ue=()=>{h(null),E.current=null,document.removeEventListener("mousemove",de),document.removeEventListener("mouseup",ue)};document.addEventListener("mousemove",de),document.addEventListener("mouseup",ue)},[p,D,c,n,e,d]);if(!k||!B)return null;let L=Fl(D),V=r||k.selected||B.selected;return pt(Zl,{children:[pt("g",{className:R("group bpmn-arrow-edge",{"is-highlighted":V}),onDoubleClick:()=>m(!0),children:[Ae("path",{d:L,fill:"none",stroke:"transparent",strokeWidth:Math.max(12,12/c),style:{pointerEvents:"stroke",cursor:"pointer"}}),pt("g",{className:R("text-grey-500 transition-colors duration-75 group-hover:text-grey-800",{"text-blue-500 group-hover:text-blue-600":V}),children:[Ae(_g,{id:e,path:L,interactionWidth:0,markerEnd:`url(#${V?"sequence-edge-marker-highlighted":"sequence-edge-marker"})`,className:R("stroke-2 stroke-current transition-[stroke,filter] duration-75 group-hover:drop-shadow-[0_0_3px_rgba(0,0,0,0.2)]",{"stroke-red-500 hover:stroke-red-600":(n==null?void 0:n.hasError)||x&&I&&!M,"stroke-green-500":x&&I&&M,"stroke-blue-500 hover:stroke-blue-600 drop-shadow-[0_0_3px_rgba(59,130,246,0.5)]":V&&!(n!=null&&n.hasError)&&!x})}),r&&!f&&!_&&Ae("g",{children:D.slice(0,-1).map((O,J)=>{let U=D[J+1];if(J===0||J===D.length-2||Er(O,U)<Ag)return null;let X=ae(O,U,"y"),z=b===J,W=z&&E.current?E.current:br(O,U);return pt("g",{children:[Ae("line",{x1:O.x,y1:O.y,x2:U.x,y2:U.y,stroke:"transparent",strokeWidth:20/c,className:R("cursor-pointer",{"cursor-ns-resize":X,"cursor-ew-resize":!X}),onMouseDown:Z=>K(J,Z)}),Ae("circle",{cx:W.x,cy:W.y,r:4/c,fill:z?"#3b82f6":"#fff",stroke:"#3b82f6",strokeWidth:2/c,className:"pointer-events-none"}),Ae("circle",{cx:W.x,cy:W.y,r:6/c,fill:"none",stroke:"#3b82f6",strokeWidth:1/c,opacity:z?.6:.3,className:"pointer-events-none"})]},J)})})]})]}),pt(Tg,{children:[pt("div",{className:"absolute z-[3000] pointer-events-none flex flex-col items-center gap-1",style:{transform:`translate(-50%, -50%) translate(${G.x}px, ${G.y}px)`},children:[r&&!f&&Ae(po,{sx:q,sy:j,tx:C,ty:P,hasLabel:!!((F=n==null?void 0:n.label)!=null&&F.trim()),children:Ae(uo,{edgeId:e,edgeType:"SEQUENCE_EDGE",sourceNode:k,targetNode:B})}),(y||((Y=n==null?void 0:n.label)==null?void 0:Y.trim()))&&Ae(Ce,{value:n==null?void 0:n.label,className:R("min-w-8 max-w-56 px-2 py-1 body-small-400",{"pointer-events-auto":y,"pointer-events-none":!y}),isEditing:y,onBlur:()=>m(!1),onChange:O=>d(e,{label:O.trim()})})]}),r&&!f&&!_&&pt(Zl,{children:[Ae("div",{className:"absolute z-[10000] pointer-events-none",style:{transform:`translate(-50%, -50%) translate(${D[0].x}px, ${D[0].y}px)`},children:pt("svg",{width:12/c,height:12/c,style:{overflow:"visible",position:"absolute",left:"50%",top:"50%",transform:"translate(-50%, -50%)"},children:[Ae("circle",{cx:6/c,cy:6/c,r:4/c,fill:x==="source"?"#3b82f6":"#fff",stroke:"#3b82f6",strokeWidth:2/c,className:"pointer-events-none"}),Ae("circle",{cx:6/c,cy:6/c,r:6/c,fill:"none",stroke:"#3b82f6",strokeWidth:1/c,opacity:x==="source"?.6:.3,className:"pointer-events-none"}),Ae("circle",{cx:6/c,cy:6/c,r:8/c,fill:"transparent",className:R("pointer-events-auto",{"cursor-move":!x||x!=="source","cursor-not-allowed":x==="source"&&I&&!M,"cursor-grabbing":x==="source"&&(!I||M)}),onMouseDown:O=>S("source",O.nativeEvent)})]})}),Ae("div",{className:"absolute z-[10000] pointer-events-none",style:{transform:`translate(-50%, -50%) translate(${D[D.length-1].x}px, ${D[D.length-1].y}px)`},children:pt("svg",{width:12/c,height:12/c,style:{overflow:"visible",position:"absolute",left:"50%",top:"50%",transform:"translate(-50%, -50%)"},children:[Ae("circle",{cx:6/c,cy:6/c,r:4/c,fill:x==="target"?"#3b82f6":"#fff",stroke:"#3b82f6",strokeWidth:2/c,className:"pointer-events-none"}),Ae("circle",{cx:6/c,cy:6/c,r:6/c,fill:"none",stroke:"#3b82f6",strokeWidth:1/c,opacity:x==="target"?.6:.3,className:"pointer-events-none"}),Ae("circle",{cx:6/c,cy:6/c,r:8/c,fill:"transparent",className:R("pointer-events-auto",{"cursor-move":!x||x!=="target","cursor-not-allowed":x==="target"&&I&&!M,"cursor-grabbing":x==="target"&&(!I||M)}),onMouseDown:O=>S("target",O.nativeEvent)})]})})]})]})]})};import{Position as ft}from"@xyflow/react";var Cg={right:ft.Right,left:ft.Left,top:ft.Top,bottom:ft.Bottom},Sr=e=>{var t;return(t=Cg[e!=null?e:""])!=null?t:ft.Right},Hi=(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,a=(u=(d=e.measured)==null?void 0:d.height)!=null?u:0;switch(Sr(t)){case ft.Right:return{x:n+i,y:r+a*o};case ft.Left:return{x:n,y:r+a*o};case ft.Top:return{x:n+i*o,y:r};case ft.Bottom:return{x:n+i*o,y:r+a};default:return{x:n+i/2,y:r+a/2}}},Ql=(e,t,o)=>{var d,u;let{position:{x:n,y:r},measured:i}=e,a=(d=i.width)!=null?d:0,s=(u=i.height)!=null?u:0;return[{id:"left",x:n,y:r+s/2},{id:"right",x:n+a,y:r+s/2},{id:"top",x:n+a/2,y:r},{id:"bottom",x:n+a/2,y:r+s}].reduce((f,p)=>{let g=Math.hypot(t-f.x,o-f.y);return Math.hypot(t-p.x,o-p.y)<g?p:f}).id};import{useDebouncedCallback as by}from"use-debounce";import{getViewportForBounds as yy,useReactFlow as xy,useStoreApi as Ey}from"@xyflow/react";import{useCallback as pd}from"react";var nn=(d=>(d.START_EVENT="start-event",d.END_EVENT_TERMINATE="end-event-terminate",d.TASK="task",d.TASK_SCRIPT="task-script",d.SUBPROCESS="subprocess-collapsed",d.GATEWAY_EXCLUSIVE="gateway-exclusive",d.GATEWAY_PARALLEL="gateway-parallel",d.GATEWAY_COMPLEX="gateway-complex",d.ANNOTATION="annotation",d.LANE="lane",d))(nn||{});import{xml2json as Sg,json2xml as Mg}from"xml-js";var jl={compact:!0,spaces:4},Pg=e=>e.replace(/\n/g,"&#xA;");function Mr(e,t=jl){if(e)return JSON.parse(Sg(e,t))}function ec(e,t=jl){return e?Mg(e,v(T({},t),{attributeValueFn:Pg})):""}var Lg={MIN_WIDTH:36,MIN_HEIGHT:36},kg={MIN_WIDTH:36,MIN_HEIGHT:36},Rg={MIN_WIDTH:56,MIN_HEIGHT:56},yo={MIN_WIDTH:176,MIN_HEIGHT:96},Pr={HEADER_WIDTH:40,MIN_WIDTH:840,MIN_HEIGHT:256},ye={HEADER_WIDTH:40,MIN_WIDTH:800,MIN_HEIGHT:256},xo={MIN_WIDTH:176,MIN_HEIGHT:64},Dg={MIN_WIDTH:128,MIN_HEIGHT:64},re={START_EVENT:Lg,END_EVENT:kg,GATEWAY:Rg,TASK:yo,LANE:ye,ANNOTATION:xo,UNSUPPORTED:Dg};var tc={"attribute-loop":"LOOP"},oc={"task-script":"SCRIPT","subprocess-collapsed":"SUBPROCESS"},nc={"gateway-exclusive":"EXCLUSIVE","gateway-parallel":"PARALLEL","gateway-complex":"COMPLEX"},rc={SCRIPT:"task-script",SUBPROCESS:"subprocess-collapsed"},ic={EXCLUSIVE:"gateway-exclusive",PARALLEL:"gateway-parallel",COMPLEX:"gateway-complex"};var Eo=(e,t,o,n,r,i)=>{let a=e._attributes.width||0,s=e._attributes.height||0,l=0,c=0;if(n&&r!==void 0&&i!==void 0){let g=n.split(`
6
+ `),y=g.length;l=g.reduce((b,h)=>Math.max(b,h.length),0)*7+r,c=y*20+i}let d=Math.max(xt(Number(a),t),l),u=Math.max(xt(Number(s),o),c);return{width:d,height:u,measured:{width:d,height:u}}},bo=e=>{let{_attributes:t,mxGeometry:o}=e,{id:n,parent:r,value:i}=t,a={x:Number(o._attributes.x||0),y:Number(o._attributes.y||0)},s={id:n,position:a,data:{label:i||""}},l=r==="1"?void 0:r;return l&&(s.parentId=l),s},Vg=e=>{let{mxGeometry:t}=e,o=bo(e),n=Eo(t,re.START_EVENT.MIN_WIDTH,re.START_EVENT.MIN_HEIGHT);return v(T(T({},o),n),{type:"START_EVENT"})},Hg=e=>{let{mxGeometry:t}=e,o=bo(e),n=Eo(t,re.END_EVENT.MIN_WIDTH,re.END_EVENT.MIN_HEIGHT);return v(T(T({},o),n),{type:"END_EVENT"})},Gi=(e,t)=>{let{_attributes:o,mxGeometry:n}=e,r=bo(e),s=Eo(n,re.TASK.MIN_WIDTH,re.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=tc[d];u&&(r.data.attribute=u)}let c=oc[o.style];return c&&(r.data.variant=c),v(T(T({},r),s),{type:"TASK"})},Bi=e=>{let{_attributes:t,mxGeometry:o}=e,{style:n}=t,r=bo(e),i=Eo(o,re.GATEWAY.MIN_WIDTH,re.GATEWAY.MIN_HEIGHT);return r.data.variant=nc[n],v(T(T({},r),i),{type:"GATEWAY"})},Gg=e=>{let{mxGeometry:t}=e,o=bo(e),i=Eo(t,re.ANNOTATION.MIN_WIDTH,re.ANNOTATION.MIN_HEIGHT,o.data.label,32,24);return v(T(T({},o),i),{type:"ANNOTATION"})},Bg=e=>{let{mxGeometry:t}=e,o=bo(e),n=Eo(t,re.LANE.MIN_WIDTH,re.LANE.MIN_HEIGHT);return v(T(T({},o),n),{type:"LANE"})},sc={task:Gi,"task-script":Gi,"subprocess-collapsed":Gi,"start-event":Vg,"end-event-terminate":Hg,"gateway-parallel":Bi,"gateway-exclusive":Bi,"gateway-complex":Bi,annotation:Gg,lane:Bg},zg=e=>{if(e&&Array.isArray(e))return e.map(t=>({x:Number(t._attributes.x),y:Number(t._attributes.y)}))},ac=e=>{let{_attributes:t,mxGeometry:o}=e,{id:n,source:r,target:i,value:a,style:s,sourceHandle:l,targetHandle:c,sourceOffset:d,targetOffset:u}=t,f=zg(o==null?void 0:o.Array),p=d!==void 0?Number(d):void 0,g=u!==void 0?Number(u):void 0,y=v(T(T({id:n,source:r,target:i},l?{sourceHandle:l}:{}),c?{targetHandle:c}:{}),{data:T(T(T({label:a||""},f&&f.length>0?{points:f}:{}),p!==void 0?{sourceOffset:p}:{}),g!==void 0?{targetOffset:g}:{})});return s.includes("association")&&s.includes('endArrow=""')?T(T({},fo),y):T(T({},Fe),y)},lc=(e,t)=>{let{id:o,type:n,source:r,target:i,sourceHandle:a,targetHandle:s,data:l}=e,c=t==null?void 0:t.find(p=>p.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(p=>({_attributes:{as:"mxPoint",x:p.x,y:p.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:a!=null?a:void 0,targetHandle:s!=null?s: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},mxGeometry:u}},_o=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}}}},Yg=e=>{let{variant:t}=e.data,o=_o(e);return v(T({},o),{_attributes:v(T({},o._attributes),{style:rc[t]||"task"})})},Fg=e=>{let t=_o(e);return v(T({},t),{_attributes:v(T({},t._attributes),{style:"start-event"})})},Wg=e=>{let t=_o(e);return v(T({},t),{_attributes:v(T({},t._attributes),{style:"end-event-terminate"})})},Xg=e=>{let{variant:t}=e.data,o=_o(e);return v(T({},o),{_attributes:v(T({},o._attributes),{style:ic[t]})})},Ug=e=>{let t=_o(e);return v(T({},t),{_attributes:v(T({},t._attributes),{style:"lane"})})},$g=e=>{let t=_o(e);return v(T({},t),{_attributes:v(T({},t._attributes),{style:"annotation"})})},cc={TASK:Yg,START_EVENT:Fg,END_EVENT:Wg,GATEWAY:Xg,ANNOTATION:$g,LANE:Ug},dc=(e,t)=>{var a,s;let r=((a=e.measured)==null?void 0:a.width)||0,i=((s=e.measured)==null?void 0:s.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}}}};import gc from"@dagrejs/dagre";import{orderBy as Jg}from"lodash";import{orderBy as Kg}from"lodash";var mt=e=>{var t,o,n,r,i,a,s,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:(a=(i=e.measured)==null?void 0:i.width)!=null?a:0,h:(l=(s=e.measured)==null?void 0:s.height)!=null?l:0}},Ft=e=>Kg(e,[o=>{let n=o.type==="LANE";return n&&!o.parentId?0:n?1:2}],["asc"]),uc=(e,t)=>{let{x:o,y:n}=mt(e),{x:r,y:i}=mt(t);return{x:o-r,y:n-i}};var To=({parentId:e,nodes:t,includeTypes:o=[...Object.values(oe)],excludeTypes:n=[]})=>t.some(r=>r.parentId===e&&(!o.length||o.includes(r.type))&&!n.includes(r.type)),qg=(e,t)=>{let{x:o,y:n}=mt(e),{x:r,y:i}=mt(t),a=o-r,s=n-i;return Math.sqrt(a*a+s*s)},Zg=(e,t)=>{let{x:o,y:n,w:r,h:i}=mt(e),{x:a,y:s,w:l,h:c}=mt(t),d=o+r/2,u=n+i/2;return d>=a&&d<=a+l&&u>=s&&u<=s+c},rn=(e,t)=>{let o=null,n=1/0;for(let r of t)if(r.id!==e.id&&Zg(e,r)){let i=qg(e,r);i<n&&(n=i,o=r)}return o},pc=(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),fc=(e,t)=>{let o=e.filter(c=>!c.parentId);if(o.length===0)return{nodes:e,edges:t};let n=o.filter(c=>c.type==="LANE"),r=n.length>0?n:o,i=Math.min(...r.map(c=>c.position.x||0)),a=Math.min(...r.map(c=>c.position.y||0)),s=e.map(c=>c.parentId?c:v(T({},c),{position:{x:c.position.x-i,y:c.position.y-a}})),l=t.map(c=>{let d=c.data;return d!=null&&d.points?v(T({},c),{data:v(T({},d),{points:d.points.map(u=>({x:u.x-i,y:u.y-a}))})}):c});return{nodes:s,edges:l}},mc=e=>{var l,c;let t=e.filter(d=>!d.parentId),o=t.filter(d=>d.type==="LANE"),n=o.length>0?o:t;if(n.length===0)return null;let r=1/0,i=1/0,a=-1/0,s=-1/0;for(let d of n){let u=d.position.x+((l=d.width)!=null?l:0),f=d.position.y+((c=d.height)!=null?c:0);d.position.x<r&&(r=d.position.x),d.position.y<i&&(i=d.position.y),u>a&&(a=u),f>s&&(s=f)}return{x:r,y:i,width:a-r,height:s-i}};var hc=(e=[],t=[],o="LR")=>{let n=new gc.graphlib.Graph;return n.setDefaultEdgeLabel(()=>({})),n.setGraph({rankdir:o}),e.forEach(({id:i,width:a,height:s})=>n.setNode(i,{width:a,height:s})),t.forEach(i=>n.setEdge(i.source,i.target)),gc.layout(n),{nodes:e.map(i=>{let a=n.node(i.id);return v(T({},i),{position:{x:a.x-i.width/2,y:a.y-i.height/2}})}),edges:t}},sn=e=>{let t=e.filter(n=>n.type==="LANE"&&!n.parentId),o=[...e];return t.forEach(n=>{o=an(n.id,o)}),o},an=(e,t)=>{var m,b;let o=[...t],n=o.find(h=>h.id===e);if(!n)return o;let r=o.filter(h=>h.parentId===e&&h.type==="LANE");if(r.length===0)return o;let i=Jg(r,["position.y"]),a=Math.max((b=(m=n.measured)==null?void 0:m.width)!=null?b:0,Pr.MIN_WIDTH),s=pc(e,i)||ye.MIN_WIDTH,l=Math.max(a,s),c=a-ye.HEADER_WIDTH>=s,d=new Map(t.map(h=>[h.id,h])),u=0,f=i.map((h,E)=>{var N,I,A,M,S,k;let w=(I=(N=d.get(h.id))==null?void 0:N.position.y)!=null?I:0,_=E<i.length-1&&(M=(A=d.get(i[E+1].id))==null?void 0:A.position.y)!=null?M:1/0,x={id:h.id,originalLaneY:w,nextLaneOriginalY:_,targetY:u,deltaY:u-w};return u+=(k=(S=h.measured)==null?void 0:S.height)!=null?k:0,x}),p=u,g=c?l-ye.HEADER_WIDTH:l;o=o.map(h=>{var _,x;if(h.id===e){let N=c?l:l+ye.HEADER_WIDTH;return v(T({},h),{height:p,width:N,measured:v(T({},h.measured),{height:p,width:N})})}let w=f.find(N=>N.id===h.id);if(w)return v(T({},h),{width:g,measured:v(T({},h.measured),{width:g}),position:{x:ye.HEADER_WIDTH,y:w.targetY}});if(h.parentId===e&&h.type!=="LANE"){let N=(x=(_=d.get(h.id))==null?void 0:_.position.y)!=null?x:0,I=f.find(A=>N>=A.originalLaneY&&N<A.nextLaneOriginalY);if(I)return v(T({},h),{position:v(T({},h.position),{y:N+I.deltaY})})}return h});let y=o.find(h=>h.id===e);return y!=null&&y.parentId&&(o=an(y.parentId,o)),o},yc=(e,t,o)=>{if(e.type==="LANE")return o;let n=dt(t),r=dt(e);return r.y<n.y&&(e.position.y=0),r.x<n.x+ye.HEADER_WIDTH&&(e.position.x=ye.HEADER_WIDTH),r.y2>n.y2&&(t.height=r.y2-n.y,t.measured.height=r.y2-n.y),r.x2>n.x2&&(t.width=r.x2-n.x,t.measured.width=r.x2-n.x),o=o.map(i=>i.id===t.id?v(T({},i),{height:t.height,width:t.width,measured:t.measured}):i.id===e.id?v(T({},i),{position:e.position}):i),o},xc=()=>{let e=document.querySelector(".react-flow__viewport");return e||(console.error("Flow element (.react-flow__viewport) not found."),null)},Qg=e=>e.type==="LANE"&&!e.parentId,zi=e=>{var i;let t=e.filter(Qg);if(t.length===0)return e;let o=new Map;for(let a of e){if(!a.parentId)continue;let s=(i=o.get(a.parentId))!=null?i:[];s.push(a.id),o.set(a.parentId,s)}let n=new Set,r=t.map(a=>a.id);for(;r.length>0;){let a=r.pop();if(!a||n.has(a))continue;n.add(a);let s=o.get(a);if(s)for(let l of s)n.has(l)||r.push(l)}return e.filter(a=>n.has(a.id))};var ln=1,Ec=e=>`<mxGraphModel>
7
7
  <root version="1.1">
8
8
  <mxCell id="0" />
9
9
  <mxCell id="1" parent="0" />
@@ -36,11 +36,11 @@ var Pu=Object.defineProperty,Lu=Object.defineProperties;var ku=Object.getOwnProp
36
36
  <mxGeometry as="geometry" relative="1" />
37
37
  </mxCell>
38
38
  </root>
39
- </mxGraphModel>`,bc=(e,t)=>{if(!e.length&&!t.length)return ln;let o=[...e.map(r=>r.id),...t.map(r=>r.id)];return Math.max(...o.map(r=>Number(r)))};var jg=e=>{let t=Object.values(nn),o=e.filter(i=>{var s;let a=(s=i._attributes)==null?void 0:s.style;return t.includes(a)}),n=e.filter(i=>{var s;let a=(s=i._attributes)==null?void 0:s.style;return["attribute-loop"].includes(a)}),r=[];for(let i of o){let{style:a}=i._attributes,s=sc[a],l=s==null?void 0:s(i,n);if(!l){console.warn(`Node ${a} not supported`);continue}r.push(l)}return r},eh=(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=ac(r),a=t.find(l=>l.id===i.source),s=t.find(l=>l.id===i.target);(a==null?void 0:a.type)==="LANE"||(s==null?void 0:s.type)==="LANE"||n.push(i)}return n},th=(e,t)=>{let o=[];return e.forEach(n=>{var a,s;let r=(s=(a=cc)[n.type])==null?void 0:s.call(a,n);if(!r){console.warn(`Node ${n.type} not supported`);return}if(o.push(r),n.type==="TASK"&&n.data.attribute==="LOOP"){let l=dc(n,t);o.push(l)}}),o},oh=(e,t)=>{let o=[];return e.forEach(n=>{let r=lc(n,t);o.push(r)}),o},_c=(e=[],t=[],o)=>{let n=th(e,o),r=oh(t,e),i={mxGraphModel:{root:{_attributes:{version:"1.1",lastId:o},mxCell:[{_attributes:{id:"0"}},{_attributes:{id:"1",parent:"0"}},...n,...r]}}};return ec(JSON.stringify(i),{compact:!0,spaces:0})},Tc=async e=>{var c,d,u,f,p;let t=await Mr(e),o=((d=(c=t==null?void 0:t.mxGraphModel)==null?void 0:c.root)==null?void 0:d.mxCell)||[],n=Number(((p=(f=(u=t==null?void 0:t.mxGraphModel)==null?void 0:u.root)==null?void 0:f._attributes)==null?void 0:p.lastId)||ln),r=jg(o),i=eh(o,r),a=sn(r),{nodes:s,edges:l}=fc(a,i);return{lastElementId:n,edges:l,nodes:Ft(s)}};import{Position as It,useConnection as Dh,useReactFlow as Oh}from"@xyflow/react";import{useCallback as Wi}from"react";import{Handle as Nc,useReactFlow as nh}from"@xyflow/react";import{jsx as vc}from"react/jsx-runtime";var te=i=>{var a=i,{type:e,position:t,className:o,nodeType:n}=a,r=tt(a,["type","position","className","nodeType"]);let s=n==="TASK";return vc(Nc,T({type:e,position:t,className:D("size-2.5 border border-grey-400 bg-white relative",{"before:content-[''] before:absolute before:inset-[-16px] before:bg-transparent before:pointer-events-none":s,"before:content-[''] before:absolute before:inset-[-4px] before:bg-transparent before:pointer-events-none":!s},o)},r))},Le=s=>{var l=s,{nodeId:e,nodeType:t,gatewayVariant:o,type:n,position:r,className:i}=l,a=tt(l,["nodeId","nodeType","gatewayVariant","type","position","className"]);let{getEdges:c,getNodes:d}=nh(),f=(()=>{if(n!=="source")return!1;let p=c();if(t==="TASK")return p.filter(y=>y.source===e).length>=2;if(t==="GATEWAY"&&o==="EXCLUSIVE")return p.filter(y=>y.source===e).length>=2;if(t==="START_EVENT"){let g=d();return p.filter(m=>{if(m.source!==e)return!1;let _=g.find(h=>h.id===m.target);return(_==null?void 0:_.type)!=="ANNOTATION"}).length>=1}return!1})();return vc(Nc,T({type:n,position:r,className:D("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":f,"hover:border-grey-500":!f},i),style:{pointerEvents:f?"none":"auto"}},a))};import{NodeResizer as rh,useReactFlow as ih}from"@xyflow/react";import{orderBy as sh}from"lodash";import{jsx as ah}from"react/jsx-runtime";var No=n=>{var r=n,{nodeId:e,isVisible:t}=r,o=tt(r,["nodeId","isVisible"]);let{getNode:i,getNodes:a,setNodes:s}=ih(),{isMultipleSelection:l}=Q(),c=({width:u,height:f})=>{if(!e)return;let p=i(e);if((p==null?void 0:p.type)!=="LANE")return;let g=[...a()],y=!p.parentId,m=y?p.id:p.parentId,_=g.filter(w=>w.type==="LANE"&&w.parentId===m);if(!_.length)return;let h=sh(_,["position.y"]),E=0;h.forEach((w,b)=>{var I,A;let x=b===h.length-1,N=(A=(I=w.measured)==null?void 0:I.height)!=null?A:0;g=g.map(M=>{if(M.id===w.id){let S=y?u-ye.HEADER_WIDTH:u,k=v(T({},M),{width:S,measured:v(T({},M.measured),{width:S}),position:v(T({},M.position),{y:E})});return x&&y&&(k.height=f-E),k}return M}),E+=N}),g=g.map(w=>{if(w.id===m){let b=y?u:u+ye.HEADER_WIDTH;return v(T({},w),{width:b,height:y?f:E,measured:{width:b,height:y?f:E}})}return w}),s(g)};return ah(rh,T({nodeId:e,handleClassName:"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]",lineClassName:"border-blue-400/90 border-dashed",isVisible:!l&&t,onResizeEnd:(u,f)=>c(f)},o))};import{NodeToolbar as wh,useReactFlow as Ah}from"@xyflow/react";import{Button as Ih,Tooltip as Ch,TooltipContent as Sh,TooltipTrigger as Mh,useTranslation as Ph}from"@produto-lecom/lecom-ui";import{useCallback as Fi,useEffect as Lh,useRef as Lr,useState as kh}from"react";import{create as lh}from"zustand";var vo=lh(e=>({draggableNode:null,setDraggableNode:t=>{e({draggableNode:t})}}));import{useEffect as ch,useState as dh}from"react";var wc=(e,t=!1)=>{let[o,n]=dh({width:0,height:0});return ch(()=>{if(e.current&&t){let r=e.current.getBoundingClientRect();n({width:r.width,height:r.height})}},[t,e]),{dimensions:o}};import{Position as cn,useReactFlow as uh}from"@xyflow/react";import{useMemo as ph}from"react";var fh=120,mh=12,Ac=(e,t=!1,o)=>{let{getNode:n,getViewport:r}=uh(),{instanceId:i}=Q();return ph(()=>{var p,g;if(!t)return{position:cn.Right,align:"start"};let a=n(e);if(!a)return{position:cn.Right,align:"start"};let s=r(),l=a.position.x*s.zoom+s.x,c=(((p=a.measured)==null?void 0:p.width)||a.width||100)*s.zoom,d=(g=document.getElementById(`modeler-${i}`))==null?void 0:g.clientWidth;if(!d)return{position:cn.Right,align:"start"};let u=(o==null?void 0:o.width)||fh;return{position:l+c+u+mh>d?cn.Left:cn.Right}},[i,e,t,o,n,r])};import{useNodesData as gh,useReactFlow as hh}from"@xyflow/react";import{Button as Ic,DropdownMenu as yh,DropdownMenuContent as xh,DropdownMenuGroup as Eh,DropdownMenuItem as bh,DropdownMenuLabel as _h,DropdownMenuTrigger as Th,Tooltip as Bi,TooltipContent as zi,TooltipTrigger as Yi,useTranslation as Nh}from"@produto-lecom/lecom-ui";import{WrenchIcon as vh}from"lucide-react";import{jsx as Se,jsxs as Wt}from"react/jsx-runtime";var Cc=({nodeId:e})=>{let{t}=Nh(),{updateNodeData:o,getEdges:n,getNode:r}=hh(),i=gh(e),s=n().filter(p=>p.source===e).some(p=>{let g=r(p.target);return(g==null?void 0:g.type)==="END_EVENT"}),l=(i==null?void 0:i.data.variant)==="SUBPROCESS",c=u=>{o(e,{variant:(i==null?void 0:i.data.variant)===u?"":u})},d=u=>{o(e,{attribute:(i==null?void 0:i.data.attribute)===u?"":u})};return Wt(yh,{children:[Wt(Bi,{children:[Se(Yi,{asChild:!0,children:Se(Th,{asChild:!0,children:Se(Ic,{variant:"ghost",color:"grey",size:"small",iconButton:!0,children:Se(vh,{})})})}),Se(zi,{color:"black",children:t("bpmn.task.menu.title")})]}),Wt(xh,{align:"start",className:"w-60 bg-white text-grey-600",children:[Wt(_h,{className:"flex items-center gap-1",children:[Se("div",{className:"flex-1 body-medium-500",children:t("bpmn.task.menu.title")}),Se("div",{className:"flex items-center gap-1",children:Object.entries(In).map(([u,f])=>{let p=u==="LOOP"&&(s||l),y=(()=>{if(u==="LOOP"&&s)return t("editor.task_menu.loop_not_allowed_when_connected_to_end");if(u==="LOOP"&&l)return t("editor.task_menu.loop_not_allowed_when_subprocess");if(u==="LOOP")return t("editor.task_menu.loop")})();return Wt(Bi,{children:[Se(Yi,{asChild:!0,children:Se(Ic,{variant:"ghost",color:"grey",size:"small",iconButton:!0,disabled:p,className:D({"bg-grey-100 text-blue-500":(i==null?void 0:i.data.attribute)===u,"opacity-50 cursor-not-allowed":p}),onClick:p?void 0:()=>d(u),children:Se(f.icon,{className:"stroke-inherit"})})}),y&&Se(zi,{color:"black",children:y})]},u)})})]}),Se(Eh,{children:Wt(Bi,{children:[Se(Yi,{asChild:!0,children:Se("div",{className:D({"cursor-not-allowed":s}),children:Wt(bh,{className:D({"bg-grey-100 text-blue-500":(i==null?void 0:i.data.variant)==="SCRIPT","opacity-50":s}),disabled:s,onClick:()=>c("SCRIPT"),children:[Se(An.SCRIPT.icon,{className:"stroke-current"}),t(`bpmn.task.variant.${"SCRIPT".toLowerCase()}`)]})})}),s&&Se(zi,{color:"black",children:t("editor.task_menu.script_not_allowed_when_connected_to_end")})]})})]})]})};import{jsx as xe,jsxs as Sc}from"react/jsx-runtime";var Xt={START_EVENT:{type:"START_EVENT",icon:ko,label:"bpmn.start_event.variant.default"},END_EVENT:{type:"END_EVENT",icon:jt,label:"bpmn.end_event.variant.default"},TASK:{type:"TASK",icon:ko,label:"bpmn.task.variant.default"},ANNOTATION:{type:"ANNOTATION",icon:Tn,label:"bpmn.annotation.variant.default"}},Rh={EXCLUSIVE:{type:"GATEWAY",variant:"EXCLUSIVE",icon:to,label:"bpmn.gateway.variant.exclusive"},PARALLEL:{type:"GATEWAY",variant:"PARALLEL",icon:oo,label:"bpmn.gateway.variant.parallel"},COMPLEX:{type:"GATEWAY",variant:"COMPLEX",icon:eo,label:"bpmn.gateway.variant.complex"}},He=({nodeId:e,nodeType:t,nodeVariant:o})=>{let n=Lr(null),r=Lr(null),{t:i}=Ph(),{setDraggableNode:a}=vo(),{getEdges:s,getNodes:l,getNode:c}=Ah(),{setIsDragging:d,mode:u,isConnecting:f,isDragging:p,isMultipleSelection:g}=Q(),y=c(e),m=!!(y!=null&&y.selected)&&!y.dragging&&!f&&!p&&!g,{dimensions:_}=wc(n,m),{position:h}=Ac(e,m,_),[E,w]=kh(void 0),b=l(),x=s(),N=o==="SUBPROCESS",I=Lr(null),A=Lr(!1),M=Fi(()=>{I.current!==null&&(clearTimeout(I.current),I.current=null),A.current=!1,d(!1),a(null),w(void 0)},[d,a]);Lh(()=>{let L=H=>{A.current&&H.buttons===0&&M()};return document.addEventListener("dragend",M),document.addEventListener("mousemove",L),()=>{document.removeEventListener("dragend",M),document.removeEventListener("mousemove",L)}},[M]);let S=Fi((L,H)=>{A.current=!0,d(!1),a({type:H.type,variant:H.variant,attribute:H.attribute,icon:H.icon}),H.icon&&w(xe(H.icon,{})),L.dataTransfer.effectAllowed="move",L.dataTransfer.setData("sourceId",e),r.current&&L.dataTransfer.setDragImage(r.current,10,10),I.current=setTimeout(()=>{I.current=null,d(!0)},100)},[e,a,d]),k=Fi(()=>{M()},[M]),B=[{component:xe(yr,{elementId:e})}],q=()=>{if(u==="view")return[];let L=!x.some(H=>{var F;return H.source===e&&((F=b.find(Y=>Y.id===H.target))==null?void 0:F.type)!=="ANNOTATION"});return[{component:xe(Yt,{nodeId:e,disabled:!L,tooltipMessage:L?void 0:i("editor.toolbar.start_event_limit_reached")})},Xt.TASK,Xt.ANNOTATION,...B]},j=()=>u==="view"?[{component:xe(wt,{elementId:e})}]:[{component:xe(wt,{elementId:e})},...N?[]:[{component:xe(Cc,{nodeId:e})}],{component:xe(Yt,{nodeId:e})},Xt.TASK,...Object.values(Rh),...B],C=()=>u==="view"?[{component:xe(wt,{elementId:e})}]:[{component:xe(wt,{elementId:e})},{component:xe(Yt,{nodeId:e})},Xt.TASK,Xt.ANNOTATION,...B],P=()=>u==="view"?[]:[{component:xe(Yt,{nodeId:e})},Xt.ANNOTATION,...B],$=()=>u==="view"?[]:[{component:xe(Yt,{nodeId:e})},Xt.ANNOTATION,...B],V=()=>u==="view"?[]:[{component:xe(Yt,{nodeId:e})},...B],R=()=>u==="view"?[]:[...B],K=(L=>{switch(L){case"START_EVENT":return q();case"TASK":return j();case"GATEWAY":return C();case"END_EVENT":return P();case"LANE":return $();case"ANNOTATION":return V();case"UNSUPPORTED":return R();default:return[]}})(t);if(!(K.length===0||u==="readonly"))return Sc(wh,{position:h,align:"start",className:"-top-8",isVisible:m,children:[xe("div",{ref:n,className:"flex items-center gap-1 px-3 py-2 bg-white rounded-sm shadow-md",children:K.map((L,H)=>{if(L.component)return xe("div",{children:L.component},H);let F={sourceNodeType:t,targetNodeType:L.type,sourceNodeId:e,nodes:b,edges:x},Y=Ll(F),O={gateway_limit_reached:i("editor.toolbar.gateway_limit_reached"),start_event_limit_reached:i("editor.toolbar.start_event_limit_reached"),start_event_already_exists:i("editor.toolbar.start_event_already_exists"),script_to_end_not_allowed:i("editor.toolbar.script_to_end_not_allowed"),loop_to_end_not_allowed:i("editor.toolbar.loop_to_end_not_allowed"),initial_activity_to_end_not_allowed:i("editor.toolbar.initial_activity_to_end_not_allowed"),final_activity_cannot_connect:i("editor.toolbar.final_activity_cannot_connect"),activity_has_outgoing_connections:i("editor.toolbar.activity_has_outgoing_connections"),task_limit_reached:i("editor.toolbar.task_limit_reached")},J=Y.shouldDisable&&Y.reason?O[Y.reason]||i(L.label):i(L.label)||"";return Sc(Ch,{children:[xe(Mh,{asChild:!0,children:xe(Ih,{variant:"ghost",color:"grey",size:"small",iconButton:!0,draggable:!Y.shouldDisable,disabled:Y.shouldDisable,className:Y.shouldDisable?"opacity-50 cursor-not-allowed":"",onDragStart:Y.shouldDisable?void 0:U=>S(U,L),onDragEnd:Y.shouldDisable?void 0:k,children:L.icon&&xe(L.icon,{size:16})})}),xe(Sh,{color:"black",children:J})]},H)})}),xe("div",{ref:r,className:"absolute w-0 h-0 top-0 left-0 z-[-1] bg-transparent",children:E})]})};import{Fragment as Mc,jsx as Je,jsxs as Xi}from"react/jsx-runtime";var Pc=({id:e,data:t,selected:o,dragging:n})=>{let{updateNodeData:r,setNodes:i}=Oh(),{inProgress:a,fromNode:s}=Dh(),{mode:l}=Q(),c=a&&(s==null?void 0:s.id)!==e,d=Wi(p=>{let h=p.split(`
40
- `),E=h.reduce((N,I)=>Math.max(N,I.length),0),w=h.length,b=Math.max(xo.MIN_WIDTH,E*7+32),x=Math.max(xo.MIN_HEIGHT,w*20+24);i(N=>N.map(I=>I.id===e?v(T({},I),{width:b,height:x,style:v(T({},I.style),{width:b,height:x})}):I))},[e,i]),u=Wi(p=>{r(e,{label:p}),d(p)},[e,r,d]),f=Wi(p=>{d(p)},[d]);return Xi("div",{className:D("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",{"text-blue-500 hover:text-blue-600 shadow-md":o,"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:[Je(Ce,{value:t.label,className:"m-1 text-grey-600 text-left",onChange:u,onInput:f,skipFirstCharValidation:!0}),Je(He,{nodeId:e,nodeType:"ANNOTATION"}),l==="edit"&&Je(No,{minWidth:xo.MIN_WIDTH,minHeight:xo.MIN_HEIGHT,isVisible:!n&&o}),!a&&Xi(Mc,{children:[Je(te,{type:"source",position:It.Left,id:"left"}),Je(te,{type:"source",position:It.Right,id:"right"}),Je(te,{type:"source",position:It.Top,id:"top"}),Je(te,{type:"source",position:It.Bottom,id:"bottom"})]}),(!a||c)&&Xi(Mc,{children:[Je(te,{type:"target",position:It.Left,id:"left",className:D({"annotation-handle":c})}),Je(te,{type:"target",position:It.Right,id:"right",className:D({"annotation-handle":c})}),Je(te,{type:"target",position:It.Top,id:"top",className:D({"annotation-handle":c})}),Je(te,{type:"target",position:It.Bottom,id:"bottom",className:D({"annotation-handle":c})})]})]})};import{Position as Ct,useConnection as Vh,useReactFlow as Hh}from"@xyflow/react";import{useState as Gh}from"react";import{Fragment as Lc,jsx as We,jsxs as Ui}from"react/jsx-runtime";var kc=({id:e,data:t,selected:o})=>{let{updateNodeData:n}=Hh(),{inProgress:r,fromNode:i}=Vh(),{reconnectingEdgeId:a}=Q(),[s,l]=Gh(!1),c=r&&(i==null?void 0:i.id)!==e||!!a,d=p=>{n(e,{label:p})},u=()=>{l(!0)},f=()=>{l(!1)};return Ui("div",{className:"relative",onDoubleClick:u,children:[We(jt,{className:D("size-9 hover:stroke-[#d33b3b] transition-colors duration-75",{"stroke-blue-500 hover:stroke-blue-600":o,"stroke-red-500 hover:stroke-red-600 drop-shadow-[0_0_3px_rgba(255,0,0,0.5)] fill-red-100":t.hasError})}),We("div",{className:"absolute top-10 left-1/2 -translate-x-1/2 max-w-80 w-max",children:We(Ce,{value:t.label,isEditing:s,onBlur:f,onChange:d})}),We(He,{nodeId:e,nodeType:"END_EVENT"}),(!r||c)&&Ui(Lc,{children:[We(te,{type:"target",position:Ct.Left,id:"left",className:D({"event-handle":c})}),We(te,{type:"target",position:Ct.Right,id:"right",className:D({"event-handle":c})}),We(te,{type:"target",position:Ct.Top,id:"top",className:D({"event-handle":c})}),We(te,{type:"target",position:Ct.Bottom,id:"bottom",className:D({"event-handle":c})})]}),!r&&Ui(Lc,{children:[We(te,{type:"source",position:Ct.Left,id:"left"}),We(te,{type:"source",position:Ct.Right,id:"right"}),We(te,{type:"source",position:Ct.Top,id:"top"}),We(te,{type:"source",position:Ct.Bottom,id:"bottom"})]})]})};import{Position as St,useConnection as Bh,useReactFlow as zh}from"@xyflow/react";import{useCallback as Yh,useState as Fh}from"react";import{Fragment as Rc,jsx as Xe,jsxs as $i}from"react/jsx-runtime";var Dc=({id:e,data:t,selected:o})=>{let n=mi[t.variant].icon,{updateNodeData:r}=zh(),{inProgress:i,fromNode:a}=Bh(),{reconnectingEdgeId:s}=Q(),[l,c]=Fh(!1),d=i&&(a==null?void 0:a.id)!==e||!!s,u=Yh(g=>{r(e,{label:g})},[e,r]),f=()=>{c(!0)},p=()=>{c(!1)};return $i("div",{className:"relative",onDoubleClick:f,children:[Xe(n,{className:D("size-14 stroke-1 stroke-grey-400 hover:stroke-grey-500 transition-colors duration-75",{"stroke-blue-500 hover:stroke-blue-600":o,"stroke-red-500 hover:stroke-red-600 drop-shadow-[0_0_3px_rgba(255,0,0,0.5)]":t.hasError})}),Xe("div",{className:"absolute top-14 left-1/2 -translate-x-1/2 max-w-80 w-max",children:Xe(Ce,{value:t.label,isEditing:l,onBlur:p,onChange:u})}),Xe(He,{nodeId:e,nodeType:"GATEWAY"}),(!i||d)&&$i(Rc,{children:[Xe(te,{type:"target",position:St.Left,id:"left",className:D({"gateway-handle":d})}),Xe(te,{type:"target",position:St.Right,id:"right",className:D({"gateway-handle":d})}),Xe(te,{type:"target",position:St.Top,id:"top",className:D({"gateway-handle":d})}),Xe(te,{type:"target",position:St.Bottom,id:"bottom",className:D({"gateway-handle":d})})]}),!i&&$i(Rc,{children:[Xe(Le,{type:"source",position:St.Left,id:"left",nodeId:e,nodeType:"GATEWAY",gatewayVariant:t.variant}),Xe(Le,{type:"source",position:St.Right,id:"right",nodeId:e,nodeType:"GATEWAY",gatewayVariant:t.variant}),Xe(Le,{type:"source",position:St.Top,id:"top",nodeId:e,nodeType:"GATEWAY",gatewayVariant:t.variant}),Xe(Le,{type:"source",position:St.Bottom,id:"bottom",nodeId:e,nodeType:"GATEWAY",gatewayVariant:t.variant})]})]})};import{useNodesData as eS,useReactFlow as tS}from"@xyflow/react";import{Button as nS,DropdownMenu as rS,DropdownMenuContent as iS,DropdownMenuGroup as sS,DropdownMenuItem as aS,DropdownMenuLabel as lS,DropdownMenuTrigger as cS,Tooltip as dS,TooltipContent as uS,TooltipTrigger as pS,useTranslation as fS}from"@produto-lecom/lecom-ui";import{WrenchIcon as gS}from"lucide-react";import{jsx as ES,jsxs as bS}from"react/jsx-runtime";import{Position as Mt,useConnection as Wh,useReactFlow as Xh}from"@xyflow/react";import{useState as Uh}from"react";import{Fragment as Oc,jsx as Ue,jsxs as Ki}from"react/jsx-runtime";var Vc=({id:e,data:t,selected:o})=>{let{updateNodeData:n}=Xh(),{inProgress:r,fromNode:i}=Wh(),{reconnectingEdgeId:a}=Q(),[s,l]=Uh(!1),c=r&&(i==null?void 0:i.id)!==e||!!a,d=p=>{n(e,{label:p})},u=()=>{l(!0)},f=()=>{l(!1)};return Ki("div",{className:"relative",onDoubleClick:u,children:[Ue(vn,{className:D("size-9 hover:stroke-[#54890b] transition-colors duration-75",{"stroke-blue-500 hover:stroke-blue-600":o,"stroke-red-500 hover:stroke-red-600 drop-shadow-[0_0_3px_rgba(255,0,0,0.5)] fill-red-100":t.hasError})}),Ue("div",{className:"absolute top-10 left-1/2 -translate-x-1/2 max-w-80 w-max",children:Ue(Ce,{value:t.label,isEditing:s,onBlur:f,onChange:d})}),Ue(He,{nodeId:e,nodeType:"START_EVENT"}),(!r||c)&&Ki(Oc,{children:[Ue(te,{type:"target",position:Mt.Left,id:"left",className:D({"event-handle":c})}),Ue(te,{type:"target",position:Mt.Right,id:"right",className:D({"event-handle":c})}),Ue(te,{type:"target",position:Mt.Top,id:"top",className:D({"event-handle":c})}),Ue(te,{type:"target",position:Mt.Bottom,id:"bottom",className:D({"event-handle":c})})]}),!r&&Ki(Oc,{children:[Ue(Le,{type:"source",position:Mt.Left,id:"left",nodeId:e,nodeType:"START_EVENT"}),Ue(Le,{type:"source",position:Mt.Right,id:"right",nodeId:e,nodeType:"START_EVENT"}),Ue(Le,{type:"source",position:Mt.Top,id:"top",nodeId:e,nodeType:"START_EVENT"}),Ue(Le,{type:"source",position:Mt.Bottom,id:"bottom",nodeId:e,nodeType:"START_EVENT"})]})]})};import{useTranslation as qh}from"@produto-lecom/lecom-ui";import{Position as Pt,useConnection as Zh,useReactFlow as Jh}from"@xyflow/react";import{useCallback as Rr}from"react";var dn=60,kr=(e,t)=>{var a;let o=[],n=`${t} `;for(let s of e){if(!(s.type==="TASK"))continue;let c=(a=s.data)==null?void 0:a.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<=dn?i:i.substring(0,dn).trim()},wo=(e,t)=>{var s;let o=new Set;for(let l of t)l.type==="TASK"&&((s=l.data)!=null&&s.label)&&o.add(l.data.label);let n=e;if(n.length>dn&&(n=n.substring(0,dn).trim()),!o.has(n))return n;let r=n.replace(/\s+\(\d+\)$/,""),i=2,a=o.size+2;for(;i<=a;){let l=` (${i})`,c=dn-l.length,u=`${r.substring(0,c).trim()}${l}`;if(!o.has(u))return u;i++}return n};import{jsx as Hc,jsxs as $h}from"react/jsx-runtime";var Gc=e=>$h("svg",v(T({width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",xmlns:"http://www.w3.org/2000/svg"},e),{children:[Hc("circle",{cx:"12",cy:"12",r:"10",fill:"#10B981"}),Hc("path",{d:"M7 12L10 15L17 8",stroke:"white",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"})]}));import{jsx as Bc}from"react/jsx-runtime";var zc=e=>Bc("svg",v(T({width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",xmlns:"http://www.w3.org/2000/svg"},e),{children:Bc("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 Yc,jsxs as Kh}from"react/jsx-runtime";var Fc=e=>Kh("svg",v(T({width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",xmlns:"http://www.w3.org/2000/svg"},e),{children:[Yc("circle",{cx:"12",cy:"12",r:"10",fill:"#EF4444"}),Yc("path",{d:"M8 8L16 16M8 16L16 8",stroke:"white",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"})]}));import{Fragment as Dr,jsx as me,jsxs as un}from"react/jsx-runtime";var Qh={APROVADO:Gc,EM_ANDAMENTO:zc,REJEITADO:Fc},qi={APROVADO:"border-green-500 border-[3px] border-solid",EM_ANDAMENTO:"border-turquoise-400 border-[3px] border-solid",REJEITADO:"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)]"},Wc=({id:e,data:t,selected:o,dragging:n})=>{let{t:r}=qh(),{toast:i}=Ve(),{updateNodeData:a,getNodes:s,setNodes:l}=Jh(),{inProgress:c,fromNode:d}=Zh(),{mode:u,onSubprocessValidationClick:f,reconnectingEdgeId:p}=Q(),{getTaskStatus:g}=Ot(),y=c&&(d==null?void 0:d.id)!==e||!!p,m=g(e),_=t.variant==="SUBPROCESS",h=!!t.variant&&!_||!!m,E=!!t.attribute||_,w=Rr(B=>{let P=h||E?80:40,$=B.split(`
41
- `),V=$.reduce((L,H)=>Math.max(L,H.length),0),R=$.length,G=Math.max(yo.MIN_WIDTH,V*7+64),K=Math.max(yo.MIN_HEIGHT,R*24+P);l(L=>L.map(H=>H.id===e?v(T({},H),{width:G,height:K,style:v(T({},H.style),{width:G,height:K})}):H))},[e,l,h,E]),b=Rr(B=>{let q=B.trim(),j=t.label||"";if(q===j)return;let C=q,P=s();if(!(q&&q!=="")){C=kr(P,r("bpmn.task.label.prefix")),a(e,{label:C}),w(C),i({variant:"warning",content:un(Dr,{children:[r("bpmn.task.feedback.label_empty.prefix")," ",me("strong",{children:C})]})});return}let V=wo(C,P);V===j||(a(e,{label:V}),w(V),V!==C&&i({variant:"warning",content:un(Dr,{children:[r("bpmn.task.feedback.label_already_exists.prefix")," ",me("strong",{children:q})," ",r("bpmn.task.feedback.label_already_exists.middle")," ",me("strong",{children:V})]})}))},[t.label,s,e,r,a,w,i]),x=Rr(B=>{w(B)},[w]),N=Rr(()=>{i({variant:"error",content:r("bpmn.task.feedback.invalid_first_character")})},[r,i]),I=m?Qh[m]:null,A=t.variant?An[t.variant].icon:null,M=t.attribute?In[t.attribute].icon:null,S=()=>t.hasError?qi.error:m?qi[m]:qi.default,k=()=>{f==null||f({id:e,type:"sub_process",label:t.label})};return un("div",{className:D("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",S(),{"border-blue-500 hover:border-blue-600 shadow-md":o,"border-red-500 hover:border-red-600 shadow-[0_0_5px_rgba(255,0,0,0.5)]":t.hasError}),children:[me("div",{className:"flex-1 flex items-stretch justify-stretch overflow-hidden",children:me(Ce,{value:t.label,maxLength:60,className:D({"py-10 px-8":h||E}),onChange:b,onInput:x,onInvalidFirstCharacter:N})}),A&&me("div",{className:D("absolute flex items-center p-1",_?"bottom-0 left-1/2 -translate-x-1/2":"top-0 left-0"),children:me(A,{size:16,className:D(t.hasError?"text-red-500":"text-grey-500",_&&"cursor-pointer"),onClick:_?k:void 0})}),M&&me("div",{className:"absolute bottom-0 left-0 w-full flex items-center justify-center",children:me("div",{className:D("flex items-center w-16 p-1",_?"justify-between":"justify-center"),children:me(M,{size:16,className:D(t.hasError?"text-red-500":"text-grey-500")})})}),I&&me("div",{className:"absolute top-0 right-0 flex items-center p-1",children:me(I,{})}),me(He,{nodeId:e,nodeType:"TASK",nodeVariant:t.variant}),u==="edit"&&me(No,{minWidth:yo.MIN_WIDTH,minHeight:yo.MIN_HEIGHT,isVisible:!n&&o}),(!c||y)&&un(Dr,{children:[me(te,{type:"target",position:Pt.Left,id:"left",className:D({"task-handle":y})}),me(te,{type:"target",position:Pt.Right,id:"right",className:D({"task-handle":y})}),me(te,{type:"target",position:Pt.Top,id:"top",className:D({"task-handle":y})}),me(te,{type:"target",position:Pt.Bottom,id:"bottom",className:D({"task-handle":y})})]}),!c&&un(Dr,{children:[me(Le,{type:"source",position:Pt.Left,id:"left",nodeId:e,nodeType:"TASK"}),me(Le,{type:"source",position:Pt.Right,id:"right",nodeId:e,nodeType:"TASK"}),me(Le,{type:"source",position:Pt.Top,id:"top",nodeId:e,nodeType:"TASK"}),me(Le,{type:"source",position:Pt.Bottom,id:"bottom",nodeId:e,nodeType:"TASK"})]})]})};import{Position as Xc}from"@xyflow/react";import{Fragment as jh,jsx as Or,jsxs as ey}from"react/jsx-runtime";var Uc=({id:e,data:t})=>ey(jh,{children:[Or("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}),Or(He,{nodeId:e,nodeType:"UNSUPPORTED"}),Or(te,{type:"source",position:Xc.Right}),Or(te,{type:"target",position:Xc.Left})]});import{BaseEdge as ty,EdgeLabelRenderer as oy,getSmoothStepPath as ny,MarkerType as ry,useInternalNode as $c,useReactFlow as iy,useViewport as sy,Position as Ao}from"@xyflow/react";import{useState as ay,useMemo as ly}from"react";import{Fragment as Kc,jsx as Ge,jsxs as Ut}from"react/jsx-runtime";var t5={type:"MESSAGE_EDGE",reconnectable:!0,markerEnd:{type:ry.Arrow},data:{label:""}},qc=({id:e,source:t,target:o,data:n,selected:r,sourcePosition:i,targetPosition:a,sourceHandleId:s,targetHandleId:l})=>{var H;let{zoom:c}=sy(),{updateEdgeData:d}=iy(),{isMultipleSelection:u,mode:f,instanceId:p}=Q(),g=f!=="edit",[y,m]=ay(!1),{reconnectingHandle:_,cursorPosition:h,hoveredNodeId:E,reconnectingSide:w,isValidReconnection:b,handleReconnectStart:x}=Ir({edgeId:e,source:t,target:o,instanceId:p,isReadOnly:g}),N=$c(t),I=$c(o),{sx:A,sy:M,tx:S,ty:k,sourcePos:B,targetPos:q}=ly(()=>{var le,ce;if(!N||!I)return{sx:0,sy:0,tx:0,ty:0,sourcePos:Ao.Left,targetPos:Ao.Right};let F=no(N,I),Y=s?i:F.sourcePos,O=l?a:F.targetPos,J=(de,ue,ge)=>{var ve,ke,yt,Jt,Qt,Ee;let{x:he,y:fe}=de.internals.positionAbsolute,se=(yt=(ke=(ve=de.measured)==null?void 0:ve.width)!=null?ke:de.width)!=null?yt:0,ie=(Ee=(Qt=(Jt=de.measured)==null?void 0:Jt.height)!=null?Qt:de.height)!=null?Ee:0;switch(ue){case Ao.Top:return{x:he+se*ge,y:fe};case Ao.Bottom:return{x:he+se*ge,y:fe+ie};case Ao.Left:return{x:he,y:fe+ie*ge};case Ao.Right:return{x:he+se,y:fe+ie*ge};default:return{x:he+se/2,y:fe+ie/2}}},U=(le=n==null?void 0:n.sourceOffset)!=null?le:.5,X=(ce=n==null?void 0:n.targetOffset)!=null?ce:.5,z=N?J(N,Y,U).x:F.sx,W=N?J(N,Y,U).y:F.sy,Z=I?J(I,O,X).x:F.tx,ee=I?J(I,O,X).y:F.ty;return _==="source"&&h?(z=h.x,W=h.y,w&&(Y=w)):_==="target"&&h&&(Z=h.x,ee=h.y,w&&(O=w)),{sx:z,sy:W,tx:Z,ty:ee,sourcePos:Y,targetPos:O}},[N,I,s,l,i,a,_,h,w,n==null?void 0:n.sourceOffset,n==null?void 0:n.targetOffset]);if(!N||!I)return null;let[j,C,P]=ny({sourceX:A,sourceY:M,targetX:S,targetY:k,sourcePosition:B,targetPosition:q}),$=r||(N==null?void 0:N.selected)||(I==null?void 0:I.selected),V=$?"sequence-edge-marker-highlighted":"sequence-edge-marker",R=y||(n==null?void 0:n.label.trim().length)>0,G=()=>{m(!0)},K=()=>{m(!1)},L=F=>{d(e,{label:F.trim()})};return Ge(Kc,{children:Ut("g",{onDoubleClick:G,children:[Ge("path",{d:j,fill:"none",stroke:"transparent",strokeWidth:Math.max(12,12/c),style:{pointerEvents:"stroke",cursor:"pointer"}}),Ut("g",{className:D("text-grey-500 hover:text-grey-600",{"text-blue-500 hover:text-blue-600":$}),children:[Ge(ty,{id:e,path:j,interactionWidth:0,markerEnd:`url(#${V})`,strokeDasharray:4,className:D("stroke-2 stroke-current transition-colors duration-75",{"stroke-red-500 hover:stroke-red-600":(n==null?void 0:n.hasError)||_&&E&&!b,"stroke-green-500":_&&E&&b,"stroke-blue-500 hover:stroke-blue-600 drop-shadow-[0_0_3px_rgba(59,130,246,0.5)]":$&&!(n!=null&&n.hasError)&&!_})}),Ut(oy,{children:[Ut("div",{className:"absolute z-[3000] pointer-events-auto flex flex-col items-center gap-1",style:{transform:`translate(-50%, -50%) translate(${C}px, ${P}px)`},children:[r&&!u&&Ge(uo,{sx:A,sy:M,tx:S,ty:k,hasLabel:!!((H=n==null?void 0:n.label)!=null&&H.trim()),children:Ge(co,{edgeId:e,edgeType:"MESSAGE_EDGE"})}),R&&Ge(Ce,{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:y,onBlur:K,onChange:L})]}),r&&!u&&!g&&Ut(Kc,{children:[Ge("div",{className:"absolute z-[1000] pointer-events-none",style:{transform:`translate(-50%, -50%) translate(${A}px, ${M}px)`},children:Ut("svg",{width:12/c,height:12/c,style:{overflow:"visible",position:"absolute",left:"50%",top:"50%",transform:"translate(-50%, -50%)"},children:[Ge("circle",{cx:6/c,cy:6/c,r:4/c,fill:_==="source"?"#3b82f6":"#fff",stroke:"#3b82f6",strokeWidth:2/c,className:"pointer-events-none"}),Ge("circle",{cx:6/c,cy:6/c,r:6/c,fill:"none",stroke:"#3b82f6",strokeWidth:1/c,opacity:_==="source"?.6:.3,className:"pointer-events-none"}),Ge("circle",{cx:6/c,cy:6/c,r:8/c,fill:"transparent",className:D("pointer-events-auto",{"cursor-move":!_||_!=="source","cursor-not-allowed":_==="source"&&E&&!b,"cursor-grabbing":_==="source"&&(!E||b)}),onMouseDown:F=>x("source",F.nativeEvent)})]})}),Ge("div",{className:"absolute z-[1000] pointer-events-none",style:{transform:`translate(-50%, -50%) translate(${S}px, ${k}px)`},children:Ut("svg",{width:12/c,height:12/c,style:{overflow:"visible",position:"absolute",left:"50%",top:"50%",transform:"translate(-50%, -50%)"},children:[Ge("circle",{cx:6/c,cy:6/c,r:4/c,fill:_==="target"?"#3b82f6":"#fff",stroke:"#3b82f6",strokeWidth:2/c,className:"pointer-events-none"}),Ge("circle",{cx:6/c,cy:6/c,r:6/c,fill:"none",stroke:"#3b82f6",strokeWidth:1/c,opacity:_==="target"?.6:.3,className:"pointer-events-none"}),Ge("circle",{cx:6/c,cy:6/c,r:8/c,fill:"transparent",className:D("pointer-events-auto",{"cursor-move":!_||_!=="target","cursor-not-allowed":_==="target"&&E&&!b,"cursor-grabbing":_==="target"&&(!E||b)}),onMouseDown:F=>x("target",F.nativeEvent)})]})})]})]})]})]})})};import{getStraightPath as cy,Position as Vr}from"@xyflow/react";import{jsx as Zc,jsxs as dy}from"react/jsx-runtime";var Jc=({toX:e,toY:t,fromNode:o})=>{var u,f;if(!o)return null;let{internals:{positionAbsolute:{x:n,y:r}},measured:i}=o,a=(u=i.width)!=null?u:0,s=(f=i.height)!=null?f:0,c=[{x:n,y:r+s/2,pos:Vr.Left},{x:n+a,y:r+s/2,pos:Vr.Right},{x:n+a/2,y:r,pos:Vr.Top},{x:n+a/2,y:r+s,pos:Vr.Bottom}].reduce((p,g)=>{let y=Math.hypot(e-p.x,t-p.y);return Math.hypot(e-g.x,t-g.y)<y?g:p}),[d]=cy({sourceX:c.x,sourceY:c.y,targetX:e,targetY:t});return dy("g",{children:[Zc("path",{fill:"none",className:"stroke-2 stroke-grey-500 animated",d}),Zc("circle",{cx:e,cy:t,fill:"none",r:4,className:"stroke-2 stroke-grey-600"})]})};import{Position as Lt,useConnection as uy,useReactFlow as py}from"@xyflow/react";import{orderBy as fy}from"lodash";import{useMemo as Qc,useState as my}from"react";import{Fragment as Zi,jsx as Be,jsxs as Hr}from"react/jsx-runtime";var jc=({id:e,data:t,selected:o,dragging:n,parentId:r})=>{let{updateNodeData:i,getNodes:a}=py(),{mode:s}=Q(),{inProgress:l,fromNode:c}=uy(),d=l&&(c==null?void 0:c.id)!==e,[u,f]=my(!1),p=a(),g=!r,y=Qc(()=>fy([...p.filter(b=>b.parentId===e&&b.type==="LANE")],"position.y","asc"),[p,e]),m=g?Pr.MIN_WIDTH:ye.MIN_WIDTH,_=Qc(()=>{if(g&&y.length>1){let b=[...y];return b.pop(),b.reduce((N,I)=>{var A,M;return N+((M=(A=I.measured)==null?void 0:A.height)!=null?M:0)},0)+ye.MIN_HEIGHT}return ye.MIN_HEIGHT},[g,y]),h=b=>{i(e,{label:b})},E=()=>{f(!0)},w=()=>{f(!1)};return Hr(Zi,{children:[Hr("div",{className:D("flex h-full min-h-64 w-full min-w-[50rem] hover:shadow-md bg-white outline outline-1 outline-grey-300",{"outline-offset-2 outline-blue-500 shadow-sm":o}),children:[Be("div",{className:"flex align-items justify-center w-10 border-r border-grey-300",onDoubleClick:E,children:Be("div",{className:"relative flex-1 [writing-mode:vertical-rl] [text-orientation:sideways] transform rotate-180",children:Be(Ce,{value:t.label,className:"w-full h-full self-auto",contentClassName:D({"whitespace-nowrap":u}),isEditing:u,onBlur:w,onChange:h})})}),Be("div",{className:"flex-1"})]}),Be(He,{nodeId:e,nodeType:"LANE",isChild:!g}),s==="edit"&&Be(No,{nodeId:e,minWidth:m,minHeight:_,isVisible:!n&&o}),!l&&Hr(Zi,{children:[Be(te,{type:"source",position:Lt.Left,id:"left"}),Be(te,{type:"source",position:Lt.Right,id:"right"}),Be(te,{type:"source",position:Lt.Top,id:"top"}),Be(te,{type:"source",position:Lt.Bottom,id:"bottom"})]}),(!l||d)&&Hr(Zi,{children:[Be(te,{type:"target",position:Lt.Left,id:"left",className:D({"annotation-handle":d})}),Be(te,{type:"target",position:Lt.Right,id:"right",className:D({"annotation-handle":d})}),Be(te,{type:"target",position:Lt.Top,id:"top",className:D({"annotation-handle":d})}),Be(te,{type:"target",position:Lt.Bottom,id:"bottom",className:D({"annotation-handle":d})})]})]})};var ed={START_EVENT:Vc,END_EVENT:kc,TASK:Wc,GATEWAY:Dc,ANNOTATION:Pc,LANE:jc,UNSUPPORTED:Uc},td={SEQUENCE_EDGE:Jl,MESSAGE_EDGE:qc,ANNOTATION_EDGE:Ol},od="#fafafa",nd="#bebebe",rd=1,id=10,sd="bottom-left",Ji=.05,ad=5,Io=.5,Co=Ji,So=1,ld={x:0,y:0,zoom:.75},cd=1,dd=2,gy={[cd]:4,[dd]:2},Gr=[cd,dd],ud=Gr.reduce((e,t)=>e|gy[t],0);import{useReactFlow as hy}from"@xyflow/react";var $e=()=>{let{getEdges:e,getNodes:t}=hy(),{lastElementId:o}=Q(),n=()=>{let i=t(),a=e(),s=bc(i,a);return Math.max(s,o)};return{getLastId:n,getNextId:()=>n()+1}};var Mo=()=>{let{getNodes:e,getEdges:t,setNodes:o,setEdges:n,setViewport:r}=xy(),{getLastId:i}=$e(),a=Ey(),{setLastElementId:s}=Q(),l=pd(async(d="")=>{let{nodes:u,edges:f,lastElementId:p}=await Tc(d),{width:g,height:y}=a.getState();if(g>0&&y>0){let m=mc(u);m&&r(yy(m,g,y,Co,So,Io))}o(u),n(f),s(p)},[o,n,s,a,r]),c=pd(()=>{let d=e(),u=t(),f=i();return _c(d,u,f)},[e,t,i]);return{importFromMxGraph:l,exportToMxGraph:c}};import{useCallback as fd}from"react";var _y=500,Br=()=>{let{isInitialized:e,onElementChanges:t}=Q(),{exportToMxGraph:o}=Mo(),n=by(()=>{if(!e)return;let a=o();t==null||t(a)},_y),r=fd(a=>{a.every(c=>c.type==="select")||a.some(c=>c.type==="position"&&c.dragging)||n()},[n]),i=fd(a=>{a.some(l=>l.type==="select")||n()},[n]);return{emitElementChanges:n,handleNodeChanges:r,handleEdgeChanges:i}};var md=({setEdges:e,saveHistory:t})=>{let{getNode:o,getEdges:n,getNodes:r,getInternalNode:i}=Ny(),{emitElementChanges:a}=Br(),s=vy(null),{getNextId:l}=$e(),c=$t(m=>{var b;let _=o(m.source),h=o(m.target);if(!_||!h)return!1;let E={sourceNodeId:_.id,targetNodeId:h.id,sourceNodeType:_.type,targetNodeType:h.type,nodes:r(),edges:n(),reconnectingEdgeId:(b=s.current)!=null?b:void 0};return Li(E).isValid},[o,n,r]),d=$t(m=>{var E,w;let _=l(),h=i(m.source);if(h){let b=i(m.target),x=b?b.internals.positionAbsolute.x+((E=b.measured.width)!=null?E:0)/2:0,N=b?b.internals.positionAbsolute.y+((w=b.measured.height)!=null?w:0)/2:0,I=Ql(h,x,N),A=(b==null?void 0:b.type)==="ANNOTATION"||(h==null?void 0:h.type)==="ANNOTATION",M=A?fo:Fe,S;if(!A&&b&&m.targetHandle){let q=Sr(I),j=Sr(m.targetHandle),{x:C,y:P}=Oi(h,I),{x:$,y:V}=Oi(b,m.targetHandle),G=wr(C,P,$,V,q,j).slice(1,-1);G.length>0&&(S=G)}let k=v(T(T({},m),M),{id:String(_),sourceHandle:I,data:T(T({},A?{}:Fe.data),S?{points:S}:{})}),B=n().concat(k);e(B),t("forceSave",{nodes:r(),edges:B}),a()}},[l,e,a,i,n,r,t]),u=$t((m,_)=>{s.current=_.id},[]),f=$t(()=>{s.current=null},[]),p=$t((m,_)=>{let h=o(_.source),E=o(_.target);if(!h||!E){s.current=null;return}let w={sourceNodeId:h.id,targetNodeId:E.id,sourceNodeType:h.type,targetNodeType:E.type,nodes:r(),edges:n(),reconnectingEdgeId:m.id};if(!Li(w).isValid){s.current=null;return}let x=Ty(m,_,n()).map(N=>N.id===m.id?v(T({},N),{data:v(T({},N.data),{points:void 0})}):N);e(x),t("forceSave",{nodes:r(),edges:x}),s.current=null,a()},[o,r,n,e,a,t]),g=$t(m=>{s.current=m},[]),y=$t(()=>{s.current=null},[]);return{isValidConnection:c,onConnect:d,onReconnect:p,onReconnectStart:u,onReconnectEnd:f,setReconnectingEdge:g,clearReconnectingEdge:y}};import{useTranslation as wy}from"@produto-lecom/lecom-ui";import{useReactFlow as Ay}from"@xyflow/react";import{useCallback as gn,useRef as Nd,useState as Iy}from"react";var pn=(e=[])=>e.filter(t=>t.type==="START_EVENT"),Kt=(e=[])=>e.filter(t=>t.type==="END_EVENT"),kt=(e=[])=>e.filter(t=>t.type==="TASK")||[],gd=(e=[])=>e.filter(t=>{var o;return t.type==="TASK"&&((o=t.properties)==null?void 0:o.variant)==="SCRIPT"}),hd=(e=[])=>e.filter(t=>{var o;return t.type==="TASK"&&((o=t.properties)==null?void 0:o.variant)==="SUBPROCESS"}),zr=(e=[])=>e.filter(t=>t.type==="GATEWAY"),yd=(e=[])=>e.filter(t=>{var o;return t.type==="GATEWAY"&&((o=t.properties)==null?void 0:o.variant)==="EXCLUSIVE"}),ze=(e,t=[])=>t.filter(o=>o.source===e),fn=(e,t=[])=>t.filter(o=>o.target===e),xd=(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"},Ed=(e,t)=>{let o=ze(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},bd=e=>e?/[^\s]/.test(e.trim()):!1,pe=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:[]}},st=(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)}},_d=(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:t.map(o=>({id:o.id,source:o.source,target:o.target,type:o.type||"default"}))});var mn=[{id:"start_event_not_found",validate:e=>{let t=pn(e.nodes);return pe({isValid:t.length>=1})}},{id:"end_event_not_found",validate:e=>{let t=Kt(e.nodes);return pe({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 pe({isValid:!0});if(!o)return pe({isValid:!1,nodeIds:t.map(i=>i.id)});let n=ze(t[0].id,e.edges);if(!(n.length<=1)){let i=[...t.map(a=>a.id),...n.map(a=>a.target)];return pe({isValid:!1,nodeIds:[...new Set(i)]})}return pe({isValid:!0})}},{id:"task_flows_limit_exceeds",validate:e=>{let t=kt(e.nodes),o=st(t,n=>ze(n.id,e.edges).length<=2);return pe({isValid:o.isValid,nodeIds:o.invalidIds})}},{id:"task_label_empty",highlightRelatedEdges:!1,validate:e=>{let t=kt(e.nodes),o=st(t,n=>!!n.label&&n.label.trim()!=="");return pe({isValid:o.isValid,nodeIds:o.invalidIds})}},{id:"task_label_length",highlightRelatedEdges:!1,validate:e=>{let o=kt(e.nodes),n=st(o,r=>!r.label||r.label.length<=60);return pe({isValid:n.isValid,nodeIds:n.invalidIds})}},{id:"duplicate_task_name",highlightRelatedEdges:!1,validate:e=>{let t=kt(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 pe({isValid:n.length===0,nodeIds:n})}},{id:"nested_gateway",validate:e=>{let t=zr(e.nodes),o=[],n=[];for(let r of t){let i=ze(r.id,e.edges);for(let a of i){let s=e.nodes.find(l=>l.id===a.target);s&&s.type==="GATEWAY"&&(o.push(r.id,s.id),n.push(a.id))}}return pe({isValid:o.length===0,nodeIds:o.length>0?[...new Set(o)]:[],edgeIds:n})}},{id:"events_nested",validate:e=>{let t=[...pn(e.nodes),...Kt(e.nodes)],o=[],n=[];for(let r of t){let i=ze(r.id,e.edges);for(let a of i){let s=e.nodes.find(l=>l.id===a.target);s&&(s.type==="START_EVENT"||s.type==="END_EVENT")&&(o.push(r.id,s.id),n.push(a.id))}}return pe({isValid:o.length===0,nodeIds:o.length>0?[...new Set(o)]:[],edgeIds:n})}},{id:"flows_on_end_tasks_not_allowed",validate:e=>{let t=Kt(e.nodes),o=[],n=[];for(let r of t){let i=fn(r.id,e.edges);for(let a of i){let s=e.nodes.find(l=>l.id===a.source);if(s&&s.type==="TASK"){let l=ze(s.id,e.edges);l.length>1&&(o.push(s.id),l.forEach(c=>n.push(c.id)))}}}return pe({isValid:o.length===0,nodeIds:o,edgeIds:n})}},{id:"conditions_flows_limit_exceeds",validate:e=>{let t=yd(e.nodes),o=st(t,r=>ze(r.id,e.edges).length<=2),n=o.invalidIds.flatMap(r=>ze(r,e.edges).map(i=>i.id));return pe({isValid:o.isValid,nodeIds:o.invalidIds,edgeIds:n})}},{id:"activity_name_invalid",validate:e=>{let t=kt(e.nodes),o=st(t,n=>!n.label||bd(n.label));return pe({isValid:o.isValid,nodeIds:o.invalidIds})}},{id:"final_activity_has_loop",validate:e=>{var a,s;if(!((a=e==null?void 0:e.nodes)!=null&&a.length)||!((s=e==null?void 0:e.edges)!=null&&s.length))return pe({isValid:!0});let t=Kt(e.nodes)[0];if(!t)return pe({isValid:!0});let o=fn(t.id,e.edges);if(!o.length)return pe({isValid:!0});let r=kt(e.nodes).filter(l=>o.some(c=>c.source===l.id)),i=st(r,l=>!xd(l.id,e));return pe({isValid:i.isValid,nodeIds:i.isValid?[]:[t.id,...i.invalidIds]})}},{id:"concurrent_initial_and_final_event",validate:e=>{let t=kt(e.nodes),o=Kt(e.nodes)[0];if(!o)return pe({isValid:!0});let n=t.filter(l=>{let c=fn(l.id,e.edges),d=ze(l.id,e.edges),u=c.some(p=>{var g;return((g=e.nodes.find(y=>y.id===p.source))==null?void 0:g.type)==="START_EVENT"}),f=d.some(p=>{var g;return((g=e.nodes.find(y=>y.id===p.target))==null?void 0:g.type)==="END_EVENT"});return u&&f}),r=fn(o.id,e.edges),i=r.length>1,a=r.map(l=>l.source),s={isValid:n.length===0&&!i,nodeIds:[...n.map(l=>l.id),...i?a:[]]};return pe(s)}},{id:"gateway_flow_to_event",validate:e=>{let t=zr(e.nodes),o=[],n=[];for(let r of t){let i=ze(r.id,e.edges);for(let a of i){let s=e.nodes.find(l=>l.id===a.target);s&&s.type==="END_EVENT"&&(o.push(r.id,s.id),n.push(a.id))}}return pe({isValid:o.length===0,nodeIds:o.length>0?[...new Set(o)]:[],edgeIds:n})}},{id:"gateway_missing_output_streams",validate:e=>{let t=zr(e.nodes),o=st(t,n=>ze(n.id,e.edges).length>=1);return pe({isValid:o.isValid,nodeIds:o.invalidIds})}},{id:"event_to_condition",validate:e=>{let t=[...pn(e.nodes),...Kt(e.nodes)],o=[],n=[];for(let r of t){let i=ze(r.id,e.edges);for(let a of i){let s=e.nodes.find(l=>l.id===a.target);s&&s.type==="GATEWAY"&&(o.push(r.id,s.id),n.push(a.id))}}return pe({isValid:o.length===0,nodeIds:o.length>0?[...new Set(o)]:[],edgeIds:n})}},{id:"script_in_final_activity",validate:e=>{let t=gd(e.nodes),o=st(t,n=>!Ed(n.id,e));return pe({isValid:o.isValid,nodeIds:o.invalidIds})}},{id:"subprocess_referenced_not_configured",validate:e=>{let t=hd(e.nodes),o=st(t,n=>{var r,i;return((r=n.properties)==null?void 0:r.subprocessRef)!==void 0&&((i=n.properties)==null?void 0:i.subprocessRef)!==""});return pe({isValid:o.isValid,nodeIds:o.invalidIds})}}];var Td=e=>{e=e||{nodes:[],edges:[]},e.nodes=e.nodes||[],e.edges=e.edges||[];let t=[];for(let n of mn){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}};import{jsx as Yr,jsxs as Cy}from"react/jsx-runtime";var vd=()=>{let{t:e}=wy(),{toast:t}=Ve(),{setNodes:o,setEdges:n,getNodes:r,getEdges:i}=Ay(),[a,s]=Iy(!1),l=Nd(!1),c=Nd(!1),d=gn(y=>{let m=_d(y.nodes,y.edges),_=Td(m),h=_.errors.map(E=>v(T({},E),{message:e(`validation.errors.${E.id}`)}));return a||s(!0),{isValid:_.isValid,errors:h}},[a,e]),u=gn((y,m=!0)=>{if(m&&y&&t({variant:y.isValid?"success":"error",duration:5e3,title:y.isValid?e("validation.success.title"):e("validation.errors.title"),content:Cy("div",{className:"flex flex-col gap-1",children:[!y.isValid&&Yr("span",{className:"body-small-500",children:e("validation.errors.subtitle")}),Yr("ul",{className:"list-disc list-inside max-h-40 overflow-y-auto",children:y.isValid?Yr("li",{children:e("validation.success.message")}):y.errors.map(S=>Yr("li",{className:"text-xs",children:S.message},S.id))})]})}),!y)return;l.current=!0,c.current=!0;let _=[],h=[];y.errors.forEach(S=>{S.nodeIds&&S.nodeIds.length>0&&S.nodeIds.forEach(k=>_.push(k)),S.edgeIds&&S.edgeIds.length>0&&S.edgeIds.forEach(k=>h.push(k))});let E=[...new Set(_)];o(S=>S.map(k=>v(T({},k),{data:v(T({},k.data),{hasError:!1})}))),n(S=>S.map(k=>v(T({},k),{data:v(T({},k.data),{hasError:!1})})));let w=r(),b=i(),x=new Set(E),N=new Set;y.errors.forEach(S=>{var q,j;let k=mn.find(C=>C.id===S.id);(k==null?void 0:k.highlightRelatedEdges)!==!1&&((q=S.edgeIds)==null||q.forEach(C=>N.add(C)),(j=S.nodeIds)==null||j.forEach(C=>{b.forEach(P=>{(P.source===C||P.target===C)&&N.add(P.id)})}))});let I=new Set,A=new Set,M=new Set;w.forEach(S=>{S.type==="START_EVENT"?I.add(S.id):S.type==="END_EVENT"&&A.add(S.id)}),b.forEach(S=>{I.has(S.source)&&M.add(S.target),A.has(S.target)&&M.add(S.source)}),M.forEach(S=>{var k,B;if(x.has(S)){let q=(k=y.errors.find(C=>{var P;return(P=C.nodeIds)==null?void 0:P.includes(S)}))==null?void 0:k.id;((B=mn.find(C=>C.id===q))==null?void 0:B.highlightRelatedEdges)!==!1&&b.forEach(C=>{C.source===S&&A.has(C.target)&&(x.add(C.target),N.add(C.id)),C.target===S&&I.has(C.source)&&(x.add(C.source),N.add(C.id))})}}),x.size>0&&o(S=>S.map(k=>v(T({},k),{data:v(T({},k.data),{hasError:x.has(k.id)})}))),N.size>0&&n(S=>S.map(k=>v(T({},k),{data:v(T({},k.data),{hasError:N.has(k.id)})}))),setTimeout(()=>{l.current=!1},0)},[e,i,r,n,o,t]),f=gn(()=>{s(!1),c.current=!1,o(y=>y.map(m=>v(T({},m),{data:v(T({},m.data),{hasError:!1})}))),n(y=>y.map(m=>v(T({},m),{data:v(T({},m.data),{hasError:!1})})))},[n,o]),p=gn(()=>{c.current&&(l.current=!0,c.current=!1,o(y=>y.map(m=>v(T({},m),{data:v(T({},m.data),{hasError:!1})}))),n(y=>y.map(m=>v(T({},m),{data:v(T({},m.data),{hasError:!1})}))),setTimeout(()=>{l.current=!1},0))},[n,o]),g=gn(()=>l.current,[]);return{validateDiagram:d,handleValidationComplete:u,clearValidation:f,dismissValidationPanel:p,isAutoValidationEnabled:a,getIsClearingValidation:g}};import{useReactFlow as Sy}from"@xyflow/react";import{useTranslation as My}from"@produto-lecom/lecom-ui";import{useEffect as Py}from"react";var Ly=15,wd="bpmn:selection",ky=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},Ad=e=>{if(!ky(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},Id=({offset:e=Ly,saveHistory:t})=>{let{t:o}=My(),{getNodes:n,setNodes:r,getEdges:i,setEdges:a}=Sy(),{getNextId:s}=$e();Py(()=>{let l=d=>{var _,h;if(!Ad(d))return;let u=n(),f=i(),p=u.filter(E=>E.selected);if(!p.length)return;d.preventDefault(),d.stopPropagation();let g=f.filter(E=>p.some(w=>w.id===E.source)&&p.some(w=>w.id===E.target)),m=JSON.stringify({nodes:p,edges:g});(_=d.clipboardData)==null||_.setData(wd,m),(h=d.clipboardData)==null||h.setData("text/plain",`BPMN Selection: ${p.length} nodes`)},c=d=>{var N,I;if(!Ad(d))return;let u=(N=d.clipboardData)==null?void 0:N.getData(wd);if(!u)return;d.preventDefault(),d.stopPropagation();let f;try{f=JSON.parse(u)}catch(A){return}if(!((I=f.nodes)!=null&&I.length))return;let p=new Map,g=n(),y=[],m=f.nodes.filter(A=>Nt(A.type,g));if(m.length===0)return;let _=s(),h=m.map(A=>{var k;let M=String(_++);p.set(A.id,M);let S=v(T({},A),{id:M,selected:!0,position:{x:A.position.x+e,y:A.position.y+e}});if(A.type==="TASK"){let B=(k=A.data)==null?void 0:k.label,q=wo(B||o("bpmn.task.label.prefix"),[...g,...y]);S.data=v(T({},A.data),{label:q})}return y.push(S),S}),E=f.edges.map(A=>v(T({},A),{id:String(_++),selected:!0,source:p.get(A.source)||A.source,target:p.get(A.target)||A.target})),w=[...g.map(A=>v(T({},A),{selected:!1})),...h],x=[...i().map(A=>v(T({},A),{selected:!1})),...E];r(w),a(x),t("forceSave",{nodes:w,edges:x})};return document.addEventListener("copy",l,!0),document.addEventListener("paste",c,!0),()=>{document.removeEventListener("copy",l,!0),document.removeEventListener("paste",c,!0)}},[n,r,i,a,s,e,o,t])};import{useReactFlow as Ry,useStoreApi as Dy}from"@xyflow/react";import{useTranslation as Oy}from"@produto-lecom/lecom-ui";import{useState as Vy}from"react";var Cd=({nodes:e,setNodes:t,setEdges:o,saveHistory:n})=>{let r=Dy(),{draggableNode:i,setDraggableNode:a}=vo(),{t:s}=Oy(),{getInternalNode:l,getNodes:c,getEdges:d,screenToFlowPosition:u}=Ry(),{getNextId:f}=$e(),{setIsDragging:p}=Q(),{rebuildIndex:g,forceRebuildIndex:y}=sr(),[m,_]=Vy(null),h=(C,P=!1)=>{let $=P?"node-drop-target-error":"node-drop-target",V=P?"node-drop-target-lane-error":"node-drop-target-lane";t(R=>R.map(G=>G.id===C?v(T({},G),{className:$}):C!==void 0&&G.parentId===C&&G.type==="LANE"?v(T({},G),{className:V}):v(T({},G),{className:""})))},E=()=>{let{nodeLookup:C}=r.getState();return Array.from(C.values())},w=(C,P)=>{let $=E();if(C.type==="LANE"){if(P){h();return}let L=$.filter(Y=>Y.id!==C.id&&Y.type==="LANE"&&!Y.parentId),H=rn(C,L);if(!H){h();return}if(To({parentId:H.id,nodes:e,excludeTypes:["LANE"]})){h(H.id,!0);return}h(H.id);return}let R=$.filter(L=>L.id!==C.id&&L.type==="LANE"),G=rn(C,R);if(!G){h();return}if(To({parentId:G.id,nodes:e,includeTypes:["LANE"]})){h();return}h(G.id)},b=C=>{let P=l(C.id),$=C.type==="LANE"&&To({parentId:C.id,nodes:e,includeTypes:["LANE"]});w(P,$)},x=C=>C.map(P=>v(T({},P),{className:void 0})),N=C=>C.some($=>$.dragging)?C.map($=>$.dragging?v(T({},$),{dragging:!1}):$):C,I=C=>{if(C.preventDefault(),C.dataTransfer.dropEffect="move",!(i!=null&&i.type))return;let P=u({x:C.clientX,y:C.clientY}),$={id:"__sidebar_drag__",type:i.type,position:P,measured:{width:1,height:1},internals:{positionAbsolute:P}};w($,!1)},A=C=>{let P=C.relatedTarget;(!P||!C.currentTarget.contains(P))&&h()},M=(C,P)=>{C.preventDefault(),b(P)},S=(C,P,$)=>{var L,H;let V=[...$];if(C.parentId===P.id)return V=yc(C,P,V),V=sn(V),x(V);if(C.type==="LANE"){if(To({parentId:P.id,nodes:V,excludeTypes:["LANE"]})){let U=dt(P),X=50,z=50;return V.map(W=>{var Z,ee;return W.id===C.id?v(T({},W),{position:{x:(Z=m==null?void 0:m.x)!=null?Z:U.x+X,y:(ee=m==null?void 0:m.y)!=null?ee:U.y2+z}}):W})}let O=V.filter(U=>U.parentId===P.id).reduce((U,X)=>{var z,W;return U+((W=(z=X.measured)==null?void 0:z.height)!=null?W:0)},0),J={x:ye.HEADER_WIDTH,y:O};return V=V.map(U=>U.id===C.id?v(T({},U),{parentId:P.id,position:J,className:void 0}):v(T({},U),{className:void 0})),V=an(P.id,V),V}if(To({parentId:P.id,nodes:V,includeTypes:["LANE"]})){let F;if(C.parentId){let Y=l(C.parentId),{x:O,y:J}=mt(Y);F={x:O+((L=C.position.x)!=null?L:0),y:J+((H=C.position.y)!=null?H:0)}}return V=V.map(Y=>Y.id===C.id?v(T({},Y),{position:F!=null?F:Y.position,parentId:void 0,className:void 0}):v(T({},Y),{className:void 0})),V}let K=uc(C,P);return V=V.map(F=>{if(F.id===C.id){let Y=dt(C),O=dt(P);return Y.y<O.y&&(K.y=0),Y.x<O.x+ye.HEADER_WIDTH&&(K.x=ye.HEADER_WIDTH),v(T({},F),{parentId:P.id,position:K,className:void 0})}return v(T({},F),{className:void 0})}),V=sn(V),V},k=C=>{if(C.preventDefault(),!(i!=null&&i.type))return;if(!Nt(i.type,c())){p(!1),a(null);return}let P=u({x:C.clientX,y:C.clientY}),$={width:re[i.type].MIN_WIDTH,height:re[i.type].MIN_HEIGHT},V=f(),R={id:String(V),type:i.type,position:P,measured:$,data:{label:i.type==="TASK"?kr(e,s("bpmn.task.label.prefix")):"",variant:i.variant,attribute:i.attribute},selected:!0},G=v(T({},R),{internals:{positionAbsolute:P}}),K=v(T({},G),{measured:{width:1,height:1}}),L=E(),H=i.type==="LANE",F=L.filter(z=>H?z.type==="LANE"&&!z.parentId:z.type==="LANE"),Y=rn(K,F),O=[...e.map(z=>v(T({},z),{selected:!1})),R];Y&&(O=S(G,Y,O)),O=Ft(O),O=x(O),t(O),y();let J=C.dataTransfer.getData("sourceId"),U=d(),X=U;if(J){let z={id:String(V+1),source:J,target:R.id},W=i.type==="ANNOTATION"?T(T({},z),fo):T(T({},z),Fe);X=U.concat(W),o(X)}n("forceSave",{nodes:O,edges:X}),p(!1),a(null)},B=async(C,P,$)=>{let V=[...e];$.forEach(R=>{let G=E(),K=l(R.id),L=R.type==="LANE",H=G.filter(Y=>Y.id!==R.id&&(L?Y.type==="LANE"&&!Y.parentId:Y.type==="LANE")),F=rn(K,H);if(F){V=S(K,F,V);return}R.parentId&&(V=j(R,V))}),V=N(V),V=Ft(V),V=x(V),t(V),g(V),_(null)},q=(C,P)=>{_({x:P.position.x,y:P.position.y})},j=(C,P)=>{var K,L;let $=l(C.parentId),{x:V,y:R}=mt($),G={x:V+((K=C.position.x)!=null?K:0),y:R+((L=C.position.y)!=null?L:0)};return P=P.map(H=>H.id===C.id?v(T({},H),{position:G,parentId:void 0}):H),P=an(C.parentId,P),P};return{onDragOver:I,onDragLeave:A,onDrop:k,onNodeDrag:M,onNodeDragStart:q,onNodeDragStop:B}};import{useReactFlow as Hy}from"@xyflow/react";import{useTranslation as Gy}from"@produto-lecom/lecom-ui";import{useEffect as By}from"react";var zy=30,Yy=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},Fy=e=>!Yy(e.target),Sd=({offset:e=zy,saveHistory:t})=>{let{t:o}=Gy(),{getNodes:n,setNodes:r,getEdges:i,setEdges:a}=Hy(),{getNextId:s}=$e();By(()=>{let l=c=>{if(c.ctrlKey&&c.key.toLowerCase()==="d"&&Fy(c)){c.preventDefault(),c.stopPropagation();let d=n(),u=i(),f=d.filter(x=>x.selected);if(!f.length)return;let p=new Map,g=[],y=f.filter(x=>Nt(x.type,d));if(y.length===0)return;let m=u.filter(x=>y.some(N=>N.id===x.source)&&y.some(N=>N.id===x.target)),_=s(),h=y.map(x=>{var A;let N=String(_++);p.set(x.id,N);let I=v(T({},x),{id:N,selected:!0,position:{x:x.position.x+e,y:x.position.y+e}});if(x.type==="TASK"){let M=(A=x.data)==null?void 0:A.label,S=wo(M||o("bpmn.task.label.prefix"),[...d,...g]);I.data=v(T({},x.data),{label:S})}return g.push(I),I}),E=m.map(x=>v(T({},x),{id:String(_++),selected:!0,source:p.get(x.source)||x.source,target:p.get(x.target)||x.target})),w=[...d.map(x=>v(T({},x),{selected:!1})),...h],b=[...u.map(x=>v(T({},x),{selected:!1})),...E];r(w),a(b),t("forceSave",{nodes:w,edges:b})}};return document.addEventListener("keydown",l,!0),()=>{document.removeEventListener("keydown",l,!0)}},[n,r,i,a,s,e,o,t])};import{useEffect as Wy,useRef as Md}from"react";import{useReactFlow as Xy}from"@xyflow/react";var Uy=20,$y=50,hn={UP:"ArrowUp",DOWN:"ArrowDown",LEFT:"ArrowLeft",RIGHT:"ArrowRight"},Ky=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},Pd=e=>{let{getNodes:t}=Xy(),{mode:o,isMoveTool:n}=Q(),r=Md(0),i=Md(new Map);Wy(()=>{let a=s=>{if(o!=="edit"||!n||Ky(s.target)||!Object.values(hn).includes(s.key))return;let u=t().filter(h=>h.selected);if(u.length===0){i.current.clear();return}s.preventDefault();let f=Date.now(),p=f-r.current<500;r.current=f;let g=s.shiftKey?$y:Uy,y=0,m=0;switch(s.key){case hn.UP:m=-g;break;case hn.DOWN:m=g;break;case hn.LEFT:y=-g;break;case hn.RIGHT:y=g;break}let _=u.map(h=>{let E=i.current.get(h.id);(!p||!E)&&(E={x:h.position.x,y:h.position.y});let w={x:E.x+y,y:E.y+m};return i.current.set(h.id,w),{id:h.id,dragging:!0,type:"position",position:w}});e&&e(_)};return window.addEventListener("keydown",a),()=>{window.removeEventListener("keydown",a)}},[t,e,o,n])};import{useReactFlow as Zy}from"@xyflow/react";var kd={"start-event":"START_EVENT","end-event":"END_EVENT",task:"TASK","gateway-exclusive":"GATEWAY"},Rd={"start-event":"","end-event":"",task:"","gateway-exclusive":"EXCLUSIVE"},Ld=(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)||[],a="",s="",l="";if(o.length){switch(o[1]){case"<start>":a="start-event";break;case"<end>":a="end-event";break}e=e.replace(o[1],"")}return n.length&&(a="task",s=n[1].replace(/\[|\]/g,""),e=e.replace(n[1],"")),r.length&&(a="gateway-exclusive",s=r[1].replace(/\{|\}/g,""),e=e.replace(r[1],"")),a||(a="task",s=e),i.length&&(l=i[1].replace(/(\||--)/g,""),e=e.replace(i[1],"")),e=e.trim(),t[e]||(t[e]={type:a,label:s}),{step:e,type:a,label:s,edgeLabel:l}},qy=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 a=Ld(i[0],o),s=Ld(i[1],o);a&&s&&n.push({sourceId:a.step,targetId:s.step,label:a.edgeLabel||s.edgeLabel||""})}),{components:o,connections:n}},Dd=e=>{let{components:t,connections:o}=qy(e);return{nodes:t,edges:o}};var Od=()=>{let{setNodes:e,setEdges:t,fitView:o}=Zy(),{getNextId:n}=$e();return{importFromLia:i=>{let a=typeof i=="string"?i:i.diagramXml||"",{nodes:s,edges:l}=Dd(a),c=[],d=new Map,u=!1,f=n();for(let[m,_]of Object.entries(s)){let h=String(f++),E=kd[_.type],w=Rd[_.type];E==="START_EVENT"&&(u=!0),d.set(m,h);let b=re[E].MIN_WIDTH,x=re[E].MIN_HEIGHT;c.push({id:h,type:E,data:{label:_.label||"",variant:w,attribute:""},position:{x:0,y:0},width:b,height:x,measured:{width:b,height:x}})}let p=[];for(let m of l){let _=v(T({},Fe),{id:String(f++),source:d.get(m.sourceId)||m.sourceId,target:d.get(m.targetId)||m.targetId});p.push(_)}if(!u&&c.length>0){let m=String(f++),_={id:m,type:"START_EVENT",data:{label:"",variant:"",attribute:""},position:{x:0,y:0},width:re.START_EVENT.MIN_WIDTH,height:re.START_EVENT.MIN_HEIGHT,measured:{width:re.START_EVENT.MIN_WIDTH,height:re.START_EVENT.MIN_HEIGHT}};c.unshift(_);let h=c[1];if(h){let E=v(T({},Fe),{id:String(f++),source:m,target:h.id});p.unshift(E)}}let{nodes:g,edges:y}=hc(c,p);e(g),t(y),o({padding:Io,minZoom:Co,maxZoom:So})}}};import{useEffect as Jy,useCallback as Qy}from"react";var jy={origin:"*",debug:!1};function Vd(e,t=jy){let{origin:o,debug:n}=t,r=Qy((i,a)=>{let s={event:i,data:[i,{event:i,data:a}]};window.parent.postMessage(s,o||"*")},[o]);return Jy(()=>{let i=a=>{let s=a.data;if(!(s!=null&&s.event)||(s==null?void 0:s.data)===void 0)return;let{event:l,data:c}=s,d;if(Array.isArray(c)){let[,u]=c;d=u.data}else d=c;n&&(console.debug("[postMessage] received:",s),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 e0}from"@xyflow/react";import{useEffect as Hd}from"react";var Gd=()=>{let e=e0(),{initialDiagram:t,setIsInitialized:o}=Q(),{importFromMxGraph:n}=Mo();Hd(()=>{t&&n(t)},[t,n,o]),Hd(()=>{if(!e)return;(async()=>{await Nn(),o(!0)})()},[e,o])};import{useCallback as Bd}from"react";import{useReactFlow as t0}from"@xyflow/react";function zd(){let{setTaskStatuses:e,clearTaskStatuses:t,calculateFlowPath:o}=Ot(),{getEdges:n}=t0(),r=Sn(),i=Bd(s=>{if(!(s!=null&&s.activities))return;e(s.activities);let l=s.activities.map(d=>d.diagramId),c=n();o(c,l),setTimeout(()=>{r()},0)},[e,o,n,r]),a=Bd(()=>{t(),setTimeout(()=>{r()},0)},[t,r]);return{handleTasksStatus:i,handleClearTaskStatus:a}}import{useReactFlow as o0}from"@xyflow/react";import{useCallback as gt,useState as n0,useEffect as Yd}from"react";import{useDebouncedCallback as r0}from"use-debounce";var i0=500,Fd=100,Wd=(e=!1)=>{let{getNodes:t,getEdges:o,setNodes:n,setEdges:r}=o0(),[i,a]=n0({history:[],currentStep:0}),{history:s,currentStep:l}=i,c=l>0,d=l<s.length-1,u=gt((b,x)=>{n(b[x].nodes),r(b[x].edges)},[n,r]),f=gt(()=>{if(l>0){let b=l-1;a(x=>v(T({},x),{currentStep:b})),u(s,b)}},[l,s,u]),p=gt(()=>{if(l<s.length-1){let b=l+1;a(x=>v(T({},x),{currentStep:b})),u(s,b)}},[s,l,u]),g=gt(b=>{a(x=>{let N=x.history[x.currentStep];if(N&&JSON.stringify(N)===JSON.stringify(b))return x;let M=[...x.history.slice(0,x.currentStep+1),b],S=M.length>Fd?M.slice(M.length-Fd):M;return{history:S,currentStep:S.length-1}})},[]),y=gt((b,x)=>{let N=b.map(A=>v(T({},A),{selected:!1,className:"",data:v(T({},A.data),{hasError:!1})})),I=x.map(A=>v(T({},A),{data:v(T({},A.data),{hasError:!1})}));return{nodes:Ft(N),edges:I}},[]),m=gt(()=>y(t(),o()),[t,o,y]),_=r0(()=>{let b=m();g(b)},i0),h=gt((b,x)=>{if(!e)return;if(s.length===0){let A=m();a({history:[A],currentStep:0})}if(b==="forceSave"){if(x){g(y(x.nodes,x.edges));return}_();return}b.some(A=>A.type==="select")||b.some(A=>A.type==="position"&&A.dragging)||_()},[e,_,s.length,m,g,y]);Yd(()=>{if(e&&s.length===0){let b=m();a({history:[b],currentStep:0})}},[e,s.length,m]);let E=gt(b=>{a({history:b||[],currentStep:0})},[]),w=gt(()=>{a({history:[],currentStep:0})},[]);return Yd(()=>{let b=x=>{(x.ctrlKey||x.metaKey)&&(x.shiftKey&&x.key.toLowerCase()==="z"?(x.preventDefault(),p()):x.key.toLowerCase()==="z"&&(x.preventDefault(),f()))};return document.addEventListener("keydown",b),()=>{document.removeEventListener("keydown",b)}},[f,p]),{history:s,undo:f,redo:p,canUndo:c,canRedo:d,saveHistory:h,resetHistory:E,clearHistory:w}};var Xd=()=>{let{t:e}=s0(),[t,o,n]=l0([]),[r,i,a]=a0([]),{getNode:s}=d0(),{toast:l}=Ve(),c=u0(),{instanceId:d,isInitialized:u,setIsConnecting:f,setIsMultipleSelection:p,onElementClick:g}=Q(),{updateHelperLines:y,HelperLines:m}=sr(),{undo:_,redo:h,canUndo:E,canRedo:w,saveHistory:b}=Wd(u),{onNodeDrag:x,onDrop:N,onDragOver:I,onDragLeave:A,onNodeDragStop:M,onNodeDragStart:S}=Cd({nodes:t,setNodes:o,setEdges:i,saveHistory:b}),{isValidConnection:k,onConnect:B,onReconnect:q,onReconnectStart:j,onReconnectEnd:C,setReconnectingEdge:P,clearReconnectingEdge:$}=md({setEdges:i,saveHistory:b}),{handleValidationComplete:V,clearValidation:R,dismissValidationPanel:G,validateDiagram:K,getIsClearingValidation:L}=vd(),{importFromLia:H}=Od(),{handleTasksStatus:F,handleClearTaskStatus:Y}=zd(),{clearPathEdges:O}=Ot(),{emitElementChanges:J,handleNodeChanges:U,handleEdgeChanges:X}=Br(),z=Sn();Id({saveHistory:b}),Sd({saveHistory:b}),Gd();let W=Rt(()=>{o([]),i([]),O(),setTimeout(z,0)},[o,i,O,z]);Vd({LIA_CREATE_DIAGRAM:H,CLEAR_DIAGRAM:W,TASKS_STATUS:F,CLEAR_TASKS_STATUS:Y});let{selectElements:Z,clearSelection:ee}=vt(),{importFromMxGraph:le,exportToMxGraph:ce}=Mo(),{configureElement:de,getConfigureElement:ue}=mr(),ge=Rt(()=>t.length+r.length,[t,r]);p0(()=>(it.set(d,{importFromMxGraph:le,exportToMxGraph:ce,selectElements:Z,clearSelection:ee,configureElement:de,getConfigureElement:ue,getElementsCount:ge,setReconnectingEdge:P,clearReconnectingEdge:$}),()=>{it.delete(d)}),[d,le,ce,Z,ee,de,ue,ge,P,$]);let he=Rt((Ee,Ie)=>{if(Ie.type!=="TASK"&&Ie.type!=="GATEWAY")return;let et=ue(Ie.id);et&&(g==null||g(et))},[ue,g]),fe=Rt((Ee,Ie)=>{if(Ie.type!=="SEQUENCE_EDGE")return;let et=s(Ie.source),ri=s(Ie.target),{isFromStartEvent:Cu,isGatewayToGateway:Su,isActiviyToAndGateway:Mu}=Cn(et,ri);if(!(!Cu&&!Su&&!Mu))return;let ls=ue(Ie.id);ls&&(g==null||g(ls))},[ue,s,g]),se=Rt(Ee=>{let Ie=y(Ee,t);n(Ie),b(Ee),L()||G(),U(Ee)},[t,n,b,L,G,y,U]),ie=Rt(Ee=>{a(Ee),b(Ee),L()||G(),X(Ee)},[a,b,L,G,X]);Pd(se);let ve=Rt(({nodes:Ee,edges:Ie})=>{p(Ee.length+Ie.length>=2)},[p]);c0({onChange:ve});let ke=Rt(async({nodes:Ee})=>Ee.some(et=>et.type==="LANE"&&t.some(ri=>ri.parentId===et.id))?(l({variant:"error",title:e("validation.errors.title"),content:e("editor.toolbar.delete_pool_lane_error")}),!1):!0,[t,e,l]);return{nodes:t,setNodes:o,edges:r,setEdges:i,events:{isValidConnection:k,onConnect:B,onReconnect:q,onReconnectStart:j,onReconnectEnd:C,onDrop:N,onDragOver:I,onDragLeave:A,onNodeDrag:x,onNodeDragStop:M,onNodeDragStart:S,onNodeClick:he,onEdgeClick:fe,onDropCapture:()=>{b("forceSave"),J(),G()},onConnectStart:()=>{f(!0)},onConnectEnd:()=>{f(!1),G()},onSelectionEnd:()=>setTimeout(()=>c.setState({nodesSelectionActive:!1}),0),onNodesChange:se,onEdgesChange:ie,onBeforeDelete:ke},ui:{handleCloseValidationPanel:R},controls:{undo:_,redo:h,canUndo:E,canRedo:w},components:{HelperLines:m},actions:{saveHistory:b,selectElements:Z,clearSelection:ee,exportToMxGraph:ce,validateDiagram:K,handleValidationComplete:V,setReconnectingEdge:P,clearReconnectingEdge:$}}};import{jsx as Ud}from"react/jsx-runtime";var Qi=({id:e,className:t})=>Ud("marker",{id:e,className:D("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:Ud("path",{d:"M 0 0 L 10 5 L 0 10 Z"})});import{jsx as ji,jsxs as f0}from"react/jsx-runtime";var $d=()=>ji("svg",{style:{position:"absolute",top:0,left:0},children:f0("defs",{children:[ji(Qi,{id:"sequence-edge-marker",className:"text-grey-500"}),ji(Qi,{id:"sequence-edge-marker-highlighted",className:"text-blue-500"})]})});import{Tooltip as Dx,TooltipContent as Ox,TooltipTrigger as Vx,useTranslation as Hx}from"@produto-lecom/lecom-ui";import{useKeyPress as pu,useReactFlow as ox}from"@xyflow/react";import{Button as qr,Tooltip as Zr,TooltipContent as Jr,TooltipTrigger as Qr,useTranslation as nx}from"@produto-lecom/lecom-ui";import{HandIcon as rx,ListCheckIcon as ix,MapIcon as sx,MousePointerIcon as ax}from"lucide-react";import{useCallback as ns,useEffect as fu}from"react";import{Tooltip as k0,TooltipContent as R0,TooltipTrigger as D0,useTranslation as O0}from"@produto-lecom/lecom-ui";var yn=(E=>(E.START_EVENT="START_EVENT",E.END_EVENT="END_EVENT",E.TASK="TASK",E.SUBPROCESS="SUBPROCESS",E.GATEWAY="GATEWAY",E.LANE="LANE",E.ANNOTATION="ANNOTATION",E.CONNECTION="CONNECTION",E.INTERMEDIATE_EVENT="INTERMEDIATE_EVENT",E.ACTIVITY="ACTIVITY",E.PROCESS_INTERFACE="PROCESS_INTERFACE",E.WORKFLOW_INTERFACE="WORKFLOW_INTERFACE",E.VARIANT_ACTIVITY="VARIANT_ACTIVITY",E.AUTO_ACTIVITY="AUTO_ACTIVITY",E.DATA_STORE="DATA_STORE",E.DATA_OBJECT="DATA_OBJECT",E.DATA_OUTPUT="DATA_OUTPUT",E.DATA_INPUT="DATA_INPUT",E.MARKER="MARKER",E))(yn||{});import{Button as w0,useTranslation as A0}from"@produto-lecom/lecom-ui";import{useReactFlow as I0}from"@xyflow/react";var Kd=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 qd({columns:e=[],rows:t=[],fileName:o="report"}){if(!e.length||!t.length)return;let r="data:text/csv;charset=utf-8,"+[e,...t].map(a=>a.join(",")).join(`
43
- `),i=encodeURI(r);Fr(i,`${o}.csv`)}var Fr=(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 Zd(e){return e==null?void 0:e.replaceAll("&#xA;"," ")}var e3={START_EVENT:"START_EVENT",END_EVENT:"END_EVENT",TASK:"TASK",GATEWAY:"GATEWAY",ANNOTATION:"ANNOTATION"},Jd={script:"SCRIPT",subprocess:"SUBPROCESS"},Qd={"marker-loop":"LOOP"},jd={complex:"COMPLEX",none:"EXCLUSIVE",exclusive:"EXCLUSIVE",parallel:"PARALLEL",inclusive:"EXCLUSIVE"};var qt=({cell:e,type:t,variant:o="",attribute:n=""})=>{let{_attributes:r,mxGeometry:i}=e,{value:a,parent:s}=r,l=Number(i._attributes.width),c=Number(i._attributes.height),d=s==="1"?void 0:s;return{id:r.id,parentId:d,type:t,data:{label:a||"",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}}},g0=e=>{let{subType:t,style:o}=e._attributes,n="imported";return["none"].includes(t)||(n="adapted"),e.mxGeometry._attributes.width=re.START_EVENT.MIN_WIDTH,e.mxGeometry._attributes.height=re.START_EVENT.MIN_HEIGHT,{node:qt({cell:e,type:"START_EVENT"}),status:n,originalType:o}},h0=e=>{let{subType:t,style:o}=e==null?void 0:e._attributes,n="imported";return["none"].includes(t)||(n="adapted"),e.mxGeometry._attributes.width=re.END_EVENT.MIN_WIDTH,e.mxGeometry._attributes.height=re.END_EVENT.MIN_HEIGHT,{node:qt({cell:e,type:"END_EVENT"}),status:n,originalType:o}},y0=(e,t)=>{let{id:o,subType:n,style:r}=e==null?void 0:e._attributes,i=Jd[n],a=t.get(o)||"",s=Qd[a]||"",l=s==="LOOP",c="imported";return!["script","none"].includes(n)&&!l&&(c="adapted"),e.mxGeometry._attributes.width=xt(e.mxGeometry._attributes.width||0,re.TASK.MIN_WIDTH),e.mxGeometry._attributes.height=xt(e.mxGeometry._attributes.height||0,re.TASK.MIN_HEIGHT),{node:qt({cell:e,type:"TASK",variant:i,attribute:s}),status:c,originalType:r}},x0=e=>{let{style:t,subType:o}=e==null?void 0:e._attributes,n=jd[o],r=["none","inclusive","event-based"],i="imported";return r.includes(o)&&(i="adapted"),e.mxGeometry._attributes.width=re.GATEWAY.MIN_WIDTH,e.mxGeometry._attributes.height=re.GATEWAY.MIN_HEIGHT,{node:qt({cell:e,type:"GATEWAY",variant:n}),status:i,originalType:t}},E0=e=>{let{style:t}=e==null?void 0:e._attributes;return{node:qt({cell:e,type:"LANE"}),status:"imported",originalType:t}},b0=e=>{let{style:t}=e==null?void 0:e._attributes;return e.mxGeometry._attributes.width=xt(e.mxGeometry._attributes.width||0,re.ANNOTATION.MIN_WIDTH),e.mxGeometry._attributes.height=xt(e.mxGeometry._attributes.height||0,re.ANNOTATION.MIN_HEIGHT),{node:qt({cell:e,type:"ANNOTATION"}),status:"imported",originalType:t}},eu=e=>{let{style:t}=e==null?void 0:e._attributes;return e.mxGeometry._attributes.width=re.UNSUPPORTED.MIN_WIDTH,e.mxGeometry._attributes.height=re.UNSUPPORTED.MIN_HEIGHT,{node:qt({cell:e,type:"UNSUPPORTED"}),status:"unsupported",originalType:t}},tu=(e,t)=>{let{id:o,source:n,target:r,value:i}=e._attributes;return v(T({},Fe),{id:o,source:t.get(n)||n,target:t.get(r)||r,data:{label:i||""}})},ou={TASK:y0,GATEWAY:x0,START_EVENT:g0,END_EVENT:h0,LANE:E0,ANNOTATION:b0};var _0=e=>{let t=new Map,o=Object.values(yn),n=[],r=new Map;e.forEach(s=>{var c;let l=(c=s._attributes)==null?void 0:c.type;if(l==="MARKER"){r.set(s._attributes.parent,s._attributes.style);return}if(o.includes(l)){n.push(s);return}});let i=[],a=[];for(let s of n){let{type:l}=s._attributes,c=ou[l]||eu,{node:d,status:u,originalType:f}=c(s,r);a.push(d),i.push({originalType:f,type:d.type,variant:d.data.variant,value:Zd(d.data.label),status:u})}return{nodes:a,governanceIdToNodeIdMap:t,summary:i}},T0=(e,t)=>e.filter(r=>{var i;return(i=r._attributes)==null?void 0:i.edge}).map(r=>tu(r,t)),N0=e=>{let{mxGraphModel:t}=e,{nodes:o,governanceIdToNodeIdMap:n,summary:r}=_0(t.root.mxCell),i=T0(t.root.mxCell,n);return{nodes:o,edges:i,summary:r}},v0=async e=>{let t=await Kd(e),o=Mr(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),a=r==null?void 0:r.root;if(!i||!a)throw new Error("INVALID_FILE");if(!Object.keys(r.root.mxCell||{}).length)throw new Error("CONTAIN_NO_CELLS");return{metadata:n,mxGraphModel:r}},nu=async e=>{try{let t=await v0(e),{nodes:o,edges:n,summary:r}=N0(t)||{};return{nodes:o,edges:n,summary:r}}catch(t){throw t}};import{jsx as C0}from"react/jsx-runtime";var ru=()=>{let{t:e}=A0(),{toast:t}=Ve(),{setNodes:o,setEdges:n,fitView:r}=I0(),i=s=>{let l=[e("adapter.governance.report.columns.type"),e("adapter.governance.report.columns.value"),e("adapter.governance.report.columns.status")],c=s.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:C0(w0,{size:"small",variant:"ghost",onClick:()=>qd({columns:l,rows:c,fileName:"governance-imported-cells"}),children:e("adapter.governance.action.download")})})};return{importFromGovernance:async s=>{try{let{nodes:l,edges:c,summary:d}=await nu(s);if(o(f=>f.concat(l)),n(f=>f.concat(c)),r({padding:Io,minZoom:Co,maxZoom:So}),d.some(f=>f.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 S0}from"@produto-lecom/lecom-ui";import{useRef as M0}from"react";import{Fragment as P0,jsx as iu,jsxs as L0}from"react/jsx-runtime";var su=s=>{var l=s,{children:e,accept:t="*",multiple:o=!1,disabled:n=!1,onClick:r,onFilesSelected:i}=l,a=tt(l,["children","accept","multiple","disabled","onClick","onFilesSelected"]);let c=M0(null),d=f=>{let p=f.target.files;p!=null&&p.length&&i(p),c.current&&(c.current.value="")};return L0(P0,{children:[iu(S0,v(T({disabled:n,onClick:f=>{var p;(p=c.current)==null||p.click(),r==null||r(f)}},a),{children:e})),iu("input",{type:"file",ref:c,className:"sr-only",accept:t,multiple:o,disabled:n,onChange:d})]})};import{jsx as Wr,jsxs as V0}from"react/jsx-runtime";var au=({disabled:e=!1})=>{let{t}=O0(),{toast:o}=Ve(),{importFromGovernance:n}=ru(),r=()=>{if(e){o({variant:"error",content:t("adapter.governance.error.ALREADY_INITIALIZED")});return}},i=a=>{let s=a[0];if(!s){o({variant:"error",content:t("adapter.governance.error.NO_FILE")});return}n(s)};return V0(k0,{children:[Wr(D0,{asChild:!0,children:Wr(su,{className:"[&>svg]:size-7 p-0",variant:"ghost",size:"small",color:"grey",iconButton:!0,accept:".mdr",disabled:e,onClick:r,onFilesSelected:i,children:Wr(Es,{})})}),Wr(R0,{color:"black",children:t("editor.controls.actions.import_governance")})]})};import{jsx as H0}from"react/jsx-runtime";var es=({shortcut:e})=>H0("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 U0,DropdownMenu as $0,DropdownMenuContent as K0,DropdownMenuItem as os,DropdownMenuTrigger as q0,Tooltip as Ur,TooltipContent as $r,TooltipTrigger as Kr,useTranslation as Z0}from"@produto-lecom/lecom-ui";import{FileCodeIcon as J0,FileImageIcon as Q0,FolderOutputIcon as j0,PrinterIcon as ex}from"lucide-react";import{useState as tx}from"react";import{useTranslation as G0}from"@produto-lecom/lecom-ui";import{useReactFlow as B0}from"@xyflow/react";import{toPng as lu,toSvg as z0}from"html-to-image";import{useState as Y0}from"react";var F0=3,ts="diagram",Xr=50,W0=96,X0=25.4,cu=e=>e*X0/W0,du=()=>{let{t:e}=G0(),{toast:t}=Ve(),{getNodes:o,getNodesBounds:n}=B0(),{clearSelection:r}=vt(),[i,a]=Y0({png:!1,html:!1,print:!1}),s=()=>{let f=Gi(o()),p=n(f),g=p.width+Xr*2,y=p.height+Xr*2,m=Xr-p.x,_=Xr-p.y;return{width:g,height:y,style:{width:`${g}px`,height:`${y}px`,transform:`translate(${m}px, ${_}px)`,transformOrigin:"top left"}}},l=async(f,p)=>{a(g=>v(T({},g),{[p]:!0})),await r();try{if(Gi(o()).length===0){t({content:e("editor.controls.actions.export.feedback.empty"),variant:"warning"});return}let y=xc();if(!y)throw new Error("Flow element not found");let m=s();return await f(y,m)}catch(g){console.error("Diagram export failed",g),t({content:e("editor.controls.actions.export.feedback.error"),variant:"error"})}finally{a(g=>v(T({},g),{[p]:!1}))}};return{exportAsPng:async(f=ts)=>{await l(async(p,g)=>{let y=await lu(p,v(T({},g),{backgroundColor:"#fcfcfc",skipFonts:!0}));Fr(y,`${f}.png`)},"png")},exportAsHtml:async(f=ts)=>{await l(async(p,g)=>{let y=await z0(p,v(T({},g),{backgroundColor:"#fcfcfc",skipFonts:!0})),m=`
39
+ </mxGraphModel>`,bc=(e,t)=>{if(!e.length&&!t.length)return ln;let o=[...e.map(r=>r.id),...t.map(r=>r.id)];return Math.max(...o.map(r=>Number(r)))};var jg=e=>{let t=Object.values(nn),o=e.filter(i=>{var s;let a=(s=i._attributes)==null?void 0:s.style;return t.includes(a)}),n=e.filter(i=>{var s;let a=(s=i._attributes)==null?void 0:s.style;return["attribute-loop"].includes(a)}),r=[];for(let i of o){let{style:a}=i._attributes,s=sc[a],l=s==null?void 0:s(i,n);if(!l){console.warn(`Node ${a} not supported`);continue}r.push(l)}return r},eh=(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=ac(r),a=t.find(l=>l.id===i.source),s=t.find(l=>l.id===i.target);(a==null?void 0:a.type)==="LANE"||(s==null?void 0:s.type)==="LANE"||n.push(i)}return n},th=(e,t)=>{let o=[];return e.forEach(n=>{var a,s;let r=(s=(a=cc)[n.type])==null?void 0:s.call(a,n);if(!r){console.warn(`Node ${n.type} not supported`);return}if(o.push(r),n.type==="TASK"&&n.data.attribute==="LOOP"){let l=dc(n,t);o.push(l)}}),o},oh=(e,t)=>{let o=[];return e.forEach(n=>{let r=lc(n,t);o.push(r)}),o},_c=(e=[],t=[],o)=>{let n=th(e,o),r=oh(t,e),i={mxGraphModel:{root:{_attributes:{version:"1.1",lastId:o},mxCell:[{_attributes:{id:"0"}},{_attributes:{id:"1",parent:"0"}},...n,...r]}}};return ec(JSON.stringify(i),{compact:!0,spaces:0})},Tc=async e=>{var c,d,u,f,p;let t=await Mr(e),o=((d=(c=t==null?void 0:t.mxGraphModel)==null?void 0:c.root)==null?void 0:d.mxCell)||[],n=Number(((p=(f=(u=t==null?void 0:t.mxGraphModel)==null?void 0:u.root)==null?void 0:f._attributes)==null?void 0:p.lastId)||ln),r=jg(o),i=eh(o,r),a=sn(r),{nodes:s,edges:l}=fc(a,i);return{lastElementId:n,edges:l,nodes:Ft(s)}};import{Position as It,useConnection as Dh,useReactFlow as Oh}from"@xyflow/react";import{useCallback as Ui}from"react";import{Handle as Nc,useReactFlow as nh}from"@xyflow/react";import{jsx as vc}from"react/jsx-runtime";var te=i=>{var a=i,{type:e,position:t,className:o,nodeType:n}=a,r=tt(a,["type","position","className","nodeType"]);let s=n==="TASK";return vc(Nc,T({type:e,position:t,className:R("size-2.5 border border-grey-400 bg-white relative",{"before:content-[''] before:absolute before:inset-[-16px] before:bg-transparent before:pointer-events-none":s,"before:content-[''] before:absolute before:inset-[-4px] before:bg-transparent before:pointer-events-none":!s},o)},r))},Le=s=>{var l=s,{nodeId:e,nodeType:t,gatewayVariant:o,type:n,position:r,className:i}=l,a=tt(l,["nodeId","nodeType","gatewayVariant","type","position","className"]);let{getEdges:c,getNodes:d}=nh(),f=(()=>{if(n!=="source")return!1;let p=c();if(t==="TASK")return p.filter(y=>y.source===e).length>=2;if(t==="GATEWAY"&&o==="EXCLUSIVE")return p.filter(y=>y.source===e).length>=2;if(t==="START_EVENT"){let g=d();return p.filter(m=>{if(m.source!==e)return!1;let b=g.find(h=>h.id===m.target);return(b==null?void 0:b.type)!=="ANNOTATION"}).length>=1}return!1})();return vc(Nc,T({type:n,position:r,className:R("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":f,"hover:border-grey-500":!f},i),style:{pointerEvents:f?"none":"auto"}},a))};import{NodeResizer as rh,useReactFlow as ih}from"@xyflow/react";import{orderBy as sh}from"lodash";import{jsx as ah}from"react/jsx-runtime";var No=n=>{var r=n,{nodeId:e,isVisible:t}=r,o=tt(r,["nodeId","isVisible"]);let{getNode:i,getNodes:a,setNodes:s}=ih(),{isMultipleSelection:l}=Q(),c=({width:u,height:f})=>{if(!e)return;let p=i(e);if((p==null?void 0:p.type)!=="LANE")return;let g=[...a()],y=!p.parentId,m=y?p.id:p.parentId,b=g.filter(w=>w.type==="LANE"&&w.parentId===m);if(!b.length)return;let h=sh(b,["position.y"]),E=0;h.forEach((w,_)=>{var I,A;let x=_===h.length-1,N=(A=(I=w.measured)==null?void 0:I.height)!=null?A:0;g=g.map(M=>{if(M.id===w.id){let S=y?u-ye.HEADER_WIDTH:u,k=v(T({},M),{width:S,measured:v(T({},M.measured),{width:S}),position:v(T({},M.position),{y:E})});return x&&y&&(k.height=f-E),k}return M}),E+=N}),g=g.map(w=>{if(w.id===m){let _=y?u:u+ye.HEADER_WIDTH;return v(T({},w),{width:_,height:y?f:E,measured:{width:_,height:y?f:E}})}return w}),s(g)};return ah(rh,T({nodeId:e,handleClassName:"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]",lineClassName:"border-blue-400/90 border-dashed",isVisible:!l&&t,onResizeEnd:(u,f)=>c(f)},o))};import{NodeToolbar as wh,useReactFlow as Ah}from"@xyflow/react";import{Button as Ih,Tooltip as Ch,TooltipContent as Sh,TooltipTrigger as Mh,useTranslation as Ph}from"@produto-lecom/lecom-ui";import{useCallback as Xi,useEffect as Lh,useRef as Lr,useState as kh}from"react";import{create as lh}from"zustand";var vo=lh(e=>({draggableNode:null,setDraggableNode:t=>{e({draggableNode:t})}}));import{useEffect as ch,useState as dh}from"react";var wc=(e,t=!1)=>{let[o,n]=dh({width:0,height:0});return ch(()=>{if(e.current&&t){let r=e.current.getBoundingClientRect();n({width:r.width,height:r.height})}},[t,e]),{dimensions:o}};import{Position as cn,useReactFlow as uh}from"@xyflow/react";import{useMemo as ph}from"react";var fh=120,mh=12,Ac=(e,t=!1,o)=>{let{getNode:n,getViewport:r}=uh(),{instanceId:i}=Q();return ph(()=>{var p,g;if(!t)return{position:cn.Right,align:"start"};let a=n(e);if(!a)return{position:cn.Right,align:"start"};let s=r(),l=a.position.x*s.zoom+s.x,c=(((p=a.measured)==null?void 0:p.width)||a.width||100)*s.zoom,d=(g=document.getElementById(`modeler-${i}`))==null?void 0:g.clientWidth;if(!d)return{position:cn.Right,align:"start"};let u=(o==null?void 0:o.width)||fh;return{position:l+c+u+mh>d?cn.Left:cn.Right}},[i,e,t,o,n,r])};import{useNodesData as gh,useReactFlow as hh}from"@xyflow/react";import{Button as Ic,DropdownMenu as yh,DropdownMenuContent as xh,DropdownMenuGroup as Eh,DropdownMenuItem as bh,DropdownMenuLabel as _h,DropdownMenuTrigger as Th,Tooltip as Yi,TooltipContent as Fi,TooltipTrigger as Wi,useTranslation as Nh}from"@produto-lecom/lecom-ui";import{WrenchIcon as vh}from"lucide-react";import{jsx as Se,jsxs as Wt}from"react/jsx-runtime";var Cc=({nodeId:e})=>{let{t}=Nh(),{updateNodeData:o,getEdges:n,getNode:r}=hh(),i=gh(e),s=n().filter(p=>p.source===e).some(p=>{let g=r(p.target);return(g==null?void 0:g.type)==="END_EVENT"}),l=(i==null?void 0:i.data.variant)==="SUBPROCESS",c=u=>{o(e,{variant:(i==null?void 0:i.data.variant)===u?"":u})},d=u=>{o(e,{attribute:(i==null?void 0:i.data.attribute)===u?"":u})};return Wt(yh,{children:[Wt(Yi,{children:[Se(Wi,{asChild:!0,children:Se(Th,{asChild:!0,children:Se(Ic,{variant:"ghost",color:"grey",size:"small",iconButton:!0,children:Se(vh,{})})})}),Se(Fi,{color:"black",children:t("bpmn.task.menu.title")})]}),Wt(xh,{align:"start",className:"w-60 bg-white text-grey-600",children:[Wt(_h,{className:"flex items-center gap-1",children:[Se("div",{className:"flex-1 body-medium-500",children:t("bpmn.task.menu.title")}),Se("div",{className:"flex items-center gap-1",children:Object.entries(In).map(([u,f])=>{let p=u==="LOOP"&&(s||l),y=(()=>{if(u==="LOOP"&&s)return t("editor.task_menu.loop_not_allowed_when_connected_to_end");if(u==="LOOP"&&l)return t("editor.task_menu.loop_not_allowed_when_subprocess");if(u==="LOOP")return t("editor.task_menu.loop")})();return Wt(Yi,{children:[Se(Wi,{asChild:!0,children:Se(Ic,{variant:"ghost",color:"grey",size:"small",iconButton:!0,disabled:p,className:R({"bg-grey-100 text-blue-500":(i==null?void 0:i.data.attribute)===u,"opacity-50 cursor-not-allowed":p}),onClick:p?void 0:()=>d(u),children:Se(f.icon,{className:"stroke-inherit"})})}),y&&Se(Fi,{color:"black",children:y})]},u)})})]}),Se(Eh,{children:Wt(Yi,{children:[Se(Wi,{asChild:!0,children:Se("div",{className:R({"cursor-not-allowed":s}),children:Wt(bh,{className:R({"bg-grey-100 text-blue-500":(i==null?void 0:i.data.variant)==="SCRIPT","opacity-50":s}),disabled:s,onClick:()=>c("SCRIPT"),children:[Se(An.SCRIPT.icon,{className:"stroke-current"}),t(`bpmn.task.variant.${"SCRIPT".toLowerCase()}`)]})})}),s&&Se(Fi,{color:"black",children:t("editor.task_menu.script_not_allowed_when_connected_to_end")})]})})]})]})};import{jsx as _e,jsxs as Sc}from"react/jsx-runtime";var Xt={START_EVENT:{type:"START_EVENT",icon:ko,label:"bpmn.start_event.variant.default"},END_EVENT:{type:"END_EVENT",icon:jt,label:"bpmn.end_event.variant.default"},TASK:{type:"TASK",icon:ko,label:"bpmn.task.variant.default"},ANNOTATION:{type:"ANNOTATION",icon:Tn,label:"bpmn.annotation.variant.default"}},Rh={EXCLUSIVE:{type:"GATEWAY",variant:"EXCLUSIVE",icon:to,label:"bpmn.gateway.variant.exclusive"},PARALLEL:{type:"GATEWAY",variant:"PARALLEL",icon:oo,label:"bpmn.gateway.variant.parallel"},COMPLEX:{type:"GATEWAY",variant:"COMPLEX",icon:eo,label:"bpmn.gateway.variant.complex"}},He=({nodeId:e,nodeType:t,nodeVariant:o})=>{let n=Lr(null),r=Lr(null),{t:i}=Ph(),{setDraggableNode:a}=vo(),{getEdges:s,getNodes:l,getNode:c}=Ah(),{setIsDragging:d,mode:u,isConnecting:f,isDragging:p,isMultipleSelection:g}=Q(),y=c(e),m=!!(y!=null&&y.selected)&&!y.dragging&&!f&&!p&&!g,{dimensions:b}=wc(n,m),{position:h}=Ac(e,m,b),[E,w]=kh(void 0),_=l(),x=s(),N=o==="SUBPROCESS",I=Lr(null),A=Lr(!1),M=Xi(()=>{I.current!==null&&(clearTimeout(I.current),I.current=null),A.current=!1,d(!1),a(null),w(void 0)},[d,a]);Lh(()=>{let L=V=>{A.current&&V.buttons===0&&M()};return document.addEventListener("dragend",M),document.addEventListener("mousemove",L),()=>{document.removeEventListener("dragend",M),document.removeEventListener("mousemove",L)}},[M]);let S=Xi((L,V)=>{A.current=!0,d(!1),a({type:V.type,variant:V.variant,attribute:V.attribute,icon:V.icon}),V.icon&&w(_e(V.icon,{})),L.dataTransfer.effectAllowed="move",L.dataTransfer.setData("sourceId",e),r.current&&L.dataTransfer.setDragImage(r.current,10,10),I.current=setTimeout(()=>{I.current=null,d(!0)},100)},[e,a,d]),k=Xi(()=>{M()},[M]),B=[{component:_e(yr,{elementId:e})}],q=()=>{if(u==="view")return[];let L=!x.some(V=>{var F;return V.source===e&&((F=_.find(Y=>Y.id===V.target))==null?void 0:F.type)!=="ANNOTATION"});return[{component:_e(lo,{nodeId:e,disabled:!L,tooltipMessage:L?void 0:i("editor.toolbar.start_event_limit_reached")})},Xt.TASK,Xt.ANNOTATION,...B]},j=()=>u==="view"?[{component:_e(wt,{elementId:e})}]:[{component:_e(wt,{elementId:e})},...N?[]:[{component:_e(Cc,{nodeId:e})}],{component:_e(lo,{nodeId:e})},Xt.TASK,...Object.values(Rh),...B],C=()=>u==="view"?[{component:_e(wt,{elementId:e})}]:[{component:_e(wt,{elementId:e})},{component:_e(lo,{nodeId:e})},Xt.TASK,Xt.ANNOTATION,...B],P=()=>u==="view"?[]:[Xt.ANNOTATION,...B],$=()=>u==="view"?[]:[{component:_e(lo,{nodeId:e})},Xt.ANNOTATION,...B],H=()=>u==="view"?[]:[{component:_e(lo,{nodeId:e})},...B],D=()=>u==="view"?[]:[...B],K=(L=>{switch(L){case"START_EVENT":return q();case"TASK":return j();case"GATEWAY":return C();case"END_EVENT":return P();case"LANE":return $();case"ANNOTATION":return H();case"UNSUPPORTED":return D();default:return[]}})(t);if(!(K.length===0||u==="readonly"))return Sc(wh,{position:h,align:"start",className:"-top-8",isVisible:m,children:[_e("div",{ref:n,className:"flex items-center gap-1 px-3 py-2 bg-white rounded-sm shadow-md",children:K.map((L,V)=>{if(L.component)return _e("div",{children:L.component},V);let F={sourceNodeType:t,targetNodeType:L.type,sourceNodeId:e,nodes:_,edges:x},Y=Ll(F),O={gateway_limit_reached:i("editor.toolbar.gateway_limit_reached"),start_event_limit_reached:i("editor.toolbar.start_event_limit_reached"),start_event_already_exists:i("editor.toolbar.start_event_already_exists"),script_to_end_not_allowed:i("editor.toolbar.script_to_end_not_allowed"),loop_to_end_not_allowed:i("editor.toolbar.loop_to_end_not_allowed"),initial_activity_to_end_not_allowed:i("editor.toolbar.initial_activity_to_end_not_allowed"),final_activity_cannot_connect:i("editor.toolbar.final_activity_cannot_connect"),activity_has_outgoing_connections:i("editor.toolbar.activity_has_outgoing_connections"),task_limit_reached:i("editor.toolbar.task_limit_reached")},J=Y.shouldDisable&&Y.reason?O[Y.reason]||i(L.label):i(L.label)||"";return Sc(Ch,{children:[_e(Mh,{asChild:!0,children:_e(Ih,{variant:"ghost",color:"grey",size:"small",iconButton:!0,draggable:!Y.shouldDisable,disabled:Y.shouldDisable,className:Y.shouldDisable?"opacity-50 cursor-not-allowed":"",onDragStart:Y.shouldDisable?void 0:U=>S(U,L),onDragEnd:Y.shouldDisable?void 0:k,children:L.icon&&_e(L.icon,{size:16})})}),_e(Sh,{color:"black",children:J})]},V)})}),_e("div",{ref:r,className:"absolute w-0 h-0 top-0 left-0 z-[-1] bg-transparent",children:E})]})};import{Fragment as Mc,jsx as Je,jsxs as $i}from"react/jsx-runtime";var Pc=({id:e,data:t,selected:o,dragging:n})=>{let{updateNodeData:r,setNodes:i}=Oh(),{inProgress:a,fromNode:s}=Dh(),{mode:l}=Q(),c=a&&(s==null?void 0:s.id)!==e,d=Ui(p=>{let h=p.split(`
40
+ `),E=h.reduce((N,I)=>Math.max(N,I.length),0),w=h.length,_=Math.max(xo.MIN_WIDTH,E*7+32),x=Math.max(xo.MIN_HEIGHT,w*20+24);i(N=>N.map(I=>I.id===e?v(T({},I),{width:_,height:x,style:v(T({},I.style),{width:_,height:x})}):I))},[e,i]),u=Ui(p=>{r(e,{label:p}),d(p)},[e,r,d]),f=Ui(p=>{d(p)},[d]);return $i("div",{className:R("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",{"text-blue-500 hover:text-blue-600 shadow-md":o,"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:[Je(Ce,{value:t.label,className:"m-1 text-grey-600 text-left",onChange:u,onInput:f,skipFirstCharValidation:!0}),Je(He,{nodeId:e,nodeType:"ANNOTATION"}),l==="edit"&&Je(No,{minWidth:xo.MIN_WIDTH,minHeight:xo.MIN_HEIGHT,isVisible:!n&&o}),!a&&$i(Mc,{children:[Je(te,{type:"source",position:It.Left,id:"left"}),Je(te,{type:"source",position:It.Right,id:"right"}),Je(te,{type:"source",position:It.Top,id:"top"}),Je(te,{type:"source",position:It.Bottom,id:"bottom"})]}),(!a||c)&&$i(Mc,{children:[Je(te,{type:"target",position:It.Left,id:"left",className:R({"annotation-handle":c})}),Je(te,{type:"target",position:It.Right,id:"right",className:R({"annotation-handle":c})}),Je(te,{type:"target",position:It.Top,id:"top",className:R({"annotation-handle":c})}),Je(te,{type:"target",position:It.Bottom,id:"bottom",className:R({"annotation-handle":c})})]})]})};import{Position as Ct,useConnection as Vh,useReactFlow as Hh}from"@xyflow/react";import{useState as Gh}from"react";import{Fragment as Lc,jsx as We,jsxs as Ki}from"react/jsx-runtime";var kc=({id:e,data:t,selected:o})=>{let{updateNodeData:n}=Hh(),{inProgress:r,fromNode:i}=Vh(),{reconnectingEdgeId:a}=Q(),[s,l]=Gh(!1),c=r&&(i==null?void 0:i.id)!==e||!!a,d=p=>{n(e,{label:p})},u=()=>{l(!0)},f=()=>{l(!1)};return Ki("div",{className:"relative",onDoubleClick:u,children:[We(jt,{className:R("size-9 hover:stroke-[#d33b3b] transition-colors duration-75",{"stroke-blue-500 hover:stroke-blue-600":o,"stroke-red-500 hover:stroke-red-600 drop-shadow-[0_0_3px_rgba(255,0,0,0.5)] fill-red-100":t.hasError})}),We("div",{className:"absolute top-10 left-1/2 -translate-x-1/2 max-w-80 w-max",children:We(Ce,{value:t.label,isEditing:s,onBlur:f,onChange:d})}),We(He,{nodeId:e,nodeType:"END_EVENT"}),(!r||c)&&Ki(Lc,{children:[We(te,{type:"target",position:Ct.Left,id:"left",className:R({"event-handle":c})}),We(te,{type:"target",position:Ct.Right,id:"right",className:R({"event-handle":c})}),We(te,{type:"target",position:Ct.Top,id:"top",className:R({"event-handle":c})}),We(te,{type:"target",position:Ct.Bottom,id:"bottom",className:R({"event-handle":c})})]}),!r&&Ki(Lc,{children:[We(te,{type:"source",position:Ct.Left,id:"left"}),We(te,{type:"source",position:Ct.Right,id:"right"}),We(te,{type:"source",position:Ct.Top,id:"top"}),We(te,{type:"source",position:Ct.Bottom,id:"bottom"})]})]})};import{Position as St,useConnection as Bh,useReactFlow as zh}from"@xyflow/react";import{useCallback as Yh,useState as Fh}from"react";import{Fragment as Rc,jsx as Xe,jsxs as qi}from"react/jsx-runtime";var Dc=({id:e,data:t,selected:o})=>{let n=hi[t.variant].icon,{updateNodeData:r}=zh(),{inProgress:i,fromNode:a}=Bh(),{reconnectingEdgeId:s}=Q(),[l,c]=Fh(!1),d=i&&(a==null?void 0:a.id)!==e||!!s,u=Yh(g=>{r(e,{label:g})},[e,r]),f=()=>{c(!0)},p=()=>{c(!1)};return qi("div",{className:"relative",onDoubleClick:f,children:[Xe(n,{className:R("size-14 stroke-1 stroke-grey-400 hover:stroke-grey-500 transition-colors duration-75",{"stroke-blue-500 hover:stroke-blue-600":o,"stroke-red-500 hover:stroke-red-600 drop-shadow-[0_0_3px_rgba(255,0,0,0.5)]":t.hasError})}),Xe("div",{className:"absolute top-14 left-1/2 -translate-x-1/2 max-w-80 w-max",children:Xe(Ce,{value:t.label,isEditing:l,onBlur:p,onChange:u})}),Xe(He,{nodeId:e,nodeType:"GATEWAY"}),(!i||d)&&qi(Rc,{children:[Xe(te,{type:"target",position:St.Left,id:"left",className:R({"gateway-handle":d})}),Xe(te,{type:"target",position:St.Right,id:"right",className:R({"gateway-handle":d})}),Xe(te,{type:"target",position:St.Top,id:"top",className:R({"gateway-handle":d})}),Xe(te,{type:"target",position:St.Bottom,id:"bottom",className:R({"gateway-handle":d})})]}),!i&&qi(Rc,{children:[Xe(Le,{type:"source",position:St.Left,id:"left",nodeId:e,nodeType:"GATEWAY",gatewayVariant:t.variant}),Xe(Le,{type:"source",position:St.Right,id:"right",nodeId:e,nodeType:"GATEWAY",gatewayVariant:t.variant}),Xe(Le,{type:"source",position:St.Top,id:"top",nodeId:e,nodeType:"GATEWAY",gatewayVariant:t.variant}),Xe(Le,{type:"source",position:St.Bottom,id:"bottom",nodeId:e,nodeType:"GATEWAY",gatewayVariant:t.variant})]})]})};import{useNodesData as eS,useReactFlow as tS}from"@xyflow/react";import{Button as nS,DropdownMenu as rS,DropdownMenuContent as iS,DropdownMenuGroup as sS,DropdownMenuItem as aS,DropdownMenuLabel as lS,DropdownMenuTrigger as cS,Tooltip as dS,TooltipContent as uS,TooltipTrigger as pS,useTranslation as fS}from"@produto-lecom/lecom-ui";import{WrenchIcon as gS}from"lucide-react";import{jsx as ES,jsxs as bS}from"react/jsx-runtime";import{Position as Mt,useConnection as Wh,useReactFlow as Xh}from"@xyflow/react";import{useState as Uh}from"react";import{Fragment as Oc,jsx as Ue,jsxs as Zi}from"react/jsx-runtime";var Vc=({id:e,data:t,selected:o})=>{let{updateNodeData:n}=Xh(),{inProgress:r,fromNode:i}=Wh(),{reconnectingEdgeId:a}=Q(),[s,l]=Uh(!1),c=r&&(i==null?void 0:i.id)!==e||!!a,d=p=>{n(e,{label:p})},u=()=>{l(!0)},f=()=>{l(!1)};return Zi("div",{className:"relative",onDoubleClick:u,children:[Ue(vn,{className:R("size-9 hover:stroke-[#54890b] transition-colors duration-75",{"stroke-blue-500 hover:stroke-blue-600":o,"stroke-red-500 hover:stroke-red-600 drop-shadow-[0_0_3px_rgba(255,0,0,0.5)] fill-red-100":t.hasError})}),Ue("div",{className:"absolute top-10 left-1/2 -translate-x-1/2 max-w-80 w-max",children:Ue(Ce,{value:t.label,isEditing:s,onBlur:f,onChange:d})}),Ue(He,{nodeId:e,nodeType:"START_EVENT"}),(!r||c)&&Zi(Oc,{children:[Ue(te,{type:"target",position:Mt.Left,id:"left",className:R({"event-handle":c})}),Ue(te,{type:"target",position:Mt.Right,id:"right",className:R({"event-handle":c})}),Ue(te,{type:"target",position:Mt.Top,id:"top",className:R({"event-handle":c})}),Ue(te,{type:"target",position:Mt.Bottom,id:"bottom",className:R({"event-handle":c})})]}),!r&&Zi(Oc,{children:[Ue(Le,{type:"source",position:Mt.Left,id:"left",nodeId:e,nodeType:"START_EVENT"}),Ue(Le,{type:"source",position:Mt.Right,id:"right",nodeId:e,nodeType:"START_EVENT"}),Ue(Le,{type:"source",position:Mt.Top,id:"top",nodeId:e,nodeType:"START_EVENT"}),Ue(Le,{type:"source",position:Mt.Bottom,id:"bottom",nodeId:e,nodeType:"START_EVENT"})]})]})};import{useTranslation as qh}from"@produto-lecom/lecom-ui";import{Position as Pt,useConnection as Zh,useReactFlow as Jh}from"@xyflow/react";import{useCallback as Rr}from"react";var dn=60,kr=(e,t)=>{var a;let o=[],n=`${t} `;for(let s of e){if(!(s.type==="TASK"))continue;let c=(a=s.data)==null?void 0:a.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<=dn?i:i.substring(0,dn).trim()},wo=(e,t)=>{var s;let o=new Set;for(let l of t)l.type==="TASK"&&((s=l.data)!=null&&s.label)&&o.add(l.data.label);let n=e;if(n.length>dn&&(n=n.substring(0,dn).trim()),!o.has(n))return n;let r=n.replace(/\s+\(\d+\)$/,""),i=2,a=o.size+2;for(;i<=a;){let l=` (${i})`,c=dn-l.length,u=`${r.substring(0,c).trim()}${l}`;if(!o.has(u))return u;i++}return n};import{jsx as Hc,jsxs as $h}from"react/jsx-runtime";var Gc=e=>$h("svg",v(T({width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",xmlns:"http://www.w3.org/2000/svg"},e),{children:[Hc("circle",{cx:"12",cy:"12",r:"10",fill:"#10B981"}),Hc("path",{d:"M7 12L10 15L17 8",stroke:"white",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"})]}));import{jsx as Bc}from"react/jsx-runtime";var zc=e=>Bc("svg",v(T({width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",xmlns:"http://www.w3.org/2000/svg"},e),{children:Bc("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 Yc,jsxs as Kh}from"react/jsx-runtime";var Fc=e=>Kh("svg",v(T({width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",xmlns:"http://www.w3.org/2000/svg"},e),{children:[Yc("circle",{cx:"12",cy:"12",r:"10",fill:"#EF4444"}),Yc("path",{d:"M8 8L16 16M8 16L16 8",stroke:"white",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"})]}));import{Fragment as Dr,jsx as me,jsxs as un}from"react/jsx-runtime";var Qh={APROVADO:Gc,EM_ANDAMENTO:zc,REJEITADO:Fc},Ji={APROVADO:"border-green-500 border-[3px] border-solid",EM_ANDAMENTO:"border-turquoise-400 border-[3px] border-solid",REJEITADO:"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)]"},Wc=({id:e,data:t,selected:o,dragging:n})=>{let{t:r}=qh(),{toast:i}=Ve(),{updateNodeData:a,getNodes:s,setNodes:l}=Jh(),{inProgress:c,fromNode:d}=Zh(),{mode:u,onSubprocessValidationClick:f,reconnectingEdgeId:p}=Q(),{getTaskStatus:g}=Ot(),y=c&&(d==null?void 0:d.id)!==e||!!p,m=g(e),b=t.variant==="SUBPROCESS",h=!!t.variant&&!b||!!m,E=!!t.attribute||b,w=Rr(B=>{let P=h||E?80:40,$=B.split(`
41
+ `),H=$.reduce((L,V)=>Math.max(L,V.length),0),D=$.length,G=Math.max(yo.MIN_WIDTH,H*7+64),K=Math.max(yo.MIN_HEIGHT,D*24+P);l(L=>L.map(V=>V.id===e?v(T({},V),{width:G,height:K,style:v(T({},V.style),{width:G,height:K})}):V))},[e,l,h,E]),_=Rr(B=>{let q=B.trim(),j=t.label||"";if(q===j)return;let C=q,P=s();if(!(q&&q!=="")){C=kr(P,r("bpmn.task.label.prefix")),a(e,{label:C}),w(C),i({variant:"warning",content:un(Dr,{children:[r("bpmn.task.feedback.label_empty.prefix")," ",me("strong",{children:C})]})});return}let H=wo(C,P);H===j||(a(e,{label:H}),w(H),H!==C&&i({variant:"warning",content:un(Dr,{children:[r("bpmn.task.feedback.label_already_exists.prefix")," ",me("strong",{children:q})," ",r("bpmn.task.feedback.label_already_exists.middle")," ",me("strong",{children:H})]})}))},[t.label,s,e,r,a,w,i]),x=Rr(B=>{w(B)},[w]),N=Rr(()=>{i({variant:"error",content:r("bpmn.task.feedback.invalid_first_character")})},[r,i]),I=m?Qh[m]:null,A=t.variant?An[t.variant].icon:null,M=t.attribute?In[t.attribute].icon:null,S=()=>t.hasError?Ji.error:m?Ji[m]:Ji.default,k=()=>{f==null||f({id:e,type:"sub_process",label:t.label})};return un("div",{className:R("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",S(),{"border-blue-500 hover:border-blue-600 shadow-md":o,"border-red-500 hover:border-red-600 shadow-[0_0_5px_rgba(255,0,0,0.5)]":t.hasError}),children:[me("div",{className:"flex-1 flex items-stretch justify-stretch overflow-hidden",children:me(Ce,{value:t.label,maxLength:60,className:R({"py-10 px-8":h||E}),onChange:_,onInput:x,onInvalidFirstCharacter:N})}),A&&me("div",{className:R("absolute flex items-center p-1",b?"bottom-0 left-1/2 -translate-x-1/2":"top-0 left-0"),children:me(A,{size:16,className:R(t.hasError?"text-red-500":"text-grey-500",b&&"cursor-pointer"),onClick:b?k:void 0})}),M&&me("div",{className:"absolute bottom-0 left-0 w-full flex items-center justify-center",children:me("div",{className:R("flex items-center w-16 p-1",b?"justify-between":"justify-center"),children:me(M,{size:16,className:R(t.hasError?"text-red-500":"text-grey-500")})})}),I&&me("div",{className:"absolute top-0 right-0 flex items-center p-1",children:me(I,{})}),me(He,{nodeId:e,nodeType:"TASK",nodeVariant:t.variant}),u==="edit"&&me(No,{minWidth:yo.MIN_WIDTH,minHeight:yo.MIN_HEIGHT,isVisible:!n&&o}),(!c||y)&&un(Dr,{children:[me(te,{type:"target",position:Pt.Left,id:"left",className:R({"task-handle":y})}),me(te,{type:"target",position:Pt.Right,id:"right",className:R({"task-handle":y})}),me(te,{type:"target",position:Pt.Top,id:"top",className:R({"task-handle":y})}),me(te,{type:"target",position:Pt.Bottom,id:"bottom",className:R({"task-handle":y})})]}),!c&&un(Dr,{children:[me(Le,{type:"source",position:Pt.Left,id:"left",nodeId:e,nodeType:"TASK"}),me(Le,{type:"source",position:Pt.Right,id:"right",nodeId:e,nodeType:"TASK"}),me(Le,{type:"source",position:Pt.Top,id:"top",nodeId:e,nodeType:"TASK"}),me(Le,{type:"source",position:Pt.Bottom,id:"bottom",nodeId:e,nodeType:"TASK"})]})]})};import{Position as Xc}from"@xyflow/react";import{Fragment as jh,jsx as Or,jsxs as ey}from"react/jsx-runtime";var Uc=({id:e,data:t})=>ey(jh,{children:[Or("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}),Or(He,{nodeId:e,nodeType:"UNSUPPORTED"}),Or(te,{type:"source",position:Xc.Right}),Or(te,{type:"target",position:Xc.Left})]});import{BaseEdge as ty,EdgeLabelRenderer as oy,getSmoothStepPath as ny,MarkerType as ry,useInternalNode as $c,useReactFlow as iy,useViewport as sy,Position as Ao}from"@xyflow/react";import{useState as ay,useMemo as ly}from"react";import{Fragment as Kc,jsx as Ge,jsxs as Ut}from"react/jsx-runtime";var t5={type:"MESSAGE_EDGE",reconnectable:!0,markerEnd:{type:ry.Arrow},data:{label:""}},qc=({id:e,source:t,target:o,data:n,selected:r,sourcePosition:i,targetPosition:a,sourceHandleId:s,targetHandleId:l})=>{var V;let{zoom:c}=sy(),{updateEdgeData:d}=iy(),{isMultipleSelection:u,mode:f,instanceId:p}=Q(),g=f!=="edit",[y,m]=ay(!1),{reconnectingHandle:b,cursorPosition:h,hoveredNodeId:E,reconnectingSide:w,isValidReconnection:_,handleReconnectStart:x}=Ir({edgeId:e,source:t,target:o,instanceId:p,isReadOnly:g}),N=$c(t),I=$c(o),{sx:A,sy:M,tx:S,ty:k,sourcePos:B,targetPos:q}=ly(()=>{var le,ce;if(!N||!I)return{sx:0,sy:0,tx:0,ty:0,sourcePos:Ao.Left,targetPos:Ao.Right};let F=no(N,I),Y=s?i:F.sourcePos,O=l?a:F.targetPos,J=(de,ue,ge)=>{var ve,ke,yt,Jt,Qt,xe;let{x:he,y:fe}=de.internals.positionAbsolute,se=(yt=(ke=(ve=de.measured)==null?void 0:ve.width)!=null?ke:de.width)!=null?yt:0,ie=(xe=(Qt=(Jt=de.measured)==null?void 0:Jt.height)!=null?Qt:de.height)!=null?xe:0;switch(ue){case Ao.Top:return{x:he+se*ge,y:fe};case Ao.Bottom:return{x:he+se*ge,y:fe+ie};case Ao.Left:return{x:he,y:fe+ie*ge};case Ao.Right:return{x:he+se,y:fe+ie*ge};default:return{x:he+se/2,y:fe+ie/2}}},U=(le=n==null?void 0:n.sourceOffset)!=null?le:.5,X=(ce=n==null?void 0:n.targetOffset)!=null?ce:.5,z=N?J(N,Y,U).x:F.sx,W=N?J(N,Y,U).y:F.sy,Z=I?J(I,O,X).x:F.tx,ee=I?J(I,O,X).y:F.ty;return b==="source"&&h?(z=h.x,W=h.y,w&&(Y=w)):b==="target"&&h&&(Z=h.x,ee=h.y,w&&(O=w)),{sx:z,sy:W,tx:Z,ty:ee,sourcePos:Y,targetPos:O}},[N,I,s,l,i,a,b,h,w,n==null?void 0:n.sourceOffset,n==null?void 0:n.targetOffset]);if(!N||!I)return null;let[j,C,P]=ny({sourceX:A,sourceY:M,targetX:S,targetY:k,sourcePosition:B,targetPosition:q}),$=r||(N==null?void 0:N.selected)||(I==null?void 0:I.selected),H=$?"sequence-edge-marker-highlighted":"sequence-edge-marker",D=y||(n==null?void 0:n.label.trim().length)>0,G=()=>{m(!0)},K=()=>{m(!1)},L=F=>{d(e,{label:F.trim()})};return Ge(Kc,{children:Ut("g",{className:R("group bpmn-arrow-edge",{"is-highlighted":$}),onDoubleClick:G,children:[Ge("path",{d:j,fill:"none",stroke:"transparent",strokeWidth:Math.max(12,12/c),style:{pointerEvents:"stroke",cursor:"pointer"}}),Ut("g",{className:R("text-grey-500 transition-colors duration-75 group-hover:text-grey-800",{"text-blue-500 group-hover:text-blue-600":$}),children:[Ge(ty,{id:e,path:j,interactionWidth:0,markerEnd:`url(#${H})`,strokeDasharray:4,className:R("stroke-2 stroke-current transition-[stroke,filter] duration-75 group-hover:drop-shadow-[0_0_3px_rgba(0,0,0,0.2)]",{"stroke-red-500 hover:stroke-red-600":(n==null?void 0:n.hasError)||b&&E&&!_,"stroke-green-500":b&&E&&_,"stroke-blue-500 hover:stroke-blue-600 drop-shadow-[0_0_3px_rgba(59,130,246,0.5)]":$&&!(n!=null&&n.hasError)&&!b})}),Ut(oy,{children:[Ut("div",{className:"absolute z-[3000] pointer-events-auto flex flex-col items-center gap-1",style:{transform:`translate(-50%, -50%) translate(${C}px, ${P}px)`},children:[r&&!u&&Ge(po,{sx:A,sy:M,tx:S,ty:k,hasLabel:!!((V=n==null?void 0:n.label)!=null&&V.trim()),children:Ge(uo,{edgeId:e,edgeType:"MESSAGE_EDGE"})}),D&&Ge(Ce,{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:y,onBlur:K,onChange:L})]}),r&&!u&&!g&&Ut(Kc,{children:[Ge("div",{className:"absolute z-[1000] pointer-events-none",style:{transform:`translate(-50%, -50%) translate(${A}px, ${M}px)`},children:Ut("svg",{width:12/c,height:12/c,style:{overflow:"visible",position:"absolute",left:"50%",top:"50%",transform:"translate(-50%, -50%)"},children:[Ge("circle",{cx:6/c,cy:6/c,r:4/c,fill:b==="source"?"#3b82f6":"#fff",stroke:"#3b82f6",strokeWidth:2/c,className:"pointer-events-none"}),Ge("circle",{cx:6/c,cy:6/c,r:6/c,fill:"none",stroke:"#3b82f6",strokeWidth:1/c,opacity:b==="source"?.6:.3,className:"pointer-events-none"}),Ge("circle",{cx:6/c,cy:6/c,r:8/c,fill:"transparent",className:R("pointer-events-auto",{"cursor-move":!b||b!=="source","cursor-not-allowed":b==="source"&&E&&!_,"cursor-grabbing":b==="source"&&(!E||_)}),onMouseDown:F=>x("source",F.nativeEvent)})]})}),Ge("div",{className:"absolute z-[1000] pointer-events-none",style:{transform:`translate(-50%, -50%) translate(${S}px, ${k}px)`},children:Ut("svg",{width:12/c,height:12/c,style:{overflow:"visible",position:"absolute",left:"50%",top:"50%",transform:"translate(-50%, -50%)"},children:[Ge("circle",{cx:6/c,cy:6/c,r:4/c,fill:b==="target"?"#3b82f6":"#fff",stroke:"#3b82f6",strokeWidth:2/c,className:"pointer-events-none"}),Ge("circle",{cx:6/c,cy:6/c,r:6/c,fill:"none",stroke:"#3b82f6",strokeWidth:1/c,opacity:b==="target"?.6:.3,className:"pointer-events-none"}),Ge("circle",{cx:6/c,cy:6/c,r:8/c,fill:"transparent",className:R("pointer-events-auto",{"cursor-move":!b||b!=="target","cursor-not-allowed":b==="target"&&E&&!_,"cursor-grabbing":b==="target"&&(!E||_)}),onMouseDown:F=>x("target",F.nativeEvent)})]})})]})]})]})]})})};import{getStraightPath as cy,Position as Vr}from"@xyflow/react";import{jsx as Zc,jsxs as dy}from"react/jsx-runtime";var Jc=({toX:e,toY:t,fromNode:o})=>{var u,f;if(!o)return null;let{internals:{positionAbsolute:{x:n,y:r}},measured:i}=o,a=(u=i.width)!=null?u:0,s=(f=i.height)!=null?f:0,c=[{x:n,y:r+s/2,pos:Vr.Left},{x:n+a,y:r+s/2,pos:Vr.Right},{x:n+a/2,y:r,pos:Vr.Top},{x:n+a/2,y:r+s,pos:Vr.Bottom}].reduce((p,g)=>{let y=Math.hypot(e-p.x,t-p.y);return Math.hypot(e-g.x,t-g.y)<y?g:p}),[d]=cy({sourceX:c.x,sourceY:c.y,targetX:e,targetY:t});return dy("g",{className:"group",children:[Zc("path",{fill:"none",className:"stroke-2 stroke-grey-500 animated transition-[stroke,filter] duration-75",d}),Zc("circle",{cx:e,cy:t,fill:"none",r:4,className:"stroke-2 stroke-grey-600"})]})};import{Position as Lt,useConnection as uy,useReactFlow as py}from"@xyflow/react";import{orderBy as fy}from"lodash";import{useMemo as Qc,useState as my}from"react";import{Fragment as Qi,jsx as Be,jsxs as Hr}from"react/jsx-runtime";var jc=({id:e,data:t,selected:o,dragging:n,parentId:r})=>{let{updateNodeData:i,getNodes:a}=py(),{mode:s}=Q(),{inProgress:l,fromNode:c}=uy(),d=l&&(c==null?void 0:c.id)!==e,[u,f]=my(!1),p=a(),g=!r,y=Qc(()=>fy([...p.filter(_=>_.parentId===e&&_.type==="LANE")],"position.y","asc"),[p,e]),m=g?Pr.MIN_WIDTH:ye.MIN_WIDTH,b=Qc(()=>{if(g&&y.length>1){let _=[...y];return _.pop(),_.reduce((N,I)=>{var A,M;return N+((M=(A=I.measured)==null?void 0:A.height)!=null?M:0)},0)+ye.MIN_HEIGHT}return ye.MIN_HEIGHT},[g,y]),h=_=>{i(e,{label:_})},E=()=>{f(!0)},w=()=>{f(!1)};return Hr(Qi,{children:[Hr("div",{className:R("flex h-full min-h-64 w-full min-w-[50rem] hover:shadow-md bg-white outline outline-1 outline-grey-300",{"outline-offset-2 outline-blue-500 shadow-sm":o}),children:[Be("div",{className:"flex align-items justify-center w-10 border-r border-grey-300",onDoubleClick:E,children:Be("div",{className:"relative flex-1 [writing-mode:vertical-rl] [text-orientation:sideways] transform rotate-180",children:Be(Ce,{value:t.label,className:"w-full h-full self-auto",contentClassName:R({"whitespace-nowrap":u}),isEditing:u,onBlur:w,onChange:h})})}),Be("div",{className:"flex-1"})]}),Be(He,{nodeId:e,nodeType:"LANE",isChild:!g}),s==="edit"&&Be(No,{nodeId:e,minWidth:m,minHeight:b,isVisible:!n&&o}),!l&&Hr(Qi,{children:[Be(te,{type:"source",position:Lt.Left,id:"left"}),Be(te,{type:"source",position:Lt.Right,id:"right"}),Be(te,{type:"source",position:Lt.Top,id:"top"}),Be(te,{type:"source",position:Lt.Bottom,id:"bottom"})]}),(!l||d)&&Hr(Qi,{children:[Be(te,{type:"target",position:Lt.Left,id:"left",className:R({"annotation-handle":d})}),Be(te,{type:"target",position:Lt.Right,id:"right",className:R({"annotation-handle":d})}),Be(te,{type:"target",position:Lt.Top,id:"top",className:R({"annotation-handle":d})}),Be(te,{type:"target",position:Lt.Bottom,id:"bottom",className:R({"annotation-handle":d})})]})]})};var ed={START_EVENT:Vc,END_EVENT:kc,TASK:Wc,GATEWAY:Dc,ANNOTATION:Pc,LANE:jc,UNSUPPORTED:Uc},td={SEQUENCE_EDGE:Jl,MESSAGE_EDGE:qc,ANNOTATION_EDGE:Ol},od="#fafafa",nd="#bebebe",rd=1,id=10,sd="bottom-left",ji=.05,ad=5,Io=.5,Co=ji,So=1,ld={x:0,y:0,zoom:.75},cd=1,dd=2,gy={[cd]:4,[dd]:2},Gr=[cd,dd],ud=Gr.reduce((e,t)=>e|gy[t],0);import{useReactFlow as hy}from"@xyflow/react";var $e=()=>{let{getEdges:e,getNodes:t}=hy(),{lastElementId:o}=Q(),n=()=>{let i=t(),a=e(),s=bc(i,a);return Math.max(s,o)};return{getLastId:n,getNextId:()=>n()+1}};var Mo=()=>{let{getNodes:e,getEdges:t,setNodes:o,setEdges:n,setViewport:r}=xy(),{getLastId:i}=$e(),a=Ey(),{setLastElementId:s}=Q(),l=pd(async(d="")=>{let{nodes:u,edges:f,lastElementId:p}=await Tc(d),{width:g,height:y}=a.getState();if(g>0&&y>0){let m=mc(u);m&&r(yy(m,g,y,Co,So,Io))}o(u),n(f),s(p)},[o,n,s,a,r]),c=pd(()=>{let d=e(),u=t(),f=i();return _c(d,u,f)},[e,t,i]);return{importFromMxGraph:l,exportToMxGraph:c}};import{useCallback as fd}from"react";var _y=500,Br=()=>{let{isInitialized:e,onElementChanges:t}=Q(),{exportToMxGraph:o}=Mo(),n=by(()=>{if(!e)return;let a=o();t==null||t(a)},_y),r=fd(a=>{a.every(c=>c.type==="select")||a.some(c=>c.type==="position"&&c.dragging)||n()},[n]),i=fd(a=>{a.some(l=>l.type==="select")||n()},[n]);return{emitElementChanges:n,handleNodeChanges:r,handleEdgeChanges:i}};var md=({setEdges:e,saveHistory:t})=>{let{getNode:o,getEdges:n,getNodes:r,getInternalNode:i}=Ny(),{emitElementChanges:a}=Br(),s=vy(null),{getNextId:l}=$e(),c=$t(m=>{var _;let b=o(m.source),h=o(m.target);if(!b||!h)return!1;let E={sourceNodeId:b.id,targetNodeId:h.id,sourceNodeType:b.type,targetNodeType:h.type,nodes:r(),edges:n(),reconnectingEdgeId:(_=s.current)!=null?_:void 0};return Ri(E).isValid},[o,n,r]),d=$t(m=>{var E,w;let b=l(),h=i(m.source);if(h){let _=i(m.target),x=_?_.internals.positionAbsolute.x+((E=_.measured.width)!=null?E:0)/2:0,N=_?_.internals.positionAbsolute.y+((w=_.measured.height)!=null?w:0)/2:0,I=Ql(h,x,N),A=(_==null?void 0:_.type)==="ANNOTATION"||(h==null?void 0:h.type)==="ANNOTATION",M=A?fo:Fe,S;if(!A&&_&&m.targetHandle){let q=Sr(I),j=Sr(m.targetHandle),{x:C,y:P}=Hi(h,I),{x:$,y:H}=Hi(_,m.targetHandle),G=wr(C,P,$,H,q,j).slice(1,-1);G.length>0&&(S=G)}let k=v(T(T({},m),M),{id:String(b),sourceHandle:I,data:T(T({},A?{}:Fe.data),S?{points:S}:{})}),B=n().concat(k);e(B),t("forceSave",{nodes:r(),edges:B}),a()}},[l,e,a,i,n,r,t]),u=$t((m,b)=>{s.current=b.id},[]),f=$t(()=>{s.current=null},[]),p=$t((m,b)=>{let h=o(b.source),E=o(b.target);if(!h||!E){s.current=null;return}let w={sourceNodeId:h.id,targetNodeId:E.id,sourceNodeType:h.type,targetNodeType:E.type,nodes:r(),edges:n(),reconnectingEdgeId:m.id};if(!Ri(w).isValid){s.current=null;return}let x=Ty(m,b,n()).map(N=>N.id===m.id?v(T({},N),{data:v(T({},N.data),{points:void 0})}):N);e(x),t("forceSave",{nodes:r(),edges:x}),s.current=null,a()},[o,r,n,e,a,t]),g=$t(m=>{s.current=m},[]),y=$t(()=>{s.current=null},[]);return{isValidConnection:c,onConnect:d,onReconnect:p,onReconnectStart:u,onReconnectEnd:f,setReconnectingEdge:g,clearReconnectingEdge:y}};import{useTranslation as wy}from"@produto-lecom/lecom-ui";import{useReactFlow as Ay}from"@xyflow/react";import{useCallback as gn,useRef as Nd,useState as Iy}from"react";var pn=(e=[])=>e.filter(t=>t.type==="START_EVENT"),Kt=(e=[])=>e.filter(t=>t.type==="END_EVENT"),kt=(e=[])=>e.filter(t=>t.type==="TASK")||[],gd=(e=[])=>e.filter(t=>{var o;return t.type==="TASK"&&((o=t.properties)==null?void 0:o.variant)==="SCRIPT"}),hd=(e=[])=>e.filter(t=>{var o;return t.type==="TASK"&&((o=t.properties)==null?void 0:o.variant)==="SUBPROCESS"}),zr=(e=[])=>e.filter(t=>t.type==="GATEWAY"),yd=(e=[])=>e.filter(t=>{var o;return t.type==="GATEWAY"&&((o=t.properties)==null?void 0:o.variant)==="EXCLUSIVE"}),ze=(e,t=[])=>t.filter(o=>o.source===e),fn=(e,t=[])=>t.filter(o=>o.target===e),xd=(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"},Ed=(e,t)=>{let o=ze(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},bd=e=>e?/[^\s]/.test(e.trim()):!1,pe=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:[]}},st=(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)}},_d=(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:t.map(o=>({id:o.id,source:o.source,target:o.target,type:o.type||"default"}))});var mn=[{id:"start_event_not_found",validate:e=>{let t=pn(e.nodes);return pe({isValid:t.length>=1})}},{id:"end_event_not_found",validate:e=>{let t=Kt(e.nodes);return pe({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 pe({isValid:!0});if(!o)return pe({isValid:!1,nodeIds:t.map(i=>i.id)});let n=ze(t[0].id,e.edges);if(!(n.length<=1)){let i=[...t.map(a=>a.id),...n.map(a=>a.target)];return pe({isValid:!1,nodeIds:[...new Set(i)]})}return pe({isValid:!0})}},{id:"task_flows_limit_exceeds",validate:e=>{let t=kt(e.nodes),o=st(t,n=>ze(n.id,e.edges).length<=2);return pe({isValid:o.isValid,nodeIds:o.invalidIds})}},{id:"task_label_empty",highlightRelatedEdges:!1,validate:e=>{let t=kt(e.nodes),o=st(t,n=>!!n.label&&n.label.trim()!=="");return pe({isValid:o.isValid,nodeIds:o.invalidIds})}},{id:"task_label_length",highlightRelatedEdges:!1,validate:e=>{let o=kt(e.nodes),n=st(o,r=>!r.label||r.label.length<=60);return pe({isValid:n.isValid,nodeIds:n.invalidIds})}},{id:"duplicate_task_name",highlightRelatedEdges:!1,validate:e=>{let t=kt(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 pe({isValid:n.length===0,nodeIds:n})}},{id:"nested_gateway",validate:e=>{let t=zr(e.nodes),o=[],n=[];for(let r of t){let i=ze(r.id,e.edges);for(let a of i){let s=e.nodes.find(l=>l.id===a.target);s&&s.type==="GATEWAY"&&(o.push(r.id,s.id),n.push(a.id))}}return pe({isValid:o.length===0,nodeIds:o.length>0?[...new Set(o)]:[],edgeIds:n})}},{id:"events_nested",validate:e=>{let t=[...pn(e.nodes),...Kt(e.nodes)],o=[],n=[];for(let r of t){let i=ze(r.id,e.edges);for(let a of i){let s=e.nodes.find(l=>l.id===a.target);s&&(s.type==="START_EVENT"||s.type==="END_EVENT")&&(o.push(r.id,s.id),n.push(a.id))}}return pe({isValid:o.length===0,nodeIds:o.length>0?[...new Set(o)]:[],edgeIds:n})}},{id:"flows_on_end_tasks_not_allowed",validate:e=>{let t=Kt(e.nodes),o=[],n=[];for(let r of t){let i=fn(r.id,e.edges);for(let a of i){let s=e.nodes.find(l=>l.id===a.source);if(s&&s.type==="TASK"){let l=ze(s.id,e.edges);l.length>1&&(o.push(s.id),l.forEach(c=>n.push(c.id)))}}}return pe({isValid:o.length===0,nodeIds:o,edgeIds:n})}},{id:"conditions_flows_limit_exceeds",validate:e=>{let t=yd(e.nodes),o=st(t,r=>ze(r.id,e.edges).length<=2),n=o.invalidIds.flatMap(r=>ze(r,e.edges).map(i=>i.id));return pe({isValid:o.isValid,nodeIds:o.invalidIds,edgeIds:n})}},{id:"activity_name_invalid",validate:e=>{let t=kt(e.nodes),o=st(t,n=>!n.label||bd(n.label));return pe({isValid:o.isValid,nodeIds:o.invalidIds})}},{id:"final_activity_has_loop",validate:e=>{var a,s;if(!((a=e==null?void 0:e.nodes)!=null&&a.length)||!((s=e==null?void 0:e.edges)!=null&&s.length))return pe({isValid:!0});let t=Kt(e.nodes)[0];if(!t)return pe({isValid:!0});let o=fn(t.id,e.edges);if(!o.length)return pe({isValid:!0});let r=kt(e.nodes).filter(l=>o.some(c=>c.source===l.id)),i=st(r,l=>!xd(l.id,e));return pe({isValid:i.isValid,nodeIds:i.isValid?[]:[t.id,...i.invalidIds]})}},{id:"concurrent_initial_and_final_event",validate:e=>{let t=kt(e.nodes),o=Kt(e.nodes)[0];if(!o)return pe({isValid:!0});let n=t.filter(l=>{let c=fn(l.id,e.edges),d=ze(l.id,e.edges),u=c.some(p=>{var g;return((g=e.nodes.find(y=>y.id===p.source))==null?void 0:g.type)==="START_EVENT"}),f=d.some(p=>{var g;return((g=e.nodes.find(y=>y.id===p.target))==null?void 0:g.type)==="END_EVENT"});return u&&f}),r=fn(o.id,e.edges),i=r.length>1,a=r.map(l=>l.source),s={isValid:n.length===0&&!i,nodeIds:[...n.map(l=>l.id),...i?a:[]]};return pe(s)}},{id:"gateway_flow_to_event",validate:e=>{let t=zr(e.nodes),o=[],n=[];for(let r of t){let i=ze(r.id,e.edges);for(let a of i){let s=e.nodes.find(l=>l.id===a.target);s&&s.type==="END_EVENT"&&(o.push(r.id,s.id),n.push(a.id))}}return pe({isValid:o.length===0,nodeIds:o.length>0?[...new Set(o)]:[],edgeIds:n})}},{id:"gateway_missing_output_streams",validate:e=>{let t=zr(e.nodes),o=st(t,n=>ze(n.id,e.edges).length>=1);return pe({isValid:o.isValid,nodeIds:o.invalidIds})}},{id:"event_to_condition",validate:e=>{let t=[...pn(e.nodes),...Kt(e.nodes)],o=[],n=[];for(let r of t){let i=ze(r.id,e.edges);for(let a of i){let s=e.nodes.find(l=>l.id===a.target);s&&s.type==="GATEWAY"&&(o.push(r.id,s.id),n.push(a.id))}}return pe({isValid:o.length===0,nodeIds:o.length>0?[...new Set(o)]:[],edgeIds:n})}},{id:"script_in_final_activity",validate:e=>{let t=gd(e.nodes),o=st(t,n=>!Ed(n.id,e));return pe({isValid:o.isValid,nodeIds:o.invalidIds})}},{id:"subprocess_referenced_not_configured",validate:e=>{let t=hd(e.nodes),o=st(t,n=>{var r,i;return((r=n.properties)==null?void 0:r.subprocessRef)!==void 0&&((i=n.properties)==null?void 0:i.subprocessRef)!==""});return pe({isValid:o.isValid,nodeIds:o.invalidIds})}}];var Td=e=>{e=e||{nodes:[],edges:[]},e.nodes=e.nodes||[],e.edges=e.edges||[];let t=[];for(let n of mn){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}};import{jsx as Yr,jsxs as Cy}from"react/jsx-runtime";var vd=()=>{let{t:e}=wy(),{toast:t}=Ve(),{setNodes:o,setEdges:n,getNodes:r,getEdges:i}=Ay(),[a,s]=Iy(!1),l=Nd(!1),c=Nd(!1),d=gn(y=>{let m=_d(y.nodes,y.edges),b=Td(m),h=b.errors.map(E=>v(T({},E),{message:e(`validation.errors.${E.id}`)}));return a||s(!0),{isValid:b.isValid,errors:h}},[a,e]),u=gn((y,m=!0)=>{if(m&&y&&t({variant:y.isValid?"success":"error",duration:5e3,title:y.isValid?e("validation.success.title"):e("validation.errors.title"),content:Cy("div",{className:"flex flex-col gap-1",children:[!y.isValid&&Yr("span",{className:"body-small-500",children:e("validation.errors.subtitle")}),Yr("ul",{className:"list-disc list-inside max-h-40 overflow-y-auto",children:y.isValid?Yr("li",{children:e("validation.success.message")}):y.errors.map(S=>Yr("li",{className:"text-xs",children:S.message},S.id))})]})}),!y)return;l.current=!0,c.current=!0;let b=[],h=[];y.errors.forEach(S=>{S.nodeIds&&S.nodeIds.length>0&&S.nodeIds.forEach(k=>b.push(k)),S.edgeIds&&S.edgeIds.length>0&&S.edgeIds.forEach(k=>h.push(k))});let E=[...new Set(b)];o(S=>S.map(k=>v(T({},k),{data:v(T({},k.data),{hasError:!1})}))),n(S=>S.map(k=>v(T({},k),{data:v(T({},k.data),{hasError:!1})})));let w=r(),_=i(),x=new Set(E),N=new Set;y.errors.forEach(S=>{var q,j;let k=mn.find(C=>C.id===S.id);(k==null?void 0:k.highlightRelatedEdges)!==!1&&((q=S.edgeIds)==null||q.forEach(C=>N.add(C)),(j=S.nodeIds)==null||j.forEach(C=>{_.forEach(P=>{(P.source===C||P.target===C)&&N.add(P.id)})}))});let I=new Set,A=new Set,M=new Set;w.forEach(S=>{S.type==="START_EVENT"?I.add(S.id):S.type==="END_EVENT"&&A.add(S.id)}),_.forEach(S=>{I.has(S.source)&&M.add(S.target),A.has(S.target)&&M.add(S.source)}),M.forEach(S=>{var k,B;if(x.has(S)){let q=(k=y.errors.find(C=>{var P;return(P=C.nodeIds)==null?void 0:P.includes(S)}))==null?void 0:k.id;((B=mn.find(C=>C.id===q))==null?void 0:B.highlightRelatedEdges)!==!1&&_.forEach(C=>{C.source===S&&A.has(C.target)&&(x.add(C.target),N.add(C.id)),C.target===S&&I.has(C.source)&&(x.add(C.source),N.add(C.id))})}}),x.size>0&&o(S=>S.map(k=>v(T({},k),{data:v(T({},k.data),{hasError:x.has(k.id)})}))),N.size>0&&n(S=>S.map(k=>v(T({},k),{data:v(T({},k.data),{hasError:N.has(k.id)})}))),setTimeout(()=>{l.current=!1},0)},[e,i,r,n,o,t]),f=gn(()=>{s(!1),c.current=!1,o(y=>y.map(m=>v(T({},m),{data:v(T({},m.data),{hasError:!1})}))),n(y=>y.map(m=>v(T({},m),{data:v(T({},m.data),{hasError:!1})})))},[n,o]),p=gn(()=>{c.current&&(l.current=!0,c.current=!1,o(y=>y.map(m=>v(T({},m),{data:v(T({},m.data),{hasError:!1})}))),n(y=>y.map(m=>v(T({},m),{data:v(T({},m.data),{hasError:!1})}))),setTimeout(()=>{l.current=!1},0))},[n,o]),g=gn(()=>l.current,[]);return{validateDiagram:d,handleValidationComplete:u,clearValidation:f,dismissValidationPanel:p,isAutoValidationEnabled:a,getIsClearingValidation:g}};import{useReactFlow as Sy}from"@xyflow/react";import{useTranslation as My}from"@produto-lecom/lecom-ui";import{useEffect as Py}from"react";var Ly=15,wd="bpmn:selection",ky=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},Ad=e=>{if(!ky(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},Id=({offset:e=Ly,saveHistory:t})=>{let{t:o}=My(),{getNodes:n,setNodes:r,getEdges:i,setEdges:a}=Sy(),{getNextId:s}=$e();Py(()=>{let l=d=>{var b,h;if(!Ad(d))return;let u=n(),f=i(),p=u.filter(E=>E.selected);if(!p.length)return;d.preventDefault(),d.stopPropagation();let g=f.filter(E=>p.some(w=>w.id===E.source)&&p.some(w=>w.id===E.target)),m=JSON.stringify({nodes:p,edges:g});(b=d.clipboardData)==null||b.setData(wd,m),(h=d.clipboardData)==null||h.setData("text/plain",`BPMN Selection: ${p.length} nodes`)},c=d=>{var N,I;if(!Ad(d))return;let u=(N=d.clipboardData)==null?void 0:N.getData(wd);if(!u)return;d.preventDefault(),d.stopPropagation();let f;try{f=JSON.parse(u)}catch(A){return}if(!((I=f.nodes)!=null&&I.length))return;let p=new Map,g=n(),y=[],m=f.nodes.filter(A=>Nt(A.type,g));if(m.length===0)return;let b=s(),h=m.map(A=>{var k;let M=String(b++);p.set(A.id,M);let S=v(T({},A),{id:M,selected:!0,position:{x:A.position.x+e,y:A.position.y+e}});if(A.type==="TASK"){let B=(k=A.data)==null?void 0:k.label,q=wo(B||o("bpmn.task.label.prefix"),[...g,...y]);S.data=v(T({},A.data),{label:q})}return y.push(S),S}),E=f.edges.map(A=>v(T({},A),{id:String(b++),selected:!0,source:p.get(A.source)||A.source,target:p.get(A.target)||A.target})),w=[...g.map(A=>v(T({},A),{selected:!1})),...h],x=[...i().map(A=>v(T({},A),{selected:!1})),...E];r(w),a(x),t("forceSave",{nodes:w,edges:x})};return document.addEventListener("copy",l,!0),document.addEventListener("paste",c,!0),()=>{document.removeEventListener("copy",l,!0),document.removeEventListener("paste",c,!0)}},[n,r,i,a,s,e,o,t])};import{useReactFlow as Ry,useStoreApi as Dy}from"@xyflow/react";import{useTranslation as Oy}from"@produto-lecom/lecom-ui";import{useState as Vy}from"react";var Cd=({nodes:e,setNodes:t,setEdges:o,saveHistory:n})=>{let r=Dy(),{draggableNode:i,setDraggableNode:a}=vo(),{t:s}=Oy(),{getInternalNode:l,getNodes:c,getEdges:d,screenToFlowPosition:u}=Ry(),{getNextId:f}=$e(),{setIsDragging:p}=Q(),{rebuildIndex:g,forceRebuildIndex:y}=sr(),[m,b]=Vy(null),h=(C,P=!1)=>{let $=P?"node-drop-target-error":"node-drop-target",H=P?"node-drop-target-lane-error":"node-drop-target-lane";t(D=>D.map(G=>G.id===C?v(T({},G),{className:$}):C!==void 0&&G.parentId===C&&G.type==="LANE"?v(T({},G),{className:H}):v(T({},G),{className:""})))},E=()=>{let{nodeLookup:C}=r.getState();return Array.from(C.values())},w=(C,P)=>{let $=E();if(C.type==="LANE"){if(P){h();return}let L=$.filter(Y=>Y.id!==C.id&&Y.type==="LANE"&&!Y.parentId),V=rn(C,L);if(!V){h();return}if(To({parentId:V.id,nodes:e,excludeTypes:["LANE"]})){h(V.id,!0);return}h(V.id);return}let D=$.filter(L=>L.id!==C.id&&L.type==="LANE"),G=rn(C,D);if(!G){h();return}if(To({parentId:G.id,nodes:e,includeTypes:["LANE"]})){h();return}h(G.id)},_=C=>{let P=l(C.id),$=C.type==="LANE"&&To({parentId:C.id,nodes:e,includeTypes:["LANE"]});w(P,$)},x=C=>C.map(P=>v(T({},P),{className:void 0})),N=C=>C.some($=>$.dragging)?C.map($=>$.dragging?v(T({},$),{dragging:!1}):$):C,I=C=>{if(C.preventDefault(),C.dataTransfer.dropEffect="move",!(i!=null&&i.type))return;let P=u({x:C.clientX,y:C.clientY}),$={id:"__sidebar_drag__",type:i.type,position:P,measured:{width:1,height:1},internals:{positionAbsolute:P}};w($,!1)},A=C=>{let P=C.relatedTarget;(!P||!C.currentTarget.contains(P))&&h()},M=(C,P)=>{C.preventDefault(),_(P)},S=(C,P,$)=>{var L,V;let H=[...$];if(C.parentId===P.id)return H=yc(C,P,H),H=sn(H),x(H);if(C.type==="LANE"){if(To({parentId:P.id,nodes:H,excludeTypes:["LANE"]})){let U=dt(P),X=50,z=50;return H.map(W=>{var Z,ee;return W.id===C.id?v(T({},W),{position:{x:(Z=m==null?void 0:m.x)!=null?Z:U.x+X,y:(ee=m==null?void 0:m.y)!=null?ee:U.y2+z}}):W})}let O=H.filter(U=>U.parentId===P.id).reduce((U,X)=>{var z,W;return U+((W=(z=X.measured)==null?void 0:z.height)!=null?W:0)},0),J={x:ye.HEADER_WIDTH,y:O};return H=H.map(U=>U.id===C.id?v(T({},U),{parentId:P.id,position:J,className:void 0}):v(T({},U),{className:void 0})),H=an(P.id,H),H}if(To({parentId:P.id,nodes:H,includeTypes:["LANE"]})){let F;if(C.parentId){let Y=l(C.parentId),{x:O,y:J}=mt(Y);F={x:O+((L=C.position.x)!=null?L:0),y:J+((V=C.position.y)!=null?V:0)}}return H=H.map(Y=>Y.id===C.id?v(T({},Y),{position:F!=null?F:Y.position,parentId:void 0,className:void 0}):v(T({},Y),{className:void 0})),H}let K=uc(C,P);return H=H.map(F=>{if(F.id===C.id){let Y=dt(C),O=dt(P);return Y.y<O.y&&(K.y=0),Y.x<O.x+ye.HEADER_WIDTH&&(K.x=ye.HEADER_WIDTH),v(T({},F),{parentId:P.id,position:K,className:void 0})}return v(T({},F),{className:void 0})}),H=sn(H),H},k=C=>{if(C.preventDefault(),!(i!=null&&i.type))return;if(!Nt(i.type,c())){p(!1),a(null);return}let P=u({x:C.clientX,y:C.clientY}),$={width:re[i.type].MIN_WIDTH,height:re[i.type].MIN_HEIGHT},H=f(),D={id:String(H),type:i.type,position:P,measured:$,data:{label:i.type==="TASK"?kr(e,s("bpmn.task.label.prefix")):"",variant:i.variant,attribute:i.attribute},selected:!0},G=v(T({},D),{internals:{positionAbsolute:P}}),K=v(T({},G),{measured:{width:1,height:1}}),L=E(),V=i.type==="LANE",F=L.filter(z=>V?z.type==="LANE"&&!z.parentId:z.type==="LANE"),Y=rn(K,F),O=[...e.map(z=>v(T({},z),{selected:!1})),D];Y&&(O=S(G,Y,O)),O=Ft(O),O=x(O),t(O),y();let J=C.dataTransfer.getData("sourceId"),U=d(),X=U;if(J){let z={id:String(H+1),source:J,target:D.id},W=i.type==="ANNOTATION"?T(T({},z),fo):T(T({},z),Fe);X=U.concat(W),o(X)}n("forceSave",{nodes:O,edges:X}),p(!1),a(null)},B=async(C,P,$)=>{let H=[...e];$.forEach(D=>{let G=E(),K=l(D.id),L=D.type==="LANE",V=G.filter(Y=>Y.id!==D.id&&(L?Y.type==="LANE"&&!Y.parentId:Y.type==="LANE")),F=rn(K,V);if(F){H=S(K,F,H);return}D.parentId&&(H=j(D,H))}),H=N(H),H=Ft(H),H=x(H),t(H),g(H),b(null)},q=(C,P)=>{b({x:P.position.x,y:P.position.y})},j=(C,P)=>{var K,L;let $=l(C.parentId),{x:H,y:D}=mt($),G={x:H+((K=C.position.x)!=null?K:0),y:D+((L=C.position.y)!=null?L:0)};return P=P.map(V=>V.id===C.id?v(T({},V),{position:G,parentId:void 0}):V),P=an(C.parentId,P),P};return{onDragOver:I,onDragLeave:A,onDrop:k,onNodeDrag:M,onNodeDragStart:q,onNodeDragStop:B}};import{useReactFlow as Hy}from"@xyflow/react";import{useTranslation as Gy}from"@produto-lecom/lecom-ui";import{useEffect as By}from"react";var zy=30,Yy=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},Fy=e=>!Yy(e.target),Sd=({offset:e=zy,saveHistory:t})=>{let{t:o}=Gy(),{getNodes:n,setNodes:r,getEdges:i,setEdges:a}=Hy(),{getNextId:s}=$e();By(()=>{let l=c=>{if(c.ctrlKey&&c.key.toLowerCase()==="d"&&Fy(c)){c.preventDefault(),c.stopPropagation();let d=n(),u=i(),f=d.filter(x=>x.selected);if(!f.length)return;let p=new Map,g=[],y=f.filter(x=>Nt(x.type,d));if(y.length===0)return;let m=u.filter(x=>y.some(N=>N.id===x.source)&&y.some(N=>N.id===x.target)),b=s(),h=y.map(x=>{var A;let N=String(b++);p.set(x.id,N);let I=v(T({},x),{id:N,selected:!0,position:{x:x.position.x+e,y:x.position.y+e}});if(x.type==="TASK"){let M=(A=x.data)==null?void 0:A.label,S=wo(M||o("bpmn.task.label.prefix"),[...d,...g]);I.data=v(T({},x.data),{label:S})}return g.push(I),I}),E=m.map(x=>v(T({},x),{id:String(b++),selected:!0,source:p.get(x.source)||x.source,target:p.get(x.target)||x.target})),w=[...d.map(x=>v(T({},x),{selected:!1})),...h],_=[...u.map(x=>v(T({},x),{selected:!1})),...E];r(w),a(_),t("forceSave",{nodes:w,edges:_})}};return document.addEventListener("keydown",l,!0),()=>{document.removeEventListener("keydown",l,!0)}},[n,r,i,a,s,e,o,t])};import{useEffect as Wy,useRef as Md}from"react";import{useReactFlow as Xy}from"@xyflow/react";var Uy=20,$y=50,hn={UP:"ArrowUp",DOWN:"ArrowDown",LEFT:"ArrowLeft",RIGHT:"ArrowRight"},Ky=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},Pd=e=>{let{getNodes:t}=Xy(),{mode:o,isMoveTool:n}=Q(),r=Md(0),i=Md(new Map);Wy(()=>{let a=s=>{if(o!=="edit"||!n||Ky(s.target)||!Object.values(hn).includes(s.key))return;let u=t().filter(h=>h.selected);if(u.length===0){i.current.clear();return}s.preventDefault();let f=Date.now(),p=f-r.current<500;r.current=f;let g=s.shiftKey?$y:Uy,y=0,m=0;switch(s.key){case hn.UP:m=-g;break;case hn.DOWN:m=g;break;case hn.LEFT:y=-g;break;case hn.RIGHT:y=g;break}let b=u.map(h=>{let E=i.current.get(h.id);(!p||!E)&&(E={x:h.position.x,y:h.position.y});let w={x:E.x+y,y:E.y+m};return i.current.set(h.id,w),{id:h.id,dragging:!0,type:"position",position:w}});e&&e(b)};return window.addEventListener("keydown",a),()=>{window.removeEventListener("keydown",a)}},[t,e,o,n])};import{useReactFlow as Zy}from"@xyflow/react";var kd={"start-event":"START_EVENT","end-event":"END_EVENT",task:"TASK","gateway-exclusive":"GATEWAY"},Rd={"start-event":"","end-event":"",task:"","gateway-exclusive":"EXCLUSIVE"},Ld=(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)||[],a="",s="",l="";if(o.length){switch(o[1]){case"<start>":a="start-event";break;case"<end>":a="end-event";break}e=e.replace(o[1],"")}return n.length&&(a="task",s=n[1].replace(/\[|\]/g,""),e=e.replace(n[1],"")),r.length&&(a="gateway-exclusive",s=r[1].replace(/\{|\}/g,""),e=e.replace(r[1],"")),a||(a="task",s=e),i.length&&(l=i[1].replace(/(\||--)/g,""),e=e.replace(i[1],"")),e=e.trim(),t[e]||(t[e]={type:a,label:s}),{step:e,type:a,label:s,edgeLabel:l}},qy=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 a=Ld(i[0],o),s=Ld(i[1],o);a&&s&&n.push({sourceId:a.step,targetId:s.step,label:a.edgeLabel||s.edgeLabel||""})}),{components:o,connections:n}},Dd=e=>{let{components:t,connections:o}=qy(e);return{nodes:t,edges:o}};var Od=()=>{let{setNodes:e,setEdges:t,fitView:o}=Zy(),{getNextId:n}=$e();return{importFromLia:i=>{let a=typeof i=="string"?i:i.diagramXml||"",{nodes:s,edges:l}=Dd(a),c=[],d=new Map,u=!1,f=n();for(let[m,b]of Object.entries(s)){let h=String(f++),E=kd[b.type],w=Rd[b.type];E==="START_EVENT"&&(u=!0),d.set(m,h);let _=re[E].MIN_WIDTH,x=re[E].MIN_HEIGHT;c.push({id:h,type:E,data:{label:b.label||"",variant:w,attribute:""},position:{x:0,y:0},width:_,height:x,measured:{width:_,height:x}})}let p=[];for(let m of l){let b=v(T({},Fe),{id:String(f++),source:d.get(m.sourceId)||m.sourceId,target:d.get(m.targetId)||m.targetId});p.push(b)}if(!u&&c.length>0){let m=String(f++),b={id:m,type:"START_EVENT",data:{label:"",variant:"",attribute:""},position:{x:0,y:0},width:re.START_EVENT.MIN_WIDTH,height:re.START_EVENT.MIN_HEIGHT,measured:{width:re.START_EVENT.MIN_WIDTH,height:re.START_EVENT.MIN_HEIGHT}};c.unshift(b);let h=c[1];if(h){let E=v(T({},Fe),{id:String(f++),source:m,target:h.id});p.unshift(E)}}let{nodes:g,edges:y}=hc(c,p);e(g),t(y),o({padding:Io,minZoom:Co,maxZoom:So})}}};import{useEffect as Jy,useCallback as Qy}from"react";var jy={origin:"*",debug:!1};function Vd(e,t=jy){let{origin:o,debug:n}=t,r=Qy((i,a)=>{let s={event:i,data:[i,{event:i,data:a}]};window.parent.postMessage(s,o||"*")},[o]);return Jy(()=>{let i=a=>{let s=a.data;if(!(s!=null&&s.event)||(s==null?void 0:s.data)===void 0)return;let{event:l,data:c}=s,d;if(Array.isArray(c)){let[,u]=c;d=u.data}else d=c;n&&(console.debug("[postMessage] received:",s),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 e0}from"@xyflow/react";import{useEffect as Hd}from"react";var Gd=()=>{let e=e0(),{initialDiagram:t,setIsInitialized:o}=Q(),{importFromMxGraph:n}=Mo();Hd(()=>{t&&n(t)},[t,n,o]),Hd(()=>{if(!e)return;(async()=>{await Nn(),o(!0)})()},[e,o])};import{useCallback as Bd}from"react";import{useReactFlow as t0}from"@xyflow/react";function zd(){let{setTaskStatuses:e,clearTaskStatuses:t,calculateFlowPath:o}=Ot(),{getEdges:n}=t0(),r=Sn(),i=Bd(s=>{if(!(s!=null&&s.activities))return;e(s.activities);let l=s.activities.map(d=>d.diagramId),c=n();o(c,l),setTimeout(()=>{r()},0)},[e,o,n,r]),a=Bd(()=>{t(),setTimeout(()=>{r()},0)},[t,r]);return{handleTasksStatus:i,handleClearTaskStatus:a}}import{useReactFlow as o0}from"@xyflow/react";import{useCallback as gt,useState as n0,useEffect as Yd}from"react";import{useDebouncedCallback as r0}from"use-debounce";var i0=500,Fd=100,Wd=(e=!1)=>{let{getNodes:t,getEdges:o,setNodes:n,setEdges:r}=o0(),[i,a]=n0({history:[],currentStep:0}),{history:s,currentStep:l}=i,c=l>0,d=l<s.length-1,u=gt((_,x)=>{n(_[x].nodes),r(_[x].edges)},[n,r]),f=gt(()=>{if(l>0){let _=l-1;a(x=>v(T({},x),{currentStep:_})),u(s,_)}},[l,s,u]),p=gt(()=>{if(l<s.length-1){let _=l+1;a(x=>v(T({},x),{currentStep:_})),u(s,_)}},[s,l,u]),g=gt(_=>{a(x=>{let N=x.history[x.currentStep];if(N&&JSON.stringify(N)===JSON.stringify(_))return x;let M=[...x.history.slice(0,x.currentStep+1),_],S=M.length>Fd?M.slice(M.length-Fd):M;return{history:S,currentStep:S.length-1}})},[]),y=gt((_,x)=>{let N=_.map(A=>v(T({},A),{selected:!1,className:"",data:v(T({},A.data),{hasError:!1})})),I=x.map(A=>v(T({},A),{data:v(T({},A.data),{hasError:!1})}));return{nodes:Ft(N),edges:I}},[]),m=gt(()=>y(t(),o()),[t,o,y]),b=r0(()=>{let _=m();g(_)},i0),h=gt((_,x)=>{if(!e)return;if(s.length===0){let A=m();a({history:[A],currentStep:0})}if(_==="forceSave"){if(x){g(y(x.nodes,x.edges));return}b();return}_.some(A=>A.type==="select")||_.some(A=>A.type==="position"&&A.dragging)||b()},[e,b,s.length,m,g,y]);Yd(()=>{if(e&&s.length===0){let _=m();a({history:[_],currentStep:0})}},[e,s.length,m]);let E=gt(_=>{a({history:_||[],currentStep:0})},[]),w=gt(()=>{a({history:[],currentStep:0})},[]);return Yd(()=>{let _=x=>{(x.ctrlKey||x.metaKey)&&(x.shiftKey&&x.key.toLowerCase()==="z"?(x.preventDefault(),p()):x.key.toLowerCase()==="z"&&(x.preventDefault(),f()))};return document.addEventListener("keydown",_),()=>{document.removeEventListener("keydown",_)}},[f,p]),{history:s,undo:f,redo:p,canUndo:c,canRedo:d,saveHistory:h,resetHistory:E,clearHistory:w}};var Xd=()=>{let{t:e}=s0(),[t,o,n]=l0([]),[r,i,a]=a0([]),{getNode:s}=d0(),{toast:l}=Ve(),c=u0(),{instanceId:d,isInitialized:u,setIsConnecting:f,setIsMultipleSelection:p,onElementClick:g}=Q(),{updateHelperLines:y,HelperLines:m}=sr(),{undo:b,redo:h,canUndo:E,canRedo:w,saveHistory:_}=Wd(u),{onNodeDrag:x,onDrop:N,onDragOver:I,onDragLeave:A,onNodeDragStop:M,onNodeDragStart:S}=Cd({nodes:t,setNodes:o,setEdges:i,saveHistory:_}),{isValidConnection:k,onConnect:B,onReconnect:q,onReconnectStart:j,onReconnectEnd:C,setReconnectingEdge:P,clearReconnectingEdge:$}=md({setEdges:i,saveHistory:_}),{handleValidationComplete:H,clearValidation:D,dismissValidationPanel:G,validateDiagram:K,getIsClearingValidation:L}=vd(),{importFromLia:V}=Od(),{handleTasksStatus:F,handleClearTaskStatus:Y}=zd(),{clearPathEdges:O}=Ot(),{emitElementChanges:J,handleNodeChanges:U,handleEdgeChanges:X}=Br(),z=Sn();Id({saveHistory:_}),Sd({saveHistory:_}),Gd();let W=Rt(()=>{o([]),i([]),O(),setTimeout(z,0)},[o,i,O,z]);Vd({LIA_CREATE_DIAGRAM:V,CLEAR_DIAGRAM:W,TASKS_STATUS:F,CLEAR_TASKS_STATUS:Y});let{selectElements:Z,clearSelection:ee}=vt(),{importFromMxGraph:le,exportToMxGraph:ce}=Mo(),{configureElement:de,getConfigureElement:ue}=mr(),ge=Rt(()=>t.length+r.length,[t,r]);p0(()=>(it.set(d,{importFromMxGraph:le,exportToMxGraph:ce,selectElements:Z,clearSelection:ee,configureElement:de,getConfigureElement:ue,getElementsCount:ge,setReconnectingEdge:P,clearReconnectingEdge:$}),()=>{it.delete(d)}),[d,le,ce,Z,ee,de,ue,ge,P,$]);let he=Rt((xe,Ie)=>{if(Ie.type!=="TASK"&&Ie.type!=="GATEWAY")return;let et=ue(Ie.id);et&&(g==null||g(et))},[ue,g]),fe=Rt((xe,Ie)=>{if(Ie.type!=="SEQUENCE_EDGE")return;let et=s(Ie.source),si=s(Ie.target),{isFromStartEvent:Cu,isGatewayToGateway:Su,isActiviyToAndGateway:Mu}=Cn(et,si);if(!(!Cu&&!Su&&!Mu))return;let ls=ue(Ie.id);ls&&(g==null||g(ls))},[ue,s,g]),se=Rt(xe=>{let Ie=y(xe,t);n(Ie),_(xe),L()||G(),U(xe)},[t,n,_,L,G,y,U]),ie=Rt(xe=>{a(xe),_(xe),L()||G(),X(xe)},[a,_,L,G,X]);Pd(se);let ve=Rt(({nodes:xe,edges:Ie})=>{p(xe.length+Ie.length>=2)},[p]);c0({onChange:ve});let ke=Rt(async({nodes:xe})=>xe.some(et=>et.type==="LANE"&&t.some(si=>si.parentId===et.id))?(l({variant:"error",title:e("validation.errors.title"),content:e("editor.toolbar.delete_pool_lane_error")}),!1):!0,[t,e,l]);return{nodes:t,setNodes:o,edges:r,setEdges:i,events:{isValidConnection:k,onConnect:B,onReconnect:q,onReconnectStart:j,onReconnectEnd:C,onDrop:N,onDragOver:I,onDragLeave:A,onNodeDrag:x,onNodeDragStop:M,onNodeDragStart:S,onNodeClick:he,onEdgeClick:fe,onDropCapture:()=>{_("forceSave"),J(),G()},onConnectStart:()=>{f(!0)},onConnectEnd:()=>{f(!1),G()},onSelectionEnd:()=>setTimeout(()=>c.setState({nodesSelectionActive:!1}),0),onNodesChange:se,onEdgesChange:ie,onBeforeDelete:ke},ui:{handleCloseValidationPanel:D},controls:{undo:b,redo:h,canUndo:E,canRedo:w},components:{HelperLines:m},actions:{saveHistory:_,selectElements:Z,clearSelection:ee,exportToMxGraph:ce,validateDiagram:K,handleValidationComplete:H,setReconnectingEdge:P,clearReconnectingEdge:$}}};import{jsx as Ud}from"react/jsx-runtime";var Fr=({id:e,className:t})=>Ud("marker",{id:e,className:R("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:Ud("path",{d:"M 0 0 L 10 5 L 0 10 Z"})});import{jsx as Wr,jsxs as f0}from"react/jsx-runtime";var $d=()=>Wr("svg",{style:{position:"absolute",top:0,left:0},children:f0("defs",{children:[Wr(Fr,{id:"sequence-edge-marker",className:"text-grey-500"}),Wr(Fr,{id:"sequence-edge-marker-hovered",className:"text-grey-800"}),Wr(Fr,{id:"sequence-edge-marker-highlighted",className:"text-blue-500"})]})});import{Tooltip as Dx,TooltipContent as Ox,TooltipTrigger as Vx,useTranslation as Hx}from"@produto-lecom/lecom-ui";import{useKeyPress as pu,useReactFlow as ox}from"@xyflow/react";import{Button as Jr,Tooltip as Qr,TooltipContent as jr,TooltipTrigger as ei,useTranslation as nx}from"@produto-lecom/lecom-ui";import{HandIcon as rx,ListCheckIcon as ix,MapIcon as sx,MousePointerIcon as ax}from"lucide-react";import{useCallback as ns,useEffect as fu}from"react";import{Tooltip as k0,TooltipContent as R0,TooltipTrigger as D0,useTranslation as O0}from"@produto-lecom/lecom-ui";var yn=(E=>(E.START_EVENT="START_EVENT",E.END_EVENT="END_EVENT",E.TASK="TASK",E.SUBPROCESS="SUBPROCESS",E.GATEWAY="GATEWAY",E.LANE="LANE",E.ANNOTATION="ANNOTATION",E.CONNECTION="CONNECTION",E.INTERMEDIATE_EVENT="INTERMEDIATE_EVENT",E.ACTIVITY="ACTIVITY",E.PROCESS_INTERFACE="PROCESS_INTERFACE",E.WORKFLOW_INTERFACE="WORKFLOW_INTERFACE",E.VARIANT_ACTIVITY="VARIANT_ACTIVITY",E.AUTO_ACTIVITY="AUTO_ACTIVITY",E.DATA_STORE="DATA_STORE",E.DATA_OBJECT="DATA_OBJECT",E.DATA_OUTPUT="DATA_OUTPUT",E.DATA_INPUT="DATA_INPUT",E.MARKER="MARKER",E))(yn||{});import{Button as w0,useTranslation as A0}from"@produto-lecom/lecom-ui";import{useReactFlow as I0}from"@xyflow/react";var Kd=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 qd({columns:e=[],rows:t=[],fileName:o="report"}){if(!e.length||!t.length)return;let r="data:text/csv;charset=utf-8,"+[e,...t].map(a=>a.join(",")).join(`
43
+ `),i=encodeURI(r);Xr(i,`${o}.csv`)}var Xr=(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 Zd(e){return e==null?void 0:e.replaceAll("&#xA;"," ")}var e3={START_EVENT:"START_EVENT",END_EVENT:"END_EVENT",TASK:"TASK",GATEWAY:"GATEWAY",ANNOTATION:"ANNOTATION"},Jd={script:"SCRIPT",subprocess:"SUBPROCESS"},Qd={"marker-loop":"LOOP"},jd={complex:"COMPLEX",none:"EXCLUSIVE",exclusive:"EXCLUSIVE",parallel:"PARALLEL",inclusive:"EXCLUSIVE"};var qt=({cell:e,type:t,variant:o="",attribute:n=""})=>{let{_attributes:r,mxGeometry:i}=e,{value:a,parent:s}=r,l=Number(i._attributes.width),c=Number(i._attributes.height),d=s==="1"?void 0:s;return{id:r.id,parentId:d,type:t,data:{label:a||"",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}}},g0=e=>{let{subType:t,style:o}=e._attributes,n="imported";return["none"].includes(t)||(n="adapted"),e.mxGeometry._attributes.width=re.START_EVENT.MIN_WIDTH,e.mxGeometry._attributes.height=re.START_EVENT.MIN_HEIGHT,{node:qt({cell:e,type:"START_EVENT"}),status:n,originalType:o}},h0=e=>{let{subType:t,style:o}=e==null?void 0:e._attributes,n="imported";return["none"].includes(t)||(n="adapted"),e.mxGeometry._attributes.width=re.END_EVENT.MIN_WIDTH,e.mxGeometry._attributes.height=re.END_EVENT.MIN_HEIGHT,{node:qt({cell:e,type:"END_EVENT"}),status:n,originalType:o}},y0=(e,t)=>{let{id:o,subType:n,style:r}=e==null?void 0:e._attributes,i=Jd[n],a=t.get(o)||"",s=Qd[a]||"",l=s==="LOOP",c="imported";return!["script","none"].includes(n)&&!l&&(c="adapted"),e.mxGeometry._attributes.width=xt(e.mxGeometry._attributes.width||0,re.TASK.MIN_WIDTH),e.mxGeometry._attributes.height=xt(e.mxGeometry._attributes.height||0,re.TASK.MIN_HEIGHT),{node:qt({cell:e,type:"TASK",variant:i,attribute:s}),status:c,originalType:r}},x0=e=>{let{style:t,subType:o}=e==null?void 0:e._attributes,n=jd[o],r=["none","inclusive","event-based"],i="imported";return r.includes(o)&&(i="adapted"),e.mxGeometry._attributes.width=re.GATEWAY.MIN_WIDTH,e.mxGeometry._attributes.height=re.GATEWAY.MIN_HEIGHT,{node:qt({cell:e,type:"GATEWAY",variant:n}),status:i,originalType:t}},E0=e=>{let{style:t}=e==null?void 0:e._attributes;return{node:qt({cell:e,type:"LANE"}),status:"imported",originalType:t}},b0=e=>{let{style:t}=e==null?void 0:e._attributes;return e.mxGeometry._attributes.width=xt(e.mxGeometry._attributes.width||0,re.ANNOTATION.MIN_WIDTH),e.mxGeometry._attributes.height=xt(e.mxGeometry._attributes.height||0,re.ANNOTATION.MIN_HEIGHT),{node:qt({cell:e,type:"ANNOTATION"}),status:"imported",originalType:t}},eu=e=>{let{style:t}=e==null?void 0:e._attributes;return e.mxGeometry._attributes.width=re.UNSUPPORTED.MIN_WIDTH,e.mxGeometry._attributes.height=re.UNSUPPORTED.MIN_HEIGHT,{node:qt({cell:e,type:"UNSUPPORTED"}),status:"unsupported",originalType:t}},tu=(e,t)=>{let{id:o,source:n,target:r,value:i}=e._attributes;return v(T({},Fe),{id:o,source:t.get(n)||n,target:t.get(r)||r,data:{label:i||""}})},ou={TASK:y0,GATEWAY:x0,START_EVENT:g0,END_EVENT:h0,LANE:E0,ANNOTATION:b0};var _0=e=>{let t=new Map,o=Object.values(yn),n=[],r=new Map;e.forEach(s=>{var c;let l=(c=s._attributes)==null?void 0:c.type;if(l==="MARKER"){r.set(s._attributes.parent,s._attributes.style);return}if(o.includes(l)){n.push(s);return}});let i=[],a=[];for(let s of n){let{type:l}=s._attributes,c=ou[l]||eu,{node:d,status:u,originalType:f}=c(s,r);a.push(d),i.push({originalType:f,type:d.type,variant:d.data.variant,value:Zd(d.data.label),status:u})}return{nodes:a,governanceIdToNodeIdMap:t,summary:i}},T0=(e,t)=>e.filter(r=>{var i;return(i=r._attributes)==null?void 0:i.edge}).map(r=>tu(r,t)),N0=e=>{let{mxGraphModel:t}=e,{nodes:o,governanceIdToNodeIdMap:n,summary:r}=_0(t.root.mxCell),i=T0(t.root.mxCell,n);return{nodes:o,edges:i,summary:r}},v0=async e=>{let t=await Kd(e),o=Mr(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),a=r==null?void 0:r.root;if(!i||!a)throw new Error("INVALID_FILE");if(!Object.keys(r.root.mxCell||{}).length)throw new Error("CONTAIN_NO_CELLS");return{metadata:n,mxGraphModel:r}},nu=async e=>{try{let t=await v0(e),{nodes:o,edges:n,summary:r}=N0(t)||{};return{nodes:o,edges:n,summary:r}}catch(t){throw t}};import{jsx as C0}from"react/jsx-runtime";var ru=()=>{let{t:e}=A0(),{toast:t}=Ve(),{setNodes:o,setEdges:n,fitView:r}=I0(),i=s=>{let l=[e("adapter.governance.report.columns.type"),e("adapter.governance.report.columns.value"),e("adapter.governance.report.columns.status")],c=s.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:C0(w0,{size:"small",variant:"ghost",onClick:()=>qd({columns:l,rows:c,fileName:"governance-imported-cells"}),children:e("adapter.governance.action.download")})})};return{importFromGovernance:async s=>{try{let{nodes:l,edges:c,summary:d}=await nu(s);if(o(f=>f.concat(l)),n(f=>f.concat(c)),r({padding:Io,minZoom:Co,maxZoom:So}),d.some(f=>f.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 S0}from"@produto-lecom/lecom-ui";import{useRef as M0}from"react";import{Fragment as P0,jsx as iu,jsxs as L0}from"react/jsx-runtime";var su=s=>{var l=s,{children:e,accept:t="*",multiple:o=!1,disabled:n=!1,onClick:r,onFilesSelected:i}=l,a=tt(l,["children","accept","multiple","disabled","onClick","onFilesSelected"]);let c=M0(null),d=f=>{let p=f.target.files;p!=null&&p.length&&i(p),c.current&&(c.current.value="")};return L0(P0,{children:[iu(S0,v(T({disabled:n,onClick:f=>{var p;(p=c.current)==null||p.click(),r==null||r(f)}},a),{children:e})),iu("input",{type:"file",ref:c,className:"sr-only",accept:t,multiple:o,disabled:n,onChange:d})]})};import{jsx as Ur,jsxs as V0}from"react/jsx-runtime";var au=({disabled:e=!1})=>{let{t}=O0(),{toast:o}=Ve(),{importFromGovernance:n}=ru(),r=()=>{if(e){o({variant:"error",content:t("adapter.governance.error.ALREADY_INITIALIZED")});return}},i=a=>{let s=a[0];if(!s){o({variant:"error",content:t("adapter.governance.error.NO_FILE")});return}n(s)};return V0(k0,{children:[Ur(D0,{asChild:!0,children:Ur(su,{className:"[&>svg]:size-7 p-0",variant:"ghost",size:"small",color:"grey",iconButton:!0,accept:".mdr",disabled:e,onClick:r,onFilesSelected:i,children:Ur(Es,{})})}),Ur(R0,{color:"black",children:t("editor.controls.actions.import_governance")})]})};import{jsx as H0}from"react/jsx-runtime";var es=({shortcut:e})=>H0("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 U0,DropdownMenu as $0,DropdownMenuContent as K0,DropdownMenuItem as os,DropdownMenuTrigger as q0,Tooltip as Kr,TooltipContent as qr,TooltipTrigger as Zr,useTranslation as Z0}from"@produto-lecom/lecom-ui";import{FileCodeIcon as J0,FileImageIcon as Q0,FolderOutputIcon as j0,PrinterIcon as ex}from"lucide-react";import{useState as tx}from"react";import{useTranslation as G0}from"@produto-lecom/lecom-ui";import{useReactFlow as B0}from"@xyflow/react";import{toPng as lu,toSvg as z0}from"html-to-image";import{useState as Y0}from"react";var F0=3,ts="diagram",$r=50,W0=96,X0=25.4,cu=e=>e*X0/W0,du=()=>{let{t:e}=G0(),{toast:t}=Ve(),{getNodes:o,getNodesBounds:n}=B0(),{clearSelection:r}=vt(),[i,a]=Y0({png:!1,html:!1,print:!1}),s=()=>{let f=zi(o()),p=n(f),g=p.width+$r*2,y=p.height+$r*2,m=$r-p.x,b=$r-p.y;return{width:g,height:y,style:{width:`${g}px`,height:`${y}px`,transform:`translate(${m}px, ${b}px)`,transformOrigin:"top left"}}},l=async(f,p)=>{a(g=>v(T({},g),{[p]:!0})),await r();try{if(zi(o()).length===0){t({content:e("editor.controls.actions.export.feedback.empty"),variant:"warning"});return}let y=xc();if(!y)throw new Error("Flow element not found");let m=s();return await f(y,m)}catch(g){console.error("Diagram export failed",g),t({content:e("editor.controls.actions.export.feedback.error"),variant:"error"})}finally{a(g=>v(T({},g),{[p]:!1}))}};return{exportAsPng:async(f=ts)=>{await l(async(p,g)=>{let y=await lu(p,v(T({},g),{backgroundColor:"#fcfcfc",skipFonts:!0}));Xr(y,`${f}.png`)},"png")},exportAsHtml:async(f=ts)=>{await l(async(p,g)=>{let y=await z0(p,v(T({},g),{backgroundColor:"#fcfcfc",skipFonts:!0})),m=`
44
44
  <!DOCTYPE html>
45
45
  <html>
46
46
  <head>
@@ -67,7 +67,7 @@ var Pu=Object.defineProperty,Lu=Object.defineProperties;var ku=Object.getOwnProp
67
67
  <body>
68
68
  <img src="${y}" alt="${f}" />
69
69
  </body>
70
- </html>`,_=new Blob([m],{type:"text/html"}),h=URL.createObjectURL(_);Fr(h,`${f}.html`),window.setTimeout(()=>URL.revokeObjectURL(h),1e4)},"html")},printDiagram:async(f=ts)=>{await l(async(p,g)=>{var I;let y=await lu(p,v(T({},g),{backgroundColor:"#fcfcfc",pixelRatio:F0,skipFonts:!0})),m=document.createElement("iframe");m.style.position="fixed",m.style.right="0",m.style.bottom="0",m.style.width="0",m.style.height="0",m.style.border="0",document.body.appendChild(m);let _=(I=m.contentWindow)==null?void 0:I.document;if(!_)throw document.body.removeChild(m),new Error("Unable to access print iframe document");let h=cu(g.width).toFixed(2),E=cu(g.height).toFixed(2),w=_.createElement("style");w.textContent=`
70
+ </html>`,b=new Blob([m],{type:"text/html"}),h=URL.createObjectURL(b);Xr(h,`${f}.html`),window.setTimeout(()=>URL.revokeObjectURL(h),1e4)},"html")},printDiagram:async(f=ts)=>{await l(async(p,g)=>{var I;let y=await lu(p,v(T({},g),{backgroundColor:"#fcfcfc",pixelRatio:F0,skipFonts:!0})),m=document.createElement("iframe");m.style.position="fixed",m.style.right="0",m.style.bottom="0",m.style.width="0",m.style.height="0",m.style.border="0",document.body.appendChild(m);let b=(I=m.contentWindow)==null?void 0:I.document;if(!b)throw document.body.removeChild(m),new Error("Unable to access print iframe document");let h=cu(g.width).toFixed(2),E=cu(g.height).toFixed(2),w=b.createElement("style");w.textContent=`
71
71
  @page {
72
72
  size: ${h}mm ${E}mm;
73
73
  margin: 0;
@@ -83,4 +83,4 @@ var Pu=Object.defineProperty,Lu=Object.defineProperties;var ku=Object.getOwnProp
83
83
  height: 100%;
84
84
  object-fit: contain;
85
85
  }
86
- `,_.head.appendChild(w),_.title=f;let b=_.createElement("img");b.alt="Diagram",_.body.appendChild(b),await new Promise((A,M)=>{let S=!1,k=B=>{S||(S=!0,B?M(B):A())};b.onload=()=>k(),b.onerror=()=>k(new Error("Failed to load print image")),b.src=y,b.complete&&b.naturalWidth>0&&k()});let x=m.contentWindow;if(!x)throw document.body.removeChild(m),new Error("Unable to access print iframe window");let N=()=>{m.parentNode&&document.body.removeChild(m)};x.addEventListener("afterprint",N,{once:!0}),window.setTimeout(N,6e4),x.focus(),x.print()},"print")},isPrintingPng:i.png,isPrintingHtml:i.html,isPrinting:i.print}};import{jsx as Te,jsxs as Po}from"react/jsx-runtime";function uu(){let{t:e}=Z0(),{exportAsPng:t,exportAsHtml:o,printDiagram:n,isPrinting:r,isPrintingPng:i,isPrintingHtml:a}=du(),[s,l]=tx(!1);return Po($0,{modal:!1,open:s,onOpenChange:l,children:[Te(q0,{asChild:!0,children:Te("div",{children:Po(Ur,{children:[Te(Kr,{asChild:!0,children:Te(U0,{size:"small",variant:"ghost",color:"grey",iconButton:!0,children:Te(j0,{})})}),!s&&Te($r,{color:"black",children:e("editor.controls.actions.export.title")})]})})}),Po(K0,{align:"center",side:"top",sideOffset:16,className:"min-w-0 flex flex-col gap-2 p-2 shadow-sm",children:[Po(Ur,{children:[Te(Kr,{asChild:!0,children:Te(os,{className:"p-1.5",disabled:i,onClick:()=>t(),children:Te(Q0,{})})}),Te($r,{side:"right",color:"black",children:e("editor.controls.actions.export.png")})]}),Po(Ur,{children:[Te(Kr,{asChild:!0,children:Te(os,{className:"p-1.5",disabled:a,onClick:()=>o(),children:Te(J0,{})})}),Te($r,{side:"right",color:"black",children:e("editor.controls.actions.export.html")})]}),Po(Ur,{children:[Te(Kr,{asChild:!0,children:Te(os,{className:"p-1.5",disabled:r,onClick:()=>n(),children:Te(ex,{})})}),Te($r,{side:"right",color:"black",children:e("editor.controls.actions.export.print")})]})]})]})}import{Fragment as mu,jsx as Ne,jsxs as ht}from"react/jsx-runtime";var gu=({nodes:e,edges:t,validateDiagram:o,handleValidationComplete:n})=>{let{t:r}=nx(),{clearSelection:i}=vt(),{mode:a,isMinimapOpen:s,setIsMinimapOpen:l,isMoveTool:c,isHandTool:d,setIsMoveTool:u,setIsHandTool:f}=Q(),{getNodes:p,getEdges:g}=ox(),y=pu(["v","V"]),m=pu(["h","H"]),_=ns(()=>{i(),f(!0),u(!1)},[i,f,u]),h=ns(()=>{u(!0),f(!1)},[u,f]),E=ns(()=>{let w=p(),b=g(),x=o({nodes:w,edges:b});n(x)},[p,g,o,n]);return fu(()=>{y&&!c&&a==="edit"&&h()},[y,h,c,a]),fu(()=>{m&&!d&&a==="edit"&&_()},[m,_,d,a]),ht("div",{className:"flex items-center gap-2 px-3 py-2 bg-white rounded-sm shadow-md",children:[a==="edit"&&ht(mu,{children:[ht(Zr,{children:[Ne(Qr,{asChild:!0,children:Ne(qr,{size:"small",variant:"ghost",color:"grey",className:D(c&&"bg-grey-400"),iconButton:!0,onClick:h,children:Ne(ax,{})})}),ht(Jr,{color:"black",className:"flex items-center gap-2",children:[r("editor.controls.actions.move_tool"),Ne(es,{shortcut:"V"})]})]}),ht(Zr,{children:[Ne(Qr,{asChild:!0,children:Ne(qr,{size:"small",variant:"ghost",color:"grey",className:D(d&&"bg-grey-400"),iconButton:!0,onClick:_,children:Ne(rx,{})})}),ht(Jr,{color:"black",className:"flex items-center gap-2",children:[r("editor.controls.actions.hand_tool")," ",Ne(es,{shortcut:"H"})]})]})]}),Ne(uu,{}),a==="edit"&&ht(mu,{children:[ht(Zr,{children:[Ne(Qr,{asChild:!0,children:Ne(qr,{size:"small",variant:"ghost",color:"grey",iconButton:!0,onClick:E,children:Ne(ix,{})})}),Ne(Jr,{color:"black",children:r("editor.controls.actions.check")})]}),Ne(au,{disabled:e.length>0||t.length>0})]}),ht(Zr,{children:[Ne(Qr,{asChild:!0,children:Ne(qr,{size:"small",variant:"ghost",color:"grey",className:D(s&&"bg-grey-400"),iconButton:!0,onClick:()=>l(!s),children:Ne(sx,{})})}),Ne(Jr,{color:"black",children:r(s?"editor.controls.actions.minimap.close":"editor.controls.actions.minimap.open")})]})]})};import{Button as hu,Tooltip as yu,TooltipContent as xu,TooltipTrigger as Eu,useTranslation as lx}from"@produto-lecom/lecom-ui";import{RedoIcon as cx,UndoIcon as dx}from"lucide-react";import{jsx as Dt,jsxs as rs}from"react/jsx-runtime";var bu=({undo:e,redo:t,canUndo:o,canRedo:n})=>{let{t:r}=lx();return rs("div",{className:"flex items-center gap-2 px-3 py-2 bg-white rounded-sm shadow-md",children:[rs(yu,{children:[Dt(Eu,{asChild:!0,children:Dt(hu,{size:"small",variant:"ghost",color:"grey",iconButton:!0,disabled:!o,onClick:e,children:Dt(dx,{})})}),Dt(xu,{color:"black",children:r("editor.controls.history.undo")})]}),rs(yu,{children:[Dt(Eu,{asChild:!0,children:Dt(hu,{size:"small",variant:"ghost",color:"grey",iconButton:!0,disabled:!n,onClick:t,children:Dt(cx,{})})}),Dt(xu,{color:"black",children:r("editor.controls.history.redo")})]})]})};import{useEdges as ux,useNodes as px,useReactFlow as fx}from"@xyflow/react";import{Button as jr,Tooltip as ei,TooltipContent as ti,TooltipTrigger as oi,useTranslation as mx}from"@produto-lecom/lecom-ui";import{ScanIcon as gx,ZoomIn as hx,ZoomOut as yx}from"lucide-react";import{jsx as Me,jsxs as xn}from"react/jsx-runtime";var _u=()=>{let{t:e}=mx(),t=px(),o=ux(),{zoomIn:n,zoomOut:r,zoomTo:i,fitView:a}=fx(),s=t.length===0&&o.length===0;return xn("div",{className:"flex items-center gap-2 px-3 py-2 bg-white rounded-sm shadow-md",children:[xn(ei,{children:[Me(oi,{asChild:!0,children:Me(jr,{iconButton:!0,size:"small",color:"grey",variant:"ghost",disabled:s,onClick:()=>a(),children:Me(gx,{})})}),Me(ti,{color:"black",children:e("editor.controls.zoom.fit")})]}),xn(ei,{children:[Me(oi,{asChild:!0,children:Me(jr,{iconButton:!0,size:"small",color:"grey",variant:"ghost",disabled:s,onClick:()=>r(),children:Me(yx,{})})}),Me(ti,{color:"black",children:e("editor.controls.zoom.out")})]}),xn(ei,{children:[Me(oi,{asChild:!0,children:Me(jr,{iconButton:!0,size:"small",color:"grey",variant:"ghost",disabled:s,onClick:()=>i(1),children:Me(Ts,{})})}),Me(ti,{color:"black",children:e("editor.controls.zoom.reset")})]}),xn(ei,{children:[Me(oi,{asChild:!0,children:Me(jr,{iconButton:!0,size:"small",color:"grey",variant:"ghost",disabled:s,onClick:()=>n(),children:Me(hx,{})})}),Me(ti,{color:"black",children:e("editor.controls.zoom.in")})]})]})};import{useNodes as xx}from"@xyflow/react";import{Button as Ex,Tooltip as bx,TooltipContent as _x,TooltipTrigger as Tx,useTranslation as Nx}from"@produto-lecom/lecom-ui";import{useRef as vx,useState as wx}from"react";import{jsx as Zt,jsxs as Tu}from"react/jsx-runtime";var Nu=()=>{let e=vx(null),{t}=Nx(),{setDraggableNode:o}=vo(),n=xx(),{setIsDragging:r}=Q(),[i,a]=wx(void 0),s=[{type:"START_EVENT",icon:vn,label:t("bpmn.start_event.variant.default")},{type:"END_EVENT",icon:jt,label:t("bpmn.end_event.variant.default")},{type:"TASK",icon:ko,label:t("bpmn.task.variant.default")},{type:"TASK",variant:"SUBPROCESS",icon:Is,label:t("bpmn.task.variant.subprocess")},{type:"TASK",variant:"SCRIPT",icon:As,label:t("bpmn.task.variant.script")},{type:"TASK",attribute:"LOOP",icon:ws,label:t("bpmn.task.attribute.loop")},{type:"GATEWAY",variant:"EXCLUSIVE",icon:to,label:t("bpmn.gateway.variant.exclusive")},{type:"GATEWAY",variant:"PARALLEL",icon:oo,label:t("bpmn.gateway.variant.parallel")},{type:"GATEWAY",variant:"COMPLEX",icon:eo,label:t("bpmn.gateway.variant.complex")},{type:"LANE",icon:_s,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}),a(Zt(d.icon,{})),c.dataTransfer.effectAllowed="move",e.current&&c.dataTransfer.setDragImage(e.current,10,10),setTimeout(()=>{r(!0)},100)};return Tu("aside",{className:"sidebar absolute z-[1] top-4 left-4",children:[Zt("div",{className:"grid grid-cols-1 gap-2 p-2 bg-white rounded-md shadow-md",children:s.map((c,d)=>{let u=!Nt(c.type,n),f=u?t("editor.toolbar.start_event_already_exists"):c.label;return Tu(bx,{children:[Zt(Tx,{asChild:!0,children:Zt(Ex,{className:D("[&>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:p=>l(p,c),children:Zt(c.icon,{})},d)}),Zt(_x,{color:"black",side:"right",children:f})]},d)})}),Zt("div",{ref:e,className:"absolute w-0 h-0 top-0 left-0 z-[-1] bg-transparent",children:i})]})};import{jsx as Qe,jsxs as ni}from"react/jsx-runtime";var is=Px((e,t)=>{let o=Mx("Space"),{instanceId:n,mode:r,isMinimapOpen:i,isMoveTool:a,isHandTool:s}=Q(),[l,c]=Rx(!1),d=kx(null),{nodes:u,edges:f,actions:p,events:g,components:y,controls:m}=Xd(),{t:_}=Hx();Lx(t,()=>({selectElements:p.selectElements,clearSelection:p.clearSelection})),vu(()=>{let x=d.current;if(!x)return;let N=A=>{s||o||r==="edit"&&Gr.some(M=>M===A.button)&&c(!0)},I=A=>{(A.buttons&ud)===0&&c(!1)};return x.addEventListener("pointerdown",N),window.addEventListener("pointerup",I),()=>{x.removeEventListener("pointerdown",N),window.removeEventListener("pointerup",I)}},[s,o,r]),vu(()=>{let x=d.current;if(!x)return;let N=x.querySelector(".react-flow__pane");if(!N)return;let I=A=>A.preventDefault();return N.addEventListener("contextmenu",I),()=>N.removeEventListener("contextmenu",I)},[]);let h=s||o||r!=="edit"?!0:Gr,E=r!=="readonly"&&a&&!o,w=r==="edit"&&a&&!o,b=r==="edit"&&a&&!o;return ni("div",{ref:d,className:"w-full h-full",children:[r==="edit"&&Qe(Nu,{}),Qe($d,{}),ni(Cx,v(T({},g),{id:`modeler-${n}`,className:D({"is-hand-tool":s||o||l}),edges:f,nodes:u,nodeTypes:ed,edgeTypes:td,minZoom:Ji,maxZoom:ad,panOnDrag:h,panOnScroll:!0,selectionOnDrag:!0,elevateEdgesOnSelect:!0,elevateNodesOnSelect:!1,elementsSelectable:E,nodesConnectable:w,nodesDraggable:b,connectionLineComponent:Jc,selectionMode:Sx.Partial,multiSelectionKeyCode:["Control","Meta"],deleteKeyCode:"Delete",selectionKeyCode:null,defaultViewport:ld,connectOnClick:!1,connectionRadius:50,proOptions:{hideAttribution:!0},children:[Qe(Ax,{gap:id,size:rd,color:nd,bgColor:od}),i&&ni(Dx,{children:[Qe(Vx,{asChild:!0,children:Qe("div",{className:"absolute bottom-[0px] left-[0px] z-[5]",children:Qe(Ix,{pannable:!0,zoomable:!0,position:sd,className:"shadow-md rounded-md",ariaLabel:"",style:{pointerEvents:"all",position:"relative"}})})}),Qe(Ox,{color:"black",children:_("editor.controls.actions.minimap.label")})]}),ni("div",{className:"absolute z-10 bottom-4 left-1/2 -translate-x-1/2 flex gap-4",children:[r==="edit"&&Qe(bu,T({},m)),Qe(gu,{nodes:u,edges:f,validateDiagram:p.validateDiagram,handleValidationComplete:p.handleValidationComplete}),Qe(_u,{})]}),Qe(y.HelperLines,{})]}))]})});is.displayName="Editor";import{useStore as Gx}from"@xyflow/react";import{useEffect as Bx,useRef as zx}from"react";import{jsx as Fx}from"react/jsx-runtime";var Yx=e=>({width:e.width,height:e.height,transform:e.transform}),ss="rgba(51, 103, 217, 0.4)",vl=({horizontal:e,vertical:t})=>{let{width:o,height:n,transform:r}=Gx(Yx),i=zx(null);return Bx(()=>{let a=i.current,s=a==null?void 0:a.getContext("2d");if(!s||!a)return;let l=window.devicePixelRatio;a.width=o*l,a.height=n*l,s.clearRect(0,0,o,n),s.scale(l,l),s.strokeStyle=ss,t&&(s.beginPath(),s.strokeStyle=t.color||ss,s.moveTo(t.position*r[2]+r[0],0),s.lineTo(t.position*r[2]+r[0],n),s.stroke()),e&&(s.beginPath(),s.strokeStyle=e.color||ss,s.moveTo(0,e.position*r[2]+r[1]),s.lineTo(o,e.position*r[2]+r[1]),s.stroke())},[o,n,r,e,t]),Fx("canvas",{ref:i,className:"w-full h-full absolute z-10 pointer-events-none"})};import{i18n as Wx,Notification as Xx,TooltipProvider as Ux}from"@produto-lecom/lecom-ui";import{createContext as $x,useContext as Kx,useEffect as qx,useState as Zx}from"react";import{jsx as wu,jsxs as Qx}from"react/jsx-runtime";var it=new Map,Au=$x(null),en=()=>{let e=Kx(Au);if(!e)throw new Error("useModeler must be used within an <ModelerProvider />");return e},Jx=({locale:e,defaultMode:t="view",toast:o,children:n})=>{let[r,i]=Zx(e||"pt_BR");qx(()=>{e&&(i(e),Wx.changeLanguage(e))},[e]);let a=g=>{let y=it.size;if(y===0)throw new Error("No modeler instances found");if(y===1||!g){let[_]=it.values();return _}let m=it.get(g);if(!m)throw new Error(`Modeler instance with ID "${g}" not found`);return m},s=(g,y)=>{let m=a(y);return m==null?void 0:m.selectElements(g)},l=async g=>{let y=a(g);return y==null?void 0:y.clearSelection()},c=(g,y)=>{let m=a(y);return m==null?void 0:m.configureElement(g)},d=(g,y)=>{let m=a(y);return m==null?void 0:m.getConfigureElement(g)},u=async(g,y)=>{let m=a(y);await(m==null?void 0:m.importFromMxGraph(g))},f=g=>{let y=a(g);return y==null?void 0:y.exportToMxGraph()},p=g=>{let y=a(g);return(y==null?void 0:y.getElementsCount())||0};return wu(Au.Provider,{value:{defaultMode:t,locale:r,selectElements:s,clearSelection:l,configureElement:c,getConfigureElement:d,importDiagram:u,exportDiagram:f,getElementsCount:p,toast:o},children:Qx(Ux,{children:[!o&&wu(Xx,{type:"toast",placement:"topRight",enableClose:!0,showProgress:!0,pauseOnHover:!0}),n]})})};import{useTranslation as iE}from"@produto-lecom/lecom-ui";import{jsx as as}from"react/jsx-runtime";var Iu=eE(null),Q=()=>{let e=tE(Iu);if(!e)throw new Error("useModelerInstance must be used within an <Modeler />");return e},sE=({selectorRef:e,initialDiagram:t,instanceId:o,mode:n,onElementChanges:r,onConfigureElement:i,onElementClick:a,onSubprocessValidationClick:s})=>{let{t:l}=iE(),{defaultMode:c}=en(),d=nE(),[u]=je(o||d),[f,p]=je(n||c||"edit"),[g,y]=je(ln),[m,_]=je(!1),[h,E]=je(!0),[w,b]=je(!1),[x,N]=je(!1),[I,A]=je(!1),[M,S]=je(!1),[k,B]=je(!1),[q,j]=je(null);oE(()=>{n&&p(n)},[n]);let C=rE(()=>t||Ec(l),[t,l]),P={instanceId:u,initialDiagram:C,mode:f,lastElementId:g,isInitialized:m,isMinimapOpen:x,isMoveTool:h,isHandTool:w,isDragging:I,isMultipleSelection:k,isConnecting:M,setLastElementId:y,setIsInitialized:_,reconnectingEdgeId:q,setIsMinimapOpen:N,setIsMoveTool:E,setIsHandTool:b,setIsDragging:A,setIsConnecting:S,setIsMultipleSelection:B,setReconnectingEdgeId:j,onElementChanges:r,onConfigureElement:i,onElementClick:a,onSubprocessValidationClick:s};return as(jx,{children:as(Iu.Provider,{value:P,children:as(is,{ref:e})})})};export{Re as EditorMode,si as ElementPosition,bn as ElementType,ai as GatewayElementVariant,qe as GatewayVariant,sE as Modeler,Jx as ModelerProvider,ot as NodeAttribute,oe as NodeType,Ke as NodeVariant,li as RoutingVariant,en as useModeler};
86
+ `,b.head.appendChild(w),b.title=f;let _=b.createElement("img");_.alt="Diagram",b.body.appendChild(_),await new Promise((A,M)=>{let S=!1,k=B=>{S||(S=!0,B?M(B):A())};_.onload=()=>k(),_.onerror=()=>k(new Error("Failed to load print image")),_.src=y,_.complete&&_.naturalWidth>0&&k()});let x=m.contentWindow;if(!x)throw document.body.removeChild(m),new Error("Unable to access print iframe window");let N=()=>{m.parentNode&&document.body.removeChild(m)};x.addEventListener("afterprint",N,{once:!0}),window.setTimeout(N,6e4),x.focus(),x.print()},"print")},isPrintingPng:i.png,isPrintingHtml:i.html,isPrinting:i.print}};import{jsx as Te,jsxs as Po}from"react/jsx-runtime";function uu(){let{t:e}=Z0(),{exportAsPng:t,exportAsHtml:o,printDiagram:n,isPrinting:r,isPrintingPng:i,isPrintingHtml:a}=du(),[s,l]=tx(!1);return Po($0,{modal:!1,open:s,onOpenChange:l,children:[Te(q0,{asChild:!0,children:Te("div",{children:Po(Kr,{children:[Te(Zr,{asChild:!0,children:Te(U0,{size:"small",variant:"ghost",color:"grey",iconButton:!0,children:Te(j0,{})})}),!s&&Te(qr,{color:"black",children:e("editor.controls.actions.export.title")})]})})}),Po(K0,{align:"center",side:"top",sideOffset:16,className:"min-w-0 flex flex-col gap-2 p-2 shadow-sm",children:[Po(Kr,{children:[Te(Zr,{asChild:!0,children:Te(os,{className:"p-1.5",disabled:i,onClick:()=>t(),children:Te(Q0,{})})}),Te(qr,{side:"right",color:"black",children:e("editor.controls.actions.export.png")})]}),Po(Kr,{children:[Te(Zr,{asChild:!0,children:Te(os,{className:"p-1.5",disabled:a,onClick:()=>o(),children:Te(J0,{})})}),Te(qr,{side:"right",color:"black",children:e("editor.controls.actions.export.html")})]}),Po(Kr,{children:[Te(Zr,{asChild:!0,children:Te(os,{className:"p-1.5",disabled:r,onClick:()=>n(),children:Te(ex,{})})}),Te(qr,{side:"right",color:"black",children:e("editor.controls.actions.export.print")})]})]})]})}import{Fragment as mu,jsx as Ne,jsxs as ht}from"react/jsx-runtime";var gu=({nodes:e,edges:t,validateDiagram:o,handleValidationComplete:n})=>{let{t:r}=nx(),{clearSelection:i}=vt(),{mode:a,isMinimapOpen:s,setIsMinimapOpen:l,isMoveTool:c,isHandTool:d,setIsMoveTool:u,setIsHandTool:f}=Q(),{getNodes:p,getEdges:g}=ox(),y=pu(["v","V"]),m=pu(["h","H"]),b=ns(()=>{i(),f(!0),u(!1)},[i,f,u]),h=ns(()=>{u(!0),f(!1)},[u,f]),E=ns(()=>{let w=p(),_=g(),x=o({nodes:w,edges:_});n(x)},[p,g,o,n]);return fu(()=>{y&&!c&&a==="edit"&&h()},[y,h,c,a]),fu(()=>{m&&!d&&a==="edit"&&b()},[m,b,d,a]),ht("div",{className:"flex items-center gap-2 px-3 py-2 bg-white rounded-sm shadow-md",children:[a==="edit"&&ht(mu,{children:[ht(Qr,{children:[Ne(ei,{asChild:!0,children:Ne(Jr,{size:"small",variant:"ghost",color:"grey",className:R(c&&"bg-grey-400"),iconButton:!0,onClick:h,children:Ne(ax,{})})}),ht(jr,{color:"black",className:"flex items-center gap-2",children:[r("editor.controls.actions.move_tool"),Ne(es,{shortcut:"V"})]})]}),ht(Qr,{children:[Ne(ei,{asChild:!0,children:Ne(Jr,{size:"small",variant:"ghost",color:"grey",className:R(d&&"bg-grey-400"),iconButton:!0,onClick:b,children:Ne(rx,{})})}),ht(jr,{color:"black",className:"flex items-center gap-2",children:[r("editor.controls.actions.hand_tool")," ",Ne(es,{shortcut:"H"})]})]})]}),Ne(uu,{}),a==="edit"&&ht(mu,{children:[ht(Qr,{children:[Ne(ei,{asChild:!0,children:Ne(Jr,{size:"small",variant:"ghost",color:"grey",iconButton:!0,onClick:E,children:Ne(ix,{})})}),Ne(jr,{color:"black",children:r("editor.controls.actions.check")})]}),Ne(au,{disabled:e.length>0||t.length>0})]}),ht(Qr,{children:[Ne(ei,{asChild:!0,children:Ne(Jr,{size:"small",variant:"ghost",color:"grey",className:R(s&&"bg-grey-400"),iconButton:!0,onClick:()=>l(!s),children:Ne(sx,{})})}),Ne(jr,{color:"black",children:r(s?"editor.controls.actions.minimap.close":"editor.controls.actions.minimap.open")})]})]})};import{Button as hu,Tooltip as yu,TooltipContent as xu,TooltipTrigger as Eu,useTranslation as lx}from"@produto-lecom/lecom-ui";import{RedoIcon as cx,UndoIcon as dx}from"lucide-react";import{jsx as Dt,jsxs as rs}from"react/jsx-runtime";var bu=({undo:e,redo:t,canUndo:o,canRedo:n})=>{let{t:r}=lx();return rs("div",{className:"flex items-center gap-2 px-3 py-2 bg-white rounded-sm shadow-md",children:[rs(yu,{children:[Dt(Eu,{asChild:!0,children:Dt(hu,{size:"small",variant:"ghost",color:"grey",iconButton:!0,disabled:!o,onClick:e,children:Dt(dx,{})})}),Dt(xu,{color:"black",children:r("editor.controls.history.undo")})]}),rs(yu,{children:[Dt(Eu,{asChild:!0,children:Dt(hu,{size:"small",variant:"ghost",color:"grey",iconButton:!0,disabled:!n,onClick:t,children:Dt(cx,{})})}),Dt(xu,{color:"black",children:r("editor.controls.history.redo")})]})]})};import{useEdges as ux,useNodes as px,useReactFlow as fx}from"@xyflow/react";import{Button as ti,Tooltip as oi,TooltipContent as ni,TooltipTrigger as ri,useTranslation as mx}from"@produto-lecom/lecom-ui";import{ScanIcon as gx,ZoomIn as hx,ZoomOut as yx}from"lucide-react";import{jsx as Me,jsxs as xn}from"react/jsx-runtime";var _u=()=>{let{t:e}=mx(),t=px(),o=ux(),{zoomIn:n,zoomOut:r,zoomTo:i,fitView:a}=fx(),s=t.length===0&&o.length===0;return xn("div",{className:"flex items-center gap-2 px-3 py-2 bg-white rounded-sm shadow-md",children:[xn(oi,{children:[Me(ri,{asChild:!0,children:Me(ti,{iconButton:!0,size:"small",color:"grey",variant:"ghost",disabled:s,onClick:()=>a(),children:Me(gx,{})})}),Me(ni,{color:"black",children:e("editor.controls.zoom.fit")})]}),xn(oi,{children:[Me(ri,{asChild:!0,children:Me(ti,{iconButton:!0,size:"small",color:"grey",variant:"ghost",disabled:s,onClick:()=>r(),children:Me(yx,{})})}),Me(ni,{color:"black",children:e("editor.controls.zoom.out")})]}),xn(oi,{children:[Me(ri,{asChild:!0,children:Me(ti,{iconButton:!0,size:"small",color:"grey",variant:"ghost",disabled:s,onClick:()=>i(1),children:Me(Ts,{})})}),Me(ni,{color:"black",children:e("editor.controls.zoom.reset")})]}),xn(oi,{children:[Me(ri,{asChild:!0,children:Me(ti,{iconButton:!0,size:"small",color:"grey",variant:"ghost",disabled:s,onClick:()=>n(),children:Me(hx,{})})}),Me(ni,{color:"black",children:e("editor.controls.zoom.in")})]})]})};import{useNodes as xx}from"@xyflow/react";import{Button as Ex,Tooltip as bx,TooltipContent as _x,TooltipTrigger as Tx,useTranslation as Nx}from"@produto-lecom/lecom-ui";import{useRef as vx,useState as wx}from"react";import{jsx as Zt,jsxs as Tu}from"react/jsx-runtime";var Nu=()=>{let e=vx(null),{t}=Nx(),{setDraggableNode:o}=vo(),n=xx(),{setIsDragging:r}=Q(),[i,a]=wx(void 0),s=[{type:"START_EVENT",icon:vn,label:t("bpmn.start_event.variant.default")},{type:"END_EVENT",icon:jt,label:t("bpmn.end_event.variant.default")},{type:"TASK",icon:ko,label:t("bpmn.task.variant.default")},{type:"TASK",variant:"SUBPROCESS",icon:Is,label:t("bpmn.task.variant.subprocess")},{type:"TASK",variant:"SCRIPT",icon:As,label:t("bpmn.task.variant.script")},{type:"TASK",attribute:"LOOP",icon:ws,label:t("bpmn.task.attribute.loop")},{type:"GATEWAY",variant:"EXCLUSIVE",icon:to,label:t("bpmn.gateway.variant.exclusive")},{type:"GATEWAY",variant:"PARALLEL",icon:oo,label:t("bpmn.gateway.variant.parallel")},{type:"GATEWAY",variant:"COMPLEX",icon:eo,label:t("bpmn.gateway.variant.complex")},{type:"LANE",icon:_s,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}),a(Zt(d.icon,{})),c.dataTransfer.effectAllowed="move",e.current&&c.dataTransfer.setDragImage(e.current,10,10),setTimeout(()=>{r(!0)},100)};return Tu("aside",{className:"sidebar absolute z-[1] top-4 left-4",children:[Zt("div",{className:"grid grid-cols-1 gap-2 p-2 bg-white rounded-md shadow-md",children:s.map((c,d)=>{let u=!Nt(c.type,n),f=u?t("editor.toolbar.start_event_already_exists"):c.label;return Tu(bx,{children:[Zt(Tx,{asChild:!0,children:Zt(Ex,{className:R("[&>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:p=>l(p,c),children:Zt(c.icon,{})},d)}),Zt(_x,{color:"black",side:"right",children:f})]},d)})}),Zt("div",{ref:e,className:"absolute w-0 h-0 top-0 left-0 z-[-1] bg-transparent",children:i})]})};import{jsx as Qe,jsxs as ii}from"react/jsx-runtime";var is=Px((e,t)=>{let o=Mx("Space"),{instanceId:n,mode:r,isMinimapOpen:i,isMoveTool:a,isHandTool:s}=Q(),[l,c]=Rx(!1),d=kx(null),{nodes:u,edges:f,actions:p,events:g,components:y,controls:m}=Xd(),{t:b}=Hx();Lx(t,()=>({selectElements:p.selectElements,clearSelection:p.clearSelection})),vu(()=>{let x=d.current;if(!x)return;let N=A=>{s||o||r==="edit"&&Gr.some(M=>M===A.button)&&c(!0)},I=A=>{(A.buttons&ud)===0&&c(!1)};return x.addEventListener("pointerdown",N),window.addEventListener("pointerup",I),()=>{x.removeEventListener("pointerdown",N),window.removeEventListener("pointerup",I)}},[s,o,r]),vu(()=>{let x=d.current;if(!x)return;let N=x.querySelector(".react-flow__pane");if(!N)return;let I=A=>A.preventDefault();return N.addEventListener("contextmenu",I),()=>N.removeEventListener("contextmenu",I)},[]);let h=s||o||r!=="edit"?!0:Gr,E=r!=="readonly"&&a&&!o,w=r==="edit"&&a&&!o,_=r==="edit"&&a&&!o;return ii("div",{ref:d,className:"w-full h-full",children:[r==="edit"&&Qe(Nu,{}),Qe($d,{}),ii(Cx,v(T({},g),{id:`modeler-${n}`,className:R({"is-hand-tool":s||o||l}),edges:f,nodes:u,nodeTypes:ed,edgeTypes:td,minZoom:ji,maxZoom:ad,panOnDrag:h,panOnScroll:!0,selectionOnDrag:!0,elevateEdgesOnSelect:!0,elevateNodesOnSelect:!1,elementsSelectable:E,nodesConnectable:w,nodesDraggable:_,connectionLineComponent:Jc,selectionMode:Sx.Partial,multiSelectionKeyCode:["Control","Meta"],deleteKeyCode:"Delete",selectionKeyCode:null,defaultViewport:ld,connectOnClick:!1,connectionRadius:50,proOptions:{hideAttribution:!0},children:[Qe(Ax,{gap:id,size:rd,color:nd,bgColor:od}),i&&ii(Dx,{children:[Qe(Vx,{asChild:!0,children:Qe("div",{className:"absolute bottom-[0px] left-[0px] z-[5]",children:Qe(Ix,{pannable:!0,zoomable:!0,position:sd,className:"shadow-md rounded-md",ariaLabel:"",style:{pointerEvents:"all",position:"relative"}})})}),Qe(Ox,{color:"black",children:b("editor.controls.actions.minimap.label")})]}),ii("div",{className:"absolute z-10 bottom-4 left-1/2 -translate-x-1/2 flex gap-4",children:[r==="edit"&&Qe(bu,T({},m)),Qe(gu,{nodes:u,edges:f,validateDiagram:p.validateDiagram,handleValidationComplete:p.handleValidationComplete}),Qe(_u,{})]}),Qe(y.HelperLines,{})]}))]})});is.displayName="Editor";import{useStore as Gx}from"@xyflow/react";import{useEffect as Bx,useRef as zx}from"react";import{jsx as Fx}from"react/jsx-runtime";var Yx=e=>({width:e.width,height:e.height,transform:e.transform}),ss="rgba(51, 103, 217, 0.4)",vl=({horizontal:e,vertical:t})=>{let{width:o,height:n,transform:r}=Gx(Yx),i=zx(null);return Bx(()=>{let a=i.current,s=a==null?void 0:a.getContext("2d");if(!s||!a)return;let l=window.devicePixelRatio;a.width=o*l,a.height=n*l,s.clearRect(0,0,o,n),s.scale(l,l),s.strokeStyle=ss,t&&(s.beginPath(),s.strokeStyle=t.color||ss,s.moveTo(t.position*r[2]+r[0],0),s.lineTo(t.position*r[2]+r[0],n),s.stroke()),e&&(s.beginPath(),s.strokeStyle=e.color||ss,s.moveTo(0,e.position*r[2]+r[1]),s.lineTo(o,e.position*r[2]+r[1]),s.stroke())},[o,n,r,e,t]),Fx("canvas",{ref:i,className:"w-full h-full absolute z-10 pointer-events-none"})};import{i18n as Wx,Notification as Xx,TooltipProvider as Ux}from"@produto-lecom/lecom-ui";import{createContext as $x,useContext as Kx,useEffect as qx,useState as Zx}from"react";import{jsx as wu,jsxs as Qx}from"react/jsx-runtime";var it=new Map,Au=$x(null),en=()=>{let e=Kx(Au);if(!e)throw new Error("useModeler must be used within an <ModelerProvider />");return e},Jx=({locale:e,defaultMode:t="view",toast:o,children:n})=>{let[r,i]=Zx(e||"pt_BR");qx(()=>{e&&(i(e),Wx.changeLanguage(e))},[e]);let a=g=>{let y=it.size;if(y===0)throw new Error("No modeler instances found");if(y===1||!g){let[b]=it.values();return b}let m=it.get(g);if(!m)throw new Error(`Modeler instance with ID "${g}" not found`);return m},s=(g,y)=>{let m=a(y);return m==null?void 0:m.selectElements(g)},l=async g=>{let y=a(g);return y==null?void 0:y.clearSelection()},c=(g,y)=>{let m=a(y);return m==null?void 0:m.configureElement(g)},d=(g,y)=>{let m=a(y);return m==null?void 0:m.getConfigureElement(g)},u=async(g,y)=>{let m=a(y);await(m==null?void 0:m.importFromMxGraph(g))},f=g=>{let y=a(g);return y==null?void 0:y.exportToMxGraph()},p=g=>{let y=a(g);return(y==null?void 0:y.getElementsCount())||0};return wu(Au.Provider,{value:{defaultMode:t,locale:r,selectElements:s,clearSelection:l,configureElement:c,getConfigureElement:d,importDiagram:u,exportDiagram:f,getElementsCount:p,toast:o},children:Qx(Ux,{children:[!o&&wu(Xx,{type:"toast",placement:"topRight",enableClose:!0,showProgress:!0,pauseOnHover:!0}),n]})})};import{useTranslation as iE}from"@produto-lecom/lecom-ui";import{jsx as as}from"react/jsx-runtime";var Iu=eE(null),Q=()=>{let e=tE(Iu);if(!e)throw new Error("useModelerInstance must be used within an <Modeler />");return e},sE=({selectorRef:e,initialDiagram:t,instanceId:o,mode:n,onElementChanges:r,onConfigureElement:i,onElementClick:a,onSubprocessValidationClick:s})=>{let{t:l}=iE(),{defaultMode:c}=en(),d=nE(),[u]=je(o||d),[f,p]=je(n||c||"edit"),[g,y]=je(ln),[m,b]=je(!1),[h,E]=je(!0),[w,_]=je(!1),[x,N]=je(!1),[I,A]=je(!1),[M,S]=je(!1),[k,B]=je(!1),[q,j]=je(null);oE(()=>{n&&p(n)},[n]);let C=rE(()=>t||Ec(l),[t,l]),P={instanceId:u,initialDiagram:C,mode:f,lastElementId:g,isInitialized:m,isMinimapOpen:x,isMoveTool:h,isHandTool:w,isDragging:I,isMultipleSelection:k,isConnecting:M,setLastElementId:y,setIsInitialized:b,reconnectingEdgeId:q,setIsMinimapOpen:N,setIsMoveTool:E,setIsHandTool:_,setIsDragging:A,setIsConnecting:S,setIsMultipleSelection:B,setReconnectingEdgeId:j,onElementChanges:r,onConfigureElement:i,onElementClick:a,onSubprocessValidationClick:s};return as(jx,{children:as(Iu.Provider,{value:P,children:as(is,{ref:e})})})};export{Re as EditorMode,li as ElementPosition,bn as ElementType,ci as GatewayElementVariant,qe as GatewayVariant,sE as Modeler,Jx as ModelerProvider,ot as NodeAttribute,oe as NodeType,Ke as NodeVariant,di as RoutingVariant,en as useModeler};