lecom-modeler 0.12.0 → 0.13.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/index.cjs +7 -7
- package/lib/index.d.cts +2 -1
- package/lib/index.d.ts +2 -1
- package/lib/index.js +7 -7
- package/lib/style.min.css +1 -1
- package/package.json +3 -3
package/lib/index.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
var hd=Object.defineProperty,yd=Object.defineProperties;var xd=Object.getOwnPropertyDescriptors;var vo=Object.getOwnPropertySymbols;var si=Object.prototype.hasOwnProperty,ai=Object.prototype.propertyIsEnumerable;var ii=(e,t,o)=>t in e?hd(e,t,{enumerable:!0,configurable:!0,writable:!0,value:o}):e[t]=o,E=(e,t)=>{for(var o in t||(t={}))si.call(t,o)&&ii(e,o,t[o]);if(vo)for(var o of vo(t))ai.call(t,o)&&ii(e,o,t[o]);return e},N=(e,t)=>yd(e,xd(t));var we=(e,t)=>{var o={};for(var n in e)si.call(e,n)&&t.indexOf(n)<0&&(o[n]=e[n]);if(e!=null&&vo)for(var n of vo(e))t.indexOf(n)<0&&ai.call(e,n)&&(o[n]=e[n]);return o};var rr=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 Ed,Translations as bd}from"lecom-ui";var li={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",connect_node:"Connect element",connecting:"Connecting..."},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:{error:"Error exporting diagram"}},import_governance:"Import diagram from Governance platform",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"}},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"}},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 ci={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",connect_node:"Conectar elemento",connecting:"Conectando..."},controls:{zoom:{fit:"Ajustar zoom",in:"Acercar",out:"Alejar",reset:"Restablecer zoom"},actions:{move_tool:"Seleccionar elementos",hand_tool:"Navegar por el diagrama",check:"Verificar diagrama",export:{title:"Exportar diagrama",print:"Imprimir",html:"Exportar como HTML",png:"Exportar como PNG",feedback:{error:"Error al exportar diagrama"}},import_governance:"Importar diagrama de la plataforma Governance",minimap:{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"}},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"}},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 di={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",connect_node:"Conectar elemento",connecting:"Conectando..."},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:"Verificar diagrama",export:{title:"Exportar diagrama",print:"Imprimir",html:"Exportar como HTML",png:"Exportar como PNG",feedback:{error:"Erro ao exportar o diagrama"}},import_governance:"Importar diagrama da plataforma Governance",minimap:{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"}},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 tarefa"},variant:{default:"Tarefa",script:"Tarefa de script",subprocess:"Subprocesso"},attribute:{loop:"Tarefa com loop"},label:{prefix:"Atividade"}},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 ui={pt_BR:di,en_US:li,es_ES:ci};var pi,fi,_d=(fi=(pi=rr("LecomUserLanguage"))!=null?pi:rr("org.springframework.web.servlet.i18n.CookieLocaleResolver.LOCALE"))!=null?fi:bd.PT_BR;Ed({lng:_d,resources:ui});var ge=(n=>(n.EDIT="edit",n.VIEW="view",n.READONLY="readonly",n))(ge||{});var wo=(r=>(r.ACTIVITY="activity",r.ROUTING="routing",r.GATEWAY="gateway",r.SUB_PROCESS="sub_process",r))(wo||{}),ir=(n=>(n.START="start",n.END="end",n.BETWEEN="between",n))(ir||{}),sr=(n=>(n.SCRIPT="script",n.LOOP="loop",n.SCRIPT_LOOP="script_loop",n))(sr||{}),ar=(c=>(c.SIMPLE="simple",c.LOOP="loop",c.SCRIPT="script",c.SCRIPT_LOOP="script_loop",c.COMPLEX="complex",c.EXCLUSIVE="exclusive",c.PARALLEL="parallel",c.FINAL="final",c.TO_SUB_PROCESS="to_sub_process",c))(ar||{});import{RotateCcw as kd,ScrollText as Dd,SquarePlus as Rd}from"lucide-react";import{jsx as Io,jsxs as Td}from"react/jsx-runtime";var Ao=({size:e=24,className:t})=>Td("svg",{width:e,height:e,viewBox:"0 0 24 24",xmlns:"http://www.w3.org/2000/svg",fill:"#6b7280",className:t,children:[Io("path",{strokeWidth:"2",d:"M16 3V3.5085V11.9998V20.4915V21H16.5411H21.4592H22V19.123H21.4592H17.9974V11.9998V4.8773H21.4592H22V3H21.4592H16.5411H16Z"}),Io("path",{d:"M4.41026 16.9999L2 18.7861L3.89693 21.1103L6.3072 19.324L4.41026 16.9999Z"}),Io("path",{d:"M8.41026 13.9999L6 15.7861L7.89693 18.1103L10.3072 16.324L8.41026 13.9999Z"}),Io("path",{d:"M12.4313 10.954L10.021 12.7402L11.9179 15.0644L14.3282 13.2781L12.4313 10.954Z"})]});import{jsx as mi}from"react/jsx-runtime";var pt=({size:e=24,className:t})=>mi("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:mi("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 Ft,jsxs as Nd}from"react/jsx-runtime";var ft=({size:e=24,className:t})=>Nd("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:[Ft("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"}),Ft("path",{d:"M12 8V16",strokeLinecap:"round",strokeLinejoin:"round"}),Ft("path",{d:"M8 12H16",strokeLinecap:"round",strokeLinejoin:"round"}),Ft("path",{d:"M9.17139 9.17188L14.8282 14.8287",strokeLinecap:"round",strokeLinejoin:"round"}),Ft("path",{d:"M14.8281 9.17188L9.17127 14.8287",strokeLinecap:"round",strokeLinejoin:"round"})]});import{jsx as lr,jsxs as vd}from"react/jsx-runtime";var mt=({size:e=24,className:t})=>vd("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:[lr("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"}),lr("path",{d:"M14.8286 9.17188L9.17176 14.8287",strokeLinecap:"round",strokeLinejoin:"round"}),lr("path",{d:"M9.17139 9.17188L14.8282 14.8287",strokeLinecap:"round",strokeLinejoin:"round"})]});import{jsx as cr,jsxs as wd}from"react/jsx-runtime";var gt=({size:e=24,className:t})=>wd("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:[cr("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"}),cr("path",{d:"M12 8V16",strokeLinecap:"round",strokeLinejoin:"round"}),cr("path",{d:"M8 12H16",strokeLinecap:"round",strokeLinejoin:"round"})]});import{jsx as dr,jsxs as Id}from"react/jsx-runtime";var gi=({size:e=24,className:t})=>dr("svg",{width:e,height:e,viewBox:"0 0 34 24",xmlns:"http://www.w3.org/2000/svg",fill:"currentColor",className:t,children:Id("g",{children:[dr("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"}),dr("path",{d:"M24.5 4.5L28 1M28 1L31.5 4.5M28 1V8",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round"})]})});import{clsx as Ad}from"clsx";import{twMerge as Cd}from"tailwind-merge";function R(...e){return Cd(Ad(e))}var Be=(e=0,t=0)=>e<t?t:e,Co=(e=1e3)=>new Promise(t=>{setTimeout(t,e)});import{jsx as hi,jsxs as Sd}from"react/jsx-runtime";var yi=({size:e=24,className:t})=>Sd("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:[hi("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"}),hi("path",{d:"M9 3V21",strokeLinecap:"round",strokeLinejoin:"round"})]});import{jsx as ur}from"react/jsx-runtime";var xi=({size:e=24,className:t})=>ur("svg",{width:e,height:e,viewBox:"0 0 24 24",xmlns:"http://www.w3.org/2000/svg",stroke:"currentColor",className:t,children:ur("g",{children:ur("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 Ei}from"react/jsx-runtime";var So=({size:e=24,className:t})=>Ei("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:Ei("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 bi}from"react/jsx-runtime";var Wt=({size:e=24,className:t})=>bi("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:bi("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 pr,jsxs as Md}from"react/jsx-runtime";var _i=({size:e=24,className:t})=>Md("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:[pr("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"}),pr("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"}),pr("path",{d:"M7.5 7.5V10H10",strokeWidth:"1.5",fill:"none",strokeLinecap:"round",strokeLinejoin:"round"})]});import{jsx as Yt,jsxs as Pd}from"react/jsx-runtime";var Ti=({size:e=24,className:t})=>Pd("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:[Yt("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"}),Yt("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"}),Yt("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"}),Yt("path",{d:"M13.5 12H11",strokeWidth:"1",strokeLinecap:"round",strokeLinejoin:"round"}),Yt("path",{d:"M13.5 10H11",strokeWidth:"1",strokeLinecap:"round",strokeLinejoin:"round"})]});import{jsx as Mo,jsxs as Ld}from"react/jsx-runtime";var Ni=({size:e=24,className:t})=>Ld("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:[Mo("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"}),Mo("path",{d:"M8 21V14C8 13.4477 8.44772 13 9 13H15C15.5523 13 16 13.4477 16 14V21",strokeWidth:"1",fill:"none"}),Mo("path",{d:"M10.2222 17H13.7777",strokeWidth:"1",strokeLinecap:"round",strokeLinejoin:"round"}),Mo("path",{d:"M12 15.2227V18.7782",strokeWidth:"1",strokeLinecap:"round",strokeLinejoin:"round"})]});var F=(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))(F||{}),Ee=(o=>(o.SCRIPT="SCRIPT",o.SUBPROCESS="SUBPROCESS",o))(Ee||{}),Po={SCRIPT:{icon:Dd},SUBPROCESS:{icon:Rd}},ze=(t=>(t.LOOP="LOOP",t))(ze||{}),Lo={LOOP:{icon:kd}},be=(n=>(n.EXCLUSIVE="EXCLUSIVE",n.PARALLEL="PARALLEL",n.COMPLEX="COMPLEX",n))(be||{}),fr={EXCLUSIVE:{icon:mt},PARALLEL:{icon:gt},COMPLEX:{icon:ft}};import{ReactFlowProvider as yy}from"@xyflow/react";import{createContext as xy,useContext as Ey,useEffect as by,useId as _y,useMemo as Ty,useState as Pe}from"react";import{Background as J0,MiniMap as Q0,ReactFlow as j0,SelectionMode as ey}from"@xyflow/react";import{forwardRef as ty,useImperativeHandle as oy}from"react";import{useEdgesState as Ch,useNodesState as Sh,useOnSelectionChange as Mh}from"@xyflow/react";import{useCallback as Yr,useEffect as Ph}from"react";import{create as Vd}from"zustand";import{useReactFlow as Od}from"@xyflow/react";import{useCallback as Hd}from"react";var ko=()=>{let{setEdges:e}=Od();return Hd(()=>{let o=Je.getState().pathEdgeIds;e(n=>n.map(r=>N(E({},r),{selected:o.includes(r.id)})))},[e])},Je=Vd((e,t)=>({statusByNodeId:{},statusData:{},pathEdgeIds:[],setTaskStatuses:o=>{o!=null&&o.length&&e(n=>{let r=E({},n.statusByNodeId),i=E({},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 p=[],f=new Set;for(p.push({node:d,path:[]}),f.add(d);p.length>0;){let{node:x,path:g}=p.shift();if(x===u)return g;let m=a[x]||[];for(let{targetId:y,edgeId:h}of m)f.has(y)||(f.add(y),p.push({node:y,path:[...g,h]}))}return[]};for(let d=0;d<r.length-1;d++){let u=r[d],p=r[d+1],f=c(u,p);f.length>0&&i.push(...f)}i.length>0&&e({pathEdgeIds:i})}}));import{useNodesInitialized as jp,useReactFlow as ef,useStore as tf}from"@xyflow/react";var Gd={value:()=>{}};function wi(){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 Do(o)}function Do(e){this._=e}function Bd(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}})}Do.prototype=wi.prototype={constructor:Do,on:function(e,t){var o=this._,n=Bd(e+"",o),r,i=-1,a=n.length;if(arguments.length<2){for(;++i<a;)if((r=(e=n[i]).type)&&(r=zd(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]=vi(o[r],e.name,t);else if(t==null)for(r in o)o[r]=vi(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 Do(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 zd(e,t){for(var o=0,n=e.length,r;o<n;++o)if((r=e[o]).name===t)return r.value}function vi(e,t,o){for(var n=0,r=e.length;n<r;++n)if(e[n].name===t){e[n]=Gd,e=e.slice(0,n).concat(e.slice(n+1));break}return o!=null&&e.push({name:t,value:o}),e}var mr=wi;var Ro="http://www.w3.org/1999/xhtml",gr={svg:"http://www.w3.org/2000/svg",xhtml:Ro,xlink:"http://www.w3.org/1999/xlink",xml:"http://www.w3.org/XML/1998/namespace",xmlns:"http://www.w3.org/2000/xmlns/"};function Re(e){var t=e+="",o=t.indexOf(":");return o>=0&&(t=e.slice(0,o))!=="xmlns"&&(e=e.slice(o+1)),gr.hasOwnProperty(t)?{space:gr[t],local:e}:e}function Fd(e){return function(){var t=this.ownerDocument,o=this.namespaceURI;return o===Ro&&t.documentElement.namespaceURI===Ro?t.createElement(e):t.createElementNS(o,e)}}function Wd(e){return function(){return this.ownerDocument.createElementNS(e.space,e.local)}}function Vo(e){var t=Re(e);return(t.local?Wd:Fd)(t)}function Yd(){}function Qe(e){return e==null?Yd:function(){return this.querySelector(e)}}function Ii(e){typeof e!="function"&&(e=Qe(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 J(n,this._parents)}function hr(e){return e==null?[]:Array.isArray(e)?e:Array.from(e)}function Ud(){return[]}function Ut(e){return e==null?Ud:function(){return this.querySelectorAll(e)}}function $d(e){return function(){return hr(e.apply(this,arguments))}}function Ai(e){typeof e=="function"?e=$d(e):e=Ut(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 J(n,r)}function $t(e){return function(){return this.matches(e)}}function Oo(e){return function(t){return t.matches(e)}}var Xd=Array.prototype.find;function Kd(e){return function(){return Xd.call(this.children,e)}}function qd(){return this.firstElementChild}function Ci(e){return this.select(e==null?qd:Kd(typeof e=="function"?e:Oo(e)))}var Zd=Array.prototype.filter;function Jd(){return Array.from(this.children)}function Qd(e){return function(){return Zd.call(this.children,e)}}function Si(e){return this.selectAll(e==null?Jd:Qd(typeof e=="function"?e:Oo(e)))}function Mi(e){typeof e!="function"&&(e=$t(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 J(n,this._parents)}function Ho(e){return new Array(e.length)}function Pi(){return new J(this._enter||this._groups.map(Ho),this._parents)}function Xt(e,t){this.ownerDocument=e.ownerDocument,this.namespaceURI=e.namespaceURI,this._next=null,this._parent=e,this.__data__=t}Xt.prototype={constructor:Xt,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 Li(e){return function(){return e}}function jd(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 Xt(e,i[a]);for(;a<l;++a)(s=t[a])&&(r[a]=s)}function eu(e,t,o,n,r,i,a){var s,l,c=new Map,d=t.length,u=i.length,p=new Array(d),f;for(s=0;s<d;++s)(l=t[s])&&(p[s]=f=a.call(l,l.__data__,s,t)+"",c.has(f)?r[s]=l:c.set(f,l));for(s=0;s<u;++s)f=a.call(e,i[s],s,i)+"",(l=c.get(f))?(n[s]=l,l.__data__=i[s],c.delete(f)):o[s]=new Xt(e,i[s]);for(s=0;s<d;++s)(l=t[s])&&c.get(p[s])===l&&(r[s]=l)}function tu(e){return e.__data__}function ki(e,t){if(!arguments.length)return Array.from(this,tu);var o=t?eu:jd,n=this._parents,r=this._groups;typeof e!="function"&&(e=Li(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],p=u.length,f=ou(e.call(d,d&&d.__data__,c,n)),x=f.length,g=s[c]=new Array(x),m=a[c]=new Array(x),y=l[c]=new Array(p);o(d,u,g,m,y,f,t);for(var h=0,b=0,T,_;h<x;++h)if(T=g[h]){for(h>=b&&(b=h+1);!(_=m[b])&&++b<x;);T._next=_||null}}return a=new J(a,n),a._enter=s,a._exit=l,a}function ou(e){return typeof e=="object"&&"length"in e?e:Array.from(e)}function Di(){return new J(this._exit||this._groups.map(Ho),this._parents)}function Ri(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 Vi(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,p=s[l]=new Array(u),f,x=0;x<u;++x)(f=c[x]||d[x])&&(p[x]=f);for(;l<r;++l)s[l]=o[l];return new J(s,this._parents)}function Oi(){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 Hi(e){e||(e=nu);function t(u,p){return u&&p?e(u.__data__,p.__data__):!u-!p}for(var o=this._groups,n=o.length,r=new Array(n),i=0;i<n;++i){for(var 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 J(r,this._parents).order()}function nu(e,t){return e<t?-1:e>t?1:e>=t?0:NaN}function Gi(){var e=arguments[0];return arguments[0]=this,e.apply(null,arguments),this}function Bi(){return Array.from(this)}function zi(){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 Fi(){let e=0;for(let t of this)++e;return e}function Wi(){return!this.node()}function Yi(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 ru(e){return function(){this.removeAttribute(e)}}function iu(e){return function(){this.removeAttributeNS(e.space,e.local)}}function su(e,t){return function(){this.setAttribute(e,t)}}function au(e,t){return function(){this.setAttributeNS(e.space,e.local,t)}}function lu(e,t){return function(){var o=t.apply(this,arguments);o==null?this.removeAttribute(e):this.setAttribute(e,o)}}function cu(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 Ui(e,t){var o=Re(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?iu:ru:typeof t=="function"?o.local?cu:lu:o.local?au:su)(o,t))}function Go(e){return e.ownerDocument&&e.ownerDocument.defaultView||e.document&&e||e.defaultView}function du(e){return function(){this.style.removeProperty(e)}}function uu(e,t,o){return function(){this.style.setProperty(e,t,o)}}function pu(e,t,o){return function(){var n=t.apply(this,arguments);n==null?this.style.removeProperty(e):this.style.setProperty(e,n,o)}}function $i(e,t,o){return arguments.length>1?this.each((t==null?du:typeof t=="function"?pu:uu)(e,t,o==null?"":o)):Fe(this.node(),e)}function Fe(e,t){return e.style.getPropertyValue(t)||Go(e).getComputedStyle(e,null).getPropertyValue(t)}function fu(e){return function(){delete this[e]}}function mu(e,t){return function(){this[e]=t}}function gu(e,t){return function(){var o=t.apply(this,arguments);o==null?delete this[e]:this[e]=o}}function Xi(e,t){return arguments.length>1?this.each((t==null?fu:typeof t=="function"?gu:mu)(e,t)):this.node()[e]}function Ki(e){return e.trim().split(/^|\s+/)}function yr(e){return e.classList||new qi(e)}function qi(e){this._node=e,this._names=Ki(e.getAttribute("class")||"")}qi.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 Zi(e,t){for(var o=yr(e),n=-1,r=t.length;++n<r;)o.add(t[n])}function Ji(e,t){for(var o=yr(e),n=-1,r=t.length;++n<r;)o.remove(t[n])}function hu(e){return function(){Zi(this,e)}}function yu(e){return function(){Ji(this,e)}}function xu(e,t){return function(){(t.apply(this,arguments)?Zi:Ji)(this,e)}}function Qi(e,t){var o=Ki(e+"");if(arguments.length<2){for(var n=yr(this.node()),r=-1,i=o.length;++r<i;)if(!n.contains(o[r]))return!1;return!0}return this.each((typeof t=="function"?xu:t?hu:yu)(o,t))}function Eu(){this.textContent=""}function bu(e){return function(){this.textContent=e}}function _u(e){return function(){var t=e.apply(this,arguments);this.textContent=t==null?"":t}}function ji(e){return arguments.length?this.each(e==null?Eu:(typeof e=="function"?_u:bu)(e)):this.node().textContent}function Tu(){this.innerHTML=""}function Nu(e){return function(){this.innerHTML=e}}function vu(e){return function(){var t=e.apply(this,arguments);this.innerHTML=t==null?"":t}}function es(e){return arguments.length?this.each(e==null?Tu:(typeof e=="function"?vu:Nu)(e)):this.node().innerHTML}function wu(){this.nextSibling&&this.parentNode.appendChild(this)}function ts(){return this.each(wu)}function Iu(){this.previousSibling&&this.parentNode.insertBefore(this,this.parentNode.firstChild)}function os(){return this.each(Iu)}function ns(e){var t=typeof e=="function"?e:Vo(e);return this.select(function(){return this.appendChild(t.apply(this,arguments))})}function Au(){return null}function rs(e,t){var o=typeof e=="function"?e:Vo(e),n=t==null?Au:typeof t=="function"?t:Qe(t);return this.select(function(){return this.insertBefore(o.apply(this,arguments),n.apply(this,arguments)||null)})}function Cu(){var e=this.parentNode;e&&e.removeChild(this)}function is(){return this.each(Cu)}function Su(){var e=this.cloneNode(!1),t=this.parentNode;return t?t.insertBefore(e,this.nextSibling):e}function Mu(){var e=this.cloneNode(!0),t=this.parentNode;return t?t.insertBefore(e,this.nextSibling):e}function ss(e){return this.select(e?Mu:Su)}function as(e){return arguments.length?this.property("__data__",e):this.node().__data__}function Pu(e){return function(t){e.call(this,t,this.__data__)}}function Lu(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 ku(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 Du(e,t,o){return function(){var n=this.__on,r,i=Pu(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 ls(e,t,o){var n=Lu(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?Du:ku,r=0;r<i;++r)this.each(s(n[r],t,o));return this}function cs(e,t,o){var n=Go(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 Ru(e,t){return function(){return cs(this,e,t)}}function Vu(e,t){return function(){return cs(this,e,t.apply(this,arguments))}}function ds(e,t){return this.each((typeof t=="function"?Vu:Ru)(e,t))}function*us(){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 Ou=[null];function J(e,t){this._groups=e,this._parents=t}function ps(){return new J([[document.documentElement]],Ou)}function Hu(){return this}J.prototype=ps.prototype={constructor:J,select:Ii,selectAll:Ai,selectChild:Ci,selectChildren:Si,filter:Mi,data:ki,enter:Pi,exit:Di,join:Ri,merge:Vi,selection:Hu,order:Oi,sort:Hi,call:Gi,nodes:Bi,node:zi,size:Fi,empty:Wi,each:Yi,attr:Ui,style:$i,property:Xi,classed:Qi,text:ji,html:es,raise:ts,lower:os,append:ns,insert:rs,remove:is,clone:ss,datum:as,on:ls,dispatch:ds,[Symbol.iterator]:us};var Ve=ps;function Bo(e,t,o){e.prototype=t.prototype=o,o.constructor=e}function xr(e,t){var o=Object.create(e.prototype);for(var n in t)o[n]=t[n];return o}function Zt(){}var Kt=.7,Wo=1/Kt,ht="\\s*([+-]?\\d+)\\s*",qt="\\s*([+-]?(?:\\d*\\.)?\\d+(?:[eE][+-]?\\d+)?)\\s*",Ie="\\s*([+-]?(?:\\d*\\.)?\\d+(?:[eE][+-]?\\d+)?)%\\s*",Gu=/^#([0-9a-f]{3,8})$/,Bu=new RegExp(`^rgb\\(${ht},${ht},${ht}\\)$`),zu=new RegExp(`^rgb\\(${Ie},${Ie},${Ie}\\)$`),Fu=new RegExp(`^rgba\\(${ht},${ht},${ht},${qt}\\)$`),Wu=new RegExp(`^rgba\\(${Ie},${Ie},${Ie},${qt}\\)$`),Yu=new RegExp(`^hsl\\(${qt},${Ie},${Ie}\\)$`),Uu=new RegExp(`^hsla\\(${qt},${Ie},${Ie},${qt}\\)$`),fs={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};Bo(Zt,We,{copy(e){return Object.assign(new this.constructor,this,e)},displayable(){return this.rgb().displayable()},hex:ms,formatHex:ms,formatHex8:$u,formatHsl:Xu,formatRgb:gs,toString:gs});function ms(){return this.rgb().formatHex()}function $u(){return this.rgb().formatHex8()}function Xu(){return _s(this).formatHsl()}function gs(){return this.rgb().formatRgb()}function We(e){var t,o;return e=(e+"").trim().toLowerCase(),(t=Gu.exec(e))?(o=t[1].length,t=parseInt(t[1],16),o===6?hs(t):o===3?new de(t>>8&15|t>>4&240,t>>4&15|t&240,(t&15)<<4|t&15,1):o===8?zo(t>>24&255,t>>16&255,t>>8&255,(t&255)/255):o===4?zo(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=Bu.exec(e))?new de(t[1],t[2],t[3],1):(t=zu.exec(e))?new de(t[1]*255/100,t[2]*255/100,t[3]*255/100,1):(t=Fu.exec(e))?zo(t[1],t[2],t[3],t[4]):(t=Wu.exec(e))?zo(t[1]*255/100,t[2]*255/100,t[3]*255/100,t[4]):(t=Yu.exec(e))?Es(t[1],t[2]/100,t[3]/100,1):(t=Uu.exec(e))?Es(t[1],t[2]/100,t[3]/100,t[4]):fs.hasOwnProperty(e)?hs(fs[e]):e==="transparent"?new de(NaN,NaN,NaN,0):null}function hs(e){return new de(e>>16&255,e>>8&255,e&255,1)}function zo(e,t,o,n){return n<=0&&(e=t=o=NaN),new de(e,t,o,n)}function Ku(e){return e instanceof Zt||(e=We(e)),e?(e=e.rgb(),new de(e.r,e.g,e.b,e.opacity)):new de}function yt(e,t,o,n){return arguments.length===1?Ku(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}Bo(de,yt,xr(Zt,{brighter(e){return e=e==null?Wo:Math.pow(Wo,e),new de(this.r*e,this.g*e,this.b*e,this.opacity)},darker(e){return e=e==null?Kt:Math.pow(Kt,e),new de(this.r*e,this.g*e,this.b*e,this.opacity)},rgb(){return this},clamp(){return new de(et(this.r),et(this.g),et(this.b),Yo(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:ys,formatHex:ys,formatHex8:qu,formatRgb:xs,toString:xs}));function ys(){return`#${je(this.r)}${je(this.g)}${je(this.b)}`}function qu(){return`#${je(this.r)}${je(this.g)}${je(this.b)}${je((isNaN(this.opacity)?1:this.opacity)*255)}`}function xs(){let e=Yo(this.opacity);return`${e===1?"rgb(":"rgba("}${et(this.r)}, ${et(this.g)}, ${et(this.b)}${e===1?")":`, ${e})`}`}function Yo(e){return isNaN(e)?1:Math.max(0,Math.min(1,e))}function et(e){return Math.max(0,Math.min(255,Math.round(e)||0))}function je(e){return e=et(e),(e<16?"0":"")+e.toString(16)}function Es(e,t,o,n){return n<=0?e=t=o=NaN:o<=0||o>=1?e=t=NaN:t<=0&&(e=NaN),new _e(e,t,o,n)}function _s(e){if(e instanceof _e)return new _e(e.h,e.s,e.l,e.opacity);if(e instanceof Zt||(e=We(e)),!e)return new _e;if(e instanceof _e)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 _e(a,s,l,e.opacity)}function Ts(e,t,o,n){return arguments.length===1?_s(e):new _e(e,t,o,n==null?1:n)}function _e(e,t,o,n){this.h=+e,this.s=+t,this.l=+o,this.opacity=+n}Bo(_e,Ts,xr(Zt,{brighter(e){return e=e==null?Wo:Math.pow(Wo,e),new _e(this.h,this.s,this.l*e,this.opacity)},darker(e){return e=e==null?Kt:Math.pow(Kt,e),new _e(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(Er(e>=240?e-240:e+120,r,n),Er(e,r,n),Er(e<120?e+240:e-120,r,n),this.opacity)},clamp(){return new _e(bs(this.h),Fo(this.s),Fo(this.l),Yo(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=Yo(this.opacity);return`${e===1?"hsl(":"hsla("}${bs(this.h)}, ${Fo(this.s)*100}%, ${Fo(this.l)*100}%${e===1?")":`, ${e})`}`}}));function bs(e){return e=(e||0)%360,e<0?e+360:e}function Fo(e){return Math.max(0,Math.min(1,e||0))}function Er(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 br(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 Ns(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 br((o-n/t)*t,a,r,i,s)}}function vs(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 br((o-n/t)*t,r,i,a,s)}}var _r=e=>()=>e;function Zu(e,t){return function(o){return e+o*t}}function Ju(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 ws(e){return(e=+e)==1?Uo:function(t,o){return o-t?Ju(t,o,e):_r(isNaN(t)?o:t)}}function Uo(e,t){var o=t-e;return o?Zu(e,o):_r(isNaN(e)?t:e)}var $o=function e(t){var o=ws(t);function n(r,i){var a=o((r=yt(r)).r,(i=yt(i)).r),s=o(r.g,i.g),l=o(r.b,i.b),c=Uo(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 Is(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=yt(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 Qu=Is(Ns),ju=Is(vs);function he(e,t){return e=+e,t=+t,function(o){return e*(1-o)+t*o}}var Nr=/[-+]?(?:\d+\.?\d*|\.?\d+)(?:[eE][-+]?\d+)?/g,Tr=new RegExp(Nr.source,"g");function ep(e){return function(){return e}}function tp(e){return function(t){return e(t)+""}}function vr(e,t){var o=Nr.lastIndex=Tr.lastIndex=0,n,r,i,a=-1,s=[],l=[];for(e=e+"",t=t+"";(n=Nr.exec(e))&&(r=Tr.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:he(n,r)})),o=Tr.lastIndex;return o<t.length&&(i=t.slice(o),s[a]?s[a]+=i:s[++a]=i),s.length<2?l[0]?tp(l[0].x):ep(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 As=180/Math.PI,Xo={translateX:0,translateY:0,rotate:0,skewX:0,scaleX:1,scaleY:1};function wr(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)*As,skewX:Math.atan(l)*As,scaleX:a,scaleY:s}}var Ko;function Cs(e){let t=new(typeof DOMMatrix=="function"?DOMMatrix:WebKitCSSMatrix)(e+"");return t.isIdentity?Xo:wr(t.a,t.b,t.c,t.d,t.e,t.f)}function Ss(e){return e==null?Xo:(Ko||(Ko=document.createElementNS("http://www.w3.org/2000/svg","g")),Ko.setAttribute("transform",e),(e=Ko.transform.baseVal.consolidate())?(e=e.matrix,wr(e.a,e.b,e.c,e.d,e.e,e.f)):Xo)}function Ms(e,t,o,n){function r(c){return c.length?c.pop()+" ":""}function i(c,d,u,p,f,x){if(c!==u||d!==p){var g=f.push("translate(",null,t,null,o);x.push({i:g-4,x:he(c,u)},{i:g-2,x:he(d,p)})}else(u||p)&&f.push("translate("+u+t+p+o)}function a(c,d,u,p){c!==d?(c-d>180?d+=360:d-c>180&&(c+=360),p.push({i:u.push(r(u)+"rotate(",null,n)-2,x:he(c,d)})):d&&u.push(r(u)+"rotate("+d+n)}function s(c,d,u,p){c!==d?p.push({i:u.push(r(u)+"skewX(",null,n)-2,x:he(c,d)}):d&&u.push(r(u)+"skewX("+d+n)}function l(c,d,u,p,f,x){if(c!==u||d!==p){var g=f.push(r(f)+"scale(",null,",",null,")");x.push({i:g-4,x:he(c,u)},{i:g-2,x:he(d,p)})}else(u!==1||p!==1)&&f.push(r(f)+"scale("+u+","+p+")")}return function(c,d){var u=[],p=[];return c=e(c),d=e(d),i(c.translateX,c.translateY,d.translateX,d.translateY,u,p),a(c.rotate,d.rotate,u,p),s(c.skewX,d.skewX,u,p),l(c.scaleX,c.scaleY,d.scaleX,d.scaleY,u,p),c=d=null,function(f){for(var x=-1,g=p.length,m;++x<g;)u[(m=p[x]).i]=m.x(f);return u.join("")}}}var Ir=Ms(Cs,"px, ","px)","deg)"),Ar=Ms(Ss,", ",")",")");var xt=0,Qt=0,Jt=0,Ls=1e3,qo,jt,Zo=0,tt=0,Jo=0,eo=typeof performance=="object"&&performance.now?performance:Date,ks=typeof window=="object"&&window.requestAnimationFrame?window.requestAnimationFrame.bind(window):function(e){setTimeout(e,17)};function oo(){return tt||(ks(op),tt=eo.now()+Jo)}function op(){tt=0}function to(){this._call=this._time=this._next=null}to.prototype=Qo.prototype={constructor:to,restart:function(e,t,o){if(typeof e!="function")throw new TypeError("callback is not a function");o=(o==null?oo():+o)+(t==null?0:+t),!this._next&&jt!==this&&(jt?jt._next=this:qo=this,jt=this),this._call=e,this._time=o,Cr()},stop:function(){this._call&&(this._call=null,this._time=1/0,Cr())}};function Qo(e,t,o){var n=new to;return n.restart(e,t,o),n}function Ds(){oo(),++xt;for(var e=qo,t;e;)(t=tt-e._time)>=0&&e._call.call(void 0,t),e=e._next;--xt}function Ps(){tt=(Zo=eo.now())+Jo,xt=Qt=0;try{Ds()}finally{xt=0,rp(),tt=0}}function np(){var e=eo.now(),t=e-Zo;t>Ls&&(Jo-=t,Zo=e)}function rp(){for(var e,t=qo,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:qo=o);jt=e,Cr(n)}function Cr(e){if(!xt){Qt&&(Qt=clearTimeout(Qt));var t=e-tt;t>24?(e<1/0&&(Qt=setTimeout(Ps,e-eo.now()-Jo)),Jt&&(Jt=clearInterval(Jt))):(Jt||(Zo=eo.now(),Jt=setInterval(np,Ls)),xt=1,ks(Ps))}}function jo(e,t,o){var n=new to;return t=t==null?0:+t,n.restart(r=>{n.stop(),e(r+t)},t,o),n}var ip=mr("start","end","cancel","interrupt"),sp=[],Os=0,Rs=1,tn=2,en=3,Vs=4,on=5,no=6;function Ye(e,t,o,n,r,i){var a=e.__transition;if(!a)e.__transition={};else if(o in a)return;ap(e,o,{name:t,index:n,group:r,on:ip,tween:sp,time:i.time,delay:i.delay,duration:i.duration,ease:i.ease,timer:null,state:Os})}function ro(e,t){var o=Q(e,t);if(o.state>Os)throw new Error("too late; already scheduled");return o}function oe(e,t){var o=Q(e,t);if(o.state>en)throw new Error("too late; already running");return o}function Q(e,t){var o=e.__transition;if(!o||!(o=o[t]))throw new Error("transition not found");return o}function ap(e,t,o){var n=e.__transition,r;n[t]=o,o.timer=Qo(i,0,o.time);function i(c){o.state=Rs,o.timer.restart(a,o.delay,o.time),o.delay<=c&&a(c-o.delay)}function a(c){var d,u,p,f;if(o.state!==Rs)return l();for(d in n)if(f=n[d],f.name===o.name){if(f.state===en)return jo(a);f.state===Vs?(f.state=no,f.timer.stop(),f.on.call("interrupt",e,e.__data__,f.index,f.group),delete n[d]):+d<t&&(f.state=no,f.timer.stop(),f.on.call("cancel",e,e.__data__,f.index,f.group),delete n[d])}if(jo(function(){o.state===en&&(o.state=Vs,o.timer.restart(s,o.delay,o.time),s(c))}),o.state=tn,o.on.call("start",e,e.__data__,o.index,o.group),o.state===tn){for(o.state=en,r=new Array(p=o.tween.length),d=0,u=-1;d<p;++d)(f=o.tween[d].value.call(e,e.__data__,o.index,o.group))&&(r[++u]=f);r.length=u+1}}function s(c){for(var d=c<o.duration?o.ease.call(null,c/o.duration):(o.timer.restart(l),o.state=on,1),u=-1,p=r.length;++u<p;)r[u].call(e,d);o.state===on&&(o.on.call("end",e,e.__data__,o.index,o.group),l())}function l(){o.state=no,o.timer.stop(),delete n[t];for(var c in n)return;delete e.__transition}}function Sr(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>tn&&n.state<on,n.state=no,n.timer.stop(),n.on.call(r?"interrupt":"cancel",e,e.__data__,n.index,n.group),delete o[a]}i&&delete e.__transition}}function Hs(e){return this.each(function(){Sr(this,e)})}function lp(e,t){var o,n;return function(){var r=oe(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 cp(e,t,o){var n,r;if(typeof o!="function")throw new Error;return function(){var i=oe(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 Gs(e,t){var o=this._id;if(e+="",arguments.length<2){for(var n=Q(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?lp:cp)(o,e,t))}function Et(e,t,o){var n=e._id;return e.each(function(){var r=oe(this,n);(r.value||(r.value={}))[t]=o.apply(this,arguments)}),function(r){return Q(r,n).value[t]}}function nn(e,t){var o;return(typeof t=="number"?he:t instanceof We?$o:(o=We(t))?(t=o,$o):vr)(e,t)}function dp(e){return function(){this.removeAttribute(e)}}function up(e){return function(){this.removeAttributeNS(e.space,e.local)}}function pp(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 fp(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 mp(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 gp(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 Bs(e,t){var o=Re(e),n=o==="transform"?Ar:nn;return this.attrTween(e,typeof t=="function"?(o.local?gp:mp)(o,n,Et(this,"attr."+e,t)):t==null?(o.local?up:dp)(o):(o.local?fp:pp)(o,n,t))}function hp(e,t){return function(o){this.setAttribute(e,t.call(this,o))}}function yp(e,t){return function(o){this.setAttributeNS(e.space,e.local,t.call(this,o))}}function xp(e,t){var o,n;function r(){var i=t.apply(this,arguments);return i!==n&&(o=(n=i)&&yp(e,i)),o}return r._value=t,r}function Ep(e,t){var o,n;function r(){var i=t.apply(this,arguments);return i!==n&&(o=(n=i)&&hp(e,i)),o}return r._value=t,r}function zs(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=Re(e);return this.tween(o,(n.local?xp:Ep)(n,t))}function bp(e,t){return function(){ro(this,e).delay=+t.apply(this,arguments)}}function _p(e,t){return t=+t,function(){ro(this,e).delay=t}}function Fs(e){var t=this._id;return arguments.length?this.each((typeof e=="function"?bp:_p)(t,e)):Q(this.node(),t).delay}function Tp(e,t){return function(){oe(this,e).duration=+t.apply(this,arguments)}}function Np(e,t){return t=+t,function(){oe(this,e).duration=t}}function Ws(e){var t=this._id;return arguments.length?this.each((typeof e=="function"?Tp:Np)(t,e)):Q(this.node(),t).duration}function vp(e,t){if(typeof t!="function")throw new Error;return function(){oe(this,e).ease=t}}function Ys(e){var t=this._id;return arguments.length?this.each(vp(t,e)):Q(this.node(),t).ease}function wp(e,t){return function(){var o=t.apply(this,arguments);if(typeof o!="function")throw new Error;oe(this,e).ease=o}}function Us(e){if(typeof e!="function")throw new Error;return this.each(wp(this._id,e))}function $s(e){typeof e!="function"&&(e=$t(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 le(n,this._parents,this._name,this._id)}function Xs(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),p,f=0;f<d;++f)(p=l[f]||c[f])&&(u[f]=p);for(;s<n;++s)a[s]=t[s];return new le(a,this._parents,this._name,this._id)}function Ip(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 Ap(e,t,o){var n,r,i=Ip(t)?ro:oe;return function(){var a=i(this,e),s=a.on;s!==n&&(r=(n=s).copy()).on(t,o),a.on=r}}function Ks(e,t){var o=this._id;return arguments.length<2?Q(this.node(),o).on.on(e):this.each(Ap(o,e,t))}function Cp(e){return function(){var t=this.parentNode;for(var o in this.__transition)if(+o!==e)return;t&&t.removeChild(this)}}function qs(){return this.on("end.remove",Cp(this._id))}function Zs(e){var t=this._name,o=this._id;typeof e!="function"&&(e=Qe(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,p=0;p<l;++p)(d=s[p])&&(u=e.call(d,d.__data__,p,s))&&("__data__"in d&&(u.__data__=d.__data__),c[p]=u,Ye(c[p],t,o,p,c,Q(d,o)));return new le(i,this._parents,t,o)}function Js(e){var t=this._name,o=this._id;typeof e!="function"&&(e=Ut(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 p=e.call(d,d.__data__,u,l),f,x=Q(d,o),g=0,m=p.length;g<m;++g)(f=p[g])&&Ye(f,t,o,g,p,x);i.push(p),a.push(d)}return new le(i,a,t,o)}var Sp=Ve.prototype.constructor;function Qs(){return new Sp(this._groups,this._parents)}function Mp(e,t){var o,n,r;return function(){var i=Fe(this,e),a=(this.style.removeProperty(e),Fe(this,e));return i===a?null:i===o&&a===n?r:r=t(o=i,n=a)}}function js(e){return function(){this.style.removeProperty(e)}}function Pp(e,t,o){var n,r=o+"",i;return function(){var a=Fe(this,e);return a===r?null:a===n?i:i=t(n=a,o)}}function Lp(e,t,o){var n,r,i;return function(){var a=Fe(this,e),s=o(this),l=s+"";return s==null&&(l=s=(this.style.removeProperty(e),Fe(this,e))),a===l?null:a===n&&l===r?i:(r=l,i=t(n=a,s))}}function kp(e,t){var o,n,r,i="style."+t,a="end."+i,s;return function(){var l=oe(this,e),c=l.on,d=l.value[i]==null?s||(s=js(t)):void 0;(c!==o||r!==d)&&(n=(o=c).copy()).on(a,r=d),l.on=n}}function ea(e,t,o){var n=(e+="")=="transform"?Ir:nn;return t==null?this.styleTween(e,Mp(e,n)).on("end.style."+e,js(e)):typeof t=="function"?this.styleTween(e,Lp(e,n,Et(this,"style."+e,t))).each(kp(this._id,e)):this.styleTween(e,Pp(e,n,t),o).on("end.style."+e,null)}function Dp(e,t,o){return function(n){this.style.setProperty(e,t.call(this,n),o)}}function Rp(e,t,o){var n,r;function i(){var a=t.apply(this,arguments);return a!==r&&(n=(r=a)&&Dp(e,a,o)),n}return i._value=t,i}function ta(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,Rp(e,t,o==null?"":o))}function Vp(e){return function(){this.textContent=e}}function Op(e){return function(){var t=e(this);this.textContent=t==null?"":t}}function oa(e){return this.tween("text",typeof e=="function"?Op(Et(this,"text",e)):Vp(e==null?"":e+""))}function Hp(e){return function(t){this.textContent=e.call(this,t)}}function Gp(e){var t,o;function n(){var r=e.apply(this,arguments);return r!==o&&(t=(o=r)&&Hp(r)),t}return n._value=e,n}function na(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,Gp(e))}function ra(){for(var e=this._name,t=this._id,o=rn(),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=Q(l,t);Ye(l,e,o,c,a,{time:d.time+d.delay+d.duration,delay:0,duration:d.duration,ease:d.ease})}return new le(n,this._parents,e,o)}function ia(){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=oe(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 Bp=0;function le(e,t,o,n){this._groups=e,this._parents=t,this._name=o,this._id=n}function sa(e){return Ve().transition(e)}function rn(){return++Bp}var Oe=Ve.prototype;le.prototype=sa.prototype={constructor:le,select:Zs,selectAll:Js,selectChild:Oe.selectChild,selectChildren:Oe.selectChildren,filter:$s,merge:Xs,selection:Qs,transition:ra,call:Oe.call,nodes:Oe.nodes,node:Oe.node,size:Oe.size,empty:Oe.empty,each:Oe.each,on:Ks,attr:Bs,attrTween:zs,style:ea,styleTween:ta,text:oa,textTween:na,remove:qs,tween:Gs,delay:Fs,duration:Ws,ease:Ys,easeVarying:Us,end:ia,[Symbol.iterator]:Oe[Symbol.iterator]};function sn(e){return((e*=2)<=1?e*e*e:(e-=2)*e*e+2)/2}var zp={time:null,delay:0,duration:250,ease:sn};function Fp(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 aa(e){var t,o;e instanceof le?(t=e._id,e=e._name):(t=rn(),(o=zp).time=oo(),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])&&Ye(l,e,t,c,a,o||Fp(l,t));return new le(n,this._parents,e,t)}Ve.prototype.interrupt=Hs;Ve.prototype.transition=aa;function Ue(e,t,o){this.k=e,this.x=t,this.y=o}Ue.prototype={constructor:Ue,scale:function(e){return e===1?this:new Ue(this.k*e,this.x,this.y)},translate:function(e,t){return e===0&t===0?this:new Ue(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 an=new Ue(1,0,0);ln.prototype=Ue.prototype;function ln(e){for(;!e.__zoom;)if(!(e=e.parentNode))return an;return e.__zoom}var Yp=[[Number.NEGATIVE_INFINITY,Number.NEGATIVE_INFINITY],[Number.POSITIVE_INFINITY,Number.POSITIVE_INFINITY]];var la;(function(e){e.Strict="strict",e.Loose="loose"})(la||(la={}));var ca;(function(e){e.Free="free",e.Vertical="vertical",e.Horizontal="horizontal"})(ca||(ca={}));var da;(function(e){e.Partial="partial",e.Full="full"})(da||(da={}));var ua;(function(e){e.Bezier="default",e.Straight="straight",e.Step="step",e.SmoothStep="smoothstep",e.SimpleBezier="simplebezier"})(ua||(ua={}));var pa;(function(e){e.Arrow="arrow",e.ArrowClosed="arrowclosed"})(pa||(pa={}));var ue;(function(e){e.Left="left",e.Top="top",e.Right="right",e.Bottom="bottom"})(ue||(ue={}));var QT={[ue.Left]:ue.Right,[ue.Right]:ue.Left,[ue.Top]:ue.Bottom,[ue.Bottom]:ue.Top};var Up=e=>"id"in e&&"internals"in e&&!("source"in e)&&!("target"in e);var $p=(e,t=[0,0])=>{var s;let{width:o,height:n}=Xp(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 fe=(e,t=[0,0])=>{var r,i,a,s,l,c,d,u;let{x:o,y:n}=Up(e)?e.internals.positionAbsolute:$p(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 Xp(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 jT={[ue.Left]:{x:-1,y:0},[ue.Right]:{x:1,y:0},[ue.Top]:{x:0,y:-1},[ue.Bottom]:{x:0,y:1}};var Kp={nodeOrigin:[0,0],nodeExtent:Yp,elevateNodesOnSelect:!0,defaults:{}},eN=N(E({},Kp),{checkEquality:!0});var fa;(function(e){e.Line="line",e.Handle="handle"})(fa||(fa={}));var qp={width:0,height:0,x:0,y:0},tN=N(E({},qp),{pointerX:0,pointerY:0,aspectRatio:1});import{useCallback as io,useEffect as of,useRef as nf,useState as ya}from"react";import{shallow as rf}from"zustand/shallow";var Zp=(e,t)=>e.x<t.x2&&e.x2>t.x&&e.y<t.y2&&e.y2>t.y;function Jp(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 Qp(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 cn=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){let i=t==="horizontal"?this.yLines:this.xLines,[a,s]=t==="horizontal"?[r.y,r.y2]:[r.x,r.x2],l=[];for(let p of i){if(p.position<a)continue;if(p.position>s)break;if(p.node.id===n.id||p.node.parentId===n.id||!Zp(p.nodeBox,r))continue;let f=Math.abs(p.position-o);if(f>dn)continue;let g=Jp(p.nodeBox,fe(n))>0?0:Qp(p.nodeBox,fe(n));l.push({line:p,lineDist:f,nodeDist:g})}let c=.5,d=t==="horizontal"?this.lastHorizontalLine:this.lastVerticalLine;l.sort((p,f)=>{if(d){if(p.line===d&&f.line!==d)return-1;if(f.line===d&&p.line!==d)return 1}return Math.abs(p.lineDist-f.lineDist)<=c?p.nodeDist-f.nodeDist:p.lineDist-f.lineDist});let u=l.length>0?l[0].line:void 0;return u&&(t==="horizontal"?this.lastHorizontalLine=u:this.lastVerticalLine=u),u}};function ma(e,t=ot,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=fe(i);Object.entries(t).forEach(([s,l])=>{var c;n.push({nodeBox:a,node:r,orientation:l.orientation,position:l.resolve(r,a),color:(c=r.style)==null?void 0:c.backgroundColor,anchorName:s})})}),n}function ga(e,t,o,n,r=Object.keys(ot)){let i=[];for(let s of r){let l=ot[s],c=l.resolve(o,n),d=e.search(l.orientation,c,o,t);d&&i.push({anchorName:s,sourcePosition:c,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 ha(e,t,o,n,r,i,a,s){var u,p,f,x,g,m,y,h;if(!(o!=null&&o.position))return{snappedX:!1,snappedY:!1};let l=!1,c=!1,d={x:o.position.x,y:o.position.y,x2:o.position.x+((p=(u=e.measured)==null?void 0:u.width)!=null?p:0),y2:o.position.y+((x=(f=e.measured)==null?void 0:f.height)!=null?x:0)};if(a){let T=a.anchor.resolve(e,d)-a.line.position;if(Math.abs(T)<=dn){if(o.position.y-=T,r!=null&&r.dimensions)if(n){let _=t.internals.positionAbsolute.y+((m=(g=e.measured)==null?void 0:g.height)!=null?m:0);r.dimensions.height=_-a.line.position}else r.dimensions.height=a.line.position-t.internals.positionAbsolute.y;c=!0}}if(s){let T=s.anchor.resolve(e,d)-s.line.position;if(Math.abs(T)<=dn){if(o.position.x-=T,r!=null&&r.dimensions)if(n){let _=t.internals.positionAbsolute.x+((h=(y=e.measured)==null?void 0:y.width)!=null?h:0);r.dimensions.width=_-s.line.position}else r.dimensions.width=s.line.position-t.internals.positionAbsolute.x;l=!0}}return i&&(l||c)&&(o.position.x-=i.position.x,o.position.y-=i.position.y),{snappedX:l,snappedY:c}}var dn=10,ot={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 af}from"react/jsx-runtime";var sf=new cn;function un(){let[e,t]=ya(void 0),[o,n]=ya(void 0),{width:r,height:i}=tf(m=>({width:m.width,height:m.height}),rf),a=jp(),s=nf(sf),{screenToFlowPosition:l,getInternalNode:c,getNodes:d}=ef(),u=io(()=>{t(void 0),n(void 0)},[]),p=io(m=>{let y=m!=null?m:d();u();let h=ma(y,ot,c);s.current.initialize(h)},[c,u,d]),f=io(()=>{setTimeout(()=>{p()},100)},[p]);of(()=>{a&&p(d())},[a,p,d]);let x=io((m,y)=>{var X,D,H,z,W;if(!s.current||m.length===0||m.length>2)return m;u();let h,b,T=Object.keys(ot);m.length===1?m[0].type==="position"?h=m[0]:m[0].type==="dimensions"&&(b=m[0],T=["right","bottom"]):m[0].type==="position"&&m[1].type==="dimensions"&&m[1].dimensions&&(h=m[0],b=m[1],T=["top","left"]);let _=y.find(Y=>Y.id===m[0].id);if(!_)return m;let v=c(_.id);if(!v)throw new Error(`Node with id ${_.id} not found in internal nodes`);let w=c((X=v.parentId)!=null?X:""),S=fe(v);b!=null&&b.dimensions&&(S.x2=S.x+b.dimensions.width,S.y2=S.y+b.dimensions.height);let{x:L,y:P}=l({x:0,y:0}),{x:C,y:I}=l({x:r,y:i}),M={x:L,y:P,x2:C,y2:I},{horizontal:A,vertical:k}=ga(s.current,M,_,S,T),V={id:_.id,type:"position",position:{x:v.internals.positionAbsolute.x,y:v.internals.positionAbsolute.y},dragging:!1};h!=null&&h.position&&V.position&&(w?(V.position.x=h.position.x+((H=(D=w==null?void 0:w.position)==null?void 0:D.x)!=null?H:0),V.position.y=h.position.y+((W=(z=w==null?void 0:w.position)==null?void 0:z.y)!=null?W:0)):(V.position.x=h.position.x,V.position.y=h.position.y));let{snappedX:O,snappedY:B}=ha(_,v,V,h,b,w,A,k);if(O||B){if((b!=null&&b.resizing||h!=null&&h.dragging)&&(O&&n(k==null?void 0:k.line),B&&t(A==null?void 0:A.line)),b&&h)return[V,b];if(h)return[V];if(b)return[b]}return m},[l,c,r,i,t,n,u]),g=io(()=>af(xa,{horizontal:e,vertical:o}),[e,o]);return{rebuildIndex:p,forceRebuildIndex:f,updateHelperLines:x,helperLineHorizontal:e,helperLineVertical:o,HelperLines:g}}import{reconnectEdge as Jg,useReactFlow as Qg}from"@xyflow/react";import{useCallback as lt,useRef as jg}from"react";var bt=e=>new Map(e.map(t=>[t.id,t])),so=(e,t,o)=>t.filter(n=>!(n.source!==e||o&&n.id===o)),Ea=(e,t,o)=>t.filter(n=>!(n.target!==e||o&&n.id===o)),pn=e=>e.some(t=>t.type==="START_EVENT"),ba=(e,t,o,n,r)=>{let i=bt(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:so(e,n,r).filter(c=>{let d=i.get(c.target);return(d==null?void 0:d.type)!=="ANNOTATION"}).length>=1},_a=(e,t,o,n,r)=>{let i=bt(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:Ea(t,n,r).filter(c=>{let d=i.get(c.source);return(d==null?void 0:d.type)!=="ANNOTATION"}).length>=1},fn=(e,t,o,n)=>{var a;let r=t.find(s=>s.id===e);return!r||r.type!=="GATEWAY"||((a=r.data)==null?void 0:a.variant)!=="EXCLUSIVE"?!1:so(e,o,n).length>=2},Ta=(e,t,o)=>{var a,s,l,c;let n=bt(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"},mn=(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"},gn=(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"},hn=(e,t,o,n)=>{let r=bt(t),i=r.get(e);return!i||i.type!=="TASK"?!1:Ea(e,o,n).some(s=>{let l=r.get(s.source);return(l==null?void 0:l.type)==="START_EVENT"})},yn=(e,t,o,n)=>{let r=bt(t),i=r.get(e);return!i||i.type!=="TASK"?!1:so(e,o,n).some(s=>{let l=r.get(s.target);return(l==null?void 0:l.type)==="END_EVENT"})},xn=(e,t,o)=>so(e,t,o).length>0,En=(e,t,o,n,r)=>{let i=bt(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:so(e,n,r).filter(c=>{let d=i.get(c.target);return(d==null?void 0:d.type)!=="ANNOTATION"}).length>=2};var lf=[e=>({isValid:e.sourceNodeId!==e.targetNodeId,reason:"self_connection_not_allowed"}),e=>({isValid:!ba(e.sourceNodeId,e.targetNodeId,e.nodes,e.edges,e.reconnectingEdgeId),reason:"start_event_limit_reached"}),e=>({isValid:!_a(e.sourceNodeId,e.targetNodeId,e.nodes,e.edges,e.reconnectingEdgeId),reason:"end_event_limit_reached"}),e=>({isValid:!fn(e.sourceNodeId,e.nodes,e.edges,e.reconnectingEdgeId),reason:"gateway_limit_reached"}),e=>({isValid:!En(e.sourceNodeId,e.targetNodeId,e.nodes,e.edges,e.reconnectingEdgeId),reason:"task_limit_reached"}),e=>({isValid:Ta(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==="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:!(mn(e.sourceNodeId,e.nodes)&&e.targetNodeType==="END_EVENT"),reason:"script_to_end_not_allowed"}),e=>({isValid:!(gn(e.sourceNodeId,e.nodes)&&e.targetNodeType==="END_EVENT"),reason:"loop_to_end_not_allowed"}),e=>({isValid:!(hn(e.sourceNodeId,e.nodes,e.edges,e.reconnectingEdgeId)&&e.targetNodeType==="END_EVENT"),reason:"initial_activity_to_end_not_allowed"}),e=>({isValid:!(yn(e.sourceNodeId,e.nodes,e.edges,e.reconnectingEdgeId)&&e.targetNodeType!=="ANNOTATION"),reason:"final_activity_cannot_connect"}),e=>({isValid:!(xn(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:[],UNSUPPORTED:[]}[e.sourceNodeType]||[]).includes(e.targetNodeType),reason:"connection_type_not_allowed"})],Mr=e=>{for(let t of lf){let o=t(e);if(!o.isValid)return o}return{isValid:!0}};var cf=[{sourceTypes:["GATEWAY"],targetTypes:["TASK","GATEWAY"],validate:e=>({shouldDisable:fn(e.sourceNodeId,e.nodes,e.edges),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:pn(e.nodes),reason:"start_event_already_exists"})},{sourceTypes:["TASK"],targetTypes:["END_EVENT"],validate:e=>({shouldDisable:mn(e.sourceNodeId,e.nodes),reason:"script_to_end_not_allowed"})},{sourceTypes:["TASK"],targetTypes:["END_EVENT"],validate:e=>({shouldDisable:gn(e.sourceNodeId,e.nodes),reason:"loop_to_end_not_allowed"})},{sourceTypes:["TASK"],targetTypes:["END_EVENT"],validate:e=>({shouldDisable:hn(e.sourceNodeId,e.nodes,e.edges),reason:"initial_activity_to_end_not_allowed"})},{sourceTypes:["TASK"],validate:e=>({shouldDisable:yn(e.sourceNodeId,e.nodes,e.edges)&&e.targetNodeType!=="ANNOTATION",reason:"final_activity_cannot_connect"})},{targetTypes:["END_EVENT"],validate:e=>({shouldDisable:xn(e.sourceNodeId,e.edges),reason:"activity_has_outgoing_connections"})},{sourceTypes:["TASK"],validate:e=>({shouldDisable:En(e.sourceNodeId,null,e.nodes,e.edges)&&e.targetNodeType!=="ANNOTATION",reason:"task_limit_reached"})}],Na=e=>{let t=cf.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 Rf,EdgeLabelRenderer as Vf,getStraightPath as Of,useInternalNode as Ia,useViewport as Hf}from"@xyflow/react";import{Position as ao}from"@xyflow/react";function va(e,t){var b,T,_,v;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+((T=(b=t==null?void 0:t.measured)==null?void 0:b.width)!=null?T:0)/2,u=i.y+((v=(_=t==null?void 0:t.measured)==null?void 0:_.height)!=null?v:0)/2,p=(d-l)/(2*a)-(u-c)/(2*s),f=(d-l)/(2*a)+(u-c)/(2*s),x=1/(Math.abs(p)+Math.abs(f)||1),g=x*p,m=x*f,y=a*(g+m)+l,h=s*(-g+m)+c;return{x:y,y:h}}function wa(e,t){var c,d,u,p;let{positionAbsolute:o}=e.internals,n=(d=(c=e.measured)==null?void 0:c.width)!=null?d:0,r=(p=(u=e.measured)==null?void 0:u.height)!=null?p:0,i=Math.round(o.x),a=Math.round(o.y),s=Math.round(t.x),l=Math.round(t.y);return s<=i+1?ao.Left:s>=i+n-1?ao.Right:l<=a+1?ao.Top:l>=a+r-1?ao.Bottom:ao.Top}function Ae(e,t){let o=va(e,t),n=va(t,e),r=wa(e,o),i=wa(t,n);return{sx:o.x,sy:o.y,tx:n.x,ty:n.y,sourcePos:r,targetPos:i}}import{Button as pf,Tooltip as ff,TooltipContent as mf,TooltipTrigger as gf,useTranslation as hf}from"lecom-ui";import{Settings as yf}from"lucide-react";import{getIncomers as bn,getOutgoers as _n,useReactFlow as uf}from"@xyflow/react";import{useStoreApi as df}from"@xyflow/react";var $e=()=>{let e=df();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 Co(),!0}}};var Tn=()=>{let{getNode:e,getEdge:t,getNodes:o,getEdges:n}=uf(),{selectElements:r}=$e(),i=m=>{let y=o(),h=n(),b=bn(m,y,h),T=_n(m,y,h),_=b.some(w=>w.type==="START_EVENT"),v=T.some(w=>w.type==="END_EVENT");return _?"start":v?"end":"between"},a=(m,y,h)=>{var _,v,w,S;if(!m)return;let b={type:m.type,variant:(_=m.data)==null?void 0:_.variant,attribute:(v=m.data)==null?void 0:v.attribute},T={id:m.id,position:i(m),label:(w=m.data)==null?void 0:w.label,node:b};return m.type==="TASK"&&((S=m.data)==null?void 0:S.variant)==="SUBPROCESS"?N(E({},T),{type:"sub_process"}):m.type==="GATEWAY"?N(E({},T),{type:"gateway",variant:s(m,y,h)}):N(E({},T),{type:"activity"})},s=(m,y,h)=>{if(m.type!=="GATEWAY")return;let b=bn(m,y,h),T=!1,_=!1;if(b.forEach(v=>{var w,S;v.type==="TASK"&&(((w=v.data)==null?void 0:w.variant)==="SCRIPT"&&(T=!0),((S=v.data)==null?void 0:S.attribute)==="LOOP"&&(_=!0))}),T&&_)return"script_loop";if(T)return"script";if(_)return"loop"},l=(m,y,h)=>{var w,S,L,P;let b=e(m.source),T=e(m.target);if(!b||!T)return"simple";if(_n(b,y,h).some(C=>C.type==="END_EVENT"))return"final";if(b.type==="GATEWAY")switch((w=b.data)==null?void 0:w.variant){case"PARALLEL":return"parallel";case"EXCLUSIVE":return"exclusive";case"COMPLEX":return"complex";default:return"simple"}if(b.type==="TASK"){let C=(S=b.data)==null?void 0:S.variant,I=(L=b.data)==null?void 0:L.attribute;if(T.type==="TASK"&&((P=T.data)==null?void 0:P.variant)==="SUBPROCESS")return"to_sub_process";let M=C==="SCRIPT",A=I==="LOOP";return M&&A?"script_loop":M?"script":A?"loop":"simple"}return"simple"},c=(m,y,h)=>{let b=[];function T(v,w,S=0){let L=a(v,y,h);if(L.depth=S,w.push(L),v.type==="TASK"){b.push([...w]),w.pop();return}let P=bn(v,y,h);if(P.length)for(let C of P)T(C,w,S+1);w.pop()}let _=bn(m,y,h);for(let v of _)T(v,[]);return b},d=(m,y,h)=>{let b=[];function T(v,w,S=0){let L=a(v,y,h);if(L.depth=S,w.push(L),v.type==="TASK"){b.push([...w]),w.pop();return}let P=_n(v,y,h);if(P.length)for(let C of P)T(C,w,S+1);w.pop()}let _=_n(m,y,h);for(let v of _)T(v,[]);return b},u=(m,y,h)=>(h=h.filter(T=>T.source===m.id),h.map(T=>{var w;let _=e(T.target),v;return _&&(v=a(_,y,h)),{id:T.id,type:"routing",variant:l(T,y,h),label:(w=T.data)==null?void 0:w.label,target:v}})),p=m=>{let y=e(m);if(!y)return;let h=o(),b=n(),T=a(y,h,b);return T.sources=c(y,h,b),T.targets=d(y,h,b),T.edgeTargets=u(y,h,b),y.type==="GATEWAY"&&(T.variant=s(y,h,b)),T},f=m=>{let y=t(m);if(!y)return;let h=o(),b=n(),T=l(y,h,b),v={id:y.id,type:"routing",variant:T,gatewayVariant:void 0},w=e(y.source);if(w){let L=a(w,h,b),P=c(w,h,b),C=s(w,h,b);v.source=L,v.sources=P.length?P:[[L]],v.gatewayVariant=C}let S=e(y.target);if(S){let L=a(S,h,b),P=d(S,h,b);v.target=L,v.targets=P.length?P:[[L]]}return v},x=m=>{let y=e(m);if(y)return p(y.id);let h=t(m);if(h)return f(h.id)};return{configureElement:m=>{let y=x(m);if(y)return r([m]),y},getConfigureElement:x,getNodeConfigure:p,getEdgeConfigure:f}};import{jsx as Nn,jsxs as xf}from"react/jsx-runtime";var Xe=({elementId:e,elementType:t="node"})=>{let{t:o}=hf(),{onConfigureElement:n}=G(),{getConfigureElement:r}=Tn();return xf(ff,{children:[Nn(gf,{asChild:!0,children:Nn(pf,{variant:"ghost",color:"grey",size:"small",iconButton:!0,onClick:()=>{let a=r(e);a&&(n==null||n(a))},children:Nn(yf,{size:16})})}),Nn(mf,{color:"black",children:o(t==="node"?"editor.toolbar.configure_node":"editor.toolbar.configure_edge")})]})};import{useReactFlow as Ef}from"@xyflow/react";import{Button as bf,Tooltip as _f,TooltipContent as Tf,TooltipTrigger as Nf,useTranslation as vf}from"lecom-ui";import{TrashIcon as wf}from"lucide-react";import{jsx as vn,jsxs as If}from"react/jsx-runtime";var wn=({elementId:e,elementType:t="node"})=>{let{t:o}=vf(),{deleteElements:n}=Ef();return If(_f,{children:[vn(Nf,{asChild:!0,children:vn(bf,{variant:"ghost",color:"destructive",size:"small",iconButton:!0,onClick:()=>{n(t==="node"?{nodes:[{id:e}]}:{edges:[{id:e}]})},children:vn(wf,{size:16})})}),vn(Tf,{color:"black",children:o("editor.toolbar.delete")})]})};import{Button as Af,Tooltip as Cf,TooltipContent as Sf,TooltipTrigger as Mf,useTranslation as Pf}from"lecom-ui";import{MoveUpRightIcon as Lf}from"lucide-react";import{useCallback as kf}from"react";import{jsx as In,jsxs as Df}from"react/jsx-runtime";var lo=({nodeId:e,disabled:t=!1,tooltipMessage:o})=>{let{t:n}=Pf(),r=kf(i=>{i.stopPropagation();let a=document.querySelector(`[data-id="${e}"]`);if(!a)return;let s=a.querySelector(".react-flow__handle.source");if(!s)return;let 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 Df(Cf,{children:[In(Mf,{asChild:!0,children:In(Af,{variant:"ghost",color:"grey",size:"small",iconButton:!0,disabled:t,className:t?"opacity-50 cursor-not-allowed":"",onMouseDown:t?void 0:r,children:In(Lf,{size:16})})}),In(Sf,{color:"black",children:o||n("editor.toolbar.connect_node")})]})};import{jsx as co}from"react/jsx-runtime";var _t=i=>{var a=i,{edgeId:e,edgeType:t,sourceNode:o,targetNode:n}=a,r=we(a,["edgeId","edgeType","sourceNode","targetNode"]);let{mode:s}=G(),l=(o==null?void 0:o.type)==="START_EVENT",c=(o==null?void 0:o.type)==="GATEWAY"&&(n==null?void 0:n.type)==="GATEWAY",d=(o==null?void 0:o.type)==="TASK"&&(n==null?void 0:n.type)==="GATEWAY",u=!l&&!c&&!d,p=[{component:co(wn,{elementId:e,elementType:"edge"})}],f=()=>s==="view"?u?[{component:co(Xe,{elementId:e,elementType:"edge"})}]:[]:u?[{component:co(Xe,{elementId:e,elementType:"edge"})},...p]:p,g=(m=>{switch(m){case"SEQUENCE_EDGE":return f();case"MESSAGE_EDGE":return s==="view"?[]:[...p];case"ANNOTATION_EDGE":return s==="view"?[]:[...p];default:return[]}})(t);if(!(g.length===0||s==="view"))return co("div",N(E({className:"flex items-center gap-1 w-fit px-3 py-2 bg-white rounded-sm shadow-md"},r),{children:g.map((m,y)=>co("div",{children:m.component},y))}))};import{jsx as An,jsxs as Gf}from"react/jsx-runtime";var Tt={type:"ANNOTATION_EDGE",reconnectable:!0},Aa=({id:e,source:t,target:o,selected:n,data:r})=>{let{zoom:i}=Hf(),{isMultipleSelection:a}=G(),s=Ia(t),l=Ia(o);if(!s||!l)return null;let{sx:c,sy:d,tx:u,ty:p}=Ae(s,l),[f,x,g]=Of({sourceX:c,sourceY:d,targetX:u,targetY:p}),m=n||(s==null?void 0:s.selected)||(l==null?void 0:l.selected),y=1/i;return Gf("g",{className:R("text-grey-400 hover:text-grey-500",{"text-blue-500 hover:text-blue-600":m}),children:[An(Rf,{id:e,path:f,strokeDasharray:4,className:R("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)})}),An(Vf,{children:An("div",{className:"absolute z-[3000] pointer-events-auto flex flex-col items-center gap-1",style:{transform:`translate(-50%, -50%) translate(${x}px, ${g}px)`},children:n&&!a&&An(_t,{edgeId:e,edgeType:"ANNOTATION_EDGE",style:{transform:`scale(${y})`}})})})]})};import{useState as La,useCallback as Uf,useMemo as Or,useEffect as $f,useRef as ka}from"react";import{BaseEdge as Xf,EdgeLabelRenderer as Kf,MarkerType as Da,useInternalNode as Ra,useReactFlow as qf,useViewport as Zf,Position as Va}from"@xyflow/react";import{useEffect as Ca,useRef as Bf,useState as zf}from"react";import{jsx as Sa}from"react/jsx-runtime";var re=({value:e,maxLength:t,style:o,className:n,contentClassName:r,isEditing:i,onChange:a,onBlur:s})=>{let l=Bf(null),[c,d]=zf(!1);Ca(()=>{d(i!=null?i:!1)},[i]),Ca(()=>{if(c&&l.current){l.current.focus();let g=document.createRange();g.selectNodeContents(l.current);let m=window.getSelection();m&&(m.removeAllRanges(),m.addRange(g))}},[c]);let u=g=>{g.stopPropagation(),c||d(!0)},p=g=>{let m=g.currentTarget.innerText.trim(),y=t&&m.length>=t,h=["Backspace","Delete","ArrowLeft","ArrowRight","ArrowUp","ArrowDown","Home","End","Tab","Enter","Escape","Shift"],b=g.ctrlKey||g.metaKey,T=b&&g.key==="a",_=b&&g.key==="c",v=b&&g.key==="x",w=b&&g.key==="v";function S(P){return/\w/.test(P)}if(m.length===0&&!S(g.key)&&!h.includes(g.key)&&!b){g.preventDefault();return}y&&(h.includes(g.key)||T||_||v||w||g.preventDefault())},f=g=>{if(!t)return;g.preventDefault();let m=g.clipboardData.getData("text/plain"),y=g.currentTarget.innerText,h=window.getSelection();if(!h||h.rangeCount===0)return;let b=h.getRangeAt(0);if((y.substring(0,b.startOffset)+m+y.substring(b.endOffset)).length>t){let _=t-(y.length-(b.endOffset-b.startOffset)),v=m.substring(0,Math.max(0,_));v&&(b.deleteContents(),b.insertNode(document.createTextNode(v)),b.setStartAfter(b.endContainer),b.collapse(!0),h.removeAllRanges(),h.addRange(b))}else b.deleteContents(),b.insertNode(document.createTextNode(m)),b.setStartAfter(b.endContainer),b.collapse(!0),h.removeAllRanges(),h.addRange(b)},x=g=>{d(!1);let m=g.currentTarget.innerText.trim();t&&m.length>t&&(m=m.substring(0,t)),g.currentTarget.innerText=m,s==null||s(),m!==e&&(a==null||a(m))};return Sa("div",{className:R("flex-1 p-2 self-stretch content-center border border-transparent overflow-hidden text-ellipsis text-sm text-center",n,{"border border-dashed border-grey-400":c}),style:o,onDoubleClick:u,children:Sa("div",{ref:l,className:R("outline-none whitespace-pre-wrap overflow-hidden",r,{"nodrag nopan cursor-text":c}),contentEditable:!0,suppressContentEditableWarning:!0,onKeyDown:p,onPaste:f,onBlur:x,children:e})})};import{Position as Cn}from"@xyflow/react";var Sn=e=>e===Cn.Left||e===Cn.Right,Pr=(e,t=30)=>e===Cn.Right||e===Cn.Bottom?t:-t,Lr=(e,t,o,n=1)=>Math.abs(e[o]-t[o])<n,Mn=(e,t)=>Math.sqrt((t.x-e.x)**2+(t.y-e.y)**2),Pn=(e,t)=>({x:(e.x+t.x)/2,y:(e.y+t.y)/2});var nt={OFFSET:30,TOLERANCE:1,MOVE_THRESHOLD:5,MIN_SEGMENT_LENGTH:15};function Ff(e,t,o,n,r,i){let a=Pr(r,nt.OFFSET),s=Pr(i,nt.OFFSET),l=Sn(r),c=Sn(i),d={x:e,y:t},u={x:o,y:n};if(l&&c){let p=(t+n)/2;return[d,{x:e+a,y:t},{x:e+a,y:p},{x:o+s,y:p},{x:o+s,y:n},u]}if(!l&&!c){let p=(e+o)/2;return[d,{x:e,y:t+a},{x:p,y:t+a},{x:p,y:n+s},{x:o,y:n+s},u]}return l?[d,{x:e+a,y:t},{x:e+a,y:n+s},{x:o,y:n+s},u]:[d,{x:e,y:t+a},{x:o+s,y:t+a},{x:o+s,y:n},u]}function kr(e,t,o,n,r,i,a){let s=Ff(e,t,o,n,r,i);if(!(a!=null&&a.length)||a.length!==s.length-2)return s;let l=[{x:e,y:t},...a,{x:o,y:n}],c=Sn(r);for(let d=0;d<l.length-1;d++){let u=l[d],p=l[d+1];if(Math.abs(p.x-u.x)>nt.TOLERANCE&&Math.abs(p.y-u.y)>nt.TOLERANCE){let x=d%2===0===c;l[d+1]=x?{x:p.x,y:u.y}:{x:u.x,y:p.y}}}return l}var Ma=e=>{if(e.length<2)return"";let[t,...o]=e;return`M ${t.x},${t.y}${o.map(n=>` L ${n.x},${n.y}`).join("")}`};import{useCallback as Dr,useEffect as Rr,useRef as Vr,useState as Ln}from"react";import{useReactFlow as Wf,useStore as Yf}from"@xyflow/react";var Pa=({edgeId:e,source:t,target:o,instanceId:n,isReadOnly:r})=>{let{setEdges:i,getNode:a,getNodes:s,screenToFlowPosition:l}=Wf(),c=Yf(S=>S.isValidConnection),[d,u]=Ln(null),[p,f]=Ln(null),[x,g]=Ln(null),[m,y]=Ln(!1),h=Vr(null),b=Vr(t),T=Vr(o);Rr(()=>{b.current=t,T.current=o},[t,o]),Rr(()=>{h.current=d},[d]);let _=Dr(S=>{var A;let L=h.current;if(!L)return;let P=l({x:S.clientX,y:S.clientY});f(P);let I=document.elementFromPoint(S.clientX,S.clientY),M=null;for(;I&&I!==document.body;){let k=I.getAttribute("data-id");if(k&&s().some(V=>V.id===k)){M=k;break}I=I.parentElement}if(g(M),M){let k={source:L==="source"?M:b.current,target:L==="target"?M:T.current,sourceHandle:null,targetHandle:null},V=(A=c==null?void 0:c(k))!=null?A:!0;y(V)}else y(!1)},[s,l,c]),v=Dr(S=>{var k;let L=h.current;if(!L)return;let P=s(),C=document.elementFromPoint(S.clientX,S.clientY),I=null,M=C;for(;M&&M!==document.body;){let V=M.getAttribute("data-id");if(V&&P.some(O=>O.id===V)){I=V;break}M=M.parentElement}if(I){let V={source:L==="source"?I:b.current,target:L==="target"?I:T.current,sourceHandle:null,targetHandle:null};if((k=c==null?void 0:c(V))==null||k){let O=a(V.source),B=a(V.target);O&&B&&i(X=>X.map(D=>D.id===e?N(E({},D),{source:V.source,target:V.target,data:N(E({},D.data),{points:void 0})}):D))}}u(null),f(null),g(null),y(!1),document.removeEventListener("mouseup",v),document.removeEventListener("mousemove",_);let A=Ce.get(n);A==null||A.clearReconnectingEdge()},[e,s,a,i,n,_,c]),w=Dr((S,L)=>{if(r||L.button!==0)return;L.stopPropagation(),L.preventDefault(),u(S);let P=Ce.get(n);P==null||P.setReconnectingEdge(e),document.addEventListener("mousemove",_),document.addEventListener("mouseup",v)},[r,e,n,_,v]);return Rr(()=>()=>{if(h.current){document.removeEventListener("mousemove",_),document.removeEventListener("mouseup",v);let S=Ce.get(n);S==null||S.clearReconnectingEdge()}},[n,_,v]),{reconnectingHandle:d,cursorPosition:p,hoveredNodeId:x,isValidReconnection:m,handleReconnectStart:w}};import{Fragment as Ha,jsx as ie,jsxs as Ke}from"react/jsx-runtime";var Te={type:"SEQUENCE_EDGE",reconnectable:!0,markerStart:{type:Da.ArrowClosed},markerEnd:{type:Da.Arrow},data:{label:""}},{TOLERANCE:Oa,MOVE_THRESHOLD:kn,MIN_SEGMENT_LENGTH:Jf}=nt,Ga=({id:e,source:t,target:o,data:n,selected:r})=>{var X;let{zoom:i}=Zf(),{updateEdgeData:a}=qf(),{isMultipleSelection:s,mode:l,instanceId:c}=G(),[d,u]=La(!1),[p,f]=La(null),x=ka(null),g=ka(null),m=l==="readonly",{reconnectingHandle:y,cursorPosition:h,hoveredNodeId:b,isValidReconnection:T,handleReconnectStart:_}=Pa({edgeId:e,source:t,target:o,instanceId:c,isReadOnly:m}),v=Ra(t),w=Ra(o),{sx:S,sy:L,tx:P,ty:C,sourcePos:I,targetPos:M}=Or(()=>v&&w?Ae(v,w):{sx:0,sy:0,tx:0,ty:0,sourcePos:Va.Right,targetPos:Va.Left},[v,w]);$f(()=>{var z;if(!g.current){g.current={sx:S,sy:L,tx:P,ty:C,sourcePos:I,targetPos:M};return}let D=g.current;(Math.abs(S-D.sx)>kn||Math.abs(L-D.sy)>kn||Math.abs(P-D.tx)>kn||Math.abs(C-D.ty)>kn||D.sourcePos!==I||D.targetPos!==M)&&((z=n==null?void 0:n.points)!=null&&z.length)&&a(e,N(E({},n),{points:void 0})),g.current={sx:S,sy:L,tx:P,ty:C,sourcePos:I,targetPos:M}},[S,L,P,C,I,M,n,e,a]);let A=Or(()=>{var D;if((D=n==null?void 0:n.points)!=null&&D.length&&v&&w){let H=n.points[0],z=n.points[n.points.length-1],Y=Ae(v,{internals:{positionAbsolute:H},measured:{width:1,height:1}}),q=Ae({internals:{positionAbsolute:z},measured:{width:1,height:1}},w);return kr(Y.sx,Y.sy,q.tx,q.ty,Y.sourcePos,q.targetPos,n.points)}return kr(S,L,P,C,I,M,n==null?void 0:n.points)},[S,L,P,C,I,M,n==null?void 0:n.points,v,w]),k=Or(()=>{if(A.length<2)return Pn({x:S,y:L},{x:P,y:C});let D=0;for(let W=0;W<A.length-1;W++)D+=Mn(A[W],A[W+1]);let H=D/2,z=0;for(let W=0;W<A.length-1;W++){let Y=Mn(A[W],A[W+1]);if(z+Y>=H){let Z=(H-z)/Y,q=A[W],ne=A[W+1];return{x:q.x+(ne.x-q.x)*Z,y:q.y+(ne.y-q.y)*Z}}z+=Y}return Pn({x:S,y:L},{x:P,y:C})},[A,S,L,P,C]),V=Uf((D,H)=>{if(l!=="edit"||H.button!==0)return;H.stopPropagation(),H.preventDefault();let z=A[D],W=A[D+1],Y=Lr(z,W,"y"),Z=Y?z.y:z.x;f(D);let q=Le=>{let ve=Z+(Y?Le.clientY-H.clientY:Le.clientX-H.clientX)/i;x.current=Y?{x:(z.x+W.x)/2,y:ve}:{x:ve,y:(z.y+W.y)/2};let Bt=A.map((ke,zt)=>zt===0||zt===A.length-1?ke:(Y?Math.abs(ke.y-Z)<Oa:Math.abs(ke.x-Z)<Oa)?Y?N(E({},ke),{y:ve}):N(E({},ke),{x:ve}):ke);a(e,N(E({},n),{points:Bt.slice(1,-1)}))},ne=()=>{f(null),x.current=null,document.removeEventListener("mousemove",q),document.removeEventListener("mouseup",ne)};document.addEventListener("mousemove",q),document.addEventListener("mouseup",ne)},[l,A,i,n,e,a]);if(!v||!w)return null;let O=Ma(A),B=r||v.selected||w.selected;return Ke(Ha,{children:[Ke("g",{className:R("text-grey-400 hover:text-grey-500",{"text-blue-500 hover:text-blue-600":B}),onBlur:()=>u(!1),onDoubleClick:()=>u(!0),children:[ie(Xf,{id:e,path:O,markerEnd:`url(#${B?"sequence-edge-marker-highlighted":"sequence-edge-marker"})`,className:R("stroke-2 stroke-current transition-colors duration-75",{"stroke-red-500 hover:stroke-red-600":n==null?void 0:n.hasError,"stroke-blue-500 hover:stroke-blue-600 drop-shadow-[0_0_3px_rgba(59,130,246,0.5)]":B&&!(n!=null&&n.hasError)})}),y&&h&&ie("line",{x1:y==="source"?A[0].x:A[A.length-1].x,y1:y==="source"?A[0].y:A[A.length-1].y,x2:h.x,y2:h.y,stroke:b?T?"#10b981":"#ef4444":"#3b82f6",strokeWidth:3,strokeDasharray:"8 4",opacity:.6,className:"pointer-events-none"}),r&&!s&&!m&&ie("g",{children:A.slice(0,-1).map((D,H)=>{let z=A[H+1];if(H===0||H===A.length-2||Mn(D,z)<Jf)return null;let W=Lr(D,z,"y"),Y=p===H,Z=Y&&x.current?x.current:Pn(D,z);return Ke("g",{children:[ie("line",{x1:D.x,y1:D.y,x2:z.x,y2:z.y,stroke:"transparent",strokeWidth:20/i,className:R("cursor-pointer",{"cursor-ns-resize":W,"cursor-ew-resize":!W}),onMouseDown:q=>V(H,q)}),ie("circle",{cx:Z.x,cy:Z.y,r:4/i,fill:Y?"#3b82f6":"#fff",stroke:"#3b82f6",strokeWidth:2/i,className:"pointer-events-none"}),ie("circle",{cx:Z.x,cy:Z.y,r:6/i,fill:"none",stroke:"#3b82f6",strokeWidth:1/i,opacity:Y?.6:.3,className:"pointer-events-none"})]},H)})})]}),Ke(Kf,{children:[Ke("div",{className:"absolute z-[3000] pointer-events-auto flex flex-col items-center gap-1",style:{transform:`translate(-50%, -50%) translate(${k.x}px, ${k.y}px)`},children:[r&&!s&&ie(_t,{edgeId:e,edgeType:"SEQUENCE_EDGE",sourceNode:v,targetNode:w,style:{transform:`scale(${1/i})`}}),(d||((X=n==null?void 0:n.label)==null?void 0:X.trim()))&&ie(re,{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:d,onChange:D=>a(e,{label:D.trim()})})]}),r&&!s&&!m&&Ke(Ha,{children:[ie("div",{className:"absolute z-[1000] pointer-events-none",style:{transform:`translate(-50%, -50%) translate(${A[0].x}px, ${A[0].y}px)`},children:Ke("svg",{width:12/i,height:12/i,style:{overflow:"visible",position:"absolute",left:"50%",top:"50%",transform:"translate(-50%, -50%)"},children:[ie("circle",{cx:6/i,cy:6/i,r:4/i,fill:y==="source"?"#3b82f6":"#fff",stroke:"#3b82f6",strokeWidth:2/i,className:"pointer-events-none"}),ie("circle",{cx:6/i,cy:6/i,r:6/i,fill:"none",stroke:"#3b82f6",strokeWidth:1/i,opacity:y==="source"?.6:.3,className:"pointer-events-none"}),ie("circle",{cx:6/i,cy:6/i,r:8/i,fill:"transparent",className:R("pointer-events-auto",{"cursor-move":!y||y!=="source","cursor-not-allowed":y==="source"&&b&&!T,"cursor-grabbing":y==="source"&&(!b||T)}),onMouseDown:D=>_("source",D.nativeEvent)})]})}),ie("div",{className:"absolute z-[1000] pointer-events-none",style:{transform:`translate(-50%, -50%) translate(${A[A.length-1].x}px, ${A[A.length-1].y}px)`},children:Ke("svg",{width:12/i,height:12/i,style:{overflow:"visible",position:"absolute",left:"50%",top:"50%",transform:"translate(-50%, -50%)"},children:[ie("circle",{cx:6/i,cy:6/i,r:4/i,fill:y==="target"?"#3b82f6":"#fff",stroke:"#3b82f6",strokeWidth:2/i,className:"pointer-events-none"}),ie("circle",{cx:6/i,cy:6/i,r:6/i,fill:"none",stroke:"#3b82f6",strokeWidth:1/i,opacity:y==="target"?.6:.3,className:"pointer-events-none"}),ie("circle",{cx:6/i,cy:6/i,r:8/i,fill:"transparent",className:R("pointer-events-auto",{"cursor-move":!y||y!=="target","cursor-not-allowed":y==="target"&&b&&!T,"cursor-grabbing":y==="target"&&(!b||T)}),onMouseDown:D=>_("target",D.nativeEvent)})]})})]})]})]})};import{useDebouncedCallback as qg}from"use-debounce";import{useReactFlow as Kg}from"@xyflow/react";import{useCallback as jl}from"react";var po=(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))(po||{});import{xml2json as Qf,json2xml as jf}from"xml-js";var Ba={compact:!0,spaces:4},em=e=>e.replaceAll(`
|
|
2
|
-
`,"
");function
|
|
1
|
+
var Hd=Object.defineProperty,Gd=Object.defineProperties;var Bd=Object.getOwnPropertyDescriptors;var jo=Object.getOwnPropertySymbols;var ki=Object.prototype.hasOwnProperty,Di=Object.prototype.propertyIsEnumerable;var Li=(e,t,o)=>t in e?Hd(e,t,{enumerable:!0,configurable:!0,writable:!0,value:o}):e[t]=o,E=(e,t)=>{for(var o in t||(t={}))ki.call(t,o)&&Li(e,o,t[o]);if(jo)for(var o of jo(t))Di.call(t,o)&&Li(e,o,t[o]);return e},v=(e,t)=>Gd(e,Bd(t));var $e=(e,t)=>{var o={};for(var n in e)ki.call(e,n)&&t.indexOf(n)<0&&(o[n]=e[n]);if(e!=null&&jo)for(var n of jo(e))t.indexOf(n)<0&&Di.call(e,n)&&(o[n]=e[n]);return o};var Dr=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 zd,Translations as Fd}from"lecom-ui";var Ri={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",connect_node:"Connect element",connecting:"Connecting..."},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:{error:"Error exporting diagram"}},import_governance:"Import diagram from Governance platform",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"}},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"}}},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 Oi={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",connect_node:"Conectar elemento",connecting:"Conectando..."},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:{error:"Error al exportar diagrama"}},import_governance:"Importar diagrama de la plataforma Governance",minimap:{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"}},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"}},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 Vi={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",connect_node:"Conectar elemento",connecting:"Conectando..."},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:{error:"Erro ao exportar o diagrama"}},import_governance:"Importar diagrama da plataforma Governance",minimap:{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"}},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 tarefa"},variant:{default:"Tarefa",script:"Tarefa de script",subprocess:"Subprocesso"},attribute:{loop:"Tarefa 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"}}},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 Hi={pt_BR:Vi,en_US:Ri,es_ES:Oi};var Gi,Bi,Wd=(Bi=(Gi=Dr("LecomUserLanguage"))!=null?Gi:Dr("org.springframework.web.servlet.i18n.CookieLocaleResolver.LOCALE"))!=null?Bi:Fd.PT_BR;zd({lng:Wd,resources:Hi});var Pe=(n=>(n.EDIT="edit",n.VIEW="view",n.READONLY="readonly",n))(Pe||{});var en=(r=>(r.ACTIVITY="activity",r.ROUTING="routing",r.GATEWAY="gateway",r.SUB_PROCESS="sub_process",r))(en||{}),Rr=(n=>(n.START="start",n.END="end",n.BETWEEN="between",n))(Rr||{}),Or=(n=>(n.SCRIPT="script",n.LOOP="loop",n.SCRIPT_LOOP="script_loop",n))(Or||{}),Vr=(c=>(c.SIMPLE="simple",c.LOOP="loop",c.SCRIPT="script",c.SCRIPT_LOOP="script_loop",c.COMPLEX="complex",c.EXCLUSIVE="exclusive",c.PARALLEL="parallel",c.FINAL="final",c.TO_SUB_PROCESS="to_sub_process",c))(Vr||{});import{RotateCcw as tu,ScrollText as ou,SquarePlus as nu}from"lucide-react";import{jsx as tn,jsxs as Yd}from"react/jsx-runtime";var on=({size:e=24,className:t})=>Yd("svg",{width:e,height:e,viewBox:"0 0 24 24",xmlns:"http://www.w3.org/2000/svg",fill:"#6b7280",className:t,children:[tn("path",{strokeWidth:"2",d:"M16 3V3.5085V11.9998V20.4915V21H16.5411H21.4592H22V19.123H21.4592H17.9974V11.9998V4.8773H21.4592H22V3H21.4592H16.5411H16Z"}),tn("path",{d:"M4.41026 16.9999L2 18.7861L3.89693 21.1103L6.3072 19.324L4.41026 16.9999Z"}),tn("path",{d:"M8.41026 13.9999L6 15.7861L7.89693 18.1103L10.3072 16.324L8.41026 13.9999Z"}),tn("path",{d:"M12.4313 10.954L10.021 12.7402L11.9179 15.0644L14.3282 13.2781L12.4313 10.954Z"})]});import{jsx as zi}from"react/jsx-runtime";var kt=({size:e=24,className:t})=>zi("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:zi("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 mo,jsxs as Ud}from"react/jsx-runtime";var Dt=({size:e=24,className:t})=>Ud("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:[mo("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"}),mo("path",{d:"M12 8V16",strokeLinecap:"round",strokeLinejoin:"round"}),mo("path",{d:"M8 12H16",strokeLinecap:"round",strokeLinejoin:"round"}),mo("path",{d:"M9.17139 9.17188L14.8282 14.8287",strokeLinecap:"round",strokeLinejoin:"round"}),mo("path",{d:"M14.8281 9.17188L9.17127 14.8287",strokeLinecap:"round",strokeLinejoin:"round"})]});import{jsx as Hr,jsxs as $d}from"react/jsx-runtime";var Rt=({size:e=24,className:t})=>$d("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:[Hr("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"}),Hr("path",{d:"M14.8286 9.17188L9.17176 14.8287",strokeLinecap:"round",strokeLinejoin:"round"}),Hr("path",{d:"M9.17139 9.17188L14.8282 14.8287",strokeLinecap:"round",strokeLinejoin:"round"})]});import{jsx as Gr,jsxs as Xd}from"react/jsx-runtime";var Ot=({size:e=24,className:t})=>Xd("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:[Gr("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"}),Gr("path",{d:"M12 8V16",strokeLinecap:"round",strokeLinejoin:"round"}),Gr("path",{d:"M8 12H16",strokeLinecap:"round",strokeLinejoin:"round"})]});import{jsx as Br,jsxs as Kd}from"react/jsx-runtime";var Fi=({size:e=24,className:t})=>Br("svg",{width:e,height:e,viewBox:"0 0 34 24",xmlns:"http://www.w3.org/2000/svg",fill:"currentColor",className:t,children:Kd("g",{children:[Br("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"}),Br("path",{d:"M24.5 4.5L28 1M28 1L31.5 4.5M28 1V8",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round"})]})});import{clsx as qd}from"clsx";import{twMerge as Zd}from"tailwind-merge";function k(...e){return Zd(qd(e))}var ot=(e=0,t=0)=>e<t?t:e,nn=(e=1e3)=>new Promise(t=>{setTimeout(t,e)});import{jsx as Wi,jsxs as Jd}from"react/jsx-runtime";var Yi=({size:e=24,className:t})=>Jd("svg",{width:e,height:e,viewBox:"0 0 24 24",fill:"none",stroke:"#6b7280",strokeWidth:2,xmlns:"http://www.w3.org/2000/svg",className:k("stroke-2",t),children:[Wi("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"}),Wi("path",{d:"M9 3V21",strokeLinecap:"round",strokeLinejoin:"round"})]});import{jsx as zr}from"react/jsx-runtime";var Ui=({size:e=24,className:t})=>zr("svg",{width:e,height:e,viewBox:"0 0 24 24",xmlns:"http://www.w3.org/2000/svg",stroke:"currentColor",className:t,children:zr("g",{children:zr("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 $i}from"react/jsx-runtime";var rn=({size:e=24,className:t})=>$i("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:$i("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 Xi}from"react/jsx-runtime";var go=({size:e=24,className:t})=>Xi("svg",{width:e,height:e,viewBox:"0 0 24 24",xmlns:"http://www.w3.org/2000/svg",fill:"white",stroke:"#6b7280",className:k("stroke-2",t),children:Xi("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 Fr,jsxs as Qd}from"react/jsx-runtime";var Ki=({size:e=24,className:t})=>Qd("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:[Fr("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"}),Fr("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"}),Fr("path",{d:"M7.5 7.5V10H10",strokeWidth:"1.5",fill:"none",strokeLinecap:"round",strokeLinejoin:"round"})]});import{jsx as ho,jsxs as jd}from"react/jsx-runtime";var qi=({size:e=24,className:t})=>jd("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:[ho("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"}),ho("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"}),ho("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"}),ho("path",{d:"M13.5 12H11",strokeWidth:"1",strokeLinecap:"round",strokeLinejoin:"round"}),ho("path",{d:"M13.5 10H11",strokeWidth:"1",strokeLinecap:"round",strokeLinejoin:"round"})]});import{jsx as sn,jsxs as eu}from"react/jsx-runtime";var Zi=({size:e=24,className:t})=>eu("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:[sn("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"}),sn("path",{d:"M8 21V14C8 13.4477 8.44772 13 9 13H15C15.5523 13 16 13.4477 16 14V21",strokeWidth:"1",fill:"none"}),sn("path",{d:"M10.2222 17H13.7777",strokeWidth:"1",strokeLinecap:"round",strokeLinejoin:"round"}),sn("path",{d:"M12 15.2227V18.7782",strokeWidth:"1",strokeLinecap:"round",strokeLinejoin:"round"})]});var Q=(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))(Q||{}),ze=(o=>(o.SCRIPT="SCRIPT",o.SUBPROCESS="SUBPROCESS",o))(ze||{}),an={SCRIPT:{icon:ou},SUBPROCESS:{icon:nu}},nt=(t=>(t.LOOP="LOOP",t))(nt||{}),ln={LOOP:{icon:tu}},Fe=(n=>(n.EXCLUSIVE="EXCLUSIVE",n.PARALLEL="PARALLEL",n.COMPLEX="COMPLEX",n))(Fe||{}),Wr={EXCLUSIVE:{icon:Rt},PARALLEL:{icon:Ot},COMPLEX:{icon:Dt}};import{ReactFlowProvider as Vy}from"@xyflow/react";import{createContext as Hy,useContext as Gy,useEffect as By,useId as zy,useMemo as Fy,useState as Ue}from"react";import{Background as yy,MiniMap as xy,ReactFlow as Ey,SelectionMode as by}from"@xyflow/react";import{forwardRef as _y,useImperativeHandle as Ty}from"react";import{useEdgesState as t0,useNodesState as o0,useOnSelectionChange as n0}from"@xyflow/react";import{useCallback as br,useEffect as r0}from"react";import{create as ru}from"zustand";import{useReactFlow as iu}from"@xyflow/react";import{useCallback as su}from"react";var cn=()=>{let{setEdges:e}=iu();return su(()=>{let o=Et.getState().pathEdgeIds;e(n=>n.map(r=>v(E({},r),{selected:o.includes(r.id)})))},[e])},Et=ru((e,t)=>({statusByNodeId:{},statusData:{},pathEdgeIds:[],setTaskStatuses:o=>{o!=null&&o.length&&e(n=>{let r=E({},n.statusByNodeId),i=E({},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 p=[],f=new Set;for(p.push({node:d,path:[]}),f.add(d);p.length>0;){let{node:h,path:g}=p.shift();if(h===u)return g;let m=a[h]||[];for(let{targetId:x,edgeId:y}of m)f.has(x)||(f.add(x),p.push({node:x,path:[...g,y]}))}return[]};for(let d=0;d<r.length-1;d++){let u=r[d],p=r[d+1],f=c(u,p);f.length>0&&i.push(...f)}i.length>0&&e({pathEdgeIds:i})}}));import{useNodesInitialized as Tf,useReactFlow as Nf,useStore as vf}from"@xyflow/react";var au={value:()=>{}};function Qi(){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 dn(o)}function dn(e){this._=e}function lu(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}})}dn.prototype=Qi.prototype={constructor:dn,on:function(e,t){var o=this._,n=lu(e+"",o),r,i=-1,a=n.length;if(arguments.length<2){for(;++i<a;)if((r=(e=n[i]).type)&&(r=cu(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]=Ji(o[r],e.name,t);else if(t==null)for(r in o)o[r]=Ji(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 dn(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 cu(e,t){for(var o=0,n=e.length,r;o<n;++o)if((r=e[o]).name===t)return r.value}function Ji(e,t,o){for(var n=0,r=e.length;n<r;++n)if(e[n].name===t){e[n]=au,e=e.slice(0,n).concat(e.slice(n+1));break}return o!=null&&e.push({name:t,value:o}),e}var Yr=Qi;var un="http://www.w3.org/1999/xhtml",Ur={svg:"http://www.w3.org/2000/svg",xhtml:un,xlink:"http://www.w3.org/1999/xlink",xml:"http://www.w3.org/XML/1998/namespace",xmlns:"http://www.w3.org/2000/xmlns/"};function Je(e){var t=e+="",o=t.indexOf(":");return o>=0&&(t=e.slice(0,o))!=="xmlns"&&(e=e.slice(o+1)),Ur.hasOwnProperty(t)?{space:Ur[t],local:e}:e}function du(e){return function(){var t=this.ownerDocument,o=this.namespaceURI;return o===un&&t.documentElement.namespaceURI===un?t.createElement(e):t.createElementNS(o,e)}}function uu(e){return function(){return this.ownerDocument.createElementNS(e.space,e.local)}}function pn(e){var t=Je(e);return(t.local?uu:du)(t)}function pu(){}function bt(e){return e==null?pu:function(){return this.querySelector(e)}}function ji(e){typeof e!="function"&&(e=bt(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 ge(n,this._parents)}function $r(e){return e==null?[]:Array.isArray(e)?e:Array.from(e)}function fu(){return[]}function yo(e){return e==null?fu:function(){return this.querySelectorAll(e)}}function mu(e){return function(){return $r(e.apply(this,arguments))}}function es(e){typeof e=="function"?e=mu(e):e=yo(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 ge(n,r)}function xo(e){return function(){return this.matches(e)}}function fn(e){return function(t){return t.matches(e)}}var gu=Array.prototype.find;function hu(e){return function(){return gu.call(this.children,e)}}function yu(){return this.firstElementChild}function ts(e){return this.select(e==null?yu:hu(typeof e=="function"?e:fn(e)))}var xu=Array.prototype.filter;function Eu(){return Array.from(this.children)}function bu(e){return function(){return xu.call(this.children,e)}}function os(e){return this.selectAll(e==null?Eu:bu(typeof e=="function"?e:fn(e)))}function ns(e){typeof e!="function"&&(e=xo(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 ge(n,this._parents)}function mn(e){return new Array(e.length)}function rs(){return new ge(this._enter||this._groups.map(mn),this._parents)}function Eo(e,t){this.ownerDocument=e.ownerDocument,this.namespaceURI=e.namespaceURI,this._next=null,this._parent=e,this.__data__=t}Eo.prototype={constructor:Eo,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 is(e){return function(){return e}}function _u(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 Eo(e,i[a]);for(;a<l;++a)(s=t[a])&&(r[a]=s)}function Tu(e,t,o,n,r,i,a){var s,l,c=new Map,d=t.length,u=i.length,p=new Array(d),f;for(s=0;s<d;++s)(l=t[s])&&(p[s]=f=a.call(l,l.__data__,s,t)+"",c.has(f)?r[s]=l:c.set(f,l));for(s=0;s<u;++s)f=a.call(e,i[s],s,i)+"",(l=c.get(f))?(n[s]=l,l.__data__=i[s],c.delete(f)):o[s]=new Eo(e,i[s]);for(s=0;s<d;++s)(l=t[s])&&c.get(p[s])===l&&(r[s]=l)}function Nu(e){return e.__data__}function ss(e,t){if(!arguments.length)return Array.from(this,Nu);var o=t?Tu:_u,n=this._parents,r=this._groups;typeof e!="function"&&(e=is(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],p=u.length,f=vu(e.call(d,d&&d.__data__,c,n)),h=f.length,g=s[c]=new Array(h),m=a[c]=new Array(h),x=l[c]=new Array(p);o(d,u,g,m,x,f,t);for(var y=0,b=0,N,T;y<h;++y)if(N=g[y]){for(y>=b&&(b=y+1);!(T=m[b])&&++b<h;);N._next=T||null}}return a=new ge(a,n),a._enter=s,a._exit=l,a}function vu(e){return typeof e=="object"&&"length"in e?e:Array.from(e)}function as(){return new ge(this._exit||this._groups.map(mn),this._parents)}function ls(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 cs(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,p=s[l]=new Array(u),f,h=0;h<u;++h)(f=c[h]||d[h])&&(p[h]=f);for(;l<r;++l)s[l]=o[l];return new ge(s,this._parents)}function ds(){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 us(e){e||(e=wu);function t(u,p){return u&&p?e(u.__data__,p.__data__):!u-!p}for(var o=this._groups,n=o.length,r=new Array(n),i=0;i<n;++i){for(var 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 ge(r,this._parents).order()}function wu(e,t){return e<t?-1:e>t?1:e>=t?0:NaN}function ps(){var e=arguments[0];return arguments[0]=this,e.apply(null,arguments),this}function fs(){return Array.from(this)}function ms(){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 gs(){let e=0;for(let t of this)++e;return e}function hs(){return!this.node()}function ys(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 Iu(e){return function(){this.removeAttribute(e)}}function Au(e){return function(){this.removeAttributeNS(e.space,e.local)}}function Cu(e,t){return function(){this.setAttribute(e,t)}}function Su(e,t){return function(){this.setAttributeNS(e.space,e.local,t)}}function Mu(e,t){return function(){var o=t.apply(this,arguments);o==null?this.removeAttribute(e):this.setAttribute(e,o)}}function Pu(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 xs(e,t){var o=Je(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?Au:Iu:typeof t=="function"?o.local?Pu:Mu:o.local?Su:Cu)(o,t))}function gn(e){return e.ownerDocument&&e.ownerDocument.defaultView||e.document&&e||e.defaultView}function Lu(e){return function(){this.style.removeProperty(e)}}function ku(e,t,o){return function(){this.style.setProperty(e,t,o)}}function Du(e,t,o){return function(){var n=t.apply(this,arguments);n==null?this.style.removeProperty(e):this.style.setProperty(e,n,o)}}function Es(e,t,o){return arguments.length>1?this.each((t==null?Lu:typeof t=="function"?Du:ku)(e,t,o==null?"":o)):rt(this.node(),e)}function rt(e,t){return e.style.getPropertyValue(t)||gn(e).getComputedStyle(e,null).getPropertyValue(t)}function Ru(e){return function(){delete this[e]}}function Ou(e,t){return function(){this[e]=t}}function Vu(e,t){return function(){var o=t.apply(this,arguments);o==null?delete this[e]:this[e]=o}}function bs(e,t){return arguments.length>1?this.each((t==null?Ru:typeof t=="function"?Vu:Ou)(e,t)):this.node()[e]}function _s(e){return e.trim().split(/^|\s+/)}function Xr(e){return e.classList||new Ts(e)}function Ts(e){this._node=e,this._names=_s(e.getAttribute("class")||"")}Ts.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 Ns(e,t){for(var o=Xr(e),n=-1,r=t.length;++n<r;)o.add(t[n])}function vs(e,t){for(var o=Xr(e),n=-1,r=t.length;++n<r;)o.remove(t[n])}function Hu(e){return function(){Ns(this,e)}}function Gu(e){return function(){vs(this,e)}}function Bu(e,t){return function(){(t.apply(this,arguments)?Ns:vs)(this,e)}}function ws(e,t){var o=_s(e+"");if(arguments.length<2){for(var n=Xr(this.node()),r=-1,i=o.length;++r<i;)if(!n.contains(o[r]))return!1;return!0}return this.each((typeof t=="function"?Bu:t?Hu:Gu)(o,t))}function zu(){this.textContent=""}function Fu(e){return function(){this.textContent=e}}function Wu(e){return function(){var t=e.apply(this,arguments);this.textContent=t==null?"":t}}function Is(e){return arguments.length?this.each(e==null?zu:(typeof e=="function"?Wu:Fu)(e)):this.node().textContent}function Yu(){this.innerHTML=""}function Uu(e){return function(){this.innerHTML=e}}function $u(e){return function(){var t=e.apply(this,arguments);this.innerHTML=t==null?"":t}}function As(e){return arguments.length?this.each(e==null?Yu:(typeof e=="function"?$u:Uu)(e)):this.node().innerHTML}function Xu(){this.nextSibling&&this.parentNode.appendChild(this)}function Cs(){return this.each(Xu)}function Ku(){this.previousSibling&&this.parentNode.insertBefore(this,this.parentNode.firstChild)}function Ss(){return this.each(Ku)}function Ms(e){var t=typeof e=="function"?e:pn(e);return this.select(function(){return this.appendChild(t.apply(this,arguments))})}function qu(){return null}function Ps(e,t){var o=typeof e=="function"?e:pn(e),n=t==null?qu:typeof t=="function"?t:bt(t);return this.select(function(){return this.insertBefore(o.apply(this,arguments),n.apply(this,arguments)||null)})}function Zu(){var e=this.parentNode;e&&e.removeChild(this)}function Ls(){return this.each(Zu)}function Ju(){var e=this.cloneNode(!1),t=this.parentNode;return t?t.insertBefore(e,this.nextSibling):e}function Qu(){var e=this.cloneNode(!0),t=this.parentNode;return t?t.insertBefore(e,this.nextSibling):e}function ks(e){return this.select(e?Qu:Ju)}function Ds(e){return arguments.length?this.property("__data__",e):this.node().__data__}function ju(e){return function(t){e.call(this,t,this.__data__)}}function ep(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 tp(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 op(e,t,o){return function(){var n=this.__on,r,i=ju(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 Rs(e,t,o){var n=ep(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?op:tp,r=0;r<i;++r)this.each(s(n[r],t,o));return this}function Os(e,t,o){var n=gn(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 np(e,t){return function(){return Os(this,e,t)}}function rp(e,t){return function(){return Os(this,e,t.apply(this,arguments))}}function Vs(e,t){return this.each((typeof t=="function"?rp:np)(e,t))}function*Hs(){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 ip=[null];function ge(e,t){this._groups=e,this._parents=t}function Gs(){return new ge([[document.documentElement]],ip)}function sp(){return this}ge.prototype=Gs.prototype={constructor:ge,select:ji,selectAll:es,selectChild:ts,selectChildren:os,filter:ns,data:ss,enter:rs,exit:as,join:ls,merge:cs,selection:sp,order:ds,sort:us,call:ps,nodes:fs,node:ms,size:gs,empty:hs,each:ys,attr:xs,style:Es,property:bs,classed:ws,text:Is,html:As,raise:Cs,lower:Ss,append:Ms,insert:Ps,remove:Ls,clone:ks,datum:Ds,on:Rs,dispatch:Vs,[Symbol.iterator]:Hs};var Qe=Gs;function hn(e,t,o){e.prototype=t.prototype=o,o.constructor=e}function Kr(e,t){var o=Object.create(e.prototype);for(var n in t)o[n]=t[n];return o}function To(){}var bo=.7,En=1/bo,Vt="\\s*([+-]?\\d+)\\s*",_o="\\s*([+-]?(?:\\d*\\.)?\\d+(?:[eE][+-]?\\d+)?)\\s*",Xe="\\s*([+-]?(?:\\d*\\.)?\\d+(?:[eE][+-]?\\d+)?)%\\s*",ap=/^#([0-9a-f]{3,8})$/,lp=new RegExp(`^rgb\\(${Vt},${Vt},${Vt}\\)$`),cp=new RegExp(`^rgb\\(${Xe},${Xe},${Xe}\\)$`),dp=new RegExp(`^rgba\\(${Vt},${Vt},${Vt},${_o}\\)$`),up=new RegExp(`^rgba\\(${Xe},${Xe},${Xe},${_o}\\)$`),pp=new RegExp(`^hsl\\(${_o},${Xe},${Xe}\\)$`),fp=new RegExp(`^hsla\\(${_o},${Xe},${Xe},${_o}\\)$`),Bs={aliceblue:15792383,antiquewhite:16444375,aqua:65535,aquamarine:8388564,azure:15794175,beige:16119260,bisque:16770244,black:0,blanchedalmond:16772045,blue:255,blueviolet:9055202,brown:10824234,burlywood:14596231,cadetblue:6266528,chartreuse:8388352,chocolate:13789470,coral:16744272,cornflowerblue:6591981,cornsilk:16775388,crimson:14423100,cyan:65535,darkblue:139,darkcyan:35723,darkgoldenrod:12092939,darkgray:11119017,darkgreen:25600,darkgrey:11119017,darkkhaki:12433259,darkmagenta:9109643,darkolivegreen:5597999,darkorange:16747520,darkorchid:10040012,darkred:9109504,darksalmon:15308410,darkseagreen:9419919,darkslateblue:4734347,darkslategray:3100495,darkslategrey:3100495,darkturquoise:52945,darkviolet:9699539,deeppink:16716947,deepskyblue:49151,dimgray:6908265,dimgrey:6908265,dodgerblue:2003199,firebrick:11674146,floralwhite:16775920,forestgreen:2263842,fuchsia:16711935,gainsboro:14474460,ghostwhite:16316671,gold:16766720,goldenrod:14329120,gray:8421504,green:32768,greenyellow:11403055,grey:8421504,honeydew:15794160,hotpink:16738740,indianred:13458524,indigo:4915330,ivory:16777200,khaki:15787660,lavender:15132410,lavenderblush:16773365,lawngreen:8190976,lemonchiffon:16775885,lightblue:11393254,lightcoral:15761536,lightcyan:14745599,lightgoldenrodyellow:16448210,lightgray:13882323,lightgreen:9498256,lightgrey:13882323,lightpink:16758465,lightsalmon:16752762,lightseagreen:2142890,lightskyblue:8900346,lightslategray:7833753,lightslategrey:7833753,lightsteelblue:11584734,lightyellow:16777184,lime:65280,limegreen:3329330,linen:16445670,magenta:16711935,maroon:8388608,mediumaquamarine:6737322,mediumblue:205,mediumorchid:12211667,mediumpurple:9662683,mediumseagreen:3978097,mediumslateblue:8087790,mediumspringgreen:64154,mediumturquoise:4772300,mediumvioletred:13047173,midnightblue:1644912,mintcream:16121850,mistyrose:16770273,moccasin:16770229,navajowhite:16768685,navy:128,oldlace:16643558,olive:8421376,olivedrab:7048739,orange:16753920,orangered:16729344,orchid:14315734,palegoldenrod:15657130,palegreen:10025880,paleturquoise:11529966,palevioletred:14381203,papayawhip:16773077,peachpuff:16767673,peru:13468991,pink:16761035,plum:14524637,powderblue:11591910,purple:8388736,rebeccapurple:6697881,red:16711680,rosybrown:12357519,royalblue:4286945,saddlebrown:9127187,salmon:16416882,sandybrown:16032864,seagreen:3050327,seashell:16774638,sienna:10506797,silver:12632256,skyblue:8900331,slateblue:6970061,slategray:7372944,slategrey:7372944,snow:16775930,springgreen:65407,steelblue:4620980,tan:13808780,teal:32896,thistle:14204888,tomato:16737095,turquoise:4251856,violet:15631086,wheat:16113331,white:16777215,whitesmoke:16119285,yellow:16776960,yellowgreen:10145074};hn(To,it,{copy(e){return Object.assign(new this.constructor,this,e)},displayable(){return this.rgb().displayable()},hex:zs,formatHex:zs,formatHex8:mp,formatHsl:gp,formatRgb:Fs,toString:Fs});function zs(){return this.rgb().formatHex()}function mp(){return this.rgb().formatHex8()}function gp(){return Ks(this).formatHsl()}function Fs(){return this.rgb().formatRgb()}function it(e){var t,o;return e=(e+"").trim().toLowerCase(),(t=ap.exec(e))?(o=t[1].length,t=parseInt(t[1],16),o===6?Ws(t):o===3?new Ce(t>>8&15|t>>4&240,t>>4&15|t&240,(t&15)<<4|t&15,1):o===8?yn(t>>24&255,t>>16&255,t>>8&255,(t&255)/255):o===4?yn(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=lp.exec(e))?new Ce(t[1],t[2],t[3],1):(t=cp.exec(e))?new Ce(t[1]*255/100,t[2]*255/100,t[3]*255/100,1):(t=dp.exec(e))?yn(t[1],t[2],t[3],t[4]):(t=up.exec(e))?yn(t[1]*255/100,t[2]*255/100,t[3]*255/100,t[4]):(t=pp.exec(e))?$s(t[1],t[2]/100,t[3]/100,1):(t=fp.exec(e))?$s(t[1],t[2]/100,t[3]/100,t[4]):Bs.hasOwnProperty(e)?Ws(Bs[e]):e==="transparent"?new Ce(NaN,NaN,NaN,0):null}function Ws(e){return new Ce(e>>16&255,e>>8&255,e&255,1)}function yn(e,t,o,n){return n<=0&&(e=t=o=NaN),new Ce(e,t,o,n)}function hp(e){return e instanceof To||(e=it(e)),e?(e=e.rgb(),new Ce(e.r,e.g,e.b,e.opacity)):new Ce}function Ht(e,t,o,n){return arguments.length===1?hp(e):new Ce(e,t,o,n==null?1:n)}function Ce(e,t,o,n){this.r=+e,this.g=+t,this.b=+o,this.opacity=+n}hn(Ce,Ht,Kr(To,{brighter(e){return e=e==null?En:Math.pow(En,e),new Ce(this.r*e,this.g*e,this.b*e,this.opacity)},darker(e){return e=e==null?bo:Math.pow(bo,e),new Ce(this.r*e,this.g*e,this.b*e,this.opacity)},rgb(){return this},clamp(){return new Ce(Tt(this.r),Tt(this.g),Tt(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:Ys,formatHex:Ys,formatHex8:yp,formatRgb:Us,toString:Us}));function Ys(){return`#${_t(this.r)}${_t(this.g)}${_t(this.b)}`}function yp(){return`#${_t(this.r)}${_t(this.g)}${_t(this.b)}${_t((isNaN(this.opacity)?1:this.opacity)*255)}`}function Us(){let e=bn(this.opacity);return`${e===1?"rgb(":"rgba("}${Tt(this.r)}, ${Tt(this.g)}, ${Tt(this.b)}${e===1?")":`, ${e})`}`}function bn(e){return isNaN(e)?1:Math.max(0,Math.min(1,e))}function Tt(e){return Math.max(0,Math.min(255,Math.round(e)||0))}function _t(e){return e=Tt(e),(e<16?"0":"")+e.toString(16)}function $s(e,t,o,n){return n<=0?e=t=o=NaN:o<=0||o>=1?e=t=NaN:t<=0&&(e=NaN),new We(e,t,o,n)}function Ks(e){if(e instanceof We)return new We(e.h,e.s,e.l,e.opacity);if(e instanceof To||(e=it(e)),!e)return new We;if(e instanceof We)return e;e=e.rgb();var t=e.r/255,o=e.g/255,n=e.b/255,r=Math.min(t,o,n),i=Math.max(t,o,n),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 We(a,s,l,e.opacity)}function qs(e,t,o,n){return arguments.length===1?Ks(e):new We(e,t,o,n==null?1:n)}function We(e,t,o,n){this.h=+e,this.s=+t,this.l=+o,this.opacity=+n}hn(We,qs,Kr(To,{brighter(e){return e=e==null?En:Math.pow(En,e),new We(this.h,this.s,this.l*e,this.opacity)},darker(e){return e=e==null?bo:Math.pow(bo,e),new We(this.h,this.s,this.l*e,this.opacity)},rgb(){var e=this.h%360+(this.h<0)*360,t=isNaN(e)||isNaN(this.s)?0:this.s,o=this.l,n=o+(o<.5?o:1-o)*t,r=2*o-n;return new Ce(qr(e>=240?e-240:e+120,r,n),qr(e,r,n),qr(e<120?e+240:e-120,r,n),this.opacity)},clamp(){return new We(Xs(this.h),xn(this.s),xn(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("}${Xs(this.h)}, ${xn(this.s)*100}%, ${xn(this.l)*100}%${e===1?")":`, ${e})`}`}}));function Xs(e){return e=(e||0)%360,e<0?e+360:e}function xn(e){return Math.max(0,Math.min(1,e||0))}function qr(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 Zr(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 Zs(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 Zr((o-n/t)*t,a,r,i,s)}}function Js(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 Zr((o-n/t)*t,r,i,a,s)}}var Jr=e=>()=>e;function xp(e,t){return function(o){return e+o*t}}function Ep(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 Qs(e){return(e=+e)==1?_n:function(t,o){return o-t?Ep(t,o,e):Jr(isNaN(t)?o:t)}}function _n(e,t){var o=t-e;return o?xp(e,o):Jr(isNaN(e)?t:e)}var Tn=function e(t){var o=Qs(t);function n(r,i){var a=o((r=Ht(r)).r,(i=Ht(i)).r),s=o(r.g,i.g),l=o(r.b,i.b),c=_n(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 js(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=Ht(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 bp=js(Zs),_p=js(Js);function Re(e,t){return e=+e,t=+t,function(o){return e*(1-o)+t*o}}var jr=/[-+]?(?:\d+\.?\d*|\.?\d+)(?:[eE][-+]?\d+)?/g,Qr=new RegExp(jr.source,"g");function Tp(e){return function(){return e}}function Np(e){return function(t){return e(t)+""}}function ei(e,t){var o=jr.lastIndex=Qr.lastIndex=0,n,r,i,a=-1,s=[],l=[];for(e=e+"",t=t+"";(n=jr.exec(e))&&(r=Qr.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:Re(n,r)})),o=Qr.lastIndex;return o<t.length&&(i=t.slice(o),s[a]?s[a]+=i:s[++a]=i),s.length<2?l[0]?Np(l[0].x):Tp(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 ea=180/Math.PI,Nn={translateX:0,translateY:0,rotate:0,skewX:0,scaleX:1,scaleY:1};function ti(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)*ea,skewX:Math.atan(l)*ea,scaleX:a,scaleY:s}}var vn;function ta(e){let t=new(typeof DOMMatrix=="function"?DOMMatrix:WebKitCSSMatrix)(e+"");return t.isIdentity?Nn:ti(t.a,t.b,t.c,t.d,t.e,t.f)}function oa(e){return e==null?Nn:(vn||(vn=document.createElementNS("http://www.w3.org/2000/svg","g")),vn.setAttribute("transform",e),(e=vn.transform.baseVal.consolidate())?(e=e.matrix,ti(e.a,e.b,e.c,e.d,e.e,e.f)):Nn)}function na(e,t,o,n){function r(c){return c.length?c.pop()+" ":""}function i(c,d,u,p,f,h){if(c!==u||d!==p){var g=f.push("translate(",null,t,null,o);h.push({i:g-4,x:Re(c,u)},{i:g-2,x:Re(d,p)})}else(u||p)&&f.push("translate("+u+t+p+o)}function a(c,d,u,p){c!==d?(c-d>180?d+=360:d-c>180&&(c+=360),p.push({i:u.push(r(u)+"rotate(",null,n)-2,x:Re(c,d)})):d&&u.push(r(u)+"rotate("+d+n)}function s(c,d,u,p){c!==d?p.push({i:u.push(r(u)+"skewX(",null,n)-2,x:Re(c,d)}):d&&u.push(r(u)+"skewX("+d+n)}function l(c,d,u,p,f,h){if(c!==u||d!==p){var g=f.push(r(f)+"scale(",null,",",null,")");h.push({i:g-4,x:Re(c,u)},{i:g-2,x:Re(d,p)})}else(u!==1||p!==1)&&f.push(r(f)+"scale("+u+","+p+")")}return function(c,d){var u=[],p=[];return c=e(c),d=e(d),i(c.translateX,c.translateY,d.translateX,d.translateY,u,p),a(c.rotate,d.rotate,u,p),s(c.skewX,d.skewX,u,p),l(c.scaleX,c.scaleY,d.scaleX,d.scaleY,u,p),c=d=null,function(f){for(var h=-1,g=p.length,m;++h<g;)u[(m=p[h]).i]=m.x(f);return u.join("")}}}var oi=na(ta,"px, ","px)","deg)"),ni=na(oa,", ",")",")");var Gt=0,vo=0,No=0,ia=1e3,wn,wo,In=0,Nt=0,An=0,Io=typeof performance=="object"&&performance.now?performance:Date,sa=typeof window=="object"&&window.requestAnimationFrame?window.requestAnimationFrame.bind(window):function(e){setTimeout(e,17)};function Co(){return Nt||(sa(vp),Nt=Io.now()+An)}function vp(){Nt=0}function Ao(){this._call=this._time=this._next=null}Ao.prototype=Cn.prototype={constructor:Ao,restart:function(e,t,o){if(typeof e!="function")throw new TypeError("callback is not a function");o=(o==null?Co():+o)+(t==null?0:+t),!this._next&&wo!==this&&(wo?wo._next=this:wn=this,wo=this),this._call=e,this._time=o,ri()},stop:function(){this._call&&(this._call=null,this._time=1/0,ri())}};function Cn(e,t,o){var n=new Ao;return n.restart(e,t,o),n}function aa(){Co(),++Gt;for(var e=wn,t;e;)(t=Nt-e._time)>=0&&e._call.call(void 0,t),e=e._next;--Gt}function ra(){Nt=(In=Io.now())+An,Gt=vo=0;try{aa()}finally{Gt=0,Ip(),Nt=0}}function wp(){var e=Io.now(),t=e-In;t>ia&&(An-=t,In=e)}function Ip(){for(var e,t=wn,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:wn=o);wo=e,ri(n)}function ri(e){if(!Gt){vo&&(vo=clearTimeout(vo));var t=e-Nt;t>24?(e<1/0&&(vo=setTimeout(ra,e-Io.now()-An)),No&&(No=clearInterval(No))):(No||(In=Io.now(),No=setInterval(wp,ia)),Gt=1,sa(ra))}}function Sn(e,t,o){var n=new Ao;return t=t==null?0:+t,n.restart(r=>{n.stop(),e(r+t)},t,o),n}var Ap=Yr("start","end","cancel","interrupt"),Cp=[],da=0,la=1,Pn=2,Mn=3,ca=4,Ln=5,So=6;function st(e,t,o,n,r,i){var a=e.__transition;if(!a)e.__transition={};else if(o in a)return;Sp(e,o,{name:t,index:n,group:r,on:Ap,tween:Cp,time:i.time,delay:i.delay,duration:i.duration,ease:i.ease,timer:null,state:da})}function Mo(e,t){var o=he(e,t);if(o.state>da)throw new Error("too late; already scheduled");return o}function _e(e,t){var o=he(e,t);if(o.state>Mn)throw new Error("too late; already running");return o}function he(e,t){var o=e.__transition;if(!o||!(o=o[t]))throw new Error("transition not found");return o}function Sp(e,t,o){var n=e.__transition,r;n[t]=o,o.timer=Cn(i,0,o.time);function i(c){o.state=la,o.timer.restart(a,o.delay,o.time),o.delay<=c&&a(c-o.delay)}function a(c){var d,u,p,f;if(o.state!==la)return l();for(d in n)if(f=n[d],f.name===o.name){if(f.state===Mn)return Sn(a);f.state===ca?(f.state=So,f.timer.stop(),f.on.call("interrupt",e,e.__data__,f.index,f.group),delete n[d]):+d<t&&(f.state=So,f.timer.stop(),f.on.call("cancel",e,e.__data__,f.index,f.group),delete n[d])}if(Sn(function(){o.state===Mn&&(o.state=ca,o.timer.restart(s,o.delay,o.time),s(c))}),o.state=Pn,o.on.call("start",e,e.__data__,o.index,o.group),o.state===Pn){for(o.state=Mn,r=new Array(p=o.tween.length),d=0,u=-1;d<p;++d)(f=o.tween[d].value.call(e,e.__data__,o.index,o.group))&&(r[++u]=f);r.length=u+1}}function s(c){for(var d=c<o.duration?o.ease.call(null,c/o.duration):(o.timer.restart(l),o.state=Ln,1),u=-1,p=r.length;++u<p;)r[u].call(e,d);o.state===Ln&&(o.on.call("end",e,e.__data__,o.index,o.group),l())}function l(){o.state=So,o.timer.stop(),delete n[t];for(var c in n)return;delete e.__transition}}function ii(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>Pn&&n.state<Ln,n.state=So,n.timer.stop(),n.on.call(r?"interrupt":"cancel",e,e.__data__,n.index,n.group),delete o[a]}i&&delete e.__transition}}function ua(e){return this.each(function(){ii(this,e)})}function Mp(e,t){var o,n;return function(){var r=_e(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 Pp(e,t,o){var n,r;if(typeof o!="function")throw new Error;return function(){var i=_e(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 pa(e,t){var o=this._id;if(e+="",arguments.length<2){for(var n=he(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?Mp:Pp)(o,e,t))}function Bt(e,t,o){var n=e._id;return e.each(function(){var r=_e(this,n);(r.value||(r.value={}))[t]=o.apply(this,arguments)}),function(r){return he(r,n).value[t]}}function kn(e,t){var o;return(typeof t=="number"?Re:t instanceof it?Tn:(o=it(t))?(t=o,Tn):ei)(e,t)}function Lp(e){return function(){this.removeAttribute(e)}}function kp(e){return function(){this.removeAttributeNS(e.space,e.local)}}function Dp(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 Rp(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 Op(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 Vp(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 fa(e,t){var o=Je(e),n=o==="transform"?ni:kn;return this.attrTween(e,typeof t=="function"?(o.local?Vp:Op)(o,n,Bt(this,"attr."+e,t)):t==null?(o.local?kp:Lp)(o):(o.local?Rp:Dp)(o,n,t))}function Hp(e,t){return function(o){this.setAttribute(e,t.call(this,o))}}function Gp(e,t){return function(o){this.setAttributeNS(e.space,e.local,t.call(this,o))}}function Bp(e,t){var o,n;function r(){var i=t.apply(this,arguments);return i!==n&&(o=(n=i)&&Gp(e,i)),o}return r._value=t,r}function zp(e,t){var o,n;function r(){var i=t.apply(this,arguments);return i!==n&&(o=(n=i)&&Hp(e,i)),o}return r._value=t,r}function ma(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=Je(e);return this.tween(o,(n.local?Bp:zp)(n,t))}function Fp(e,t){return function(){Mo(this,e).delay=+t.apply(this,arguments)}}function Wp(e,t){return t=+t,function(){Mo(this,e).delay=t}}function ga(e){var t=this._id;return arguments.length?this.each((typeof e=="function"?Fp:Wp)(t,e)):he(this.node(),t).delay}function Yp(e,t){return function(){_e(this,e).duration=+t.apply(this,arguments)}}function Up(e,t){return t=+t,function(){_e(this,e).duration=t}}function ha(e){var t=this._id;return arguments.length?this.each((typeof e=="function"?Yp:Up)(t,e)):he(this.node(),t).duration}function $p(e,t){if(typeof t!="function")throw new Error;return function(){_e(this,e).ease=t}}function ya(e){var t=this._id;return arguments.length?this.each($p(t,e)):he(this.node(),t).ease}function Xp(e,t){return function(){var o=t.apply(this,arguments);if(typeof o!="function")throw new Error;_e(this,e).ease=o}}function xa(e){if(typeof e!="function")throw new Error;return this.each(Xp(this._id,e))}function Ea(e){typeof e!="function"&&(e=xo(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 we(n,this._parents,this._name,this._id)}function ba(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),p,f=0;f<d;++f)(p=l[f]||c[f])&&(u[f]=p);for(;s<n;++s)a[s]=t[s];return new we(a,this._parents,this._name,this._id)}function Kp(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 qp(e,t,o){var n,r,i=Kp(t)?Mo:_e;return function(){var a=i(this,e),s=a.on;s!==n&&(r=(n=s).copy()).on(t,o),a.on=r}}function _a(e,t){var o=this._id;return arguments.length<2?he(this.node(),o).on.on(e):this.each(qp(o,e,t))}function Zp(e){return function(){var t=this.parentNode;for(var o in this.__transition)if(+o!==e)return;t&&t.removeChild(this)}}function Ta(){return this.on("end.remove",Zp(this._id))}function Na(e){var t=this._name,o=this._id;typeof e!="function"&&(e=bt(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,p=0;p<l;++p)(d=s[p])&&(u=e.call(d,d.__data__,p,s))&&("__data__"in d&&(u.__data__=d.__data__),c[p]=u,st(c[p],t,o,p,c,he(d,o)));return new we(i,this._parents,t,o)}function va(e){var t=this._name,o=this._id;typeof e!="function"&&(e=yo(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 p=e.call(d,d.__data__,u,l),f,h=he(d,o),g=0,m=p.length;g<m;++g)(f=p[g])&&st(f,t,o,g,p,h);i.push(p),a.push(d)}return new we(i,a,t,o)}var Jp=Qe.prototype.constructor;function wa(){return new Jp(this._groups,this._parents)}function Qp(e,t){var o,n,r;return function(){var i=rt(this,e),a=(this.style.removeProperty(e),rt(this,e));return i===a?null:i===o&&a===n?r:r=t(o=i,n=a)}}function Ia(e){return function(){this.style.removeProperty(e)}}function jp(e,t,o){var n,r=o+"",i;return function(){var a=rt(this,e);return a===r?null:a===n?i:i=t(n=a,o)}}function ef(e,t,o){var n,r,i;return function(){var a=rt(this,e),s=o(this),l=s+"";return s==null&&(l=s=(this.style.removeProperty(e),rt(this,e))),a===l?null:a===n&&l===r?i:(r=l,i=t(n=a,s))}}function tf(e,t){var o,n,r,i="style."+t,a="end."+i,s;return function(){var l=_e(this,e),c=l.on,d=l.value[i]==null?s||(s=Ia(t)):void 0;(c!==o||r!==d)&&(n=(o=c).copy()).on(a,r=d),l.on=n}}function Aa(e,t,o){var n=(e+="")=="transform"?oi:kn;return t==null?this.styleTween(e,Qp(e,n)).on("end.style."+e,Ia(e)):typeof t=="function"?this.styleTween(e,ef(e,n,Bt(this,"style."+e,t))).each(tf(this._id,e)):this.styleTween(e,jp(e,n,t),o).on("end.style."+e,null)}function of(e,t,o){return function(n){this.style.setProperty(e,t.call(this,n),o)}}function nf(e,t,o){var n,r;function i(){var a=t.apply(this,arguments);return a!==r&&(n=(r=a)&&of(e,a,o)),n}return i._value=t,i}function Ca(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,nf(e,t,o==null?"":o))}function rf(e){return function(){this.textContent=e}}function sf(e){return function(){var t=e(this);this.textContent=t==null?"":t}}function Sa(e){return this.tween("text",typeof e=="function"?sf(Bt(this,"text",e)):rf(e==null?"":e+""))}function af(e){return function(t){this.textContent=e.call(this,t)}}function lf(e){var t,o;function n(){var r=e.apply(this,arguments);return r!==o&&(t=(o=r)&&af(r)),t}return n._value=e,n}function Ma(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,lf(e))}function Pa(){for(var e=this._name,t=this._id,o=Dn(),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=he(l,t);st(l,e,o,c,a,{time:d.time+d.delay+d.duration,delay:0,duration:d.duration,ease:d.ease})}return new we(n,this._parents,e,o)}function La(){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=_e(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 cf=0;function we(e,t,o,n){this._groups=e,this._parents=t,this._name=o,this._id=n}function ka(e){return Qe().transition(e)}function Dn(){return++cf}var je=Qe.prototype;we.prototype=ka.prototype={constructor:we,select:Na,selectAll:va,selectChild:je.selectChild,selectChildren:je.selectChildren,filter:Ea,merge:ba,selection:wa,transition:Pa,call:je.call,nodes:je.nodes,node:je.node,size:je.size,empty:je.empty,each:je.each,on:_a,attr:fa,attrTween:ma,style:Aa,styleTween:Ca,text:Sa,textTween:Ma,remove:Ta,tween:pa,delay:ga,duration:ha,ease:ya,easeVarying:xa,end:La,[Symbol.iterator]:je[Symbol.iterator]};function Rn(e){return((e*=2)<=1?e*e*e:(e-=2)*e*e+2)/2}var df={time:null,delay:0,duration:250,ease:Rn};function uf(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 Da(e){var t,o;e instanceof we?(t=e._id,e=e._name):(t=Dn(),(o=df).time=Co(),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])&&st(l,e,t,c,a,o||uf(l,t));return new we(n,this._parents,e,t)}Qe.prototype.interrupt=ua;Qe.prototype.transition=Da;function at(e,t,o){this.k=e,this.x=t,this.y=o}at.prototype={constructor:at,scale:function(e){return e===1?this:new at(this.k*e,this.x,this.y)},translate:function(e,t){return e===0&t===0?this:new at(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 On=new at(1,0,0);Vn.prototype=at.prototype;function Vn(e){for(;!e.__zoom;)if(!(e=e.parentNode))return On;return e.__zoom}var ff=[[Number.NEGATIVE_INFINITY,Number.NEGATIVE_INFINITY],[Number.POSITIVE_INFINITY,Number.POSITIVE_INFINITY]];var Ra;(function(e){e.Strict="strict",e.Loose="loose"})(Ra||(Ra={}));var Oa;(function(e){e.Free="free",e.Vertical="vertical",e.Horizontal="horizontal"})(Oa||(Oa={}));var Va;(function(e){e.Partial="partial",e.Full="full"})(Va||(Va={}));var Ha;(function(e){e.Bezier="default",e.Straight="straight",e.Step="step",e.SmoothStep="smoothstep",e.SimpleBezier="simplebezier"})(Ha||(Ha={}));var Ga;(function(e){e.Arrow="arrow",e.ArrowClosed="arrowclosed"})(Ga||(Ga={}));var Se;(function(e){e.Left="left",e.Top="top",e.Right="right",e.Bottom="bottom"})(Se||(Se={}));var gN={[Se.Left]:Se.Right,[Se.Right]:Se.Left,[Se.Top]:Se.Bottom,[Se.Bottom]:Se.Top};var mf=e=>"id"in e&&"internals"in e&&!("source"in e)&&!("target"in e);var gf=(e,t=[0,0])=>{var s;let{width:o,height:n}=hf(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 Le=(e,t=[0,0])=>{var r,i,a,s,l,c,d,u;let{x:o,y:n}=mf(e)?e.internals.positionAbsolute:gf(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 hf(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 hN={[Se.Left]:{x:-1,y:0},[Se.Right]:{x:1,y:0},[Se.Top]:{x:0,y:-1},[Se.Bottom]:{x:0,y:1}};var yf={nodeOrigin:[0,0],nodeExtent:ff,elevateNodesOnSelect:!0,defaults:{}},yN=v(E({},yf),{checkEquality:!0});var Ba;(function(e){e.Line="line",e.Handle="handle"})(Ba||(Ba={}));var xf={width:0,height:0,x:0,y:0},xN=v(E({},xf),{pointerX:0,pointerY:0,aspectRatio:1});import{useCallback as Po,useEffect as wf,useRef as If,useState as Ya}from"react";import{shallow as Af}from"zustand/shallow";var Ef=(e,t)=>e.x<t.x2&&e.x2>t.x&&e.y<t.y2&&e.y2>t.y;function bf(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 _f(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 Hn=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){let i=t==="horizontal"?this.yLines:this.xLines,[a,s]=t==="horizontal"?[r.y,r.y2]:[r.x,r.x2],l=[];for(let p of i){if(p.position<a)continue;if(p.position>s)break;if(p.node.id===n.id||p.node.parentId===n.id||!Ef(p.nodeBox,r))continue;let f=Math.abs(p.position-o);if(f>Gn)continue;let g=bf(p.nodeBox,Le(n))>0?0:_f(p.nodeBox,Le(n));l.push({line:p,lineDist:f,nodeDist:g})}let c=.5,d=t==="horizontal"?this.lastHorizontalLine:this.lastVerticalLine;l.sort((p,f)=>{if(d){if(p.line===d&&f.line!==d)return-1;if(f.line===d&&p.line!==d)return 1}return Math.abs(p.lineDist-f.lineDist)<=c?p.nodeDist-f.nodeDist:p.lineDist-f.lineDist});let u=l.length>0?l[0].line:void 0;return u&&(t==="horizontal"?this.lastHorizontalLine=u:this.lastVerticalLine=u),u}};function za(e,t=vt,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=Le(i);Object.entries(t).forEach(([s,l])=>{var c;n.push({nodeBox:a,node:r,orientation:l.orientation,position:l.resolve(r,a),color:(c=r.style)==null?void 0:c.backgroundColor,anchorName:s})})}),n}function Fa(e,t,o,n,r=Object.keys(vt)){let i=[];for(let s of r){let l=vt[s],c=l.resolve(o,n),d=e.search(l.orientation,c,o,t);d&&i.push({anchorName:s,sourcePosition:c,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 Wa(e,t,o,n,r,i,a,s){var u,p,f,h,g,m,x,y;if(!(o!=null&&o.position))return{snappedX:!1,snappedY:!1};let l=!1,c=!1,d={x:o.position.x,y:o.position.y,x2:o.position.x+((p=(u=e.measured)==null?void 0:u.width)!=null?p:0),y2:o.position.y+((h=(f=e.measured)==null?void 0:f.height)!=null?h:0)};if(a){let N=a.anchor.resolve(e,d)-a.line.position;if(Math.abs(N)<=Gn){if(o.position.y-=N,r!=null&&r.dimensions)if(n){let T=t.internals.positionAbsolute.y+((m=(g=e.measured)==null?void 0:g.height)!=null?m:0);r.dimensions.height=T-a.line.position}else r.dimensions.height=a.line.position-t.internals.positionAbsolute.y;c=!0}}if(s){let N=s.anchor.resolve(e,d)-s.line.position;if(Math.abs(N)<=Gn){if(o.position.x-=N,r!=null&&r.dimensions)if(n){let T=t.internals.positionAbsolute.x+((y=(x=e.measured)==null?void 0:x.width)!=null?y:0);r.dimensions.width=T-s.line.position}else r.dimensions.width=s.line.position-t.internals.positionAbsolute.x;l=!0}}return i&&(l||c)&&(o.position.x-=i.position.x,o.position.y-=i.position.y),{snappedX:l,snappedY:c}}var Gn=10,vt={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 Sf}from"react/jsx-runtime";var Cf=new Hn;function Bn(){let[e,t]=Ya(void 0),[o,n]=Ya(void 0),{width:r,height:i}=vf(m=>({width:m.width,height:m.height}),Af),a=Tf(),s=If(Cf),{screenToFlowPosition:l,getInternalNode:c,getNodes:d}=Nf(),u=Po(()=>{t(void 0),n(void 0)},[]),p=Po(m=>{let x=m!=null?m:d();u();let y=za(x,vt,c);s.current.initialize(y)},[c,u,d]),f=Po(()=>{setTimeout(()=>{p()},100)},[p]);wf(()=>{a&&p(d())},[a,p,d]);let h=Po((m,x)=>{var te,S,O,Y,G;if(!s.current||m.length===0||m.length>2)return m;u();let y,b,N=Object.keys(vt);m.length===1?m[0].type==="position"?y=m[0]:m[0].type==="dimensions"&&(b=m[0],N=["right","bottom"]):m[0].type==="position"&&m[1].type==="dimensions"&&m[1].dimensions&&(y=m[0],b=m[1],N=["top","left"]);let T=x.find(X=>X.id===m[0].id);if(!T)return m;let _=c(T.id);if(!_)throw new Error(`Node with id ${T.id} not found in internal nodes`);let w=c((te=_.parentId)!=null?te:""),P=Le(_);b!=null&&b.dimensions&&(P.x2=P.x+b.dimensions.width,P.y2=P.y+b.dimensions.height);let{x:H,y:C}=l({x:0,y:0}),{x:I,y:L}=l({x:r,y:i}),B={x:H,y:C,x2:I,y2:L},{horizontal:M,vertical:A}=Fa(s.current,B,T,P,N),D={id:T.id,type:"position",position:{x:_.internals.positionAbsolute.x,y:_.internals.positionAbsolute.y},dragging:!1};y!=null&&y.position&&D.position&&(w?(D.position.x=y.position.x+((O=(S=w==null?void 0:w.position)==null?void 0:S.x)!=null?O:0),D.position.y=y.position.y+((G=(Y=w==null?void 0:w.position)==null?void 0:Y.y)!=null?G:0)):(D.position.x=y.position.x,D.position.y=y.position.y));let{snappedX:U,snappedY:F}=Wa(T,_,D,y,b,w,M,A);if(U||F){if((b!=null&&b.resizing||y!=null&&y.dragging)&&(U&&n(A==null?void 0:A.line),F&&t(M==null?void 0:M.line)),b&&y)return[D,b];if(y)return[D];if(b)return[b]}return m},[l,c,r,i,t,n,u]),g=Po(()=>Sf(Ua,{horizontal:e,vertical:o}),[e,o]);return{rebuildIndex:p,forceRebuildIndex:f,updateHelperLines:h,helperLineHorizontal:e,helperLineVertical:o,HelperLines:g}}import{reconnectEdge as _h,useReactFlow as Th}from"@xyflow/react";import{useCallback as St,useRef as Nh}from"react";var zt=e=>new Map(e.map(t=>[t.id,t])),Lo=(e,t,o)=>t.filter(n=>!(n.source!==e||o&&n.id===o)),$a=(e,t,o)=>t.filter(n=>!(n.target!==e||o&&n.id===o)),zn=e=>e.some(t=>t.type==="START_EVENT"),Xa=(e,t,o,n,r)=>{let i=zt(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:Lo(e,n,r).filter(c=>{let d=i.get(c.target);return(d==null?void 0:d.type)!=="ANNOTATION"}).length>=1},Ka=(e,t,o,n,r)=>{let i=zt(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:$a(t,n,r).filter(c=>{let d=i.get(c.source);return(d==null?void 0:d.type)!=="ANNOTATION"}).length>=1},Fn=(e,t,o,n)=>{var a;let r=t.find(s=>s.id===e);return!r||r.type!=="GATEWAY"||((a=r.data)==null?void 0:a.variant)!=="EXCLUSIVE"?!1:Lo(e,o,n).length>=2},qa=(e,t,o)=>{var a,s,l,c;let n=zt(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"},Wn=(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"},Yn=(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"},Un=(e,t,o,n)=>{let r=zt(t),i=r.get(e);return!i||i.type!=="TASK"?!1:$a(e,o,n).some(s=>{let l=r.get(s.source);return(l==null?void 0:l.type)==="START_EVENT"})},$n=(e,t,o,n)=>{let r=zt(t),i=r.get(e);return!i||i.type!=="TASK"?!1:Lo(e,o,n).some(s=>{let l=r.get(s.target);return(l==null?void 0:l.type)==="END_EVENT"})},Xn=(e,t,o)=>Lo(e,t,o).length>0,Kn=(e,t,o,n,r)=>{let i=zt(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:Lo(e,n,r).filter(c=>{let d=i.get(c.target);return(d==null?void 0:d.type)!=="ANNOTATION"}).length>=2};var Mf=[e=>({isValid:e.sourceNodeId!==e.targetNodeId,reason:"self_connection_not_allowed"}),e=>({isValid:!Xa(e.sourceNodeId,e.targetNodeId,e.nodes,e.edges,e.reconnectingEdgeId),reason:"start_event_limit_reached"}),e=>({isValid:!Ka(e.sourceNodeId,e.targetNodeId,e.nodes,e.edges,e.reconnectingEdgeId),reason:"end_event_limit_reached"}),e=>({isValid:!Fn(e.sourceNodeId,e.nodes,e.edges,e.reconnectingEdgeId),reason:"gateway_limit_reached"}),e=>({isValid:!Kn(e.sourceNodeId,e.targetNodeId,e.nodes,e.edges,e.reconnectingEdgeId),reason:"task_limit_reached"}),e=>({isValid:qa(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==="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:!(Wn(e.sourceNodeId,e.nodes)&&e.targetNodeType==="END_EVENT"),reason:"script_to_end_not_allowed"}),e=>({isValid:!(Yn(e.sourceNodeId,e.nodes)&&e.targetNodeType==="END_EVENT"),reason:"loop_to_end_not_allowed"}),e=>({isValid:!(Un(e.sourceNodeId,e.nodes,e.edges,e.reconnectingEdgeId)&&e.targetNodeType==="END_EVENT"),reason:"initial_activity_to_end_not_allowed"}),e=>({isValid:!($n(e.sourceNodeId,e.nodes,e.edges,e.reconnectingEdgeId)&&e.targetNodeType!=="ANNOTATION"),reason:"final_activity_cannot_connect"}),e=>({isValid:!(Xn(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:[],UNSUPPORTED:[]}[e.sourceNodeType]||[]).includes(e.targetNodeType),reason:"connection_type_not_allowed"})],si=e=>{for(let t of Mf){let o=t(e);if(!o.isValid)return o}return{isValid:!0}};var Pf=[{sourceTypes:["GATEWAY"],targetTypes:["TASK","GATEWAY"],validate:e=>({shouldDisable:Fn(e.sourceNodeId,e.nodes,e.edges),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:zn(e.nodes),reason:"start_event_already_exists"})},{sourceTypes:["TASK"],targetTypes:["END_EVENT"],validate:e=>({shouldDisable:Wn(e.sourceNodeId,e.nodes),reason:"script_to_end_not_allowed"})},{sourceTypes:["TASK"],targetTypes:["END_EVENT"],validate:e=>({shouldDisable:Yn(e.sourceNodeId,e.nodes),reason:"loop_to_end_not_allowed"})},{sourceTypes:["TASK"],targetTypes:["END_EVENT"],validate:e=>({shouldDisable:Un(e.sourceNodeId,e.nodes,e.edges),reason:"initial_activity_to_end_not_allowed"})},{sourceTypes:["TASK"],validate:e=>({shouldDisable:$n(e.sourceNodeId,e.nodes,e.edges)&&e.targetNodeType!=="ANNOTATION",reason:"final_activity_cannot_connect"})},{targetTypes:["END_EVENT"],validate:e=>({shouldDisable:Xn(e.sourceNodeId,e.edges),reason:"activity_has_outgoing_connections"})},{sourceTypes:["TASK"],validate:e=>({shouldDisable:Kn(e.sourceNodeId,null,e.nodes,e.edges)&&e.targetNodeType!=="ANNOTATION",reason:"task_limit_reached"})}],Za=e=>{let t=Pf.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 nm,EdgeLabelRenderer as rm,getStraightPath as im,useInternalNode as ja,useViewport as sm}from"@xyflow/react";import{Position as ko}from"@xyflow/react";function Ja(e,t){var b,N,T,_;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+((N=(b=t==null?void 0:t.measured)==null?void 0:b.width)!=null?N:0)/2,u=i.y+((_=(T=t==null?void 0:t.measured)==null?void 0:T.height)!=null?_:0)/2,p=(d-l)/(2*a)-(u-c)/(2*s),f=(d-l)/(2*a)+(u-c)/(2*s),h=1/(Math.abs(p)+Math.abs(f)||1),g=h*p,m=h*f,x=a*(g+m)+l,y=s*(-g+m)+c;return{x,y}}function Qa(e,t){var c,d,u,p;let{positionAbsolute:o}=e.internals,n=(d=(c=e.measured)==null?void 0:c.width)!=null?d:0,r=(p=(u=e.measured)==null?void 0:u.height)!=null?p:0,i=Math.round(o.x),a=Math.round(o.y),s=Math.round(t.x),l=Math.round(t.y);return s<=i+1?ko.Left:s>=i+n-1?ko.Right:l<=a+1?ko.Top:l>=a+r-1?ko.Bottom:ko.Top}function lt(e,t){let o=Ja(e,t),n=Ja(t,e),r=Qa(e,o),i=Qa(t,n);return{sx:o.x,sy:o.y,tx:n.x,ty:n.y,sourcePos:r,targetPos:i}}import{Button as Df,Tooltip as Rf,TooltipContent as Of,TooltipTrigger as Vf,useTranslation as Hf}from"lecom-ui";import{Settings as Gf}from"lucide-react";import{getIncomers as qn,getOutgoers as Zn,useReactFlow as kf}from"@xyflow/react";import{useStoreApi as Lf}from"@xyflow/react";var ct=()=>{let e=Lf();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 Jn=()=>{let{getNode:e,getEdge:t,getNodes:o,getEdges:n}=kf(),{selectElements:r}=ct(),i=m=>{let x=o(),y=n(),b=qn(m,x,y),N=Zn(m,x,y),T=b.some(w=>w.type==="START_EVENT"),_=N.some(w=>w.type==="END_EVENT");return T?"start":_?"end":"between"},a=(m,x,y)=>{var T,_,w,P;if(!m)return;let b={type:m.type,variant:(T=m.data)==null?void 0:T.variant,attribute:(_=m.data)==null?void 0:_.attribute},N={id:m.id,position:i(m),label:(w=m.data)==null?void 0:w.label,node:b};return m.type==="TASK"&&((P=m.data)==null?void 0:P.variant)==="SUBPROCESS"?v(E({},N),{type:"sub_process"}):m.type==="GATEWAY"?v(E({},N),{type:"gateway",variant:s(m,x,y)}):v(E({},N),{type:"activity"})},s=(m,x,y)=>{if(m.type!=="GATEWAY")return;let b=qn(m,x,y),N=!1,T=!1;if(b.forEach(_=>{var w,P;_.type==="TASK"&&(((w=_.data)==null?void 0:w.variant)==="SCRIPT"&&(N=!0),((P=_.data)==null?void 0:P.attribute)==="LOOP"&&(T=!0))}),N&&T)return"script_loop";if(N)return"script";if(T)return"loop"},l=(m,x,y)=>{var w,P,H,C;let b=e(m.source),N=e(m.target);if(!b||!N)return"simple";if(Zn(b,x,y).some(I=>I.type==="END_EVENT"))return"final";if(b.type==="GATEWAY")switch((w=b.data)==null?void 0:w.variant){case"PARALLEL":return"parallel";case"EXCLUSIVE":return"exclusive";case"COMPLEX":return"complex";default:return"simple"}if(b.type==="TASK"){let I=(P=b.data)==null?void 0:P.variant,L=(H=b.data)==null?void 0:H.attribute;if(N.type==="TASK"&&((C=N.data)==null?void 0:C.variant)==="SUBPROCESS")return"to_sub_process";let B=I==="SCRIPT",M=L==="LOOP";return B&&M?"script_loop":B?"script":M?"loop":"simple"}return"simple"},c=(m,x,y)=>{let b=[];function N(_,w,P=0){let H=a(_,x,y);if(H.depth=P,w.push(H),_.type==="TASK"){b.push([...w]),w.pop();return}let C=qn(_,x,y);if(C.length)for(let I of C)N(I,w,P+1);w.pop()}let T=qn(m,x,y);for(let _ of T)N(_,[]);return b},d=(m,x,y)=>{let b=[];function N(_,w,P=0){let H=a(_,x,y);if(H.depth=P,w.push(H),_.type==="TASK"){b.push([...w]),w.pop();return}let C=Zn(_,x,y);if(C.length)for(let I of C)N(I,w,P+1);w.pop()}let T=Zn(m,x,y);for(let _ of T)N(_,[]);return b},u=(m,x,y)=>(y=y.filter(N=>N.source===m.id),y.map(N=>{var w;let T=e(N.target),_;return T&&(_=a(T,x,y)),{id:N.id,type:"routing",variant:l(N,x,y),label:(w=N.data)==null?void 0:w.label,target:_}})),p=m=>{let x=e(m);if(!x)return;let y=o(),b=n(),N=a(x,y,b);return N.sources=c(x,y,b),N.targets=d(x,y,b),N.edgeTargets=u(x,y,b),x.type==="GATEWAY"&&(N.variant=s(x,y,b)),N},f=m=>{let x=t(m);if(!x)return;let y=o(),b=n(),N=l(x,y,b),_={id:x.id,type:"routing",variant:N,gatewayVariant:void 0},w=e(x.source);if(w){let H=a(w,y,b),C=c(w,y,b),I=s(w,y,b);_.source=H,_.sources=C.length?C:[[H]],_.gatewayVariant=I}let P=e(x.target);if(P){let H=a(P,y,b),C=d(P,y,b);_.target=H,_.targets=C.length?C:[[H]]}return _},h=m=>{let x=e(m);if(x)return p(x.id);let y=t(m);if(y)return f(y.id)};return{configureElement:m=>{let x=h(m);if(x)return r([m]),x},getConfigureElement:h,getNodeConfigure:p,getEdgeConfigure:f}};import{jsx as Qn,jsxs as Bf}from"react/jsx-runtime";var dt=({elementId:e,elementType:t="node"})=>{let{t:o}=Hf(),{onConfigureElement:n}=W(),{getConfigureElement:r}=Jn();return Bf(Rf,{children:[Qn(Vf,{asChild:!0,children:Qn(Df,{variant:"ghost",color:"grey",size:"small",iconButton:!0,onClick:()=>{let a=r(e);a&&(n==null||n(a))},children:Qn(Gf,{size:16})})}),Qn(Of,{color:"black",children:o(t==="node"?"editor.toolbar.configure_node":"editor.toolbar.configure_edge")})]})};import{useReactFlow as zf}from"@xyflow/react";import{Button as Ff,Tooltip as Wf,TooltipContent as Yf,TooltipTrigger as Uf,useTranslation as $f}from"lecom-ui";import{TrashIcon as Xf}from"lucide-react";import{jsx as jn,jsxs as Kf}from"react/jsx-runtime";var er=({elementId:e,elementType:t="node"})=>{let{t:o}=$f(),{deleteElements:n}=zf();return Kf(Wf,{children:[jn(Uf,{asChild:!0,children:jn(Ff,{variant:"ghost",color:"destructive",size:"small",iconButton:!0,onClick:()=>{n(t==="node"?{nodes:[{id:e}]}:{edges:[{id:e}]})},children:jn(Xf,{size:16})})}),jn(Yf,{color:"black",children:o("editor.toolbar.delete")})]})};import{Button as qf,Tooltip as Zf,TooltipContent as Jf,TooltipTrigger as Qf,useTranslation as jf}from"lecom-ui";import{MoveUpRightIcon as em}from"lucide-react";import{useCallback as tm}from"react";import{jsx as tr,jsxs as om}from"react/jsx-runtime";var Do=({nodeId:e,disabled:t=!1,tooltipMessage:o})=>{let{t:n}=jf(),r=tm(i=>{i.stopPropagation();let a=document.querySelector(`[data-id="${e}"]`);if(!a)return;let s=a.querySelector(".react-flow__handle.source");if(!s)return;let 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 om(Zf,{children:[tr(Qf,{asChild:!0,children:tr(qf,{variant:"ghost",color:"grey",size:"small",iconButton:!0,disabled:t,className:t?"opacity-50 cursor-not-allowed":"",onMouseDown:t?void 0:r,children:tr(em,{size:16})})}),tr(Jf,{color:"black",children:o||n("editor.toolbar.connect_node")})]})};import{jsx as Ro}from"react/jsx-runtime";var Ft=i=>{var a=i,{edgeId:e,edgeType:t,sourceNode:o,targetNode:n}=a,r=$e(a,["edgeId","edgeType","sourceNode","targetNode"]);let{mode:s}=W(),l=(o==null?void 0:o.type)==="START_EVENT",c=(o==null?void 0:o.type)==="GATEWAY"&&(n==null?void 0:n.type)==="GATEWAY",d=(o==null?void 0:o.type)==="TASK"&&(n==null?void 0:n.type)==="GATEWAY",u=!l&&!c&&!d,p=[{component:Ro(er,{elementId:e,elementType:"edge"})}],f=()=>s==="view"?u?[{component:Ro(dt,{elementId:e,elementType:"edge"})}]:[]:u?[{component:Ro(dt,{elementId:e,elementType:"edge"})},...p]:p,g=(m=>{switch(m){case"SEQUENCE_EDGE":return f();case"MESSAGE_EDGE":return s==="view"?[]:[...p];case"ANNOTATION_EDGE":return s==="view"?[]:[...p];default:return[]}})(t);if(!(g.length===0||s==="view"))return Ro("div",v(E({className:"flex items-center gap-1 w-fit px-3 py-2 bg-white rounded-sm shadow-md"},r),{children:g.map((m,x)=>Ro("div",{children:m.component},x))}))};import{jsx as or,jsxs as am}from"react/jsx-runtime";var Wt={type:"ANNOTATION_EDGE",reconnectable:!0},el=({id:e,source:t,target:o,selected:n,data:r})=>{let{zoom:i}=sm(),{isMultipleSelection:a}=W(),s=ja(t),l=ja(o);if(!s||!l)return null;let{sx:c,sy:d,tx:u,ty:p}=lt(s,l),[f,h,g]=im({sourceX:c,sourceY:d,targetX:u,targetY:p}),m=n||(s==null?void 0:s.selected)||(l==null?void 0:l.selected),x=1/i;return am("g",{className:k("text-grey-400 hover:text-grey-500",{"text-blue-500 hover:text-blue-600":m}),children:[or(nm,{id:e,path:f,strokeDasharray:4,className:k("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)})}),or(rm,{children:or("div",{className:"absolute z-[3000] pointer-events-auto flex flex-col items-center gap-1",style:{transform:`translate(-50%, -50%) translate(${h}px, ${g}px)`},children:n&&!a&&or(Ft,{edgeId:e,edgeType:"ANNOTATION_EDGE",style:{transform:`scale(${x})`}})})})]})};import{useState as sl,useCallback as gm,useMemo as ar,useEffect as hm,useRef as al}from"react";import{BaseEdge as ym,EdgeLabelRenderer as xm,MarkerType as ll,useInternalNode as cl,useReactFlow as Em,useViewport as bm,useEdges as _m,Position as Xt}from"@xyflow/react";import{useEffect as tl,useRef as lm,useState as cm}from"react";import{jsx as ol}from"react/jsx-runtime";var Te=({value:e,maxLength:t,style:o,className:n,contentClassName:r,isEditing:i,onChange:a,onBlur:s})=>{let l=lm(null),[c,d]=cm(!1);tl(()=>{d(i!=null?i:!1)},[i]),tl(()=>{if(c&&l.current){l.current.focus();let g=document.createRange();g.selectNodeContents(l.current);let m=window.getSelection();m&&(m.removeAllRanges(),m.addRange(g))}},[c]);let u=g=>{g.stopPropagation(),c||d(!0)},p=g=>{let m=g.currentTarget.innerText.trim(),x=t&&m.length>=t,y=["Backspace","Delete","ArrowLeft","ArrowRight","ArrowUp","ArrowDown","Home","End","Tab","Enter","Escape","Shift"],b=g.ctrlKey||g.metaKey,N=b&&g.key==="a",T=b&&g.key==="c",_=b&&g.key==="x",w=b&&g.key==="v";function P(C){return/\w/.test(C)}if(m.length===0&&!P(g.key)&&!y.includes(g.key)&&!b){g.preventDefault();return}x&&(y.includes(g.key)||N||T||_||w||g.preventDefault())},f=g=>{if(!t)return;g.preventDefault();let m=g.clipboardData.getData("text/plain"),x=g.currentTarget.innerText,y=window.getSelection();if(!y||y.rangeCount===0)return;let b=y.getRangeAt(0);if((x.substring(0,b.startOffset)+m+x.substring(b.endOffset)).length>t){let T=t-(x.length-(b.endOffset-b.startOffset)),_=m.substring(0,Math.max(0,T));_&&(b.deleteContents(),b.insertNode(document.createTextNode(_)),b.setStartAfter(b.endContainer),b.collapse(!0),y.removeAllRanges(),y.addRange(b))}else b.deleteContents(),b.insertNode(document.createTextNode(m)),b.setStartAfter(b.endContainer),b.collapse(!0),y.removeAllRanges(),y.addRange(b)},h=g=>{d(!1);let m=g.currentTarget.innerText.trim();t&&m.length>t&&(m=m.substring(0,t)),g.currentTarget.innerText=m,s==null||s(),m!==e&&(a==null||a(m))};return ol("div",{className:k("flex-1 p-2 self-stretch content-center border border-transparent overflow-hidden text-ellipsis text-sm text-center",n,{"border border-dashed border-grey-400":c}),style:o,onDoubleClick:u,children:ol("div",{ref:l,className:k("outline-none whitespace-pre-wrap overflow-hidden",r,{"nodrag nopan cursor-text":c}),contentEditable:!0,suppressContentEditableWarning:!0,onKeyDown:p,onPaste:f,onBlur:h,children:e})})};import{Position as nr}from"@xyflow/react";var Vo=e=>e===nr.Left||e===nr.Right,ai=(e,t=30)=>e===nr.Right||e===nr.Bottom?t:-t,li=(e,t,o,n=1)=>Math.abs(e[o]-t[o])<n,Yt=(e,t)=>Math.sqrt((t.x-e.x)**2+(t.y-e.y)**2),rr=(e,t)=>({x:(e.x+t.x)/2,y:(e.y+t.y)/2});var Ho={OFFSET:30,TOLERANCE:1,MOVE_THRESHOLD:5,MIN_SEGMENT_LENGTH:15,PARALLEL_OFFSET:15};function dm(e,t,o,n,r,i,a=0){let s=ai(r,Ho.OFFSET),l=ai(i,Ho.OFFSET),c=Vo(r),d=Vo(i),u=c?0:a,p=c?a:0,f=d?0:a,h=d?a:0,g={x:e+u,y:t+p},m={x:o+f,y:n+h};if(c&&d){let x=(t+n)/2+a;return[g,{x:e+s,y:t+a},{x:e+s,y:x},{x:o+l,y:x},{x:o+l,y:n+a},m]}if(!c&&!d){let x=(e+o)/2+a;return[g,{x:e+a,y:t+s},{x,y:t+s},{x,y:n+l},{x:o+a,y:n+l},m]}return c?[g,{x:e+s,y:t+a},{x:e+s,y:n+l+a},{x:o+a,y:n+l+a},m]:[g,{x:e+a,y:t+s},{x:o+l+a,y:t+s},{x:o+l+a,y:n+a},m]}function nl(e,t,o,n,r,i,a,s=0){let l=dm(e,t,o,n,r,i,s);if(!(a!=null&&a.length))return l;let c=[...a];if(c.length>0){let d={x:e,y:t},u=c[0],p=Vo(r);p&&Math.abs(d.y-u.y)>1?c.unshift({x:u.x,y:d.y}):!p&&Math.abs(d.x-u.x)>1&&c.unshift({x:d.x,y:u.y})}if(c.length>0){let d={x:o,y:n},u=c[c.length-1],p=Vo(i);p&&Math.abs(d.y-u.y)>1?c.push({x:u.x,y:d.y}):!p&&Math.abs(d.x-u.x)>1&&c.push({x:d.x,y:u.y})}return[{x:e,y:t},...c,{x:o,y:n}]}var rl=e=>{if(e.length<2)return"";let[t,...o]=e;return`M ${t.x},${t.y}${o.map(n=>` L ${n.x},${n.y}`).join("")}`};import{useCallback as Ut,useEffect as ir,useRef as Go,useState as $t}from"react";import{useReactFlow as um,useStore as pm}from"@xyflow/react";var fm=50,il=.1,mm=.6,sr=({edgeId:e,source:t,target:o,instanceId:n,isReadOnly:r})=>{let{setEdges:i,getNode:a,getNodes:s,getEdge:l,screenToFlowPosition:c}=um(),{setIsDragging:d,setReconnectingEdgeId:u}=W(),p=pm(S=>S.isValidConnection),[f,h]=$t(null),[g,m]=$t(null),[x,y]=$t(null),[b,N]=$t(null),[T,_]=$t(null),[w,P]=$t(!1),H=Go(null),C=Go(null),I=Go(null),L=Go(t),B=Go(o);ir(()=>{L.current=t,B.current=o},[t,o]),ir(()=>{H.current=f},[f]),ir(()=>{C.current=T},[T]);let M=Ut(S=>{let O=s(),Y=O.find(ee=>ee.id===S);if(!Y)return{x:0,y:0};let G=Y.position.x,X=Y.position.y,K=Y.parentId;for(;K;){let ee=O.find(R=>R.id===K);if(!ee)break;G+=ee.position.x,X+=ee.position.y,K=ee.parentId}return{x:G,y:X}},[s]),A=Ut(S=>{var K,ee,R,$,q,z;let O=s(),Y=null,G=fm,X=O.filter(V=>V.type!=="LANE"&&V.type!=="ANNOTATION");for(let V of X){if(V.id===e)continue;let Z=M(V.id),J=(R=(ee=(K=V.measured)==null?void 0:K.width)!=null?ee:V.width)!=null?R:0,ne=(z=(q=($=V.measured)==null?void 0:$.height)!=null?q:V.height)!=null?z:0;if(S.x>=Z.x&&S.x<=Z.x+J&&S.y>=Z.y&&S.y<=Z.y+ne)return V.id;let le=Math.max(Z.x-S.x,0,S.x-(Z.x+J)),de=Math.max(Z.y-S.y,0,S.y-(Z.y+ne)),be=Math.sqrt(le*le+de*de);be<G&&(G=be,Y=V.id)}return Y},[s,M,e]),D=Ut((S,O)=>{var le,de,be,re,ue,pe;let Y=a(S);if(!Y)return null;let G=M(S),X=(be=(de=(le=Y.measured)==null?void 0:le.width)!=null?de:Y.width)!=null?be:0,K=(pe=(ue=(re=Y.measured)==null?void 0:re.height)!=null?ue:Y.height)!=null?pe:0,ee=Math.abs(G.x+X-O.x),R=Math.abs(O.x-G.x),$=Math.abs(G.y+K-O.y),q=Math.abs(O.y-G.y),z={right:ee,left:R,bottom:$,top:q},V=Object.entries(z).reduce((ae,[ie,De])=>De<ae[1]?[ie,De]:ae,["right",z.right])[0],Z=I.current;if(Z&&Z!==V){let ae=z[V],ie=z[Z],De=Math.abs(ie-ae),Ze=Math.min(Math.abs(ie),Math.abs(ae));De<Ze*mm&&(V=Z)}let J=V,ne,me;if(J==="right"||J==="left"){let ie=(Math.max(G.y,Math.min(G.y+K,O.y))-G.y)/(K||1);Math.abs(ie-.5)<il&&(ie=.5),me=ie,ne={x:J==="right"?G.x+X:G.x,y:G.y+me*K}}else{let ie=(Math.max(G.x,Math.min(G.x+X,O.x))-G.x)/(X||1);Math.abs(ie-.5)<il&&(ie=.5),me=ie,ne={x:G.x+me*X,y:J==="bottom"?G.y+K:G.y}}return{side:J,snapPosition:ne,offset:me}},[a,M]),U=Ut(S=>{var R,$,q;let O=H.current;if(!O)return;let Y=c({x:S.clientX,y:S.clientY}),G=A(Y);y(G);let X=Y,K=null,ee=null;if(G){let z=D(G,Y);z&&(K=z.side,X=z.snapPosition,ee=z.offset,I.current=K);let V=l(e),Z={source:O==="source"?G:L.current,target:O==="target"?G:B.current,sourceHandle:O==="source"?K:(R=V==null?void 0:V.sourceHandle)!=null?R:null,targetHandle:O==="target"?K:($=V==null?void 0:V.targetHandle)!=null?$:null},J=(q=p==null?void 0:p(Z))!=null?q:!0;P(J)}else I.current=null,P(!1);N(K),_(ee),m(X)},[A,D,l,e,c,p]),F=Ut(S=>{var K,ee,R,$,q;let O=H.current;if(!O)return;let Y=c({x:S.clientX,y:S.clientY}),G=A(Y);if(G){let z=D(G,Y),V=(K=z==null?void 0:z.side)!=null?K:null,Z=(ee=z==null?void 0:z.offset)!=null?ee:.5,J=l(e),ne={source:O==="source"?G:L.current,target:O==="target"?G:B.current,sourceHandle:O==="source"?V:(R=J==null?void 0:J.sourceHandle)!=null?R:null,targetHandle:O==="target"?V:($=J==null?void 0:J.targetHandle)!=null?$:null};((q=p==null?void 0:p(ne))==null||q)&&i(me=>me.map(le=>{var de,be;return le.id===e?v(E({},le),{source:ne.source,target:ne.target,sourceHandle:ne.sourceHandle,targetHandle:ne.targetHandle,data:v(E({},le.data),{points:void 0,sourceOffset:O==="source"?Z:(de=le.data)==null?void 0:de.sourceOffset,targetOffset:O==="target"?Z:(be=le.data)==null?void 0:be.targetOffset})}):le}))}h(null),m(null),y(null),N(null),_(null),d(!1),P(!1),u(null),I.current=null,document.removeEventListener("mouseup",F),document.removeEventListener("mousemove",U);let X=Ke.get(n);X==null||X.clearReconnectingEdge()},[e,A,D,l,i,n,U,p,c,d,u]),te=Ut((S,O)=>{if(r||O.button!==0)return;O.stopPropagation(),O.preventDefault(),i(G=>G.map(X=>X.id===e?v(E({},X),{data:v(E({},X.data),{points:void 0})}):X)),h(S),u(e);let Y=Ke.get(n);Y==null||Y.setReconnectingEdge(e),document.addEventListener("mousemove",U),document.addEventListener("mouseup",F)},[r,e,n,U,F,u,i]);return ir(()=>()=>{if(H.current){document.removeEventListener("mousemove",U),document.removeEventListener("mouseup",F),u(null);let S=Ke.get(n);S==null||S.clearReconnectingEdge()}},[n,U,F,u]),{reconnectingHandle:f,cursorPosition:g,hoveredNodeId:x,reconnectingSide:b,reconnectingOffset:T,isValidReconnection:w,handleReconnectStart:te}};import{Fragment as ul,jsx as Ne,jsxs as ut}from"react/jsx-runtime";var Ye={type:"SEQUENCE_EDGE",reconnectable:!0,markerStart:{type:ll.ArrowClosed},markerEnd:{type:ll.Arrow},data:{label:""}},{MOVE_THRESHOLD:lr,MIN_SEGMENT_LENGTH:Tm,PARALLEL_OFFSET:dl}=Ho;function Nm(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)*dl}let i=r.findIndex(s=>s.id===e),a=(r.length-1)/2;return(i-a)*dl}var pl=({id:e,source:t,target:o,data:n,selected:r,sourcePosition:i,targetPosition:a,sourceHandleId:s,targetHandleId:l})=>{var ee;let{zoom:c}=bm(),{updateEdgeData:d}=Em(),u=_m(),{isMultipleSelection:p,mode:f,instanceId:h}=W(),[g,m]=sl(!1),[x,y]=sl(null),b=al(null),N=al(null),T=f!=="edit",{reconnectingHandle:_,cursorPosition:w,hoveredNodeId:P,reconnectingSide:H,isValidReconnection:C,handleReconnectStart:I}=sr({edgeId:e,source:t,target:o,instanceId:h,isReadOnly:T}),L=cl(t),B=cl(o),{sx:M,sy:A,tx:D,ty:U,sourcePos:F,targetPos:te}=ar(()=>{var de,be;let R=L&&B?lt(L,B):{sx:0,sy:0,tx:0,ty:0,sourcePos:Xt.Right,targetPos:Xt.Left},$=s?i:R.sourcePos,q=l?a:R.targetPos,z=(re,ue,pe)=>{var co,uo,po,fo,Mi,Pi;let{x:ae,y:ie}=re.internals.positionAbsolute,De=(po=(uo=(co=re.measured)==null?void 0:co.width)!=null?uo:re.width)!=null?po:0,Ze=(Pi=(Mi=(fo=re.measured)==null?void 0:fo.height)!=null?Mi:re.height)!=null?Pi:0;switch(ue){case Xt.Top:return{x:ae+De*pe,y:ie};case Xt.Bottom:return{x:ae+De*pe,y:ie+Ze};case Xt.Left:return{x:ae,y:ie+Ze*pe};case Xt.Right:return{x:ae+De,y:ie+Ze*pe};default:return{x:ae+De/2,y:ie+Ze/2}}},V=(de=n==null?void 0:n.sourceOffset)!=null?de:.5,Z=(be=n==null?void 0:n.targetOffset)!=null?be:.5,J=L?z(L,$,V).x:R.sx,ne=L?z(L,$,V).y:R.sy,me=B?z(B,q,Z).x:R.tx,le=B?z(B,q,Z).y:R.ty;return _==="source"&&w?(J=w.x,ne=w.y,H&&($=H)):_==="target"&&w&&(me=w.x,le=w.y,H&&(q=H)),{sx:J,sy:ne,tx:me,ty:le,sourcePos:$,targetPos:q}},[L,B,s,l,i,a,_,w,H,n==null?void 0:n.sourceOffset,n==null?void 0:n.targetOffset]);hm(()=>{var q;if(!N.current){N.current={sx:M,sy:A,tx:D,ty:U,sourcePos:F,targetPos:te};return}let R=N.current;(Math.abs(M-R.sx)>lr||Math.abs(A-R.sy)>lr||Math.abs(D-R.tx)>lr||Math.abs(U-R.ty)>lr||R.sourcePos!==F||R.targetPos!==te)&&((q=n==null?void 0:n.points)!=null&&q.length)&&!_&&d(e,v(E({},n),{points:void 0})),N.current={sx:M,sy:A,tx:D,ty:U,sourcePos:F,targetPos:te}},[M,A,D,U,F,te,n,e,d,_]);let S=ar(()=>{let R=Nm(e,t,o,u);return nl(M,A,D,U,F,te,n==null?void 0:n.points,R)},[M,A,D,U,F,te,n==null?void 0:n.points,u,e,t,o]),O=ar(()=>{if(S.length<2)return rr({x:M,y:A},{x:D,y:U});let R=0;for(let z=0;z<S.length-1;z++)R+=Yt(S[z],S[z+1]);let $=R/2,q=0;for(let z=0;z<S.length-1;z++){let V=Yt(S[z],S[z+1]);if(q+V>=$){let Z=($-q)/V,J=S[z],ne=S[z+1];return{x:J.x+(ne.x-J.x)*Z,y:J.y+(ne.y-J.y)*Z}}q+=V}return rr({x:M,y:A},{x:D,y:U})},[S,M,A,D,U]),Y=ar(()=>{if(S.length<2){let V=Math.abs(D-M);return Math.abs(U-A)>V?{x:-60,y:0}:{x:0,y:-60}}let $=0;for(let V=0;V<S.length-1;V++)$+=Yt(S[V],S[V+1]);let q=$/2,z=0;for(let V=0;V<S.length-1;V++){let Z=Yt(S[V],S[V+1]);if(z+Z>=q){let J=S[V],ne=S[V+1],me=Math.abs(ne.x-J.x);return Math.abs(ne.y-J.y)>me?{x:-60,y:0}:{x:0,y:-60}}z+=Z}return{x:0,y:-60}},[S,M,A,D,U]),G=gm((R,$)=>{if(f!=="edit"||$.button!==0)return;$.stopPropagation(),$.preventDefault();let q=S[R],z=S[R+1],V=li(q,z,"y"),Z=V?q.y:q.x,J=[...S],ne=J.length,me=R,le=R+1;y(R);let de=re=>{let ue=Z+(V?re.clientY-$.clientY:re.clientX-$.clientX)/c;b.current=V?{x:(q.x+z.x)/2,y:ue}:{x:ue,y:(q.y+z.y)/2};let pe=[];for(let ae=1;ae<ne-1;ae++){let ie=J[ae];ae===me||ae===le?V?pe.push({x:ie.x,y:ue}):pe.push({x:ue,y:ie.y}):pe.push(E({},ie))}d(e,v(E({},n),{points:pe}))},be=()=>{y(null),b.current=null,document.removeEventListener("mousemove",de),document.removeEventListener("mouseup",be)};document.addEventListener("mousemove",de),document.addEventListener("mouseup",be)},[f,S,c,n,e,d]);if(!L||!B)return null;let X=rl(S),K=r||L.selected||B.selected;return ut(ul,{children:[ut("g",{className:k("text-grey-400 hover:text-grey-500",{"text-blue-500 hover:text-blue-600":K}),onBlur:()=>m(!1),onDoubleClick:()=>m(!0),children:[Ne(ym,{id:e,path:X,markerEnd:`url(#${K?"sequence-edge-marker-highlighted":"sequence-edge-marker"})`,className:k("stroke-2 stroke-current transition-colors duration-75",{"stroke-red-500 hover:stroke-red-600":(n==null?void 0:n.hasError)||_&&P&&!C,"stroke-green-500":_&&P&&C,"stroke-blue-500 hover:stroke-blue-600 drop-shadow-[0_0_3px_rgba(59,130,246,0.5)]":K&&!(n!=null&&n.hasError)&&!_})}),r&&!p&&!T&&Ne("g",{children:S.slice(0,-1).map((R,$)=>{let q=S[$+1];if($===0||$===S.length-2||Yt(R,q)<Tm)return null;let z=li(R,q,"y"),V=x===$,Z=V&&b.current?b.current:rr(R,q);return ut("g",{children:[Ne("line",{x1:R.x,y1:R.y,x2:q.x,y2:q.y,stroke:"transparent",strokeWidth:20/c,className:k("cursor-pointer",{"cursor-ns-resize":z,"cursor-ew-resize":!z}),onMouseDown:J=>G($,J)}),Ne("circle",{cx:Z.x,cy:Z.y,r:4/c,fill:V?"#3b82f6":"#fff",stroke:"#3b82f6",strokeWidth:2/c,className:"pointer-events-none"}),Ne("circle",{cx:Z.x,cy:Z.y,r:6/c,fill:"none",stroke:"#3b82f6",strokeWidth:1/c,opacity:V?.6:.3,className:"pointer-events-none"})]},$)})})]}),ut(xm,{children:[ut("div",{className:"absolute z-[3000] pointer-events-auto flex flex-col items-center gap-1",style:{transform:`translate(-50%, -50%) translate(${O.x}px, ${O.y}px)`},children:[r&&!p&&Ne("div",{className:"absolute",style:{transform:`translate(${Y.x}px, ${Y.y}px)`},children:Ne(Ft,{edgeId:e,edgeType:"SEQUENCE_EDGE",sourceNode:L,targetNode:B,style:{transform:`scale(${1/c})`}})}),(g||((ee=n==null?void 0:n.label)==null?void 0:ee.trim()))&&Ne(Te,{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:g,onChange:R=>d(e,{label:R.trim()})})]}),r&&!p&&!T&&ut(ul,{children:[Ne("div",{className:"absolute z-[10000] pointer-events-none",style:{transform:`translate(-50%, -50%) translate(${S[0].x}px, ${S[0].y}px)`},children:ut("svg",{width:12/c,height:12/c,style:{overflow:"visible",position:"absolute",left:"50%",top:"50%",transform:"translate(-50%, -50%)"},children:[Ne("circle",{cx:6/c,cy:6/c,r:4/c,fill:_==="source"?"#3b82f6":"#fff",stroke:"#3b82f6",strokeWidth:2/c,className:"pointer-events-none"}),Ne("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"}),Ne("circle",{cx:6/c,cy:6/c,r:8/c,fill:"transparent",className:k("pointer-events-auto",{"cursor-move":!_||_!=="source","cursor-not-allowed":_==="source"&&P&&!C,"cursor-grabbing":_==="source"&&(!P||C)}),onMouseDown:R=>I("source",R.nativeEvent)})]})}),Ne("div",{className:"absolute z-[10000] pointer-events-none",style:{transform:`translate(-50%, -50%) translate(${S[S.length-1].x}px, ${S[S.length-1].y}px)`},children:ut("svg",{width:12/c,height:12/c,style:{overflow:"visible",position:"absolute",left:"50%",top:"50%",transform:"translate(-50%, -50%)"},children:[Ne("circle",{cx:6/c,cy:6/c,r:4/c,fill:_==="target"?"#3b82f6":"#fff",stroke:"#3b82f6",strokeWidth:2/c,className:"pointer-events-none"}),Ne("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"}),Ne("circle",{cx:6/c,cy:6/c,r:8/c,fill:"transparent",className:k("pointer-events-auto",{"cursor-move":!_||_!=="target","cursor-not-allowed":_==="target"&&P&&!C,"cursor-grabbing":_==="target"&&(!P||C)}),onMouseDown:R=>I("target",R.nativeEvent)})]})})]})]})]})};import{useDebouncedCallback as Eh}from"use-debounce";import{useReactFlow as xh}from"@xyflow/react";import{useCallback as Ic}from"react";var Bo=(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))(Bo||{});import{xml2json as vm,json2xml as wm}from"xml-js";var fl={compact:!0,spaces:4},Im=e=>e.replaceAll(`
|
|
2
|
+
`,"
");function cr(e,t=fl){if(e)return JSON.parse(vm(e,v(E({},t),{attributeValueFn:Im})))}function ml(e,t=fl){return e?wm(e,t):""}var Am={MIN_WIDTH:36,MIN_HEIGHT:36},Cm={MIN_WIDTH:36,MIN_HEIGHT:36},Sm={MIN_WIDTH:56,MIN_HEIGHT:56},dr={MIN_WIDTH:176,MIN_HEIGHT:96},ur={HEADER_WIDTH:40,MIN_WIDTH:840,MIN_HEIGHT:256},ce={HEADER_WIDTH:40,MIN_WIDTH:800,MIN_HEIGHT:256},pr={MIN_WIDTH:176,MIN_HEIGHT:64},Mm={MIN_WIDTH:128,MIN_HEIGHT:64},j={START_EVENT:Am,END_EVENT:Cm,GATEWAY:Sm,TASK:dr,LANE:ce,ANNOTATION:pr,UNSUPPORTED:Mm};var gl={"attribute-loop":"LOOP"},hl={"task-script":"SCRIPT","subprocess-collapsed":"SUBPROCESS"},yl={"gateway-exclusive":"EXCLUSIVE","gateway-parallel":"PARALLEL","gateway-complex":"COMPLEX"},xl={SCRIPT:"task-script",SUBPROCESS:"subprocess-collapsed"},El={EXCLUSIVE:"gateway-exclusive",PARALLEL:"gateway-parallel",COMPLEX:"gateway-complex"};var Kt=(e,t,o)=>{let n=e._attributes.width||0,r=e._attributes.height||0,i=ot(Number(n),t),a=ot(Number(r),o);return{width:i,height:a,measured:{width:i,height:a}}},qt=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},Lm=e=>{let{mxGeometry:t}=e,o=qt(e),n=Kt(t,j.START_EVENT.MIN_WIDTH,j.START_EVENT.MIN_HEIGHT);return v(E(E({},o),n),{type:"START_EVENT"})},km=e=>{let{mxGeometry:t}=e,o=qt(e),n=Kt(t,j.END_EVENT.MIN_WIDTH,j.END_EVENT.MIN_HEIGHT);return v(E(E({},o),n),{type:"END_EVENT"})},ci=(e,t)=>{let{_attributes:o,mxGeometry:n}=e,r=qt(e),i=Kt(n,j.TASK.MIN_WIDTH,j.TASK.MIN_HEIGHT),a=t==null?void 0:t.find(l=>{let{parent:c}=l._attributes;return c===e._attributes.id});if(a){let{style:l}=a._attributes,c=gl[l];c&&(r.data.attribute=c)}let s=hl[o.style];return s&&(r.data.variant=s),v(E(E({},r),i),{type:"TASK"})},di=e=>{let{_attributes:t,mxGeometry:o}=e,{style:n}=t,r=qt(e),i=Kt(o,j.GATEWAY.MIN_WIDTH,j.GATEWAY.MIN_HEIGHT);return r.data.variant=yl[n],v(E(E({},r),i),{type:"GATEWAY"})},Dm=e=>{let{mxGeometry:t}=e,o=qt(e),n=Kt(t,j.ANNOTATION.MIN_WIDTH,j.ANNOTATION.MIN_HEIGHT);return v(E(E({},o),n),{type:"ANNOTATION"})},Rm=e=>{let{mxGeometry:t}=e,o=qt(e),n=Kt(t,j.LANE.MIN_WIDTH,j.LANE.MIN_HEIGHT);return v(E(E({},o),n),{type:"LANE"})},bl={task:ci,"task-script":ci,"subprocess-collapsed":ci,"start-event":Lm,"end-event-terminate":km,"gateway-parallel":di,"gateway-exclusive":di,"gateway-complex":di,annotation:Dm,lane:Rm},Om=e=>{if(e&&Array.isArray(e))return e.map(t=>({x:Number(t._attributes.x),y:Number(t._attributes.y)}))},_l=e=>{let{_attributes:t,mxGeometry:o}=e,{id:n,source:r,target:i,value:a,style:s}=t,l=Om(o==null?void 0:o.Array),c={id:n,source:r,target:i,data:E({label:a||""},l&&l.length>0?{points:l}:{})};return s.includes("association")&&s.includes('endArrow=""')?E(E({},Wt),c):E(E({},Ye),c)},Tl=(e,t)=>{let{id:o,type:n,source:r,target:i,data:a}=e,s=t==null?void 0:t.find(u=>u.id===r),l="";n==="ANNOTATION_EDGE"&&(l='association;endArrow=""');let c={_attributes:{as:"geometry",relative:"1"}};return a!=null&&a.points&&Array.isArray(a.points)&&a.points.length>0&&(c.Array=a.points.map(u=>({_attributes:{as:"mxPoint",x:u.x,y:u.y}}))),{_attributes:{id:o,parent:(s==null?void 0:s.parentId)||"1",edge:"1",style:l,source:r,target:i,value:(a==null?void 0:a.label)||""},mxGeometry:c}},Zt=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}}}},Vm=e=>{let{variant:t}=e.data,o=Zt(e);return v(E({},o),{_attributes:v(E({},o._attributes),{style:xl[t]||"task"})})},Hm=e=>{let t=Zt(e);return v(E({},t),{_attributes:v(E({},t._attributes),{style:"start-event"})})},Gm=e=>{let t=Zt(e);return v(E({},t),{_attributes:v(E({},t._attributes),{style:"end-event-terminate"})})},Bm=e=>{let{variant:t}=e.data,o=Zt(e);return v(E({},o),{_attributes:v(E({},o._attributes),{style:El[t]})})},zm=e=>{let t=Zt(e);return v(E({},t),{_attributes:v(E({},t._attributes),{style:"lane"})})},Fm=e=>{let t=Zt(e);return v(E({},t),{_attributes:v(E({},t._attributes),{style:"annotation"})})},Nl={TASK:Vm,START_EVENT:Hm,END_EVENT:Gm,GATEWAY:Bm,ANNOTATION:Fm,LANE:zm},vl=(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 Al from"@dagrejs/dagre";import{getNodesBounds as $m}from"@xyflow/react";import{orderBy as Xm}from"lodash";import{orderBy as Wm}from"lodash";var et=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}},wt=e=>Wm(e,[o=>{let n=o.type==="LANE";return n&&!o.parentId?0:n?1:2}],["asc"]),wl=(e,t)=>{let{x:o,y:n}=et(e),{x:r,y:i}=et(t);return{x:o-r,y:n-i}};var Jt=({parentId:e,nodes:t,includeTypes:o=[...Object.values(Q)],excludeTypes:n=[]})=>t.some(r=>r.parentId===e&&(!o.length||o.includes(r.type))&&!n.includes(r.type)),Ym=(e,t)=>{let{x:o,y:n}=et(e),{x:r,y:i}=et(t),a=o-r,s=n-i;return Math.sqrt(a*a+s*s)},Um=(e,t)=>{let{x:o,y:n,w:r,h:i}=et(e),{x:a,y:s,w:l,h:c}=et(t);return o<a+l&&a<o+r&&n<s+c&&s<n+i},zo=(e,t)=>{let o=null,n=1/0;for(let r of t)if(r.id!==e.id&&Um(e,r)){let i=Ym(e,r);i<n&&(n=i,o=r)}return o},Il=(e,t)=>t.filter(o=>o.parentId===e).reduce((o,n)=>{var r,i;return Math.max(o,(i=(r=n.measured)==null?void 0:r.width)!=null?i:0)},0);var Cl=(e=[],t=[],o="LR")=>{let n=new Al.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)),Al.layout(n),{nodes:e.map(i=>{let a=n.node(i.id);return v(E({},i),{position:{x:a.x-i.width/2,y:a.y-i.height/2}})}),edges:t}},Fo=e=>{let t=e.filter(n=>n.type==="LANE"&&!n.parentId),o=[...e];return t.forEach(n=>{o=Wo(n.id,o)}),o},Wo=(e,t)=>{var f,h;let o=[...t],n=o.find(g=>g.id===e);if(!n)return o;let r=o.filter(g=>g.parentId===e&&g.type==="LANE");if(r.length===0)return o;let i=Xm(r,["position.y"]),a=Math.max((h=(f=n.measured)==null?void 0:f.width)!=null?h:0,ur.MIN_WIDTH),s=Il(e,i)||ce.MIN_WIDTH,l=Math.max(a,s),c=a-ce.HEADER_WIDTH>=s,d=0,u=0;i.forEach(g=>{var m,x,y,b;o=o.map(N=>N.id===g.id?v(E({},N),{width:c?l-ce.HEADER_WIDTH:l,measured:v(E({},N.measured),{width:c?l-ce.HEADER_WIDTH:l}),position:{x:ce.HEADER_WIDTH,y:d}}):N),d+=(x=(m=g.measured)==null?void 0:m.height)!=null?x:0,u+=(b=(y=g.measured)==null?void 0:y.height)!=null?b:0}),o=o.map(g=>g.id===e?v(E({},g),{height:u,width:c?l:l+ce.HEADER_WIDTH,measured:v(E({},g.measured),{height:u,width:c?l:l+ce.HEADER_WIDTH})}):g);let p=o.find(g=>g.id===e);return p!=null&&p.parentId&&(o=Wo(p.parentId,o)),o},Sl=(e,t,o)=>{if(e.type==="LANE")return o;let n=Le(t),r=Le(e);return r.y<n.y&&(e.position.y=0),r.x<n.x+ce.HEADER_WIDTH&&(e.position.x=ce.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(E({},i),{height:t.height,width:t.width,measured:t.measured}):i.id===e.id?v(E({},i),{position:e.position}):i),o},Ml=()=>{let e=document.querySelector(".react-flow__viewport");return e||(console.error("Flow element (.react-flow__viewport) not found."),null)},Km=50,Pl=(e,t=Km)=>{let o=$m(e);return{x:o.x-t,y:o.y-t,width:o.width+t*2,height:o.height+t*2}};var Yo=1,Ll=()=>`<mxGraphModel>
|
|
3
3
|
<root version="1.1">
|
|
4
4
|
<mxCell id="0" />
|
|
5
5
|
<mxCell id="1" parent="0" />
|
|
@@ -32,9 +32,9 @@ var hd=Object.defineProperty,yd=Object.defineProperties;var xd=Object.getOwnProp
|
|
|
32
32
|
<mxGeometry as="geometry" relative="1" />
|
|
33
33
|
</mxCell>
|
|
34
34
|
</root>
|
|
35
|
-
</mxGraphModel>`,sl=(e,t)=>{if(!e.length&&!t.length)return ho;let o=[...e.map(r=>r.id),...t.map(r=>r.id)];return Math.max(...o.map(r=>Number(r)))};var Tm=e=>{let t=Object.values(po),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=Xa[a],l=s==null?void 0:s(i,n);if(!l){console.warn(`Node ${a} not supported`);continue}r.push(l)}return r},Nm=(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=Ka(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},vm=(e,t)=>{let o=[];return e.forEach(n=>{var a,s;let r=(s=(a=Za)[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=Ja(n,t);o.push(l)}}),o},wm=(e,t)=>{let o=[];return e.forEach(n=>{let r=qa(n,t);o.push(r)}),o},al=(e=[],t=[],o)=>{let n=vm(e,o),r=wm(t,e),i={mxGraphModel:{root:{_attributes:{version:"1.1",lastId:o},mxCell:[{_attributes:{id:"0"}},{_attributes:{id:"1",parent:"0"}},...n,...r]}}};return za(JSON.stringify(i),{compact:!0,spaces:0})},ll=async e=>{var s,l,c,d,u;let t=await Dn(e),o=((l=(s=t==null?void 0:t.mxGraphModel)==null?void 0:s.root)==null?void 0:l.mxCell)||[],n=Number(((u=(d=(c=t==null?void 0:t.mxGraphModel)==null?void 0:c.root)==null?void 0:d._attributes)==null?void 0:u.lastId)||ho),r=Tm(o),i=Nm(o,r);return{nodes:rt(mo(r)),edges:i,lastElementId:n}};import{Position as rg,useConnection as ig,useReactFlow as sg}from"@xyflow/react";import{Handle as cl,useReactFlow as Im}from"@xyflow/react";import{jsx as dl}from"react/jsx-runtime";var se=i=>{var a=i,{type:e,position:t,className:o,nodeType:n}=a,r=we(a,["type","position","className","nodeType"]);let s=n==="TASK";return dl(cl,E({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":s,"before:content-[''] before:absolute before:inset-[-4px] before:bg-transparent":!s},o)},r))},At=s=>{var l=s,{nodeId:e,nodeType:t,gatewayVariant:o,type:n,position:r,className:i}=l,a=we(l,["nodeId","nodeType","gatewayVariant","type","position","className"]);let{getEdges:c,getNodes:d}=Im(),p=(()=>{if(n!=="source")return!1;let f=c();if(t==="TASK")return f.filter(g=>g.source===e).length>=2;if(t==="GATEWAY"&&o==="EXCLUSIVE")return f.filter(g=>g.source===e).length>=2;if(t==="START_EVENT"){let x=d();return f.filter(m=>{if(m.source!==e)return!1;let y=x.find(h=>h.id===m.target);return(y==null?void 0:y.type)!=="ANNOTATION"}).length>=1}return!1})();return dl(cl,E({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":t==="TASK","before:content-[''] before:absolute before:inset-[-4px] before:bg-transparent":t!=="TASK","opacity-50 cursor-not-allowed pointer-events-none":p,"hover:border-grey-500":!p},i),style:{pointerEvents:p?"none":"auto"}},a))};import{NodeResizer as Am,useReactFlow as Cm}from"@xyflow/react";import{orderBy as Sm}from"lodash";import{jsx as Mm}from"react/jsx-runtime";var Ct=n=>{var r=n,{nodeId:e,isVisible:t}=r,o=we(r,["nodeId","isVisible"]);let{getNode:i,getNodes:a,setNodes:s}=Cm(),{isMultipleSelection:l}=G(),c=({width:u,height:p})=>{if(!e)return;let f=i(e);if((f==null?void 0:f.type)!=="LANE")return;let x=[...a()],g=!f.parentId,m=g?f.id:f.parentId,y=x.filter(T=>T.type==="LANE"&&T.parentId===m);if(!y.length)return;let h=Sm(y,["position.y"]),b=0;h.forEach((T,_)=>{var S,L;let v=_===h.length-1,w=(L=(S=T.measured)==null?void 0:S.height)!=null?L:0;x=x.map(P=>{if(P.id===T.id){let C=g?u-K.HEADER_WIDTH:u,I=N(E({},P),{width:C,measured:N(E({},P.measured),{width:C}),position:N(E({},P.position),{y:b})});return v&&g&&(I.height=p-b),I}return P}),b+=w}),x=x.map(T=>{if(T.id===m){let _=g?u:u+K.HEADER_WIDTH;return N(E({},T),{width:_,height:g?p:b,measured:{width:_,height:g?p:b}})}return T}),s(x)};return Mm(Am,E({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,p)=>c(p)},o))};import{NodeToolbar as Km,useReactFlow as qm}from"@xyflow/react";import{Button as Zm,Tooltip as Jm,TooltipContent as Qm,TooltipTrigger as jm,useTranslation as eg}from"lecom-ui";import{useCallback as tg,useRef as gl,useState as og}from"react";import{create as Pm}from"zustand";var St=Pm(e=>({draggableNode:null,setDraggableNode:t=>{e({draggableNode:t})}}));import{useEffect as Lm,useState as km}from"react";var ul=(e,t=!1)=>{let[o,n]=km({width:0,height:0});return Lm(()=>{if(e.current&&t){let r=e.current.getBoundingClientRect();n({width:r.width,height:r.height})}},[t,e]),{dimensions:o}};import{Position as yo,useReactFlow as Dm}from"@xyflow/react";import{useMemo as Rm}from"react";var Vm=120,Om=12,pl=(e,t=!1,o)=>{let{getNode:n,getViewport:r}=Dm(),{instanceId:i}=G();return Rm(()=>{var f,x;if(!t)return{position:yo.Right,align:"start"};let a=n(e);if(!a)return{position:yo.Right,align:"start"};let s=r(),l=a.position.x*s.zoom+s.x,c=(((f=a.measured)==null?void 0:f.width)||a.width||100)*s.zoom,d=(x=document.getElementById(`modeler-${i}`))==null?void 0:x.clientWidth;if(!d)return{position:yo.Right,align:"start"};let u=(o==null?void 0:o.width)||Vm;return{position:l+c+u+Om>d?yo.Left:yo.Right}},[i,e,t,o,n,r])};import{useNodesData as Hm,useReactFlow as Gm}from"@xyflow/react";import{Button as fl,DropdownMenu as Bm,DropdownMenuContent as zm,DropdownMenuGroup as Fm,DropdownMenuItem as Wm,DropdownMenuLabel as Ym,DropdownMenuTrigger as Um,Tooltip as Br,TooltipContent as zr,TooltipTrigger as Fr,useTranslation as $m}from"lecom-ui";import{WrenchIcon as Xm}from"lucide-react";import{jsx as ce,jsxs as it}from"react/jsx-runtime";var ml=({nodeId:e})=>{let{t}=$m(),{updateNodeData:o,getEdges:n,getNode:r}=Gm(),i=Hm(e),s=n().filter(f=>f.source===e).some(f=>{let x=r(f.target);return(x==null?void 0:x.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 it(Bm,{children:[it(Br,{children:[ce(Fr,{asChild:!0,children:ce(Um,{asChild:!0,children:ce(fl,{variant:"ghost",color:"grey",size:"small",iconButton:!0,children:ce(Xm,{})})})}),ce(zr,{color:"black",children:t("bpmn.task.menu.title")})]}),it(zm,{align:"start",className:"w-60 bg-white text-grey-600",children:[it(Ym,{className:"flex items-center gap-1",children:[ce("div",{className:"flex-1 text-sm font-semibold",children:t("bpmn.task.menu.title")}),ce("div",{className:"flex items-center gap-1",children:Object.entries(Lo).map(([u,p])=>{let f=u==="LOOP"&&(s||l),g=(()=>{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")})();return it(Br,{children:[ce(Fr,{asChild:!0,children:ce(fl,{variant:"ghost",color:"grey",size:"small",iconButton:!0,disabled:f,className:R({"bg-grey-100 text-blue-500":(i==null?void 0:i.data.attribute)===u,"opacity-50 cursor-not-allowed":f}),onClick:f?void 0:()=>d(u),children:ce(p.icon,{className:"stroke-inherit"})})}),g&&ce(zr,{color:"black",children:g})]},u)})})]}),ce(Fm,{children:it(Br,{children:[ce(Fr,{asChild:!0,children:it(Wm,{className:R({"bg-grey-100 text-blue-500":(i==null?void 0:i.data.variant)==="SCRIPT","opacity-50 cursor-not-allowed":s}),disabled:s,onClick:s?void 0:()=>c("SCRIPT"),children:[ce(Po.SCRIPT.icon,{className:"stroke-current"}),t(`bpmn.task.variant.${"SCRIPT".toLowerCase()}`)]})}),s&&ce(zr,{color:"black",children:t("editor.task_menu.script_not_allowed_when_connected_to_end")})]})})]})]})};import{jsx as j,jsxs as hl}from"react/jsx-runtime";var st={START_EVENT:{type:"START_EVENT",icon:Wt,label:"bpmn.start_event.variant.default"},END_EVENT:{type:"END_EVENT",icon:pt,label:"bpmn.end_event.variant.default"},TASK:{type:"TASK",icon:Wt,label:"bpmn.task.variant.default"},ANNOTATION:{type:"ANNOTATION",icon:Ao,label:"bpmn.annotation.variant.default"}},ng={EXCLUSIVE:{type:"GATEWAY",variant:"EXCLUSIVE",icon:mt,label:"bpmn.gateway.variant.exclusive"},PARALLEL:{type:"GATEWAY",variant:"PARALLEL",icon:gt,label:"bpmn.gateway.variant.parallel"},COMPLEX:{type:"GATEWAY",variant:"COMPLEX",icon:ft,label:"bpmn.gateway.variant.complex"}},pe=({nodeId:e,nodeType:t,nodeVariant:o,isChild:n,isVisible:r})=>{let i=gl(null),a=gl(null),{t:s}=eg(),{setDraggableNode:l}=St(),{getEdges:c,getNodes:d}=qm(),{setIsDragging:u,mode:p}=G(),{dimensions:f}=ul(i,r),{position:x}=pl(e,r,f),[g,m]=og(void 0),y=d(),h=c(),b=o==="SUBPROCESS",T=tg((k,V)=>{l({type:V.type,variant:V.variant,attribute:V.attribute,icon:V.icon}),V.icon&&m(j(V.icon,{})),k.dataTransfer.effectAllowed="move",k.dataTransfer.setData("sourceId",e),a.current&&k.dataTransfer.setDragImage(a.current,10,10),setTimeout(()=>{u(!0)},100)},[e,l,u]),_=[{component:j(wn,{elementId:e})}],v=()=>{if(p==="view")return[];let k=!h.some(V=>{var O;return V.source===e&&((O=y.find(B=>B.id===V.target))==null?void 0:O.type)!=="ANNOTATION"});return[{component:j(lo,{nodeId:e,disabled:!k,tooltipMessage:k?void 0:s("editor.toolbar.start_event_limit_reached")})},st.TASK,st.ANNOTATION,..._]},w=()=>p==="view"?[{component:j(Xe,{elementId:e})}]:[{component:j(Xe,{elementId:e})},...b?[]:[{component:j(ml,{nodeId:e})}],{component:j(lo,{nodeId:e})},st.TASK,...Object.values(ng),..._],S=()=>p==="view"?[{component:j(Xe,{elementId:e})}]:[{component:j(Xe,{elementId:e})},{component:j(lo,{nodeId:e})},st.TASK,st.ANNOTATION,..._],L=()=>p==="view"?[]:[{component:j(lo,{nodeId:e})},st.ANNOTATION,..._],P=()=>p==="view"?[]:[...n?[]:[st.ANNOTATION],..._],C=()=>p==="view"?[]:[..._],I=()=>p==="view"?[]:[..._],A=(k=>{switch(k){case"START_EVENT":return v();case"TASK":return w();case"GATEWAY":return S();case"END_EVENT":return L();case"LANE":return P();case"ANNOTATION":return C();case"UNSUPPORTED":return I();default:return[]}})(t);if(!(A.length===0||p==="readonly"))return hl(Km,{position:x,align:"start",className:"-top-8",isVisible:r,children:[j("div",{ref:i,className:"flex items-center gap-1 px-3 py-2 bg-white rounded-sm shadow-md",children:A.map((k,V)=>{if(k.component)return j("div",{children:k.component},V);let O={sourceNodeType:t,targetNodeType:k.type,sourceNodeId:e,nodes:y,edges:h},B=Na(O),X={gateway_limit_reached:s("editor.toolbar.gateway_limit_reached"),start_event_limit_reached:s("editor.toolbar.start_event_limit_reached"),start_event_already_exists:s("editor.toolbar.start_event_already_exists"),script_to_end_not_allowed:s("editor.toolbar.script_to_end_not_allowed"),loop_to_end_not_allowed:s("editor.toolbar.loop_to_end_not_allowed"),initial_activity_to_end_not_allowed:s("editor.toolbar.initial_activity_to_end_not_allowed"),final_activity_cannot_connect:s("editor.toolbar.final_activity_cannot_connect"),activity_has_outgoing_connections:s("editor.toolbar.activity_has_outgoing_connections"),task_limit_reached:s("editor.toolbar.task_limit_reached")},D=B.shouldDisable&&B.reason?X[B.reason]||s(k.label):s(k.label)||"";return hl(Jm,{children:[j(jm,{asChild:!0,children:j(Zm,{variant:"ghost",color:"grey",size:"small",iconButton:!0,draggable:!B.shouldDisable,disabled:B.shouldDisable,className:B.shouldDisable?"opacity-50 cursor-not-allowed":"",onDragStart:B.shouldDisable?void 0:H=>T(H,k),children:k.icon&&j(k.icon,{size:16})})}),j(Qm,{color:"black",children:D})]},V)})}),j("div",{ref:a,className:"absolute w-0 h-0 top-0 left-0 z-[-1] bg-transparent",children:g})]})};import{jsx as Hn,jsxs as ag}from"react/jsx-runtime";var yl=({id:e,data:t,selected:o,dragging:n})=>{let{updateNodeData:r}=sg(),{inProgress:i,fromNode:a}=ig(),{mode:s,isConnecting:l,isDragging:c,isMultipleSelection:d}=G(),u=i&&(a==null?void 0:a.id)!==e,p=x=>{r(e,{label:x})},f=!l&&!c&&!d;return ag("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:[Hn(re,{value:t.label,className:"m-1 text-grey-600",onChange:p}),f&&Hn(pe,{nodeId:e,nodeType:"ANNOTATION",isVisible:!n&&o}),s==="edit"&&Hn(Ct,{minWidth:On.MIN_WIDTH,minHeight:On.MIN_HEIGHT,isVisible:!n&&o}),(!i||u)&&Hn(se,{type:"target",position:rg.Left,className:R({"annotation-handle":u})})]})};import{Position as xl,useConnection as lg,useReactFlow as cg}from"@xyflow/react";import{useState as dg}from"react";import{jsx as Mt,jsxs as ug}from"react/jsx-runtime";var El=({id:e,data:t,selected:o,dragging:n})=>{let{updateNodeData:r}=cg(),{inProgress:i,fromNode:a}=lg(),{isConnecting:s,isDragging:l,isMultipleSelection:c}=G(),[d,u]=dg(!1),p=i&&(a==null?void 0:a.id)!==e,f=y=>{r(e,{label:y})},x=()=>{u(!0)},g=()=>{u(!1)},m=!s&&!l&&!c;return ug("div",{className:"relative",onBlur:g,onDoubleClick:x,children:[Mt(pt,{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})}),Mt("div",{className:"absolute top-9 left-1/2 -translate-x-1/2 max-w-80 w-max",children:Mt(re,{value:t.label,isEditing:d,onChange:f})}),m&&Mt(pe,{nodeId:e,nodeType:"END_EVENT",isVisible:!n&&o}),(!i||p)&&Mt(se,{type:"target",position:xl.Left,className:R({"event-handle":p})}),!i&&Mt(se,{type:"source",position:xl.Right})]})};import{Position as bl,useConnection as pg,useReactFlow as fg}from"@xyflow/react";import{useCallback as mg,useState as gg}from"react";import{jsx as Pt,jsxs as hg}from"react/jsx-runtime";var _l=({id:e,data:t,selected:o,dragging:n})=>{let r=fr[t.variant].icon,{updateNodeData:i}=fg(),{inProgress:a,fromNode:s}=pg(),{isConnecting:l,isDragging:c,isMultipleSelection:d}=G(),[u,p]=gg(!1),f=a&&(s==null?void 0:s.id)!==e,x=mg(h=>{i(e,{label:h})},[e,i]),g=()=>{p(!0)},m=()=>{p(!1)},y=!l&&!c&&!d;return hg("div",{className:"relative",onBlur:m,onDoubleClick:g,children:[Pt(r,{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})}),Pt("div",{className:"absolute top-14 left-1/2 -translate-x-1/2 max-w-80 w-max",children:Pt(re,{value:t.label,isEditing:u,onChange:x})}),y&&Pt(pe,{nodeId:e,nodeType:"GATEWAY",isVisible:!n&&o}),(!a||f)&&Pt(se,{type:"target",position:bl.Left,className:R({"gateway-handle":f})}),!a&&Pt(At,{type:"source",position:bl.Right,nodeId:e,nodeType:"GATEWAY",gatewayVariant:t.variant})]})};import{useNodesData as tA,useReactFlow as oA}from"@xyflow/react";import{Button as rA,DropdownMenu as iA,DropdownMenuContent as sA,DropdownMenuGroup as aA,DropdownMenuItem as lA,DropdownMenuLabel as cA,DropdownMenuTrigger as dA,Tooltip as uA,TooltipContent as pA,TooltipTrigger as fA,useTranslation as mA}from"lecom-ui";import{WrenchIcon as hA}from"lucide-react";import{jsx as bA,jsxs as _A}from"react/jsx-runtime";import{Position as Tl,useConnection as yg,useReactFlow as xg}from"@xyflow/react";import{useState as Eg}from"react";import{jsx as Lt,jsxs as bg}from"react/jsx-runtime";var Nl=({id:e,data:t,selected:o,dragging:n})=>{let{updateNodeData:r}=xg(),{inProgress:i,fromNode:a}=yg(),{isConnecting:s,isDragging:l,isMultipleSelection:c}=G(),[d,u]=Eg(!1),p=i&&(a==null?void 0:a.id)!==e,f=y=>{r(e,{label:y})},x=()=>{u(!0)},g=()=>{u(!1)},m=!s&&!l&&!c;return bg("div",{className:"relative",onBlur:g,onDoubleClick:x,children:[Lt(So,{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})}),Lt("div",{className:"absolute top-9 left-1/2 -translate-x-1/2 max-w-80 w-max",children:Lt(re,{value:t.label,isEditing:d,onChange:f})}),m&&Lt(pe,{nodeId:e,nodeType:"START_EVENT",isVisible:!n&&o}),(!i||p)&&Lt(se,{type:"target",position:Tl.Left,className:R({"event-handle":p})}),!i&&Lt(At,{type:"source",position:Tl.Right,nodeId:e,nodeType:"START_EVENT"})]})};import{Position as Ml,useConnection as Ng,useReactFlow as vg}from"@xyflow/react";import{useTranslation as wg}from"lecom-ui";import{useCallback as Ig}from"react";var Gn=(e,t)=>{let n=e.filter(i=>i.type==="TASK").map(i=>{var s;let a=(s=i.data)==null?void 0:s.label;if(a&&a.startsWith(`${t} `)){let l=a.match(new RegExp(`^${t} (\\d+)$`));return l?parseInt(l[1],10):0}return 0}).filter(i=>i>0),r=n.length>0?Math.max(...n)+1:1;return`${t} ${r}`},kt=(e,t)=>{let n=t.filter(s=>s.type==="TASK").map(s=>{var l;return(l=s.data)==null?void 0:l.label}).filter(Boolean);if(!n.includes(e))return e;let r=e.replace(/\s+\(\d+\)$/,""),i=n.filter(s=>s===r||s.startsWith(`${r} (`)).map(s=>{if(s===r)return 1;let l=s.match(/\s+\((\d+)\)$/);return l?parseInt(l[1],10):0}).filter(s=>s>0),a=2;for(;i.includes(a);)a++;return`${r} (${a})`};import{jsx as vl,jsxs as _g}from"react/jsx-runtime";var wl=e=>_g("svg",N(E({width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",xmlns:"http://www.w3.org/2000/svg"},e),{children:[vl("circle",{cx:"12",cy:"12",r:"10",fill:"#10B981"}),vl("path",{d:"M7 12L10 15L17 8",stroke:"white",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"})]}));import{jsx as Il}from"react/jsx-runtime";var Al=e=>Il("svg",N(E({width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",xmlns:"http://www.w3.org/2000/svg"},e),{children:Il("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 Cl,jsxs as Tg}from"react/jsx-runtime";var Sl=e=>Tg("svg",N(E({width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",xmlns:"http://www.w3.org/2000/svg"},e),{children:[Cl("circle",{cx:"12",cy:"12",r:"10",fill:"#EF4444"}),Cl("path",{d:"M8 8L16 16M8 16L16 8",stroke:"white",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"})]}));import{jsx as ye,jsxs as Cg}from"react/jsx-runtime";var Ag={APROVADO:wl,EM_ANDAMENTO:Al,REJEITADO:Sl},Wr={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)]"},Pl=({id:e,data:t,selected:o,dragging:n})=>{let{t:r}=wg(),{updateNodeData:i,getNodes:a}=vg(),{inProgress:s,fromNode:l}=Ng(),{mode:c,isConnecting:d,isDragging:u,isMultipleSelection:p,onSubprocessValidationClick:f}=G(),{getTaskStatus:x}=Je(),g=s&&(l==null?void 0:l.id)!==e,m=Ig(C=>{let I=C.trim(),M=t.label||"";if(I===M)return;let A=a(),k=I;I||(k=Gn(A,r("bpmn.task.label.prefix")));let V=kt(k,A);V!==M&&i(e,{label:V})},[t.label,a,e,r,i]),y=x(e),h=y?Ag[y]:null,b=t.variant?Po[t.variant].icon:null,T=t.attribute?Lo[t.attribute].icon:null,_=t.variant==="SUBPROCESS",v=b&&!_,w=T||_,S=()=>t.hasError?Wr.error:y?Wr[y]:Wr.default,L=()=>{f==null||f({id:e,type:"sub_process",label:t.label})},P=!d&&!u&&!p;return Cg("div",{className:R("relative w-full h-full min-w-44 min-h-24 flex items-center justify-center 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:[ye(re,{value:t.label,maxLength:60,className:R("m-1",{"py-6":v||w}),onChange:m}),b&&ye("div",{className:R("absolute flex items-center p-1",_?"bottom-0":"top-0 left-0"),children:ye(b,{size:16,className:R(t.hasError?"text-red-500":"text-grey-500",_&&"cursor-pointer"),onClick:_?L:void 0})}),T&&ye("div",{className:"absolute bottom-0 left-0 w-full flex items-center justify-center",children:ye("div",{className:R("flex items-center w-16 p-1",_?"justify-between":"justify-center"),children:ye(T,{size:16,className:R(t.hasError?"text-red-500":"text-grey-500")})})}),h&&ye("div",{className:"absolute top-0 right-0 flex items-center p-1",children:ye(h,{})}),P&&ye(pe,{nodeId:e,nodeType:"TASK",nodeVariant:t.variant,isVisible:!n&&o}),c==="edit"&&ye(Ct,{minWidth:Rn.MIN_WIDTH,minHeight:Rn.MIN_HEIGHT,isVisible:!n&&o}),(!s||g)&&ye(se,{type:"target",position:Ml.Left,className:R({"task-handle":g})}),!s&&ye(At,{type:"source",position:Ml.Right,nodeId:e,nodeType:"TASK"})]})};import{Position as Ll}from"@xyflow/react";import{Fragment as Sg,jsx as Bn,jsxs as Mg}from"react/jsx-runtime";var kl=({id:e,data:t,selected:o,dragging:n})=>{let{isConnecting:r,isDragging:i,isMultipleSelection:a}=G(),s=!r&&!i&&!a;return Mg(Sg,{children:[Bn("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}),s&&Bn(pe,{nodeId:e,nodeType:"UNSUPPORTED",isVisible:!n&&o}),Bn(se,{type:"source",position:Ll.Right}),Bn(se,{type:"target",position:Ll.Left})]})};import{BaseEdge as Pg,EdgeLabelRenderer as Lg,getSmoothStepPath as kg,MarkerType as Dg,useInternalNode as Dl,useReactFlow as Rg,useViewport as Vg}from"@xyflow/react";import{useState as Og}from"react";import{jsx as zn,jsxs as Rl}from"react/jsx-runtime";var QC={type:"MESSAGE_EDGE",reconnectable:!0,markerEnd:{type:Dg.Arrow},data:{label:""}},Vl=({id:e,source:t,target:o,data:n,selected:r})=>{let{zoom:i}=Vg(),{updateEdgeData:a}=Rg(),{isMultipleSelection:s}=G(),[l,c]=Og(!1),d=Dl(t),u=Dl(o);if(!d||!u)return null;let{sx:p,sy:f,tx:x,ty:g,sourcePos:m,targetPos:y}=Ae(d,u),[h,b,T]=kg({sourceX:p,sourceY:f,targetX:x,targetY:g,sourcePosition:m,targetPosition:y}),_=r||(d==null?void 0:d.selected)||(u==null?void 0:u.selected),v=_?"sequence-edge-marker-highlighted":"sequence-edge-marker",w=l||(n==null?void 0:n.label.trim().length)>0,S=1/i,L=()=>{c(!0)},P=()=>{c(!1)},C=I=>{a(e,{label:I.trim()})};return Rl("g",{className:R("text-grey-400 hover:text-grey-500",{"text-blue-500 hover:text-blue-600":_}),onBlur:P,onDoubleClick:L,children:[zn(Pg,{id:e,path:h,markerEnd:`url(#${v})`,strokeDasharray:4,className:R("stroke-2 stroke-current transition-colors duration-75",{"stroke-red-500 hover:stroke-red-600":n==null?void 0:n.hasError,"stroke-blue-500 hover:stroke-blue-600 drop-shadow-[0_0_3px_rgba(59,130,246,0.5)]":_&&!(n!=null&&n.hasError)})}),zn(Lg,{children:Rl("div",{className:"absolute z-[3000] pointer-events-auto flex flex-col items-center gap-1",style:{transform:`translate(-50%, -50%) translate(${b}px, ${T}px)`},children:[r&&!s&&zn(_t,{edgeId:e,edgeType:"MESSAGE_EDGE",style:{transform:`scale(${S})`}}),w&&zn(re,{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:l,onChange:C})]})})]})};import{getBezierPath as Hg}from"@xyflow/react";import{jsx as Ol,jsxs as Gg}from"react/jsx-runtime";var Hl=({toX:e,toY:t,fromPosition:o,toPosition:n,fromNode:r})=>{if(!r)return null;let i={id:"connection-target",measured:{width:1,height:1},internals:{positionAbsolute:{x:e,y:t}}},{sx:a,sy:s,tx:l,ty:c,sourcePos:d,targetPos:u}=Ae(r,i),[p]=Hg({sourceX:a,sourceY:s,sourcePosition:d||o,targetPosition:u||n,targetX:l||e,targetY:c||t});return Gg("g",{children:[Ol("path",{fill:"none",className:"stroke-2 stroke-grey-400 animated",d:p}),Ol("circle",{cx:l||e,cy:c||t,fill:"none",r:4,className:"stroke-2 stroke-grey-500"})]})};import{Position as Bg,useReactFlow as zg}from"@xyflow/react";import{orderBy as Fg}from"lodash";import{useMemo as Gl,useState as Wg}from"react";import{Fragment as Yg,jsx as at,jsxs as Bl}from"react/jsx-runtime";var zl=({id:e,data:t,selected:o,dragging:n,parentId:r})=>{let{updateNodeData:i,getNodes:a}=zg(),{mode:s,isConnecting:l,isDragging:c,isMultipleSelection:d}=G(),[u,p]=Wg(!1),f=a(),x=!r,g=Gl(()=>Fg([...f.filter(v=>v.parentId===e&&v.type==="LANE")],"position.y","asc"),[f,e]),m=x?Vn.MIN_WIDTH:K.MIN_WIDTH,y=Gl(()=>{if(x&&g.length>1){let v=[...g];return v.pop(),v.reduce((S,L)=>{var P,C;return S+((C=(P=L.measured)==null?void 0:P.height)!=null?C:0)},0)+K.MIN_HEIGHT}return K.MIN_HEIGHT},[x,g]),h=v=>{i(e,{label:v})},b=()=>{p(!0)},T=()=>{p(!1)},_=!l&&!c&&!d;return Bl(Yg,{children:[Bl("div",{className:R("flex h-full min-h-64 w-full min-w-[50rem] hover:shadow-md bg-white outline outline-2 outline-grey-400",{"outline-offset-2 outline-blue-500 shadow-sm":o}),children:[at("div",{className:"flex align-items justify-center w-10 border-r-2 border-grey-400",onBlur:T,onDoubleClick:b,children:at("div",{className:R("relative flex-1",{"[writing-mode:vertical-rl] [text-orientation:sideways] transform rotate-180":!u}),children:at(re,{value:t.label,className:"w-full h-full pointer-events-none self-auto",contentClassName:R({"whitespace-nowrap":u}),isEditing:u,onChange:h})})}),at("div",{className:"flex-1"})]}),_&&at(pe,{nodeId:e,nodeType:"LANE",isChild:!x,isVisible:!n&&o}),s==="edit"&&at(Ct,{nodeId:e,minWidth:m,minHeight:y,isVisible:!n&&o}),x&&at(se,{type:"source",position:Bg.Right})]})};var Fl={START_EVENT:Nl,END_EVENT:El,TASK:Pl,GATEWAY:_l,ANNOTATION:yl,LANE:zl,UNSUPPORTED:kl},Wl={SEQUENCE_EDGE:Ga,MESSAGE_EDGE:Vl,ANNOTATION_EDGE:Aa},Yl="#fafafa",Ul="#bebebe",$l=1,Xl=10,Kl="bottom-left",ql=.2,Zl=5,Dt=.5,Rt=.4,Vt=1,Jl={x:0,y:0,zoom:.75},Ug=1,$g=2,Ql=[Ug,$g];import{useReactFlow as Xg}from"@xyflow/react";var xe=()=>{let{getEdges:e,getNodes:t}=Xg(),{lastElementId:o}=G(),n=()=>{let i=t(),a=e(),s=sl(i,a);return Math.max(s,o)};return{getLastId:n,getNextId:()=>n()+1}};var Ot=()=>{let{getNodes:e,getEdges:t,setNodes:o,setEdges:n,fitView:r}=Kg(),{getLastId:i}=xe(),{setLastElementId:a}=G(),s=jl(async(c="")=>{let{nodes:d,edges:u,lastElementId:p}=await ll(c);o(d),n(u),a(p),r({padding:Dt,minZoom:Rt,maxZoom:Vt})},[o,n,a,r]),l=jl((c,d)=>{let u=c||e()||[],p=d||t()||[],f=i();return al(u,p,f)},[e,t,i]);return{importFromMxGraph:s,exportToMxGraph:l}};import{useCallback as ec}from"react";var Zg=500,Fn=()=>{let{isInitialized:e,onElementChanges:t}=G(),{exportToMxGraph:o}=Ot(),n=qg(()=>{if(!e)return;let a=o();t==null||t(a)},Zg),r=ec(a=>{a.every(c=>c.type==="select")||a.some(c=>c.type==="position"&&c.dragging)||n()},[n]),i=ec(a=>{a.some(l=>l.type==="select")||n()},[n]);return{emitElementChanges:n,handleNodeChanges:r,handleEdgeChanges:i}};var tc=({setEdges:e})=>{let{getNode:t,getEdges:o,getNodes:n}=Qg(),{emitElementChanges:r}=Fn(),i=jg(null),{getNextId:a}=xe(),s=lt(x=>{var b;let g=t(x.source),m=t(x.target);if(!g||!m)return!1;let y={sourceNodeId:g.id,targetNodeId:m.id,sourceNodeType:g.type,targetNodeType:m.type,nodes:n(),edges:o(),reconnectingEdgeId:(b=i.current)!=null?b:void 0};return Mr(y).isValid},[t,o,n]),l=lt(x=>{let g=a(),m=t(x.target),y=(m==null?void 0:m.type)==="ANNOTATION"?Tt:Te,h=N(E(E({},x),y),{id:String(g)});e(b=>b.concat(h)),r()},[t,a,e,r]),c=lt((x,g)=>{i.current=g.id},[]),d=lt(()=>{i.current=null},[]),u=lt((x,g)=>{let m=t(g.source),y=t(g.target);if(!m||!y){i.current=null;return}let h={sourceNodeId:m.id,targetNodeId:y.id,sourceNodeType:m.type,targetNodeType:y.type,nodes:n(),edges:o(),reconnectingEdgeId:x.id};if(!Mr(h).isValid){i.current=null;return}e(T=>Jg(x,g,T).map(v=>v.id===x.id?N(E({},v),{data:N(E({},v.data),{points:void 0})}):v)),i.current=null,r()},[t,n,o,e,r]),p=lt(x=>{i.current=x},[]),f=lt(()=>{i.current=null},[]);return{isValidConnection:s,onConnect:l,onReconnect:u,onReconnectStart:c,onReconnectEnd:d,setReconnectingEdge:p,clearReconnectingEdge:f}};import{useReactFlow as eh}from"@xyflow/react";import{useTranslation as th}from"lecom-ui";import{useCallback as _o,useRef as dc,useState as uc}from"react";var xo=(e=[])=>e.filter(t=>t.type==="START_EVENT"),ct=(e=[])=>e.filter(t=>t.type==="END_EVENT"),qe=(e=[])=>e.filter(t=>t.type==="TASK")||[],oc=(e=[])=>e.filter(t=>{var o;return t.type==="TASK"&&((o=t.properties)==null?void 0:o.variant)==="SCRIPT"}),nc=(e=[])=>e.filter(t=>{var o;return t.type==="TASK"&&((o=t.properties)==null?void 0:o.variant)==="SUBPROCESS"}),Wn=(e=[])=>e.filter(t=>t.type==="GATEWAY"),rc=(e=[])=>e.filter(t=>{var o;return t.type==="GATEWAY"&&((o=t.properties)==null?void 0:o.variant)==="EXCLUSIVE"}),me=(e,t=[])=>t.filter(o=>o.source===e),Eo=(e,t=[])=>t.filter(o=>o.target===e),ic=(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"},sc=(e,t)=>{let o=me(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},ac=e=>e?/\w/g.test(e.trim()):!1,$=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:[]}},Se=(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)}},lc=(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 bo=[{id:"start_event_not_found",validate:e=>{let t=xo(e.nodes);return $({isValid:t.length>=1})}},{id:"end_event_not_found",validate:e=>{let t=ct(e.nodes);return $({isValid:t.length>=1})}},{id:"multiple_start_event_not_allowed",validate:e=>{let t=xo(e.nodes),o=t.length===1;if(t.length===0)return $({isValid:!0});if(!o)return $({isValid:!1,nodeIds:t.map(i=>i.id)});let n=me(t[0].id,e.edges);if(!(n.length<=1)){let i=[...t.map(a=>a.id),...n.map(a=>a.target)];return $({isValid:!1,nodeIds:[...new Set(i)]})}return $({isValid:!0})}},{id:"task_flows_limit_exceeds",validate:e=>{let t=qe(e.nodes),o=Se(t,n=>me(n.id,e.edges).length<=2);return $({isValid:o.isValid,nodeIds:o.invalidIds})}},{id:"task_label_empty",highlightRelatedEdges:!1,validate:e=>{let t=qe(e.nodes),o=Se(t,n=>!!n.label&&n.label.trim()!=="");return $({isValid:o.isValid,nodeIds:o.invalidIds})}},{id:"task_label_length",highlightRelatedEdges:!1,validate:e=>{let o=qe(e.nodes),n=Se(o,r=>!r.label||r.label.length<=60);return $({isValid:n.isValid,nodeIds:n.invalidIds})}},{id:"duplicate_task_name",highlightRelatedEdges:!1,validate:e=>{let t=qe(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 $({isValid:n.length===0,nodeIds:n})}},{id:"nested_gateway",validate:e=>{let t=Wn(e.nodes),o=[],n=[];for(let r of t){let i=me(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 $({isValid:o.length===0,nodeIds:o.length>0?[...new Set(o)]:[],edgeIds:n})}},{id:"events_nested",validate:e=>{let t=[...xo(e.nodes),...ct(e.nodes)],o=[],n=[];for(let r of t){let i=me(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 $({isValid:o.length===0,nodeIds:o.length>0?[...new Set(o)]:[],edgeIds:n})}},{id:"flows_on_end_tasks_not_allowed",validate:e=>{let t=ct(e.nodes),o=[],n=[];for(let r of t){let i=Eo(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=me(s.id,e.edges);l.length>1&&(o.push(s.id),l.forEach(c=>n.push(c.id)))}}}return $({isValid:o.length===0,nodeIds:o,edgeIds:n})}},{id:"conditions_flows_limit_exceeds",validate:e=>{let t=rc(e.nodes),o=Se(t,r=>me(r.id,e.edges).length<=2),n=o.invalidIds.flatMap(r=>me(r,e.edges).map(i=>i.id));return $({isValid:o.isValid,nodeIds:o.invalidIds,edgeIds:n})}},{id:"activity_name_invalid",validate:e=>{let t=qe(e.nodes),o=Se(t,n=>!n.label||ac(n.label));return $({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 $({isValid:!0});let t=ct(e.nodes)[0];if(!t)return $({isValid:!0});let o=Eo(t.id,e.edges);if(!o.length)return $({isValid:!0});let r=qe(e.nodes).filter(l=>o.some(c=>c.source===l.id)),i=Se(r,l=>!ic(l.id,e));return $({isValid:i.isValid,nodeIds:i.isValid?[]:[t.id,...i.invalidIds]})}},{id:"concurrent_initial_and_final_event",validate:e=>{let t=qe(e.nodes),o=ct(e.nodes)[0];if(!o)return $({isValid:!0});let n=t.filter(l=>{let c=Eo(l.id,e.edges),d=me(l.id,e.edges),u=c.some(f=>{var x;return((x=e.nodes.find(g=>g.id===f.source))==null?void 0:x.type)==="START_EVENT"}),p=d.some(f=>{var x;return((x=e.nodes.find(g=>g.id===f.target))==null?void 0:x.type)==="END_EVENT"});return u&&p}),r=Eo(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 $(s)}},{id:"gateway_flow_to_event",validate:e=>{let t=Wn(e.nodes),o=[],n=[];for(let r of t){let i=me(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 $({isValid:o.length===0,nodeIds:o.length>0?[...new Set(o)]:[],edgeIds:n})}},{id:"gateway_missing_output_streams",validate:e=>{let t=Wn(e.nodes),o=Se(t,n=>me(n.id,e.edges).length>=1);return $({isValid:o.isValid,nodeIds:o.invalidIds})}},{id:"event_to_condition",validate:e=>{let t=[...xo(e.nodes),...ct(e.nodes)],o=[],n=[];for(let r of t){let i=me(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 $({isValid:o.length===0,nodeIds:o.length>0?[...new Set(o)]:[],edgeIds:n})}},{id:"script_in_final_activity",validate:e=>{let t=oc(e.nodes),o=Se(t,n=>!sc(n.id,e));return $({isValid:o.isValid,nodeIds:o.invalidIds})}},{id:"subprocess_referenced_not_configured",validate:e=>{let t=nc(e.nodes),o=Se(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 $({isValid:o.isValid,nodeIds:o.invalidIds})}}];var cc=e=>{e=e||{nodes:[],edges:[]},e.nodes=e.nodes||[],e.edges=e.edges||[];let t=[];for(let n of bo){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}};var pc=()=>{let{t:e}=th(),{setNodes:t,setEdges:o,getNodes:n,getEdges:r}=eh(),[i,a]=uc(null),[s,l]=uc(!1),c=dc(!1),d=dc(!1),u=_o(m=>{let y=lc(m.nodes,m.edges),h=cc(y),b=h.errors.map(T=>N(E({},T),{message:e(`validation.errors.${T.id}`)}));return s||l(!0),{isValid:h.isValid,errors:b}},[s,e]),p=_o((m,y=!0)=>{if(y&&a(m),!m)return;c.current=!0,d.current=!0;let h=[],b=[];m.errors.forEach(I=>{I.nodeIds&&I.nodeIds.length>0&&I.nodeIds.forEach(M=>h.push(M)),I.edgeIds&&I.edgeIds.length>0&&I.edgeIds.forEach(M=>b.push(M))});let T=[...new Set(h)];t(I=>I.map(M=>N(E({},M),{data:N(E({},M.data),{hasError:!1})}))),o(I=>I.map(M=>N(E({},M),{data:N(E({},M.data),{hasError:!1})})));let _=n(),v=r(),w=new Set(T),S=new Set;m.errors.forEach(I=>{var k,V;let M=bo.find(O=>O.id===I.id);(M==null?void 0:M.highlightRelatedEdges)!==!1&&((k=I.edgeIds)==null||k.forEach(O=>S.add(O)),(V=I.nodeIds)==null||V.forEach(O=>{v.forEach(B=>{(B.source===O||B.target===O)&&S.add(B.id)})}))});let L=new Set,P=new Set,C=new Set;_.forEach(I=>{I.type==="START_EVENT"?L.add(I.id):I.type==="END_EVENT"&&P.add(I.id)}),v.forEach(I=>{L.has(I.source)&&C.add(I.target),P.has(I.target)&&C.add(I.source)}),C.forEach(I=>{var M,A;if(w.has(I)){let k=(M=m.errors.find(O=>{var B;return(B=O.nodeIds)==null?void 0:B.includes(I)}))==null?void 0:M.id;((A=bo.find(O=>O.id===k))==null?void 0:A.highlightRelatedEdges)!==!1&&v.forEach(O=>{O.source===I&&P.has(O.target)&&(w.add(O.target),S.add(O.id)),O.target===I&&L.has(O.source)&&(w.add(O.source),S.add(O.id))})}}),w.size>0&&t(I=>I.map(M=>N(E({},M),{data:N(E({},M.data),{hasError:w.has(M.id)})}))),S.size>0&&o(I=>I.map(M=>N(E({},M),{data:N(E({},M.data),{hasError:S.has(M.id)})}))),setTimeout(()=>{c.current=!1},0)},[r,n,o,t]),f=_o(()=>{a(null),l(!1),d.current=!1,t(m=>m.map(y=>N(E({},y),{data:N(E({},y.data),{hasError:!1})}))),o(m=>m.map(y=>N(E({},y),{data:N(E({},y.data),{hasError:!1})})))},[o,t]),x=_o(()=>{d.current&&(a(null),c.current=!0,d.current=!1,t(m=>m.map(y=>N(E({},y),{data:N(E({},y.data),{hasError:!1})}))),o(m=>m.map(y=>N(E({},y),{data:N(E({},y.data),{hasError:!1})}))),setTimeout(()=>{c.current=!1},0))},[o,t]),g=_o(()=>c.current,[]);return{validationResult:i,validateDiagram:u,handleValidationComplete:p,clearValidation:f,dismissValidationPanel:x,isAutoValidationEnabled:s,getIsClearingValidation:g}};import{useReactFlow as oh}from"@xyflow/react";import{useTranslation as nh}from"lecom-ui";import{useEffect as rh}from"react";var ih=15,fc="bpmn:selection",sh=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},mc=e=>{if(!sh(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},gc=({offset:e=ih}={})=>{let{t}=nh(),{getNodes:o,setNodes:n,getEdges:r,setEdges:i}=oh(),{getNextId:a}=xe();rh(()=>{let s=c=>{var m,y;if(!mc(c))return;let d=o(),u=r(),p=d.filter(h=>h.selected);if(!p.length)return;c.preventDefault(),c.stopPropagation();let f=u.filter(h=>p.some(b=>b.id===h.source)&&p.some(b=>b.id===h.target)),g=JSON.stringify({nodes:p,edges:f});(m=c.clipboardData)==null||m.setData(fc,g),(y=c.clipboardData)==null||y.setData("text/plain",`BPMN Selection: ${p.length} nodes`)},l=c=>{var _,v;if(!mc(c))return;let d=(_=c.clipboardData)==null?void 0:_.getData(fc);if(!d)return;c.preventDefault(),c.stopPropagation();let u;try{u=JSON.parse(d)}catch(w){return}if(!((v=u.nodes)!=null&&v.length))return;let p=new Map,f=o(),x=[],g=f.some(w=>w.type==="START_EVENT"),m=u.nodes.filter(w=>w.type==="START_EVENT"),y=u.nodes;if(g&&m.length>0&&(y=u.nodes.filter(w=>w.type!=="START_EVENT"),y.length===0))return;let h=a(),b=y.map(w=>{var P;let S=String(h++);p.set(w.id,S);let L=N(E({},w),{id:S,selected:!0,position:{x:w.position.x+e,y:w.position.y+e}});if(w.type==="TASK"){let C=(P=w.data)==null?void 0:P.label,I=kt(C||t("bpmn.task.label.prefix"),[...f,...x]);L.data=N(E({},w.data),{label:I})}return x.push(L),L}),T=u.edges.map(w=>N(E({},w),{id:String(h++),selected:!0,source:p.get(w.source)||w.source,target:p.get(w.target)||w.target}));n(w=>[...w.map(S=>N(E({},S),{selected:!1})),...b]),i(w=>[...w.map(S=>N(E({},S),{selected:!1})),...T])};return document.addEventListener("copy",s,!0),document.addEventListener("paste",l,!0),()=>{document.removeEventListener("copy",s,!0),document.removeEventListener("paste",l,!0)}},[o,n,r,i,a,e,t])};import{useReactFlow as ah,useStoreApi as lh}from"@xyflow/react";import{useTranslation as ch}from"lecom-ui";import{useState as dh}from"react";var hc=({nodes:e,setNodes:t,setEdges:o})=>{let n=lh(),{draggableNode:r,setDraggableNode:i}=St(),{t:a}=ch(),{getInternalNode:s,screenToFlowPosition:l}=ah(),{getNextId:c}=xe(),{setIsDragging:d}=G(),{rebuildIndex:u,forceRebuildIndex:p}=un(),[f,x]=dh(null),g=(C,I=!1)=>{let M=I?"[&>div]:bg-red-50 [&>div]:outline [&>div]:outline-[3px] [&>div]:outline-red-500":"[&>div]:bg-green-50/75 [&>div]:outline [&>div]:outline-[3px] [&>div]:outline-green-500";t(A=>A.map(k=>N(E({},k),{className:k.id===C?M:""})))},m=()=>{let{nodeLookup:C}=n.getState();return Array.from(C.values())},y=C=>{let I=s(C.id),M=m();if(C.type==="LANE"){if(It({parentId:C.id,nodes:e,includeTypes:["LANE"]})){g();return}let X=M.filter(z=>z.id!==C.id&&z.type==="LANE"&&!z.parentId),D=fo(I,X);if(!D){g();return}if(It({parentId:D.id,nodes:e,excludeTypes:["LANE"]})){g(D.id,!0);return}g(D.id);return}let k=M.filter(B=>B.id!==C.id&&B.type==="LANE"),V=fo(I,k);if(!V){g();return}if(It({parentId:V.id,nodes:e,includeTypes:["LANE"]})){g();return}g(V.id)},h=C=>C.map(I=>N(E({},I),{className:void 0})),b=C=>C.some(M=>M.dragging)?C.map(M=>M.dragging?N(E({},M),{dragging:!1}):M):C,T=C=>{C.preventDefault(),C.dataTransfer.dropEffect="move"},_=(C,I)=>{C.preventDefault(),y(I)},v=(C,I,M)=>{var B,X;let A=[...M];if(C.parentId===I.id)return A=ol(C,I,A),A=mo(A),h(A);if(C.type==="LANE"){if(It({parentId:I.id,nodes:A,excludeTypes:["LANE"]})){let Y=fe(I),Z=50,q=50;return A.map(ne=>{var Le,ve;return ne.id===C.id?N(E({},ne),{position:{x:(Le=f==null?void 0:f.x)!=null?Le:Y.x+Z,y:(ve=f==null?void 0:f.y)!=null?ve:Y.y2+q}}):ne})}let z=A.filter(Y=>Y.parentId===I.id).reduce((Y,Z)=>{var q,ne;return Y+((ne=(q=Z.measured)==null?void 0:q.height)!=null?ne:0)},0),W={x:K.HEADER_WIDTH,y:z};return A=A.map(Y=>Y.id===C.id?N(E({},Y),{parentId:I.id,position:W,className:void 0}):N(E({},Y),{className:void 0})),A=go(I.id,A),A}if(It({parentId:I.id,nodes:A,includeTypes:["LANE"]})){let D;if(C.parentId){let H=s(C.parentId),{x:z,y:W}=He(H);D={x:z+((B=C.position.x)!=null?B:0),y:W+((X=C.position.y)!=null?X:0)}}return A=A.map(H=>H.id===C.id?N(E({},H),{position:D!=null?D:H.position,parentId:void 0,className:void 0}):N(E({},H),{className:void 0})),A}let O=Qa(C,I);return A=A.map(D=>{if(D.id===C.id){let H=fe(C),z=fe(I);return H.y<z.y&&(O.y=0),H.x<z.x+K.HEADER_WIDTH&&(O.x=K.HEADER_WIDTH),N(E({},D),{parentId:I.id,position:O,className:void 0})}return N(E({},D),{className:void 0})}),A=mo(A),A},w=C=>{if(C.preventDefault(),!(r!=null&&r.type))return;let I=l({x:C.clientX,y:C.clientY}),M={width:U[r.type].MIN_WIDTH,height:U[r.type].MIN_HEIGHT},A=c(),k={id:String(A),type:r.type,position:I,measured:M,data:{label:r.type==="TASK"?Gn(e,a("bpmn.task.label.prefix")):"",variant:r.variant,attribute:r.attribute},selected:!0},V=N(E({},k),{internals:{positionAbsolute:I}}),O=m(),B=r.type==="LANE",X=O.filter(W=>B?W.type==="LANE"&&!W.parentId:W.type==="LANE"),D=fo(V,X),H=[...e.map(W=>N(E({},W),{selected:!1})),k];D&&(H=v(V,D,H)),H=rt(H),t(H),p();let z=C.dataTransfer.getData("sourceId");if(z){let W={id:String(A+1),source:z,target:k.id};if(r.type==="ANNOTATION"){o(Y=>Y.concat(E(E({},W),Tt)));return}o(Y=>Y.concat(E(E({},W),Te)))}d(!1),i(null)},S=async(C,I,M)=>{let A=[...e];M.forEach(k=>{let V=m(),O=s(k.id),B=k.type==="LANE",X=V.filter(H=>H.id!==k.id&&(B?H.type==="LANE"&&!H.parentId:H.type==="LANE")),D=fo(O,X);if(D){A=v(O,D,A);return}k.parentId&&(A=P(k,A))}),A=b(A),A=rt(A),A=h(A),t(A),u(A),x(null)},L=(C,I)=>{x({x:I.position.x,y:I.position.y})},P=(C,I)=>{var O,B;let M=s(C.parentId),{x:A,y:k}=He(M),V={x:A+((O=C.position.x)!=null?O:0),y:k+((B=C.position.y)!=null?B:0)};return I=I.map(X=>X.id===C.id?N(E({},X),{position:V,parentId:void 0}):X),I=go(C.parentId,I),I};return{onDragOver:T,onDrop:w,onNodeDrag:_,onNodeDragStart:L,onNodeDragStop:S}};import{useReactFlow as uh}from"@xyflow/react";import{useTranslation as ph}from"lecom-ui";import{useEffect as fh}from"react";var mh=30,gh=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},hh=e=>!gh(e.target),yc=({offset:e=mh}={})=>{let{t}=ph(),{getNodes:o,setNodes:n,getEdges:r,setEdges:i}=uh(),{getNextId:a}=xe();fh(()=>{let s=l=>{if(l.ctrlKey&&l.key.toLowerCase()==="d"&&hh(l)){l.preventDefault(),l.stopPropagation();let c=o(),d=r(),u=c.filter(_=>_.selected);if(!u.length)return;let p=new Map,f=[],x=c.some(_=>_.type==="START_EVENT"),g=u.filter(_=>_.type==="START_EVENT"),m=u;if(x&&g.length>0&&(m=u.filter(_=>_.type!=="START_EVENT"),m.length===0))return;let y=d.filter(_=>m.some(v=>v.id===_.source)&&m.some(v=>v.id===_.target)),h=a(),b=m.map(_=>{var S;let v=String(h++);p.set(_.id,v);let w=N(E({},_),{id:v,selected:!0,position:{x:_.position.x+e,y:_.position.y+e}});if(_.type==="TASK"){let L=(S=_.data)==null?void 0:S.label,P=kt(L||t("bpmn.task.label.prefix"),[...c,...f]);w.data=N(E({},_.data),{label:P})}return f.push(w),w}),T=y.map(_=>N(E({},_),{id:String(h++),selected:!0,source:p.get(_.source)||_.source,target:p.get(_.target)||_.target}));n(_=>[..._.map(v=>N(E({},v),{selected:!1})),...b]),i(_=>[..._.map(v=>N(E({},v),{selected:!1})),...T])}};return document.addEventListener("keydown",s,!0),()=>{document.removeEventListener("keydown",s,!0)}},[o,n,r,i,a,e,t])};import{useReactFlow as xh}from"@xyflow/react";var Ec={"start-event":"START_EVENT","end-event":"END_EVENT",task:"TASK","gateway-exclusive":"GATEWAY"},bc={"start-event":"","end-event":"",task:"","gateway-exclusive":"EXCLUSIVE"},xc=(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}},yh=e=>{e=e||"";let t=e.trim().split(`
|
|
36
|
-
`),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=
|
|
37
|
-
`),i=encodeURI(r);
|
|
35
|
+
</mxGraphModel>`,kl=(e,t)=>{if(!e.length&&!t.length)return Yo;let o=[...e.map(r=>r.id),...t.map(r=>r.id)];return Math.max(...o.map(r=>Number(r)))};var qm=e=>{let t=Object.values(Bo),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=bl[a],l=s==null?void 0:s(i,n);if(!l){console.warn(`Node ${a} not supported`);continue}r.push(l)}return r},Zm=(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=_l(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},Jm=(e,t)=>{let o=[];return e.forEach(n=>{var a,s;let r=(s=(a=Nl)[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=vl(n,t);o.push(l)}}),o},Qm=(e,t)=>{let o=[];return e.forEach(n=>{let r=Tl(n,t);o.push(r)}),o},Dl=(e=[],t=[],o)=>{let n=Jm(e,o),r=Qm(t,e),i={mxGraphModel:{root:{_attributes:{version:"1.1",lastId:o},mxCell:[{_attributes:{id:"0"}},{_attributes:{id:"1",parent:"0"}},...n,...r]}}};return ml(JSON.stringify(i),{compact:!0,spaces:0})},Rl=async e=>{var s,l,c,d,u;let t=await cr(e),o=((l=(s=t==null?void 0:t.mxGraphModel)==null?void 0:s.root)==null?void 0:l.mxCell)||[],n=Number(((u=(d=(c=t==null?void 0:t.mxGraphModel)==null?void 0:c.root)==null?void 0:d._attributes)==null?void 0:u.lastId)||Yo),r=qm(o),i=Zm(o,r);return{nodes:wt(Fo(r)),edges:i,lastElementId:n}};import{Position as Pg,useConnection as Lg,useReactFlow as kg}from"@xyflow/react";import{Handle as Ol,useReactFlow as jm}from"@xyflow/react";import{jsx as Vl}from"react/jsx-runtime";var oe=i=>{var a=i,{type:e,position:t,className:o,nodeType:n}=a,r=$e(a,["type","position","className","nodeType"]);let s=n==="TASK";return Vl(Ol,E({type:e,position:t,className:k("size-2.5 border border-grey-400 bg-white relative",{"before:content-[''] before:absolute before:inset-[-16px] before:bg-transparent":s,"before:content-[''] before:absolute before:inset-[-4px] before:bg-transparent":!s},o)},r))},Ie=s=>{var l=s,{nodeId:e,nodeType:t,gatewayVariant:o,type:n,position:r,className:i}=l,a=$e(l,["nodeId","nodeType","gatewayVariant","type","position","className"]);let{getEdges:c,getNodes:d}=jm(),p=(()=>{if(n!=="source")return!1;let f=c();if(t==="TASK")return f.filter(g=>g.source===e).length>=2;if(t==="GATEWAY"&&o==="EXCLUSIVE")return f.filter(g=>g.source===e).length>=2;if(t==="START_EVENT"){let h=d();return f.filter(m=>{if(m.source!==e)return!1;let x=h.find(y=>y.id===m.target);return(x==null?void 0:x.type)!=="ANNOTATION"}).length>=1}return!1})();return Vl(Ol,E({type:n,position:r,className:k("size-2.5 border border-grey-400 bg-white transition-all duration-200 relative",{"before:content-[''] before:absolute before:inset-[-16px] before:bg-transparent":t==="TASK","before:content-[''] before:absolute before:inset-[-4px] before:bg-transparent":t!=="TASK","opacity-50 cursor-not-allowed pointer-events-none":p,"hover:border-grey-500":!p},i),style:{pointerEvents:p?"none":"auto"}},a))};import{NodeResizer as eg,useReactFlow as tg}from"@xyflow/react";import{orderBy as og}from"lodash";import{jsx as ng}from"react/jsx-runtime";var Qt=n=>{var r=n,{nodeId:e,isVisible:t}=r,o=$e(r,["nodeId","isVisible"]);let{getNode:i,getNodes:a,setNodes:s}=tg(),{isMultipleSelection:l}=W(),c=({width:u,height:p})=>{if(!e)return;let f=i(e);if((f==null?void 0:f.type)!=="LANE")return;let h=[...a()],g=!f.parentId,m=g?f.id:f.parentId,x=h.filter(N=>N.type==="LANE"&&N.parentId===m);if(!x.length)return;let y=og(x,["position.y"]),b=0;y.forEach((N,T)=>{var P,H;let _=T===y.length-1,w=(H=(P=N.measured)==null?void 0:P.height)!=null?H:0;h=h.map(C=>{if(C.id===N.id){let I=g?u-ce.HEADER_WIDTH:u,L=v(E({},C),{width:I,measured:v(E({},C.measured),{width:I}),position:v(E({},C.position),{y:b})});return _&&g&&(L.height=p-b),L}return C}),b+=w}),h=h.map(N=>{if(N.id===m){let T=g?u:u+ce.HEADER_WIDTH;return v(E({},N),{width:T,height:g?p:b,measured:{width:T,height:g?p:b}})}return N}),s(h)};return ng(eg,E({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,p)=>c(p)},o))};import{NodeToolbar as _g,useReactFlow as Tg}from"@xyflow/react";import{Button as Ng,Tooltip as vg,TooltipContent as wg,TooltipTrigger as Ig,useTranslation as Ag}from"lecom-ui";import{useCallback as Cg,useRef as Fl,useState as Sg}from"react";import{create as rg}from"zustand";var jt=rg(e=>({draggableNode:null,setDraggableNode:t=>{e({draggableNode:t})}}));import{useEffect as ig,useState as sg}from"react";var Hl=(e,t=!1)=>{let[o,n]=sg({width:0,height:0});return ig(()=>{if(e.current&&t){let r=e.current.getBoundingClientRect();n({width:r.width,height:r.height})}},[t,e]),{dimensions:o}};import{Position as Uo,useReactFlow as ag}from"@xyflow/react";import{useMemo as lg}from"react";var cg=120,dg=12,Gl=(e,t=!1,o)=>{let{getNode:n,getViewport:r}=ag(),{instanceId:i}=W();return lg(()=>{var f,h;if(!t)return{position:Uo.Right,align:"start"};let a=n(e);if(!a)return{position:Uo.Right,align:"start"};let s=r(),l=a.position.x*s.zoom+s.x,c=(((f=a.measured)==null?void 0:f.width)||a.width||100)*s.zoom,d=(h=document.getElementById(`modeler-${i}`))==null?void 0:h.clientWidth;if(!d)return{position:Uo.Right,align:"start"};let u=(o==null?void 0:o.width)||cg;return{position:l+c+u+dg>d?Uo.Left:Uo.Right}},[i,e,t,o,n,r])};import{useNodesData as ug,useReactFlow as pg}from"@xyflow/react";import{Button as Bl,DropdownMenu as fg,DropdownMenuContent as mg,DropdownMenuGroup as gg,DropdownMenuItem as hg,DropdownMenuLabel as yg,DropdownMenuTrigger as xg,Tooltip as ui,TooltipContent as pi,TooltipTrigger as fi,useTranslation as Eg}from"lecom-ui";import{WrenchIcon as bg}from"lucide-react";import{jsx as Ae,jsxs as It}from"react/jsx-runtime";var zl=({nodeId:e})=>{let{t}=Eg(),{updateNodeData:o,getEdges:n,getNode:r}=pg(),i=ug(e),s=n().filter(f=>f.source===e).some(f=>{let h=r(f.target);return(h==null?void 0:h.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 It(fg,{children:[It(ui,{children:[Ae(fi,{asChild:!0,children:Ae(xg,{asChild:!0,children:Ae(Bl,{variant:"ghost",color:"grey",size:"small",iconButton:!0,children:Ae(bg,{})})})}),Ae(pi,{color:"black",children:t("bpmn.task.menu.title")})]}),It(mg,{align:"start",className:"w-60 bg-white text-grey-600",children:[It(yg,{className:"flex items-center gap-1",children:[Ae("div",{className:"flex-1 text-sm font-semibold",children:t("bpmn.task.menu.title")}),Ae("div",{className:"flex items-center gap-1",children:Object.entries(ln).map(([u,p])=>{let f=u==="LOOP"&&(s||l),g=(()=>{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")})();return It(ui,{children:[Ae(fi,{asChild:!0,children:Ae(Bl,{variant:"ghost",color:"grey",size:"small",iconButton:!0,disabled:f,className:k({"bg-grey-100 text-blue-500":(i==null?void 0:i.data.attribute)===u,"opacity-50 cursor-not-allowed":f}),onClick:f?void 0:()=>d(u),children:Ae(p.icon,{className:"stroke-inherit"})})}),g&&Ae(pi,{color:"black",children:g})]},u)})})]}),Ae(gg,{children:It(ui,{children:[Ae(fi,{asChild:!0,children:It(hg,{className:k({"bg-grey-100 text-blue-500":(i==null?void 0:i.data.variant)==="SCRIPT","opacity-50 cursor-not-allowed":s}),disabled:s,onClick:s?void 0:()=>c("SCRIPT"),children:[Ae(an.SCRIPT.icon,{className:"stroke-current"}),t(`bpmn.task.variant.${"SCRIPT".toLowerCase()}`)]})}),s&&Ae(pi,{color:"black",children:t("editor.task_menu.script_not_allowed_when_connected_to_end")})]})})]})]})};import{jsx as ye,jsxs as Wl}from"react/jsx-runtime";var At={START_EVENT:{type:"START_EVENT",icon:go,label:"bpmn.start_event.variant.default"},END_EVENT:{type:"END_EVENT",icon:kt,label:"bpmn.end_event.variant.default"},TASK:{type:"TASK",icon:go,label:"bpmn.task.variant.default"},ANNOTATION:{type:"ANNOTATION",icon:on,label:"bpmn.annotation.variant.default"}},Mg={EXCLUSIVE:{type:"GATEWAY",variant:"EXCLUSIVE",icon:Rt,label:"bpmn.gateway.variant.exclusive"},PARALLEL:{type:"GATEWAY",variant:"PARALLEL",icon:Ot,label:"bpmn.gateway.variant.parallel"},COMPLEX:{type:"GATEWAY",variant:"COMPLEX",icon:Dt,label:"bpmn.gateway.variant.complex"}},Me=({nodeId:e,nodeType:t,nodeVariant:o,isChild:n,isVisible:r})=>{let i=Fl(null),a=Fl(null),{t:s}=Ag(),{setDraggableNode:l}=jt(),{getEdges:c,getNodes:d}=Tg(),{setIsDragging:u,mode:p}=W(),{dimensions:f}=Hl(i,r),{position:h}=Gl(e,r,f),[g,m]=Sg(void 0),x=d(),y=c(),b=o==="SUBPROCESS",N=Cg((A,D)=>{l({type:D.type,variant:D.variant,attribute:D.attribute,icon:D.icon}),D.icon&&m(ye(D.icon,{})),A.dataTransfer.effectAllowed="move",A.dataTransfer.setData("sourceId",e),a.current&&A.dataTransfer.setDragImage(a.current,10,10),setTimeout(()=>{u(!0)},100)},[e,l,u]),T=[{component:ye(er,{elementId:e})}],_=()=>{if(p==="view")return[];let A=!y.some(D=>{var U;return D.source===e&&((U=x.find(F=>F.id===D.target))==null?void 0:U.type)!=="ANNOTATION"});return[{component:ye(Do,{nodeId:e,disabled:!A,tooltipMessage:A?void 0:s("editor.toolbar.start_event_limit_reached")})},At.TASK,At.ANNOTATION,...T]},w=()=>p==="view"?[{component:ye(dt,{elementId:e})}]:[{component:ye(dt,{elementId:e})},...b?[]:[{component:ye(zl,{nodeId:e})}],{component:ye(Do,{nodeId:e})},At.TASK,...Object.values(Mg),...T],P=()=>p==="view"?[{component:ye(dt,{elementId:e})}]:[{component:ye(dt,{elementId:e})},{component:ye(Do,{nodeId:e})},At.TASK,At.ANNOTATION,...T],H=()=>p==="view"?[]:[{component:ye(Do,{nodeId:e})},At.ANNOTATION,...T],C=()=>p==="view"?[]:[...n?[]:[At.ANNOTATION],...T],I=()=>p==="view"?[]:[...T],L=()=>p==="view"?[]:[...T],M=(A=>{switch(A){case"START_EVENT":return _();case"TASK":return w();case"GATEWAY":return P();case"END_EVENT":return H();case"LANE":return C();case"ANNOTATION":return I();case"UNSUPPORTED":return L();default:return[]}})(t);if(!(M.length===0||p==="readonly"))return Wl(_g,{position:h,align:"start",className:"-top-8",isVisible:r,children:[ye("div",{ref:i,className:"flex items-center gap-1 px-3 py-2 bg-white rounded-sm shadow-md",children:M.map((A,D)=>{if(A.component)return ye("div",{children:A.component},D);let U={sourceNodeType:t,targetNodeType:A.type,sourceNodeId:e,nodes:x,edges:y},F=Za(U),te={gateway_limit_reached:s("editor.toolbar.gateway_limit_reached"),start_event_limit_reached:s("editor.toolbar.start_event_limit_reached"),start_event_already_exists:s("editor.toolbar.start_event_already_exists"),script_to_end_not_allowed:s("editor.toolbar.script_to_end_not_allowed"),loop_to_end_not_allowed:s("editor.toolbar.loop_to_end_not_allowed"),initial_activity_to_end_not_allowed:s("editor.toolbar.initial_activity_to_end_not_allowed"),final_activity_cannot_connect:s("editor.toolbar.final_activity_cannot_connect"),activity_has_outgoing_connections:s("editor.toolbar.activity_has_outgoing_connections"),task_limit_reached:s("editor.toolbar.task_limit_reached")},S=F.shouldDisable&&F.reason?te[F.reason]||s(A.label):s(A.label)||"";return Wl(vg,{children:[ye(Ig,{asChild:!0,children:ye(Ng,{variant:"ghost",color:"grey",size:"small",iconButton:!0,draggable:!F.shouldDisable,disabled:F.shouldDisable,className:F.shouldDisable?"opacity-50 cursor-not-allowed":"",onDragStart:F.shouldDisable?void 0:O=>N(O,A),children:A.icon&&ye(A.icon,{size:16})})}),ye(wg,{color:"black",children:S})]},D)})}),ye("div",{ref:a,className:"absolute w-0 h-0 top-0 left-0 z-[-1] bg-transparent",children:g})]})};import{jsx as fr,jsxs as Dg}from"react/jsx-runtime";var Yl=({id:e,data:t,selected:o,dragging:n})=>{let{updateNodeData:r}=kg(),{inProgress:i,fromNode:a}=Lg(),{mode:s,isConnecting:l,isDragging:c,isMultipleSelection:d}=W(),u=i&&(a==null?void 0:a.id)!==e,p=h=>{r(e,{label:h})},f=!l&&!c&&!d;return Dg("div",{className:k("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:[fr(Te,{value:t.label,className:"m-1 text-grey-600",onChange:p}),f&&fr(Me,{nodeId:e,nodeType:"ANNOTATION",isVisible:!n&&o}),s==="edit"&&fr(Qt,{minWidth:pr.MIN_WIDTH,minHeight:pr.MIN_HEIGHT,isVisible:!n&&o}),(!i||u)&&fr(oe,{type:"target",position:Pg.Left,className:k({"annotation-handle":u})})]})};import{Position as pt,useConnection as Rg,useReactFlow as Og}from"@xyflow/react";import{useState as Vg}from"react";import{Fragment as Ul,jsx as Oe,jsxs as mi}from"react/jsx-runtime";var $l=({id:e,data:t,selected:o,dragging:n})=>{let{updateNodeData:r}=Og(),{inProgress:i,fromNode:a}=Rg(),{isConnecting:s,isDragging:l,isMultipleSelection:c,reconnectingEdgeId:d}=W(),[u,p]=Vg(!1),f=i&&(a==null?void 0:a.id)!==e||!!d,h=y=>{r(e,{label:y})},g=()=>{p(!0)},m=()=>{p(!1)},x=!s&&!l&&!c;return mi("div",{className:"relative",onBlur:m,onDoubleClick:g,children:[Oe(kt,{className:k("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})}),Oe("div",{className:"absolute top-9 left-1/2 -translate-x-1/2 max-w-80 w-max",children:Oe(Te,{value:t.label,isEditing:u,onChange:h})}),x&&Oe(Me,{nodeId:e,nodeType:"END_EVENT",isVisible:!n&&o}),(!i||f)&&mi(Ul,{children:[Oe(oe,{type:"target",position:pt.Left,id:"left",className:k({"event-handle":f})}),Oe(oe,{type:"target",position:pt.Right,id:"right",className:k({"event-handle":f})}),Oe(oe,{type:"target",position:pt.Top,id:"top",className:k({"event-handle":f})}),Oe(oe,{type:"target",position:pt.Bottom,id:"bottom",className:k({"event-handle":f})})]}),!i&&mi(Ul,{children:[Oe(oe,{type:"source",position:pt.Left,id:"left"}),Oe(oe,{type:"source",position:pt.Right,id:"right"}),Oe(oe,{type:"source",position:pt.Top,id:"top"}),Oe(oe,{type:"source",position:pt.Bottom,id:"bottom"})]})]})};import{Position as ft,useConnection as Hg,useReactFlow as Gg}from"@xyflow/react";import{useCallback as Bg,useState as zg}from"react";import{Fragment as Xl,jsx as Ve,jsxs as gi}from"react/jsx-runtime";var Kl=({id:e,data:t,selected:o,dragging:n})=>{let r=Wr[t.variant].icon,{updateNodeData:i}=Gg(),{inProgress:a,fromNode:s}=Hg(),{isConnecting:l,isDragging:c,isMultipleSelection:d,reconnectingEdgeId:u}=W(),[p,f]=zg(!1),h=a&&(s==null?void 0:s.id)!==e||!!u,g=Bg(b=>{i(e,{label:b})},[e,i]),m=()=>{f(!0)},x=()=>{f(!1)},y=!l&&!c&&!d;return gi("div",{className:"relative",onBlur:x,onDoubleClick:m,children:[Ve(r,{className:k("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})}),Ve("div",{className:"absolute top-14 left-1/2 -translate-x-1/2 max-w-80 w-max",children:Ve(Te,{value:t.label,isEditing:p,onChange:g})}),y&&Ve(Me,{nodeId:e,nodeType:"GATEWAY",isVisible:!n&&o}),(!a||h)&&gi(Xl,{children:[Ve(oe,{type:"target",position:ft.Left,id:"left",className:k({"gateway-handle":h})}),Ve(oe,{type:"target",position:ft.Right,id:"right",className:k({"gateway-handle":h})}),Ve(oe,{type:"target",position:ft.Top,id:"top",className:k({"gateway-handle":h})}),Ve(oe,{type:"target",position:ft.Bottom,id:"bottom",className:k({"gateway-handle":h})})]}),!a&&gi(Xl,{children:[Ve(Ie,{type:"source",position:ft.Left,id:"left",nodeId:e,nodeType:"GATEWAY",gatewayVariant:t.variant}),Ve(Ie,{type:"source",position:ft.Right,id:"right",nodeId:e,nodeType:"GATEWAY",gatewayVariant:t.variant}),Ve(Ie,{type:"source",position:ft.Top,id:"top",nodeId:e,nodeType:"GATEWAY",gatewayVariant:t.variant}),Ve(Ie,{type:"source",position:ft.Bottom,id:"bottom",nodeId:e,nodeType:"GATEWAY",gatewayVariant:t.variant})]})]})};import{useNodesData as EA,useReactFlow as bA}from"@xyflow/react";import{Button as TA,DropdownMenu as NA,DropdownMenuContent as vA,DropdownMenuGroup as wA,DropdownMenuItem as IA,DropdownMenuLabel as AA,DropdownMenuTrigger as CA,Tooltip as SA,TooltipContent as MA,TooltipTrigger as PA,useTranslation as LA}from"lecom-ui";import{WrenchIcon as DA}from"lucide-react";import{jsx as HA,jsxs as GA}from"react/jsx-runtime";import{Position as mt,useConnection as Fg,useReactFlow as Wg}from"@xyflow/react";import{useState as Yg}from"react";import{Fragment as ql,jsx as He,jsxs as hi}from"react/jsx-runtime";var Zl=({id:e,data:t,selected:o,dragging:n})=>{let{updateNodeData:r}=Wg(),{inProgress:i,fromNode:a}=Fg(),{isConnecting:s,isDragging:l,isMultipleSelection:c,reconnectingEdgeId:d}=W(),[u,p]=Yg(!1),f=i&&(a==null?void 0:a.id)!==e||!!d,h=y=>{r(e,{label:y})},g=()=>{p(!0)},m=()=>{p(!1)},x=!s&&!l&&!c;return hi("div",{className:"relative",onBlur:m,onDoubleClick:g,children:[He(rn,{className:k("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})}),He("div",{className:"absolute top-9 left-1/2 -translate-x-1/2 max-w-80 w-max",children:He(Te,{value:t.label,isEditing:u,onChange:h})}),x&&He(Me,{nodeId:e,nodeType:"START_EVENT",isVisible:!n&&o}),(!i||f)&&hi(ql,{children:[He(oe,{type:"target",position:mt.Left,id:"left",className:k({"event-handle":f})}),He(oe,{type:"target",position:mt.Right,id:"right",className:k({"event-handle":f})}),He(oe,{type:"target",position:mt.Top,id:"top",className:k({"event-handle":f})}),He(oe,{type:"target",position:mt.Bottom,id:"bottom",className:k({"event-handle":f})})]}),!i&&hi(ql,{children:[He(Ie,{type:"source",position:mt.Left,id:"left",nodeId:e,nodeType:"START_EVENT"}),He(Ie,{type:"source",position:mt.Right,id:"right",nodeId:e,nodeType:"START_EVENT"}),He(Ie,{type:"source",position:mt.Top,id:"top",nodeId:e,nodeType:"START_EVENT"}),He(Ie,{type:"source",position:mt.Bottom,id:"bottom",nodeId:e,nodeType:"START_EVENT"})]})]})};import{Position as gt,useConnection as Xg,useReactFlow as Kg}from"@xyflow/react";import{toast as nc,useTranslation as qg}from"lecom-ui";import{useCallback as Zg}from"react";var mr=(e,t)=>{let n=e.filter(i=>i.type==="TASK").map(i=>{var s;let a=(s=i.data)==null?void 0:s.label;if(a&&a.startsWith(`${t} `)){let l=a.match(new RegExp(`^${t} (\\d+)$`));return l?parseInt(l[1],10):0}return 0}).filter(i=>i>0),r=n.length>0?Math.max(...n)+1:1;return`${t} ${r}`},eo=(e,t)=>{let n=t.filter(l=>l.type==="TASK").map(l=>{var c;return(c=l.data)==null?void 0:c.label}).filter(Boolean);if(!n.includes(e))return e;let i=e.replace(/\s+\(\d+\)$/,""),a=n.filter(l=>l===i||l.startsWith(`${i} (`)).map(l=>{if(l===i)return 1;let c=l.match(/\s+\((\d+)\)$/);return c?parseInt(c[1],10):0}).filter(l=>l>0),s=2;for(;a.includes(s);)s++;return`${i} (${s})`};import{jsx as Jl,jsxs as Ug}from"react/jsx-runtime";var Ql=e=>Ug("svg",v(E({width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",xmlns:"http://www.w3.org/2000/svg"},e),{children:[Jl("circle",{cx:"12",cy:"12",r:"10",fill:"#10B981"}),Jl("path",{d:"M7 12L10 15L17 8",stroke:"white",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"})]}));import{jsx as jl}from"react/jsx-runtime";var ec=e=>jl("svg",v(E({width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",xmlns:"http://www.w3.org/2000/svg"},e),{children:jl("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 tc,jsxs as $g}from"react/jsx-runtime";var oc=e=>$g("svg",v(E({width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",xmlns:"http://www.w3.org/2000/svg"},e),{children:[tc("circle",{cx:"12",cy:"12",r:"10",fill:"#EF4444"}),tc("path",{d:"M8 8L16 16M8 16L16 8",stroke:"white",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"})]}));import{Fragment as gr,jsx as fe,jsxs as $o}from"react/jsx-runtime";var Jg={APROVADO:Ql,EM_ANDAMENTO:ec,REJEITADO:oc},yi={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)]"},rc=({id:e,data:t,selected:o,dragging:n})=>{let{t:r}=qg(),{updateNodeData:i,getNodes:a}=Kg(),{inProgress:s,fromNode:l}=Xg(),{mode:c,isConnecting:d,isDragging:u,isMultipleSelection:p,onSubprocessValidationClick:f,reconnectingEdgeId:h}=W(),{getTaskStatus:g}=Et(),m=s&&(l==null?void 0:l.id)!==e||!!h,x=Zg(L=>{let B=L.trim(),M=t.label||"";if(B===M)return;let A=B,D=a();if(!(B&&B!=="")){A=mr(D,r("bpmn.task.label.prefix")),i(e,{label:A}),nc({variant:"warning",content:$o(gr,{children:[r("bpmn.task.feedback.label_empty.prefix")," ",fe("strong",{children:A})]})});return}let F=eo(A,D);F===M||(i(e,{label:F}),F!==A&&nc({variant:"warning",content:$o(gr,{children:[r("bpmn.task.feedback.label_already_exists.prefix")," ",fe("strong",{children:B})," ",r("bpmn.task.feedback.label_already_exists.middle")," ",fe("strong",{children:F})]})}))},[t.label,a,e,r,i]),y=g(e),b=y?Jg[y]:null,N=t.variant?an[t.variant].icon:null,T=t.attribute?ln[t.attribute].icon:null,_=t.variant==="SUBPROCESS",w=N&&!_,P=T||_,H=()=>t.hasError?yi.error:y?yi[y]:yi.default,C=()=>{f==null||f({id:e,type:"sub_process",label:t.label})},I=!d&&!u&&!p;return $o("div",{className:k("relative w-full h-full min-w-44 min-h-24 flex items-center justify-center bg-white border-2 border-grey-400 hover:border-grey-500 rounded-md hover:shadow-md transition-colors duration-75",H(),{"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:[fe(Te,{value:t.label,maxLength:60,className:k("m-1",{"py-6":w||P}),onChange:x}),N&&fe("div",{className:k("absolute flex items-center p-1",_?"bottom-0":"top-0 left-0"),children:fe(N,{size:16,className:k(t.hasError?"text-red-500":"text-grey-500",_&&"cursor-pointer"),onClick:_?C:void 0})}),T&&fe("div",{className:"absolute bottom-0 left-0 w-full flex items-center justify-center",children:fe("div",{className:k("flex items-center w-16 p-1",_?"justify-between":"justify-center"),children:fe(T,{size:16,className:k(t.hasError?"text-red-500":"text-grey-500")})})}),b&&fe("div",{className:"absolute top-0 right-0 flex items-center p-1",children:fe(b,{})}),I&&fe(Me,{nodeId:e,nodeType:"TASK",nodeVariant:t.variant,isVisible:!n&&o}),c==="edit"&&fe(Qt,{minWidth:dr.MIN_WIDTH,minHeight:dr.MIN_HEIGHT,isVisible:!n&&o}),(!s||m)&&$o(gr,{children:[fe(oe,{type:"target",position:gt.Left,id:"left",className:k({"task-handle":m})}),fe(oe,{type:"target",position:gt.Right,id:"right",className:k({"task-handle":m})}),fe(oe,{type:"target",position:gt.Top,id:"top",className:k({"task-handle":m})}),fe(oe,{type:"target",position:gt.Bottom,id:"bottom",className:k({"task-handle":m})})]}),!s&&$o(gr,{children:[fe(Ie,{type:"source",position:gt.Left,id:"left",nodeId:e,nodeType:"TASK"}),fe(Ie,{type:"source",position:gt.Right,id:"right",nodeId:e,nodeType:"TASK"}),fe(Ie,{type:"source",position:gt.Top,id:"top",nodeId:e,nodeType:"TASK"}),fe(Ie,{type:"source",position:gt.Bottom,id:"bottom",nodeId:e,nodeType:"TASK"})]})]})};import{Position as ic}from"@xyflow/react";import{Fragment as Qg,jsx as hr,jsxs as jg}from"react/jsx-runtime";var sc=({id:e,data:t,selected:o,dragging:n})=>{let{isConnecting:r,isDragging:i,isMultipleSelection:a}=W(),s=!r&&!i&&!a;return jg(Qg,{children:[hr("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}),s&&hr(Me,{nodeId:e,nodeType:"UNSUPPORTED",isVisible:!n&&o}),hr(oe,{type:"source",position:ic.Right}),hr(oe,{type:"target",position:ic.Left})]})};import{BaseEdge as eh,EdgeLabelRenderer as th,getSmoothStepPath as oh,MarkerType as nh,useInternalNode as ac,useReactFlow as rh,useViewport as ih,Position as to}from"@xyflow/react";import{useState as sh,useMemo as ah}from"react";import{Fragment as lc,jsx as Ge,jsxs as oo}from"react/jsx-runtime";var xS={type:"MESSAGE_EDGE",reconnectable:!0,markerEnd:{type:nh.Arrow},data:{label:""}},cc=({id:e,source:t,target:o,data:n,selected:r,sourcePosition:i,targetPosition:a,sourceHandleId:s,targetHandleId:l})=>{let{zoom:c}=ih(),{updateEdgeData:d}=rh(),{isMultipleSelection:u,mode:p,instanceId:f}=W(),h=p!=="edit",[g,m]=sh(!1),{reconnectingHandle:x,cursorPosition:y,hoveredNodeId:b,reconnectingSide:N,isValidReconnection:T,handleReconnectStart:_}=sr({edgeId:e,source:t,target:o,instanceId:f,isReadOnly:h}),w=ac(t),P=ac(o),{sx:H,sy:C,tx:I,ty:L,sourcePos:B,targetPos:M}=ah(()=>{var me,le;if(!w||!P)return{sx:0,sy:0,tx:0,ty:0,sourcePos:to.Left,targetPos:to.Right};let K=lt(w,P),ee=s?i:K.sourcePos,R=l?a:K.targetPos,$=(de,be,re)=>{var De,Ze,co,uo,po,fo;let{x:ue,y:pe}=de.internals.positionAbsolute,ae=(co=(Ze=(De=de.measured)==null?void 0:De.width)!=null?Ze:de.width)!=null?co:0,ie=(fo=(po=(uo=de.measured)==null?void 0:uo.height)!=null?po:de.height)!=null?fo:0;switch(be){case to.Top:return{x:ue+ae*re,y:pe};case to.Bottom:return{x:ue+ae*re,y:pe+ie};case to.Left:return{x:ue,y:pe+ie*re};case to.Right:return{x:ue+ae,y:pe+ie*re};default:return{x:ue+ae/2,y:pe+ie/2}}},q=(me=n==null?void 0:n.sourceOffset)!=null?me:.5,z=(le=n==null?void 0:n.targetOffset)!=null?le:.5,V=w?$(w,ee,q).x:K.sx,Z=w?$(w,ee,q).y:K.sy,J=P?$(P,R,z).x:K.tx,ne=P?$(P,R,z).y:K.ty;return x==="source"&&y?(V=y.x,Z=y.y,N&&(ee=N)):x==="target"&&y&&(J=y.x,ne=y.y,N&&(R=N)),{sx:V,sy:Z,tx:J,ty:ne,sourcePos:ee,targetPos:R}},[w,P,s,l,i,a,x,y,N,n==null?void 0:n.sourceOffset,n==null?void 0:n.targetOffset]);if(!w||!P)return null;let[A,D,U]=oh({sourceX:H,sourceY:C,targetX:I,targetY:L,sourcePosition:B,targetPosition:M}),F=r||(w==null?void 0:w.selected)||(P==null?void 0:P.selected),te=F?"sequence-edge-marker-highlighted":"sequence-edge-marker",S=g||(n==null?void 0:n.label.trim().length)>0,O=1/c,Y=()=>{m(!0)},G=()=>{m(!1)},X=K=>{d(e,{label:K.trim()})};return Ge(lc,{children:oo("g",{className:k("text-grey-400 hover:text-grey-500",{"text-blue-500 hover:text-blue-600":F}),onBlur:G,onDoubleClick:Y,children:[Ge(eh,{id:e,path:A,markerEnd:`url(#${te})`,strokeDasharray:4,className:k("stroke-2 stroke-current transition-colors duration-75",{"stroke-red-500 hover:stroke-red-600":(n==null?void 0:n.hasError)||x&&b&&!T,"stroke-green-500":x&&b&&T,"stroke-blue-500 hover:stroke-blue-600 drop-shadow-[0_0_3px_rgba(59,130,246,0.5)]":F&&!(n!=null&&n.hasError)&&!x})}),oo(th,{children:[oo("div",{className:"absolute z-[3000] pointer-events-auto flex flex-col items-center gap-1",style:{transform:`translate(-50%, -50%) translate(${D}px, ${U}px)`},children:[r&&!u&&Ge(Ft,{edgeId:e,edgeType:"MESSAGE_EDGE",style:{transform:`scale(${O})`}}),S&&Ge(Te,{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:g,onChange:X})]}),r&&!u&&!h&&oo(lc,{children:[Ge("div",{className:"absolute z-[1000] pointer-events-none",style:{transform:`translate(-50%, -50%) translate(${H}px, ${C}px)`},children:oo("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:x==="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:x==="source"?.6:.3,className:"pointer-events-none"}),Ge("circle",{cx:6/c,cy:6/c,r:8/c,fill:"transparent",className:k("pointer-events-auto",{"cursor-move":!x||x!=="source","cursor-not-allowed":x==="source"&&b&&!T,"cursor-grabbing":x==="source"&&(!b||T)}),onMouseDown:K=>_("source",K.nativeEvent)})]})}),Ge("div",{className:"absolute z-[1000] pointer-events-none",style:{transform:`translate(-50%, -50%) translate(${I}px, ${L}px)`},children:oo("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:x==="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:x==="target"?.6:.3,className:"pointer-events-none"}),Ge("circle",{cx:6/c,cy:6/c,r:8/c,fill:"transparent",className:k("pointer-events-auto",{"cursor-move":!x||x!=="target","cursor-not-allowed":x==="target"&&b&&!T,"cursor-grabbing":x==="target"&&(!b||T)}),onMouseDown:K=>_("target",K.nativeEvent)})]})})]})]})]})})};import{getStraightPath as lh}from"@xyflow/react";import{jsx as dc,jsxs as ch}from"react/jsx-runtime";var uc=({toX:e,toY:t,fromNode:o})=>{if(!o)return null;let n={id:"connection-target",measured:{width:1,height:1},internals:{positionAbsolute:{x:e,y:t}}},{sx:r,sy:i,tx:a,ty:s}=lt(o,n),[l]=lh({sourceX:r,sourceY:i,targetX:a||e,targetY:s||t});return ch("g",{children:[dc("path",{fill:"none",className:"stroke-2 stroke-grey-400 animated",d:l}),dc("circle",{cx:a||e,cy:s||t,fill:"none",r:4,className:"stroke-2 stroke-grey-500"})]})};import{Position as dh,useReactFlow as uh}from"@xyflow/react";import{orderBy as ph}from"lodash";import{useMemo as pc,useState as fh}from"react";import{Fragment as mh,jsx as Ct,jsxs as fc}from"react/jsx-runtime";var mc=({id:e,data:t,selected:o,dragging:n,parentId:r})=>{let{updateNodeData:i,getNodes:a}=uh(),{mode:s,isConnecting:l,isDragging:c,isMultipleSelection:d}=W(),[u,p]=fh(!1),f=a(),h=!r,g=pc(()=>ph([...f.filter(_=>_.parentId===e&&_.type==="LANE")],"position.y","asc"),[f,e]),m=h?ur.MIN_WIDTH:ce.MIN_WIDTH,x=pc(()=>{if(h&&g.length>1){let _=[...g];return _.pop(),_.reduce((P,H)=>{var C,I;return P+((I=(C=H.measured)==null?void 0:C.height)!=null?I:0)},0)+ce.MIN_HEIGHT}return ce.MIN_HEIGHT},[h,g]),y=_=>{i(e,{label:_})},b=()=>{p(!0)},N=()=>{p(!1)},T=!l&&!c&&!d;return fc(mh,{children:[fc("div",{className:k("flex h-full min-h-64 w-full min-w-[50rem] hover:shadow-md bg-white outline outline-2 outline-grey-400",{"outline-offset-2 outline-blue-500 shadow-sm":o}),children:[Ct("div",{className:"flex align-items justify-center w-10 border-r-2 border-grey-400",onBlur:N,onDoubleClick:b,children:Ct("div",{className:k("relative flex-1",{"[writing-mode:vertical-rl] [text-orientation:sideways] transform rotate-180":!u}),children:Ct(Te,{value:t.label,className:"w-full h-full pointer-events-none self-auto",contentClassName:k({"whitespace-nowrap":u}),isEditing:u,onChange:y})})}),Ct("div",{className:"flex-1"})]}),T&&Ct(Me,{nodeId:e,nodeType:"LANE",isChild:!h,isVisible:!n&&o}),s==="edit"&&Ct(Qt,{nodeId:e,minWidth:m,minHeight:x,isVisible:!n&&o}),h&&Ct(oe,{type:"source",position:dh.Right})]})};var gc={START_EVENT:Zl,END_EVENT:$l,TASK:rc,GATEWAY:Kl,ANNOTATION:Yl,LANE:mc,UNSUPPORTED:sc},hc={SEQUENCE_EDGE:pl,MESSAGE_EDGE:cc,ANNOTATION_EDGE:el},yc="#fafafa",xc="#bebebe",Ec=1,bc=10,_c="bottom-left",Tc=.2,Nc=5,no=.5,ro=.4,io=1,vc={x:0,y:0,zoom:.75},gh=1,hh=2,wc=[gh,hh];import{useReactFlow as yh}from"@xyflow/react";var Be=()=>{let{getEdges:e,getNodes:t}=yh(),{lastElementId:o}=W(),n=()=>{let i=t(),a=e(),s=kl(i,a);return Math.max(s,o)};return{getLastId:n,getNextId:()=>n()+1}};var so=()=>{let{getNodes:e,getEdges:t,setNodes:o,setEdges:n,fitView:r}=xh(),{getLastId:i}=Be(),{setLastElementId:a}=W(),s=Ic(async(c="")=>{let{nodes:d,edges:u,lastElementId:p}=await Rl(c);o(d),n(u),a(p),r({padding:no,minZoom:ro,maxZoom:io})},[o,n,a,r]),l=Ic((c,d)=>{let u=c||e()||[],p=d||t()||[],f=i();return Dl(u,p,f)},[e,t,i]);return{importFromMxGraph:s,exportToMxGraph:l}};import{useCallback as Ac}from"react";var bh=500,yr=()=>{let{isInitialized:e,onElementChanges:t}=W(),{exportToMxGraph:o}=so(),n=Eh(()=>{if(!e)return;let a=o();t==null||t(a)},bh),r=Ac(a=>{a.every(c=>c.type==="select")||a.some(c=>c.type==="position"&&c.dragging)||n()},[n]),i=Ac(a=>{a.some(l=>l.type==="select")||n()},[n]);return{emitElementChanges:n,handleNodeChanges:r,handleEdgeChanges:i}};var Cc=({setEdges:e})=>{let{getNode:t,getEdges:o,getNodes:n}=Th(),{emitElementChanges:r}=yr(),i=Nh(null),{getNextId:a}=Be(),s=St(h=>{var b;let g=t(h.source),m=t(h.target);if(!g||!m)return!1;let x={sourceNodeId:g.id,targetNodeId:m.id,sourceNodeType:g.type,targetNodeType:m.type,nodes:n(),edges:o(),reconnectingEdgeId:(b=i.current)!=null?b:void 0};return si(x).isValid},[t,o,n]),l=St(h=>{let g=a(),m=t(h.target),x=(m==null?void 0:m.type)==="ANNOTATION"?Wt:Ye,y=v(E(E({},h),x),{id:String(g)});e(b=>b.concat(y)),r()},[t,a,e,r]),c=St((h,g)=>{i.current=g.id},[]),d=St(()=>{i.current=null},[]),u=St((h,g)=>{let m=t(g.source),x=t(g.target);if(!m||!x){i.current=null;return}let y={sourceNodeId:m.id,targetNodeId:x.id,sourceNodeType:m.type,targetNodeType:x.type,nodes:n(),edges:o(),reconnectingEdgeId:h.id};if(!si(y).isValid){i.current=null;return}e(N=>_h(h,g,N).map(_=>_.id===h.id?v(E({},_),{data:v(E({},_.data),{points:void 0})}):_)),i.current=null,r()},[t,n,o,e,r]),p=St(h=>{i.current=h},[]),f=St(()=>{i.current=null},[]);return{isValidConnection:s,onConnect:l,onReconnect:u,onReconnectStart:c,onReconnectEnd:d,setReconnectingEdge:p,clearReconnectingEdge:f}};import{useReactFlow as vh}from"@xyflow/react";import{toast as wh,useTranslation as Ih}from"lecom-ui";import{useCallback as Zo,useRef as Vc,useState as Ah}from"react";var Xo=(e=[])=>e.filter(t=>t.type==="START_EVENT"),Mt=(e=[])=>e.filter(t=>t.type==="END_EVENT"),ht=(e=[])=>e.filter(t=>t.type==="TASK")||[],Sc=(e=[])=>e.filter(t=>{var o;return t.type==="TASK"&&((o=t.properties)==null?void 0:o.variant)==="SCRIPT"}),Mc=(e=[])=>e.filter(t=>{var o;return t.type==="TASK"&&((o=t.properties)==null?void 0:o.variant)==="SUBPROCESS"}),xr=(e=[])=>e.filter(t=>t.type==="GATEWAY"),Pc=(e=[])=>e.filter(t=>{var o;return t.type==="GATEWAY"&&((o=t.properties)==null?void 0:o.variant)==="EXCLUSIVE"}),ke=(e,t=[])=>t.filter(o=>o.source===e),Ko=(e,t=[])=>t.filter(o=>o.target===e),Lc=(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"},kc=(e,t)=>{let o=ke(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},Dc=e=>e?/\w/g.test(e.trim()):!1,se=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:[]}},qe=(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)}},Rc=(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 qo=[{id:"start_event_not_found",validate:e=>{let t=Xo(e.nodes);return se({isValid:t.length>=1})}},{id:"end_event_not_found",validate:e=>{let t=Mt(e.nodes);return se({isValid:t.length>=1})}},{id:"multiple_start_event_not_allowed",validate:e=>{let t=Xo(e.nodes),o=t.length===1;if(t.length===0)return se({isValid:!0});if(!o)return se({isValid:!1,nodeIds:t.map(i=>i.id)});let n=ke(t[0].id,e.edges);if(!(n.length<=1)){let i=[...t.map(a=>a.id),...n.map(a=>a.target)];return se({isValid:!1,nodeIds:[...new Set(i)]})}return se({isValid:!0})}},{id:"task_flows_limit_exceeds",validate:e=>{let t=ht(e.nodes),o=qe(t,n=>ke(n.id,e.edges).length<=2);return se({isValid:o.isValid,nodeIds:o.invalidIds})}},{id:"task_label_empty",highlightRelatedEdges:!1,validate:e=>{let t=ht(e.nodes),o=qe(t,n=>!!n.label&&n.label.trim()!=="");return se({isValid:o.isValid,nodeIds:o.invalidIds})}},{id:"task_label_length",highlightRelatedEdges:!1,validate:e=>{let o=ht(e.nodes),n=qe(o,r=>!r.label||r.label.length<=60);return se({isValid:n.isValid,nodeIds:n.invalidIds})}},{id:"duplicate_task_name",highlightRelatedEdges:!1,validate:e=>{let t=ht(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 se({isValid:n.length===0,nodeIds:n})}},{id:"nested_gateway",validate:e=>{let t=xr(e.nodes),o=[],n=[];for(let r of t){let i=ke(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 se({isValid:o.length===0,nodeIds:o.length>0?[...new Set(o)]:[],edgeIds:n})}},{id:"events_nested",validate:e=>{let t=[...Xo(e.nodes),...Mt(e.nodes)],o=[],n=[];for(let r of t){let i=ke(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 se({isValid:o.length===0,nodeIds:o.length>0?[...new Set(o)]:[],edgeIds:n})}},{id:"flows_on_end_tasks_not_allowed",validate:e=>{let t=Mt(e.nodes),o=[],n=[];for(let r of t){let i=Ko(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=ke(s.id,e.edges);l.length>1&&(o.push(s.id),l.forEach(c=>n.push(c.id)))}}}return se({isValid:o.length===0,nodeIds:o,edgeIds:n})}},{id:"conditions_flows_limit_exceeds",validate:e=>{let t=Pc(e.nodes),o=qe(t,r=>ke(r.id,e.edges).length<=2),n=o.invalidIds.flatMap(r=>ke(r,e.edges).map(i=>i.id));return se({isValid:o.isValid,nodeIds:o.invalidIds,edgeIds:n})}},{id:"activity_name_invalid",validate:e=>{let t=ht(e.nodes),o=qe(t,n=>!n.label||Dc(n.label));return se({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 se({isValid:!0});let t=Mt(e.nodes)[0];if(!t)return se({isValid:!0});let o=Ko(t.id,e.edges);if(!o.length)return se({isValid:!0});let r=ht(e.nodes).filter(l=>o.some(c=>c.source===l.id)),i=qe(r,l=>!Lc(l.id,e));return se({isValid:i.isValid,nodeIds:i.isValid?[]:[t.id,...i.invalidIds]})}},{id:"concurrent_initial_and_final_event",validate:e=>{let t=ht(e.nodes),o=Mt(e.nodes)[0];if(!o)return se({isValid:!0});let n=t.filter(l=>{let c=Ko(l.id,e.edges),d=ke(l.id,e.edges),u=c.some(f=>{var h;return((h=e.nodes.find(g=>g.id===f.source))==null?void 0:h.type)==="START_EVENT"}),p=d.some(f=>{var h;return((h=e.nodes.find(g=>g.id===f.target))==null?void 0:h.type)==="END_EVENT"});return u&&p}),r=Ko(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 se(s)}},{id:"gateway_flow_to_event",validate:e=>{let t=xr(e.nodes),o=[],n=[];for(let r of t){let i=ke(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 se({isValid:o.length===0,nodeIds:o.length>0?[...new Set(o)]:[],edgeIds:n})}},{id:"gateway_missing_output_streams",validate:e=>{let t=xr(e.nodes),o=qe(t,n=>ke(n.id,e.edges).length>=1);return se({isValid:o.isValid,nodeIds:o.invalidIds})}},{id:"event_to_condition",validate:e=>{let t=[...Xo(e.nodes),...Mt(e.nodes)],o=[],n=[];for(let r of t){let i=ke(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 se({isValid:o.length===0,nodeIds:o.length>0?[...new Set(o)]:[],edgeIds:n})}},{id:"script_in_final_activity",validate:e=>{let t=Sc(e.nodes),o=qe(t,n=>!kc(n.id,e));return se({isValid:o.isValid,nodeIds:o.invalidIds})}},{id:"subprocess_referenced_not_configured",validate:e=>{let t=Mc(e.nodes),o=qe(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 se({isValid:o.isValid,nodeIds:o.invalidIds})}}];var Oc=e=>{e=e||{nodes:[],edges:[]},e.nodes=e.nodes||[],e.edges=e.edges||[];let t=[];for(let n of qo){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 Er,jsxs as Ch}from"react/jsx-runtime";var Hc=()=>{let{t:e}=Ih(),{setNodes:t,setEdges:o,getNodes:n,getEdges:r}=vh(),[i,a]=Ah(!1),s=Vc(!1),l=Vc(!1),c=Zo(h=>{let g=Rc(h.nodes,h.edges),m=Oc(g),x=m.errors.map(y=>v(E({},y),{message:e(`validation.errors.${y.id}`)}));return i||a(!0),{isValid:m.isValid,errors:x}},[i,e]),d=Zo((h,g=!0)=>{if(g&&h&&wh({variant:h.isValid?"success":"error",duration:5e3,title:h.isValid?e("validation.success.title"):e("validation.errors.title"),content:Ch("div",{className:"flex flex-col gap-1",children:[!h.isValid&&Er("span",{className:"body-small-500",children:e("validation.errors.subtitle")}),Er("ul",{className:"list-disc list-inside max-h-40 overflow-y-auto",children:h.isValid?Er("li",{children:e("validation.success.message")}):h.errors.map(C=>Er("li",{className:"text-xs",children:C.message},C.id))})]})}),!h)return;s.current=!0,l.current=!0;let m=[],x=[];h.errors.forEach(C=>{C.nodeIds&&C.nodeIds.length>0&&C.nodeIds.forEach(I=>m.push(I)),C.edgeIds&&C.edgeIds.length>0&&C.edgeIds.forEach(I=>x.push(I))});let y=[...new Set(m)];t(C=>C.map(I=>v(E({},I),{data:v(E({},I.data),{hasError:!1})}))),o(C=>C.map(I=>v(E({},I),{data:v(E({},I.data),{hasError:!1})})));let b=n(),N=r(),T=new Set(y),_=new Set;h.errors.forEach(C=>{var B,M;let I=qo.find(A=>A.id===C.id);(I==null?void 0:I.highlightRelatedEdges)!==!1&&((B=C.edgeIds)==null||B.forEach(A=>_.add(A)),(M=C.nodeIds)==null||M.forEach(A=>{N.forEach(D=>{(D.source===A||D.target===A)&&_.add(D.id)})}))});let w=new Set,P=new Set,H=new Set;b.forEach(C=>{C.type==="START_EVENT"?w.add(C.id):C.type==="END_EVENT"&&P.add(C.id)}),N.forEach(C=>{w.has(C.source)&&H.add(C.target),P.has(C.target)&&H.add(C.source)}),H.forEach(C=>{var I,L;if(T.has(C)){let B=(I=h.errors.find(A=>{var D;return(D=A.nodeIds)==null?void 0:D.includes(C)}))==null?void 0:I.id;((L=qo.find(A=>A.id===B))==null?void 0:L.highlightRelatedEdges)!==!1&&N.forEach(A=>{A.source===C&&P.has(A.target)&&(T.add(A.target),_.add(A.id)),A.target===C&&w.has(A.source)&&(T.add(A.source),_.add(A.id))})}}),T.size>0&&t(C=>C.map(I=>v(E({},I),{data:v(E({},I.data),{hasError:T.has(I.id)})}))),_.size>0&&o(C=>C.map(I=>v(E({},I),{data:v(E({},I.data),{hasError:_.has(I.id)})}))),setTimeout(()=>{s.current=!1},0)},[e,r,n,o,t]),u=Zo(()=>{a(!1),l.current=!1,t(h=>h.map(g=>v(E({},g),{data:v(E({},g.data),{hasError:!1})}))),o(h=>h.map(g=>v(E({},g),{data:v(E({},g.data),{hasError:!1})})))},[o,t]),p=Zo(()=>{l.current&&(s.current=!0,l.current=!1,t(h=>h.map(g=>v(E({},g),{data:v(E({},g.data),{hasError:!1})}))),o(h=>h.map(g=>v(E({},g),{data:v(E({},g.data),{hasError:!1})}))),setTimeout(()=>{s.current=!1},0))},[o,t]),f=Zo(()=>s.current,[]);return{validateDiagram:c,handleValidationComplete:d,clearValidation:u,dismissValidationPanel:p,isAutoValidationEnabled:i,getIsClearingValidation:f}};import{useReactFlow as Sh}from"@xyflow/react";import{useTranslation as Mh}from"lecom-ui";import{useEffect as Ph}from"react";var Lh=15,Gc="bpmn:selection",kh=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},Bc=e=>{if(!kh(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},zc=({offset:e=Lh}={})=>{let{t}=Mh(),{getNodes:o,setNodes:n,getEdges:r,setEdges:i}=Sh(),{getNextId:a}=Be();Ph(()=>{let s=c=>{var m,x;if(!Bc(c))return;let d=o(),u=r(),p=d.filter(y=>y.selected);if(!p.length)return;c.preventDefault(),c.stopPropagation();let f=u.filter(y=>p.some(b=>b.id===y.source)&&p.some(b=>b.id===y.target)),g=JSON.stringify({nodes:p,edges:f});(m=c.clipboardData)==null||m.setData(Gc,g),(x=c.clipboardData)==null||x.setData("text/plain",`BPMN Selection: ${p.length} nodes`)},l=c=>{var T,_;if(!Bc(c))return;let d=(T=c.clipboardData)==null?void 0:T.getData(Gc);if(!d)return;c.preventDefault(),c.stopPropagation();let u;try{u=JSON.parse(d)}catch(w){return}if(!((_=u.nodes)!=null&&_.length))return;let p=new Map,f=o(),h=[],g=f.some(w=>w.type==="START_EVENT"),m=u.nodes.filter(w=>w.type==="START_EVENT"),x=u.nodes;if(g&&m.length>0&&(x=u.nodes.filter(w=>w.type!=="START_EVENT"),x.length===0))return;let y=a(),b=x.map(w=>{var C;let P=String(y++);p.set(w.id,P);let H=v(E({},w),{id:P,selected:!0,position:{x:w.position.x+e,y:w.position.y+e}});if(w.type==="TASK"){let I=(C=w.data)==null?void 0:C.label,L=eo(I||t("bpmn.task.label.prefix"),[...f,...h]);H.data=v(E({},w.data),{label:L})}return h.push(H),H}),N=u.edges.map(w=>v(E({},w),{id:String(y++),selected:!0,source:p.get(w.source)||w.source,target:p.get(w.target)||w.target}));n(w=>[...w.map(P=>v(E({},P),{selected:!1})),...b]),i(w=>[...w.map(P=>v(E({},P),{selected:!1})),...N])};return document.addEventListener("copy",s,!0),document.addEventListener("paste",l,!0),()=>{document.removeEventListener("copy",s,!0),document.removeEventListener("paste",l,!0)}},[o,n,r,i,a,e,t])};import{useReactFlow as Dh,useStoreApi as Rh}from"@xyflow/react";import{useTranslation as Oh}from"lecom-ui";import{useState as Vh}from"react";var Fc=({nodes:e,setNodes:t,setEdges:o})=>{let n=Rh(),{draggableNode:r,setDraggableNode:i}=jt(),{t:a}=Oh(),{getInternalNode:s,screenToFlowPosition:l}=Dh(),{getNextId:c}=Be(),{setIsDragging:d}=W(),{rebuildIndex:u,forceRebuildIndex:p}=Bn(),[f,h]=Vh(null),g=(I,L=!1)=>{let B=L?"[&>div]:bg-red-50 [&>div]:outline [&>div]:outline-[3px] [&>div]:outline-red-500":"[&>div]:bg-green-50/75 [&>div]:outline [&>div]:outline-[3px] [&>div]:outline-green-500";t(M=>M.map(A=>v(E({},A),{className:A.id===I?B:""})))},m=()=>{let{nodeLookup:I}=n.getState();return Array.from(I.values())},x=I=>{let L=s(I.id),B=m();if(I.type==="LANE"){if(Jt({parentId:I.id,nodes:e,includeTypes:["LANE"]})){g();return}let te=B.filter(Y=>Y.id!==I.id&&Y.type==="LANE"&&!Y.parentId),S=zo(L,te);if(!S){g();return}if(Jt({parentId:S.id,nodes:e,excludeTypes:["LANE"]})){g(S.id,!0);return}g(S.id);return}let A=B.filter(F=>F.id!==I.id&&F.type==="LANE"),D=zo(L,A);if(!D){g();return}if(Jt({parentId:D.id,nodes:e,includeTypes:["LANE"]})){g();return}g(D.id)},y=I=>I.map(L=>v(E({},L),{className:void 0})),b=I=>I.some(B=>B.dragging)?I.map(B=>B.dragging?v(E({},B),{dragging:!1}):B):I,N=I=>{I.preventDefault(),I.dataTransfer.dropEffect="move"},T=(I,L)=>{I.preventDefault(),x(L)},_=(I,L,B)=>{var F,te;let M=[...B];if(I.parentId===L.id)return M=Sl(I,L,M),M=Fo(M),y(M);if(I.type==="LANE"){if(Jt({parentId:L.id,nodes:M,excludeTypes:["LANE"]})){let X=Le(L),K=50,ee=50;return M.map(R=>{var $,q;return R.id===I.id?v(E({},R),{position:{x:($=f==null?void 0:f.x)!=null?$:X.x+K,y:(q=f==null?void 0:f.y)!=null?q:X.y2+ee}}):R})}let Y=M.filter(X=>X.parentId===L.id).reduce((X,K)=>{var ee,R;return X+((R=(ee=K.measured)==null?void 0:ee.height)!=null?R:0)},0),G={x:ce.HEADER_WIDTH,y:Y};return M=M.map(X=>X.id===I.id?v(E({},X),{parentId:L.id,position:G,className:void 0}):v(E({},X),{className:void 0})),M=Wo(L.id,M),M}if(Jt({parentId:L.id,nodes:M,includeTypes:["LANE"]})){let S;if(I.parentId){let O=s(I.parentId),{x:Y,y:G}=et(O);S={x:Y+((F=I.position.x)!=null?F:0),y:G+((te=I.position.y)!=null?te:0)}}return M=M.map(O=>O.id===I.id?v(E({},O),{position:S!=null?S:O.position,parentId:void 0,className:void 0}):v(E({},O),{className:void 0})),M}let U=wl(I,L);return M=M.map(S=>{if(S.id===I.id){let O=Le(I),Y=Le(L);return O.y<Y.y&&(U.y=0),O.x<Y.x+ce.HEADER_WIDTH&&(U.x=ce.HEADER_WIDTH),v(E({},S),{parentId:L.id,position:U,className:void 0})}return v(E({},S),{className:void 0})}),M=Fo(M),M},w=I=>{if(I.preventDefault(),!(r!=null&&r.type))return;let L=l({x:I.clientX,y:I.clientY}),B={width:j[r.type].MIN_WIDTH,height:j[r.type].MIN_HEIGHT},M=c(),A={id:String(M),type:r.type,position:L,measured:B,data:{label:r.type==="TASK"?mr(e,a("bpmn.task.label.prefix")):"",variant:r.variant,attribute:r.attribute},selected:!0},D=v(E({},A),{internals:{positionAbsolute:L}}),U=m(),F=r.type==="LANE",te=U.filter(G=>F?G.type==="LANE"&&!G.parentId:G.type==="LANE"),S=zo(D,te),O=[...e.map(G=>v(E({},G),{selected:!1})),A];S&&(O=_(D,S,O)),O=wt(O),t(O),p();let Y=I.dataTransfer.getData("sourceId");if(Y){let G={id:String(M+1),source:Y,target:A.id};if(r.type==="ANNOTATION"){o(X=>X.concat(E(E({},G),Wt)));return}o(X=>X.concat(E(E({},G),Ye)))}d(!1),i(null)},P=async(I,L,B)=>{let M=[...e];B.forEach(A=>{let D=m(),U=s(A.id),F=A.type==="LANE",te=D.filter(O=>O.id!==A.id&&(F?O.type==="LANE"&&!O.parentId:O.type==="LANE")),S=zo(U,te);if(S){M=_(U,S,M);return}A.parentId&&(M=C(A,M))}),M=b(M),M=wt(M),M=y(M),t(M),u(M),h(null)},H=(I,L)=>{h({x:L.position.x,y:L.position.y})},C=(I,L)=>{var U,F;let B=s(I.parentId),{x:M,y:A}=et(B),D={x:M+((U=I.position.x)!=null?U:0),y:A+((F=I.position.y)!=null?F:0)};return L=L.map(te=>te.id===I.id?v(E({},te),{position:D,parentId:void 0}):te),L=Wo(I.parentId,L),L};return{onDragOver:N,onDrop:w,onNodeDrag:T,onNodeDragStart:H,onNodeDragStop:P}};import{useReactFlow as Hh}from"@xyflow/react";import{useTranslation as Gh}from"lecom-ui";import{useEffect as Bh}from"react";var zh=30,Fh=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},Wh=e=>!Fh(e.target),Wc=({offset:e=zh}={})=>{let{t}=Gh(),{getNodes:o,setNodes:n,getEdges:r,setEdges:i}=Hh(),{getNextId:a}=Be();Bh(()=>{let s=l=>{if(l.ctrlKey&&l.key.toLowerCase()==="d"&&Wh(l)){l.preventDefault(),l.stopPropagation();let c=o(),d=r(),u=c.filter(T=>T.selected);if(!u.length)return;let p=new Map,f=[],h=c.some(T=>T.type==="START_EVENT"),g=u.filter(T=>T.type==="START_EVENT"),m=u;if(h&&g.length>0&&(m=u.filter(T=>T.type!=="START_EVENT"),m.length===0))return;let x=d.filter(T=>m.some(_=>_.id===T.source)&&m.some(_=>_.id===T.target)),y=a(),b=m.map(T=>{var P;let _=String(y++);p.set(T.id,_);let w=v(E({},T),{id:_,selected:!0,position:{x:T.position.x+e,y:T.position.y+e}});if(T.type==="TASK"){let H=(P=T.data)==null?void 0:P.label,C=eo(H||t("bpmn.task.label.prefix"),[...c,...f]);w.data=v(E({},T.data),{label:C})}return f.push(w),w}),N=x.map(T=>v(E({},T),{id:String(y++),selected:!0,source:p.get(T.source)||T.source,target:p.get(T.target)||T.target}));n(T=>[...T.map(_=>v(E({},_),{selected:!1})),...b]),i(T=>[...T.map(_=>v(E({},_),{selected:!1})),...N])}};return document.addEventListener("keydown",s,!0),()=>{document.removeEventListener("keydown",s,!0)}},[o,n,r,i,a,e,t])};import{useReactFlow as Uh}from"@xyflow/react";var Uc={"start-event":"START_EVENT","end-event":"END_EVENT",task:"TASK","gateway-exclusive":"GATEWAY"},$c={"start-event":"","end-event":"",task:"","gateway-exclusive":"EXCLUSIVE"},Yc=(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}},Yh=e=>{e=e||"";let t=e.trim().split(`
|
|
36
|
+
`),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=Yc(i[0],o),s=Yc(i[1],o);a&&s&&n.push({sourceId:a.step,targetId:s.step,label:a.edgeLabel||s.edgeLabel||""})}),{components:o,connections:n}},Xc=e=>{let{components:t,connections:o}=Yh(e);return{nodes:t,edges:o}};var Kc=()=>{let{setNodes:e,setEdges:t,fitView:o}=Uh(),{getNextId:n}=Be();return{importFromLia:i=>{let a=typeof i=="string"?i:i.diagramXml||"",{nodes:s,edges:l}=Xc(a),c=[],d=new Map,u=!1,p=n();for(let[m,x]of Object.entries(s)){let y=String(p++),b=Uc[x.type],N=$c[x.type];b==="START_EVENT"&&(u=!0),d.set(m,y);let T=j[b].MIN_WIDTH,_=j[b].MIN_HEIGHT;c.push({id:y,type:b,data:{label:x.label||"",variant:N,attribute:""},position:{x:0,y:0},width:T,height:_,measured:{width:T,height:_}})}let f=[];for(let m of l){let x=v(E({},Ye),{id:String(p++),source:d.get(m.sourceId)||m.sourceId,target:d.get(m.targetId)||m.targetId});f.push(x)}if(!u&&c.length>0){let m=String(p++),x={id:m,type:"START_EVENT",data:{label:"",variant:"",attribute:""},position:{x:0,y:0},width:j.START_EVENT.MIN_WIDTH,height:j.START_EVENT.MIN_HEIGHT,measured:{width:j.START_EVENT.MIN_WIDTH,height:j.START_EVENT.MIN_HEIGHT}};c.unshift(x);let y=c[1];if(y){let b=v(E({},Ye),{id:String(p++),source:m,target:y.id});f.unshift(b)}}let{nodes:h,edges:g}=Cl(c,f);e(h),t(g),o({padding:no,minZoom:ro,maxZoom:io})}}};import{useEffect as $h,useCallback as Xh}from"react";var Kh={origin:"*",debug:!1};function qc(e,t=Kh){let{origin:o,debug:n}=t,r=Xh((i,a)=>{let s={event:i,data:[i,{event:i,data:a}]};window.parent.postMessage(s,o||"*")},[o]);return $h(()=>{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 qh}from"@xyflow/react";import{useEffect as Zc}from"react";var Jc=()=>{let e=qh(),{initialDiagram:t,setIsInitialized:o}=W(),{importFromMxGraph:n}=so();Zc(()=>{t&&n(t)},[t,n,o]),Zc(()=>{if(!e)return;(async()=>{await nn(),o(!0)})()},[e,o])};import{useCallback as Qc}from"react";import{useReactFlow as Zh}from"@xyflow/react";function jc(){let{setTaskStatuses:e,clearTaskStatuses:t,calculateFlowPath:o}=Et(),{getEdges:n}=Zh(),r=cn(),i=Qc(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=Qc(()=>{t(),setTimeout(()=>{r()},0)},[t,r]);return{handleTasksStatus:i,handleClearTaskStatus:a}}import{useReactFlow as Jh}from"@xyflow/react";import{useCallback as ao,useState as ed,useEffect as Qh}from"react";import{useDebouncedCallback as jh}from"use-debounce";var td=[{nodes:[],edges:[]}],e0=500,od=100,nd=(e=td)=>{let{getNodes:t,getEdges:o,setNodes:n,setEdges:r}=Jh(),[i,a]=ed(e),[s,l]=ed(0),c=i[s],d=s>0,u=s<i.length-1,p=ao(N=>{n(i[N].nodes),r(i[N].edges)},[i,n,r]),f=ao(()=>{if(s>0){let N=s-1;l(N),p(N)}},[s,p]),h=ao(()=>{if(s<i.length-1){let N=s+1;l(N),p(N)}},[i,s,p]),g=N=>{let _=[...i.slice(0,s+1),N],w=_.length>od?_.slice(_.length-od):_;a(w),l(w.length-1)},m=jh(()=>{let N=t(),T=o(),_=N.map(H=>v(E({},H),{selected:!1,className:""})),w={nodes:wt(_),edges:T};JSON.stringify(c)!==JSON.stringify(w)&&g(w)},e0),x=ao(N=>{if(N==="forceSave"){m();return}N.some(w=>w.type==="select")||N.some(w=>w.type==="position"&&w.dragging)||m()},[m]),y=ao(N=>{a(N||td),l(0)},[]),b=ao(()=>{a([]),l(0)},[]);return Qh(()=>{let N=T=>{(T.ctrlKey||T.metaKey)&&(T.shiftKey&&T.key.toLowerCase()==="z"?(T.preventDefault(),h()):T.key.toLowerCase()==="z"&&(T.preventDefault(),f()))};return document.addEventListener("keydown",N),()=>{document.removeEventListener("keydown",N)}},[f,h]),{history:i,undo:f,redo:h,canUndo:d,canRedo:u,saveHistory:x,resetHistory:y,clearHistory:b}};var rd=()=>{let[e,t,o]=o0([]),[n,r,i]=t0([]),{instanceId:a,setIsConnecting:s,setIsMultipleSelection:l,onElementClick:c}=W(),{updateHelperLines:d,HelperLines:u}=Bn(),{undo:p,redo:f,canUndo:h,canRedo:g,saveHistory:m}=nd(),{onNodeDrag:x,onDrop:y,onDragOver:b,onNodeDragStop:N,onNodeDragStart:T}=Fc({nodes:e,setNodes:t,setEdges:r}),{isValidConnection:_,onConnect:w,onReconnect:P,onReconnectStart:H,onReconnectEnd:C,setReconnectingEdge:I,clearReconnectingEdge:L}=Cc({setEdges:r}),{handleValidationComplete:B,clearValidation:M,dismissValidationPanel:A,validateDiagram:D,getIsClearingValidation:U}=Hc(),{importFromLia:F}=Kc(),{handleTasksStatus:te,handleClearTaskStatus:S}=jc(),{clearPathEdges:O}=Et(),Y=cn(),{emitElementChanges:G,handleNodeChanges:X,handleEdgeChanges:K}=yr();zc(),Wc(),Jc();let ee=br(()=>{t([]),r([]),O(),setTimeout(()=>{Y()},0)},[t,r,O,Y]);qc({LIA_CREATE_DIAGRAM:F,CLEAR_DIAGRAM:ee,TASKS_STATUS:te,CLEAR_TASKS_STATUS:S});let{selectElements:R,clearSelection:$}=ct(),{importFromMxGraph:q,exportToMxGraph:z}=so(),{configureElement:V,getConfigureElement:Z}=Jn();r0(()=>(Ke.set(a,{importFromMxGraph:q,exportToMxGraph:z,selectElements:R,clearSelection:$,configureElement:V,getConfigureElement:Z,setReconnectingEdge:I,clearReconnectingEdge:L}),()=>{Ke.delete(a)}),[a,q,z,R,$,V,Z,I,L]);let J=br((re,ue)=>{let pe=Z(ue.id);pe&&(c==null||c(pe))},[Z,c]),ne=br(re=>{let ue=d(re,e);o(ue),m(re),U()||A(),X(re)},[e,o,m,U,A,d,X]),me=br(re=>{i(re),m(re),U()||A(),K(re)},[i,m,U,A,K]);return n0({onChange:({nodes:re,edges:ue})=>{l(re.length+ue.length>1)}}),{nodes:e,setNodes:t,edges:n,setEdges:r,events:{isValidConnection:_,onConnect:w,onReconnect:P,onReconnectStart:H,onReconnectEnd:C,onDrop:y,onDragOver:b,onNodeDrag:x,onNodeDragStop:N,onNodeDragStart:T,onNodeClick:J,onDropCapture:()=>{m("forceSave"),G(),A()},onConnectStart:()=>{s(!0)},onConnectEnd:()=>{s(!1),A()},onNodesChange:ne,onEdgesChange:me},ui:{handleCloseValidationPanel:M},controls:{undo:p,redo:f,canUndo:h,canRedo:g},components:{HelperLines:u},actions:{saveHistory:m,selectElements:R,clearSelection:$,exportToMxGraph:z,validateDiagram:D,handleValidationComplete:B,setReconnectingEdge:I,clearReconnectingEdge:L}}};import{jsx as id}from"react/jsx-runtime";var xi=({id:e,className:t})=>id("marker",{id:e,className:k("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:id("path",{d:"M 0 0 L 10 5 L 0 10 Z"})});import{jsx as Ei,jsxs as i0}from"react/jsx-runtime";var sd=()=>Ei("svg",{style:{position:"absolute",top:0,left:0},children:i0("defs",{children:[Ei(xi,{id:"sequence-edge-marker",className:"text-grey-400"}),Ei(xi,{id:"sequence-edge-marker-highlighted",className:"text-blue-500"})]})});import{useKeyPress as Nd,useReactFlow as q0}from"@xyflow/react";import{Button as Ir,Tooltip as Ar,TooltipContent as Cr,TooltipTrigger as Sr,useTranslation as Z0}from"lecom-ui";import{HandIcon as J0,ListCheckIcon as Q0,MapIcon as j0,MousePointerIcon as ey}from"lucide-react";import{useCallback as Ni,useEffect as vd}from"react";import{Tooltip as I0,TooltipContent as A0,TooltipTrigger as C0,useNotificationToast as S0,useTranslation as M0}from"lecom-ui";var Jo=(y=>(y.START_EVENT="START_EVENT",y.END_EVENT="END_EVENT",y.TASK="TASK",y.SUBPROCESS="SUBPROCESS",y.GATEWAY="GATEWAY",y.LANE="LANE",y.ANNOTATION="ANNOTATION",y.CONNECTION="CONNECTION",y.INTERMEDIATE_EVENT="INTERMEDIATE_EVENT",y.ACTIVITY="ACTIVITY",y.PROCESS_INTERFACE="PROCESS_INTERFACE",y.WORKFLOW_INTERFACE="WORKFLOW_INTERFACE",y.VARIANT_ACTIVITY="VARIANT_ACTIVITY",y.AUTO_ACTIVITY="AUTO_ACTIVITY",y.DATA_STORE="DATA_STORE",y.DATA_OBJECT="DATA_OBJECT",y.DATA_OUTPUT="DATA_OUTPUT",y.DATA_INPUT="DATA_INPUT",y))(Jo||{});import{useReactFlow as y0}from"@xyflow/react";import{useNotificationToast as x0,useTranslation as E0,Button as b0}from"lecom-ui";var ad=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 ld({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(`
|
|
37
|
+
`),i=encodeURI(r);_r(i,`${o}.csv`)}var _r=(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 cd(e){return e==null?void 0:e.replaceAll("
"," ")}var q6={START_EVENT:"START_EVENT",END_EVENT:"END_EVENT",TASK:"TASK",GATEWAY:"GATEWAY",ANNOTATION:"ANNOTATION"},dd={script:"SCRIPT",subprocess:"SUBPROCESS"},ud={complex:"COMPLEX",none:"EXCLUSIVE",exclusive:"EXCLUSIVE",parallel:"PARALLEL"};var Pt=({cell:e,type:t,variant:o=""})=>{let{_attributes:n,mxGeometry:r}=e,{value:i,parent:a}=n,s=Number(r._attributes.width),l=Number(r._attributes.height),c=a==="1"?void 0:a;return{id:n.id,parentId:c,type:t,data:{label:i||"",variant:o,attribute:""},position:{x:Number(r._attributes.x)||0,y:Number(r._attributes.y)||0},width:s,height:l,measured:{width:s,height:l}}},a0=e=>{let{subType:t,style:o}=e._attributes,n="imported";return["none"].includes(t)||(n="adapted"),e.mxGeometry._attributes.width=j.START_EVENT.MIN_WIDTH,e.mxGeometry._attributes.height=j.START_EVENT.MIN_HEIGHT,{node:Pt({cell:e,type:"START_EVENT"}),status:n,originalType:o}},l0=e=>{let{subType:t,style:o}=e==null?void 0:e._attributes,n="imported";return["none"].includes(t)||(n="adapted"),e.mxGeometry._attributes.width=j.END_EVENT.MIN_WIDTH,e.mxGeometry._attributes.height=j.END_EVENT.MIN_HEIGHT,{node:Pt({cell:e,type:"END_EVENT"}),status:n,originalType:o}},c0=e=>{let{subType:t,style:o}=e==null?void 0:e._attributes,n=dd[t],r="imported";return["script","none"].includes(t)||(r="adapted"),e.mxGeometry._attributes.width=ot(e.mxGeometry._attributes.width||0,j.TASK.MIN_WIDTH),e.mxGeometry._attributes.height=ot(e.mxGeometry._attributes.height||0,j.TASK.MIN_HEIGHT),{node:Pt({cell:e,type:"TASK",variant:n}),status:r,originalType:o}},d0=e=>{let{style:t,subType:o}=e==null?void 0:e._attributes,n=ud[o],r=["none","inclusive","event-based"],i="imported";return r.includes(o)&&(i="adapted"),e.mxGeometry._attributes.width=j.GATEWAY.MIN_WIDTH,e.mxGeometry._attributes.height=j.GATEWAY.MIN_HEIGHT,{node:Pt({cell:e,type:"GATEWAY",variant:n}),status:i,originalType:t}},u0=e=>{let{style:t}=e==null?void 0:e._attributes;return{node:Pt({cell:e,type:"LANE"}),status:"imported",originalType:t}},p0=e=>{let{style:t}=e==null?void 0:e._attributes;return e.mxGeometry._attributes.width=ot(e.mxGeometry._attributes.width||0,j.ANNOTATION.MIN_WIDTH),e.mxGeometry._attributes.height=ot(e.mxGeometry._attributes.height||0,j.ANNOTATION.MIN_HEIGHT),{node:Pt({cell:e,type:"ANNOTATION"}),status:"imported",originalType:t}},pd=e=>{let{style:t}=e==null?void 0:e._attributes;return e.mxGeometry._attributes.width=j.UNSUPPORTED.MIN_WIDTH,e.mxGeometry._attributes.height=j.UNSUPPORTED.MIN_HEIGHT,{node:Pt({cell:e,type:"UNSUPPORTED"}),status:"unsupported",originalType:t}},fd=(e,t)=>{let{id:o,source:n,target:r,value:i}=e._attributes;return v(E({},Ye),{id:o,source:t.get(n)||n,target:t.get(r)||r,data:{label:i||""}})},md={TASK:c0,GATEWAY:d0,START_EVENT:a0,END_EVENT:l0,LANE:u0,ANNOTATION:p0};var f0=e=>{let t=new Map,o=Object.values(Jo),n=e.filter(a=>{var l;let s=(l=a._attributes)==null?void 0:l.type;return o.includes(s)}),r=[],i=[];for(let a of n){let{type:s}=a._attributes,l=md[s]||pd,{node:c,status:d,originalType:u}=l(a);i.push(c),r.push({originalType:u,type:c.type,variant:c.data.variant,value:cd(c.data.label),status:d})}return{nodes:i,governanceIdToNodeIdMap:t,summary:r}},m0=(e,t)=>e.filter(r=>{var i;return(i=r._attributes)==null?void 0:i.edge}).map(r=>fd(r,t)),g0=e=>{let{mxGraphModel:t}=e,{nodes:o,governanceIdToNodeIdMap:n,summary:r}=f0(t.root.mxCell),i=m0(t.root.mxCell,n);return{nodes:o,edges:i,summary:r}},h0=async e=>{let t=await ad(e),o=cr(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}},gd=async e=>{try{let t=await h0(e),{nodes:o,edges:n,summary:r}=g0(t)||{};return{nodes:o,edges:n,summary:r}}catch(t){throw t}};import{jsx as _0}from"react/jsx-runtime";var hd=()=>{let{t:e}=E0(),{toast:t}=x0(),{setNodes:o,setEdges:n,fitView:r}=y0(),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:_0(b0,{size:"small",variant:"ghost",onClick:()=>ld({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 gd(s);if(o(p=>p.concat(l)),n(p=>p.concat(c)),r({padding:no,minZoom:ro,maxZoom:io}),d.some(p=>p.status==="unsupported")){i(d);return}t({variant:"success",content:e("adapter.governance.success.default")})}catch(l){let c=l instanceof Error?l.message:"DEFAULT";t({variant:"error",content:e(`adapter.governance.error.${c}`)})}}}};import{Button as T0}from"lecom-ui";import{useRef as N0}from"react";import{Fragment as v0,jsx as yd,jsxs as w0}from"react/jsx-runtime";var xd=s=>{var l=s,{children:e,accept:t="*",multiple:o=!1,disabled:n=!1,onClick:r,onFilesSelected:i}=l,a=$e(l,["children","accept","multiple","disabled","onClick","onFilesSelected"]);let c=N0(null),d=p=>{let f=p.target.files;f!=null&&f.length&&i(f),c.current&&(c.current.value="")};return w0(v0,{children:[yd(T0,v(E({onClick:p=>{var f;(f=c.current)==null||f.click(),r==null||r(p)}},a),{children:e})),yd("input",{type:"file",ref:c,className:"sr-only",accept:t,multiple:o,disabled:n,onChange:d})]})};import{jsx as Tr,jsxs as P0}from"react/jsx-runtime";var Ed=({disabled:e=!1})=>{let{t}=M0(),{toast:o}=S0(),{importFromGovernance:n}=hd(),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 P0(I0,{children:[Tr(C0,{asChild:!0,children:Tr(xd,{className:"[&>svg]:size-7 p-0",variant:"ghost",size:"small",color:"grey",iconButton:!0,accept:".mdr",disabled:e,onClick:r,onFilesSelected:i,children:Tr(Fi,{})})}),Tr(A0,{color:"black",children:t("editor.controls.actions.import_governance")})]})};import{jsx as L0}from"react/jsx-runtime";var bi=({shortcut:e})=>L0("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 G0,DropdownMenu as B0,DropdownMenuContent as z0,DropdownMenuItem as Ti,DropdownMenuTrigger as F0,Tooltip as Nr,TooltipContent as vr,TooltipTrigger as wr,useTranslation as W0}from"lecom-ui";import{FileCodeIcon as Y0,FileImageIcon as U0,FolderOutputIcon as $0,PrinterIcon as X0}from"lucide-react";import{useState as K0}from"react";import{useReactFlow as k0}from"@xyflow/react";import{toPng as bd,toSvg as D0}from"html-to-image";import{toast as R0,useTranslation as O0}from"lecom-ui";import{useState as V0}from"react";var H0=3,_i="diagram",_d=()=>{let{t:e}=O0(),{getNodes:t}=k0(),{clearSelection:o}=ct(),[n,r]=V0({png:!1,html:!1,print:!1}),i=()=>{let{x:d,y:u,width:p,height:f}=Pl(t());return{width:p,height:f,style:{width:`${p}px`,height:`${f}px`,transform:`translate(${-d}px, ${-u}px)`}}},a=async(d,u)=>{r(v(E({},n),{[u]:!0})),await o();try{let p=Ml();if(!p)throw new Error("Flow element not found");let f=i();return await d(p,f)}catch(p){R0({content:e("editor.controls.actions.export.feedback.error"),variant:"error"})}finally{r(v(E({},n),{[u]:!1}))}};return{exportAsPng:async(d=_i)=>{await a(async(u,p)=>{let f=await bd(u,v(E({},p),{backgroundColor:"#fcfcfc"}));_r(f,`${d}.png`)},"png")},exportAsHtml:async(d=_i)=>{await a(async(u,p)=>{let f=await D0(u,v(E({},p),{backgroundColor:"#fcfcfc"})),h=`
|
|
38
38
|
<!DOCTYPE html>
|
|
39
39
|
<html>
|
|
40
40
|
<head>
|
|
@@ -48,7 +48,7 @@ var hd=Object.defineProperty,yd=Object.defineProperties;var xd=Object.getOwnProp
|
|
|
48
48
|
<img src="${f}" alt="Diagram" />
|
|
49
49
|
</body>
|
|
50
50
|
</html>
|
|
51
|
-
`,g=new Blob([
|
|
51
|
+
`,g=new Blob([h],{type:"text/html"}),m=URL.createObjectURL(g);_r(m,`${d}.html`),setTimeout(()=>URL.revokeObjectURL(m),100)},"html")},printDiagram:async(d=_i)=>{await a(async(u,p)=>{let f=await bd(u,v(E({},p),{pixelRatio:H0})),h=window.open("","_blank");if(!h)throw new Error("Failed to open print window.");let g=h.document;g.open(),g.write(`
|
|
52
52
|
<!DOCTYPE html>
|
|
53
53
|
<html>
|
|
54
54
|
<head>
|
|
@@ -64,4 +64,4 @@ var hd=Object.defineProperty,yd=Object.defineProperties;var xd=Object.getOwnProp
|
|
|
64
64
|
<img src="${f}" alt="Diagram" onload="window.print(); window.close();" />
|
|
65
65
|
</body>
|
|
66
66
|
</html>
|
|
67
|
-
`),g.close()},"print")},isPrintingPng:n.png,isPrintingHtml:n.html,isPrinting:n.print}};import{jsx as ee,jsxs as Gt}from"react/jsx-runtime";function Zc(){let{t:e}=h0(),{exportAsPng:t,exportAsHtml:o,printDiagram:n,isPrinting:r,isPrintingPng:i,isPrintingHtml:a}=qc(),[s,l]=_0(!1);return Gt(f0,{modal:!1,open:s,onOpenChange:l,children:[ee(g0,{asChild:!0,children:ee("div",{children:Gt($n,{children:[ee(Kn,{asChild:!0,children:ee(p0,{size:"small",variant:"ghost",color:"grey",iconButton:!0,children:ee(E0,{})})}),!s&&ee(Xn,{color:"black",children:e("editor.controls.actions.export.title")})]})})}),Gt(m0,{align:"center",side:"top",sideOffset:16,className:"min-w-0 flex flex-col gap-2 p-2 shadow-sm",children:[Gt($n,{children:[ee(Kn,{asChild:!0,children:ee(qr,{className:"p-1.5",disabled:i,onClick:()=>t(),children:ee(x0,{})})}),ee(Xn,{side:"right",color:"black",children:e("editor.controls.actions.export.png")})]}),Gt($n,{children:[ee(Kn,{asChild:!0,children:ee(qr,{className:"p-1.5",disabled:a,onClick:()=>o(),children:ee(y0,{})})}),ee(Xn,{side:"right",color:"black",children:e("editor.controls.actions.export.html")})]}),Gt($n,{children:[ee(Kn,{asChild:!0,children:ee(qr,{className:"p-1.5",disabled:r,onClick:()=>n(),children:ee(b0,{})})}),ee(Xn,{side:"right",color:"black",children:e("editor.controls.actions.export.print")})]})]})]})}import{Fragment as jc,jsx as te,jsxs as Ge}from"react/jsx-runtime";var ed=({nodes:e,validateDiagram:t,handleValidationComplete:o})=>{let{t:n}=N0(),{clearSelection:r}=$e(),{mode:i,isMinimapOpen:a,setIsMinimapOpen:s,isMoveTool:l,isHandTool:c,setIsMoveTool:d,setIsHandTool:u}=G(),{getNodes:p,getEdges:f}=T0(),x=Jc(["v","V"]),g=Jc(["h","H"]),m=Zr(()=>{r(),u(!0),d(!1)},[r,u,d]),y=Zr(()=>{d(!0),u(!1)},[d,u]),h=Zr(()=>{let b=p(),T=f(),_=t({nodes:b,edges:T});o(_)},[p,f,t,o]);return Qc(()=>{x&&!l&&i==="edit"&&y()},[x,y,l,i]),Qc(()=>{g&&!c&&i==="edit"&&m()},[g,m,c,i]),Ge("div",{className:"flex items-center gap-2 px-3 py-2 bg-white rounded-sm shadow-md",children:[i==="edit"&&Ge(jc,{children:[Ge(Zn,{children:[te(Qn,{asChild:!0,children:te(qn,{size:"small",variant:"ghost",color:"grey",className:R(l&&"bg-grey-400"),iconButton:!0,onClick:y,children:te(A0,{})})}),Ge(Jn,{color:"black",className:"flex items-center gap-2",children:[n("editor.controls.actions.move_tool"),te(Xr,{shortcut:"V"})]})]}),Ge(Zn,{children:[te(Qn,{asChild:!0,children:te(qn,{size:"small",variant:"ghost",color:"grey",className:R(c&&"bg-grey-400"),iconButton:!0,onClick:m,children:te(v0,{})})}),Ge(Jn,{color:"black",className:"flex items-center gap-2",children:[n("editor.controls.actions.hand_tool")," ",te(Xr,{shortcut:"H"})]})]})]}),te(Zc,{}),i==="edit"&&Ge(jc,{children:[Ge(Zn,{children:[te(Qn,{asChild:!0,children:te(qn,{size:"small",variant:"ghost",color:"grey",iconButton:!0,onClick:h,children:te(w0,{})})}),te(Jn,{color:"black",children:n("editor.controls.actions.check")})]}),te(Xc,{disabled:e.length>0})]}),Ge(Zn,{children:[te(Qn,{asChild:!0,children:te(qn,{size:"small",variant:"ghost",color:"grey",className:R(a&&"bg-grey-400"),iconButton:!0,onClick:()=>s(!a),children:te(I0,{})})}),te(Jn,{color:"black",children:n(a?"editor.controls.actions.minimap.close":"editor.controls.actions.minimap.open")})]})]})};import{Button as td,Tooltip as od,TooltipContent as nd,TooltipTrigger as rd,useTranslation as C0}from"lecom-ui";import{RedoIcon as S0,UndoIcon as M0}from"lucide-react";import{jsx as Ze,jsxs as Jr}from"react/jsx-runtime";var id=({undo:e,redo:t,canUndo:o,canRedo:n})=>{let{t:r}=C0();return Jr("div",{className:"flex items-center gap-2 px-3 py-2 bg-white rounded-sm shadow-md",children:[Jr(od,{children:[Ze(rd,{asChild:!0,children:Ze(td,{size:"small",variant:"ghost",color:"grey",iconButton:!0,disabled:!o,onClick:e,children:Ze(M0,{})})}),Ze(nd,{color:"black",children:r("editor.controls.history.undo")})]}),Jr(od,{children:[Ze(rd,{asChild:!0,children:Ze(td,{size:"small",variant:"ghost",color:"grey",iconButton:!0,disabled:!n,onClick:t,children:Ze(S0,{})})}),Ze(nd,{color:"black",children:r("editor.controls.history.redo")})]})]})};import{useReactFlow as P0}from"@xyflow/react";import{Button as jn,Tooltip as er,TooltipContent as tr,TooltipTrigger as or,useTranslation as L0}from"lecom-ui";import{ScanIcon as k0,ZoomIn as D0,ZoomOut as R0}from"lucide-react";import{jsx as ae,jsxs as No}from"react/jsx-runtime";var sd=()=>{let{t:e}=L0(),{zoomIn:t,zoomOut:o,zoomTo:n,fitView:r}=P0();return No("div",{className:"flex items-center gap-2 px-3 py-2 bg-white rounded-sm shadow-md",children:[No(er,{children:[ae(or,{asChild:!0,children:ae(jn,{size:"small",variant:"ghost",color:"grey",iconButton:!0,onClick:()=>r(),children:ae(k0,{})})}),ae(tr,{color:"black",children:e("editor.controls.zoom.fit")})]}),No(er,{children:[ae(or,{asChild:!0,children:ae(jn,{size:"small",variant:"ghost",color:"grey",iconButton:!0,onClick:()=>o(),children:ae(R0,{})})}),ae(tr,{color:"black",children:e("editor.controls.zoom.out")})]}),No(er,{children:[ae(or,{asChild:!0,children:ae(jn,{size:"small",variant:"ghost",color:"grey",iconButton:!0,onClick:()=>n(1),children:ae(xi,{})})}),ae(tr,{color:"black",children:e("editor.controls.zoom.reset")})]}),No(er,{children:[ae(or,{asChild:!0,children:ae(jn,{size:"small",variant:"ghost",color:"grey",iconButton:!0,onClick:()=>t(),children:ae(D0,{})})}),ae(tr,{color:"black",children:e("editor.controls.zoom.in")})]})]})};import{useReactFlow as V0}from"@xyflow/react";import{Button as O0,Tooltip as H0,TooltipContent as G0,TooltipTrigger as B0,useTranslation as z0}from"lecom-ui";import{useRef as F0,useState as W0}from"react";import{jsx as ut,jsxs as ad}from"react/jsx-runtime";var ld=()=>{let e=F0(null),{t}=z0(),{setDraggableNode:o}=St(),{getNodes:n}=V0(),{setIsDragging:r}=G(),[i,a]=W0(void 0),s=n(),l=pn(s),c=[{type:"START_EVENT",icon:So,label:t("bpmn.start_event.variant.default")},{type:"END_EVENT",icon:pt,label:t("bpmn.end_event.variant.default")},{type:"TASK",icon:Wt,label:t("bpmn.task.variant.default")},{type:"TASK",variant:"SUBPROCESS",icon:Ni,label:t("bpmn.task.variant.subprocess")},{type:"TASK",variant:"SCRIPT",icon:Ti,label:t("bpmn.task.variant.script")},{type:"TASK",attribute:"LOOP",icon:_i,label:t("bpmn.task.attribute.loop")},{type:"GATEWAY",variant:"EXCLUSIVE",icon:mt,label:t("bpmn.gateway.variant.exclusive")},{type:"GATEWAY",variant:"PARALLEL",icon:gt,label:t("bpmn.gateway.variant.parallel")},{type:"GATEWAY",variant:"COMPLEX",icon:ft,label:t("bpmn.gateway.variant.complex")},{type:"LANE",icon:yi,label:t("bpmn.lane.variant.default")},{type:"ANNOTATION",icon:Ao,label:t("bpmn.annotation.variant.default")}],d=(u,p)=>{o({type:p.type,variant:p.variant,attribute:p.attribute,icon:p.icon}),a(ut(p.icon,{})),u.dataTransfer.effectAllowed="move",e.current&&u.dataTransfer.setDragImage(e.current,10,10),setTimeout(()=>{r(!0)},100)};return ad("aside",{className:"sidebar absolute z-[1] top-4 left-4",children:[ut("div",{className:"grid grid-cols-1 gap-2 p-2 bg-white rounded-md shadow-md",children:c.map((u,p)=>{let f=l&&u.type==="START_EVENT",x=f?t("editor.toolbar.start_event_already_exists"):u.label;return ad(H0,{children:[ut(B0,{asChild:!0,children:ut(O0,{className:R("[&>svg]:size-6",{"opacity-50 cursor-not-allowed":f}),size:"small",variant:"ghost",color:"grey",draggable:!f,disabled:f,iconButton:!0,onDragStart:f?void 0:g=>d(g,u),children:ut(u.icon,{})},p)}),ut(G0,{color:"black",side:"right",children:x})]},p)})}),ut("div",{ref:e,className:"absolute w-0 h-0 top-0 left-0 z-[-1] bg-transparent",children:i})]})};import{Button as Y0,useTranslation as U0}from"lecom-ui";import{AlertCircleIcon as $0,CircleCheckIcon as X0,XIcon as K0}from"lucide-react";import{useEffect as cd,useRef as q0,useState as dd}from"react";import{jsx as Ne,jsxs as Qr}from"react/jsx-runtime";var Z0=5e3,ud=({validationResult:e,onClose:t})=>{let{t:o}=U0(),[n,r]=dd(!1),[i,a]=dd(!1),s=q0(null);cd(()=>{e&&r(!0)},[e]),cd(()=>(n&&!i&&(s.current=setTimeout(()=>{r(!1),t()},Z0)),()=>{s.current&&(clearTimeout(s.current),s.current=null)}),[n,i,t]);let l=()=>{a(!0),s.current&&(clearTimeout(s.current),s.current=null)},c=()=>{a(!1)};if(!n||!e)return null;let{isValid:d,errors:u}=e;return Qr("div",{className:R("w-72 max-w-[95vw] rounded-lg border px-4 py-2",{"bg-green-100":d,"bg-red-100":!d}),onMouseEnter:l,onMouseLeave:c,children:[Qr("div",{className:"flex flex-row items-start gap-4",children:[Ne("div",{className:"flex-shrink-0",children:d?Ne(X0,{className:"text-green-500 size-5"}):Ne($0,{className:"text-red-500 size-5"})}),Qr("div",{className:"body-medium-500 text-grey-800",children:[Ne("div",{children:o(d?"validation.success.title":"validation.errors.title")}),!d&&Ne("div",{children:o("validation.errors.subtitle")})]}),Ne(Y0,{variant:"ghost",size:"small",color:"grey",className:"size-5 hover:bg-transparent",iconButton:!0,onClick:()=>{r(!1),t()},children:Ne(K0,{})})]}),Ne("div",{className:"max-h-80 overflow-y-auto mt-2 px-9 body-medium-400 text-grey-800",children:d?Ne("p",{children:o("validation.success.message")}):Ne("div",{className:"list-disc list-inside",children:u.map(p=>Ne("li",{className:"mb-1",children:p.message},p.id))})})]})};import{jsx as Me,jsxs as jr}from"react/jsx-runtime";var ei=ty((e,t)=>{let{instanceId:o,mode:n,isMinimapOpen:r,isMoveTool:i,isHandTool:a}=G(),{nodes:s,edges:l,ui:c,actions:d,events:u,components:p,controls:f}=Lc();return oy(t,()=>({selectElements:d.selectElements,clearSelection:d.clearSelection})),jr("div",{className:"w-full h-full",children:[n==="edit"&&Me(ld,{}),Me(Dc,{}),jr(j0,N(E({},u),{id:`modeler-${o}`,edges:l,nodes:s,nodeTypes:Fl,edgeTypes:Wl,minZoom:ql,maxZoom:Zl,panOnDrag:a||n!=="edit"?!0:Ql,panOnScroll:!0,selectionOnDrag:!0,elevateEdgesOnSelect:!0,elevateNodesOnSelect:!0,elementsSelectable:n!=="readonly"&&i,nodesConnectable:n==="edit"&&i,nodesDraggable:n==="edit"&&i,connectionLineComponent:Hl,selectionMode:ey.Partial,multiSelectionKeyCode:"Shift",deleteKeyCode:"Delete",selectionKeyCode:null,snapToGrid:!0,snapGrid:[5,5],defaultViewport:Jl,connectOnClick:!1,proOptions:{hideAttribution:!0},children:[Me(J0,{gap:Xl,size:$l,color:Ul,bgColor:Yl}),r&&Me(Q0,{pannable:!0,zoomable:!0,position:Kl,className:"shadow-md rounded-md"}),jr("div",{className:"absolute z-10 bottom-4 left-1/2 -translate-x-1/2 flex gap-4",children:[n==="edit"&&Me(id,E({},f)),Me(ed,{nodes:s,validateDiagram:d.validateDiagram,handleValidationComplete:d.handleValidationComplete}),Me(sd,{})]}),Me(p.HelperLines,{}),c.validationResult&&Me("div",{className:"absolute top-6 right-6 z-[1000]",children:Me(ud,{validationResult:c.validationResult,onClose:c.handleCloseValidationPanel})})]}))]})});ei.displayName="Editor";import{useStore as ny}from"@xyflow/react";import{useEffect as ry,useRef as iy}from"react";import{jsx as ay}from"react/jsx-runtime";var sy=e=>({width:e.width,height:e.height,transform:e.transform}),ti="rgba(51, 103, 217, 0.4)",xa=({horizontal:e,vertical:t})=>{let{width:o,height:n,transform:r}=ny(sy),i=iy(null);return ry(()=>{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=ti,t&&(s.beginPath(),s.strokeStyle=t.color||ti,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||ti,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]),ay("canvas",{ref:i,className:"w-full h-full absolute z-10 pointer-events-none"})};import{i18n as ly,Notification as cy,TooltipProvider as dy}from"lecom-ui";import{createContext as uy,useContext as py,useEffect as fy,useState as my}from"react";import{jsx as pd,jsxs as hy}from"react/jsx-runtime";var Ce=new Map,fd=uy(null),oi=()=>{let e=py(fd);if(!e)throw new Error("useModeler must be used within an <ModelerProvider />");return e},gy=({locale:e,defaultMode:t="view",showNotification:o=!0,children:n})=>{let[r,i]=my(e||"pt_BR");fy(()=>{e&&(i(e),ly.changeLanguage(e))},[e]);let a=f=>{let x=Ce.size;if(x===0)throw new Error("No modeler instances found");if(x===1||!f){let[m]=Ce.values();return m}let g=Ce.get(f);if(!g)throw new Error(`Modeler instance with ID "${f}" not found`);return g},s=(f,x)=>{let g=a(x);return g==null?void 0:g.selectElements(f)},l=async f=>{let x=a(f);return x==null?void 0:x.clearSelection()},c=(f,x)=>{let g=a(x);return g==null?void 0:g.configureElement(f)},d=(f,x)=>{let g=a(x);return g==null?void 0:g.getConfigureElement(f)},u=async(f,x)=>{let g=a(x);await(g==null?void 0:g.importFromMxGraph(f))},p=f=>{let x=a(f);return x==null?void 0:x.exportToMxGraph()};return pd(fd.Provider,{value:{defaultMode:t,locale:r,selectElements:s,clearSelection:l,configureElement:c,getConfigureElement:d,importDiagram:u,exportDiagram:p},children:hy(dy,{children:[o&&pd(cy,{type:"toast",placement:"topRight",enableClose:!0,showProgress:!0,pauseOnHover:!0}),n]})})};import{jsx as ni}from"react/jsx-runtime";var md=xy(null),G=()=>{let e=Ey(md);if(!e)throw new Error("useModelerInstance must be used within an <Modeler />");return e},Ny=({selectorRef:e,initialDiagram:t,instanceId:o,mode:n,onElementChanges:r,onConfigureElement:i,onSubprocessValidationClick:a})=>{let{defaultMode:s}=oi(),l=_y(),[c]=Pe(o||l),[d,u]=Pe(n||s||"edit"),[p,f]=Pe(ho),[x,g]=Pe(!1),[m,y]=Pe(!0),[h,b]=Pe(!1),[T,_]=Pe(!1),[v,w]=Pe(!1),[S,L]=Pe(!1),[P,C]=Pe(!1);by(()=>{n&&u(n)},[n]);let I=Ty(()=>t||il(),[t]),M={instanceId:c,initialDiagram:I,mode:d,lastElementId:p,isInitialized:x,isMinimapOpen:T,isMoveTool:m,isHandTool:h,isDragging:v,isMultipleSelection:P,isConnecting:S,setLastElementId:f,setIsInitialized:g,setIsMinimapOpen:_,setIsMoveTool:y,setIsHandTool:b,setIsDragging:w,setIsConnecting:L,setIsMultipleSelection:C,onElementChanges:r,onConfigureElement:i,onSubprocessValidationClick:a};return ni(yy,{children:ni(md.Provider,{value:M,children:ni(ei,{ref:e})})})};export{ge as EditorMode,ir as ElementPosition,wo as ElementType,sr as GatewayElementVariant,be as GatewayVariant,Ny as Modeler,gy as ModelerProvider,ze as NodeAttribute,F as NodeType,Ee as NodeVariant,ar as RoutingVariant,oi as useModeler};
|
|
67
|
+
`),g.close()},"print")},isPrintingPng:n.png,isPrintingHtml:n.html,isPrinting:n.print}};import{jsx as xe,jsxs as lo}from"react/jsx-runtime";function Td(){let{t:e}=W0(),{exportAsPng:t,exportAsHtml:o,printDiagram:n,isPrinting:r,isPrintingPng:i,isPrintingHtml:a}=_d(),[s,l]=K0(!1);return lo(B0,{modal:!1,open:s,onOpenChange:l,children:[xe(F0,{asChild:!0,children:xe("div",{children:lo(Nr,{children:[xe(wr,{asChild:!0,children:xe(G0,{size:"small",variant:"ghost",color:"grey",iconButton:!0,children:xe($0,{})})}),!s&&xe(vr,{color:"black",children:e("editor.controls.actions.export.title")})]})})}),lo(z0,{align:"center",side:"top",sideOffset:16,className:"min-w-0 flex flex-col gap-2 p-2 shadow-sm",children:[lo(Nr,{children:[xe(wr,{asChild:!0,children:xe(Ti,{className:"p-1.5",disabled:i,onClick:()=>t(),children:xe(U0,{})})}),xe(vr,{side:"right",color:"black",children:e("editor.controls.actions.export.png")})]}),lo(Nr,{children:[xe(wr,{asChild:!0,children:xe(Ti,{className:"p-1.5",disabled:a,onClick:()=>o(),children:xe(Y0,{})})}),xe(vr,{side:"right",color:"black",children:e("editor.controls.actions.export.html")})]}),lo(Nr,{children:[xe(wr,{asChild:!0,children:xe(Ti,{className:"p-1.5",disabled:r,onClick:()=>n(),children:xe(X0,{})})}),xe(vr,{side:"right",color:"black",children:e("editor.controls.actions.export.print")})]})]})]})}import{Fragment as wd,jsx as Ee,jsxs as tt}from"react/jsx-runtime";var Id=({nodes:e,validateDiagram:t,handleValidationComplete:o})=>{let{t:n}=Z0(),{clearSelection:r}=ct(),{mode:i,isMinimapOpen:a,setIsMinimapOpen:s,isMoveTool:l,isHandTool:c,setIsMoveTool:d,setIsHandTool:u}=W(),{getNodes:p,getEdges:f}=q0(),h=Nd(["v","V"]),g=Nd(["h","H"]),m=Ni(()=>{r(),u(!0),d(!1)},[r,u,d]),x=Ni(()=>{d(!0),u(!1)},[d,u]),y=Ni(()=>{let b=p(),N=f(),T=t({nodes:b,edges:N});o(T)},[p,f,t,o]);return vd(()=>{h&&!l&&i==="edit"&&x()},[h,x,l,i]),vd(()=>{g&&!c&&i==="edit"&&m()},[g,m,c,i]),tt("div",{className:"flex items-center gap-2 px-3 py-2 bg-white rounded-sm shadow-md",children:[i==="edit"&&tt(wd,{children:[tt(Ar,{children:[Ee(Sr,{asChild:!0,children:Ee(Ir,{size:"small",variant:"ghost",color:"grey",className:k(l&&"bg-grey-400"),iconButton:!0,onClick:x,children:Ee(ey,{})})}),tt(Cr,{color:"black",className:"flex items-center gap-2",children:[n("editor.controls.actions.move_tool"),Ee(bi,{shortcut:"V"})]})]}),tt(Ar,{children:[Ee(Sr,{asChild:!0,children:Ee(Ir,{size:"small",variant:"ghost",color:"grey",className:k(c&&"bg-grey-400"),iconButton:!0,onClick:m,children:Ee(J0,{})})}),tt(Cr,{color:"black",className:"flex items-center gap-2",children:[n("editor.controls.actions.hand_tool")," ",Ee(bi,{shortcut:"H"})]})]})]}),Ee(Td,{}),i==="edit"&&tt(wd,{children:[tt(Ar,{children:[Ee(Sr,{asChild:!0,children:Ee(Ir,{size:"small",variant:"ghost",color:"grey",iconButton:!0,onClick:y,children:Ee(Q0,{})})}),Ee(Cr,{color:"black",children:n("editor.controls.actions.check")})]}),Ee(Ed,{disabled:e.length>0})]}),tt(Ar,{children:[Ee(Sr,{asChild:!0,children:Ee(Ir,{size:"small",variant:"ghost",color:"grey",className:k(a&&"bg-grey-400"),iconButton:!0,onClick:()=>s(!a),children:Ee(j0,{})})}),Ee(Cr,{color:"black",children:n(a?"editor.controls.actions.minimap.close":"editor.controls.actions.minimap.open")})]})]})};import{Button as Ad,Tooltip as Cd,TooltipContent as Sd,TooltipTrigger as Md,useTranslation as ty}from"lecom-ui";import{RedoIcon as oy,UndoIcon as ny}from"lucide-react";import{jsx as yt,jsxs as vi}from"react/jsx-runtime";var Pd=({undo:e,redo:t,canUndo:o,canRedo:n})=>{let{t:r}=ty();return vi("div",{className:"flex items-center gap-2 px-3 py-2 bg-white rounded-sm shadow-md",children:[vi(Cd,{children:[yt(Md,{asChild:!0,children:yt(Ad,{size:"small",variant:"ghost",color:"grey",iconButton:!0,disabled:!o,onClick:e,children:yt(ny,{})})}),yt(Sd,{color:"black",children:r("editor.controls.history.undo")})]}),vi(Cd,{children:[yt(Md,{asChild:!0,children:yt(Ad,{size:"small",variant:"ghost",color:"grey",iconButton:!0,disabled:!n,onClick:t,children:yt(oy,{})})}),yt(Sd,{color:"black",children:r("editor.controls.history.redo")})]})]})};import{useReactFlow as ry}from"@xyflow/react";import{Button as Mr,Tooltip as Pr,TooltipContent as Lr,TooltipTrigger as kr,useTranslation as iy}from"lecom-ui";import{ScanIcon as sy,ZoomIn as ay,ZoomOut as ly}from"lucide-react";import{jsx as ve,jsxs as Qo}from"react/jsx-runtime";var Ld=()=>{let{t:e}=iy(),{zoomIn:t,zoomOut:o,zoomTo:n,fitView:r}=ry();return Qo("div",{className:"flex items-center gap-2 px-3 py-2 bg-white rounded-sm shadow-md",children:[Qo(Pr,{children:[ve(kr,{asChild:!0,children:ve(Mr,{size:"small",variant:"ghost",color:"grey",iconButton:!0,onClick:()=>r(),children:ve(sy,{})})}),ve(Lr,{color:"black",children:e("editor.controls.zoom.fit")})]}),Qo(Pr,{children:[ve(kr,{asChild:!0,children:ve(Mr,{size:"small",variant:"ghost",color:"grey",iconButton:!0,onClick:()=>o(),children:ve(ly,{})})}),ve(Lr,{color:"black",children:e("editor.controls.zoom.out")})]}),Qo(Pr,{children:[ve(kr,{asChild:!0,children:ve(Mr,{size:"small",variant:"ghost",color:"grey",iconButton:!0,onClick:()=>n(1),children:ve(Ui,{})})}),ve(Lr,{color:"black",children:e("editor.controls.zoom.reset")})]}),Qo(Pr,{children:[ve(kr,{asChild:!0,children:ve(Mr,{size:"small",variant:"ghost",color:"grey",iconButton:!0,onClick:()=>t(),children:ve(ay,{})})}),ve(Lr,{color:"black",children:e("editor.controls.zoom.in")})]})]})};import{useReactFlow as cy}from"@xyflow/react";import{Button as dy,Tooltip as uy,TooltipContent as py,TooltipTrigger as fy,useTranslation as my}from"lecom-ui";import{useRef as gy,useState as hy}from"react";import{jsx as Lt,jsxs as kd}from"react/jsx-runtime";var Dd=()=>{let e=gy(null),{t}=my(),{setDraggableNode:o}=jt(),{getNodes:n}=cy(),{setIsDragging:r}=W(),[i,a]=hy(void 0),s=n(),l=zn(s),c=[{type:"START_EVENT",icon:rn,label:t("bpmn.start_event.variant.default")},{type:"END_EVENT",icon:kt,label:t("bpmn.end_event.variant.default")},{type:"TASK",icon:go,label:t("bpmn.task.variant.default")},{type:"TASK",variant:"SUBPROCESS",icon:Zi,label:t("bpmn.task.variant.subprocess")},{type:"TASK",variant:"SCRIPT",icon:qi,label:t("bpmn.task.variant.script")},{type:"TASK",attribute:"LOOP",icon:Ki,label:t("bpmn.task.attribute.loop")},{type:"GATEWAY",variant:"EXCLUSIVE",icon:Rt,label:t("bpmn.gateway.variant.exclusive")},{type:"GATEWAY",variant:"PARALLEL",icon:Ot,label:t("bpmn.gateway.variant.parallel")},{type:"GATEWAY",variant:"COMPLEX",icon:Dt,label:t("bpmn.gateway.variant.complex")},{type:"LANE",icon:Yi,label:t("bpmn.lane.variant.default")},{type:"ANNOTATION",icon:on,label:t("bpmn.annotation.variant.default")}],d=(u,p)=>{o({type:p.type,variant:p.variant,attribute:p.attribute,icon:p.icon}),a(Lt(p.icon,{})),u.dataTransfer.effectAllowed="move",e.current&&u.dataTransfer.setDragImage(e.current,10,10),setTimeout(()=>{r(!0)},100)};return kd("aside",{className:"sidebar absolute z-[1] top-4 left-4",children:[Lt("div",{className:"grid grid-cols-1 gap-2 p-2 bg-white rounded-md shadow-md",children:c.map((u,p)=>{let f=l&&u.type==="START_EVENT",h=f?t("editor.toolbar.start_event_already_exists"):u.label;return kd(uy,{children:[Lt(fy,{asChild:!0,children:Lt(dy,{className:k("[&>svg]:size-6",{"opacity-50 cursor-not-allowed":f}),size:"small",variant:"ghost",color:"grey",draggable:!f,disabled:f,iconButton:!0,onDragStart:f?void 0:g=>d(g,u),children:Lt(u.icon,{})},p)}),Lt(py,{color:"black",side:"right",children:h})]},p)})}),Lt("div",{ref:e,className:"absolute w-0 h-0 top-0 left-0 z-[-1] bg-transparent",children:i})]})};import{jsx as xt,jsxs as wi}from"react/jsx-runtime";var Ii=_y((e,t)=>{let{instanceId:o,mode:n,isMinimapOpen:r,isMoveTool:i,isHandTool:a}=W(),{nodes:s,edges:l,actions:c,events:d,components:u,controls:p}=rd();return Ty(t,()=>({selectElements:c.selectElements,clearSelection:c.clearSelection})),wi("div",{className:"w-full h-full",children:[n==="edit"&&xt(Dd,{}),xt(sd,{}),wi(Ey,v(E({},d),{id:`modeler-${o}`,edges:l,nodes:s,nodeTypes:gc,edgeTypes:hc,minZoom:Tc,maxZoom:Nc,panOnDrag:a||n!=="edit"?!0:wc,panOnScroll:!0,selectionOnDrag:!0,elevateEdgesOnSelect:!0,elevateNodesOnSelect:!1,elementsSelectable:n!=="readonly"&&i,nodesConnectable:n==="edit"&&i,nodesDraggable:n==="edit"&&i,connectionLineComponent:uc,selectionMode:by.Partial,multiSelectionKeyCode:"Shift",deleteKeyCode:"Delete",selectionKeyCode:null,snapToGrid:!0,snapGrid:[5,5],defaultViewport:vc,connectOnClick:!1,connectionRadius:30,proOptions:{hideAttribution:!0},children:[xt(yy,{gap:bc,size:Ec,color:xc,bgColor:yc}),r&&xt(xy,{pannable:!0,zoomable:!0,position:_c,className:"shadow-md rounded-md"}),wi("div",{className:"absolute z-10 bottom-4 left-1/2 -translate-x-1/2 flex gap-4",children:[n==="edit"&&xt(Pd,E({},p)),xt(Id,{nodes:s,validateDiagram:c.validateDiagram,handleValidationComplete:c.handleValidationComplete}),xt(Ld,{})]}),xt(u.HelperLines,{})]}))]})});Ii.displayName="Editor";import{useStore as Ny}from"@xyflow/react";import{useEffect as vy,useRef as wy}from"react";import{jsx as Ay}from"react/jsx-runtime";var Iy=e=>({width:e.width,height:e.height,transform:e.transform}),Ai="rgba(51, 103, 217, 0.4)",Ua=({horizontal:e,vertical:t})=>{let{width:o,height:n,transform:r}=Ny(Iy),i=wy(null);return vy(()=>{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=Ai,t&&(s.beginPath(),s.strokeStyle=t.color||Ai,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||Ai,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]),Ay("canvas",{ref:i,className:"w-full h-full absolute z-10 pointer-events-none"})};import{i18n as Cy,Notification as Sy,TooltipProvider as My}from"lecom-ui";import{createContext as Py,useContext as Ly,useEffect as ky,useState as Dy}from"react";import{jsx as Rd,jsxs as Oy}from"react/jsx-runtime";var Ke=new Map,Od=Py(null),Ci=()=>{let e=Ly(Od);if(!e)throw new Error("useModeler must be used within an <ModelerProvider />");return e},Ry=({locale:e,defaultMode:t="view",showNotification:o=!0,children:n})=>{let[r,i]=Dy(e||"pt_BR");ky(()=>{e&&(i(e),Cy.changeLanguage(e))},[e]);let a=f=>{let h=Ke.size;if(h===0)throw new Error("No modeler instances found");if(h===1||!f){let[m]=Ke.values();return m}let g=Ke.get(f);if(!g)throw new Error(`Modeler instance with ID "${f}" not found`);return g},s=(f,h)=>{let g=a(h);return g==null?void 0:g.selectElements(f)},l=async f=>{let h=a(f);return h==null?void 0:h.clearSelection()},c=(f,h)=>{let g=a(h);return g==null?void 0:g.configureElement(f)},d=(f,h)=>{let g=a(h);return g==null?void 0:g.getConfigureElement(f)},u=async(f,h)=>{let g=a(h);await(g==null?void 0:g.importFromMxGraph(f))},p=f=>{let h=a(f);return h==null?void 0:h.exportToMxGraph()};return Rd(Od.Provider,{value:{defaultMode:t,locale:r,selectElements:s,clearSelection:l,configureElement:c,getConfigureElement:d,importDiagram:u,exportDiagram:p},children:Oy(My,{children:[o&&Rd(Sy,{type:"toast",placement:"topRight",enableClose:!0,showProgress:!0,pauseOnHover:!0}),n]})})};import{jsx as Si}from"react/jsx-runtime";var Vd=Hy(null),W=()=>{let e=Gy(Vd);if(!e)throw new Error("useModelerInstance must be used within an <Modeler />");return e},Wy=({selectorRef:e,initialDiagram:t,instanceId:o,mode:n,onElementChanges:r,onConfigureElement:i,onElementClick:a,onSubprocessValidationClick:s})=>{let{defaultMode:l}=Ci(),c=zy(),[d]=Ue(o||c),[u,p]=Ue(n||l||"edit"),[f,h]=Ue(Yo),[g,m]=Ue(!1),[x,y]=Ue(!0),[b,N]=Ue(!1),[T,_]=Ue(!1),[w,P]=Ue(!1),[H,C]=Ue(!1),[I,L]=Ue(!1),[B,M]=Ue(null);By(()=>{n&&p(n)},[n]);let A=Fy(()=>t||Ll(),[t]),D={instanceId:d,initialDiagram:A,mode:u,lastElementId:f,isInitialized:g,isMinimapOpen:T,isMoveTool:x,isHandTool:b,isDragging:w,isMultipleSelection:I,isConnecting:H,setLastElementId:h,setIsInitialized:m,reconnectingEdgeId:B,setIsMinimapOpen:_,setIsMoveTool:y,setIsHandTool:N,setIsDragging:P,setIsConnecting:C,setIsMultipleSelection:L,setReconnectingEdgeId:M,onElementChanges:r,onConfigureElement:i,onElementClick:a,onSubprocessValidationClick:s};return Si(Vy,{children:Si(Vd.Provider,{value:D,children:Si(Ii,{ref:e})})})};export{Pe as EditorMode,Rr as ElementPosition,en as ElementType,Or as GatewayElementVariant,Fe as GatewayVariant,Wy as Modeler,Ry as ModelerProvider,nt as NodeAttribute,Q as NodeType,ze as NodeVariant,Vr as RoutingVariant,Ci as useModeler};
|