lecom-modeler 0.10.1 → 0.11.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/lib/index.js CHANGED
@@ -1,5 +1,5 @@
1
- var vd=Object.defineProperty,Nd=Object.defineProperties;var wd=Object.getOwnPropertyDescriptors;var Ao=Object.getOwnPropertySymbols;var di=Object.prototype.hasOwnProperty,ui=Object.prototype.propertyIsEnumerable;var ci=(e,t,o)=>t in e?vd(e,t,{enumerable:!0,configurable:!0,writable:!0,value:o}):e[t]=o,b=(e,t)=>{for(var o in t||(t={}))di.call(t,o)&&ci(e,o,t[o]);if(Ao)for(var o of Ao(t))ui.call(t,o)&&ci(e,o,t[o]);return e},v=(e,t)=>Nd(e,wd(t));var Ae=(e,t)=>{var o={};for(var n in e)di.call(e,n)&&t.indexOf(n)<0&&(o[n]=e[n]);if(e!=null&&Ao)for(var n of Ao(e))t.indexOf(n)<0&&ui.call(e,n)&&(o[n]=e[n]);return o};var sr=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 Id,Translations as Ad}from"lecom-ui";var pi={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 fi={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 mi={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 gi={pt_BR:mi,en_US:pi,es_ES:fi};var hi,yi,Cd=(yi=(hi=sr("LecomUserLanguage"))!=null?hi:sr("org.springframework.web.servlet.i18n.CookieLocaleResolver.LOCALE"))!=null?yi:Ad.PT_BR;Id({lng:Cd,resources:gi});var ge=(n=>(n.EDIT="edit",n.VIEW="view",n.READONLY="readonly",n))(ge||{});var Co=(r=>(r.ACTIVITY="activity",r.ROUTING="routing",r.GATEWAY="gateway",r.SUB_PROCESS="sub_process",r))(Co||{}),ar=(n=>(n.START="start",n.END="end",n.BETWEEN="between",n))(ar||{}),lr=(n=>(n.SCRIPT="script",n.LOOP="loop",n.SCRIPT_LOOP="script_loop",n))(lr||{}),cr=(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))(cr||{});import{RotateCcw as Bd,ScrollText as zd,SquarePlus as Fd}from"lucide-react";import{jsx as So,jsxs as Sd}from"react/jsx-runtime";var Mo=({size:e=24,className:t})=>Sd("svg",{width:e,height:e,viewBox:"0 0 24 24",xmlns:"http://www.w3.org/2000/svg",fill:"#6b7280",className:t,children:[So("path",{strokeWidth:"2",d:"M16 3V3.5085V11.9998V20.4915V21H16.5411H21.4592H22V19.123H21.4592H17.9974V11.9998V4.8773H21.4592H22V3H21.4592H16.5411H16Z"}),So("path",{d:"M4.41026 16.9999L2 18.7861L3.89693 21.1103L6.3072 19.324L4.41026 16.9999Z"}),So("path",{d:"M8.41026 13.9999L6 15.7861L7.89693 18.1103L10.3072 16.324L8.41026 13.9999Z"}),So("path",{d:"M12.4313 10.954L10.021 12.7402L11.9179 15.0644L14.3282 13.2781L12.4313 10.954Z"})]});import{jsx as xi}from"react/jsx-runtime";var gt=({size:e=24,className:t})=>xi("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:xi("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 Xt,jsxs as Md}from"react/jsx-runtime";var ht=({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:[Xt("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"}),Xt("path",{d:"M12 8V16",strokeLinecap:"round",strokeLinejoin:"round"}),Xt("path",{d:"M8 12H16",strokeLinecap:"round",strokeLinejoin:"round"}),Xt("path",{d:"M9.17139 9.17188L14.8282 14.8287",strokeLinecap:"round",strokeLinejoin:"round"}),Xt("path",{d:"M14.8281 9.17188L9.17127 14.8287",strokeLinecap:"round",strokeLinejoin:"round"})]});import{jsx as dr,jsxs as Pd}from"react/jsx-runtime";var yt=({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:[dr("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"}),dr("path",{d:"M14.8286 9.17188L9.17176 14.8287",strokeLinecap:"round",strokeLinejoin:"round"}),dr("path",{d:"M9.17139 9.17188L14.8282 14.8287",strokeLinecap:"round",strokeLinejoin:"round"})]});import{jsx as ur,jsxs as Ld}from"react/jsx-runtime";var xt=({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:[ur("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"}),ur("path",{d:"M12 8V16",strokeLinecap:"round",strokeLinejoin:"round"}),ur("path",{d:"M8 12H16",strokeLinecap:"round",strokeLinejoin:"round"})]});import{jsx as pr,jsxs as kd}from"react/jsx-runtime";var Ei=({size:e=24,className:t})=>pr("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:[pr("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"}),pr("path",{d:"M24.5 4.5L28 1M28 1L31.5 4.5M28 1V8",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round"})]})});import{clsx as Dd}from"clsx";import{twMerge as Rd}from"tailwind-merge";function R(...e){return Rd(Dd(e))}var ze=(e=0,t=0)=>e<t?t:e,Po=(e=1e3)=>new Promise(t=>{setTimeout(t,e)});import{jsx as bi,jsxs as Vd}from"react/jsx-runtime";var _i=({size:e=24,className:t})=>Vd("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:[bi("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"}),bi("path",{d:"M9 3V21",strokeLinecap:"round",strokeLinejoin:"round"})]});import{jsx as fr}from"react/jsx-runtime";var Ti=({size:e=24,className:t})=>fr("svg",{width:e,height:e,viewBox:"0 0 24 24",xmlns:"http://www.w3.org/2000/svg",stroke:"currentColor",className:t,children:fr("g",{children:fr("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 vi}from"react/jsx-runtime";var Lo=({size:e=24,className:t})=>vi("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:vi("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 Ni}from"react/jsx-runtime";var Kt=({size:e=24,className:t})=>Ni("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:Ni("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 mr,jsxs as Od}from"react/jsx-runtime";var wi=({size:e=24,className:t})=>Od("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:[mr("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"}),mr("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"}),mr("path",{d:"M7.5 7.5V10H10",strokeWidth:"1.5",fill:"none",strokeLinecap:"round",strokeLinejoin:"round"})]});import{jsx as qt,jsxs as Hd}from"react/jsx-runtime";var Ii=({size:e=24,className:t})=>Hd("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:[qt("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"}),qt("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"}),qt("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"}),qt("path",{d:"M13.5 12H11",strokeWidth:"1",strokeLinecap:"round",strokeLinejoin:"round"}),qt("path",{d:"M13.5 10H11",strokeWidth:"1",strokeLinecap:"round",strokeLinejoin:"round"})]});import{jsx as ko,jsxs as Gd}from"react/jsx-runtime";var Ai=({size:e=24,className:t})=>Gd("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:[ko("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"}),ko("path",{d:"M8 21V14C8 13.4477 8.44772 13 9 13H15C15.5523 13 16 13.4477 16 14V21",strokeWidth:"1",fill:"none"}),ko("path",{d:"M10.2222 17H13.7777",strokeWidth:"1",strokeLinecap:"round",strokeLinejoin:"round"}),ko("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||{}),_e=(o=>(o.SCRIPT="SCRIPT",o.SUBPROCESS="SUBPROCESS",o))(_e||{}),Do={SCRIPT:{icon:zd},SUBPROCESS:{icon:Fd}},Fe=(t=>(t.LOOP="LOOP",t))(Fe||{}),Ro={LOOP:{icon:Bd}},Te=(n=>(n.EXCLUSIVE="EXCLUSIVE",n.PARALLEL="PARALLEL",n.COMPLEX="COMPLEX",n))(Te||{}),gr={EXCLUSIVE:{icon:yt},PARALLEL:{icon:xt},COMPLEX:{icon:ht}};import{ReactFlowProvider as ky}from"@xyflow/react";import{createContext as Dy,useContext as Ry,useEffect as Vy,useId as Oy,useMemo as Hy,useState as Be}from"react";import{Background as fy,MiniMap as my,ReactFlow as gy,SelectionMode as hy}from"@xyflow/react";import{forwardRef as yy,useImperativeHandle as xy}from"react";import{useEdgesState as Vh,useNodesState as Oh,useOnSelectionChange as Hh}from"@xyflow/react";import{useCallback as Un,useEffect as Gh,useState as Bh}from"react";import{create as Wd}from"zustand";import{useReactFlow as Yd}from"@xyflow/react";import{useCallback as Ud}from"react";var Vo=()=>{let{setEdges:e}=Yd();return Ud(()=>{let o=je.getState().pathEdgeIds;e(n=>n.map(r=>v(b({},r),{selected:o.includes(r.id)})))},[e])},je=Wd((e,t)=>({statusByNodeId:{},statusData:{},pathEdgeIds:[],setTaskStatuses:o=>{o!=null&&o.length&&e(n=>{let r=b({},n.statusByNodeId),i=b({},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:y,path:g}=p.shift();if(y===u)return g;let m=a[y]||[];for(let{targetId:h,edgeId:x}of m)f.has(h)||(f.add(h),p.push({node:h,path:[...g,x]}))}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 af,useReactFlow as lf,useStore as cf}from"@xyflow/react";var $d={value:()=>{}};function Si(){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 Oo(o)}function Oo(e){this._=e}function Xd(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}})}Oo.prototype=Si.prototype={constructor:Oo,on:function(e,t){var o=this._,n=Xd(e+"",o),r,i=-1,a=n.length;if(arguments.length<2){for(;++i<a;)if((r=(e=n[i]).type)&&(r=Kd(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]=Ci(o[r],e.name,t);else if(t==null)for(r in o)o[r]=Ci(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 Oo(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 Kd(e,t){for(var o=0,n=e.length,r;o<n;++o)if((r=e[o]).name===t)return r.value}function Ci(e,t,o){for(var n=0,r=e.length;n<r;++n)if(e[n].name===t){e[n]=$d,e=e.slice(0,n).concat(e.slice(n+1));break}return o!=null&&e.push({name:t,value:o}),e}var hr=Si;var Ho="http://www.w3.org/1999/xhtml",yr={svg:"http://www.w3.org/2000/svg",xhtml:Ho,xlink:"http://www.w3.org/1999/xlink",xml:"http://www.w3.org/XML/1998/namespace",xmlns:"http://www.w3.org/2000/xmlns/"};function De(e){var t=e+="",o=t.indexOf(":");return o>=0&&(t=e.slice(0,o))!=="xmlns"&&(e=e.slice(o+1)),yr.hasOwnProperty(t)?{space:yr[t],local:e}:e}function qd(e){return function(){var t=this.ownerDocument,o=this.namespaceURI;return o===Ho&&t.documentElement.namespaceURI===Ho?t.createElement(e):t.createElementNS(o,e)}}function Zd(e){return function(){return this.ownerDocument.createElementNS(e.space,e.local)}}function Go(e){var t=De(e);return(t.local?Zd:qd)(t)}function Jd(){}function et(e){return e==null?Jd:function(){return this.querySelector(e)}}function Mi(e){typeof e!="function"&&(e=et(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 Z(n,this._parents)}function xr(e){return e==null?[]:Array.isArray(e)?e:Array.from(e)}function Qd(){return[]}function Zt(e){return e==null?Qd:function(){return this.querySelectorAll(e)}}function jd(e){return function(){return xr(e.apply(this,arguments))}}function Pi(e){typeof e=="function"?e=jd(e):e=Zt(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 Z(n,r)}function Jt(e){return function(){return this.matches(e)}}function Bo(e){return function(t){return t.matches(e)}}var eu=Array.prototype.find;function tu(e){return function(){return eu.call(this.children,e)}}function ou(){return this.firstElementChild}function Li(e){return this.select(e==null?ou:tu(typeof e=="function"?e:Bo(e)))}var nu=Array.prototype.filter;function ru(){return Array.from(this.children)}function iu(e){return function(){return nu.call(this.children,e)}}function ki(e){return this.selectAll(e==null?ru:iu(typeof e=="function"?e:Bo(e)))}function Di(e){typeof e!="function"&&(e=Jt(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 Z(n,this._parents)}function zo(e){return new Array(e.length)}function Ri(){return new Z(this._enter||this._groups.map(zo),this._parents)}function Qt(e,t){this.ownerDocument=e.ownerDocument,this.namespaceURI=e.namespaceURI,this._next=null,this._parent=e,this.__data__=t}Qt.prototype={constructor:Qt,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 Vi(e){return function(){return e}}function su(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 Qt(e,i[a]);for(;a<l;++a)(s=t[a])&&(r[a]=s)}function au(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 Qt(e,i[s]);for(s=0;s<d;++s)(l=t[s])&&c.get(p[s])===l&&(r[s]=l)}function lu(e){return e.__data__}function Oi(e,t){if(!arguments.length)return Array.from(this,lu);var o=t?au:su,n=this._parents,r=this._groups;typeof e!="function"&&(e=Vi(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=cu(e.call(d,d&&d.__data__,c,n)),y=f.length,g=s[c]=new Array(y),m=a[c]=new Array(y),h=l[c]=new Array(p);o(d,u,g,m,h,f,t);for(var x=0,E=0,T,_;x<y;++x)if(T=g[x]){for(x>=E&&(E=x+1);!(_=m[E])&&++E<y;);T._next=_||null}}return a=new Z(a,n),a._enter=s,a._exit=l,a}function cu(e){return typeof e=="object"&&"length"in e?e:Array.from(e)}function Hi(){return new Z(this._exit||this._groups.map(zo),this._parents)}function Gi(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 Bi(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,y=0;y<u;++y)(f=c[y]||d[y])&&(p[y]=f);for(;l<r;++l)s[l]=o[l];return new Z(s,this._parents)}function zi(){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 Fi(e){e||(e=du);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 Z(r,this._parents).order()}function du(e,t){return e<t?-1:e>t?1:e>=t?0:NaN}function Wi(){var e=arguments[0];return arguments[0]=this,e.apply(null,arguments),this}function Yi(){return Array.from(this)}function Ui(){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 $i(){let e=0;for(let t of this)++e;return e}function Xi(){return!this.node()}function Ki(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 uu(e){return function(){this.removeAttribute(e)}}function pu(e){return function(){this.removeAttributeNS(e.space,e.local)}}function fu(e,t){return function(){this.setAttribute(e,t)}}function mu(e,t){return function(){this.setAttributeNS(e.space,e.local,t)}}function gu(e,t){return function(){var o=t.apply(this,arguments);o==null?this.removeAttribute(e):this.setAttribute(e,o)}}function hu(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 qi(e,t){var o=De(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?pu:uu:typeof t=="function"?o.local?hu:gu:o.local?mu:fu)(o,t))}function Fo(e){return e.ownerDocument&&e.ownerDocument.defaultView||e.document&&e||e.defaultView}function yu(e){return function(){this.style.removeProperty(e)}}function xu(e,t,o){return function(){this.style.setProperty(e,t,o)}}function Eu(e,t,o){return function(){var n=t.apply(this,arguments);n==null?this.style.removeProperty(e):this.style.setProperty(e,n,o)}}function Zi(e,t,o){return arguments.length>1?this.each((t==null?yu:typeof t=="function"?Eu:xu)(e,t,o==null?"":o)):We(this.node(),e)}function We(e,t){return e.style.getPropertyValue(t)||Fo(e).getComputedStyle(e,null).getPropertyValue(t)}function bu(e){return function(){delete this[e]}}function _u(e,t){return function(){this[e]=t}}function Tu(e,t){return function(){var o=t.apply(this,arguments);o==null?delete this[e]:this[e]=o}}function Ji(e,t){return arguments.length>1?this.each((t==null?bu:typeof t=="function"?Tu:_u)(e,t)):this.node()[e]}function Qi(e){return e.trim().split(/^|\s+/)}function Er(e){return e.classList||new ji(e)}function ji(e){this._node=e,this._names=Qi(e.getAttribute("class")||"")}ji.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 es(e,t){for(var o=Er(e),n=-1,r=t.length;++n<r;)o.add(t[n])}function ts(e,t){for(var o=Er(e),n=-1,r=t.length;++n<r;)o.remove(t[n])}function vu(e){return function(){es(this,e)}}function Nu(e){return function(){ts(this,e)}}function wu(e,t){return function(){(t.apply(this,arguments)?es:ts)(this,e)}}function os(e,t){var o=Qi(e+"");if(arguments.length<2){for(var n=Er(this.node()),r=-1,i=o.length;++r<i;)if(!n.contains(o[r]))return!1;return!0}return this.each((typeof t=="function"?wu:t?vu:Nu)(o,t))}function Iu(){this.textContent=""}function Au(e){return function(){this.textContent=e}}function Cu(e){return function(){var t=e.apply(this,arguments);this.textContent=t==null?"":t}}function ns(e){return arguments.length?this.each(e==null?Iu:(typeof e=="function"?Cu:Au)(e)):this.node().textContent}function Su(){this.innerHTML=""}function Mu(e){return function(){this.innerHTML=e}}function Pu(e){return function(){var t=e.apply(this,arguments);this.innerHTML=t==null?"":t}}function rs(e){return arguments.length?this.each(e==null?Su:(typeof e=="function"?Pu:Mu)(e)):this.node().innerHTML}function Lu(){this.nextSibling&&this.parentNode.appendChild(this)}function is(){return this.each(Lu)}function ku(){this.previousSibling&&this.parentNode.insertBefore(this,this.parentNode.firstChild)}function ss(){return this.each(ku)}function as(e){var t=typeof e=="function"?e:Go(e);return this.select(function(){return this.appendChild(t.apply(this,arguments))})}function Du(){return null}function ls(e,t){var o=typeof e=="function"?e:Go(e),n=t==null?Du:typeof t=="function"?t:et(t);return this.select(function(){return this.insertBefore(o.apply(this,arguments),n.apply(this,arguments)||null)})}function Ru(){var e=this.parentNode;e&&e.removeChild(this)}function cs(){return this.each(Ru)}function Vu(){var e=this.cloneNode(!1),t=this.parentNode;return t?t.insertBefore(e,this.nextSibling):e}function Ou(){var e=this.cloneNode(!0),t=this.parentNode;return t?t.insertBefore(e,this.nextSibling):e}function ds(e){return this.select(e?Ou:Vu)}function us(e){return arguments.length?this.property("__data__",e):this.node().__data__}function Hu(e){return function(t){e.call(this,t,this.__data__)}}function Gu(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 Bu(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 zu(e,t,o){return function(){var n=this.__on,r,i=Hu(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 ps(e,t,o){var n=Gu(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?zu:Bu,r=0;r<i;++r)this.each(s(n[r],t,o));return this}function fs(e,t,o){var n=Fo(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 Fu(e,t){return function(){return fs(this,e,t)}}function Wu(e,t){return function(){return fs(this,e,t.apply(this,arguments))}}function ms(e,t){return this.each((typeof t=="function"?Wu:Fu)(e,t))}function*gs(){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 Yu=[null];function Z(e,t){this._groups=e,this._parents=t}function hs(){return new Z([[document.documentElement]],Yu)}function Uu(){return this}Z.prototype=hs.prototype={constructor:Z,select:Mi,selectAll:Pi,selectChild:Li,selectChildren:ki,filter:Di,data:Oi,enter:Ri,exit:Hi,join:Gi,merge:Bi,selection:Uu,order:zi,sort:Fi,call:Wi,nodes:Yi,node:Ui,size:$i,empty:Xi,each:Ki,attr:qi,style:Zi,property:Ji,classed:os,text:ns,html:rs,raise:is,lower:ss,append:as,insert:ls,remove:cs,clone:ds,datum:us,on:ps,dispatch:ms,[Symbol.iterator]:gs};var Re=hs;function Wo(e,t,o){e.prototype=t.prototype=o,o.constructor=e}function br(e,t){var o=Object.create(e.prototype);for(var n in t)o[n]=t[n];return o}function to(){}var jt=.7,$o=1/jt,Et="\\s*([+-]?\\d+)\\s*",eo="\\s*([+-]?(?:\\d*\\.)?\\d+(?:[eE][+-]?\\d+)?)\\s*",Ce="\\s*([+-]?(?:\\d*\\.)?\\d+(?:[eE][+-]?\\d+)?)%\\s*",$u=/^#([0-9a-f]{3,8})$/,Xu=new RegExp(`^rgb\\(${Et},${Et},${Et}\\)$`),Ku=new RegExp(`^rgb\\(${Ce},${Ce},${Ce}\\)$`),qu=new RegExp(`^rgba\\(${Et},${Et},${Et},${eo}\\)$`),Zu=new RegExp(`^rgba\\(${Ce},${Ce},${Ce},${eo}\\)$`),Ju=new RegExp(`^hsl\\(${eo},${Ce},${Ce}\\)$`),Qu=new RegExp(`^hsla\\(${eo},${Ce},${Ce},${eo}\\)$`),ys={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};Wo(to,Ye,{copy(e){return Object.assign(new this.constructor,this,e)},displayable(){return this.rgb().displayable()},hex:xs,formatHex:xs,formatHex8:ju,formatHsl:ep,formatRgb:Es,toString:Es});function xs(){return this.rgb().formatHex()}function ju(){return this.rgb().formatHex8()}function ep(){return ws(this).formatHsl()}function Es(){return this.rgb().formatRgb()}function Ye(e){var t,o;return e=(e+"").trim().toLowerCase(),(t=$u.exec(e))?(o=t[1].length,t=parseInt(t[1],16),o===6?bs(t):o===3?new de(t>>8&15|t>>4&240,t>>4&15|t&240,(t&15)<<4|t&15,1):o===8?Yo(t>>24&255,t>>16&255,t>>8&255,(t&255)/255):o===4?Yo(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=Xu.exec(e))?new de(t[1],t[2],t[3],1):(t=Ku.exec(e))?new de(t[1]*255/100,t[2]*255/100,t[3]*255/100,1):(t=qu.exec(e))?Yo(t[1],t[2],t[3],t[4]):(t=Zu.exec(e))?Yo(t[1]*255/100,t[2]*255/100,t[3]*255/100,t[4]):(t=Ju.exec(e))?vs(t[1],t[2]/100,t[3]/100,1):(t=Qu.exec(e))?vs(t[1],t[2]/100,t[3]/100,t[4]):ys.hasOwnProperty(e)?bs(ys[e]):e==="transparent"?new de(NaN,NaN,NaN,0):null}function bs(e){return new de(e>>16&255,e>>8&255,e&255,1)}function Yo(e,t,o,n){return n<=0&&(e=t=o=NaN),new de(e,t,o,n)}function tp(e){return e instanceof to||(e=Ye(e)),e?(e=e.rgb(),new de(e.r,e.g,e.b,e.opacity)):new de}function bt(e,t,o,n){return arguments.length===1?tp(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}Wo(de,bt,br(to,{brighter(e){return e=e==null?$o:Math.pow($o,e),new de(this.r*e,this.g*e,this.b*e,this.opacity)},darker(e){return e=e==null?jt:Math.pow(jt,e),new de(this.r*e,this.g*e,this.b*e,this.opacity)},rgb(){return this},clamp(){return new de(ot(this.r),ot(this.g),ot(this.b),Xo(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:_s,formatHex:_s,formatHex8:op,formatRgb:Ts,toString:Ts}));function _s(){return`#${tt(this.r)}${tt(this.g)}${tt(this.b)}`}function op(){return`#${tt(this.r)}${tt(this.g)}${tt(this.b)}${tt((isNaN(this.opacity)?1:this.opacity)*255)}`}function Ts(){let e=Xo(this.opacity);return`${e===1?"rgb(":"rgba("}${ot(this.r)}, ${ot(this.g)}, ${ot(this.b)}${e===1?")":`, ${e})`}`}function Xo(e){return isNaN(e)?1:Math.max(0,Math.min(1,e))}function ot(e){return Math.max(0,Math.min(255,Math.round(e)||0))}function tt(e){return e=ot(e),(e<16?"0":"")+e.toString(16)}function vs(e,t,o,n){return n<=0?e=t=o=NaN:o<=0||o>=1?e=t=NaN:t<=0&&(e=NaN),new ve(e,t,o,n)}function ws(e){if(e instanceof ve)return new ve(e.h,e.s,e.l,e.opacity);if(e instanceof to||(e=Ye(e)),!e)return new ve;if(e instanceof ve)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 ve(a,s,l,e.opacity)}function Is(e,t,o,n){return arguments.length===1?ws(e):new ve(e,t,o,n==null?1:n)}function ve(e,t,o,n){this.h=+e,this.s=+t,this.l=+o,this.opacity=+n}Wo(ve,Is,br(to,{brighter(e){return e=e==null?$o:Math.pow($o,e),new ve(this.h,this.s,this.l*e,this.opacity)},darker(e){return e=e==null?jt:Math.pow(jt,e),new ve(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(_r(e>=240?e-240:e+120,r,n),_r(e,r,n),_r(e<120?e+240:e-120,r,n),this.opacity)},clamp(){return new ve(Ns(this.h),Uo(this.s),Uo(this.l),Xo(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=Xo(this.opacity);return`${e===1?"hsl(":"hsla("}${Ns(this.h)}, ${Uo(this.s)*100}%, ${Uo(this.l)*100}%${e===1?")":`, ${e})`}`}}));function Ns(e){return e=(e||0)%360,e<0?e+360:e}function Uo(e){return Math.max(0,Math.min(1,e||0))}function _r(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 Tr(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 As(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 Tr((o-n/t)*t,a,r,i,s)}}function Cs(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 Tr((o-n/t)*t,r,i,a,s)}}var vr=e=>()=>e;function np(e,t){return function(o){return e+o*t}}function rp(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 Ss(e){return(e=+e)==1?Ko:function(t,o){return o-t?rp(t,o,e):vr(isNaN(t)?o:t)}}function Ko(e,t){var o=t-e;return o?np(e,o):vr(isNaN(e)?t:e)}var qo=function e(t){var o=Ss(t);function n(r,i){var a=o((r=bt(r)).r,(i=bt(i)).r),s=o(r.g,i.g),l=o(r.b,i.b),c=Ko(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 Ms(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=bt(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 ip=Ms(As),sp=Ms(Cs);function he(e,t){return e=+e,t=+t,function(o){return e*(1-o)+t*o}}var wr=/[-+]?(?:\d+\.?\d*|\.?\d+)(?:[eE][-+]?\d+)?/g,Nr=new RegExp(wr.source,"g");function ap(e){return function(){return e}}function lp(e){return function(t){return e(t)+""}}function Ir(e,t){var o=wr.lastIndex=Nr.lastIndex=0,n,r,i,a=-1,s=[],l=[];for(e=e+"",t=t+"";(n=wr.exec(e))&&(r=Nr.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=Nr.lastIndex;return o<t.length&&(i=t.slice(o),s[a]?s[a]+=i:s[++a]=i),s.length<2?l[0]?lp(l[0].x):ap(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 Ps=180/Math.PI,Zo={translateX:0,translateY:0,rotate:0,skewX:0,scaleX:1,scaleY:1};function Ar(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)*Ps,skewX:Math.atan(l)*Ps,scaleX:a,scaleY:s}}var Jo;function Ls(e){let t=new(typeof DOMMatrix=="function"?DOMMatrix:WebKitCSSMatrix)(e+"");return t.isIdentity?Zo:Ar(t.a,t.b,t.c,t.d,t.e,t.f)}function ks(e){return e==null?Zo:(Jo||(Jo=document.createElementNS("http://www.w3.org/2000/svg","g")),Jo.setAttribute("transform",e),(e=Jo.transform.baseVal.consolidate())?(e=e.matrix,Ar(e.a,e.b,e.c,e.d,e.e,e.f)):Zo)}function Ds(e,t,o,n){function r(c){return c.length?c.pop()+" ":""}function i(c,d,u,p,f,y){if(c!==u||d!==p){var g=f.push("translate(",null,t,null,o);y.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,y){if(c!==u||d!==p){var g=f.push(r(f)+"scale(",null,",",null,")");y.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 y=-1,g=p.length,m;++y<g;)u[(m=p[y]).i]=m.x(f);return u.join("")}}}var Cr=Ds(Ls,"px, ","px)","deg)"),Sr=Ds(ks,", ",")",")");var _t=0,no=0,oo=0,Vs=1e3,Qo,ro,jo=0,nt=0,en=0,io=typeof performance=="object"&&performance.now?performance:Date,Os=typeof window=="object"&&window.requestAnimationFrame?window.requestAnimationFrame.bind(window):function(e){setTimeout(e,17)};function ao(){return nt||(Os(cp),nt=io.now()+en)}function cp(){nt=0}function so(){this._call=this._time=this._next=null}so.prototype=tn.prototype={constructor:so,restart:function(e,t,o){if(typeof e!="function")throw new TypeError("callback is not a function");o=(o==null?ao():+o)+(t==null?0:+t),!this._next&&ro!==this&&(ro?ro._next=this:Qo=this,ro=this),this._call=e,this._time=o,Mr()},stop:function(){this._call&&(this._call=null,this._time=1/0,Mr())}};function tn(e,t,o){var n=new so;return n.restart(e,t,o),n}function Hs(){ao(),++_t;for(var e=Qo,t;e;)(t=nt-e._time)>=0&&e._call.call(void 0,t),e=e._next;--_t}function Rs(){nt=(jo=io.now())+en,_t=no=0;try{Hs()}finally{_t=0,up(),nt=0}}function dp(){var e=io.now(),t=e-jo;t>Vs&&(en-=t,jo=e)}function up(){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);ro=e,Mr(n)}function Mr(e){if(!_t){no&&(no=clearTimeout(no));var t=e-nt;t>24?(e<1/0&&(no=setTimeout(Rs,e-io.now()-en)),oo&&(oo=clearInterval(oo))):(oo||(jo=io.now(),oo=setInterval(dp,Vs)),_t=1,Os(Rs))}}function on(e,t,o){var n=new so;return t=t==null?0:+t,n.restart(r=>{n.stop(),e(r+t)},t,o),n}var pp=hr("start","end","cancel","interrupt"),fp=[],zs=0,Gs=1,rn=2,nn=3,Bs=4,sn=5,lo=6;function Ue(e,t,o,n,r,i){var a=e.__transition;if(!a)e.__transition={};else if(o in a)return;mp(e,o,{name:t,index:n,group:r,on:pp,tween:fp,time:i.time,delay:i.delay,duration:i.duration,ease:i.ease,timer:null,state:zs})}function co(e,t){var o=J(e,t);if(o.state>zs)throw new Error("too late; already scheduled");return o}function oe(e,t){var o=J(e,t);if(o.state>nn)throw new Error("too late; already running");return o}function J(e,t){var o=e.__transition;if(!o||!(o=o[t]))throw new Error("transition not found");return o}function mp(e,t,o){var n=e.__transition,r;n[t]=o,o.timer=tn(i,0,o.time);function i(c){o.state=Gs,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!==Gs)return l();for(d in n)if(f=n[d],f.name===o.name){if(f.state===nn)return on(a);f.state===Bs?(f.state=lo,f.timer.stop(),f.on.call("interrupt",e,e.__data__,f.index,f.group),delete n[d]):+d<t&&(f.state=lo,f.timer.stop(),f.on.call("cancel",e,e.__data__,f.index,f.group),delete n[d])}if(on(function(){o.state===nn&&(o.state=Bs,o.timer.restart(s,o.delay,o.time),s(c))}),o.state=rn,o.on.call("start",e,e.__data__,o.index,o.group),o.state===rn){for(o.state=nn,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=sn,1),u=-1,p=r.length;++u<p;)r[u].call(e,d);o.state===sn&&(o.on.call("end",e,e.__data__,o.index,o.group),l())}function l(){o.state=lo,o.timer.stop(),delete n[t];for(var c in n)return;delete e.__transition}}function Pr(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>rn&&n.state<sn,n.state=lo,n.timer.stop(),n.on.call(r?"interrupt":"cancel",e,e.__data__,n.index,n.group),delete o[a]}i&&delete e.__transition}}function Fs(e){return this.each(function(){Pr(this,e)})}function gp(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 hp(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 Ws(e,t){var o=this._id;if(e+="",arguments.length<2){for(var n=J(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?gp:hp)(o,e,t))}function Tt(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 J(r,n).value[t]}}function an(e,t){var o;return(typeof t=="number"?he:t instanceof Ye?qo:(o=Ye(t))?(t=o,qo):Ir)(e,t)}function yp(e){return function(){this.removeAttribute(e)}}function xp(e){return function(){this.removeAttributeNS(e.space,e.local)}}function Ep(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 bp(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 _p(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 Tp(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 Ys(e,t){var o=De(e),n=o==="transform"?Sr:an;return this.attrTween(e,typeof t=="function"?(o.local?Tp:_p)(o,n,Tt(this,"attr."+e,t)):t==null?(o.local?xp:yp)(o):(o.local?bp:Ep)(o,n,t))}function vp(e,t){return function(o){this.setAttribute(e,t.call(this,o))}}function Np(e,t){return function(o){this.setAttributeNS(e.space,e.local,t.call(this,o))}}function wp(e,t){var o,n;function r(){var i=t.apply(this,arguments);return i!==n&&(o=(n=i)&&Np(e,i)),o}return r._value=t,r}function Ip(e,t){var o,n;function r(){var i=t.apply(this,arguments);return i!==n&&(o=(n=i)&&vp(e,i)),o}return r._value=t,r}function Us(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=De(e);return this.tween(o,(n.local?wp:Ip)(n,t))}function Ap(e,t){return function(){co(this,e).delay=+t.apply(this,arguments)}}function Cp(e,t){return t=+t,function(){co(this,e).delay=t}}function $s(e){var t=this._id;return arguments.length?this.each((typeof e=="function"?Ap:Cp)(t,e)):J(this.node(),t).delay}function Sp(e,t){return function(){oe(this,e).duration=+t.apply(this,arguments)}}function Mp(e,t){return t=+t,function(){oe(this,e).duration=t}}function Xs(e){var t=this._id;return arguments.length?this.each((typeof e=="function"?Sp:Mp)(t,e)):J(this.node(),t).duration}function Pp(e,t){if(typeof t!="function")throw new Error;return function(){oe(this,e).ease=t}}function Ks(e){var t=this._id;return arguments.length?this.each(Pp(t,e)):J(this.node(),t).ease}function Lp(e,t){return function(){var o=t.apply(this,arguments);if(typeof o!="function")throw new Error;oe(this,e).ease=o}}function qs(e){if(typeof e!="function")throw new Error;return this.each(Lp(this._id,e))}function Zs(e){typeof e!="function"&&(e=Jt(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 Js(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 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 Dp(e,t,o){var n,r,i=kp(t)?co:oe;return function(){var a=i(this,e),s=a.on;s!==n&&(r=(n=s).copy()).on(t,o),a.on=r}}function Qs(e,t){var o=this._id;return arguments.length<2?J(this.node(),o).on.on(e):this.each(Dp(o,e,t))}function Rp(e){return function(){var t=this.parentNode;for(var o in this.__transition)if(+o!==e)return;t&&t.removeChild(this)}}function js(){return this.on("end.remove",Rp(this._id))}function ea(e){var t=this._name,o=this._id;typeof e!="function"&&(e=et(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,Ue(c[p],t,o,p,c,J(d,o)));return new le(i,this._parents,t,o)}function ta(e){var t=this._name,o=this._id;typeof e!="function"&&(e=Zt(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,y=J(d,o),g=0,m=p.length;g<m;++g)(f=p[g])&&Ue(f,t,o,g,p,y);i.push(p),a.push(d)}return new le(i,a,t,o)}var Vp=Re.prototype.constructor;function oa(){return new Vp(this._groups,this._parents)}function Op(e,t){var o,n,r;return function(){var i=We(this,e),a=(this.style.removeProperty(e),We(this,e));return i===a?null:i===o&&a===n?r:r=t(o=i,n=a)}}function na(e){return function(){this.style.removeProperty(e)}}function Hp(e,t,o){var n,r=o+"",i;return function(){var a=We(this,e);return a===r?null:a===n?i:i=t(n=a,o)}}function Gp(e,t,o){var n,r,i;return function(){var a=We(this,e),s=o(this),l=s+"";return s==null&&(l=s=(this.style.removeProperty(e),We(this,e))),a===l?null:a===n&&l===r?i:(r=l,i=t(n=a,s))}}function Bp(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=na(t)):void 0;(c!==o||r!==d)&&(n=(o=c).copy()).on(a,r=d),l.on=n}}function ra(e,t,o){var n=(e+="")=="transform"?Cr:an;return t==null?this.styleTween(e,Op(e,n)).on("end.style."+e,na(e)):typeof t=="function"?this.styleTween(e,Gp(e,n,Tt(this,"style."+e,t))).each(Bp(this._id,e)):this.styleTween(e,Hp(e,n,t),o).on("end.style."+e,null)}function zp(e,t,o){return function(n){this.style.setProperty(e,t.call(this,n),o)}}function Fp(e,t,o){var n,r;function i(){var a=t.apply(this,arguments);return a!==r&&(n=(r=a)&&zp(e,a,o)),n}return i._value=t,i}function ia(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,Fp(e,t,o==null?"":o))}function Wp(e){return function(){this.textContent=e}}function Yp(e){return function(){var t=e(this);this.textContent=t==null?"":t}}function sa(e){return this.tween("text",typeof e=="function"?Yp(Tt(this,"text",e)):Wp(e==null?"":e+""))}function Up(e){return function(t){this.textContent=e.call(this,t)}}function $p(e){var t,o;function n(){var r=e.apply(this,arguments);return r!==o&&(t=(o=r)&&Up(r)),t}return n._value=e,n}function aa(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,$p(e))}function la(){for(var e=this._name,t=this._id,o=ln(),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=J(l,t);Ue(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 ca(){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 Xp=0;function le(e,t,o,n){this._groups=e,this._parents=t,this._name=o,this._id=n}function da(e){return Re().transition(e)}function ln(){return++Xp}var Ve=Re.prototype;le.prototype=da.prototype={constructor:le,select:ea,selectAll:ta,selectChild:Ve.selectChild,selectChildren:Ve.selectChildren,filter:Zs,merge:Js,selection:oa,transition:la,call:Ve.call,nodes:Ve.nodes,node:Ve.node,size:Ve.size,empty:Ve.empty,each:Ve.each,on:Qs,attr:Ys,attrTween:Us,style:ra,styleTween:ia,text:sa,textTween:aa,remove:js,tween:Ws,delay:$s,duration:Xs,ease:Ks,easeVarying:qs,end:ca,[Symbol.iterator]:Ve[Symbol.iterator]};function cn(e){return((e*=2)<=1?e*e*e:(e-=2)*e*e+2)/2}var Kp={time:null,delay:0,duration:250,ease:cn};function qp(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 ua(e){var t,o;e instanceof le?(t=e._id,e=e._name):(t=ln(),(o=Kp).time=ao(),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])&&Ue(l,e,t,c,a,o||qp(l,t));return new le(n,this._parents,e,t)}Re.prototype.interrupt=Fs;Re.prototype.transition=ua;function $e(e,t,o){this.k=e,this.x=t,this.y=o}$e.prototype={constructor:$e,scale:function(e){return e===1?this:new $e(this.k*e,this.x,this.y)},translate:function(e,t){return e===0&t===0?this:new $e(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 dn=new $e(1,0,0);un.prototype=$e.prototype;function un(e){for(;!e.__zoom;)if(!(e=e.parentNode))return dn;return e.__zoom}var Jp=[[Number.NEGATIVE_INFINITY,Number.NEGATIVE_INFINITY],[Number.POSITIVE_INFINITY,Number.POSITIVE_INFINITY]];var pa;(function(e){e.Strict="strict",e.Loose="loose"})(pa||(pa={}));var fa;(function(e){e.Free="free",e.Vertical="vertical",e.Horizontal="horizontal"})(fa||(fa={}));var ma;(function(e){e.Partial="partial",e.Full="full"})(ma||(ma={}));var ga;(function(e){e.Bezier="default",e.Straight="straight",e.Step="step",e.SmoothStep="smoothstep",e.SimpleBezier="simplebezier"})(ga||(ga={}));var ha;(function(e){e.Arrow="arrow",e.ArrowClosed="arrowclosed"})(ha||(ha={}));var ue;(function(e){e.Left="left",e.Top="top",e.Right="right",e.Bottom="bottom"})(ue||(ue={}));var mv={[ue.Left]:ue.Right,[ue.Right]:ue.Left,[ue.Top]:ue.Bottom,[ue.Bottom]:ue.Top};var Qp=e=>"id"in e&&"internals"in e&&!("source"in e)&&!("target"in e);var jp=(e,t=[0,0])=>{var s;let{width:o,height:n}=ef(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}=Qp(e)?e.internals.positionAbsolute:jp(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 ef(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 gv={[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 tf={nodeOrigin:[0,0],nodeExtent:Jp,elevateNodesOnSelect:!0,defaults:{}},hv=v(b({},tf),{checkEquality:!0});var ya;(function(e){e.Line="line",e.Handle="handle"})(ya||(ya={}));var of={width:0,height:0,x:0,y:0},yv=v(b({},of),{pointerX:0,pointerY:0,aspectRatio:1});import{useCallback as uo,useEffect as df,useRef as uf,useState as _a}from"react";import{shallow as pf}from"zustand/shallow";var nf=(e,t)=>e.x<t.x2&&e.x2>t.x&&e.y<t.y2&&e.y2>t.y;function rf(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 sf(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 pn=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||!nf(p.nodeBox,r))continue;let f=Math.abs(p.position-o);if(f>fn)continue;let g=rf(p.nodeBox,fe(n))>0?0:sf(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 xa(e,t=rt,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 Ea(e,t,o,n,r=Object.keys(rt)){let i=[];for(let s of r){let l=rt[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 ba(e,t,o,n,r,i,a,s){var u,p,f,y,g,m,h,x;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+((y=(f=e.measured)==null?void 0:f.height)!=null?y:0)};if(a){let T=a.anchor.resolve(e,d)-a.line.position;if(Math.abs(T)<=fn){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)<=fn){if(o.position.x-=T,r!=null&&r.dimensions)if(n){let _=t.internals.positionAbsolute.x+((x=(h=e.measured)==null?void 0:h.width)!=null?x: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 fn=10,rt={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 mf}from"react/jsx-runtime";var ff=new pn;function vt(){let[e,t]=_a(void 0),[o,n]=_a(void 0),{width:r,height:i}=cf(m=>({width:m.width,height:m.height}),pf),a=af(),s=uf(ff),{screenToFlowPosition:l,getInternalNode:c,getNodes:d}=lf(),u=uo(()=>{t(void 0),n(void 0)},[]),p=uo(m=>{let h=m!=null?m:d();u();let x=xa(h,rt,c);s.current.initialize(x)},[c,u,d]),f=uo(()=>{setTimeout(()=>{p()},100)},[p]);df(()=>{a&&p(d())},[a,p,d]);let y=uo((m,h)=>{var $,D,H,z,W;if(!s.current||m.length===0||m.length>2)return m;u();let x,E,T=Object.keys(rt);m.length===1?m[0].type==="position"?x=m[0]:m[0].type==="dimensions"&&(E=m[0],T=["right","bottom"]):m[0].type==="position"&&m[1].type==="dimensions"&&m[1].dimensions&&(x=m[0],E=m[1],T=["top","left"]);let _=h.find(Y=>Y.id===m[0].id);if(!_)return m;let N=c(_.id);if(!N)throw new Error(`Node with id ${_.id} not found in internal nodes`);let w=c(($=N.parentId)!=null?$:""),S=fe(N);E!=null&&E.dimensions&&(S.x2=S.x+E.dimensions.width,S.y2=S.y+E.dimensions.height);let{x:P,y:L}=l({x:0,y:0}),{x:C,y:I}=l({x:r,y:i}),M={x:P,y:L,x2:C,y2:I},{horizontal:A,vertical:k}=Ea(s.current,M,_,S,T),V={id:_.id,type:"position",position:{x:N.internals.positionAbsolute.x,y:N.internals.positionAbsolute.y},dragging:!1};x!=null&&x.position&&V.position&&(w?(V.position.x=x.position.x+((H=(D=w==null?void 0:w.position)==null?void 0:D.x)!=null?H:0),V.position.y=x.position.y+((W=(z=w==null?void 0:w.position)==null?void 0:z.y)!=null?W:0)):(V.position.x=x.position.x,V.position.y=x.position.y));let{snappedX:O,snappedY:B}=ba(_,N,V,x,E,w,A,k);if(O||B){if((E!=null&&E.resizing||x!=null&&x.dragging)&&(O&&n(k==null?void 0:k.line),B&&t(A==null?void 0:A.line)),E&&x)return[V,E];if(x)return[V];if(E)return[E]}return m},[l,c,r,i,t,n,u]),g=uo(()=>mf(Ta,{horizontal:e,vertical:o}),[e,o]);return{rebuildIndex:p,forceRebuildIndex:f,updateHelperLines:y,helperLineHorizontal:e,helperLineVertical:o,HelperLines:g}}import{reconnectEdge as ih,useReactFlow as sh}from"@xyflow/react";import{useCallback as dt,useRef as ah}from"react";var Nt=e=>new Map(e.map(t=>[t.id,t])),po=(e,t,o)=>t.filter(n=>!(n.source!==e||o&&n.id===o)),va=(e,t,o)=>t.filter(n=>!(n.target!==e||o&&n.id===o)),mn=e=>e.some(t=>t.type==="START_EVENT"),Na=(e,t,o,n,r)=>{let i=Nt(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:po(e,n,r).filter(c=>{let d=i.get(c.target);return(d==null?void 0:d.type)!=="ANNOTATION"}).length>=1},wa=(e,t,o,n,r)=>{let i=Nt(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:va(t,n,r).filter(c=>{let d=i.get(c.source);return(d==null?void 0:d.type)!=="ANNOTATION"}).length>=1},gn=(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:po(e,o,n).length>=2},Ia=(e,t,o)=>{var a,s,l,c;let n=Nt(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"},hn=(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"},xn=(e,t,o,n)=>{let r=Nt(t),i=r.get(e);return!i||i.type!=="TASK"?!1:va(e,o,n).some(s=>{let l=r.get(s.source);return(l==null?void 0:l.type)==="START_EVENT"})},En=(e,t,o,n)=>{let r=Nt(t),i=r.get(e);return!i||i.type!=="TASK"?!1:po(e,o,n).some(s=>{let l=r.get(s.target);return(l==null?void 0:l.type)==="END_EVENT"})},bn=(e,t,o)=>po(e,t,o).length>0,_n=(e,t,o,n,r)=>{let i=Nt(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:po(e,n,r).filter(c=>{let d=i.get(c.target);return(d==null?void 0:d.type)!=="ANNOTATION"}).length>=2};var gf=[e=>({isValid:e.sourceNodeId!==e.targetNodeId,reason:"self_connection_not_allowed"}),e=>({isValid:!Na(e.sourceNodeId,e.targetNodeId,e.nodes,e.edges,e.reconnectingEdgeId),reason:"start_event_limit_reached"}),e=>({isValid:!wa(e.sourceNodeId,e.targetNodeId,e.nodes,e.edges,e.reconnectingEdgeId),reason:"end_event_limit_reached"}),e=>({isValid:!gn(e.sourceNodeId,e.nodes,e.edges,e.reconnectingEdgeId),reason:"gateway_limit_reached"}),e=>({isValid:!_n(e.sourceNodeId,e.targetNodeId,e.nodes,e.edges,e.reconnectingEdgeId),reason:"task_limit_reached"}),e=>({isValid:Ia(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:!(hn(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:!(xn(e.sourceNodeId,e.nodes,e.edges,e.reconnectingEdgeId)&&e.targetNodeType==="END_EVENT"),reason:"initial_activity_to_end_not_allowed"}),e=>({isValid:!(En(e.sourceNodeId,e.nodes,e.edges,e.reconnectingEdgeId)&&e.targetNodeType!=="ANNOTATION"),reason:"final_activity_cannot_connect"}),e=>({isValid:!(bn(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"})],Lr=e=>{for(let t of gf){let o=t(e);if(!o.isValid)return o}return{isValid:!0}};var hf=[{sourceTypes:["GATEWAY"],targetTypes:["TASK","GATEWAY"],validate:e=>({shouldDisable:gn(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:mn(e.nodes),reason:"start_event_already_exists"})},{sourceTypes:["TASK"],targetTypes:["END_EVENT"],validate:e=>({shouldDisable:hn(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:xn(e.sourceNodeId,e.nodes,e.edges),reason:"initial_activity_to_end_not_allowed"})},{sourceTypes:["TASK"],validate:e=>({shouldDisable:En(e.sourceNodeId,e.nodes,e.edges)&&e.targetNodeType!=="ANNOTATION",reason:"final_activity_cannot_connect"})},{targetTypes:["END_EVENT"],validate:e=>({shouldDisable:bn(e.sourceNodeId,e.edges),reason:"activity_has_outgoing_connections"})},{sourceTypes:["TASK"],validate:e=>({shouldDisable:_n(e.sourceNodeId,null,e.nodes,e.edges)&&e.targetNodeType!=="ANNOTATION",reason:"task_limit_reached"})}],Aa=e=>{let t=hf.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 Ff,EdgeLabelRenderer as Wf,getStraightPath as Yf,useInternalNode as Ma,useViewport as Uf}from"@xyflow/react";import{Position as fo}from"@xyflow/react";function Ca(e,t){var E,T,_,N;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=(E=t==null?void 0:t.measured)==null?void 0:E.width)!=null?T:0)/2,u=i.y+((N=(_=t==null?void 0:t.measured)==null?void 0:_.height)!=null?N:0)/2,p=(d-l)/(2*a)-(u-c)/(2*s),f=(d-l)/(2*a)+(u-c)/(2*s),y=1/(Math.abs(p)+Math.abs(f)||1),g=y*p,m=y*f,h=a*(g+m)+l,x=s*(-g+m)+c;return{x:h,y:x}}function Sa(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?fo.Left:s>=i+n-1?fo.Right:l<=a+1?fo.Top:l>=a+r-1?fo.Bottom:fo.Top}function Se(e,t){let o=Ca(e,t),n=Ca(t,e),r=Sa(e,o),i=Sa(t,n);return{sx:o.x,sy:o.y,tx:n.x,ty:n.y,sourcePos:r,targetPos:i}}import{Button as Ef,Tooltip as bf,TooltipContent as _f,TooltipTrigger as Tf,useTranslation as vf}from"lecom-ui";import{Settings as Nf}from"lucide-react";import{getIncomers as Tn,getOutgoers as vn,useReactFlow as xf}from"@xyflow/react";import{useStoreApi as yf}from"@xyflow/react";var Xe=()=>{let e=yf();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 Po(),!0}}};var Nn=()=>{let{getNode:e,getEdge:t,getNodes:o,getEdges:n}=xf(),{selectElements:r}=Xe(),i=m=>{let h=o(),x=n(),E=Tn(m,h,x),T=vn(m,h,x),_=E.some(w=>w.type==="START_EVENT"),N=T.some(w=>w.type==="END_EVENT");return _?"start":N?"end":"between"},a=(m,h,x)=>{var _,N,w,S;if(!m)return;let E={type:m.type,variant:(_=m.data)==null?void 0:_.variant,attribute:(N=m.data)==null?void 0:N.attribute},T={id:m.id,position:i(m),label:(w=m.data)==null?void 0:w.label,node:E};return m.type==="TASK"&&((S=m.data)==null?void 0:S.variant)==="SUBPROCESS"?v(b({},T),{type:"sub_process"}):m.type==="GATEWAY"?v(b({},T),{type:"gateway",variant:s(m,h,x)}):v(b({},T),{type:"activity"})},s=(m,h,x)=>{if(m.type!=="GATEWAY")return;let E=Tn(m,h,x),T=!1,_=!1;if(E.forEach(N=>{var w,S;N.type==="TASK"&&(((w=N.data)==null?void 0:w.variant)==="SCRIPT"&&(T=!0),((S=N.data)==null?void 0:S.attribute)==="LOOP"&&(_=!0))}),T&&_)return"script_loop";if(T)return"script";if(_)return"loop"},l=(m,h,x)=>{var w,S,P,L;let E=e(m.source),T=e(m.target);if(!E||!T)return"simple";if(vn(E,h,x).some(C=>C.type==="END_EVENT"))return"final";if(E.type==="GATEWAY")switch((w=E.data)==null?void 0:w.variant){case"PARALLEL":return"parallel";case"EXCLUSIVE":return"exclusive";case"COMPLEX":return"complex";default:return"simple"}if(E.type==="TASK"){let C=(S=E.data)==null?void 0:S.variant,I=(P=E.data)==null?void 0:P.attribute;if(T.type==="TASK"&&((L=T.data)==null?void 0:L.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,h,x)=>{let E=[];function T(N,w,S=0){let P=a(N,h,x);if(P.depth=S,w.push(P),N.type==="TASK"){E.push([...w]),w.pop();return}let L=Tn(N,h,x);if(L.length)for(let C of L)T(C,w,S+1);w.pop()}let _=Tn(m,h,x);for(let N of _)T(N,[]);return E},d=(m,h,x)=>{let E=[];function T(N,w,S=0){let P=a(N,h,x);if(P.depth=S,w.push(P),N.type==="TASK"){E.push([...w]),w.pop();return}let L=vn(N,h,x);if(L.length)for(let C of L)T(C,w,S+1);w.pop()}let _=vn(m,h,x);for(let N of _)T(N,[]);return E},u=(m,h,x)=>{x=x.filter(T=>T.source===m.id);let E=x.map(T=>{var w;let _=e(T.target),N;return _&&(N=a(_,h,x)),{id:T.id,type:"routing",variant:l(T,h,x),label:(w=T.data)==null?void 0:w.label,target:N}});return console.log(E),E},p=m=>{let h=e(m);if(!h)return;let x=o(),E=n(),T=a(h,x,E);return T.sources=c(h,x,E),T.targets=d(h,x,E),T.edgeTargets=u(h,x,E),h.type==="GATEWAY"&&(T.variant=s(h,x,E)),T},f=m=>{let h=t(m);if(!h)return;let x=o(),E=n(),T=l(h,x,E),N={id:h.id,type:"routing",variant:T,gatewayVariant:void 0},w=e(h.source);if(w){let P=a(w,x,E),L=c(w,x,E),C=s(w,x,E);N.source=P,N.sources=L.length?L:[[P]],N.gatewayVariant=C}let S=e(h.target);if(S){let P=a(S,x,E),L=d(S,x,E);N.target=P,N.targets=L.length?L:[[P]]}return N},y=m=>{let h=e(m);if(h)return p(h.id);let x=t(m);if(x)return f(x.id)};return{configureElement:m=>{let h=y(m);if(h)return r([m]),h},getConfigureElement:y,getNodeConfigure:p,getEdgeConfigure:f}};import{jsx as wn,jsxs as wf}from"react/jsx-runtime";var Ke=({elementId:e,elementType:t="node"})=>{let{t:o}=vf(),{onConfigureElement:n}=G(),{getConfigureElement:r}=Nn();return wf(bf,{children:[wn(Tf,{asChild:!0,children:wn(Ef,{variant:"ghost",color:"grey",size:"small",iconButton:!0,onClick:()=>{let a=r(e);a&&(n==null||n(a))},children:wn(Nf,{size:16})})}),wn(_f,{color:"black",children:o(t==="node"?"editor.toolbar.configure_node":"editor.toolbar.configure_edge")})]})};import{useReactFlow as If}from"@xyflow/react";import{Button as Af,Tooltip as Cf,TooltipContent as Sf,TooltipTrigger as Mf,useTranslation as Pf}from"lecom-ui";import{TrashIcon as Lf}from"lucide-react";import{jsx as In,jsxs as kf}from"react/jsx-runtime";var An=({elementId:e,elementType:t="node"})=>{let{t:o}=Pf(),{deleteElements:n}=If();return kf(Cf,{children:[In(Mf,{asChild:!0,children:In(Af,{variant:"ghost",color:"destructive",size:"small",iconButton:!0,onClick:()=>{n(t==="node"?{nodes:[{id:e}]}:{edges:[{id:e}]})},children:In(Lf,{size:16})})}),In(Sf,{color:"black",children:o("editor.toolbar.delete")})]})};import{Button as Df,Tooltip as Rf,TooltipContent as Vf,TooltipTrigger as Of,useTranslation as Hf}from"lecom-ui";import{MoveUpRightIcon as Gf}from"lucide-react";import{useCallback as Bf}from"react";import{jsx as Cn,jsxs as zf}from"react/jsx-runtime";var mo=({nodeId:e,disabled:t=!1,tooltipMessage:o})=>{let{t:n}=Hf(),r=Bf(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 zf(Rf,{children:[Cn(Of,{asChild:!0,children:Cn(Df,{variant:"ghost",color:"grey",size:"small",iconButton:!0,disabled:t,className:t?"opacity-50 cursor-not-allowed":"",onMouseDown:t?void 0:r,children:Cn(Gf,{size:16})})}),Cn(Vf,{color:"black",children:o||n("editor.toolbar.connect_node")})]})};import{jsx as go}from"react/jsx-runtime";var wt=i=>{var a=i,{edgeId:e,edgeType:t,sourceNode:o,targetNode:n}=a,r=Ae(a,["edgeId","edgeType","sourceNode","targetNode"]);let{mode:s}=G(),l=(o==null?void 0:o.type)==="START_EVENT",c=(n==null?void 0:n.type)==="END_EVENT",d=(o==null?void 0:o.type)==="GATEWAY"&&(n==null?void 0:n.type)==="GATEWAY",u=(o==null?void 0:o.type)==="TASK"&&(n==null?void 0:n.type)==="GATEWAY",p=!l&&!c&&!d&&!u,f=[{component:go(An,{elementId:e,elementType:"edge"})}],y=()=>s==="view"?p?[{component:go(Ke,{elementId:e,elementType:"edge"})}]:[]:p?[{component:go(Ke,{elementId:e,elementType:"edge"})},...f]:f,m=(h=>{switch(h){case"SEQUENCE_EDGE":return y();case"MESSAGE_EDGE":return s==="view"?[]:[...f];case"ANNOTATION_EDGE":return s==="view"?[]:[...f];default:return[]}})(t);if(!(m.length===0||s==="view"))return go("div",v(b({className:"flex items-center gap-1 w-fit px-3 py-2 bg-white rounded-sm shadow-md"},r),{children:m.map((h,x)=>go("div",{children:h.component},x))}))};import{jsx as Sn,jsxs as $f}from"react/jsx-runtime";var It={type:"ANNOTATION_EDGE",reconnectable:!0},Pa=({id:e,source:t,target:o,selected:n,data:r})=>{let{zoom:i}=Uf(),{isMultipleSelection:a}=G(),s=Ma(t),l=Ma(o);if(!s||!l)return null;let{sx:c,sy:d,tx:u,ty:p}=Se(s,l),[f,y,g]=Yf({sourceX:c,sourceY:d,targetX:u,targetY:p}),m=n||(s==null?void 0:s.selected)||(l==null?void 0:l.selected),h=1/i;return $f("g",{className:R("text-grey-400 hover:text-grey-500",{"text-blue-500 hover:text-blue-600":m}),children:[Sn(Ff,{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)})}),Sn(Wf,{children:Sn("div",{className:"absolute z-[3000] pointer-events-auto flex flex-col items-center gap-1",style:{transform:`translate(-50%, -50%) translate(${y}px, ${g}px)`},children:n&&!a&&Sn(wt,{edgeId:e,edgeType:"ANNOTATION_EDGE",style:{transform:`scale(${h})`}})})})]})};import{useState as Va,useCallback as Qf,useMemo as Gr,useEffect as jf,useRef as Oa}from"react";import{BaseEdge as em,EdgeLabelRenderer as tm,MarkerType as Ha,useInternalNode as Ga,useReactFlow as om,useViewport as nm,Position as Ba}from"@xyflow/react";import{useEffect as La,useRef as Xf,useState as Kf}from"react";import{jsx as ka}from"react/jsx-runtime";var ne=({value:e,maxLength:t,style:o,className:n,contentClassName:r,isEditing:i,onChange:a,onBlur:s})=>{let l=Xf(null),[c,d]=Kf(!1);La(()=>{d(i!=null?i:!1)},[i]),La(()=>{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(),h=t&&m.length>=t,x=["Backspace","Delete","ArrowLeft","ArrowRight","ArrowUp","ArrowDown","Home","End","Tab","Enter","Escape","Shift"],E=g.ctrlKey||g.metaKey,T=E&&g.key==="a",_=E&&g.key==="c",N=E&&g.key==="x",w=E&&g.key==="v";function S(L){return/\w/.test(L)}if(m.length===0&&!S(g.key)&&!x.includes(g.key)&&!E){g.preventDefault();return}h&&(x.includes(g.key)||T||_||N||w||g.preventDefault())},f=g=>{if(!t)return;g.preventDefault();let m=g.clipboardData.getData("text/plain"),h=g.currentTarget.innerText,x=window.getSelection();if(!x||x.rangeCount===0)return;let E=x.getRangeAt(0);if((h.substring(0,E.startOffset)+m+h.substring(E.endOffset)).length>t){let _=t-(h.length-(E.endOffset-E.startOffset)),N=m.substring(0,Math.max(0,_));N&&(E.deleteContents(),E.insertNode(document.createTextNode(N)),E.setStartAfter(E.endContainer),E.collapse(!0),x.removeAllRanges(),x.addRange(E))}else E.deleteContents(),E.insertNode(document.createTextNode(m)),E.setStartAfter(E.endContainer),E.collapse(!0),x.removeAllRanges(),x.addRange(E)},y=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 ka("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:ka("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:y,children:e})})};import{Position as Mn}from"@xyflow/react";var Pn=e=>e===Mn.Left||e===Mn.Right,kr=(e,t=30)=>e===Mn.Right||e===Mn.Bottom?t:-t,Dr=(e,t,o,n=1)=>Math.abs(e[o]-t[o])<n,Ln=(e,t)=>Math.sqrt((t.x-e.x)**2+(t.y-e.y)**2),kn=(e,t)=>({x:(e.x+t.x)/2,y:(e.y+t.y)/2});var it={OFFSET:30,TOLERANCE:1,MOVE_THRESHOLD:5,MIN_SEGMENT_LENGTH:15};function qf(e,t,o,n,r,i){let a=kr(r,it.OFFSET),s=kr(i,it.OFFSET),l=Pn(r),c=Pn(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 Rr(e,t,o,n,r,i,a){let s=qf(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=Pn(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)>it.TOLERANCE&&Math.abs(p.y-u.y)>it.TOLERANCE){let y=d%2===0===c;l[d+1]=y?{x:p.x,y:u.y}:{x:u.x,y:p.y}}}return l}var Da=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 Vr,useEffect as Or,useRef as Hr,useState as Dn}from"react";import{useReactFlow as Zf,useStore as Jf}from"@xyflow/react";var Ra=({edgeId:e,source:t,target:o,instanceId:n,isReadOnly:r})=>{let{setEdges:i,getNode:a,getNodes:s,screenToFlowPosition:l}=Zf(),c=Jf(S=>S.isValidConnection),[d,u]=Dn(null),[p,f]=Dn(null),[y,g]=Dn(null),[m,h]=Dn(!1),x=Hr(null),E=Hr(t),T=Hr(o);Or(()=>{E.current=t,T.current=o},[t,o]),Or(()=>{x.current=d},[d]);let _=Vr(S=>{var A;let P=x.current;if(!P)return;let L=l({x:S.clientX,y:S.clientY});f(L);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:P==="source"?M:E.current,target:P==="target"?M:T.current,sourceHandle:null,targetHandle:null},V=(A=c==null?void 0:c(k))!=null?A:!0;h(V)}else h(!1)},[s,l,c]),N=Vr(S=>{var k;let P=x.current;if(!P)return;let L=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&&L.some(O=>O.id===V)){I=V;break}M=M.parentElement}if(I){let V={source:P==="source"?I:E.current,target:P==="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($=>$.map(D=>D.id===e?v(b({},D),{source:V.source,target:V.target,data:v(b({},D.data),{points:void 0})}):D))}}u(null),f(null),g(null),h(!1),document.removeEventListener("mouseup",N),document.removeEventListener("mousemove",_);let A=Me.get(n);A==null||A.clearReconnectingEdge()},[e,s,a,i,n,_,c]),w=Vr((S,P)=>{if(r||P.button!==0)return;P.stopPropagation(),P.preventDefault(),u(S);let L=Me.get(n);L==null||L.setReconnectingEdge(e),document.addEventListener("mousemove",_),document.addEventListener("mouseup",N)},[r,e,n,_,N]);return Or(()=>()=>{if(x.current){document.removeEventListener("mousemove",_),document.removeEventListener("mouseup",N);let S=Me.get(n);S==null||S.clearReconnectingEdge()}},[n,_,N]),{reconnectingHandle:d,cursorPosition:p,hoveredNodeId:y,isValidReconnection:m,handleReconnectStart:w}};import{Fragment as Fa,jsx as re,jsxs as qe}from"react/jsx-runtime";var Ne={type:"SEQUENCE_EDGE",reconnectable:!0,markerStart:{type:Ha.ArrowClosed},markerEnd:{type:Ha.Arrow},data:{label:""}},{TOLERANCE:za,MOVE_THRESHOLD:Rn,MIN_SEGMENT_LENGTH:rm}=it,Wa=({id:e,source:t,target:o,data:n,selected:r})=>{var $;let{zoom:i}=nm(),{updateEdgeData:a}=om(),{isMultipleSelection:s,mode:l,instanceId:c}=G(),[d,u]=Va(!1),[p,f]=Va(null),y=Oa(null),g=Oa(null),m=l==="readonly",{reconnectingHandle:h,cursorPosition:x,hoveredNodeId:E,isValidReconnection:T,handleReconnectStart:_}=Ra({edgeId:e,source:t,target:o,instanceId:c,isReadOnly:m}),N=Ga(t),w=Ga(o),{sx:S,sy:P,tx:L,ty:C,sourcePos:I,targetPos:M}=Gr(()=>N&&w?Se(N,w):{sx:0,sy:0,tx:0,ty:0,sourcePos:Ba.Right,targetPos:Ba.Left},[N,w]);jf(()=>{var z;if(!g.current){g.current={sx:S,sy:P,tx:L,ty:C,sourcePos:I,targetPos:M};return}let D=g.current;(Math.abs(S-D.sx)>Rn||Math.abs(P-D.sy)>Rn||Math.abs(L-D.tx)>Rn||Math.abs(C-D.ty)>Rn||D.sourcePos!==I||D.targetPos!==M)&&((z=n==null?void 0:n.points)!=null&&z.length)&&a(e,v(b({},n),{points:void 0})),g.current={sx:S,sy:P,tx:L,ty:C,sourcePos:I,targetPos:M}},[S,P,L,C,I,M,n,e,a]);let A=Gr(()=>{var D;if((D=n==null?void 0:n.points)!=null&&D.length&&N&&w){let H=n.points[0],z=n.points[n.points.length-1],Y=Se(N,{internals:{positionAbsolute:H},measured:{width:1,height:1}}),q=Se({internals:{positionAbsolute:z},measured:{width:1,height:1}},w);return Rr(Y.sx,Y.sy,q.tx,q.ty,Y.sourcePos,q.targetPos,n.points)}return Rr(S,P,L,C,I,M,n==null?void 0:n.points)},[S,P,L,C,I,M,n==null?void 0:n.points,N,w]),k=Gr(()=>{if(A.length<2)return kn({x:S,y:P},{x:L,y:C});let D=0;for(let W=0;W<A.length-1;W++)D+=Ln(A[W],A[W+1]);let H=D/2,z=0;for(let W=0;W<A.length-1;W++){let Y=Ln(A[W],A[W+1]);if(z+Y>=H){let Q=(H-z)/Y,q=A[W],ae=A[W+1];return{x:q.x+(ae.x-q.x)*Q,y:q.y+(ae.y-q.y)*Q}}z+=Y}return kn({x:S,y:P},{x:L,y:C})},[A,S,P,L,C]),V=Qf((D,H)=>{if(l!=="edit"||H.button!==0)return;H.stopPropagation(),H.preventDefault();let z=A[D],W=A[D+1],Y=Dr(z,W,"y"),Q=Y?z.y:z.x;f(D);let q=Qe=>{let Ee=Q+(Y?Qe.clientY-H.clientY:Qe.clientX-H.clientX)/i;y.current=Y?{x:(z.x+W.x)/2,y:Ee}:{x:Ee,y:(z.y+W.y)/2};let Ut=A.map((ke,mt)=>mt===0||mt===A.length-1?ke:(Y?Math.abs(ke.y-Q)<za:Math.abs(ke.x-Q)<za)?Y?v(b({},ke),{y:Ee}):v(b({},ke),{x:Ee}):ke);a(e,v(b({},n),{points:Ut.slice(1,-1)}))},ae=()=>{f(null),y.current=null,document.removeEventListener("mousemove",q),document.removeEventListener("mouseup",ae)};document.addEventListener("mousemove",q),document.addEventListener("mouseup",ae)},[l,A,i,n,e,a]);if(!N||!w)return null;let O=Da(A),B=r||N.selected||w.selected;return qe(Fa,{children:[qe("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:[re(em,{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)})}),h&&x&&re("line",{x1:h==="source"?A[0].x:A[A.length-1].x,y1:h==="source"?A[0].y:A[A.length-1].y,x2:x.x,y2:x.y,stroke:E?T?"#10b981":"#ef4444":"#3b82f6",strokeWidth:3,strokeDasharray:"8 4",opacity:.6,className:"pointer-events-none"}),r&&!s&&!m&&re("g",{children:A.slice(0,-1).map((D,H)=>{let z=A[H+1];if(H===0||H===A.length-2||Ln(D,z)<rm)return null;let W=Dr(D,z,"y"),Y=p===H,Q=Y&&y.current?y.current:kn(D,z);return qe("g",{children:[re("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)}),re("circle",{cx:Q.x,cy:Q.y,r:4/i,fill:Y?"#3b82f6":"#fff",stroke:"#3b82f6",strokeWidth:2/i,className:"pointer-events-none"}),re("circle",{cx:Q.x,cy:Q.y,r:6/i,fill:"none",stroke:"#3b82f6",strokeWidth:1/i,opacity:Y?.6:.3,className:"pointer-events-none"})]},H)})})]}),qe(tm,{children:[qe("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&&re(wt,{edgeId:e,edgeType:"SEQUENCE_EDGE",sourceNode:N,targetNode:w,style:{transform:`scale(${1/i})`}}),(d||(($=n==null?void 0:n.label)==null?void 0:$.trim()))&&re(ne,{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&&qe(Fa,{children:[re("div",{className:"absolute z-[1000] pointer-events-none",style:{transform:`translate(-50%, -50%) translate(${A[0].x}px, ${A[0].y}px)`},children:qe("svg",{width:12/i,height:12/i,style:{overflow:"visible",position:"absolute",left:"50%",top:"50%",transform:"translate(-50%, -50%)"},children:[re("circle",{cx:6/i,cy:6/i,r:4/i,fill:h==="source"?"#3b82f6":"#fff",stroke:"#3b82f6",strokeWidth:2/i,className:"pointer-events-none"}),re("circle",{cx:6/i,cy:6/i,r:6/i,fill:"none",stroke:"#3b82f6",strokeWidth:1/i,opacity:h==="source"?.6:.3,className:"pointer-events-none"}),re("circle",{cx:6/i,cy:6/i,r:8/i,fill:"transparent",className:R("pointer-events-auto",{"cursor-move":!h||h!=="source","cursor-not-allowed":h==="source"&&E&&!T,"cursor-grabbing":h==="source"&&(!E||T)}),onMouseDown:D=>_("source",D.nativeEvent)})]})}),re("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:qe("svg",{width:12/i,height:12/i,style:{overflow:"visible",position:"absolute",left:"50%",top:"50%",transform:"translate(-50%, -50%)"},children:[re("circle",{cx:6/i,cy:6/i,r:4/i,fill:h==="target"?"#3b82f6":"#fff",stroke:"#3b82f6",strokeWidth:2/i,className:"pointer-events-none"}),re("circle",{cx:6/i,cy:6/i,r:6/i,fill:"none",stroke:"#3b82f6",strokeWidth:1/i,opacity:h==="target"?.6:.3,className:"pointer-events-none"}),re("circle",{cx:6/i,cy:6/i,r:8/i,fill:"transparent",className:R("pointer-events-auto",{"cursor-move":!h||h!=="target","cursor-not-allowed":h==="target"&&E&&!T,"cursor-grabbing":h==="target"&&(!E||T)}),onMouseDown:D=>_("target",D.nativeEvent)})]})})]})]})]})};import{useDebouncedCallback as nh}from"use-debounce";import{useReactFlow as oh}from"@xyflow/react";import{useCallback as oc}from"react";var yo=(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))(yo||{});import{xml2json as im,json2xml as sm}from"xml-js";var Ya={compact:!0,spaces:4},am=e=>e.replaceAll(`
2
- `,"&#xA;");function Vn(e,t=Ya){if(e)return JSON.parse(im(e,v(b({},t),{attributeValueFn:am})))}function Ua(e,t=Ya){return e?sm(e,t):""}var lm={MIN_WIDTH:36,MIN_HEIGHT:36},cm={MIN_WIDTH:36,MIN_HEIGHT:36},dm={MIN_WIDTH:56,MIN_HEIGHT:56},On={MIN_WIDTH:176,MIN_HEIGHT:96},Hn={HEADER_WIDTH:40,MIN_WIDTH:840,MIN_HEIGHT:256},K={HEADER_WIDTH:40,MIN_WIDTH:800,MIN_HEIGHT:256},Gn={MIN_WIDTH:176,MIN_HEIGHT:64},um={MIN_WIDTH:128,MIN_HEIGHT:64},U={START_EVENT:lm,END_EVENT:cm,GATEWAY:dm,TASK:On,LANE:K,ANNOTATION:Gn,UNSUPPORTED:um};var $a={"attribute-loop":"LOOP"},Xa={"task-script":"SCRIPT","subprocess-collapsed":"SUBPROCESS"},Ka={"gateway-exclusive":"EXCLUSIVE","gateway-parallel":"PARALLEL","gateway-complex":"COMPLEX"},qa={SCRIPT:"task-script",SUBPROCESS:"subprocess-collapsed"},Za={EXCLUSIVE:"gateway-exclusive",PARALLEL:"gateway-parallel",COMPLEX:"gateway-complex"};var At=(e,t,o)=>{let n=e._attributes.width||0,r=e._attributes.height||0,i=ze(Number(n),t),a=ze(Number(r),o);return{width:i,height:a,measured:{width:i,height:a}}},Ct=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},fm=e=>{let{mxGeometry:t}=e,o=Ct(e),n=At(t,U.START_EVENT.MIN_WIDTH,U.START_EVENT.MIN_HEIGHT);return v(b(b({},o),n),{type:"START_EVENT"})},mm=e=>{let{mxGeometry:t}=e,o=Ct(e),n=At(t,U.END_EVENT.MIN_WIDTH,U.END_EVENT.MIN_HEIGHT);return v(b(b({},o),n),{type:"END_EVENT"})},Br=(e,t)=>{let{_attributes:o,mxGeometry:n}=e,r=Ct(e),i=At(n,U.TASK.MIN_WIDTH,U.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=$a[l];c&&(r.data.attribute=c)}let s=Xa[o.style];return s&&(r.data.variant=s),v(b(b({},r),i),{type:"TASK"})},zr=e=>{let{_attributes:t,mxGeometry:o}=e,{style:n}=t,r=Ct(e),i=At(o,U.GATEWAY.MIN_WIDTH,U.GATEWAY.MIN_HEIGHT);return r.data.variant=Ka[n],v(b(b({},r),i),{type:"GATEWAY"})},gm=e=>{let{mxGeometry:t}=e,o=Ct(e),n=At(t,U.ANNOTATION.MIN_WIDTH,U.ANNOTATION.MIN_HEIGHT);return v(b(b({},o),n),{type:"ANNOTATION"})},hm=e=>{let{mxGeometry:t}=e,o=Ct(e),n=At(t,U.LANE.MIN_WIDTH,U.LANE.MIN_HEIGHT);return v(b(b({},o),n),{type:"LANE"})},Ja={task:Br,"task-script":Br,"subprocess-collapsed":Br,"start-event":fm,"end-event-terminate":mm,"gateway-parallel":zr,"gateway-exclusive":zr,"gateway-complex":zr,annotation:gm,lane:hm},Qa=e=>{var d;let{_attributes:t,mxGeometry:o}=e,{id:n,source:r,target:i,value:a,style:s}=t,l=(d=o==null?void 0:o.Array)==null?void 0:d.map(u=>({x:Number(u._attributes.x),y:Number(u._attributes.y)})),c={id:n,source:r,target:i,data:b({label:a||""},l&&l.length>0?{points:l}:{})};return s.includes("association")&&s.includes('endArrow=""')?b(b({},It),c):b(b({},Ne),c)},ja=(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}},St=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}}}},ym=e=>{let{variant:t}=e.data,o=St(e);return v(b({},o),{_attributes:v(b({},o._attributes),{style:qa[t]||"task"})})},xm=e=>{let t=St(e);return v(b({},t),{_attributes:v(b({},t._attributes),{style:"start-event"})})},Em=e=>{let t=St(e);return v(b({},t),{_attributes:v(b({},t._attributes),{style:"end-event-terminate"})})},bm=e=>{let{variant:t}=e.data,o=St(e);return v(b({},o),{_attributes:v(b({},o._attributes),{style:Za[t]})})},_m=e=>{let t=St(e);return v(b({},t),{_attributes:v(b({},t._attributes),{style:"lane"})})},Tm=e=>{let t=St(e);return v(b({},t),{_attributes:v(b({},t._attributes),{style:"annotation"})})},el={TASK:ym,START_EVENT:xm,END_EVENT:Em,GATEWAY:bm,ANNOTATION:Tm,LANE:_m},tl=(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 rl from"@dagrejs/dagre";import{getNodesBounds as Im}from"@xyflow/react";import{orderBy as Am}from"lodash";import{orderBy as vm}from"lodash";var Oe=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}},He=e=>vm(e,[o=>{let n=o.type==="LANE";return n&&!o.parentId?0:n?1:2}],["asc"]),ol=(e,t)=>{let{x:o,y:n}=Oe(e),{x:r,y:i}=Oe(t);return{x:o-r,y:n-i}};var Mt=({parentId:e,nodes:t,includeTypes:o=[...Object.values(F)],excludeTypes:n=[]})=>t.some(r=>r.parentId===e&&(!o.length||o.includes(r.type))&&!n.includes(r.type)),Nm=(e,t)=>{let{x:o,y:n}=Oe(e),{x:r,y:i}=Oe(t),a=o-r,s=n-i;return Math.sqrt(a*a+s*s)},wm=(e,t)=>{let{x:o,y:n,w:r,h:i}=Oe(e),{x:a,y:s,w:l,h:c}=Oe(t);return o<a+l&&a<o+r&&n<s+c&&s<n+i},xo=(e,t)=>{let o=null,n=1/0;for(let r of t)if(r.id!==e.id&&wm(e,r)){let i=Nm(e,r);i<n&&(n=i,o=r)}return o},nl=(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 il=(e=[],t=[],o="LR")=>{let n=new rl.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)),rl.layout(n),{nodes:e.map(i=>{let a=n.node(i.id);return v(b({},i),{position:{x:a.x-i.width/2,y:a.y-i.height/2}})}),edges:t}},Eo=e=>{let t=e.filter(n=>n.type==="LANE"&&!n.parentId),o=[...e];return t.forEach(n=>{o=st(n.id,o)}),o},st=(e,t)=>{var f,y;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=Am(r,["position.y"]),a=Math.max((y=(f=n.measured)==null?void 0:f.width)!=null?y:0,Hn.MIN_WIDTH),s=nl(e,i)||K.MIN_WIDTH,l=Math.max(a,s),c=a-K.HEADER_WIDTH>=s,d=0,u=0;i.forEach(g=>{var m,h,x,E;o=o.map(T=>T.id===g.id?v(b({},T),{width:c?l-K.HEADER_WIDTH:l,measured:v(b({},T.measured),{width:c?l-K.HEADER_WIDTH:l}),position:{x:K.HEADER_WIDTH,y:d}}):T),d+=(h=(m=g.measured)==null?void 0:m.height)!=null?h:0,u+=(E=(x=g.measured)==null?void 0:x.height)!=null?E:0}),o=o.map(g=>g.id===e?v(b({},g),{height:u,width:c?l:l+K.HEADER_WIDTH,measured:v(b({},g.measured),{height:u,width:c?l:l+K.HEADER_WIDTH})}):g);let p=o.find(g=>g.id===e);return p!=null&&p.parentId&&(o=st(p.parentId,o)),o},sl=(e,t,o)=>{if(e.type==="LANE")return o;let n=fe(t),r=fe(e);return r.y<n.y&&(e.position.y=0),r.x<n.x+K.HEADER_WIDTH&&(e.position.x=K.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(b({},i),{height:t.height,width:t.width,measured:t.measured}):i.id===e.id?v(b({},i),{position:e.position}):i),o},al=()=>{let e=document.querySelector(".react-flow__viewport");return e||(console.error("Flow element (.react-flow__viewport) not found."),null)},Cm=50,ll=(e,t=Cm)=>{let o=Im(e);return{x:o.x-t,y:o.y-t,width:o.width+t*2,height:o.height+t*2}};var Sm=e=>{let t=Object.values(yo),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=Ja[a],l=s==null?void 0:s(i,n);if(!l){console.warn(`Node ${a} not supported`);continue}r.push(l)}return r},Mm=(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=Qa(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},Pm=(e,t)=>{let o=[];return e.forEach(n=>{var a,s;let r=(s=(a=el)[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=tl(n,t);o.push(l)}}),o},Lm=(e,t)=>{let o=[];return e.forEach(n=>{let r=ja(n,t);o.push(r)}),o},cl=(e=[],t=[],o)=>{let n=Pm(e,o),r=Lm(t,e),i={mxGraphModel:{root:{_attributes:{version:"1.1",lastId:o},mxCell:[{_attributes:{id:"0"}},{_attributes:{id:"1",parent:"0"}},...n,...r]}}};return Ua(JSON.stringify(i),{compact:!0,spaces:0})},dl=async e=>{var a,s;let t=await Vn(e),o=((s=(a=t==null?void 0:t.mxGraphModel)==null?void 0:a.root)==null?void 0:s.mxCell)||[],n=Sm(o),r=Mm(o,n);return{nodes:He(Eo(n)),edges:r}};import{Position as ug,useConnection as pg,useReactFlow as fg}from"@xyflow/react";import{Handle as ul,useReactFlow as km}from"@xyflow/react";import{jsx as pl}from"react/jsx-runtime";var ie=i=>{var a=i,{type:e,position:t,className:o,nodeType:n}=a,r=Ae(a,["type","position","className","nodeType"]);let s=n==="TASK";return pl(ul,b({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))},Pt=s=>{var l=s,{nodeId:e,nodeType:t,gatewayVariant:o,type:n,position:r,className:i}=l,a=Ae(l,["nodeId","nodeType","gatewayVariant","type","position","className"]);let{getEdges:c,getNodes:d}=km(),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 y=d();return f.filter(m=>{if(m.source!==e)return!1;let h=y.find(x=>x.id===m.target);return(h==null?void 0:h.type)!=="ANNOTATION"}).length>=1}return!1})();return pl(ul,b({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 Dm,useReactFlow as Rm}from"@xyflow/react";import{orderBy as Vm}from"lodash";import{jsx as Om}from"react/jsx-runtime";var Lt=n=>{var r=n,{nodeId:e,isVisible:t}=r,o=Ae(r,["nodeId","isVisible"]);let{getNode:i,getNodes:a,setNodes:s}=Rm(),{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 y=[...a()],g=!f.parentId,m=g?f.id:f.parentId,h=y.filter(T=>T.type==="LANE"&&T.parentId===m);if(!h.length)return;let x=Vm(h,["position.y"]),E=0;x.forEach((T,_)=>{var S,P;let N=_===x.length-1,w=(P=(S=T.measured)==null?void 0:S.height)!=null?P:0;y=y.map(L=>{if(L.id===T.id){let C=g?u-K.HEADER_WIDTH:u,I=v(b({},L),{width:C,measured:v(b({},L.measured),{width:C}),position:v(b({},L.position),{y:E})});return N&&g&&(I.height=p-E),I}return L}),E+=w}),y=y.map(T=>{if(T.id===m){let _=g?u:u+K.HEADER_WIDTH;return v(b({},T),{width:_,height:g?p:E,measured:{width:_,height:g?p:E}})}return T}),s(y)};return Om(Dm,b({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 tg,useReactFlow as og}from"@xyflow/react";import{Button as ng,Tooltip as rg,TooltipContent as ig,TooltipTrigger as sg,useTranslation as ag}from"lecom-ui";import{useCallback as lg,useRef as yl,useState as cg}from"react";import{create as Hm}from"zustand";var kt=Hm(e=>({draggableNode:null,setDraggableNode:t=>{e({draggableNode:t})}}));import{useEffect as Gm,useState as Bm}from"react";var fl=(e,t=!1)=>{let[o,n]=Bm({width:0,height:0});return Gm(()=>{if(e.current&&t){let r=e.current.getBoundingClientRect();n({width:r.width,height:r.height})}},[t,e]),{dimensions:o}};import{Position as bo,useReactFlow as zm}from"@xyflow/react";import{useMemo as Fm}from"react";var Wm=120,Ym=12,ml=(e,t=!1,o)=>{let{getNode:n,getViewport:r}=zm(),{instanceId:i}=G();return Fm(()=>{var f,y;if(!t)return{position:bo.Right,align:"start"};let a=n(e);if(!a)return{position:bo.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=(y=document.getElementById(`modeler-${i}`))==null?void 0:y.clientWidth;if(!d)return{position:bo.Right,align:"start"};let u=(o==null?void 0:o.width)||Wm;return{position:l+c+u+Ym>d?bo.Left:bo.Right}},[i,e,t,o,n,r])};import{useNodesData as Um,useReactFlow as $m}from"@xyflow/react";import{Button as gl,DropdownMenu as Xm,DropdownMenuContent as Km,DropdownMenuGroup as qm,DropdownMenuItem as Zm,DropdownMenuLabel as Jm,DropdownMenuTrigger as Qm,Tooltip as Fr,TooltipContent as Wr,TooltipTrigger as Yr,useTranslation as jm}from"lecom-ui";import{WrenchIcon as eg}from"lucide-react";import{jsx as ce,jsxs as at}from"react/jsx-runtime";var hl=({nodeId:e})=>{let{t}=jm(),{updateNodeData:o,getEdges:n,getNode:r}=$m(),i=Um(e),s=n().filter(f=>f.source===e).some(f=>{let y=r(f.target);return(y==null?void 0:y.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 at(Xm,{children:[at(Fr,{children:[ce(Yr,{asChild:!0,children:ce(Qm,{asChild:!0,children:ce(gl,{variant:"ghost",color:"grey",size:"small",iconButton:!0,children:ce(eg,{})})})}),ce(Wr,{color:"black",children:t("bpmn.task.menu.title")})]}),at(Km,{align:"start",className:"w-60 bg-white text-grey-600",children:[at(Jm,{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(Ro).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 at(Fr,{children:[ce(Yr,{asChild:!0,children:ce(gl,{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(Wr,{color:"black",children:g})]},u)})})]}),ce(qm,{children:at(Fr,{children:[ce(Yr,{asChild:!0,children:at(Zm,{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(Do.SCRIPT.icon,{className:"stroke-current"}),t(`bpmn.task.variant.${"SCRIPT".toLowerCase()}`)]})}),s&&ce(Wr,{color:"black",children:t("editor.task_menu.script_not_allowed_when_connected_to_end")})]})})]})]})};import{jsx as j,jsxs as xl}from"react/jsx-runtime";var lt={START_EVENT:{type:"START_EVENT",icon:Kt,label:"bpmn.start_event.variant.default"},END_EVENT:{type:"END_EVENT",icon:gt,label:"bpmn.end_event.variant.default"},TASK:{type:"TASK",icon:Kt,label:"bpmn.task.variant.default"},ANNOTATION:{type:"ANNOTATION",icon:Mo,label:"bpmn.annotation.variant.default"}},dg={EXCLUSIVE:{type:"GATEWAY",variant:"EXCLUSIVE",icon:yt,label:"bpmn.gateway.variant.exclusive"},PARALLEL:{type:"GATEWAY",variant:"PARALLEL",icon:xt,label:"bpmn.gateway.variant.parallel"},COMPLEX:{type:"GATEWAY",variant:"COMPLEX",icon:ht,label:"bpmn.gateway.variant.complex"}},pe=({nodeId:e,nodeType:t,nodeVariant:o,isChild:n,isVisible:r})=>{let i=yl(null),a=yl(null),{t:s}=ag(),{setDraggableNode:l}=kt(),{getEdges:c,getNodes:d}=og(),{setIsDragging:u,mode:p}=G(),{dimensions:f}=fl(i,r),{position:y}=ml(e,r,f),[g,m]=cg(void 0),h=d(),x=c(),E=o==="SUBPROCESS",T=lg((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(An,{elementId:e})}],N=()=>{if(p==="view")return[];let k=!x.some(V=>{var O;return V.source===e&&((O=h.find(B=>B.id===V.target))==null?void 0:O.type)!=="ANNOTATION"});return[{component:j(mo,{nodeId:e,disabled:!k,tooltipMessage:k?void 0:s("editor.toolbar.start_event_limit_reached")})},lt.TASK,lt.ANNOTATION,..._]},w=()=>p==="view"?[{component:j(Ke,{elementId:e})}]:[{component:j(Ke,{elementId:e})},...E?[]:[{component:j(hl,{nodeId:e})}],{component:j(mo,{nodeId:e})},lt.TASK,...Object.values(dg),..._],S=()=>p==="view"?[{component:j(Ke,{elementId:e})}]:[{component:j(Ke,{elementId:e})},{component:j(mo,{nodeId:e})},lt.TASK,lt.ANNOTATION,..._],P=()=>p==="view"?[]:[{component:j(mo,{nodeId:e})},lt.ANNOTATION,..._],L=()=>p==="view"?[]:[...n?[]:[lt.ANNOTATION],..._],C=()=>p==="view"?[]:[..._],I=()=>p==="view"?[]:[..._],A=(k=>{switch(k){case"START_EVENT":return N();case"TASK":return w();case"GATEWAY":return S();case"END_EVENT":return P();case"LANE":return L();case"ANNOTATION":return C();case"UNSUPPORTED":return I();default:return[]}})(t);if(!(A.length===0||p==="readonly"))return xl(tg,{position:y,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:h,edges:x},B=Aa(O),$={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?$[B.reason]||s(k.label):s(k.label)||"";return xl(rg,{children:[j(sg,{asChild:!0,children:j(ng,{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(ig,{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 Bn,jsxs as mg}from"react/jsx-runtime";var El=({id:e,data:t,selected:o,dragging:n})=>{let{updateNodeData:r}=fg(),{inProgress:i,fromNode:a}=pg(),{mode:s,isConnecting:l,isDragging:c,isMultipleSelection:d}=G(),u=i&&(a==null?void 0:a.id)!==e,p=y=>{r(e,{label:y})},f=!l&&!c&&!d;return mg("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:[Bn(ne,{value:t.label,className:"m-1 text-grey-600",onChange:p}),f&&Bn(pe,{nodeId:e,nodeType:"ANNOTATION",isVisible:!n&&o}),s==="edit"&&Bn(Lt,{minWidth:Gn.MIN_WIDTH,minHeight:Gn.MIN_HEIGHT,isVisible:!n&&o}),(!i||u)&&Bn(ie,{type:"target",position:ug.Left,className:R({"annotation-handle":u})})]})};import{Position as bl,useConnection as gg,useReactFlow as hg}from"@xyflow/react";import{useState as yg}from"react";import{jsx as Dt,jsxs as xg}from"react/jsx-runtime";var _l=({id:e,data:t,selected:o,dragging:n})=>{let{updateNodeData:r}=hg(),{inProgress:i,fromNode:a}=gg(),{isConnecting:s,isDragging:l,isMultipleSelection:c}=G(),[d,u]=yg(!1),p=i&&(a==null?void 0:a.id)!==e,f=h=>{r(e,{label:h})},y=()=>{u(!0)},g=()=>{u(!1)},m=!s&&!l&&!c;return xg("div",{className:"relative",onBlur:g,onDoubleClick:y,children:[Dt(gt,{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})}),Dt("div",{className:"absolute top-9 left-1/2 -translate-x-1/2 max-w-80 w-max",children:Dt(ne,{value:t.label,isEditing:d,onChange:f})}),m&&Dt(pe,{nodeId:e,nodeType:"END_EVENT",isVisible:!n&&o}),(!i||p)&&Dt(ie,{type:"target",position:bl.Left,className:R({"event-handle":p})}),!i&&Dt(ie,{type:"source",position:bl.Right})]})};import{Position as Tl,useConnection as Eg,useReactFlow as bg}from"@xyflow/react";import{useCallback as _g,useState as Tg}from"react";import{jsx as Rt,jsxs as vg}from"react/jsx-runtime";var vl=({id:e,data:t,selected:o,dragging:n})=>{let r=gr[t.variant].icon,{updateNodeData:i}=bg(),{inProgress:a,fromNode:s}=Eg(),{isConnecting:l,isDragging:c,isMultipleSelection:d}=G(),[u,p]=Tg(!1),f=a&&(s==null?void 0:s.id)!==e,y=_g(x=>{i(e,{label:x})},[e,i]),g=()=>{p(!0)},m=()=>{p(!1)},h=!l&&!c&&!d;return vg("div",{className:"relative",onBlur:m,onDoubleClick:g,children:[Rt(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})}),Rt("div",{className:"absolute top-14 left-1/2 -translate-x-1/2 max-w-80 w-max",children:Rt(ne,{value:t.label,isEditing:u,onChange:y})}),h&&Rt(pe,{nodeId:e,nodeType:"GATEWAY",isVisible:!n&&o}),(!a||f)&&Rt(ie,{type:"target",position:Tl.Left,className:R({"gateway-handle":f})}),!a&&Rt(Pt,{type:"source",position:Tl.Right,nodeId:e,nodeType:"GATEWAY",gatewayVariant:t.variant})]})};import{useNodesData as gA,useReactFlow as hA}from"@xyflow/react";import{Button as xA,DropdownMenu as EA,DropdownMenuContent as bA,DropdownMenuGroup as _A,DropdownMenuItem as TA,DropdownMenuLabel as vA,DropdownMenuTrigger as NA,Tooltip as wA,TooltipContent as IA,TooltipTrigger as AA,useTranslation as CA}from"lecom-ui";import{WrenchIcon as MA}from"lucide-react";import{jsx as DA,jsxs as RA}from"react/jsx-runtime";import{Position as Nl,useConnection as Ng,useReactFlow as wg}from"@xyflow/react";import{useState as Ig}from"react";import{jsx as Vt,jsxs as Ag}from"react/jsx-runtime";var wl=({id:e,data:t,selected:o,dragging:n})=>{let{updateNodeData:r}=wg(),{inProgress:i,fromNode:a}=Ng(),{isConnecting:s,isDragging:l,isMultipleSelection:c}=G(),[d,u]=Ig(!1),p=i&&(a==null?void 0:a.id)!==e,f=h=>{r(e,{label:h})},y=()=>{u(!0)},g=()=>{u(!1)},m=!s&&!l&&!c;return Ag("div",{className:"relative",onBlur:g,onDoubleClick:y,children:[Vt(Lo,{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})}),Vt("div",{className:"absolute top-9 left-1/2 -translate-x-1/2 max-w-80 w-max",children:Vt(ne,{value:t.label,isEditing:d,onChange:f})}),m&&Vt(pe,{nodeId:e,nodeType:"START_EVENT",isVisible:!n&&o}),(!i||p)&&Vt(ie,{type:"target",position:Nl.Left,className:R({"event-handle":p})}),!i&&Vt(Pt,{type:"source",position:Nl.Right,nodeId:e,nodeType:"START_EVENT"})]})};import{Position as Ll,useConnection as Mg,useReactFlow as Pg}from"@xyflow/react";import{useTranslation as Lg}from"lecom-ui";import{useCallback as kg}from"react";var zn=(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}`},Ot=(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 Il,jsxs as Cg}from"react/jsx-runtime";var Al=e=>Cg("svg",v(b({width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",xmlns:"http://www.w3.org/2000/svg"},e),{children:[Il("circle",{cx:"12",cy:"12",r:"10",fill:"#10B981"}),Il("path",{d:"M7 12L10 15L17 8",stroke:"white",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"})]}));import{jsx as Cl}from"react/jsx-runtime";var Sl=e=>Cl("svg",v(b({width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",xmlns:"http://www.w3.org/2000/svg"},e),{children:Cl("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 Ml,jsxs as Sg}from"react/jsx-runtime";var Pl=e=>Sg("svg",v(b({width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",xmlns:"http://www.w3.org/2000/svg"},e),{children:[Ml("circle",{cx:"12",cy:"12",r:"10",fill:"#EF4444"}),Ml("path",{d:"M8 8L16 16M8 16L16 8",stroke:"white",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"})]}));import{jsx as ye,jsxs as Rg}from"react/jsx-runtime";var Dg={APROVADO:Al,EM_ANDAMENTO:Sl,REJEITADO:Pl},Ur={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)]"},kl=({id:e,data:t,selected:o,dragging:n})=>{let{t:r}=Lg(),{updateNodeData:i,getNodes:a}=Pg(),{inProgress:s,fromNode:l}=Mg(),{mode:c,isConnecting:d,isDragging:u,isMultipleSelection:p,onSubprocessValidationClick:f}=G(),{getTaskStatus:y}=je(),g=s&&(l==null?void 0:l.id)!==e,m=kg(C=>{let I=C.trim(),M=t.label||"";if(I===M)return;let A=a(),k=I;I||(k=zn(A,r("bpmn.task.label.prefix")));let V=Ot(k,A);V!==M&&i(e,{label:V})},[t.label,a,e,r,i]),h=y(e),x=h?Dg[h]:null,E=t.variant?Do[t.variant].icon:null,T=t.attribute?Ro[t.attribute].icon:null,_=t.variant==="SUBPROCESS",N=E&&!_,w=T||_,S=()=>t.hasError?Ur.error:h?Ur[h]:Ur.default,P=()=>{f==null||f({id:e,type:"sub_process",label:t.label})},L=!d&&!u&&!p;return Rg("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(ne,{value:t.label,maxLength:60,className:R("m-1",{"py-6":N||w}),onChange:m}),E&&ye("div",{className:R("absolute flex items-center p-1",_?"bottom-0":"top-0 left-0"),children:ye(E,{size:16,className:R(t.hasError?"text-red-500":"text-grey-500",_&&"cursor-pointer"),onClick:_?P: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")})})}),x&&ye("div",{className:"absolute top-0 right-0 flex items-center p-1",children:ye(x,{})}),L&&ye(pe,{nodeId:e,nodeType:"TASK",nodeVariant:t.variant,isVisible:!n&&o}),c==="edit"&&ye(Lt,{minWidth:On.MIN_WIDTH,minHeight:On.MIN_HEIGHT,isVisible:!n&&o}),(!s||g)&&ye(ie,{type:"target",position:Ll.Left,className:R({"task-handle":g})}),!s&&ye(Pt,{type:"source",position:Ll.Right,nodeId:e,nodeType:"TASK"})]})};import{Position as Dl}from"@xyflow/react";import{Fragment as Vg,jsx as Fn,jsxs as Og}from"react/jsx-runtime";var Rl=({id:e,data:t,selected:o,dragging:n})=>{let{isConnecting:r,isDragging:i,isMultipleSelection:a}=G(),s=!r&&!i&&!a;return Og(Vg,{children:[Fn("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&&Fn(pe,{nodeId:e,nodeType:"UNSUPPORTED",isVisible:!n&&o}),Fn(ie,{type:"source",position:Dl.Right}),Fn(ie,{type:"target",position:Dl.Left})]})};import{BaseEdge as Hg,EdgeLabelRenderer as Gg,getSmoothStepPath as Bg,MarkerType as zg,useInternalNode as Vl,useReactFlow as Fg,useViewport as Wg}from"@xyflow/react";import{useState as Yg}from"react";import{jsx as Wn,jsxs as Ol}from"react/jsx-runtime";var pS={type:"MESSAGE_EDGE",reconnectable:!0,markerEnd:{type:zg.Arrow},data:{label:""}},Hl=({id:e,source:t,target:o,data:n,selected:r})=>{let{zoom:i}=Wg(),{updateEdgeData:a}=Fg(),{isMultipleSelection:s}=G(),[l,c]=Yg(!1),d=Vl(t),u=Vl(o);if(!d||!u)return null;let{sx:p,sy:f,tx:y,ty:g,sourcePos:m,targetPos:h}=Se(d,u),[x,E,T]=Bg({sourceX:p,sourceY:f,targetX:y,targetY:g,sourcePosition:m,targetPosition:h}),_=r||(d==null?void 0:d.selected)||(u==null?void 0:u.selected),N=_?"sequence-edge-marker-highlighted":"sequence-edge-marker",w=l||(n==null?void 0:n.label.trim().length)>0,S=1/i,P=()=>{c(!0)},L=()=>{c(!1)},C=I=>{a(e,{label:I.trim()})};return Ol("g",{className:R("text-grey-400 hover:text-grey-500",{"text-blue-500 hover:text-blue-600":_}),onBlur:L,onDoubleClick:P,children:[Wn(Hg,{id:e,path:x,markerEnd:`url(#${N})`,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)})}),Wn(Gg,{children:Ol("div",{className:"absolute z-[3000] pointer-events-auto flex flex-col items-center gap-1",style:{transform:`translate(-50%, -50%) translate(${E}px, ${T}px)`},children:[r&&!s&&Wn(wt,{edgeId:e,edgeType:"MESSAGE_EDGE",style:{transform:`scale(${S})`}}),w&&Wn(ne,{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 Ug}from"@xyflow/react";import{jsx as Gl,jsxs as $g}from"react/jsx-runtime";var Bl=({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}=Se(r,i),[p]=Ug({sourceX:a,sourceY:s,sourcePosition:d||o,targetPosition:u||n,targetX:l||e,targetY:c||t});return $g("g",{children:[Gl("path",{fill:"none",className:"stroke-2 stroke-grey-400 animated",d:p}),Gl("circle",{cx:l||e,cy:c||t,fill:"none",r:4,className:"stroke-2 stroke-grey-500"})]})};import{Position as Xg,useReactFlow as Kg}from"@xyflow/react";import{orderBy as qg}from"lodash";import{useMemo as zl,useState as Zg}from"react";import{Fragment as Jg,jsx as ct,jsxs as Fl}from"react/jsx-runtime";var Wl=({id:e,data:t,selected:o,dragging:n,parentId:r})=>{let{updateNodeData:i,getNodes:a}=Kg(),{mode:s,isConnecting:l,isDragging:c,isMultipleSelection:d}=G(),[u,p]=Zg(!1),f=a(),y=!r,g=zl(()=>qg([...f.filter(N=>N.parentId===e&&N.type==="LANE")],"position.y","asc"),[f,e]),m=y?Hn.MIN_WIDTH:K.MIN_WIDTH,h=zl(()=>{if(y&&g.length>1){let N=[...g];return N.pop(),N.reduce((S,P)=>{var L,C;return S+((C=(L=P.measured)==null?void 0:L.height)!=null?C:0)},0)+K.MIN_HEIGHT}return K.MIN_HEIGHT},[y,g]),x=N=>{i(e,{label:N})},E=()=>{p(!0)},T=()=>{p(!1)},_=!l&&!c&&!d;return Fl(Jg,{children:[Fl("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:[ct("div",{className:"flex align-items justify-center w-10 border-r-2 border-grey-400",onBlur:T,onDoubleClick:E,children:ct("div",{className:R("relative flex-1",{"[writing-mode:vertical-rl] [text-orientation:sideways] transform rotate-180":!u}),children:ct(ne,{value:t.label,className:"w-full h-full pointer-events-none self-auto",contentClassName:R({"whitespace-nowrap":u}),isEditing:u,onChange:x})})}),ct("div",{className:"flex-1"})]}),_&&ct(pe,{nodeId:e,nodeType:"LANE",isChild:!y,isVisible:!n&&o}),s==="edit"&&ct(Lt,{nodeId:e,minWidth:m,minHeight:h,isVisible:!n&&o}),y&&ct(ie,{type:"source",position:Xg.Right})]})};var Yl={START_EVENT:wl,END_EVENT:_l,TASK:kl,GATEWAY:vl,ANNOTATION:El,LANE:Wl,UNSUPPORTED:Rl},Ul={SEQUENCE_EDGE:Wa,MESSAGE_EDGE:Hl,ANNOTATION_EDGE:Pa},$l="#fafafa",Xl="#bebebe",Kl=1,ql=10,Zl="bottom-left",Jl=.2,Ql=5,Ht=.5,Gt=.4,Bt=1,jl={x:0,y:0,zoom:.75},Qg=1,jg=2,ec=[Qg,jg];import{useReactFlow as th}from"@xyflow/react";var eh=1,tc=()=>`<mxGraphModel>
1
+ var Nd=Object.defineProperty,wd=Object.defineProperties;var Id=Object.getOwnPropertyDescriptors;var Co=Object.getOwnPropertySymbols;var di=Object.prototype.hasOwnProperty,ui=Object.prototype.propertyIsEnumerable;var ci=(e,t,o)=>t in e?Nd(e,t,{enumerable:!0,configurable:!0,writable:!0,value:o}):e[t]=o,E=(e,t)=>{for(var o in t||(t={}))di.call(t,o)&&ci(e,o,t[o]);if(Co)for(var o of Co(t))ui.call(t,o)&&ci(e,o,t[o]);return e},v=(e,t)=>wd(e,Id(t));var Ae=(e,t)=>{var o={};for(var n in e)di.call(e,n)&&t.indexOf(n)<0&&(o[n]=e[n]);if(e!=null&&Co)for(var n of Co(e))t.indexOf(n)<0&&ui.call(e,n)&&(o[n]=e[n]);return o};var ar=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 Ad,Translations as Cd}from"lecom-ui";var pi={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 fi={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 mi={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 gi={pt_BR:mi,en_US:pi,es_ES:fi};var hi,yi,Sd=(yi=(hi=ar("LecomUserLanguage"))!=null?hi:ar("org.springframework.web.servlet.i18n.CookieLocaleResolver.LOCALE"))!=null?yi:Cd.PT_BR;Ad({lng:Sd,resources:gi});var ge=(n=>(n.EDIT="edit",n.VIEW="view",n.READONLY="readonly",n))(ge||{});var So=(r=>(r.ACTIVITY="activity",r.ROUTING="routing",r.GATEWAY="gateway",r.SUB_PROCESS="sub_process",r))(So||{}),lr=(n=>(n.START="start",n.END="end",n.BETWEEN="between",n))(lr||{}),cr=(n=>(n.SCRIPT="script",n.LOOP="loop",n.SCRIPT_LOOP="script_loop",n))(cr||{}),dr=(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))(dr||{});import{RotateCcw as zd,ScrollText as Fd,SquarePlus as Wd}from"lucide-react";import{jsx as Mo,jsxs as Md}from"react/jsx-runtime";var Po=({size:e=24,className:t})=>Md("svg",{width:e,height:e,viewBox:"0 0 24 24",xmlns:"http://www.w3.org/2000/svg",fill:"#6b7280",className:t,children:[Mo("path",{strokeWidth:"2",d:"M16 3V3.5085V11.9998V20.4915V21H16.5411H21.4592H22V19.123H21.4592H17.9974V11.9998V4.8773H21.4592H22V3H21.4592H16.5411H16Z"}),Mo("path",{d:"M4.41026 16.9999L2 18.7861L3.89693 21.1103L6.3072 19.324L4.41026 16.9999Z"}),Mo("path",{d:"M8.41026 13.9999L6 15.7861L7.89693 18.1103L10.3072 16.324L8.41026 13.9999Z"}),Mo("path",{d:"M12.4313 10.954L10.021 12.7402L11.9179 15.0644L14.3282 13.2781L12.4313 10.954Z"})]});import{jsx as xi}from"react/jsx-runtime";var gt=({size:e=24,className:t})=>xi("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:xi("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 Xt,jsxs as Pd}from"react/jsx-runtime";var ht=({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:[Xt("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"}),Xt("path",{d:"M12 8V16",strokeLinecap:"round",strokeLinejoin:"round"}),Xt("path",{d:"M8 12H16",strokeLinecap:"round",strokeLinejoin:"round"}),Xt("path",{d:"M9.17139 9.17188L14.8282 14.8287",strokeLinecap:"round",strokeLinejoin:"round"}),Xt("path",{d:"M14.8281 9.17188L9.17127 14.8287",strokeLinecap:"round",strokeLinejoin:"round"})]});import{jsx as ur,jsxs as Ld}from"react/jsx-runtime";var yt=({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:[ur("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"}),ur("path",{d:"M14.8286 9.17188L9.17176 14.8287",strokeLinecap:"round",strokeLinejoin:"round"}),ur("path",{d:"M9.17139 9.17188L14.8282 14.8287",strokeLinecap:"round",strokeLinejoin:"round"})]});import{jsx as pr,jsxs as kd}from"react/jsx-runtime";var xt=({size:e=24,className:t})=>kd("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:"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"}),pr("path",{d:"M12 8V16",strokeLinecap:"round",strokeLinejoin:"round"}),pr("path",{d:"M8 12H16",strokeLinecap:"round",strokeLinejoin:"round"})]});import{jsx as fr,jsxs as Dd}from"react/jsx-runtime";var Ei=({size:e=24,className:t})=>fr("svg",{width:e,height:e,viewBox:"0 0 34 24",xmlns:"http://www.w3.org/2000/svg",fill:"currentColor",className:t,children:Dd("g",{children:[fr("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"}),fr("path",{d:"M24.5 4.5L28 1M28 1L31.5 4.5M28 1V8",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round"})]})});import{clsx as Rd}from"clsx";import{twMerge as Vd}from"tailwind-merge";function R(...e){return Vd(Rd(e))}var ze=(e=0,t=0)=>e<t?t:e,Lo=(e=1e3)=>new Promise(t=>{setTimeout(t,e)});import{jsx as bi,jsxs as Od}from"react/jsx-runtime";var _i=({size:e=24,className:t})=>Od("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:[bi("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"}),bi("path",{d:"M9 3V21",strokeLinecap:"round",strokeLinejoin:"round"})]});import{jsx as mr}from"react/jsx-runtime";var Ti=({size:e=24,className:t})=>mr("svg",{width:e,height:e,viewBox:"0 0 24 24",xmlns:"http://www.w3.org/2000/svg",stroke:"currentColor",className:t,children:mr("g",{children:mr("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 vi}from"react/jsx-runtime";var ko=({size:e=24,className:t})=>vi("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:vi("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 Ni}from"react/jsx-runtime";var Kt=({size:e=24,className:t})=>Ni("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:Ni("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 gr,jsxs as Hd}from"react/jsx-runtime";var wi=({size:e=24,className:t})=>Hd("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:"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"}),gr("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"}),gr("path",{d:"M7.5 7.5V10H10",strokeWidth:"1.5",fill:"none",strokeLinecap:"round",strokeLinejoin:"round"})]});import{jsx as qt,jsxs as Gd}from"react/jsx-runtime";var Ii=({size:e=24,className:t})=>Gd("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:[qt("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"}),qt("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"}),qt("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"}),qt("path",{d:"M13.5 12H11",strokeWidth:"1",strokeLinecap:"round",strokeLinejoin:"round"}),qt("path",{d:"M13.5 10H11",strokeWidth:"1",strokeLinecap:"round",strokeLinejoin:"round"})]});import{jsx as Do,jsxs as Bd}from"react/jsx-runtime";var Ai=({size:e=24,className:t})=>Bd("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:[Do("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"}),Do("path",{d:"M8 21V14C8 13.4477 8.44772 13 9 13H15C15.5523 13 16 13.4477 16 14V21",strokeWidth:"1",fill:"none"}),Do("path",{d:"M10.2222 17H13.7777",strokeWidth:"1",strokeLinecap:"round",strokeLinejoin:"round"}),Do("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||{}),_e=(o=>(o.SCRIPT="SCRIPT",o.SUBPROCESS="SUBPROCESS",o))(_e||{}),Ro={SCRIPT:{icon:Fd},SUBPROCESS:{icon:Wd}},Fe=(t=>(t.LOOP="LOOP",t))(Fe||{}),Vo={LOOP:{icon:zd}},Te=(n=>(n.EXCLUSIVE="EXCLUSIVE",n.PARALLEL="PARALLEL",n.COMPLEX="COMPLEX",n))(Te||{}),hr={EXCLUSIVE:{icon:yt},PARALLEL:{icon:xt},COMPLEX:{icon:ht}};import{ReactFlowProvider as ky}from"@xyflow/react";import{createContext as Dy,useContext as Ry,useEffect as Vy,useId as Oy,useMemo as Hy,useState as ke}from"react";import{Background as fy,MiniMap as my,ReactFlow as gy,SelectionMode as hy}from"@xyflow/react";import{forwardRef as yy,useImperativeHandle as xy}from"react";import{useEdgesState as Vh,useNodesState as Oh,useOnSelectionChange as Hh}from"@xyflow/react";import{useCallback as $n,useEffect as Gh,useState as Bh}from"react";import{create as Yd}from"zustand";import{useReactFlow as Ud}from"@xyflow/react";import{useCallback as $d}from"react";var Oo=()=>{let{setEdges:e}=Ud();return $d(()=>{let o=je.getState().pathEdgeIds;e(n=>n.map(r=>v(E({},r),{selected:o.includes(r.id)})))},[e])},je=Yd((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:y,path:g}=p.shift();if(y===u)return g;let m=a[y]||[];for(let{targetId:h,edgeId:x}of m)f.has(h)||(f.add(h),p.push({node:h,path:[...g,x]}))}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 lf,useReactFlow as cf,useStore as df}from"@xyflow/react";var Xd={value:()=>{}};function Si(){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 Ho(o)}function Ho(e){this._=e}function Kd(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}})}Ho.prototype=Si.prototype={constructor:Ho,on:function(e,t){var o=this._,n=Kd(e+"",o),r,i=-1,a=n.length;if(arguments.length<2){for(;++i<a;)if((r=(e=n[i]).type)&&(r=qd(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]=Ci(o[r],e.name,t);else if(t==null)for(r in o)o[r]=Ci(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 Ho(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 qd(e,t){for(var o=0,n=e.length,r;o<n;++o)if((r=e[o]).name===t)return r.value}function Ci(e,t,o){for(var n=0,r=e.length;n<r;++n)if(e[n].name===t){e[n]=Xd,e=e.slice(0,n).concat(e.slice(n+1));break}return o!=null&&e.push({name:t,value:o}),e}var yr=Si;var Go="http://www.w3.org/1999/xhtml",xr={svg:"http://www.w3.org/2000/svg",xhtml:Go,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)),xr.hasOwnProperty(t)?{space:xr[t],local:e}:e}function Zd(e){return function(){var t=this.ownerDocument,o=this.namespaceURI;return o===Go&&t.documentElement.namespaceURI===Go?t.createElement(e):t.createElementNS(o,e)}}function Jd(e){return function(){return this.ownerDocument.createElementNS(e.space,e.local)}}function Bo(e){var t=Re(e);return(t.local?Jd:Zd)(t)}function Qd(){}function et(e){return e==null?Qd:function(){return this.querySelector(e)}}function Mi(e){typeof e!="function"&&(e=et(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 Z(n,this._parents)}function Er(e){return e==null?[]:Array.isArray(e)?e:Array.from(e)}function jd(){return[]}function Zt(e){return e==null?jd:function(){return this.querySelectorAll(e)}}function eu(e){return function(){return Er(e.apply(this,arguments))}}function Pi(e){typeof e=="function"?e=eu(e):e=Zt(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 Z(n,r)}function Jt(e){return function(){return this.matches(e)}}function zo(e){return function(t){return t.matches(e)}}var tu=Array.prototype.find;function ou(e){return function(){return tu.call(this.children,e)}}function nu(){return this.firstElementChild}function Li(e){return this.select(e==null?nu:ou(typeof e=="function"?e:zo(e)))}var ru=Array.prototype.filter;function iu(){return Array.from(this.children)}function su(e){return function(){return ru.call(this.children,e)}}function ki(e){return this.selectAll(e==null?iu:su(typeof e=="function"?e:zo(e)))}function Di(e){typeof e!="function"&&(e=Jt(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 Z(n,this._parents)}function Fo(e){return new Array(e.length)}function Ri(){return new Z(this._enter||this._groups.map(Fo),this._parents)}function Qt(e,t){this.ownerDocument=e.ownerDocument,this.namespaceURI=e.namespaceURI,this._next=null,this._parent=e,this.__data__=t}Qt.prototype={constructor:Qt,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 Vi(e){return function(){return e}}function au(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 Qt(e,i[a]);for(;a<l;++a)(s=t[a])&&(r[a]=s)}function lu(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 Qt(e,i[s]);for(s=0;s<d;++s)(l=t[s])&&c.get(p[s])===l&&(r[s]=l)}function cu(e){return e.__data__}function Oi(e,t){if(!arguments.length)return Array.from(this,cu);var o=t?lu:au,n=this._parents,r=this._groups;typeof e!="function"&&(e=Vi(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=du(e.call(d,d&&d.__data__,c,n)),y=f.length,g=s[c]=new Array(y),m=a[c]=new Array(y),h=l[c]=new Array(p);o(d,u,g,m,h,f,t);for(var x=0,b=0,T,_;x<y;++x)if(T=g[x]){for(x>=b&&(b=x+1);!(_=m[b])&&++b<y;);T._next=_||null}}return a=new Z(a,n),a._enter=s,a._exit=l,a}function du(e){return typeof e=="object"&&"length"in e?e:Array.from(e)}function Hi(){return new Z(this._exit||this._groups.map(Fo),this._parents)}function Gi(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 Bi(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,y=0;y<u;++y)(f=c[y]||d[y])&&(p[y]=f);for(;l<r;++l)s[l]=o[l];return new Z(s,this._parents)}function zi(){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 Fi(e){e||(e=uu);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 Z(r,this._parents).order()}function uu(e,t){return e<t?-1:e>t?1:e>=t?0:NaN}function Wi(){var e=arguments[0];return arguments[0]=this,e.apply(null,arguments),this}function Yi(){return Array.from(this)}function Ui(){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 $i(){let e=0;for(let t of this)++e;return e}function Xi(){return!this.node()}function Ki(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 pu(e){return function(){this.removeAttribute(e)}}function fu(e){return function(){this.removeAttributeNS(e.space,e.local)}}function mu(e,t){return function(){this.setAttribute(e,t)}}function gu(e,t){return function(){this.setAttributeNS(e.space,e.local,t)}}function hu(e,t){return function(){var o=t.apply(this,arguments);o==null?this.removeAttribute(e):this.setAttribute(e,o)}}function yu(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 qi(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?fu:pu:typeof t=="function"?o.local?yu:hu:o.local?gu:mu)(o,t))}function Wo(e){return e.ownerDocument&&e.ownerDocument.defaultView||e.document&&e||e.defaultView}function xu(e){return function(){this.style.removeProperty(e)}}function Eu(e,t,o){return function(){this.style.setProperty(e,t,o)}}function bu(e,t,o){return function(){var n=t.apply(this,arguments);n==null?this.style.removeProperty(e):this.style.setProperty(e,n,o)}}function Zi(e,t,o){return arguments.length>1?this.each((t==null?xu:typeof t=="function"?bu:Eu)(e,t,o==null?"":o)):We(this.node(),e)}function We(e,t){return e.style.getPropertyValue(t)||Wo(e).getComputedStyle(e,null).getPropertyValue(t)}function _u(e){return function(){delete this[e]}}function Tu(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 Ji(e,t){return arguments.length>1?this.each((t==null?_u:typeof t=="function"?vu:Tu)(e,t)):this.node()[e]}function Qi(e){return e.trim().split(/^|\s+/)}function br(e){return e.classList||new ji(e)}function ji(e){this._node=e,this._names=Qi(e.getAttribute("class")||"")}ji.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 es(e,t){for(var o=br(e),n=-1,r=t.length;++n<r;)o.add(t[n])}function ts(e,t){for(var o=br(e),n=-1,r=t.length;++n<r;)o.remove(t[n])}function Nu(e){return function(){es(this,e)}}function wu(e){return function(){ts(this,e)}}function Iu(e,t){return function(){(t.apply(this,arguments)?es:ts)(this,e)}}function os(e,t){var o=Qi(e+"");if(arguments.length<2){for(var n=br(this.node()),r=-1,i=o.length;++r<i;)if(!n.contains(o[r]))return!1;return!0}return this.each((typeof t=="function"?Iu:t?Nu:wu)(o,t))}function Au(){this.textContent=""}function Cu(e){return function(){this.textContent=e}}function Su(e){return function(){var t=e.apply(this,arguments);this.textContent=t==null?"":t}}function ns(e){return arguments.length?this.each(e==null?Au:(typeof e=="function"?Su:Cu)(e)):this.node().textContent}function Mu(){this.innerHTML=""}function Pu(e){return function(){this.innerHTML=e}}function Lu(e){return function(){var t=e.apply(this,arguments);this.innerHTML=t==null?"":t}}function rs(e){return arguments.length?this.each(e==null?Mu:(typeof e=="function"?Lu:Pu)(e)):this.node().innerHTML}function ku(){this.nextSibling&&this.parentNode.appendChild(this)}function is(){return this.each(ku)}function Du(){this.previousSibling&&this.parentNode.insertBefore(this,this.parentNode.firstChild)}function ss(){return this.each(Du)}function as(e){var t=typeof e=="function"?e:Bo(e);return this.select(function(){return this.appendChild(t.apply(this,arguments))})}function Ru(){return null}function ls(e,t){var o=typeof e=="function"?e:Bo(e),n=t==null?Ru:typeof t=="function"?t:et(t);return this.select(function(){return this.insertBefore(o.apply(this,arguments),n.apply(this,arguments)||null)})}function Vu(){var e=this.parentNode;e&&e.removeChild(this)}function cs(){return this.each(Vu)}function Ou(){var e=this.cloneNode(!1),t=this.parentNode;return t?t.insertBefore(e,this.nextSibling):e}function Hu(){var e=this.cloneNode(!0),t=this.parentNode;return t?t.insertBefore(e,this.nextSibling):e}function ds(e){return this.select(e?Hu:Ou)}function us(e){return arguments.length?this.property("__data__",e):this.node().__data__}function Gu(e){return function(t){e.call(this,t,this.__data__)}}function Bu(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 zu(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 Fu(e,t,o){return function(){var n=this.__on,r,i=Gu(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 ps(e,t,o){var n=Bu(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?Fu:zu,r=0;r<i;++r)this.each(s(n[r],t,o));return this}function fs(e,t,o){var n=Wo(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 Wu(e,t){return function(){return fs(this,e,t)}}function Yu(e,t){return function(){return fs(this,e,t.apply(this,arguments))}}function ms(e,t){return this.each((typeof t=="function"?Yu:Wu)(e,t))}function*gs(){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 Uu=[null];function Z(e,t){this._groups=e,this._parents=t}function hs(){return new Z([[document.documentElement]],Uu)}function $u(){return this}Z.prototype=hs.prototype={constructor:Z,select:Mi,selectAll:Pi,selectChild:Li,selectChildren:ki,filter:Di,data:Oi,enter:Ri,exit:Hi,join:Gi,merge:Bi,selection:$u,order:zi,sort:Fi,call:Wi,nodes:Yi,node:Ui,size:$i,empty:Xi,each:Ki,attr:qi,style:Zi,property:Ji,classed:os,text:ns,html:rs,raise:is,lower:ss,append:as,insert:ls,remove:cs,clone:ds,datum:us,on:ps,dispatch:ms,[Symbol.iterator]:gs};var Ve=hs;function Yo(e,t,o){e.prototype=t.prototype=o,o.constructor=e}function _r(e,t){var o=Object.create(e.prototype);for(var n in t)o[n]=t[n];return o}function to(){}var jt=.7,Xo=1/jt,Et="\\s*([+-]?\\d+)\\s*",eo="\\s*([+-]?(?:\\d*\\.)?\\d+(?:[eE][+-]?\\d+)?)\\s*",Ce="\\s*([+-]?(?:\\d*\\.)?\\d+(?:[eE][+-]?\\d+)?)%\\s*",Xu=/^#([0-9a-f]{3,8})$/,Ku=new RegExp(`^rgb\\(${Et},${Et},${Et}\\)$`),qu=new RegExp(`^rgb\\(${Ce},${Ce},${Ce}\\)$`),Zu=new RegExp(`^rgba\\(${Et},${Et},${Et},${eo}\\)$`),Ju=new RegExp(`^rgba\\(${Ce},${Ce},${Ce},${eo}\\)$`),Qu=new RegExp(`^hsl\\(${eo},${Ce},${Ce}\\)$`),ju=new RegExp(`^hsla\\(${eo},${Ce},${Ce},${eo}\\)$`),ys={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};Yo(to,Ye,{copy(e){return Object.assign(new this.constructor,this,e)},displayable(){return this.rgb().displayable()},hex:xs,formatHex:xs,formatHex8:ep,formatHsl:tp,formatRgb:Es,toString:Es});function xs(){return this.rgb().formatHex()}function ep(){return this.rgb().formatHex8()}function tp(){return ws(this).formatHsl()}function Es(){return this.rgb().formatRgb()}function Ye(e){var t,o;return e=(e+"").trim().toLowerCase(),(t=Xu.exec(e))?(o=t[1].length,t=parseInt(t[1],16),o===6?bs(t):o===3?new de(t>>8&15|t>>4&240,t>>4&15|t&240,(t&15)<<4|t&15,1):o===8?Uo(t>>24&255,t>>16&255,t>>8&255,(t&255)/255):o===4?Uo(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=Ku.exec(e))?new de(t[1],t[2],t[3],1):(t=qu.exec(e))?new de(t[1]*255/100,t[2]*255/100,t[3]*255/100,1):(t=Zu.exec(e))?Uo(t[1],t[2],t[3],t[4]):(t=Ju.exec(e))?Uo(t[1]*255/100,t[2]*255/100,t[3]*255/100,t[4]):(t=Qu.exec(e))?vs(t[1],t[2]/100,t[3]/100,1):(t=ju.exec(e))?vs(t[1],t[2]/100,t[3]/100,t[4]):ys.hasOwnProperty(e)?bs(ys[e]):e==="transparent"?new de(NaN,NaN,NaN,0):null}function bs(e){return new de(e>>16&255,e>>8&255,e&255,1)}function Uo(e,t,o,n){return n<=0&&(e=t=o=NaN),new de(e,t,o,n)}function op(e){return e instanceof to||(e=Ye(e)),e?(e=e.rgb(),new de(e.r,e.g,e.b,e.opacity)):new de}function bt(e,t,o,n){return arguments.length===1?op(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}Yo(de,bt,_r(to,{brighter(e){return e=e==null?Xo:Math.pow(Xo,e),new de(this.r*e,this.g*e,this.b*e,this.opacity)},darker(e){return e=e==null?jt:Math.pow(jt,e),new de(this.r*e,this.g*e,this.b*e,this.opacity)},rgb(){return this},clamp(){return new de(ot(this.r),ot(this.g),ot(this.b),Ko(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:_s,formatHex:_s,formatHex8:np,formatRgb:Ts,toString:Ts}));function _s(){return`#${tt(this.r)}${tt(this.g)}${tt(this.b)}`}function np(){return`#${tt(this.r)}${tt(this.g)}${tt(this.b)}${tt((isNaN(this.opacity)?1:this.opacity)*255)}`}function Ts(){let e=Ko(this.opacity);return`${e===1?"rgb(":"rgba("}${ot(this.r)}, ${ot(this.g)}, ${ot(this.b)}${e===1?")":`, ${e})`}`}function Ko(e){return isNaN(e)?1:Math.max(0,Math.min(1,e))}function ot(e){return Math.max(0,Math.min(255,Math.round(e)||0))}function tt(e){return e=ot(e),(e<16?"0":"")+e.toString(16)}function vs(e,t,o,n){return n<=0?e=t=o=NaN:o<=0||o>=1?e=t=NaN:t<=0&&(e=NaN),new ve(e,t,o,n)}function ws(e){if(e instanceof ve)return new ve(e.h,e.s,e.l,e.opacity);if(e instanceof to||(e=Ye(e)),!e)return new ve;if(e instanceof ve)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 ve(a,s,l,e.opacity)}function Is(e,t,o,n){return arguments.length===1?ws(e):new ve(e,t,o,n==null?1:n)}function ve(e,t,o,n){this.h=+e,this.s=+t,this.l=+o,this.opacity=+n}Yo(ve,Is,_r(to,{brighter(e){return e=e==null?Xo:Math.pow(Xo,e),new ve(this.h,this.s,this.l*e,this.opacity)},darker(e){return e=e==null?jt:Math.pow(jt,e),new ve(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(Tr(e>=240?e-240:e+120,r,n),Tr(e,r,n),Tr(e<120?e+240:e-120,r,n),this.opacity)},clamp(){return new ve(Ns(this.h),$o(this.s),$o(this.l),Ko(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=Ko(this.opacity);return`${e===1?"hsl(":"hsla("}${Ns(this.h)}, ${$o(this.s)*100}%, ${$o(this.l)*100}%${e===1?")":`, ${e})`}`}}));function Ns(e){return e=(e||0)%360,e<0?e+360:e}function $o(e){return Math.max(0,Math.min(1,e||0))}function Tr(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 vr(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 As(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 vr((o-n/t)*t,a,r,i,s)}}function Cs(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 vr((o-n/t)*t,r,i,a,s)}}var Nr=e=>()=>e;function rp(e,t){return function(o){return e+o*t}}function ip(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 Ss(e){return(e=+e)==1?qo:function(t,o){return o-t?ip(t,o,e):Nr(isNaN(t)?o:t)}}function qo(e,t){var o=t-e;return o?rp(e,o):Nr(isNaN(e)?t:e)}var Zo=function e(t){var o=Ss(t);function n(r,i){var a=o((r=bt(r)).r,(i=bt(i)).r),s=o(r.g,i.g),l=o(r.b,i.b),c=qo(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 Ms(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=bt(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 sp=Ms(As),ap=Ms(Cs);function he(e,t){return e=+e,t=+t,function(o){return e*(1-o)+t*o}}var Ir=/[-+]?(?:\d+\.?\d*|\.?\d+)(?:[eE][-+]?\d+)?/g,wr=new RegExp(Ir.source,"g");function lp(e){return function(){return e}}function cp(e){return function(t){return e(t)+""}}function Ar(e,t){var o=Ir.lastIndex=wr.lastIndex=0,n,r,i,a=-1,s=[],l=[];for(e=e+"",t=t+"";(n=Ir.exec(e))&&(r=wr.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=wr.lastIndex;return o<t.length&&(i=t.slice(o),s[a]?s[a]+=i:s[++a]=i),s.length<2?l[0]?cp(l[0].x):lp(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 Ps=180/Math.PI,Jo={translateX:0,translateY:0,rotate:0,skewX:0,scaleX:1,scaleY:1};function Cr(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)*Ps,skewX:Math.atan(l)*Ps,scaleX:a,scaleY:s}}var Qo;function Ls(e){let t=new(typeof DOMMatrix=="function"?DOMMatrix:WebKitCSSMatrix)(e+"");return t.isIdentity?Jo:Cr(t.a,t.b,t.c,t.d,t.e,t.f)}function ks(e){return e==null?Jo:(Qo||(Qo=document.createElementNS("http://www.w3.org/2000/svg","g")),Qo.setAttribute("transform",e),(e=Qo.transform.baseVal.consolidate())?(e=e.matrix,Cr(e.a,e.b,e.c,e.d,e.e,e.f)):Jo)}function Ds(e,t,o,n){function r(c){return c.length?c.pop()+" ":""}function i(c,d,u,p,f,y){if(c!==u||d!==p){var g=f.push("translate(",null,t,null,o);y.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,y){if(c!==u||d!==p){var g=f.push(r(f)+"scale(",null,",",null,")");y.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 y=-1,g=p.length,m;++y<g;)u[(m=p[y]).i]=m.x(f);return u.join("")}}}var Sr=Ds(Ls,"px, ","px)","deg)"),Mr=Ds(ks,", ",")",")");var _t=0,no=0,oo=0,Vs=1e3,jo,ro,en=0,nt=0,tn=0,io=typeof performance=="object"&&performance.now?performance:Date,Os=typeof window=="object"&&window.requestAnimationFrame?window.requestAnimationFrame.bind(window):function(e){setTimeout(e,17)};function ao(){return nt||(Os(dp),nt=io.now()+tn)}function dp(){nt=0}function so(){this._call=this._time=this._next=null}so.prototype=on.prototype={constructor:so,restart:function(e,t,o){if(typeof e!="function")throw new TypeError("callback is not a function");o=(o==null?ao():+o)+(t==null?0:+t),!this._next&&ro!==this&&(ro?ro._next=this:jo=this,ro=this),this._call=e,this._time=o,Pr()},stop:function(){this._call&&(this._call=null,this._time=1/0,Pr())}};function on(e,t,o){var n=new so;return n.restart(e,t,o),n}function Hs(){ao(),++_t;for(var e=jo,t;e;)(t=nt-e._time)>=0&&e._call.call(void 0,t),e=e._next;--_t}function Rs(){nt=(en=io.now())+tn,_t=no=0;try{Hs()}finally{_t=0,pp(),nt=0}}function up(){var e=io.now(),t=e-en;t>Vs&&(tn-=t,en=e)}function pp(){for(var e,t=jo,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:jo=o);ro=e,Pr(n)}function Pr(e){if(!_t){no&&(no=clearTimeout(no));var t=e-nt;t>24?(e<1/0&&(no=setTimeout(Rs,e-io.now()-tn)),oo&&(oo=clearInterval(oo))):(oo||(en=io.now(),oo=setInterval(up,Vs)),_t=1,Os(Rs))}}function nn(e,t,o){var n=new so;return t=t==null?0:+t,n.restart(r=>{n.stop(),e(r+t)},t,o),n}var fp=yr("start","end","cancel","interrupt"),mp=[],zs=0,Gs=1,sn=2,rn=3,Bs=4,an=5,lo=6;function Ue(e,t,o,n,r,i){var a=e.__transition;if(!a)e.__transition={};else if(o in a)return;gp(e,o,{name:t,index:n,group:r,on:fp,tween:mp,time:i.time,delay:i.delay,duration:i.duration,ease:i.ease,timer:null,state:zs})}function co(e,t){var o=J(e,t);if(o.state>zs)throw new Error("too late; already scheduled");return o}function oe(e,t){var o=J(e,t);if(o.state>rn)throw new Error("too late; already running");return o}function J(e,t){var o=e.__transition;if(!o||!(o=o[t]))throw new Error("transition not found");return o}function gp(e,t,o){var n=e.__transition,r;n[t]=o,o.timer=on(i,0,o.time);function i(c){o.state=Gs,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!==Gs)return l();for(d in n)if(f=n[d],f.name===o.name){if(f.state===rn)return nn(a);f.state===Bs?(f.state=lo,f.timer.stop(),f.on.call("interrupt",e,e.__data__,f.index,f.group),delete n[d]):+d<t&&(f.state=lo,f.timer.stop(),f.on.call("cancel",e,e.__data__,f.index,f.group),delete n[d])}if(nn(function(){o.state===rn&&(o.state=Bs,o.timer.restart(s,o.delay,o.time),s(c))}),o.state=sn,o.on.call("start",e,e.__data__,o.index,o.group),o.state===sn){for(o.state=rn,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=an,1),u=-1,p=r.length;++u<p;)r[u].call(e,d);o.state===an&&(o.on.call("end",e,e.__data__,o.index,o.group),l())}function l(){o.state=lo,o.timer.stop(),delete n[t];for(var c in n)return;delete e.__transition}}function Lr(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>sn&&n.state<an,n.state=lo,n.timer.stop(),n.on.call(r?"interrupt":"cancel",e,e.__data__,n.index,n.group),delete o[a]}i&&delete e.__transition}}function Fs(e){return this.each(function(){Lr(this,e)})}function hp(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 yp(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 Ws(e,t){var o=this._id;if(e+="",arguments.length<2){for(var n=J(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?hp:yp)(o,e,t))}function Tt(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 J(r,n).value[t]}}function ln(e,t){var o;return(typeof t=="number"?he:t instanceof Ye?Zo:(o=Ye(t))?(t=o,Zo):Ar)(e,t)}function xp(e){return function(){this.removeAttribute(e)}}function Ep(e){return function(){this.removeAttributeNS(e.space,e.local)}}function bp(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 _p(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 Tp(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 Ys(e,t){var o=Re(e),n=o==="transform"?Mr:ln;return this.attrTween(e,typeof t=="function"?(o.local?vp:Tp)(o,n,Tt(this,"attr."+e,t)):t==null?(o.local?Ep:xp)(o):(o.local?_p:bp)(o,n,t))}function Np(e,t){return function(o){this.setAttribute(e,t.call(this,o))}}function wp(e,t){return function(o){this.setAttributeNS(e.space,e.local,t.call(this,o))}}function Ip(e,t){var o,n;function r(){var i=t.apply(this,arguments);return i!==n&&(o=(n=i)&&wp(e,i)),o}return r._value=t,r}function Ap(e,t){var o,n;function r(){var i=t.apply(this,arguments);return i!==n&&(o=(n=i)&&Np(e,i)),o}return r._value=t,r}function Us(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?Ip:Ap)(n,t))}function Cp(e,t){return function(){co(this,e).delay=+t.apply(this,arguments)}}function Sp(e,t){return t=+t,function(){co(this,e).delay=t}}function $s(e){var t=this._id;return arguments.length?this.each((typeof e=="function"?Cp:Sp)(t,e)):J(this.node(),t).delay}function Mp(e,t){return function(){oe(this,e).duration=+t.apply(this,arguments)}}function Pp(e,t){return t=+t,function(){oe(this,e).duration=t}}function Xs(e){var t=this._id;return arguments.length?this.each((typeof e=="function"?Mp:Pp)(t,e)):J(this.node(),t).duration}function Lp(e,t){if(typeof t!="function")throw new Error;return function(){oe(this,e).ease=t}}function Ks(e){var t=this._id;return arguments.length?this.each(Lp(t,e)):J(this.node(),t).ease}function kp(e,t){return function(){var o=t.apply(this,arguments);if(typeof o!="function")throw new Error;oe(this,e).ease=o}}function qs(e){if(typeof e!="function")throw new Error;return this.each(kp(this._id,e))}function Zs(e){typeof e!="function"&&(e=Jt(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 Js(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 Dp(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 Rp(e,t,o){var n,r,i=Dp(t)?co:oe;return function(){var a=i(this,e),s=a.on;s!==n&&(r=(n=s).copy()).on(t,o),a.on=r}}function Qs(e,t){var o=this._id;return arguments.length<2?J(this.node(),o).on.on(e):this.each(Rp(o,e,t))}function Vp(e){return function(){var t=this.parentNode;for(var o in this.__transition)if(+o!==e)return;t&&t.removeChild(this)}}function js(){return this.on("end.remove",Vp(this._id))}function ea(e){var t=this._name,o=this._id;typeof e!="function"&&(e=et(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,Ue(c[p],t,o,p,c,J(d,o)));return new le(i,this._parents,t,o)}function ta(e){var t=this._name,o=this._id;typeof e!="function"&&(e=Zt(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,y=J(d,o),g=0,m=p.length;g<m;++g)(f=p[g])&&Ue(f,t,o,g,p,y);i.push(p),a.push(d)}return new le(i,a,t,o)}var Op=Ve.prototype.constructor;function oa(){return new Op(this._groups,this._parents)}function Hp(e,t){var o,n,r;return function(){var i=We(this,e),a=(this.style.removeProperty(e),We(this,e));return i===a?null:i===o&&a===n?r:r=t(o=i,n=a)}}function na(e){return function(){this.style.removeProperty(e)}}function Gp(e,t,o){var n,r=o+"",i;return function(){var a=We(this,e);return a===r?null:a===n?i:i=t(n=a,o)}}function Bp(e,t,o){var n,r,i;return function(){var a=We(this,e),s=o(this),l=s+"";return s==null&&(l=s=(this.style.removeProperty(e),We(this,e))),a===l?null:a===n&&l===r?i:(r=l,i=t(n=a,s))}}function zp(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=na(t)):void 0;(c!==o||r!==d)&&(n=(o=c).copy()).on(a,r=d),l.on=n}}function ra(e,t,o){var n=(e+="")=="transform"?Sr:ln;return t==null?this.styleTween(e,Hp(e,n)).on("end.style."+e,na(e)):typeof t=="function"?this.styleTween(e,Bp(e,n,Tt(this,"style."+e,t))).each(zp(this._id,e)):this.styleTween(e,Gp(e,n,t),o).on("end.style."+e,null)}function Fp(e,t,o){return function(n){this.style.setProperty(e,t.call(this,n),o)}}function Wp(e,t,o){var n,r;function i(){var a=t.apply(this,arguments);return a!==r&&(n=(r=a)&&Fp(e,a,o)),n}return i._value=t,i}function ia(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,Wp(e,t,o==null?"":o))}function Yp(e){return function(){this.textContent=e}}function Up(e){return function(){var t=e(this);this.textContent=t==null?"":t}}function sa(e){return this.tween("text",typeof e=="function"?Up(Tt(this,"text",e)):Yp(e==null?"":e+""))}function $p(e){return function(t){this.textContent=e.call(this,t)}}function Xp(e){var t,o;function n(){var r=e.apply(this,arguments);return r!==o&&(t=(o=r)&&$p(r)),t}return n._value=e,n}function aa(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,Xp(e))}function la(){for(var e=this._name,t=this._id,o=cn(),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=J(l,t);Ue(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 ca(){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 Kp=0;function le(e,t,o,n){this._groups=e,this._parents=t,this._name=o,this._id=n}function da(e){return Ve().transition(e)}function cn(){return++Kp}var Oe=Ve.prototype;le.prototype=da.prototype={constructor:le,select:ea,selectAll:ta,selectChild:Oe.selectChild,selectChildren:Oe.selectChildren,filter:Zs,merge:Js,selection:oa,transition:la,call:Oe.call,nodes:Oe.nodes,node:Oe.node,size:Oe.size,empty:Oe.empty,each:Oe.each,on:Qs,attr:Ys,attrTween:Us,style:ra,styleTween:ia,text:sa,textTween:aa,remove:js,tween:Ws,delay:$s,duration:Xs,ease:Ks,easeVarying:qs,end:ca,[Symbol.iterator]:Oe[Symbol.iterator]};function dn(e){return((e*=2)<=1?e*e*e:(e-=2)*e*e+2)/2}var qp={time:null,delay:0,duration:250,ease:dn};function Zp(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 ua(e){var t,o;e instanceof le?(t=e._id,e=e._name):(t=cn(),(o=qp).time=ao(),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])&&Ue(l,e,t,c,a,o||Zp(l,t));return new le(n,this._parents,e,t)}Ve.prototype.interrupt=Fs;Ve.prototype.transition=ua;function $e(e,t,o){this.k=e,this.x=t,this.y=o}$e.prototype={constructor:$e,scale:function(e){return e===1?this:new $e(this.k*e,this.x,this.y)},translate:function(e,t){return e===0&t===0?this:new $e(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 un=new $e(1,0,0);pn.prototype=$e.prototype;function pn(e){for(;!e.__zoom;)if(!(e=e.parentNode))return un;return e.__zoom}var Qp=[[Number.NEGATIVE_INFINITY,Number.NEGATIVE_INFINITY],[Number.POSITIVE_INFINITY,Number.POSITIVE_INFINITY]];var pa;(function(e){e.Strict="strict",e.Loose="loose"})(pa||(pa={}));var fa;(function(e){e.Free="free",e.Vertical="vertical",e.Horizontal="horizontal"})(fa||(fa={}));var ma;(function(e){e.Partial="partial",e.Full="full"})(ma||(ma={}));var ga;(function(e){e.Bezier="default",e.Straight="straight",e.Step="step",e.SmoothStep="smoothstep",e.SimpleBezier="simplebezier"})(ga||(ga={}));var ha;(function(e){e.Arrow="arrow",e.ArrowClosed="arrowclosed"})(ha||(ha={}));var ue;(function(e){e.Left="left",e.Top="top",e.Right="right",e.Bottom="bottom"})(ue||(ue={}));var mv={[ue.Left]:ue.Right,[ue.Right]:ue.Left,[ue.Top]:ue.Bottom,[ue.Bottom]:ue.Top};var jp=e=>"id"in e&&"internals"in e&&!("source"in e)&&!("target"in e);var ef=(e,t=[0,0])=>{var s;let{width:o,height:n}=tf(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}=jp(e)?e.internals.positionAbsolute:ef(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 tf(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 gv={[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 of={nodeOrigin:[0,0],nodeExtent:Qp,elevateNodesOnSelect:!0,defaults:{}},hv=v(E({},of),{checkEquality:!0});var ya;(function(e){e.Line="line",e.Handle="handle"})(ya||(ya={}));var nf={width:0,height:0,x:0,y:0},yv=v(E({},nf),{pointerX:0,pointerY:0,aspectRatio:1});import{useCallback as uo,useEffect as uf,useRef as pf,useState as _a}from"react";import{shallow as ff}from"zustand/shallow";var rf=(e,t)=>e.x<t.x2&&e.x2>t.x&&e.y<t.y2&&e.y2>t.y;function sf(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 af(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 fn=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||!rf(p.nodeBox,r))continue;let f=Math.abs(p.position-o);if(f>mn)continue;let g=sf(p.nodeBox,fe(n))>0?0:af(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 xa(e,t=rt,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 Ea(e,t,o,n,r=Object.keys(rt)){let i=[];for(let s of r){let l=rt[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 ba(e,t,o,n,r,i,a,s){var u,p,f,y,g,m,h,x;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+((y=(f=e.measured)==null?void 0:f.height)!=null?y:0)};if(a){let T=a.anchor.resolve(e,d)-a.line.position;if(Math.abs(T)<=mn){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)<=mn){if(o.position.x-=T,r!=null&&r.dimensions)if(n){let _=t.internals.positionAbsolute.x+((x=(h=e.measured)==null?void 0:h.width)!=null?x: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 mn=10,rt={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 gf}from"react/jsx-runtime";var mf=new fn;function vt(){let[e,t]=_a(void 0),[o,n]=_a(void 0),{width:r,height:i}=df(m=>({width:m.width,height:m.height}),ff),a=lf(),s=pf(mf),{screenToFlowPosition:l,getInternalNode:c,getNodes:d}=cf(),u=uo(()=>{t(void 0),n(void 0)},[]),p=uo(m=>{let h=m!=null?m:d();u();let x=xa(h,rt,c);s.current.initialize(x)},[c,u,d]),f=uo(()=>{setTimeout(()=>{p()},100)},[p]);uf(()=>{a&&p(d())},[a,p,d]);let y=uo((m,h)=>{var $,D,H,z,W;if(!s.current||m.length===0||m.length>2)return m;u();let x,b,T=Object.keys(rt);m.length===1?m[0].type==="position"?x=m[0]:m[0].type==="dimensions"&&(b=m[0],T=["right","bottom"]):m[0].type==="position"&&m[1].type==="dimensions"&&m[1].dimensions&&(x=m[0],b=m[1],T=["top","left"]);let _=h.find(Y=>Y.id===m[0].id);if(!_)return m;let N=c(_.id);if(!N)throw new Error(`Node with id ${_.id} not found in internal nodes`);let w=c(($=N.parentId)!=null?$:""),S=fe(N);b!=null&&b.dimensions&&(S.x2=S.x+b.dimensions.width,S.y2=S.y+b.dimensions.height);let{x:P,y:L}=l({x:0,y:0}),{x:C,y:I}=l({x:r,y:i}),M={x:P,y:L,x2:C,y2:I},{horizontal:A,vertical:k}=Ea(s.current,M,_,S,T),V={id:_.id,type:"position",position:{x:N.internals.positionAbsolute.x,y:N.internals.positionAbsolute.y},dragging:!1};x!=null&&x.position&&V.position&&(w?(V.position.x=x.position.x+((H=(D=w==null?void 0:w.position)==null?void 0:D.x)!=null?H:0),V.position.y=x.position.y+((W=(z=w==null?void 0:w.position)==null?void 0:z.y)!=null?W:0)):(V.position.x=x.position.x,V.position.y=x.position.y));let{snappedX:O,snappedY:B}=ba(_,N,V,x,b,w,A,k);if(O||B){if((b!=null&&b.resizing||x!=null&&x.dragging)&&(O&&n(k==null?void 0:k.line),B&&t(A==null?void 0:A.line)),b&&x)return[V,b];if(x)return[V];if(b)return[b]}return m},[l,c,r,i,t,n,u]),g=uo(()=>gf(Ta,{horizontal:e,vertical:o}),[e,o]);return{rebuildIndex:p,forceRebuildIndex:f,updateHelperLines:y,helperLineHorizontal:e,helperLineVertical:o,HelperLines:g}}import{reconnectEdge as ih,useReactFlow as sh}from"@xyflow/react";import{useCallback as dt,useRef as ah}from"react";var Nt=e=>new Map(e.map(t=>[t.id,t])),po=(e,t,o)=>t.filter(n=>!(n.source!==e||o&&n.id===o)),va=(e,t,o)=>t.filter(n=>!(n.target!==e||o&&n.id===o)),gn=e=>e.some(t=>t.type==="START_EVENT"),Na=(e,t,o,n,r)=>{let i=Nt(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:po(e,n,r).filter(c=>{let d=i.get(c.target);return(d==null?void 0:d.type)!=="ANNOTATION"}).length>=1},wa=(e,t,o,n,r)=>{let i=Nt(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:va(t,n,r).filter(c=>{let d=i.get(c.source);return(d==null?void 0:d.type)!=="ANNOTATION"}).length>=1},hn=(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:po(e,o,n).length>=2},Ia=(e,t,o)=>{var a,s,l,c;let n=Nt(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"},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.variant)==="SCRIPT"},xn=(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"},En=(e,t,o,n)=>{let r=Nt(t),i=r.get(e);return!i||i.type!=="TASK"?!1:va(e,o,n).some(s=>{let l=r.get(s.source);return(l==null?void 0:l.type)==="START_EVENT"})},bn=(e,t,o,n)=>{let r=Nt(t),i=r.get(e);return!i||i.type!=="TASK"?!1:po(e,o,n).some(s=>{let l=r.get(s.target);return(l==null?void 0:l.type)==="END_EVENT"})},_n=(e,t,o)=>po(e,t,o).length>0,Tn=(e,t,o,n,r)=>{let i=Nt(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:po(e,n,r).filter(c=>{let d=i.get(c.target);return(d==null?void 0:d.type)!=="ANNOTATION"}).length>=2};var hf=[e=>({isValid:e.sourceNodeId!==e.targetNodeId,reason:"self_connection_not_allowed"}),e=>({isValid:!Na(e.sourceNodeId,e.targetNodeId,e.nodes,e.edges,e.reconnectingEdgeId),reason:"start_event_limit_reached"}),e=>({isValid:!wa(e.sourceNodeId,e.targetNodeId,e.nodes,e.edges,e.reconnectingEdgeId),reason:"end_event_limit_reached"}),e=>({isValid:!hn(e.sourceNodeId,e.nodes,e.edges,e.reconnectingEdgeId),reason:"gateway_limit_reached"}),e=>({isValid:!Tn(e.sourceNodeId,e.targetNodeId,e.nodes,e.edges,e.reconnectingEdgeId),reason:"task_limit_reached"}),e=>({isValid:Ia(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:!(yn(e.sourceNodeId,e.nodes)&&e.targetNodeType==="END_EVENT"),reason:"script_to_end_not_allowed"}),e=>({isValid:!(xn(e.sourceNodeId,e.nodes)&&e.targetNodeType==="END_EVENT"),reason:"loop_to_end_not_allowed"}),e=>({isValid:!(En(e.sourceNodeId,e.nodes,e.edges,e.reconnectingEdgeId)&&e.targetNodeType==="END_EVENT"),reason:"initial_activity_to_end_not_allowed"}),e=>({isValid:!(bn(e.sourceNodeId,e.nodes,e.edges,e.reconnectingEdgeId)&&e.targetNodeType!=="ANNOTATION"),reason:"final_activity_cannot_connect"}),e=>({isValid:!(_n(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"})],kr=e=>{for(let t of hf){let o=t(e);if(!o.isValid)return o}return{isValid:!0}};var yf=[{sourceTypes:["GATEWAY"],targetTypes:["TASK","GATEWAY"],validate:e=>({shouldDisable:hn(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:gn(e.nodes),reason:"start_event_already_exists"})},{sourceTypes:["TASK"],targetTypes:["END_EVENT"],validate:e=>({shouldDisable:yn(e.sourceNodeId,e.nodes),reason:"script_to_end_not_allowed"})},{sourceTypes:["TASK"],targetTypes:["END_EVENT"],validate:e=>({shouldDisable:xn(e.sourceNodeId,e.nodes),reason:"loop_to_end_not_allowed"})},{sourceTypes:["TASK"],targetTypes:["END_EVENT"],validate:e=>({shouldDisable:En(e.sourceNodeId,e.nodes,e.edges),reason:"initial_activity_to_end_not_allowed"})},{sourceTypes:["TASK"],validate:e=>({shouldDisable:bn(e.sourceNodeId,e.nodes,e.edges)&&e.targetNodeType!=="ANNOTATION",reason:"final_activity_cannot_connect"})},{targetTypes:["END_EVENT"],validate:e=>({shouldDisable:_n(e.sourceNodeId,e.edges),reason:"activity_has_outgoing_connections"})},{sourceTypes:["TASK"],validate:e=>({shouldDisable:Tn(e.sourceNodeId,null,e.nodes,e.edges)&&e.targetNodeType!=="ANNOTATION",reason:"task_limit_reached"})}],Aa=e=>{let t=yf.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 Wf,EdgeLabelRenderer as Yf,getStraightPath as Uf,useInternalNode as Ma,useViewport as $f}from"@xyflow/react";import{Position as fo}from"@xyflow/react";function Ca(e,t){var b,T,_,N;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+((N=(_=t==null?void 0:t.measured)==null?void 0:_.height)!=null?N:0)/2,p=(d-l)/(2*a)-(u-c)/(2*s),f=(d-l)/(2*a)+(u-c)/(2*s),y=1/(Math.abs(p)+Math.abs(f)||1),g=y*p,m=y*f,h=a*(g+m)+l,x=s*(-g+m)+c;return{x:h,y:x}}function Sa(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?fo.Left:s>=i+n-1?fo.Right:l<=a+1?fo.Top:l>=a+r-1?fo.Bottom:fo.Top}function Se(e,t){let o=Ca(e,t),n=Ca(t,e),r=Sa(e,o),i=Sa(t,n);return{sx:o.x,sy:o.y,tx:n.x,ty:n.y,sourcePos:r,targetPos:i}}import{Button as bf,Tooltip as _f,TooltipContent as Tf,TooltipTrigger as vf,useTranslation as Nf}from"lecom-ui";import{Settings as wf}from"lucide-react";import{getIncomers as vn,getOutgoers as Nn,useReactFlow as Ef}from"@xyflow/react";import{useStoreApi as xf}from"@xyflow/react";var Xe=()=>{let e=xf();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 Lo(),!0}}};var wn=()=>{let{getNode:e,getEdge:t,getNodes:o,getEdges:n}=Ef(),{selectElements:r}=Xe(),i=m=>{let h=o(),x=n(),b=vn(m,h,x),T=Nn(m,h,x),_=b.some(w=>w.type==="START_EVENT"),N=T.some(w=>w.type==="END_EVENT");return _?"start":N?"end":"between"},a=(m,h,x)=>{var _,N,w,S;if(!m)return;let b={type:m.type,variant:(_=m.data)==null?void 0:_.variant,attribute:(N=m.data)==null?void 0:N.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"?v(E({},T),{type:"sub_process"}):m.type==="GATEWAY"?v(E({},T),{type:"gateway",variant:s(m,h,x)}):v(E({},T),{type:"activity"})},s=(m,h,x)=>{if(m.type!=="GATEWAY")return;let b=vn(m,h,x),T=!1,_=!1;if(b.forEach(N=>{var w,S;N.type==="TASK"&&(((w=N.data)==null?void 0:w.variant)==="SCRIPT"&&(T=!0),((S=N.data)==null?void 0:S.attribute)==="LOOP"&&(_=!0))}),T&&_)return"script_loop";if(T)return"script";if(_)return"loop"},l=(m,h,x)=>{var w,S,P,L;let b=e(m.source),T=e(m.target);if(!b||!T)return"simple";if(Nn(b,h,x).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=(P=b.data)==null?void 0:P.attribute;if(T.type==="TASK"&&((L=T.data)==null?void 0:L.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,h,x)=>{let b=[];function T(N,w,S=0){let P=a(N,h,x);if(P.depth=S,w.push(P),N.type==="TASK"){b.push([...w]),w.pop();return}let L=vn(N,h,x);if(L.length)for(let C of L)T(C,w,S+1);w.pop()}let _=vn(m,h,x);for(let N of _)T(N,[]);return b},d=(m,h,x)=>{let b=[];function T(N,w,S=0){let P=a(N,h,x);if(P.depth=S,w.push(P),N.type==="TASK"){b.push([...w]),w.pop();return}let L=Nn(N,h,x);if(L.length)for(let C of L)T(C,w,S+1);w.pop()}let _=Nn(m,h,x);for(let N of _)T(N,[]);return b},u=(m,h,x)=>(x=x.filter(T=>T.source===m.id),x.map(T=>{var w;let _=e(T.target),N;return _&&(N=a(_,h,x)),{id:T.id,type:"routing",variant:l(T,h,x),label:(w=T.data)==null?void 0:w.label,target:N}})),p=m=>{let h=e(m);if(!h)return;let x=o(),b=n(),T=a(h,x,b);return T.sources=c(h,x,b),T.targets=d(h,x,b),T.edgeTargets=u(h,x,b),h.type==="GATEWAY"&&(T.variant=s(h,x,b)),T},f=m=>{let h=t(m);if(!h)return;let x=o(),b=n(),T=l(h,x,b),N={id:h.id,type:"routing",variant:T,gatewayVariant:void 0},w=e(h.source);if(w){let P=a(w,x,b),L=c(w,x,b),C=s(w,x,b);N.source=P,N.sources=L.length?L:[[P]],N.gatewayVariant=C}let S=e(h.target);if(S){let P=a(S,x,b),L=d(S,x,b);N.target=P,N.targets=L.length?L:[[P]]}return N},y=m=>{let h=e(m);if(h)return p(h.id);let x=t(m);if(x)return f(x.id)};return{configureElement:m=>{let h=y(m);if(h)return r([m]),h},getConfigureElement:y,getNodeConfigure:p,getEdgeConfigure:f}};import{jsx as In,jsxs as If}from"react/jsx-runtime";var Ke=({elementId:e,elementType:t="node"})=>{let{t:o}=Nf(),{onConfigureElement:n}=G(),{getConfigureElement:r}=wn();return If(_f,{children:[In(vf,{asChild:!0,children:In(bf,{variant:"ghost",color:"grey",size:"small",iconButton:!0,onClick:()=>{let a=r(e);a&&(n==null||n(a))},children:In(wf,{size:16})})}),In(Tf,{color:"black",children:o(t==="node"?"editor.toolbar.configure_node":"editor.toolbar.configure_edge")})]})};import{useReactFlow as Af}from"@xyflow/react";import{Button as Cf,Tooltip as Sf,TooltipContent as Mf,TooltipTrigger as Pf,useTranslation as Lf}from"lecom-ui";import{TrashIcon as kf}from"lucide-react";import{jsx as An,jsxs as Df}from"react/jsx-runtime";var Cn=({elementId:e,elementType:t="node"})=>{let{t:o}=Lf(),{deleteElements:n}=Af();return Df(Sf,{children:[An(Pf,{asChild:!0,children:An(Cf,{variant:"ghost",color:"destructive",size:"small",iconButton:!0,onClick:()=>{n(t==="node"?{nodes:[{id:e}]}:{edges:[{id:e}]})},children:An(kf,{size:16})})}),An(Mf,{color:"black",children:o("editor.toolbar.delete")})]})};import{Button as Rf,Tooltip as Vf,TooltipContent as Of,TooltipTrigger as Hf,useTranslation as Gf}from"lecom-ui";import{MoveUpRightIcon as Bf}from"lucide-react";import{useCallback as zf}from"react";import{jsx as Sn,jsxs as Ff}from"react/jsx-runtime";var mo=({nodeId:e,disabled:t=!1,tooltipMessage:o})=>{let{t:n}=Gf(),r=zf(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 Ff(Vf,{children:[Sn(Hf,{asChild:!0,children:Sn(Rf,{variant:"ghost",color:"grey",size:"small",iconButton:!0,disabled:t,className:t?"opacity-50 cursor-not-allowed":"",onMouseDown:t?void 0:r,children:Sn(Bf,{size:16})})}),Sn(Of,{color:"black",children:o||n("editor.toolbar.connect_node")})]})};import{jsx as go}from"react/jsx-runtime";var wt=i=>{var a=i,{edgeId:e,edgeType:t,sourceNode:o,targetNode:n}=a,r=Ae(a,["edgeId","edgeType","sourceNode","targetNode"]);let{mode:s}=G(),l=(o==null?void 0:o.type)==="START_EVENT",c=(n==null?void 0:n.type)==="END_EVENT",d=(o==null?void 0:o.type)==="GATEWAY"&&(n==null?void 0:n.type)==="GATEWAY",u=(o==null?void 0:o.type)==="TASK"&&(n==null?void 0:n.type)==="GATEWAY",p=!l&&!c&&!d&&!u,f=[{component:go(Cn,{elementId:e,elementType:"edge"})}],y=()=>s==="view"?p?[{component:go(Ke,{elementId:e,elementType:"edge"})}]:[]:p?[{component:go(Ke,{elementId:e,elementType:"edge"})},...f]:f,m=(h=>{switch(h){case"SEQUENCE_EDGE":return y();case"MESSAGE_EDGE":return s==="view"?[]:[...f];case"ANNOTATION_EDGE":return s==="view"?[]:[...f];default:return[]}})(t);if(!(m.length===0||s==="view"))return go("div",v(E({className:"flex items-center gap-1 w-fit px-3 py-2 bg-white rounded-sm shadow-md"},r),{children:m.map((h,x)=>go("div",{children:h.component},x))}))};import{jsx as Mn,jsxs as Xf}from"react/jsx-runtime";var It={type:"ANNOTATION_EDGE",reconnectable:!0},Pa=({id:e,source:t,target:o,selected:n,data:r})=>{let{zoom:i}=$f(),{isMultipleSelection:a}=G(),s=Ma(t),l=Ma(o);if(!s||!l)return null;let{sx:c,sy:d,tx:u,ty:p}=Se(s,l),[f,y,g]=Uf({sourceX:c,sourceY:d,targetX:u,targetY:p}),m=n||(s==null?void 0:s.selected)||(l==null?void 0:l.selected),h=1/i;return Xf("g",{className:R("text-grey-400 hover:text-grey-500",{"text-blue-500 hover:text-blue-600":m}),children:[Mn(Wf,{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)})}),Mn(Yf,{children:Mn("div",{className:"absolute z-[3000] pointer-events-auto flex flex-col items-center gap-1",style:{transform:`translate(-50%, -50%) translate(${y}px, ${g}px)`},children:n&&!a&&Mn(wt,{edgeId:e,edgeType:"ANNOTATION_EDGE",style:{transform:`scale(${h})`}})})})]})};import{useState as Va,useCallback as jf,useMemo as Br,useEffect as em,useRef as Oa}from"react";import{BaseEdge as tm,EdgeLabelRenderer as om,MarkerType as Ha,useInternalNode as Ga,useReactFlow as nm,useViewport as rm,Position as Ba}from"@xyflow/react";import{useEffect as La,useRef as Kf,useState as qf}from"react";import{jsx as ka}from"react/jsx-runtime";var ne=({value:e,maxLength:t,style:o,className:n,contentClassName:r,isEditing:i,onChange:a,onBlur:s})=>{let l=Kf(null),[c,d]=qf(!1);La(()=>{d(i!=null?i:!1)},[i]),La(()=>{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(),h=t&&m.length>=t,x=["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",N=b&&g.key==="x",w=b&&g.key==="v";function S(L){return/\w/.test(L)}if(m.length===0&&!S(g.key)&&!x.includes(g.key)&&!b){g.preventDefault();return}h&&(x.includes(g.key)||T||_||N||w||g.preventDefault())},f=g=>{if(!t)return;g.preventDefault();let m=g.clipboardData.getData("text/plain"),h=g.currentTarget.innerText,x=window.getSelection();if(!x||x.rangeCount===0)return;let b=x.getRangeAt(0);if((h.substring(0,b.startOffset)+m+h.substring(b.endOffset)).length>t){let _=t-(h.length-(b.endOffset-b.startOffset)),N=m.substring(0,Math.max(0,_));N&&(b.deleteContents(),b.insertNode(document.createTextNode(N)),b.setStartAfter(b.endContainer),b.collapse(!0),x.removeAllRanges(),x.addRange(b))}else b.deleteContents(),b.insertNode(document.createTextNode(m)),b.setStartAfter(b.endContainer),b.collapse(!0),x.removeAllRanges(),x.addRange(b)},y=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 ka("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:ka("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:y,children:e})})};import{Position as Pn}from"@xyflow/react";var Ln=e=>e===Pn.Left||e===Pn.Right,Dr=(e,t=30)=>e===Pn.Right||e===Pn.Bottom?t:-t,Rr=(e,t,o,n=1)=>Math.abs(e[o]-t[o])<n,kn=(e,t)=>Math.sqrt((t.x-e.x)**2+(t.y-e.y)**2),Dn=(e,t)=>({x:(e.x+t.x)/2,y:(e.y+t.y)/2});var it={OFFSET:30,TOLERANCE:1,MOVE_THRESHOLD:5,MIN_SEGMENT_LENGTH:15};function Zf(e,t,o,n,r,i){let a=Dr(r,it.OFFSET),s=Dr(i,it.OFFSET),l=Ln(r),c=Ln(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 Vr(e,t,o,n,r,i,a){let s=Zf(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=Ln(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)>it.TOLERANCE&&Math.abs(p.y-u.y)>it.TOLERANCE){let y=d%2===0===c;l[d+1]=y?{x:p.x,y:u.y}:{x:u.x,y:p.y}}}return l}var Da=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 Or,useEffect as Hr,useRef as Gr,useState as Rn}from"react";import{useReactFlow as Jf,useStore as Qf}from"@xyflow/react";var Ra=({edgeId:e,source:t,target:o,instanceId:n,isReadOnly:r})=>{let{setEdges:i,getNode:a,getNodes:s,screenToFlowPosition:l}=Jf(),c=Qf(S=>S.isValidConnection),[d,u]=Rn(null),[p,f]=Rn(null),[y,g]=Rn(null),[m,h]=Rn(!1),x=Gr(null),b=Gr(t),T=Gr(o);Hr(()=>{b.current=t,T.current=o},[t,o]),Hr(()=>{x.current=d},[d]);let _=Or(S=>{var A;let P=x.current;if(!P)return;let L=l({x:S.clientX,y:S.clientY});f(L);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:P==="source"?M:b.current,target:P==="target"?M:T.current,sourceHandle:null,targetHandle:null},V=(A=c==null?void 0:c(k))!=null?A:!0;h(V)}else h(!1)},[s,l,c]),N=Or(S=>{var k;let P=x.current;if(!P)return;let L=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&&L.some(O=>O.id===V)){I=V;break}M=M.parentElement}if(I){let V={source:P==="source"?I:b.current,target:P==="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($=>$.map(D=>D.id===e?v(E({},D),{source:V.source,target:V.target,data:v(E({},D.data),{points:void 0})}):D))}}u(null),f(null),g(null),h(!1),document.removeEventListener("mouseup",N),document.removeEventListener("mousemove",_);let A=Me.get(n);A==null||A.clearReconnectingEdge()},[e,s,a,i,n,_,c]),w=Or((S,P)=>{if(r||P.button!==0)return;P.stopPropagation(),P.preventDefault(),u(S);let L=Me.get(n);L==null||L.setReconnectingEdge(e),document.addEventListener("mousemove",_),document.addEventListener("mouseup",N)},[r,e,n,_,N]);return Hr(()=>()=>{if(x.current){document.removeEventListener("mousemove",_),document.removeEventListener("mouseup",N);let S=Me.get(n);S==null||S.clearReconnectingEdge()}},[n,_,N]),{reconnectingHandle:d,cursorPosition:p,hoveredNodeId:y,isValidReconnection:m,handleReconnectStart:w}};import{Fragment as Fa,jsx as re,jsxs as qe}from"react/jsx-runtime";var Ne={type:"SEQUENCE_EDGE",reconnectable:!0,markerStart:{type:Ha.ArrowClosed},markerEnd:{type:Ha.Arrow},data:{label:""}},{TOLERANCE:za,MOVE_THRESHOLD:Vn,MIN_SEGMENT_LENGTH:im}=it,Wa=({id:e,source:t,target:o,data:n,selected:r})=>{var $;let{zoom:i}=rm(),{updateEdgeData:a}=nm(),{isMultipleSelection:s,mode:l,instanceId:c}=G(),[d,u]=Va(!1),[p,f]=Va(null),y=Oa(null),g=Oa(null),m=l==="readonly",{reconnectingHandle:h,cursorPosition:x,hoveredNodeId:b,isValidReconnection:T,handleReconnectStart:_}=Ra({edgeId:e,source:t,target:o,instanceId:c,isReadOnly:m}),N=Ga(t),w=Ga(o),{sx:S,sy:P,tx:L,ty:C,sourcePos:I,targetPos:M}=Br(()=>N&&w?Se(N,w):{sx:0,sy:0,tx:0,ty:0,sourcePos:Ba.Right,targetPos:Ba.Left},[N,w]);em(()=>{var z;if(!g.current){g.current={sx:S,sy:P,tx:L,ty:C,sourcePos:I,targetPos:M};return}let D=g.current;(Math.abs(S-D.sx)>Vn||Math.abs(P-D.sy)>Vn||Math.abs(L-D.tx)>Vn||Math.abs(C-D.ty)>Vn||D.sourcePos!==I||D.targetPos!==M)&&((z=n==null?void 0:n.points)!=null&&z.length)&&a(e,v(E({},n),{points:void 0})),g.current={sx:S,sy:P,tx:L,ty:C,sourcePos:I,targetPos:M}},[S,P,L,C,I,M,n,e,a]);let A=Br(()=>{var D;if((D=n==null?void 0:n.points)!=null&&D.length&&N&&w){let H=n.points[0],z=n.points[n.points.length-1],Y=Se(N,{internals:{positionAbsolute:H},measured:{width:1,height:1}}),q=Se({internals:{positionAbsolute:z},measured:{width:1,height:1}},w);return Vr(Y.sx,Y.sy,q.tx,q.ty,Y.sourcePos,q.targetPos,n.points)}return Vr(S,P,L,C,I,M,n==null?void 0:n.points)},[S,P,L,C,I,M,n==null?void 0:n.points,N,w]),k=Br(()=>{if(A.length<2)return Dn({x:S,y:P},{x:L,y:C});let D=0;for(let W=0;W<A.length-1;W++)D+=kn(A[W],A[W+1]);let H=D/2,z=0;for(let W=0;W<A.length-1;W++){let Y=kn(A[W],A[W+1]);if(z+Y>=H){let Q=(H-z)/Y,q=A[W],ae=A[W+1];return{x:q.x+(ae.x-q.x)*Q,y:q.y+(ae.y-q.y)*Q}}z+=Y}return Dn({x:S,y:P},{x:L,y:C})},[A,S,P,L,C]),V=jf((D,H)=>{if(l!=="edit"||H.button!==0)return;H.stopPropagation(),H.preventDefault();let z=A[D],W=A[D+1],Y=Rr(z,W,"y"),Q=Y?z.y:z.x;f(D);let q=Qe=>{let Ee=Q+(Y?Qe.clientY-H.clientY:Qe.clientX-H.clientX)/i;y.current=Y?{x:(z.x+W.x)/2,y:Ee}:{x:Ee,y:(z.y+W.y)/2};let Ut=A.map((De,mt)=>mt===0||mt===A.length-1?De:(Y?Math.abs(De.y-Q)<za:Math.abs(De.x-Q)<za)?Y?v(E({},De),{y:Ee}):v(E({},De),{x:Ee}):De);a(e,v(E({},n),{points:Ut.slice(1,-1)}))},ae=()=>{f(null),y.current=null,document.removeEventListener("mousemove",q),document.removeEventListener("mouseup",ae)};document.addEventListener("mousemove",q),document.addEventListener("mouseup",ae)},[l,A,i,n,e,a]);if(!N||!w)return null;let O=Da(A),B=r||N.selected||w.selected;return qe(Fa,{children:[qe("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:[re(tm,{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)})}),h&&x&&re("line",{x1:h==="source"?A[0].x:A[A.length-1].x,y1:h==="source"?A[0].y:A[A.length-1].y,x2:x.x,y2:x.y,stroke:b?T?"#10b981":"#ef4444":"#3b82f6",strokeWidth:3,strokeDasharray:"8 4",opacity:.6,className:"pointer-events-none"}),r&&!s&&!m&&re("g",{children:A.slice(0,-1).map((D,H)=>{let z=A[H+1];if(H===0||H===A.length-2||kn(D,z)<im)return null;let W=Rr(D,z,"y"),Y=p===H,Q=Y&&y.current?y.current:Dn(D,z);return qe("g",{children:[re("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)}),re("circle",{cx:Q.x,cy:Q.y,r:4/i,fill:Y?"#3b82f6":"#fff",stroke:"#3b82f6",strokeWidth:2/i,className:"pointer-events-none"}),re("circle",{cx:Q.x,cy:Q.y,r:6/i,fill:"none",stroke:"#3b82f6",strokeWidth:1/i,opacity:Y?.6:.3,className:"pointer-events-none"})]},H)})})]}),qe(om,{children:[qe("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&&re(wt,{edgeId:e,edgeType:"SEQUENCE_EDGE",sourceNode:N,targetNode:w,style:{transform:`scale(${1/i})`}}),(d||(($=n==null?void 0:n.label)==null?void 0:$.trim()))&&re(ne,{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&&qe(Fa,{children:[re("div",{className:"absolute z-[1000] pointer-events-none",style:{transform:`translate(-50%, -50%) translate(${A[0].x}px, ${A[0].y}px)`},children:qe("svg",{width:12/i,height:12/i,style:{overflow:"visible",position:"absolute",left:"50%",top:"50%",transform:"translate(-50%, -50%)"},children:[re("circle",{cx:6/i,cy:6/i,r:4/i,fill:h==="source"?"#3b82f6":"#fff",stroke:"#3b82f6",strokeWidth:2/i,className:"pointer-events-none"}),re("circle",{cx:6/i,cy:6/i,r:6/i,fill:"none",stroke:"#3b82f6",strokeWidth:1/i,opacity:h==="source"?.6:.3,className:"pointer-events-none"}),re("circle",{cx:6/i,cy:6/i,r:8/i,fill:"transparent",className:R("pointer-events-auto",{"cursor-move":!h||h!=="source","cursor-not-allowed":h==="source"&&b&&!T,"cursor-grabbing":h==="source"&&(!b||T)}),onMouseDown:D=>_("source",D.nativeEvent)})]})}),re("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:qe("svg",{width:12/i,height:12/i,style:{overflow:"visible",position:"absolute",left:"50%",top:"50%",transform:"translate(-50%, -50%)"},children:[re("circle",{cx:6/i,cy:6/i,r:4/i,fill:h==="target"?"#3b82f6":"#fff",stroke:"#3b82f6",strokeWidth:2/i,className:"pointer-events-none"}),re("circle",{cx:6/i,cy:6/i,r:6/i,fill:"none",stroke:"#3b82f6",strokeWidth:1/i,opacity:h==="target"?.6:.3,className:"pointer-events-none"}),re("circle",{cx:6/i,cy:6/i,r:8/i,fill:"transparent",className:R("pointer-events-auto",{"cursor-move":!h||h!=="target","cursor-not-allowed":h==="target"&&b&&!T,"cursor-grabbing":h==="target"&&(!b||T)}),onMouseDown:D=>_("target",D.nativeEvent)})]})})]})]})]})};import{useDebouncedCallback as nh}from"use-debounce";import{useReactFlow as oh}from"@xyflow/react";import{useCallback as nc}from"react";var yo=(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))(yo||{});import{xml2json as sm,json2xml as am}from"xml-js";var Ya={compact:!0,spaces:4},lm=e=>e.replaceAll(`
2
+ `,"&#xA;");function On(e,t=Ya){if(e)return JSON.parse(sm(e,v(E({},t),{attributeValueFn:lm})))}function Ua(e,t=Ya){return e?am(e,t):""}var cm={MIN_WIDTH:36,MIN_HEIGHT:36},dm={MIN_WIDTH:36,MIN_HEIGHT:36},um={MIN_WIDTH:56,MIN_HEIGHT:56},Hn={MIN_WIDTH:176,MIN_HEIGHT:96},Gn={HEADER_WIDTH:40,MIN_WIDTH:840,MIN_HEIGHT:256},K={HEADER_WIDTH:40,MIN_WIDTH:800,MIN_HEIGHT:256},Bn={MIN_WIDTH:176,MIN_HEIGHT:64},pm={MIN_WIDTH:128,MIN_HEIGHT:64},U={START_EVENT:cm,END_EVENT:dm,GATEWAY:um,TASK:Hn,LANE:K,ANNOTATION:Bn,UNSUPPORTED:pm};var $a={"attribute-loop":"LOOP"},Xa={"task-script":"SCRIPT","subprocess-collapsed":"SUBPROCESS"},Ka={"gateway-exclusive":"EXCLUSIVE","gateway-parallel":"PARALLEL","gateway-complex":"COMPLEX"},qa={SCRIPT:"task-script",SUBPROCESS:"subprocess-collapsed"},Za={EXCLUSIVE:"gateway-exclusive",PARALLEL:"gateway-parallel",COMPLEX:"gateway-complex"};var At=(e,t,o)=>{let n=e._attributes.width||0,r=e._attributes.height||0,i=ze(Number(n),t),a=ze(Number(r),o);return{width:i,height:a,measured:{width:i,height:a}}},Ct=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},mm=e=>{let{mxGeometry:t}=e,o=Ct(e),n=At(t,U.START_EVENT.MIN_WIDTH,U.START_EVENT.MIN_HEIGHT);return v(E(E({},o),n),{type:"START_EVENT"})},gm=e=>{let{mxGeometry:t}=e,o=Ct(e),n=At(t,U.END_EVENT.MIN_WIDTH,U.END_EVENT.MIN_HEIGHT);return v(E(E({},o),n),{type:"END_EVENT"})},zr=(e,t)=>{let{_attributes:o,mxGeometry:n}=e,r=Ct(e),i=At(n,U.TASK.MIN_WIDTH,U.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=$a[l];c&&(r.data.attribute=c)}let s=Xa[o.style];return s&&(r.data.variant=s),v(E(E({},r),i),{type:"TASK"})},Fr=e=>{let{_attributes:t,mxGeometry:o}=e,{style:n}=t,r=Ct(e),i=At(o,U.GATEWAY.MIN_WIDTH,U.GATEWAY.MIN_HEIGHT);return r.data.variant=Ka[n],v(E(E({},r),i),{type:"GATEWAY"})},hm=e=>{let{mxGeometry:t}=e,o=Ct(e),n=At(t,U.ANNOTATION.MIN_WIDTH,U.ANNOTATION.MIN_HEIGHT);return v(E(E({},o),n),{type:"ANNOTATION"})},ym=e=>{let{mxGeometry:t}=e,o=Ct(e),n=At(t,U.LANE.MIN_WIDTH,U.LANE.MIN_HEIGHT);return v(E(E({},o),n),{type:"LANE"})},Ja={task:zr,"task-script":zr,"subprocess-collapsed":zr,"start-event":mm,"end-event-terminate":gm,"gateway-parallel":Fr,"gateway-exclusive":Fr,"gateway-complex":Fr,annotation:hm,lane:ym},Qa=e=>{var d;let{_attributes:t,mxGeometry:o}=e,{id:n,source:r,target:i,value:a,style:s}=t,l=(d=o==null?void 0:o.Array)==null?void 0:d.map(u=>({x:Number(u._attributes.x),y:Number(u._attributes.y)})),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({},It),c):E(E({},Ne),c)},ja=(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}},St=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}}}},xm=e=>{let{variant:t}=e.data,o=St(e);return v(E({},o),{_attributes:v(E({},o._attributes),{style:qa[t]||"task"})})},Em=e=>{let t=St(e);return v(E({},t),{_attributes:v(E({},t._attributes),{style:"start-event"})})},bm=e=>{let t=St(e);return v(E({},t),{_attributes:v(E({},t._attributes),{style:"end-event-terminate"})})},_m=e=>{let{variant:t}=e.data,o=St(e);return v(E({},o),{_attributes:v(E({},o._attributes),{style:Za[t]})})},Tm=e=>{let t=St(e);return v(E({},t),{_attributes:v(E({},t._attributes),{style:"lane"})})},vm=e=>{let t=St(e);return v(E({},t),{_attributes:v(E({},t._attributes),{style:"annotation"})})},el={TASK:xm,START_EVENT:Em,END_EVENT:bm,GATEWAY:_m,ANNOTATION:vm,LANE:Tm},tl=(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 rl from"@dagrejs/dagre";import{getNodesBounds as Am}from"@xyflow/react";import{orderBy as Cm}from"lodash";import{orderBy as Nm}from"lodash";var He=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}},Ge=e=>Nm(e,[o=>{let n=o.type==="LANE";return n&&!o.parentId?0:n?1:2}],["asc"]),ol=(e,t)=>{let{x:o,y:n}=He(e),{x:r,y:i}=He(t);return{x:o-r,y:n-i}};var Mt=({parentId:e,nodes:t,includeTypes:o=[...Object.values(F)],excludeTypes:n=[]})=>t.some(r=>r.parentId===e&&(!o.length||o.includes(r.type))&&!n.includes(r.type)),wm=(e,t)=>{let{x:o,y:n}=He(e),{x:r,y:i}=He(t),a=o-r,s=n-i;return Math.sqrt(a*a+s*s)},Im=(e,t)=>{let{x:o,y:n,w:r,h:i}=He(e),{x:a,y:s,w:l,h:c}=He(t);return o<a+l&&a<o+r&&n<s+c&&s<n+i},xo=(e,t)=>{let o=null,n=1/0;for(let r of t)if(r.id!==e.id&&Im(e,r)){let i=wm(e,r);i<n&&(n=i,o=r)}return o},nl=(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 il=(e=[],t=[],o="LR")=>{let n=new rl.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)),rl.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}},Eo=e=>{let t=e.filter(n=>n.type==="LANE"&&!n.parentId),o=[...e];return t.forEach(n=>{o=st(n.id,o)}),o},st=(e,t)=>{var f,y;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=Cm(r,["position.y"]),a=Math.max((y=(f=n.measured)==null?void 0:f.width)!=null?y:0,Gn.MIN_WIDTH),s=nl(e,i)||K.MIN_WIDTH,l=Math.max(a,s),c=a-K.HEADER_WIDTH>=s,d=0,u=0;i.forEach(g=>{var m,h,x,b;o=o.map(T=>T.id===g.id?v(E({},T),{width:c?l-K.HEADER_WIDTH:l,measured:v(E({},T.measured),{width:c?l-K.HEADER_WIDTH:l}),position:{x:K.HEADER_WIDTH,y:d}}):T),d+=(h=(m=g.measured)==null?void 0:m.height)!=null?h:0,u+=(b=(x=g.measured)==null?void 0:x.height)!=null?b:0}),o=o.map(g=>g.id===e?v(E({},g),{height:u,width:c?l:l+K.HEADER_WIDTH,measured:v(E({},g.measured),{height:u,width:c?l:l+K.HEADER_WIDTH})}):g);let p=o.find(g=>g.id===e);return p!=null&&p.parentId&&(o=st(p.parentId,o)),o},sl=(e,t,o)=>{if(e.type==="LANE")return o;let n=fe(t),r=fe(e);return r.y<n.y&&(e.position.y=0),r.x<n.x+K.HEADER_WIDTH&&(e.position.x=K.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},al=()=>{let e=document.querySelector(".react-flow__viewport");return e||(console.error("Flow element (.react-flow__viewport) not found."),null)},Sm=50,ll=(e,t=Sm)=>{let o=Am(e);return{x:o.x-t,y:o.y-t,width:o.width+t*2,height:o.height+t*2}};var bo=1,cl=()=>`<mxGraphModel>
3
3
  <root version="1.1">
4
4
  <mxCell id="0" />
5
5
  <mxCell id="1" parent="0" />
@@ -32,9 +32,9 @@ var vd=Object.defineProperty,Nd=Object.defineProperties;var wd=Object.getOwnProp
32
32
  <mxGeometry as="geometry" relative="1" />
33
33
  </mxCell>
34
34
  </root>
35
- </mxGraphModel>`,$r=(e,t)=>{if(!e.length&&!t.length)return eh;let o=[...e.map(r=>r.id),...t.map(r=>r.id)];return Math.max(...o.map(r=>Number(r)))};var xe=()=>{let{getEdges:e,getNodes:t}=th();return{getLastId:()=>$r(t(),e()),getNextId:()=>{let n=t(),r=e();return $r(n,r)+1}}};var zt=()=>{let{getNodes:e,getEdges:t,setNodes:o,setEdges:n,fitView:r}=oh(),{getLastId:i}=xe(),a=oc(async(l="")=>{let{nodes:c,edges:d}=await dl(l);o(c),n(d),r({padding:Ht,minZoom:Gt,maxZoom:Bt})},[o,n,r]),s=oc((l,c)=>{let d=l||e()||[],u=c||t()||[],p=i();return cl(d,u,p)},[e,t,i]);return{importFromMxGraph:a,exportToMxGraph:s}};import{useCallback as nc}from"react";var rh=500,Ft=()=>{let{isInitialized:e,onElementChanges:t}=G(),{exportToMxGraph:o}=zt(),n=nh(()=>{if(!e)return;let a=o();t==null||t(a)},rh),r=nc(a=>{a.every(c=>c.type==="select")||a.some(c=>c.type==="position"&&c.dragging)||n()},[n]),i=nc(a=>{a.some(l=>l.type==="select")||n()},[n]);return{emitElementChanges:n,handleNodeChanges:r,handleEdgeChanges:i}};var rc=({setEdges:e})=>{let{getNode:t,getEdges:o,getNodes:n}=sh(),{emitElementChanges:r}=Ft(),i=ah(null),{getNextId:a}=xe(),s=dt(y=>{var E;let g=t(y.source),m=t(y.target);if(!g||!m)return!1;let h={sourceNodeId:g.id,targetNodeId:m.id,sourceNodeType:g.type,targetNodeType:m.type,nodes:n(),edges:o(),reconnectingEdgeId:(E=i.current)!=null?E:void 0};return Lr(h).isValid},[t,o,n]),l=dt(y=>{let g=a(),m=t(y.target),h=(m==null?void 0:m.type)==="ANNOTATION"?It:Ne,x=v(b(b({},y),h),{id:String(g)});e(E=>E.concat(x)),r()},[t,a,e,r]),c=dt((y,g)=>{i.current=g.id},[]),d=dt(()=>{i.current=null},[]),u=dt((y,g)=>{let m=t(g.source),h=t(g.target);if(!m||!h){i.current=null;return}let x={sourceNodeId:m.id,targetNodeId:h.id,sourceNodeType:m.type,targetNodeType:h.type,nodes:n(),edges:o(),reconnectingEdgeId:y.id};if(!Lr(x).isValid){i.current=null;return}e(T=>ih(y,g,T).map(N=>N.id===y.id?v(b({},N),{data:v(b({},N.data),{points:void 0})}):N)),i.current=null,r()},[t,n,o,e,r]),p=dt(y=>{i.current=y},[]),f=dt(()=>{i.current=null},[]);return{isValidConnection:s,onConnect:l,onReconnect:u,onReconnectStart:c,onReconnectEnd:d,setReconnectingEdge:p,clearReconnectingEdge:f}};import{useReactFlow as lh}from"@xyflow/react";import{useTranslation as ch}from"lecom-ui";import{useCallback as No,useRef as fc,useState as mc}from"react";var _o=(e=[])=>e.filter(t=>t.type==="START_EVENT"),ut=(e=[])=>e.filter(t=>t.type==="END_EVENT"),Ze=(e=[])=>e.filter(t=>t.type==="TASK")||[],ic=(e=[])=>e.filter(t=>{var o;return t.type==="TASK"&&((o=t.properties)==null?void 0:o.variant)==="SCRIPT"}),sc=(e=[])=>e.filter(t=>{var o;return t.type==="TASK"&&((o=t.properties)==null?void 0:o.variant)==="SUBPROCESS"}),Yn=(e=[])=>e.filter(t=>t.type==="GATEWAY"),ac=(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),To=(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"},cc=(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},dc=e=>e?/\w/g.test(e.trim()):!1,X=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:[]}},Pe=(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)}},uc=(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 vo=[{id:"start_event_not_found",validate:e=>{let t=_o(e.nodes);return X({isValid:t.length>=1})}},{id:"end_event_not_found",validate:e=>{let t=ut(e.nodes);return X({isValid:t.length>=1})}},{id:"multiple_start_event_not_allowed",validate:e=>{let t=_o(e.nodes),o=t.length===1;if(t.length===0)return X({isValid:!0});if(!o)return X({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 X({isValid:!1,nodeIds:[...new Set(i)]})}return X({isValid:!0})}},{id:"task_flows_limit_exceeds",validate:e=>{let t=Ze(e.nodes),o=Pe(t,n=>me(n.id,e.edges).length<=2);return X({isValid:o.isValid,nodeIds:o.invalidIds})}},{id:"task_label_empty",highlightRelatedEdges:!1,validate:e=>{let t=Ze(e.nodes),o=Pe(t,n=>!!n.label&&n.label.trim()!=="");return X({isValid:o.isValid,nodeIds:o.invalidIds})}},{id:"task_label_length",highlightRelatedEdges:!1,validate:e=>{let o=Ze(e.nodes),n=Pe(o,r=>!r.label||r.label.length<=60);return X({isValid:n.isValid,nodeIds:n.invalidIds})}},{id:"duplicate_task_name",highlightRelatedEdges:!1,validate:e=>{let t=Ze(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 X({isValid:n.length===0,nodeIds:n})}},{id:"nested_gateway",validate:e=>{let t=Yn(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 X({isValid:o.length===0,nodeIds:o.length>0?[...new Set(o)]:[],edgeIds:n})}},{id:"events_nested",validate:e=>{let t=[..._o(e.nodes),...ut(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 X({isValid:o.length===0,nodeIds:o.length>0?[...new Set(o)]:[],edgeIds:n})}},{id:"flows_on_end_tasks_not_allowed",validate:e=>{let t=ut(e.nodes),o=[],n=[];for(let r of t){let i=To(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 X({isValid:o.length===0,nodeIds:o,edgeIds:n})}},{id:"conditions_flows_limit_exceeds",validate:e=>{let t=ac(e.nodes),o=Pe(t,r=>me(r.id,e.edges).length<=2),n=o.invalidIds.flatMap(r=>me(r,e.edges).map(i=>i.id));return X({isValid:o.isValid,nodeIds:o.invalidIds,edgeIds:n})}},{id:"activity_name_invalid",validate:e=>{let t=Ze(e.nodes),o=Pe(t,n=>!n.label||dc(n.label));return X({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 X({isValid:!0});let t=ut(e.nodes)[0];if(!t)return X({isValid:!0});let o=To(t.id,e.edges);if(!o.length)return X({isValid:!0});let r=Ze(e.nodes).filter(l=>o.some(c=>c.source===l.id)),i=Pe(r,l=>!lc(l.id,e));return X({isValid:i.isValid,nodeIds:i.isValid?[]:[t.id,...i.invalidIds]})}},{id:"concurrent_initial_and_final_event",validate:e=>{let t=Ze(e.nodes),o=ut(e.nodes)[0];if(!o)return X({isValid:!0});let n=t.filter(l=>{let c=To(l.id,e.edges),d=me(l.id,e.edges),u=c.some(f=>{var y;return((y=e.nodes.find(g=>g.id===f.source))==null?void 0:y.type)==="START_EVENT"}),p=d.some(f=>{var y;return((y=e.nodes.find(g=>g.id===f.target))==null?void 0:y.type)==="END_EVENT"});return u&&p}),r=To(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 X(s)}},{id:"gateway_flow_to_event",validate:e=>{let t=Yn(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 X({isValid:o.length===0,nodeIds:o.length>0?[...new Set(o)]:[],edgeIds:n})}},{id:"gateway_missing_output_streams",validate:e=>{let t=Yn(e.nodes),o=Pe(t,n=>me(n.id,e.edges).length>=1);return X({isValid:o.isValid,nodeIds:o.invalidIds})}},{id:"event_to_condition",validate:e=>{let t=[..._o(e.nodes),...ut(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 X({isValid:o.length===0,nodeIds:o.length>0?[...new Set(o)]:[],edgeIds:n})}},{id:"script_in_final_activity",validate:e=>{let t=ic(e.nodes),o=Pe(t,n=>!cc(n.id,e));return X({isValid:o.isValid,nodeIds:o.invalidIds})}},{id:"subprocess_referenced_not_configured",validate:e=>{let t=sc(e.nodes),o=Pe(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 X({isValid:o.isValid,nodeIds:o.invalidIds})}}];var pc=e=>{e=e||{nodes:[],edges:[]},e.nodes=e.nodes||[],e.edges=e.edges||[];let t=[];for(let n of vo){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 gc=()=>{let{t:e}=ch(),{setNodes:t,setEdges:o,getNodes:n,getEdges:r}=lh(),[i,a]=mc(null),[s,l]=mc(!1),c=fc(!1),d=fc(!1),u=No(m=>{let h=uc(m.nodes,m.edges),x=pc(h),E=x.errors.map(T=>v(b({},T),{message:e(`validation.errors.${T.id}`)}));return s||l(!0),{isValid:x.isValid,errors:E}},[s,e]),p=No((m,h=!0)=>{if(h&&a(m),!m)return;c.current=!0,d.current=!0;let x=[],E=[];m.errors.forEach(I=>{I.nodeIds&&I.nodeIds.length>0&&I.nodeIds.forEach(M=>x.push(M)),I.edgeIds&&I.edgeIds.length>0&&I.edgeIds.forEach(M=>E.push(M))});let T=[...new Set(x)];t(I=>I.map(M=>v(b({},M),{data:v(b({},M.data),{hasError:!1})}))),o(I=>I.map(M=>v(b({},M),{data:v(b({},M.data),{hasError:!1})})));let _=n(),N=r(),w=new Set(T),S=new Set;m.errors.forEach(I=>{var k,V;let M=vo.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=>{N.forEach(B=>{(B.source===O||B.target===O)&&S.add(B.id)})}))});let P=new Set,L=new Set,C=new Set;_.forEach(I=>{I.type==="START_EVENT"?P.add(I.id):I.type==="END_EVENT"&&L.add(I.id)}),N.forEach(I=>{P.has(I.source)&&C.add(I.target),L.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=vo.find(O=>O.id===k))==null?void 0:A.highlightRelatedEdges)!==!1&&N.forEach(O=>{O.source===I&&L.has(O.target)&&(w.add(O.target),S.add(O.id)),O.target===I&&P.has(O.source)&&(w.add(O.source),S.add(O.id))})}}),w.size>0&&t(I=>I.map(M=>v(b({},M),{data:v(b({},M.data),{hasError:w.has(M.id)})}))),S.size>0&&o(I=>I.map(M=>v(b({},M),{data:v(b({},M.data),{hasError:S.has(M.id)})}))),setTimeout(()=>{c.current=!1},0)},[r,n,o,t]),f=No(()=>{a(null),l(!1),d.current=!1,t(m=>m.map(h=>v(b({},h),{data:v(b({},h.data),{hasError:!1})}))),o(m=>m.map(h=>v(b({},h),{data:v(b({},h.data),{hasError:!1})})))},[o,t]),y=No(()=>{d.current&&(a(null),c.current=!0,d.current=!1,t(m=>m.map(h=>v(b({},h),{data:v(b({},h.data),{hasError:!1})}))),o(m=>m.map(h=>v(b({},h),{data:v(b({},h.data),{hasError:!1})}))),setTimeout(()=>{c.current=!1},0))},[o,t]),g=No(()=>c.current,[]);return{validationResult:i,validateDiagram:u,handleValidationComplete:p,clearValidation:f,dismissValidationPanel:y,isAutoValidationEnabled:s,getIsClearingValidation:g}};import{useReactFlow as dh}from"@xyflow/react";import{useTranslation as uh}from"lecom-ui";import{useEffect as ph}from"react";var fh=15,hc="bpmn:selection",mh=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},yc=e=>{if(!mh(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},xc=({offset:e=fh}={})=>{let{t}=uh(),{getNodes:o,setNodes:n,getEdges:r,setEdges:i}=dh(),{getNextId:a}=xe();ph(()=>{let s=c=>{var m,h;if(!yc(c))return;let d=o(),u=r(),p=d.filter(x=>x.selected);if(!p.length)return;c.preventDefault(),c.stopPropagation();let f=u.filter(x=>p.some(E=>E.id===x.source)&&p.some(E=>E.id===x.target)),g=JSON.stringify({nodes:p,edges:f});(m=c.clipboardData)==null||m.setData(hc,g),(h=c.clipboardData)==null||h.setData("text/plain",`BPMN Selection: ${p.length} nodes`)},l=c=>{var _,N;if(!yc(c))return;let d=(_=c.clipboardData)==null?void 0:_.getData(hc);if(!d)return;c.preventDefault(),c.stopPropagation();let u;try{u=JSON.parse(d)}catch(w){return}if(!((N=u.nodes)!=null&&N.length))return;let p=new Map,f=o(),y=[],g=f.some(w=>w.type==="START_EVENT"),m=u.nodes.filter(w=>w.type==="START_EVENT"),h=u.nodes;if(g&&m.length>0&&(h=u.nodes.filter(w=>w.type!=="START_EVENT"),h.length===0))return;let x=a(),E=h.map(w=>{var L;let S=String(x++);p.set(w.id,S);let P=v(b({},w),{id:S,selected:!0,position:{x:w.position.x+e,y:w.position.y+e}});if(w.type==="TASK"){let C=(L=w.data)==null?void 0:L.label,I=Ot(C||t("bpmn.task.label.prefix"),[...f,...y]);P.data=v(b({},w.data),{label:I})}return y.push(P),P}),T=u.edges.map(w=>v(b({},w),{id:String(x++),selected:!0,source:p.get(w.source)||w.source,target:p.get(w.target)||w.target}));n(w=>[...w.map(S=>v(b({},S),{selected:!1})),...E]),i(w=>[...w.map(S=>v(b({},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 gh,useStoreApi as hh}from"@xyflow/react";import{useTranslation as yh}from"lecom-ui";import{useState as xh}from"react";var Ec=({nodes:e,setNodes:t,setEdges:o})=>{let n=hh(),{draggableNode:r,setDraggableNode:i}=kt(),{t:a}=yh(),{getInternalNode:s,screenToFlowPosition:l}=gh(),{getNextId:c}=xe(),{setIsDragging:d}=G(),{rebuildIndex:u,forceRebuildIndex:p}=vt(),[f,y]=xh(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=>v(b({},k),{className:k.id===C?M:""})))},m=()=>{let{nodeLookup:C}=n.getState();return Array.from(C.values())},h=C=>{let I=s(C.id),M=m();if(C.type==="LANE"){if(Mt({parentId:C.id,nodes:e,includeTypes:["LANE"]})){g();return}let $=M.filter(z=>z.id!==C.id&&z.type==="LANE"&&!z.parentId),D=xo(I,$);if(!D){g();return}if(Mt({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=xo(I,k);if(!V){g();return}if(Mt({parentId:V.id,nodes:e,includeTypes:["LANE"]})){g();return}g(V.id)},x=C=>C.map(I=>v(b({},I),{className:void 0})),E=C=>C.some(M=>M.dragging)?C.map(M=>M.dragging?v(b({},M),{dragging:!1}):M):C,T=C=>{C.preventDefault(),C.dataTransfer.dropEffect="move"},_=(C,I)=>{C.preventDefault(),h(I)},N=(C,I,M)=>{var B,$;let A=[...M];if(C.parentId===I.id)return A=sl(C,I,A),A=Eo(A),x(A);if(C.type==="LANE"){if(Mt({parentId:I.id,nodes:A,excludeTypes:["LANE"]})){let Y=fe(I),Q=50,q=50;return A.map(ae=>{var Qe,Ee;return ae.id===C.id?v(b({},ae),{position:{x:(Qe=f==null?void 0:f.x)!=null?Qe:Y.x+Q,y:(Ee=f==null?void 0:f.y)!=null?Ee:Y.y2+q}}):ae})}let z=A.filter(Y=>Y.parentId===I.id).reduce((Y,Q)=>{var q,ae;return Y+((ae=(q=Q.measured)==null?void 0:q.height)!=null?ae:0)},0),W={x:K.HEADER_WIDTH,y:z};return A=A.map(Y=>Y.id===C.id?v(b({},Y),{parentId:I.id,position:W,className:void 0}):v(b({},Y),{className:void 0})),A=st(I.id,A),A}if(Mt({parentId:I.id,nodes:A,includeTypes:["LANE"]})){let D;if(C.parentId){let H=s(C.parentId),{x:z,y:W}=Oe(H);D={x:z+((B=C.position.x)!=null?B:0),y:W+(($=C.position.y)!=null?$:0)}}return A=A.map(H=>H.id===C.id?v(b({},H),{position:D!=null?D:H.position,parentId:void 0,className:void 0}):v(b({},H),{className:void 0})),A}let O=ol(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),v(b({},D),{parentId:I.id,position:O,className:void 0})}return v(b({},D),{className:void 0})}),A=Eo(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"?zn(e,a("bpmn.task.label.prefix")):"",variant:r.variant,attribute:r.attribute},selected:!0},V=v(b({},k),{internals:{positionAbsolute:I}}),O=m(),B=r.type==="LANE",$=O.filter(W=>B?W.type==="LANE"&&!W.parentId:W.type==="LANE"),D=xo(V,$),H=[...e.map(W=>v(b({},W),{selected:!1})),k];D&&(H=N(V,D,H)),H=He(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(b(b({},W),It)));return}o(Y=>Y.concat(b(b({},W),Ne)))}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",$=V.filter(H=>H.id!==k.id&&(B?H.type==="LANE"&&!H.parentId:H.type==="LANE")),D=xo(O,$);if(D){A=N(O,D,A);return}k.parentId&&(A=L(k,A))}),A=E(A),A=He(A),A=x(A),t(A),u(A),y(null)},P=(C,I)=>{y({x:I.position.x,y:I.position.y})},L=(C,I)=>{var O,B;let M=s(C.parentId),{x:A,y:k}=Oe(M),V={x:A+((O=C.position.x)!=null?O:0),y:k+((B=C.position.y)!=null?B:0)};return I=I.map($=>$.id===C.id?v(b({},$),{position:V,parentId:void 0}):$),I=st(C.parentId,I),I};return{onDragOver:T,onDrop:w,onNodeDrag:_,onNodeDragStart:P,onNodeDragStop:S}};import{useReactFlow as Eh}from"@xyflow/react";import{useTranslation as bh}from"lecom-ui";import{useEffect as _h}from"react";var Th=30,vh=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},Nh=e=>!vh(e.target),bc=({offset:e=Th}={})=>{let{t}=bh(),{getNodes:o,setNodes:n,getEdges:r,setEdges:i}=Eh(),{getNextId:a}=xe();_h(()=>{let s=l=>{if(l.ctrlKey&&l.key.toLowerCase()==="d"&&Nh(l)){l.preventDefault(),l.stopPropagation();let c=o(),d=r(),u=c.filter(_=>_.selected);if(!u.length)return;let p=new Map,f=[],y=c.some(_=>_.type==="START_EVENT"),g=u.filter(_=>_.type==="START_EVENT"),m=u;if(y&&g.length>0&&(m=u.filter(_=>_.type!=="START_EVENT"),m.length===0))return;let h=d.filter(_=>m.some(N=>N.id===_.source)&&m.some(N=>N.id===_.target)),x=a(),E=m.map(_=>{var S;let N=String(x++);p.set(_.id,N);let w=v(b({},_),{id:N,selected:!0,position:{x:_.position.x+e,y:_.position.y+e}});if(_.type==="TASK"){let P=(S=_.data)==null?void 0:S.label,L=Ot(P||t("bpmn.task.label.prefix"),[...c,...f]);w.data=v(b({},_.data),{label:L})}return f.push(w),w}),T=h.map(_=>v(b({},_),{id:String(x++),selected:!0,source:p.get(_.source)||_.source,target:p.get(_.target)||_.target}));n(_=>[..._.map(N=>v(b({},N),{selected:!1})),...E]),i(_=>[..._.map(N=>v(b({},N),{selected:!1})),...T])}};return document.addEventListener("keydown",s,!0),()=>{document.removeEventListener("keydown",s,!0)}},[o,n,r,i,a,e,t])};import{useReactFlow as Ih}from"@xyflow/react";var Tc={"start-event":"START_EVENT","end-event":"END_EVENT",task:"TASK","gateway-exclusive":"GATEWAY"},vc={"start-event":"","end-event":"",task:"","gateway-exclusive":"EXCLUSIVE"},_c=(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}},wh=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=_c(i[0],o),s=_c(i[1],o);a&&s&&n.push({sourceId:a.step,targetId:s.step,label:a.edgeLabel||s.edgeLabel||""})}),{components:o,connections:n}},Nc=e=>{let{components:t,connections:o}=wh(e);return{nodes:t,edges:o}};var wc=()=>{let{setNodes:e,setEdges:t,fitView:o}=Ih(),{getNextId:n}=xe();return{importFromLia:i=>{let a=typeof i=="string"?i:i.diagramXml||"",{nodes:s,edges:l}=Nc(a),c=[],d=new Map,u=!1,p=n();for(let[m,h]of Object.entries(s)){let x=String(p++),E=Tc[h.type],T=vc[h.type];E==="START_EVENT"&&(u=!0),d.set(m,x);let _=U[E].MIN_WIDTH,N=U[E].MIN_HEIGHT;c.push({id:x,type:E,data:{label:h.label||"",variant:T,attribute:""},position:{x:0,y:0},width:_,height:N,measured:{width:_,height:N}})}let f=[];for(let m of l){let h=v(b({},Ne),{id:String(p++),source:d.get(m.sourceId)||m.sourceId,target:d.get(m.targetId)||m.targetId});f.push(h)}if(!u&&c.length>0){let m=String(p++),h={id:m,type:"START_EVENT",data:{label:"",variant:"",attribute:""},position:{x:0,y:0},width:U.START_EVENT.MIN_WIDTH,height:U.START_EVENT.MIN_HEIGHT,measured:{width:U.START_EVENT.MIN_WIDTH,height:U.START_EVENT.MIN_HEIGHT}};c.unshift(h);let x=c[1];if(x){let E=v(b({},Ne),{id:String(p++),source:m,target:x.id});f.unshift(E)}}let{nodes:y,edges:g}=il(c,f);e(y),t(g),o({padding:Ht,minZoom:Gt,maxZoom:Bt})}}};import{useEffect as Ah,useCallback as Ch}from"react";var Sh={origin:"*",debug:!1};function Ic(e,t=Sh){let{origin:o,debug:n}=t,r=Ch((i,a)=>{let s={event:i,data:[i,{event:i,data:a}]};window.parent.postMessage(s,o||"*")},[o]);return Ah(()=>{let i=a=>{let s=a.data;if(!(s!=null&&s.event)||!(s!=null&&s.data))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 Mh}from"@xyflow/react";import{useEffect as Ac}from"react";var Cc=()=>{let e=Mh(),{initialDiagram:t,setIsInitialized:o}=G(),{importFromMxGraph:n}=zt();Ac(()=>{t&&n(t)},[t,n,o]),Ac(()=>{if(!e)return;(async()=>{await Po(),o(!0)})()},[e,o])};import{useCallback as Sc}from"react";import{useReactFlow as Ph}from"@xyflow/react";function Mc(){let{setTaskStatuses:e,clearTaskStatuses:t,calculateFlowPath:o}=je(),{getEdges:n}=Ph(),r=Vo(),i=Sc(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=Sc(()=>{t(),setTimeout(()=>{r()},0)},[t,r]);return{handleTasksStatus:i,handleClearTaskStatus:a}}import{useReactFlow as Lh}from"@xyflow/react";import{useCallback as Wt,useState as Pc,useEffect as kh}from"react";import{useDebouncedCallback as Dh}from"use-debounce";var Lc=[{nodes:[],edges:[]}],Rh=500,kc=100,Dc=(e=Lc)=>{let{getNodes:t,getEdges:o,setNodes:n,setEdges:r}=Lh(),[i,a]=Pc(e),[s,l]=Pc(0),c=i[s],d=s>0,u=s<i.length-1,p=Wt(T=>{n(i[T].nodes),r(i[T].edges)},[i,n,r]),f=Wt(()=>{if(s>0){let T=s-1;l(T),p(T)}},[s,p]),y=Wt(()=>{if(s<i.length-1){let T=s+1;l(T),p(T)}},[i,s,p]),g=T=>{let N=[...i.slice(0,s+1),T],w=N.length>kc?N.slice(N.length-kc):N;a(w),l(w.length-1)},m=Dh(()=>{let T=t(),_=o(),N=T.map(P=>v(b({},P),{selected:!1,className:""})),w={nodes:He(N),edges:_};JSON.stringify(c)!==JSON.stringify(w)&&g(w)},Rh),h=Wt(T=>{if(T==="forceSave"){m();return}T.some(w=>w.type==="select")||T.some(w=>w.type==="position"&&w.dragging)||m()},[m]),x=Wt(T=>{a(T||Lc),l(0)},[]),E=Wt(()=>{a([]),l(0)},[]);return kh(()=>{let T=_=>{(_.ctrlKey||_.metaKey)&&(_.shiftKey&&_.key.toLowerCase()==="z"?(_.preventDefault(),y()):_.key.toLowerCase()==="z"&&(_.preventDefault(),f()))};return document.addEventListener("keydown",T),()=>{document.removeEventListener("keydown",T)}},[f,y]),{history:i,undo:f,redo:y,canUndo:d,canRedo:u,saveHistory:h,resetHistory:x,clearHistory:E}};var Rc=()=>{let[e,t,o]=Oh([]),[n,r,i]=Vh([]),[a,s]=Bh(null),{instanceId:l,setIsConnecting:c,setIsMultipleSelection:d}=G(),{updateHelperLines:u,HelperLines:p}=vt(),{undo:f,redo:y,canUndo:g,canRedo:m,saveHistory:h}=Dc(),{onNodeDrag:x,onDrop:E,onDragOver:T,onNodeDragStop:_,onNodeDragStart:N}=Ec({nodes:e,setNodes:t,setEdges:r}),{isValidConnection:w,onConnect:S,onReconnect:P,onReconnectStart:L,onReconnectEnd:C,setReconnectingEdge:I,clearReconnectingEdge:M}=rc({setEdges:r}),{validationResult:A,handleValidationComplete:k,clearValidation:V,dismissValidationPanel:O,validateDiagram:B,getIsClearingValidation:$}=gc(),{importFromLia:D}=wc(),{handleTasksStatus:H,handleClearTaskStatus:z}=Mc(),{clearPathEdges:W}=je(),Y=Vo(),{emitElementChanges:Q,handleNodeChanges:q,handleEdgeChanges:ae}=Ft();xc(),bc(),Cc();let Qe=Un(()=>{t([]),r([]),W(),setTimeout(()=>{Y()},0)},[t,r,W,Y]);Ic({LIA_CREATE_DIAGRAM:D,CLEAR_DIAGRAM:Qe,TASKS_STATUS:H,CLEAR_TASKS_STATUS:z});let{selectElements:Ee,clearSelection:Ut}=Xe(),{importFromMxGraph:ke,exportToMxGraph:mt}=zt(),{configureElement:ir,getConfigureElement:li}=Nn();Gh(()=>(Me.set(l,{importFromMxGraph:ke,exportToMxGraph:mt,selectElements:Ee,clearSelection:Ut,configureElement:ir,getConfigureElement:li,setReconnectingEdge:I,clearReconnectingEdge:M}),()=>{Me.delete(l)}),[l,ke,mt,Ee,Ut,ir,li,I,M]);let bd=Un(be=>{let $t=u(be,e);o($t),h(be),$()||O(),q(be)},[e,o,h,$,O,u,q]),_d=Un(be=>{i(be),h(be),$()||O(),ae(be)},[i,h,$,O,ae]);Hh({onChange:({nodes:be,edges:$t})=>{d(be.length+$t.length>1)}});let Td=Un(async({nodes:be,edges:$t})=>(s({nodes:be,edges:$t}),!1),[s]);return{nodes:e,setNodes:t,edges:n,setEdges:r,events:{isValidConnection:w,onConnect:S,onReconnect:P,onReconnectStart:L,onReconnectEnd:C,onDrop:E,onDragOver:T,onNodeDrag:x,onNodeDragStop:_,onNodeDragStart:N,onDropCapture:()=>{h("forceSave"),Q(),O()},onConnectStart:()=>{c(!0)},onConnectEnd:()=>{c(!1),O()},onBeforeDelete:Td,onNodesChange:bd,onEdgesChange:_d},ui:{pendingDelete:a,setPendingDelete:s,validationResult:A,handleCloseValidationPanel:V},controls:{undo:f,redo:y,canUndo:g,canRedo:m},components:{HelperLines:p},actions:{saveHistory:h,selectElements:Ee,clearSelection:Ut,exportToMxGraph:mt,validateDiagram:B,handleValidationComplete:k,setReconnectingEdge:I,clearReconnectingEdge:M}}};import{jsx as Vc}from"react/jsx-runtime";var Xr=({id:e,className:t})=>Vc("marker",{id:e,className:R("react-flow__arrowhead",t),viewBox:"0 0 10 10",refX:"9",refY:"5",markerWidth:"7",markerHeight:"7",orient:"auto",markerUnits:"userSpaceOnUse",fill:"currentColor",stroke:"currentColor",children:Vc("path",{d:"M 0 0 L 10 5 L 0 10 Z"})});import{jsx as Kr,jsxs as zh}from"react/jsx-runtime";var Oc=()=>Kr("svg",{style:{position:"absolute",top:0,left:0},children:zh("defs",{children:[Kr(Xr,{id:"sequence-edge-marker",className:"text-grey-400"}),Kr(Xr,{id:"sequence-edge-marker-highlighted",className:"text-blue-500"})]})});import{useKeyPress as ed,useReactFlow as P0}from"@xyflow/react";import{Button as Jn,Tooltip as Qn,TooltipContent as jn,TooltipTrigger as er,useTranslation as L0}from"lecom-ui";import{HandIcon as k0,ListCheckIcon as D0,MapIcon as R0,MousePointerIcon as V0}from"lucide-react";import{useCallback as Qr,useEffect as td}from"react";import{Tooltip as l0,TooltipContent as c0,TooltipTrigger as d0,useNotificationToast as u0,useTranslation as p0}from"lecom-ui";var wo=(x=>(x.START_EVENT="START_EVENT",x.END_EVENT="END_EVENT",x.TASK="TASK",x.SUBPROCESS="SUBPROCESS",x.GATEWAY="GATEWAY",x.LANE="LANE",x.ANNOTATION="ANNOTATION",x.CONNECTION="CONNECTION",x.INTERMEDIATE_EVENT="INTERMEDIATE_EVENT",x.ACTIVITY="ACTIVITY",x.PROCESS_INTERFACE="PROCESS_INTERFACE",x.WORKFLOW_INTERFACE="WORKFLOW_INTERFACE",x.VARIANT_ACTIVITY="VARIANT_ACTIVITY",x.AUTO_ACTIVITY="AUTO_ACTIVITY",x.DATA_STORE="DATA_STORE",x.DATA_OBJECT="DATA_OBJECT",x.DATA_OUTPUT="DATA_OUTPUT",x.DATA_INPUT="DATA_INPUT",x))(wo||{});import{useReactFlow as jh}from"@xyflow/react";import{useNotificationToast as e0,useTranslation as t0,Button as o0}from"lecom-ui";var Hc=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 Gc({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);$n(i,`${o}.csv`)}var $n=(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 Bc(e){return e==null?void 0:e.replaceAll("&#xA;"," ")}var W6={START_EVENT:"START_EVENT",END_EVENT:"END_EVENT",TASK:"TASK",GATEWAY:"GATEWAY",ANNOTATION:"ANNOTATION"},zc={script:"SCRIPT",subprocess:"SUBPROCESS"},Fc={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}}},Wh=e=>{let{subType:t,style:o}=e._attributes,n="imported";return["none"].includes(t)||(n="adapted"),e.mxGeometry._attributes.width=U.START_EVENT.MIN_WIDTH,e.mxGeometry._attributes.height=U.START_EVENT.MIN_HEIGHT,{node:pt({cell:e,type:"START_EVENT"}),status:n,originalType:o}},Yh=e=>{let{subType:t,style:o}=e==null?void 0:e._attributes,n="imported";return["none"].includes(t)||(n="adapted"),e.mxGeometry._attributes.width=U.END_EVENT.MIN_WIDTH,e.mxGeometry._attributes.height=U.END_EVENT.MIN_HEIGHT,{node:pt({cell:e,type:"END_EVENT"}),status:n,originalType:o}},Uh=e=>{let{subType:t,style:o}=e==null?void 0:e._attributes,n=zc[t],r="imported";return["script","none"].includes(t)||(r="adapted"),e.mxGeometry._attributes.width=ze(e.mxGeometry._attributes.width||0,U.TASK.MIN_WIDTH),e.mxGeometry._attributes.height=ze(e.mxGeometry._attributes.height||0,U.TASK.MIN_HEIGHT),{node:pt({cell:e,type:"TASK",variant:n}),status:r,originalType:o}},$h=e=>{let{style:t,subType:o}=e==null?void 0:e._attributes,n=Fc[o],r=["none","inclusive","event-based"],i="imported";return r.includes(o)&&(i="adapted"),e.mxGeometry._attributes.width=U.GATEWAY.MIN_WIDTH,e.mxGeometry._attributes.height=U.GATEWAY.MIN_HEIGHT,{node:pt({cell:e,type:"GATEWAY",variant:n}),status:i,originalType:t}},Xh=e=>{let{style:t}=e==null?void 0:e._attributes;return{node:pt({cell:e,type:"LANE"}),status:"imported",originalType:t}},Kh=e=>{let{style:t}=e==null?void 0:e._attributes;return e.mxGeometry._attributes.width=ze(e.mxGeometry._attributes.width||0,U.ANNOTATION.MIN_WIDTH),e.mxGeometry._attributes.height=ze(e.mxGeometry._attributes.height||0,U.ANNOTATION.MIN_HEIGHT),{node:pt({cell:e,type:"ANNOTATION"}),status:"imported",originalType:t}},Wc=e=>{let{style:t}=e==null?void 0:e._attributes;return e.mxGeometry._attributes.width=U.UNSUPPORTED.MIN_WIDTH,e.mxGeometry._attributes.height=U.UNSUPPORTED.MIN_HEIGHT,{node:pt({cell:e,type:"UNSUPPORTED"}),status:"unsupported",originalType:t}},Yc=(e,t)=>{let{id:o,source:n,target:r,value:i}=e._attributes;return v(b({},Ne),{id:o,source:t.get(n)||n,target:t.get(r)||r,data:{label:i||""}})},Uc={TASK:Uh,GATEWAY:$h,START_EVENT:Wh,END_EVENT:Yh,LANE:Xh,ANNOTATION:Kh};var qh=e=>{let t=new Map,o=Object.values(wo),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=Uc[s]||Wc,{node:c,status:d,originalType:u}=l(a);i.push(c),r.push({originalType:u,type:c.type,variant:c.data.variant,value:Bc(c.data.label),status:d})}return{nodes:i,governanceIdToNodeIdMap:t,summary:r}},Zh=(e,t)=>e.filter(r=>{var i;return(i=r._attributes)==null?void 0:i.edge}).map(r=>Yc(r,t)),Jh=e=>{let{mxGraphModel:t}=e,{nodes:o,governanceIdToNodeIdMap:n,summary:r}=qh(t.root.mxCell),i=Zh(t.root.mxCell,n);return{nodes:o,edges:i,summary:r}},Qh=async e=>{let t=await Hc(e),o=Vn(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}},$c=async e=>{try{let t=await Qh(e),{nodes:o,edges:n,summary:r}=Jh(t)||{};return{nodes:o,edges:n,summary:r}}catch(t){throw t}};import{jsx as n0}from"react/jsx-runtime";var Xc=()=>{let{t:e}=t0(),{toast:t}=e0(),{setNodes:o,setEdges:n,fitView:r}=jh(),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:n0(o0,{size:"small",variant:"ghost",onClick:()=>Gc({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 $c(s);if(o(p=>p.concat(l)),n(p=>p.concat(c)),r({padding:Ht,minZoom:Gt,maxZoom:Bt}),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 r0}from"lecom-ui";import{useRef as i0}from"react";import{Fragment as s0,jsx as Kc,jsxs as a0}from"react/jsx-runtime";var qc=s=>{var l=s,{children:e,accept:t="*",multiple:o=!1,disabled:n=!1,onClick:r,onFilesSelected:i}=l,a=Ae(l,["children","accept","multiple","disabled","onClick","onFilesSelected"]);let c=i0(null),d=p=>{let f=p.target.files;f!=null&&f.length&&i(f),c.current&&(c.current.value="")};return a0(s0,{children:[Kc(r0,v(b({onClick:p=>{var f;(f=c.current)==null||f.click(),r==null||r(p)}},a),{children:e})),Kc("input",{type:"file",ref:c,className:"sr-only",accept:t,multiple:o,disabled:n,onChange:d})]})};import{jsx as Xn,jsxs as f0}from"react/jsx-runtime";var Zc=({disabled:e=!1})=>{let{t}=p0(),{toast:o}=u0(),{importFromGovernance:n}=Xc(),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 f0(l0,{children:[Xn(d0,{asChild:!0,children:Xn(qc,{className:"[&>svg]:size-7 p-0",variant:"ghost",size:"small",color:"grey",iconButton:!0,accept:".mdr",disabled:e,onClick:r,onFilesSelected:i,children:Xn(Ei,{})})}),Xn(c0,{color:"black",children:t("editor.controls.actions.import_governance")})]})};import{jsx as m0}from"react/jsx-runtime";var qr=({shortcut:e})=>m0("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 _0,DropdownMenu as T0,DropdownMenuContent as v0,DropdownMenuItem as Jr,DropdownMenuTrigger as N0,Tooltip as Kn,TooltipContent as qn,TooltipTrigger as Zn,useTranslation as w0}from"lecom-ui";import{FileCodeIcon as I0,FileImageIcon as A0,FolderOutputIcon as C0,PrinterIcon as S0}from"lucide-react";import{useState as M0}from"react";import{useReactFlow as g0}from"@xyflow/react";import{toPng as Jc,toSvg as h0}from"html-to-image";import{toast as y0,useTranslation as x0}from"lecom-ui";import{useState as E0}from"react";var b0=3,Zr="diagram",Qc=()=>{let{t:e}=x0(),{getNodes:t}=g0(),{clearSelection:o}=Xe(),[n,r]=E0({png:!1,html:!1,print:!1}),i=()=>{let{x:d,y:u,width:p,height:f}=ll(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(b({},n),{[u]:!0})),await o();try{let p=al();if(!p)throw new Error("Flow element not found");let f=i();return await d(p,f)}catch(p){y0({content:e("editor.controls.actions.export.feedback.error"),variant:"error"})}finally{r(v(b({},n),{[u]:!1}))}};return{exportAsPng:async(d=Zr)=>{await a(async(u,p)=>{let f=await Jc(u,v(b({},p),{backgroundColor:"#fcfcfc"}));$n(f,`${d}.png`)},"png")},exportAsHtml:async(d=Zr)=>{await a(async(u,p)=>{let f=await h0(u,v(b({},p),{backgroundColor:"#fcfcfc"})),y=`
35
+ </mxGraphModel>`,dl=(e,t)=>{if(!e.length&&!t.length)return bo;let o=[...e.map(r=>r.id),...t.map(r=>r.id)];return Math.max(...o.map(r=>Number(r)))};var Mm=e=>{let t=Object.values(yo),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=Ja[a],l=s==null?void 0:s(i,n);if(!l){console.warn(`Node ${a} not supported`);continue}r.push(l)}return r},Pm=(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=Qa(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},Lm=(e,t)=>{let o=[];return e.forEach(n=>{var a,s;let r=(s=(a=el)[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=tl(n,t);o.push(l)}}),o},km=(e,t)=>{let o=[];return e.forEach(n=>{let r=ja(n,t);o.push(r)}),o},ul=(e=[],t=[],o)=>{let n=Lm(e,o),r=km(t,e),i={mxGraphModel:{root:{_attributes:{version:"1.1",lastId:o},mxCell:[{_attributes:{id:"0"}},{_attributes:{id:"1",parent:"0"}},...n,...r]}}};return Ua(JSON.stringify(i),{compact:!0,spaces:0})},pl=async e=>{var s,l,c,d,u;let t=await On(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)||bo),r=Mm(o),i=Pm(o,r);return{nodes:Ge(Eo(r)),edges:i,lastElementId:n}};import{Position as pg,useConnection as fg,useReactFlow as mg}from"@xyflow/react";import{Handle as fl,useReactFlow as Dm}from"@xyflow/react";import{jsx as ml}from"react/jsx-runtime";var ie=i=>{var a=i,{type:e,position:t,className:o,nodeType:n}=a,r=Ae(a,["type","position","className","nodeType"]);let s=n==="TASK";return ml(fl,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))},Pt=s=>{var l=s,{nodeId:e,nodeType:t,gatewayVariant:o,type:n,position:r,className:i}=l,a=Ae(l,["nodeId","nodeType","gatewayVariant","type","position","className"]);let{getEdges:c,getNodes:d}=Dm(),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 y=d();return f.filter(m=>{if(m.source!==e)return!1;let h=y.find(x=>x.id===m.target);return(h==null?void 0:h.type)!=="ANNOTATION"}).length>=1}return!1})();return ml(fl,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 Rm,useReactFlow as Vm}from"@xyflow/react";import{orderBy as Om}from"lodash";import{jsx as Hm}from"react/jsx-runtime";var Lt=n=>{var r=n,{nodeId:e,isVisible:t}=r,o=Ae(r,["nodeId","isVisible"]);let{getNode:i,getNodes:a,setNodes:s}=Vm(),{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 y=[...a()],g=!f.parentId,m=g?f.id:f.parentId,h=y.filter(T=>T.type==="LANE"&&T.parentId===m);if(!h.length)return;let x=Om(h,["position.y"]),b=0;x.forEach((T,_)=>{var S,P;let N=_===x.length-1,w=(P=(S=T.measured)==null?void 0:S.height)!=null?P:0;y=y.map(L=>{if(L.id===T.id){let C=g?u-K.HEADER_WIDTH:u,I=v(E({},L),{width:C,measured:v(E({},L.measured),{width:C}),position:v(E({},L.position),{y:b})});return N&&g&&(I.height=p-b),I}return L}),b+=w}),y=y.map(T=>{if(T.id===m){let _=g?u:u+K.HEADER_WIDTH;return v(E({},T),{width:_,height:g?p:b,measured:{width:_,height:g?p:b}})}return T}),s(y)};return Hm(Rm,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 og,useReactFlow as ng}from"@xyflow/react";import{Button as rg,Tooltip as ig,TooltipContent as sg,TooltipTrigger as ag,useTranslation as lg}from"lecom-ui";import{useCallback as cg,useRef as El,useState as dg}from"react";import{create as Gm}from"zustand";var kt=Gm(e=>({draggableNode:null,setDraggableNode:t=>{e({draggableNode:t})}}));import{useEffect as Bm,useState as zm}from"react";var gl=(e,t=!1)=>{let[o,n]=zm({width:0,height:0});return Bm(()=>{if(e.current&&t){let r=e.current.getBoundingClientRect();n({width:r.width,height:r.height})}},[t,e]),{dimensions:o}};import{Position as _o,useReactFlow as Fm}from"@xyflow/react";import{useMemo as Wm}from"react";var Ym=120,Um=12,hl=(e,t=!1,o)=>{let{getNode:n,getViewport:r}=Fm(),{instanceId:i}=G();return Wm(()=>{var f,y;if(!t)return{position:_o.Right,align:"start"};let a=n(e);if(!a)return{position:_o.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=(y=document.getElementById(`modeler-${i}`))==null?void 0:y.clientWidth;if(!d)return{position:_o.Right,align:"start"};let u=(o==null?void 0:o.width)||Ym;return{position:l+c+u+Um>d?_o.Left:_o.Right}},[i,e,t,o,n,r])};import{useNodesData as $m,useReactFlow as Xm}from"@xyflow/react";import{Button as yl,DropdownMenu as Km,DropdownMenuContent as qm,DropdownMenuGroup as Zm,DropdownMenuItem as Jm,DropdownMenuLabel as Qm,DropdownMenuTrigger as jm,Tooltip as Wr,TooltipContent as Yr,TooltipTrigger as Ur,useTranslation as eg}from"lecom-ui";import{WrenchIcon as tg}from"lucide-react";import{jsx as ce,jsxs as at}from"react/jsx-runtime";var xl=({nodeId:e})=>{let{t}=eg(),{updateNodeData:o,getEdges:n,getNode:r}=Xm(),i=$m(e),s=n().filter(f=>f.source===e).some(f=>{let y=r(f.target);return(y==null?void 0:y.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 at(Km,{children:[at(Wr,{children:[ce(Ur,{asChild:!0,children:ce(jm,{asChild:!0,children:ce(yl,{variant:"ghost",color:"grey",size:"small",iconButton:!0,children:ce(tg,{})})})}),ce(Yr,{color:"black",children:t("bpmn.task.menu.title")})]}),at(qm,{align:"start",className:"w-60 bg-white text-grey-600",children:[at(Qm,{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(Vo).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 at(Wr,{children:[ce(Ur,{asChild:!0,children:ce(yl,{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(Yr,{color:"black",children:g})]},u)})})]}),ce(Zm,{children:at(Wr,{children:[ce(Ur,{asChild:!0,children:at(Jm,{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(Ro.SCRIPT.icon,{className:"stroke-current"}),t(`bpmn.task.variant.${"SCRIPT".toLowerCase()}`)]})}),s&&ce(Yr,{color:"black",children:t("editor.task_menu.script_not_allowed_when_connected_to_end")})]})})]})]})};import{jsx as j,jsxs as bl}from"react/jsx-runtime";var lt={START_EVENT:{type:"START_EVENT",icon:Kt,label:"bpmn.start_event.variant.default"},END_EVENT:{type:"END_EVENT",icon:gt,label:"bpmn.end_event.variant.default"},TASK:{type:"TASK",icon:Kt,label:"bpmn.task.variant.default"},ANNOTATION:{type:"ANNOTATION",icon:Po,label:"bpmn.annotation.variant.default"}},ug={EXCLUSIVE:{type:"GATEWAY",variant:"EXCLUSIVE",icon:yt,label:"bpmn.gateway.variant.exclusive"},PARALLEL:{type:"GATEWAY",variant:"PARALLEL",icon:xt,label:"bpmn.gateway.variant.parallel"},COMPLEX:{type:"GATEWAY",variant:"COMPLEX",icon:ht,label:"bpmn.gateway.variant.complex"}},pe=({nodeId:e,nodeType:t,nodeVariant:o,isChild:n,isVisible:r})=>{let i=El(null),a=El(null),{t:s}=lg(),{setDraggableNode:l}=kt(),{getEdges:c,getNodes:d}=ng(),{setIsDragging:u,mode:p}=G(),{dimensions:f}=gl(i,r),{position:y}=hl(e,r,f),[g,m]=dg(void 0),h=d(),x=c(),b=o==="SUBPROCESS",T=cg((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(Cn,{elementId:e})}],N=()=>{if(p==="view")return[];let k=!x.some(V=>{var O;return V.source===e&&((O=h.find(B=>B.id===V.target))==null?void 0:O.type)!=="ANNOTATION"});return[{component:j(mo,{nodeId:e,disabled:!k,tooltipMessage:k?void 0:s("editor.toolbar.start_event_limit_reached")})},lt.TASK,lt.ANNOTATION,..._]},w=()=>p==="view"?[{component:j(Ke,{elementId:e})}]:[{component:j(Ke,{elementId:e})},...b?[]:[{component:j(xl,{nodeId:e})}],{component:j(mo,{nodeId:e})},lt.TASK,...Object.values(ug),..._],S=()=>p==="view"?[{component:j(Ke,{elementId:e})}]:[{component:j(Ke,{elementId:e})},{component:j(mo,{nodeId:e})},lt.TASK,lt.ANNOTATION,..._],P=()=>p==="view"?[]:[{component:j(mo,{nodeId:e})},lt.ANNOTATION,..._],L=()=>p==="view"?[]:[...n?[]:[lt.ANNOTATION],..._],C=()=>p==="view"?[]:[..._],I=()=>p==="view"?[]:[..._],A=(k=>{switch(k){case"START_EVENT":return N();case"TASK":return w();case"GATEWAY":return S();case"END_EVENT":return P();case"LANE":return L();case"ANNOTATION":return C();case"UNSUPPORTED":return I();default:return[]}})(t);if(!(A.length===0||p==="readonly"))return bl(og,{position:y,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:h,edges:x},B=Aa(O),$={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?$[B.reason]||s(k.label):s(k.label)||"";return bl(ig,{children:[j(ag,{asChild:!0,children:j(rg,{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(sg,{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 zn,jsxs as gg}from"react/jsx-runtime";var _l=({id:e,data:t,selected:o,dragging:n})=>{let{updateNodeData:r}=mg(),{inProgress:i,fromNode:a}=fg(),{mode:s,isConnecting:l,isDragging:c,isMultipleSelection:d}=G(),u=i&&(a==null?void 0:a.id)!==e,p=y=>{r(e,{label:y})},f=!l&&!c&&!d;return gg("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:[zn(ne,{value:t.label,className:"m-1 text-grey-600",onChange:p}),f&&zn(pe,{nodeId:e,nodeType:"ANNOTATION",isVisible:!n&&o}),s==="edit"&&zn(Lt,{minWidth:Bn.MIN_WIDTH,minHeight:Bn.MIN_HEIGHT,isVisible:!n&&o}),(!i||u)&&zn(ie,{type:"target",position:pg.Left,className:R({"annotation-handle":u})})]})};import{Position as Tl,useConnection as hg,useReactFlow as yg}from"@xyflow/react";import{useState as xg}from"react";import{jsx as Dt,jsxs as Eg}from"react/jsx-runtime";var vl=({id:e,data:t,selected:o,dragging:n})=>{let{updateNodeData:r}=yg(),{inProgress:i,fromNode:a}=hg(),{isConnecting:s,isDragging:l,isMultipleSelection:c}=G(),[d,u]=xg(!1),p=i&&(a==null?void 0:a.id)!==e,f=h=>{r(e,{label:h})},y=()=>{u(!0)},g=()=>{u(!1)},m=!s&&!l&&!c;return Eg("div",{className:"relative",onBlur:g,onDoubleClick:y,children:[Dt(gt,{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})}),Dt("div",{className:"absolute top-9 left-1/2 -translate-x-1/2 max-w-80 w-max",children:Dt(ne,{value:t.label,isEditing:d,onChange:f})}),m&&Dt(pe,{nodeId:e,nodeType:"END_EVENT",isVisible:!n&&o}),(!i||p)&&Dt(ie,{type:"target",position:Tl.Left,className:R({"event-handle":p})}),!i&&Dt(ie,{type:"source",position:Tl.Right})]})};import{Position as Nl,useConnection as bg,useReactFlow as _g}from"@xyflow/react";import{useCallback as Tg,useState as vg}from"react";import{jsx as Rt,jsxs as Ng}from"react/jsx-runtime";var wl=({id:e,data:t,selected:o,dragging:n})=>{let r=hr[t.variant].icon,{updateNodeData:i}=_g(),{inProgress:a,fromNode:s}=bg(),{isConnecting:l,isDragging:c,isMultipleSelection:d}=G(),[u,p]=vg(!1),f=a&&(s==null?void 0:s.id)!==e,y=Tg(x=>{i(e,{label:x})},[e,i]),g=()=>{p(!0)},m=()=>{p(!1)},h=!l&&!c&&!d;return Ng("div",{className:"relative",onBlur:m,onDoubleClick:g,children:[Rt(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})}),Rt("div",{className:"absolute top-14 left-1/2 -translate-x-1/2 max-w-80 w-max",children:Rt(ne,{value:t.label,isEditing:u,onChange:y})}),h&&Rt(pe,{nodeId:e,nodeType:"GATEWAY",isVisible:!n&&o}),(!a||f)&&Rt(ie,{type:"target",position:Nl.Left,className:R({"gateway-handle":f})}),!a&&Rt(Pt,{type:"source",position:Nl.Right,nodeId:e,nodeType:"GATEWAY",gatewayVariant:t.variant})]})};import{useNodesData as yA,useReactFlow as xA}from"@xyflow/react";import{Button as bA,DropdownMenu as _A,DropdownMenuContent as TA,DropdownMenuGroup as vA,DropdownMenuItem as NA,DropdownMenuLabel as wA,DropdownMenuTrigger as IA,Tooltip as AA,TooltipContent as CA,TooltipTrigger as SA,useTranslation as MA}from"lecom-ui";import{WrenchIcon as LA}from"lucide-react";import{jsx as VA,jsxs as OA}from"react/jsx-runtime";import{Position as Il,useConnection as wg,useReactFlow as Ig}from"@xyflow/react";import{useState as Ag}from"react";import{jsx as Vt,jsxs as Cg}from"react/jsx-runtime";var Al=({id:e,data:t,selected:o,dragging:n})=>{let{updateNodeData:r}=Ig(),{inProgress:i,fromNode:a}=wg(),{isConnecting:s,isDragging:l,isMultipleSelection:c}=G(),[d,u]=Ag(!1),p=i&&(a==null?void 0:a.id)!==e,f=h=>{r(e,{label:h})},y=()=>{u(!0)},g=()=>{u(!1)},m=!s&&!l&&!c;return Cg("div",{className:"relative",onBlur:g,onDoubleClick:y,children:[Vt(ko,{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})}),Vt("div",{className:"absolute top-9 left-1/2 -translate-x-1/2 max-w-80 w-max",children:Vt(ne,{value:t.label,isEditing:d,onChange:f})}),m&&Vt(pe,{nodeId:e,nodeType:"START_EVENT",isVisible:!n&&o}),(!i||p)&&Vt(ie,{type:"target",position:Il.Left,className:R({"event-handle":p})}),!i&&Vt(Pt,{type:"source",position:Il.Right,nodeId:e,nodeType:"START_EVENT"})]})};import{Position as Dl,useConnection as Pg,useReactFlow as Lg}from"@xyflow/react";import{useTranslation as kg}from"lecom-ui";import{useCallback as Dg}from"react";var Fn=(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}`},Ot=(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 Cl,jsxs as Sg}from"react/jsx-runtime";var Sl=e=>Sg("svg",v(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:"#10B981"}),Cl("path",{d:"M7 12L10 15L17 8",stroke:"white",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"})]}));import{jsx as Ml}from"react/jsx-runtime";var Pl=e=>Ml("svg",v(E({width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",xmlns:"http://www.w3.org/2000/svg"},e),{children:Ml("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 Ll,jsxs as Mg}from"react/jsx-runtime";var kl=e=>Mg("svg",v(E({width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",xmlns:"http://www.w3.org/2000/svg"},e),{children:[Ll("circle",{cx:"12",cy:"12",r:"10",fill:"#EF4444"}),Ll("path",{d:"M8 8L16 16M8 16L16 8",stroke:"white",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"})]}));import{jsx as ye,jsxs as Vg}from"react/jsx-runtime";var Rg={APROVADO:Sl,EM_ANDAMENTO:Pl,REJEITADO:kl},$r={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)]"},Rl=({id:e,data:t,selected:o,dragging:n})=>{let{t:r}=kg(),{updateNodeData:i,getNodes:a}=Lg(),{inProgress:s,fromNode:l}=Pg(),{mode:c,isConnecting:d,isDragging:u,isMultipleSelection:p,onSubprocessValidationClick:f}=G(),{getTaskStatus:y}=je(),g=s&&(l==null?void 0:l.id)!==e,m=Dg(C=>{let I=C.trim(),M=t.label||"";if(I===M)return;let A=a(),k=I;I||(k=Fn(A,r("bpmn.task.label.prefix")));let V=Ot(k,A);V!==M&&i(e,{label:V})},[t.label,a,e,r,i]),h=y(e),x=h?Rg[h]:null,b=t.variant?Ro[t.variant].icon:null,T=t.attribute?Vo[t.attribute].icon:null,_=t.variant==="SUBPROCESS",N=b&&!_,w=T||_,S=()=>t.hasError?$r.error:h?$r[h]:$r.default,P=()=>{f==null||f({id:e,type:"sub_process",label:t.label})},L=!d&&!u&&!p;return Vg("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(ne,{value:t.label,maxLength:60,className:R("m-1",{"py-6":N||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:_?P: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")})})}),x&&ye("div",{className:"absolute top-0 right-0 flex items-center p-1",children:ye(x,{})}),L&&ye(pe,{nodeId:e,nodeType:"TASK",nodeVariant:t.variant,isVisible:!n&&o}),c==="edit"&&ye(Lt,{minWidth:Hn.MIN_WIDTH,minHeight:Hn.MIN_HEIGHT,isVisible:!n&&o}),(!s||g)&&ye(ie,{type:"target",position:Dl.Left,className:R({"task-handle":g})}),!s&&ye(Pt,{type:"source",position:Dl.Right,nodeId:e,nodeType:"TASK"})]})};import{Position as Vl}from"@xyflow/react";import{Fragment as Og,jsx as Wn,jsxs as Hg}from"react/jsx-runtime";var Ol=({id:e,data:t,selected:o,dragging:n})=>{let{isConnecting:r,isDragging:i,isMultipleSelection:a}=G(),s=!r&&!i&&!a;return Hg(Og,{children:[Wn("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&&Wn(pe,{nodeId:e,nodeType:"UNSUPPORTED",isVisible:!n&&o}),Wn(ie,{type:"source",position:Vl.Right}),Wn(ie,{type:"target",position:Vl.Left})]})};import{BaseEdge as Gg,EdgeLabelRenderer as Bg,getSmoothStepPath as zg,MarkerType as Fg,useInternalNode as Hl,useReactFlow as Wg,useViewport as Yg}from"@xyflow/react";import{useState as Ug}from"react";import{jsx as Yn,jsxs as Gl}from"react/jsx-runtime";var mS={type:"MESSAGE_EDGE",reconnectable:!0,markerEnd:{type:Fg.Arrow},data:{label:""}},Bl=({id:e,source:t,target:o,data:n,selected:r})=>{let{zoom:i}=Yg(),{updateEdgeData:a}=Wg(),{isMultipleSelection:s}=G(),[l,c]=Ug(!1),d=Hl(t),u=Hl(o);if(!d||!u)return null;let{sx:p,sy:f,tx:y,ty:g,sourcePos:m,targetPos:h}=Se(d,u),[x,b,T]=zg({sourceX:p,sourceY:f,targetX:y,targetY:g,sourcePosition:m,targetPosition:h}),_=r||(d==null?void 0:d.selected)||(u==null?void 0:u.selected),N=_?"sequence-edge-marker-highlighted":"sequence-edge-marker",w=l||(n==null?void 0:n.label.trim().length)>0,S=1/i,P=()=>{c(!0)},L=()=>{c(!1)},C=I=>{a(e,{label:I.trim()})};return Gl("g",{className:R("text-grey-400 hover:text-grey-500",{"text-blue-500 hover:text-blue-600":_}),onBlur:L,onDoubleClick:P,children:[Yn(Gg,{id:e,path:x,markerEnd:`url(#${N})`,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)})}),Yn(Bg,{children:Gl("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&&Yn(wt,{edgeId:e,edgeType:"MESSAGE_EDGE",style:{transform:`scale(${S})`}}),w&&Yn(ne,{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 $g}from"@xyflow/react";import{jsx as zl,jsxs as Xg}from"react/jsx-runtime";var Fl=({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}=Se(r,i),[p]=$g({sourceX:a,sourceY:s,sourcePosition:d||o,targetPosition:u||n,targetX:l||e,targetY:c||t});return Xg("g",{children:[zl("path",{fill:"none",className:"stroke-2 stroke-grey-400 animated",d:p}),zl("circle",{cx:l||e,cy:c||t,fill:"none",r:4,className:"stroke-2 stroke-grey-500"})]})};import{Position as Kg,useReactFlow as qg}from"@xyflow/react";import{orderBy as Zg}from"lodash";import{useMemo as Wl,useState as Jg}from"react";import{Fragment as Qg,jsx as ct,jsxs as Yl}from"react/jsx-runtime";var Ul=({id:e,data:t,selected:o,dragging:n,parentId:r})=>{let{updateNodeData:i,getNodes:a}=qg(),{mode:s,isConnecting:l,isDragging:c,isMultipleSelection:d}=G(),[u,p]=Jg(!1),f=a(),y=!r,g=Wl(()=>Zg([...f.filter(N=>N.parentId===e&&N.type==="LANE")],"position.y","asc"),[f,e]),m=y?Gn.MIN_WIDTH:K.MIN_WIDTH,h=Wl(()=>{if(y&&g.length>1){let N=[...g];return N.pop(),N.reduce((S,P)=>{var L,C;return S+((C=(L=P.measured)==null?void 0:L.height)!=null?C:0)},0)+K.MIN_HEIGHT}return K.MIN_HEIGHT},[y,g]),x=N=>{i(e,{label:N})},b=()=>{p(!0)},T=()=>{p(!1)},_=!l&&!c&&!d;return Yl(Qg,{children:[Yl("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:[ct("div",{className:"flex align-items justify-center w-10 border-r-2 border-grey-400",onBlur:T,onDoubleClick:b,children:ct("div",{className:R("relative flex-1",{"[writing-mode:vertical-rl] [text-orientation:sideways] transform rotate-180":!u}),children:ct(ne,{value:t.label,className:"w-full h-full pointer-events-none self-auto",contentClassName:R({"whitespace-nowrap":u}),isEditing:u,onChange:x})})}),ct("div",{className:"flex-1"})]}),_&&ct(pe,{nodeId:e,nodeType:"LANE",isChild:!y,isVisible:!n&&o}),s==="edit"&&ct(Lt,{nodeId:e,minWidth:m,minHeight:h,isVisible:!n&&o}),y&&ct(ie,{type:"source",position:Kg.Right})]})};var $l={START_EVENT:Al,END_EVENT:vl,TASK:Rl,GATEWAY:wl,ANNOTATION:_l,LANE:Ul,UNSUPPORTED:Ol},Xl={SEQUENCE_EDGE:Wa,MESSAGE_EDGE:Bl,ANNOTATION_EDGE:Pa},Kl="#fafafa",ql="#bebebe",Zl=1,Jl=10,Ql="bottom-left",jl=.2,ec=5,Ht=.5,Gt=.4,Bt=1,tc={x:0,y:0,zoom:.75},jg=1,eh=2,oc=[jg,eh];import{useReactFlow as th}from"@xyflow/react";var xe=()=>{let{getEdges:e,getNodes:t}=th(),{lastElementId:o}=G(),n=()=>{let i=t(),a=e(),s=dl(i,a);return Math.max(s,o)};return{getLastId:n,getNextId:()=>n()+1}};var zt=()=>{let{getNodes:e,getEdges:t,setNodes:o,setEdges:n,fitView:r}=oh(),{getLastId:i}=xe(),{setLastElementId:a}=G(),s=nc(async(c="")=>{let{nodes:d,edges:u,lastElementId:p}=await pl(c);o(d),n(u),a(p),r({padding:Ht,minZoom:Gt,maxZoom:Bt})},[o,n,a,r]),l=nc((c,d)=>{let u=c||e()||[],p=d||t()||[],f=i();return ul(u,p,f)},[e,t,i]);return{importFromMxGraph:s,exportToMxGraph:l}};import{useCallback as rc}from"react";var rh=500,Ft=()=>{let{isInitialized:e,onElementChanges:t}=G(),{exportToMxGraph:o}=zt(),n=nh(()=>{if(!e)return;let a=o();t==null||t(a)},rh),r=rc(a=>{a.every(c=>c.type==="select")||a.some(c=>c.type==="position"&&c.dragging)||n()},[n]),i=rc(a=>{a.some(l=>l.type==="select")||n()},[n]);return{emitElementChanges:n,handleNodeChanges:r,handleEdgeChanges:i}};var ic=({setEdges:e})=>{let{getNode:t,getEdges:o,getNodes:n}=sh(),{emitElementChanges:r}=Ft(),i=ah(null),{getNextId:a}=xe(),s=dt(y=>{var b;let g=t(y.source),m=t(y.target);if(!g||!m)return!1;let h={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 kr(h).isValid},[t,o,n]),l=dt(y=>{let g=a(),m=t(y.target),h=(m==null?void 0:m.type)==="ANNOTATION"?It:Ne,x=v(E(E({},y),h),{id:String(g)});e(b=>b.concat(x)),r()},[t,a,e,r]),c=dt((y,g)=>{i.current=g.id},[]),d=dt(()=>{i.current=null},[]),u=dt((y,g)=>{let m=t(g.source),h=t(g.target);if(!m||!h){i.current=null;return}let x={sourceNodeId:m.id,targetNodeId:h.id,sourceNodeType:m.type,targetNodeType:h.type,nodes:n(),edges:o(),reconnectingEdgeId:y.id};if(!kr(x).isValid){i.current=null;return}e(T=>ih(y,g,T).map(N=>N.id===y.id?v(E({},N),{data:v(E({},N.data),{points:void 0})}):N)),i.current=null,r()},[t,n,o,e,r]),p=dt(y=>{i.current=y},[]),f=dt(()=>{i.current=null},[]);return{isValidConnection:s,onConnect:l,onReconnect:u,onReconnectStart:c,onReconnectEnd:d,setReconnectingEdge:p,clearReconnectingEdge:f}};import{useReactFlow as lh}from"@xyflow/react";import{useTranslation as ch}from"lecom-ui";import{useCallback as wo,useRef as mc,useState as gc}from"react";var To=(e=[])=>e.filter(t=>t.type==="START_EVENT"),ut=(e=[])=>e.filter(t=>t.type==="END_EVENT"),Ze=(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"}),ac=(e=[])=>e.filter(t=>{var o;return t.type==="TASK"&&((o=t.properties)==null?void 0:o.variant)==="SUBPROCESS"}),Un=(e=[])=>e.filter(t=>t.type==="GATEWAY"),lc=(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),vo=(e,t=[])=>t.filter(o=>o.target===e),cc=(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"},dc=(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},uc=e=>e?/\w/g.test(e.trim()):!1,X=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:[]}},Pe=(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)}},pc=(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 No=[{id:"start_event_not_found",validate:e=>{let t=To(e.nodes);return X({isValid:t.length>=1})}},{id:"end_event_not_found",validate:e=>{let t=ut(e.nodes);return X({isValid:t.length>=1})}},{id:"multiple_start_event_not_allowed",validate:e=>{let t=To(e.nodes),o=t.length===1;if(t.length===0)return X({isValid:!0});if(!o)return X({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 X({isValid:!1,nodeIds:[...new Set(i)]})}return X({isValid:!0})}},{id:"task_flows_limit_exceeds",validate:e=>{let t=Ze(e.nodes),o=Pe(t,n=>me(n.id,e.edges).length<=2);return X({isValid:o.isValid,nodeIds:o.invalidIds})}},{id:"task_label_empty",highlightRelatedEdges:!1,validate:e=>{let t=Ze(e.nodes),o=Pe(t,n=>!!n.label&&n.label.trim()!=="");return X({isValid:o.isValid,nodeIds:o.invalidIds})}},{id:"task_label_length",highlightRelatedEdges:!1,validate:e=>{let o=Ze(e.nodes),n=Pe(o,r=>!r.label||r.label.length<=60);return X({isValid:n.isValid,nodeIds:n.invalidIds})}},{id:"duplicate_task_name",highlightRelatedEdges:!1,validate:e=>{let t=Ze(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 X({isValid:n.length===0,nodeIds:n})}},{id:"nested_gateway",validate:e=>{let t=Un(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 X({isValid:o.length===0,nodeIds:o.length>0?[...new Set(o)]:[],edgeIds:n})}},{id:"events_nested",validate:e=>{let t=[...To(e.nodes),...ut(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 X({isValid:o.length===0,nodeIds:o.length>0?[...new Set(o)]:[],edgeIds:n})}},{id:"flows_on_end_tasks_not_allowed",validate:e=>{let t=ut(e.nodes),o=[],n=[];for(let r of t){let i=vo(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 X({isValid:o.length===0,nodeIds:o,edgeIds:n})}},{id:"conditions_flows_limit_exceeds",validate:e=>{let t=lc(e.nodes),o=Pe(t,r=>me(r.id,e.edges).length<=2),n=o.invalidIds.flatMap(r=>me(r,e.edges).map(i=>i.id));return X({isValid:o.isValid,nodeIds:o.invalidIds,edgeIds:n})}},{id:"activity_name_invalid",validate:e=>{let t=Ze(e.nodes),o=Pe(t,n=>!n.label||uc(n.label));return X({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 X({isValid:!0});let t=ut(e.nodes)[0];if(!t)return X({isValid:!0});let o=vo(t.id,e.edges);if(!o.length)return X({isValid:!0});let r=Ze(e.nodes).filter(l=>o.some(c=>c.source===l.id)),i=Pe(r,l=>!cc(l.id,e));return X({isValid:i.isValid,nodeIds:i.isValid?[]:[t.id,...i.invalidIds]})}},{id:"concurrent_initial_and_final_event",validate:e=>{let t=Ze(e.nodes),o=ut(e.nodes)[0];if(!o)return X({isValid:!0});let n=t.filter(l=>{let c=vo(l.id,e.edges),d=me(l.id,e.edges),u=c.some(f=>{var y;return((y=e.nodes.find(g=>g.id===f.source))==null?void 0:y.type)==="START_EVENT"}),p=d.some(f=>{var y;return((y=e.nodes.find(g=>g.id===f.target))==null?void 0:y.type)==="END_EVENT"});return u&&p}),r=vo(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 X(s)}},{id:"gateway_flow_to_event",validate:e=>{let t=Un(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 X({isValid:o.length===0,nodeIds:o.length>0?[...new Set(o)]:[],edgeIds:n})}},{id:"gateway_missing_output_streams",validate:e=>{let t=Un(e.nodes),o=Pe(t,n=>me(n.id,e.edges).length>=1);return X({isValid:o.isValid,nodeIds:o.invalidIds})}},{id:"event_to_condition",validate:e=>{let t=[...To(e.nodes),...ut(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 X({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=Pe(t,n=>!dc(n.id,e));return X({isValid:o.isValid,nodeIds:o.invalidIds})}},{id:"subprocess_referenced_not_configured",validate:e=>{let t=ac(e.nodes),o=Pe(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 X({isValid:o.isValid,nodeIds:o.invalidIds})}}];var fc=e=>{e=e||{nodes:[],edges:[]},e.nodes=e.nodes||[],e.edges=e.edges||[];let t=[];for(let n of No){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 hc=()=>{let{t:e}=ch(),{setNodes:t,setEdges:o,getNodes:n,getEdges:r}=lh(),[i,a]=gc(null),[s,l]=gc(!1),c=mc(!1),d=mc(!1),u=wo(m=>{let h=pc(m.nodes,m.edges),x=fc(h),b=x.errors.map(T=>v(E({},T),{message:e(`validation.errors.${T.id}`)}));return s||l(!0),{isValid:x.isValid,errors:b}},[s,e]),p=wo((m,h=!0)=>{if(h&&a(m),!m)return;c.current=!0,d.current=!0;let x=[],b=[];m.errors.forEach(I=>{I.nodeIds&&I.nodeIds.length>0&&I.nodeIds.forEach(M=>x.push(M)),I.edgeIds&&I.edgeIds.length>0&&I.edgeIds.forEach(M=>b.push(M))});let T=[...new Set(x)];t(I=>I.map(M=>v(E({},M),{data:v(E({},M.data),{hasError:!1})}))),o(I=>I.map(M=>v(E({},M),{data:v(E({},M.data),{hasError:!1})})));let _=n(),N=r(),w=new Set(T),S=new Set;m.errors.forEach(I=>{var k,V;let M=No.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=>{N.forEach(B=>{(B.source===O||B.target===O)&&S.add(B.id)})}))});let P=new Set,L=new Set,C=new Set;_.forEach(I=>{I.type==="START_EVENT"?P.add(I.id):I.type==="END_EVENT"&&L.add(I.id)}),N.forEach(I=>{P.has(I.source)&&C.add(I.target),L.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=No.find(O=>O.id===k))==null?void 0:A.highlightRelatedEdges)!==!1&&N.forEach(O=>{O.source===I&&L.has(O.target)&&(w.add(O.target),S.add(O.id)),O.target===I&&P.has(O.source)&&(w.add(O.source),S.add(O.id))})}}),w.size>0&&t(I=>I.map(M=>v(E({},M),{data:v(E({},M.data),{hasError:w.has(M.id)})}))),S.size>0&&o(I=>I.map(M=>v(E({},M),{data:v(E({},M.data),{hasError:S.has(M.id)})}))),setTimeout(()=>{c.current=!1},0)},[r,n,o,t]),f=wo(()=>{a(null),l(!1),d.current=!1,t(m=>m.map(h=>v(E({},h),{data:v(E({},h.data),{hasError:!1})}))),o(m=>m.map(h=>v(E({},h),{data:v(E({},h.data),{hasError:!1})})))},[o,t]),y=wo(()=>{d.current&&(a(null),c.current=!0,d.current=!1,t(m=>m.map(h=>v(E({},h),{data:v(E({},h.data),{hasError:!1})}))),o(m=>m.map(h=>v(E({},h),{data:v(E({},h.data),{hasError:!1})}))),setTimeout(()=>{c.current=!1},0))},[o,t]),g=wo(()=>c.current,[]);return{validationResult:i,validateDiagram:u,handleValidationComplete:p,clearValidation:f,dismissValidationPanel:y,isAutoValidationEnabled:s,getIsClearingValidation:g}};import{useReactFlow as dh}from"@xyflow/react";import{useTranslation as uh}from"lecom-ui";import{useEffect as ph}from"react";var fh=15,yc="bpmn:selection",mh=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},xc=e=>{if(!mh(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},Ec=({offset:e=fh}={})=>{let{t}=uh(),{getNodes:o,setNodes:n,getEdges:r,setEdges:i}=dh(),{getNextId:a}=xe();ph(()=>{let s=c=>{var m,h;if(!xc(c))return;let d=o(),u=r(),p=d.filter(x=>x.selected);if(!p.length)return;c.preventDefault(),c.stopPropagation();let f=u.filter(x=>p.some(b=>b.id===x.source)&&p.some(b=>b.id===x.target)),g=JSON.stringify({nodes:p,edges:f});(m=c.clipboardData)==null||m.setData(yc,g),(h=c.clipboardData)==null||h.setData("text/plain",`BPMN Selection: ${p.length} nodes`)},l=c=>{var _,N;if(!xc(c))return;let d=(_=c.clipboardData)==null?void 0:_.getData(yc);if(!d)return;c.preventDefault(),c.stopPropagation();let u;try{u=JSON.parse(d)}catch(w){return}if(!((N=u.nodes)!=null&&N.length))return;let p=new Map,f=o(),y=[],g=f.some(w=>w.type==="START_EVENT"),m=u.nodes.filter(w=>w.type==="START_EVENT"),h=u.nodes;if(g&&m.length>0&&(h=u.nodes.filter(w=>w.type!=="START_EVENT"),h.length===0))return;let x=a(),b=h.map(w=>{var L;let S=String(x++);p.set(w.id,S);let P=v(E({},w),{id:S,selected:!0,position:{x:w.position.x+e,y:w.position.y+e}});if(w.type==="TASK"){let C=(L=w.data)==null?void 0:L.label,I=Ot(C||t("bpmn.task.label.prefix"),[...f,...y]);P.data=v(E({},w.data),{label:I})}return y.push(P),P}),T=u.edges.map(w=>v(E({},w),{id:String(x++),selected:!0,source:p.get(w.source)||w.source,target:p.get(w.target)||w.target}));n(w=>[...w.map(S=>v(E({},S),{selected:!1})),...b]),i(w=>[...w.map(S=>v(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 gh,useStoreApi as hh}from"@xyflow/react";import{useTranslation as yh}from"lecom-ui";import{useState as xh}from"react";var bc=({nodes:e,setNodes:t,setEdges:o})=>{let n=hh(),{draggableNode:r,setDraggableNode:i}=kt(),{t:a}=yh(),{getInternalNode:s,screenToFlowPosition:l}=gh(),{getNextId:c}=xe(),{setIsDragging:d}=G(),{rebuildIndex:u,forceRebuildIndex:p}=vt(),[f,y]=xh(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=>v(E({},k),{className:k.id===C?M:""})))},m=()=>{let{nodeLookup:C}=n.getState();return Array.from(C.values())},h=C=>{let I=s(C.id),M=m();if(C.type==="LANE"){if(Mt({parentId:C.id,nodes:e,includeTypes:["LANE"]})){g();return}let $=M.filter(z=>z.id!==C.id&&z.type==="LANE"&&!z.parentId),D=xo(I,$);if(!D){g();return}if(Mt({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=xo(I,k);if(!V){g();return}if(Mt({parentId:V.id,nodes:e,includeTypes:["LANE"]})){g();return}g(V.id)},x=C=>C.map(I=>v(E({},I),{className:void 0})),b=C=>C.some(M=>M.dragging)?C.map(M=>M.dragging?v(E({},M),{dragging:!1}):M):C,T=C=>{C.preventDefault(),C.dataTransfer.dropEffect="move"},_=(C,I)=>{C.preventDefault(),h(I)},N=(C,I,M)=>{var B,$;let A=[...M];if(C.parentId===I.id)return A=sl(C,I,A),A=Eo(A),x(A);if(C.type==="LANE"){if(Mt({parentId:I.id,nodes:A,excludeTypes:["LANE"]})){let Y=fe(I),Q=50,q=50;return A.map(ae=>{var Qe,Ee;return ae.id===C.id?v(E({},ae),{position:{x:(Qe=f==null?void 0:f.x)!=null?Qe:Y.x+Q,y:(Ee=f==null?void 0:f.y)!=null?Ee:Y.y2+q}}):ae})}let z=A.filter(Y=>Y.parentId===I.id).reduce((Y,Q)=>{var q,ae;return Y+((ae=(q=Q.measured)==null?void 0:q.height)!=null?ae:0)},0),W={x:K.HEADER_WIDTH,y:z};return A=A.map(Y=>Y.id===C.id?v(E({},Y),{parentId:I.id,position:W,className:void 0}):v(E({},Y),{className:void 0})),A=st(I.id,A),A}if(Mt({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+(($=C.position.y)!=null?$:0)}}return A=A.map(H=>H.id===C.id?v(E({},H),{position:D!=null?D:H.position,parentId:void 0,className:void 0}):v(E({},H),{className:void 0})),A}let O=ol(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),v(E({},D),{parentId:I.id,position:O,className:void 0})}return v(E({},D),{className:void 0})}),A=Eo(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"?Fn(e,a("bpmn.task.label.prefix")):"",variant:r.variant,attribute:r.attribute},selected:!0},V=v(E({},k),{internals:{positionAbsolute:I}}),O=m(),B=r.type==="LANE",$=O.filter(W=>B?W.type==="LANE"&&!W.parentId:W.type==="LANE"),D=xo(V,$),H=[...e.map(W=>v(E({},W),{selected:!1})),k];D&&(H=N(V,D,H)),H=Ge(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),It)));return}o(Y=>Y.concat(E(E({},W),Ne)))}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",$=V.filter(H=>H.id!==k.id&&(B?H.type==="LANE"&&!H.parentId:H.type==="LANE")),D=xo(O,$);if(D){A=N(O,D,A);return}k.parentId&&(A=L(k,A))}),A=b(A),A=Ge(A),A=x(A),t(A),u(A),y(null)},P=(C,I)=>{y({x:I.position.x,y:I.position.y})},L=(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($=>$.id===C.id?v(E({},$),{position:V,parentId:void 0}):$),I=st(C.parentId,I),I};return{onDragOver:T,onDrop:w,onNodeDrag:_,onNodeDragStart:P,onNodeDragStop:S}};import{useReactFlow as Eh}from"@xyflow/react";import{useTranslation as bh}from"lecom-ui";import{useEffect as _h}from"react";var Th=30,vh=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},Nh=e=>!vh(e.target),_c=({offset:e=Th}={})=>{let{t}=bh(),{getNodes:o,setNodes:n,getEdges:r,setEdges:i}=Eh(),{getNextId:a}=xe();_h(()=>{let s=l=>{if(l.ctrlKey&&l.key.toLowerCase()==="d"&&Nh(l)){l.preventDefault(),l.stopPropagation();let c=o(),d=r(),u=c.filter(_=>_.selected);if(!u.length)return;let p=new Map,f=[],y=c.some(_=>_.type==="START_EVENT"),g=u.filter(_=>_.type==="START_EVENT"),m=u;if(y&&g.length>0&&(m=u.filter(_=>_.type!=="START_EVENT"),m.length===0))return;let h=d.filter(_=>m.some(N=>N.id===_.source)&&m.some(N=>N.id===_.target)),x=a(),b=m.map(_=>{var S;let N=String(x++);p.set(_.id,N);let w=v(E({},_),{id:N,selected:!0,position:{x:_.position.x+e,y:_.position.y+e}});if(_.type==="TASK"){let P=(S=_.data)==null?void 0:S.label,L=Ot(P||t("bpmn.task.label.prefix"),[...c,...f]);w.data=v(E({},_.data),{label:L})}return f.push(w),w}),T=h.map(_=>v(E({},_),{id:String(x++),selected:!0,source:p.get(_.source)||_.source,target:p.get(_.target)||_.target}));n(_=>[..._.map(N=>v(E({},N),{selected:!1})),...b]),i(_=>[..._.map(N=>v(E({},N),{selected:!1})),...T])}};return document.addEventListener("keydown",s,!0),()=>{document.removeEventListener("keydown",s,!0)}},[o,n,r,i,a,e,t])};import{useReactFlow as Ih}from"@xyflow/react";var vc={"start-event":"START_EVENT","end-event":"END_EVENT",task:"TASK","gateway-exclusive":"GATEWAY"},Nc={"start-event":"","end-event":"",task:"","gateway-exclusive":"EXCLUSIVE"},Tc=(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}},wh=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=Tc(i[0],o),s=Tc(i[1],o);a&&s&&n.push({sourceId:a.step,targetId:s.step,label:a.edgeLabel||s.edgeLabel||""})}),{components:o,connections:n}},wc=e=>{let{components:t,connections:o}=wh(e);return{nodes:t,edges:o}};var Ic=()=>{let{setNodes:e,setEdges:t,fitView:o}=Ih(),{getNextId:n}=xe();return{importFromLia:i=>{let a=typeof i=="string"?i:i.diagramXml||"",{nodes:s,edges:l}=wc(a),c=[],d=new Map,u=!1,p=n();for(let[m,h]of Object.entries(s)){let x=String(p++),b=vc[h.type],T=Nc[h.type];b==="START_EVENT"&&(u=!0),d.set(m,x);let _=U[b].MIN_WIDTH,N=U[b].MIN_HEIGHT;c.push({id:x,type:b,data:{label:h.label||"",variant:T,attribute:""},position:{x:0,y:0},width:_,height:N,measured:{width:_,height:N}})}let f=[];for(let m of l){let h=v(E({},Ne),{id:String(p++),source:d.get(m.sourceId)||m.sourceId,target:d.get(m.targetId)||m.targetId});f.push(h)}if(!u&&c.length>0){let m=String(p++),h={id:m,type:"START_EVENT",data:{label:"",variant:"",attribute:""},position:{x:0,y:0},width:U.START_EVENT.MIN_WIDTH,height:U.START_EVENT.MIN_HEIGHT,measured:{width:U.START_EVENT.MIN_WIDTH,height:U.START_EVENT.MIN_HEIGHT}};c.unshift(h);let x=c[1];if(x){let b=v(E({},Ne),{id:String(p++),source:m,target:x.id});f.unshift(b)}}let{nodes:y,edges:g}=il(c,f);e(y),t(g),o({padding:Ht,minZoom:Gt,maxZoom:Bt})}}};import{useEffect as Ah,useCallback as Ch}from"react";var Sh={origin:"*",debug:!1};function Ac(e,t=Sh){let{origin:o,debug:n}=t,r=Ch((i,a)=>{let s={event:i,data:[i,{event:i,data:a}]};window.parent.postMessage(s,o||"*")},[o]);return Ah(()=>{let i=a=>{let s=a.data;if(!(s!=null&&s.event)||!(s!=null&&s.data))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 Mh}from"@xyflow/react";import{useEffect as Cc}from"react";var Sc=()=>{let e=Mh(),{initialDiagram:t,setIsInitialized:o}=G(),{importFromMxGraph:n}=zt();Cc(()=>{t&&n(t)},[t,n,o]),Cc(()=>{if(!e)return;(async()=>{await Lo(),o(!0)})()},[e,o])};import{useCallback as Mc}from"react";import{useReactFlow as Ph}from"@xyflow/react";function Pc(){let{setTaskStatuses:e,clearTaskStatuses:t,calculateFlowPath:o}=je(),{getEdges:n}=Ph(),r=Oo(),i=Mc(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=Mc(()=>{t(),setTimeout(()=>{r()},0)},[t,r]);return{handleTasksStatus:i,handleClearTaskStatus:a}}import{useReactFlow as Lh}from"@xyflow/react";import{useCallback as Wt,useState as Lc,useEffect as kh}from"react";import{useDebouncedCallback as Dh}from"use-debounce";var kc=[{nodes:[],edges:[]}],Rh=500,Dc=100,Rc=(e=kc)=>{let{getNodes:t,getEdges:o,setNodes:n,setEdges:r}=Lh(),[i,a]=Lc(e),[s,l]=Lc(0),c=i[s],d=s>0,u=s<i.length-1,p=Wt(T=>{n(i[T].nodes),r(i[T].edges)},[i,n,r]),f=Wt(()=>{if(s>0){let T=s-1;l(T),p(T)}},[s,p]),y=Wt(()=>{if(s<i.length-1){let T=s+1;l(T),p(T)}},[i,s,p]),g=T=>{let N=[...i.slice(0,s+1),T],w=N.length>Dc?N.slice(N.length-Dc):N;a(w),l(w.length-1)},m=Dh(()=>{let T=t(),_=o(),N=T.map(P=>v(E({},P),{selected:!1,className:""})),w={nodes:Ge(N),edges:_};JSON.stringify(c)!==JSON.stringify(w)&&g(w)},Rh),h=Wt(T=>{if(T==="forceSave"){m();return}T.some(w=>w.type==="select")||T.some(w=>w.type==="position"&&w.dragging)||m()},[m]),x=Wt(T=>{a(T||kc),l(0)},[]),b=Wt(()=>{a([]),l(0)},[]);return kh(()=>{let T=_=>{(_.ctrlKey||_.metaKey)&&(_.shiftKey&&_.key.toLowerCase()==="z"?(_.preventDefault(),y()):_.key.toLowerCase()==="z"&&(_.preventDefault(),f()))};return document.addEventListener("keydown",T),()=>{document.removeEventListener("keydown",T)}},[f,y]),{history:i,undo:f,redo:y,canUndo:d,canRedo:u,saveHistory:h,resetHistory:x,clearHistory:b}};var Vc=()=>{let[e,t,o]=Oh([]),[n,r,i]=Vh([]),[a,s]=Bh(null),{instanceId:l,setIsConnecting:c,setIsMultipleSelection:d}=G(),{updateHelperLines:u,HelperLines:p}=vt(),{undo:f,redo:y,canUndo:g,canRedo:m,saveHistory:h}=Rc(),{onNodeDrag:x,onDrop:b,onDragOver:T,onNodeDragStop:_,onNodeDragStart:N}=bc({nodes:e,setNodes:t,setEdges:r}),{isValidConnection:w,onConnect:S,onReconnect:P,onReconnectStart:L,onReconnectEnd:C,setReconnectingEdge:I,clearReconnectingEdge:M}=ic({setEdges:r}),{validationResult:A,handleValidationComplete:k,clearValidation:V,dismissValidationPanel:O,validateDiagram:B,getIsClearingValidation:$}=hc(),{importFromLia:D}=Ic(),{handleTasksStatus:H,handleClearTaskStatus:z}=Pc(),{clearPathEdges:W}=je(),Y=Oo(),{emitElementChanges:Q,handleNodeChanges:q,handleEdgeChanges:ae}=Ft();Ec(),_c(),Sc();let Qe=$n(()=>{t([]),r([]),W(),setTimeout(()=>{Y()},0)},[t,r,W,Y]);Ac({LIA_CREATE_DIAGRAM:D,CLEAR_DIAGRAM:Qe,TASKS_STATUS:H,CLEAR_TASKS_STATUS:z});let{selectElements:Ee,clearSelection:Ut}=Xe(),{importFromMxGraph:De,exportToMxGraph:mt}=zt(),{configureElement:sr,getConfigureElement:li}=wn();Gh(()=>(Me.set(l,{importFromMxGraph:De,exportToMxGraph:mt,selectElements:Ee,clearSelection:Ut,configureElement:sr,getConfigureElement:li,setReconnectingEdge:I,clearReconnectingEdge:M}),()=>{Me.delete(l)}),[l,De,mt,Ee,Ut,sr,li,I,M]);let _d=$n(be=>{let $t=u(be,e);o($t),h(be),$()||O(),q(be)},[e,o,h,$,O,u,q]),Td=$n(be=>{i(be),h(be),$()||O(),ae(be)},[i,h,$,O,ae]);Hh({onChange:({nodes:be,edges:$t})=>{d(be.length+$t.length>1)}});let vd=$n(async({nodes:be,edges:$t})=>(s({nodes:be,edges:$t}),!1),[s]);return{nodes:e,setNodes:t,edges:n,setEdges:r,events:{isValidConnection:w,onConnect:S,onReconnect:P,onReconnectStart:L,onReconnectEnd:C,onDrop:b,onDragOver:T,onNodeDrag:x,onNodeDragStop:_,onNodeDragStart:N,onDropCapture:()=>{h("forceSave"),Q(),O()},onConnectStart:()=>{c(!0)},onConnectEnd:()=>{c(!1),O()},onBeforeDelete:vd,onNodesChange:_d,onEdgesChange:Td},ui:{pendingDelete:a,setPendingDelete:s,validationResult:A,handleCloseValidationPanel:V},controls:{undo:f,redo:y,canUndo:g,canRedo:m},components:{HelperLines:p},actions:{saveHistory:h,selectElements:Ee,clearSelection:Ut,exportToMxGraph:mt,validateDiagram:B,handleValidationComplete:k,setReconnectingEdge:I,clearReconnectingEdge:M}}};import{jsx as Oc}from"react/jsx-runtime";var Xr=({id:e,className:t})=>Oc("marker",{id:e,className:R("react-flow__arrowhead",t),viewBox:"0 0 10 10",refX:"9",refY:"5",markerWidth:"7",markerHeight:"7",orient:"auto",markerUnits:"userSpaceOnUse",fill:"currentColor",stroke:"currentColor",children:Oc("path",{d:"M 0 0 L 10 5 L 0 10 Z"})});import{jsx as Kr,jsxs as zh}from"react/jsx-runtime";var Hc=()=>Kr("svg",{style:{position:"absolute",top:0,left:0},children:zh("defs",{children:[Kr(Xr,{id:"sequence-edge-marker",className:"text-grey-400"}),Kr(Xr,{id:"sequence-edge-marker-highlighted",className:"text-blue-500"})]})});import{useKeyPress as td,useReactFlow as P0}from"@xyflow/react";import{Button as Qn,Tooltip as jn,TooltipContent as er,TooltipTrigger as tr,useTranslation as L0}from"lecom-ui";import{HandIcon as k0,ListCheckIcon as D0,MapIcon as R0,MousePointerIcon as V0}from"lucide-react";import{useCallback as Qr,useEffect as od}from"react";import{Tooltip as l0,TooltipContent as c0,TooltipTrigger as d0,useNotificationToast as u0,useTranslation as p0}from"lecom-ui";var Io=(x=>(x.START_EVENT="START_EVENT",x.END_EVENT="END_EVENT",x.TASK="TASK",x.SUBPROCESS="SUBPROCESS",x.GATEWAY="GATEWAY",x.LANE="LANE",x.ANNOTATION="ANNOTATION",x.CONNECTION="CONNECTION",x.INTERMEDIATE_EVENT="INTERMEDIATE_EVENT",x.ACTIVITY="ACTIVITY",x.PROCESS_INTERFACE="PROCESS_INTERFACE",x.WORKFLOW_INTERFACE="WORKFLOW_INTERFACE",x.VARIANT_ACTIVITY="VARIANT_ACTIVITY",x.AUTO_ACTIVITY="AUTO_ACTIVITY",x.DATA_STORE="DATA_STORE",x.DATA_OBJECT="DATA_OBJECT",x.DATA_OUTPUT="DATA_OUTPUT",x.DATA_INPUT="DATA_INPUT",x))(Io||{});import{useReactFlow as jh}from"@xyflow/react";import{useNotificationToast as e0,useTranslation as t0,Button as o0}from"lecom-ui";var Gc=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 Bc({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);Xn(i,`${o}.csv`)}var Xn=(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 zc(e){return e==null?void 0:e.replaceAll("&#xA;"," ")}var $6={START_EVENT:"START_EVENT",END_EVENT:"END_EVENT",TASK:"TASK",GATEWAY:"GATEWAY",ANNOTATION:"ANNOTATION"},Fc={script:"SCRIPT",subprocess:"SUBPROCESS"},Wc={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}}},Wh=e=>{let{subType:t,style:o}=e._attributes,n="imported";return["none"].includes(t)||(n="adapted"),e.mxGeometry._attributes.width=U.START_EVENT.MIN_WIDTH,e.mxGeometry._attributes.height=U.START_EVENT.MIN_HEIGHT,{node:pt({cell:e,type:"START_EVENT"}),status:n,originalType:o}},Yh=e=>{let{subType:t,style:o}=e==null?void 0:e._attributes,n="imported";return["none"].includes(t)||(n="adapted"),e.mxGeometry._attributes.width=U.END_EVENT.MIN_WIDTH,e.mxGeometry._attributes.height=U.END_EVENT.MIN_HEIGHT,{node:pt({cell:e,type:"END_EVENT"}),status:n,originalType:o}},Uh=e=>{let{subType:t,style:o}=e==null?void 0:e._attributes,n=Fc[t],r="imported";return["script","none"].includes(t)||(r="adapted"),e.mxGeometry._attributes.width=ze(e.mxGeometry._attributes.width||0,U.TASK.MIN_WIDTH),e.mxGeometry._attributes.height=ze(e.mxGeometry._attributes.height||0,U.TASK.MIN_HEIGHT),{node:pt({cell:e,type:"TASK",variant:n}),status:r,originalType:o}},$h=e=>{let{style:t,subType:o}=e==null?void 0:e._attributes,n=Wc[o],r=["none","inclusive","event-based"],i="imported";return r.includes(o)&&(i="adapted"),e.mxGeometry._attributes.width=U.GATEWAY.MIN_WIDTH,e.mxGeometry._attributes.height=U.GATEWAY.MIN_HEIGHT,{node:pt({cell:e,type:"GATEWAY",variant:n}),status:i,originalType:t}},Xh=e=>{let{style:t}=e==null?void 0:e._attributes;return{node:pt({cell:e,type:"LANE"}),status:"imported",originalType:t}},Kh=e=>{let{style:t}=e==null?void 0:e._attributes;return e.mxGeometry._attributes.width=ze(e.mxGeometry._attributes.width||0,U.ANNOTATION.MIN_WIDTH),e.mxGeometry._attributes.height=ze(e.mxGeometry._attributes.height||0,U.ANNOTATION.MIN_HEIGHT),{node:pt({cell:e,type:"ANNOTATION"}),status:"imported",originalType:t}},Yc=e=>{let{style:t}=e==null?void 0:e._attributes;return e.mxGeometry._attributes.width=U.UNSUPPORTED.MIN_WIDTH,e.mxGeometry._attributes.height=U.UNSUPPORTED.MIN_HEIGHT,{node:pt({cell:e,type:"UNSUPPORTED"}),status:"unsupported",originalType:t}},Uc=(e,t)=>{let{id:o,source:n,target:r,value:i}=e._attributes;return v(E({},Ne),{id:o,source:t.get(n)||n,target:t.get(r)||r,data:{label:i||""}})},$c={TASK:Uh,GATEWAY:$h,START_EVENT:Wh,END_EVENT:Yh,LANE:Xh,ANNOTATION:Kh};var qh=e=>{let t=new Map,o=Object.values(Io),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=$c[s]||Yc,{node:c,status:d,originalType:u}=l(a);i.push(c),r.push({originalType:u,type:c.type,variant:c.data.variant,value:zc(c.data.label),status:d})}return{nodes:i,governanceIdToNodeIdMap:t,summary:r}},Zh=(e,t)=>e.filter(r=>{var i;return(i=r._attributes)==null?void 0:i.edge}).map(r=>Uc(r,t)),Jh=e=>{let{mxGraphModel:t}=e,{nodes:o,governanceIdToNodeIdMap:n,summary:r}=qh(t.root.mxCell),i=Zh(t.root.mxCell,n);return{nodes:o,edges:i,summary:r}},Qh=async e=>{let t=await Gc(e),o=On(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}},Xc=async e=>{try{let t=await Qh(e),{nodes:o,edges:n,summary:r}=Jh(t)||{};return{nodes:o,edges:n,summary:r}}catch(t){throw t}};import{jsx as n0}from"react/jsx-runtime";var Kc=()=>{let{t:e}=t0(),{toast:t}=e0(),{setNodes:o,setEdges:n,fitView:r}=jh(),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:n0(o0,{size:"small",variant:"ghost",onClick:()=>Bc({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 Xc(s);if(o(p=>p.concat(l)),n(p=>p.concat(c)),r({padding:Ht,minZoom:Gt,maxZoom:Bt}),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 r0}from"lecom-ui";import{useRef as i0}from"react";import{Fragment as s0,jsx as qc,jsxs as a0}from"react/jsx-runtime";var Zc=s=>{var l=s,{children:e,accept:t="*",multiple:o=!1,disabled:n=!1,onClick:r,onFilesSelected:i}=l,a=Ae(l,["children","accept","multiple","disabled","onClick","onFilesSelected"]);let c=i0(null),d=p=>{let f=p.target.files;f!=null&&f.length&&i(f),c.current&&(c.current.value="")};return a0(s0,{children:[qc(r0,v(E({onClick:p=>{var f;(f=c.current)==null||f.click(),r==null||r(p)}},a),{children:e})),qc("input",{type:"file",ref:c,className:"sr-only",accept:t,multiple:o,disabled:n,onChange:d})]})};import{jsx as Kn,jsxs as f0}from"react/jsx-runtime";var Jc=({disabled:e=!1})=>{let{t}=p0(),{toast:o}=u0(),{importFromGovernance:n}=Kc(),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 f0(l0,{children:[Kn(d0,{asChild:!0,children:Kn(Zc,{className:"[&>svg]:size-7 p-0",variant:"ghost",size:"small",color:"grey",iconButton:!0,accept:".mdr",disabled:e,onClick:r,onFilesSelected:i,children:Kn(Ei,{})})}),Kn(c0,{color:"black",children:t("editor.controls.actions.import_governance")})]})};import{jsx as m0}from"react/jsx-runtime";var qr=({shortcut:e})=>m0("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 _0,DropdownMenu as T0,DropdownMenuContent as v0,DropdownMenuItem as Jr,DropdownMenuTrigger as N0,Tooltip as qn,TooltipContent as Zn,TooltipTrigger as Jn,useTranslation as w0}from"lecom-ui";import{FileCodeIcon as I0,FileImageIcon as A0,FolderOutputIcon as C0,PrinterIcon as S0}from"lucide-react";import{useState as M0}from"react";import{useReactFlow as g0}from"@xyflow/react";import{toPng as Qc,toSvg as h0}from"html-to-image";import{toast as y0,useTranslation as x0}from"lecom-ui";import{useState as E0}from"react";var b0=3,Zr="diagram",jc=()=>{let{t:e}=x0(),{getNodes:t}=g0(),{clearSelection:o}=Xe(),[n,r]=E0({png:!1,html:!1,print:!1}),i=()=>{let{x:d,y:u,width:p,height:f}=ll(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=al();if(!p)throw new Error("Flow element not found");let f=i();return await d(p,f)}catch(p){y0({content:e("editor.controls.actions.export.feedback.error"),variant:"error"})}finally{r(v(E({},n),{[u]:!1}))}};return{exportAsPng:async(d=Zr)=>{await a(async(u,p)=>{let f=await Qc(u,v(E({},p),{backgroundColor:"#fcfcfc"}));Xn(f,`${d}.png`)},"png")},exportAsHtml:async(d=Zr)=>{await a(async(u,p)=>{let f=await h0(u,v(E({},p),{backgroundColor:"#fcfcfc"})),y=`
38
38
  <!DOCTYPE html>
39
39
  <html>
40
40
  <head>
@@ -48,7 +48,7 @@ var vd=Object.defineProperty,Nd=Object.defineProperties;var wd=Object.getOwnProp
48
48
  <img src="${f}" alt="Diagram" />
49
49
  </body>
50
50
  </html>
51
- `,g=new Blob([y],{type:"text/html"}),m=URL.createObjectURL(g);$n(m,`${d}.html`),setTimeout(()=>URL.revokeObjectURL(m),100)},"html")},printDiagram:async(d=Zr)=>{await a(async(u,p)=>{let f=await Jc(u,v(b({},p),{pixelRatio:b0})),y=window.open("","_blank");if(!y)throw new Error("Failed to open print window.");let g=y.document;g.open(),g.write(`
51
+ `,g=new Blob([y],{type:"text/html"}),m=URL.createObjectURL(g);Xn(m,`${d}.html`),setTimeout(()=>URL.revokeObjectURL(m),100)},"html")},printDiagram:async(d=Zr)=>{await a(async(u,p)=>{let f=await Qc(u,v(E({},p),{pixelRatio:b0})),y=window.open("","_blank");if(!y)throw new Error("Failed to open print window.");let g=y.document;g.open(),g.write(`
52
52
  <!DOCTYPE html>
53
53
  <html>
54
54
  <head>
@@ -64,4 +64,4 @@ var vd=Object.defineProperty,Nd=Object.defineProperties;var wd=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 Yt}from"react/jsx-runtime";function jc(){let{t:e}=w0(),{exportAsPng:t,exportAsHtml:o,printDiagram:n,isPrinting:r,isPrintingPng:i,isPrintingHtml:a}=Qc(),[s,l]=M0(!1);return Yt(T0,{modal:!1,open:s,onOpenChange:l,children:[ee(N0,{asChild:!0,children:ee("div",{children:Yt(Kn,{children:[ee(Zn,{asChild:!0,children:ee(_0,{size:"small",variant:"ghost",color:"grey",iconButton:!0,children:ee(C0,{})})}),!s&&ee(qn,{color:"black",children:e("editor.controls.actions.export.title")})]})})}),Yt(v0,{align:"center",side:"top",sideOffset:16,className:"min-w-0 flex flex-col gap-2 p-2 shadow-sm",children:[Yt(Kn,{children:[ee(Zn,{asChild:!0,children:ee(Jr,{className:"p-1.5",disabled:i,onClick:()=>t(),children:ee(A0,{})})}),ee(qn,{side:"right",color:"black",children:e("editor.controls.actions.export.png")})]}),Yt(Kn,{children:[ee(Zn,{asChild:!0,children:ee(Jr,{className:"p-1.5",disabled:a,onClick:()=>o(),children:ee(I0,{})})}),ee(qn,{side:"right",color:"black",children:e("editor.controls.actions.export.html")})]}),Yt(Kn,{children:[ee(Zn,{asChild:!0,children:ee(Jr,{className:"p-1.5",disabled:r,onClick:()=>n(),children:ee(S0,{})})}),ee(qn,{side:"right",color:"black",children:e("editor.controls.actions.export.print")})]})]})]})}import{Fragment as od,jsx as te,jsxs as Ge}from"react/jsx-runtime";var nd=({nodes:e,validateDiagram:t,handleValidationComplete:o})=>{let{t:n}=L0(),{clearSelection:r}=Xe(),{mode:i,isMinimapOpen:a,setIsMinimapOpen:s,isMoveTool:l,isHandTool:c,setIsMoveTool:d,setIsHandTool:u}=G(),{getNodes:p,getEdges:f}=P0(),y=ed(["v","V"]),g=ed(["h","H"]),m=Qr(()=>{r(),u(!0),d(!1)},[r,u,d]),h=Qr(()=>{d(!0),u(!1)},[d,u]),x=Qr(()=>{let E=p(),T=f(),_=t({nodes:E,edges:T});o(_)},[p,f,t,o]);return td(()=>{y&&!l&&i==="edit"&&h()},[y,h,l,i]),td(()=>{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(od,{children:[Ge(Qn,{children:[te(er,{asChild:!0,children:te(Jn,{size:"small",variant:"ghost",color:"grey",className:R(l&&"bg-grey-400"),iconButton:!0,onClick:h,children:te(V0,{})})}),Ge(jn,{color:"black",className:"flex items-center gap-2",children:[n("editor.controls.actions.move_tool"),te(qr,{shortcut:"V"})]})]}),Ge(Qn,{children:[te(er,{asChild:!0,children:te(Jn,{size:"small",variant:"ghost",color:"grey",className:R(c&&"bg-grey-400"),iconButton:!0,onClick:m,children:te(k0,{})})}),Ge(jn,{color:"black",className:"flex items-center gap-2",children:[n("editor.controls.actions.hand_tool")," ",te(qr,{shortcut:"H"})]})]})]}),te(jc,{}),i==="edit"&&Ge(od,{children:[Ge(Qn,{children:[te(er,{asChild:!0,children:te(Jn,{size:"small",variant:"ghost",color:"grey",iconButton:!0,onClick:x,children:te(D0,{})})}),te(jn,{color:"black",children:n("editor.controls.actions.check")})]}),te(Zc,{disabled:e.length>0})]}),Ge(Qn,{children:[te(er,{asChild:!0,children:te(Jn,{size:"small",variant:"ghost",color:"grey",className:R(a&&"bg-grey-400"),iconButton:!0,onClick:()=>s(!a),children:te(R0,{})})}),te(jn,{color:"black",children:n(a?"editor.controls.actions.minimap.close":"editor.controls.actions.minimap.open")})]})]})};import{Button as rd,Tooltip as id,TooltipContent as sd,TooltipTrigger as ad,useTranslation as O0}from"lecom-ui";import{RedoIcon as H0,UndoIcon as G0}from"lucide-react";import{jsx as Je,jsxs as jr}from"react/jsx-runtime";var ld=({undo:e,redo:t,canUndo:o,canRedo:n})=>{let{t:r}=O0();return jr("div",{className:"flex items-center gap-2 px-3 py-2 bg-white rounded-sm shadow-md",children:[jr(id,{children:[Je(ad,{asChild:!0,children:Je(rd,{size:"small",variant:"ghost",color:"grey",iconButton:!0,disabled:!o,onClick:e,children:Je(G0,{})})}),Je(sd,{color:"black",children:r("editor.controls.history.undo")})]}),jr(id,{children:[Je(ad,{asChild:!0,children:Je(rd,{size:"small",variant:"ghost",color:"grey",iconButton:!0,disabled:!n,onClick:t,children:Je(H0,{})})}),Je(sd,{color:"black",children:r("editor.controls.history.redo")})]})]})};import{useReactFlow as B0}from"@xyflow/react";import{Button as tr,Tooltip as or,TooltipContent as nr,TooltipTrigger as rr,useTranslation as z0}from"lecom-ui";import{ScanIcon as F0,ZoomIn as W0,ZoomOut as Y0}from"lucide-react";import{jsx as se,jsxs as Io}from"react/jsx-runtime";var cd=()=>{let{t:e}=z0(),{zoomIn:t,zoomOut:o,zoomTo:n,fitView:r}=B0();return Io("div",{className:"flex items-center gap-2 px-3 py-2 bg-white rounded-sm shadow-md",children:[Io(or,{children:[se(rr,{asChild:!0,children:se(tr,{size:"small",variant:"ghost",color:"grey",iconButton:!0,onClick:()=>r(),children:se(F0,{})})}),se(nr,{color:"black",children:e("editor.controls.zoom.fit")})]}),Io(or,{children:[se(rr,{asChild:!0,children:se(tr,{size:"small",variant:"ghost",color:"grey",iconButton:!0,onClick:()=>o(),children:se(Y0,{})})}),se(nr,{color:"black",children:e("editor.controls.zoom.out")})]}),Io(or,{children:[se(rr,{asChild:!0,children:se(tr,{size:"small",variant:"ghost",color:"grey",iconButton:!0,onClick:()=>n(1),children:se(Ti,{})})}),se(nr,{color:"black",children:e("editor.controls.zoom.reset")})]}),Io(or,{children:[se(rr,{asChild:!0,children:se(tr,{size:"small",variant:"ghost",color:"grey",iconButton:!0,onClick:()=>t(),children:se(W0,{})})}),se(nr,{color:"black",children:e("editor.controls.zoom.in")})]})]})};import{Button as dd,Dialog as U0,DialogContent as $0,DialogFooter as X0,DialogHeader as K0,DialogTitle as q0,Notification as Z0,Typography as ei,useTranslation as J0}from"lecom-ui";import{jsx as Le,jsxs as ti}from"react/jsx-runtime";var ud=({pendingDelete:e,setPendingDelete:t,nodes:o,setNodes:n,setEdges:r,saveHistory:i})=>{let{t:a}=J0(),{forceRebuildIndex:s}=vt(),{emitElementChanges:l}=Ft(),c=!!e,d=()=>{let{nodes:y}=e||{};if(y!=null&&y.length){let g=o.filter(m=>!y.some(h=>h.id===m.id));y.forEach(m=>{(m==null?void 0:m.type)==="LANE"&&(m!=null&&m.parentId)&&(g=st(m.parentId,g))}),n(He(g))}},u=()=>{let{edges:y}=e||{};y!=null&&y.length&&r(g=>g.filter(m=>!y.some(h=>h.id===m.id)))},p=()=>{d(),u(),i("forceSave"),s(),l(),t(null)},f=()=>{t(null)};return Le(U0,{open:c,onOpenChange:f,children:ti($0,{className:"w-[488px] max-w-fit gap-2",children:[Le(K0,{children:Le(q0,{children:Le(ei,{variant:"heading-small-600",textColor:"text-grey-950",children:a("editor.modals.delete_elements.title")})})}),ti("div",{className:"flex flex-col gap-2",children:[Le("div",{className:"py-2",children:Le(Z0,{type:"callout",variant:"warning",content:a("editor.modals.delete_elements.callout")})}),Le(ei,{variant:"body-large-400",textColor:"text-grey-800",className:"py-2",children:a("editor.modals.delete_elements.content")})]}),ti(X0,{className:"flex items-center flex-row justify-end w-full gap-2",children:[Le(dd,{variant:"outlined",color:"grey",disabled:!1,size:"small",onClick:f,children:Le(ei,{variant:"body-medium-500",textColor:"text-grey-800",children:a("editor.modals.delete_elements.cancel")})}),Le(dd,{size:"small",variant:"filled",color:"destructive",autoFocus:!0,onClick:p,children:a("editor.modals.delete_elements.confirm")})]})]})})};import{useReactFlow as Q0}from"@xyflow/react";import{Button as j0,Tooltip as ey,TooltipContent as ty,TooltipTrigger as oy,useTranslation as ny}from"lecom-ui";import{useRef as ry,useState as iy}from"react";import{jsx as ft,jsxs as pd}from"react/jsx-runtime";var fd=()=>{let e=ry(null),{t}=ny(),{setDraggableNode:o}=kt(),{getNodes:n}=Q0(),{setIsDragging:r}=G(),[i,a]=iy(void 0),s=n(),l=mn(s),c=[{type:"START_EVENT",icon:Lo,label:t("bpmn.start_event.variant.default")},{type:"END_EVENT",icon:gt,label:t("bpmn.end_event.variant.default")},{type:"TASK",icon:Kt,label:t("bpmn.task.variant.default")},{type:"TASK",variant:"SUBPROCESS",icon:Ai,label:t("bpmn.task.variant.subprocess")},{type:"TASK",variant:"SCRIPT",icon:Ii,label:t("bpmn.task.variant.script")},{type:"TASK",attribute:"LOOP",icon:wi,label:t("bpmn.task.attribute.loop")},{type:"GATEWAY",variant:"EXCLUSIVE",icon:yt,label:t("bpmn.gateway.variant.exclusive")},{type:"GATEWAY",variant:"PARALLEL",icon:xt,label:t("bpmn.gateway.variant.parallel")},{type:"GATEWAY",variant:"COMPLEX",icon:ht,label:t("bpmn.gateway.variant.complex")},{type:"LANE",icon:_i,label:t("bpmn.lane.variant.default")},{type:"ANNOTATION",icon:Mo,label:t("bpmn.annotation.variant.default")}],d=(u,p)=>{o({type:p.type,variant:p.variant,attribute:p.attribute,icon:p.icon}),a(ft(p.icon,{})),u.dataTransfer.effectAllowed="move",e.current&&u.dataTransfer.setDragImage(e.current,10,10),setTimeout(()=>{r(!0)},100)};return pd("aside",{className:"sidebar absolute z-[1] top-4 left-4",children:[ft("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",y=f?t("editor.toolbar.start_event_already_exists"):u.label;return pd(ey,{children:[ft(oy,{asChild:!0,children:ft(j0,{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:ft(u.icon,{})},p)}),ft(ty,{color:"black",side:"right",children:y})]},p)})}),ft("div",{ref:e,className:"absolute w-0 h-0 top-0 left-0 z-[-1] bg-transparent",children:i})]})};import{Button as sy,useTranslation as ay}from"lecom-ui";import{AlertCircleIcon as ly,CircleCheckIcon as cy,XIcon as dy}from"lucide-react";import{useEffect as md,useRef as uy,useState as gd}from"react";import{jsx as we,jsxs as oi}from"react/jsx-runtime";var py=5e3,hd=({validationResult:e,onClose:t})=>{let{t:o}=ay(),[n,r]=gd(!1),[i,a]=gd(!1),s=uy(null);md(()=>{e&&r(!0)},[e]),md(()=>(n&&!i&&(s.current=setTimeout(()=>{r(!1),t()},py)),()=>{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 oi("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:[oi("div",{className:"flex flex-row items-start gap-4",children:[we("div",{className:"flex-shrink-0",children:d?we(cy,{className:"text-green-500 size-5"}):we(ly,{className:"text-red-500 size-5"})}),oi("div",{className:"body-medium-500 text-grey-800",children:[we("div",{children:o(d?"validation.success.title":"validation.errors.title")}),!d&&we("div",{children:o("validation.errors.subtitle")})]}),we(sy,{variant:"ghost",size:"small",color:"grey",className:"size-5 hover:bg-transparent",iconButton:!0,onClick:()=>{r(!1),t()},children:we(dy,{})})]}),we("div",{className:"max-h-80 overflow-y-auto mt-2 px-9 body-medium-400 text-grey-800",children:d?we("p",{children:o("validation.success.message")}):we("div",{className:"list-disc list-inside",children:u.map(p=>we("li",{className:"mb-1",children:p.message},p.id))})})]})};import{jsx as Ie,jsxs as ni}from"react/jsx-runtime";var ri=yy((e,t)=>{let{instanceId:o,mode:n,isMinimapOpen:r,isMoveTool:i,isHandTool:a}=G(),{nodes:s,setNodes:l,edges:c,setEdges:d,ui:u,actions:p,events:f,components:y,controls:g}=Rc();return xy(t,()=>({selectElements:p.selectElements,clearSelection:p.clearSelection})),ni("div",{className:"w-full h-full",children:[n==="edit"&&Ie(fd,{}),Ie(Oc,{}),ni(gy,v(b({},f),{id:`modeler-${o}`,edges:c,nodes:s,nodeTypes:Yl,edgeTypes:Ul,minZoom:Jl,maxZoom:Ql,panOnDrag:a||n!=="edit"?!0:ec,panOnScroll:!0,selectionOnDrag:!0,elevateEdgesOnSelect:!0,elevateNodesOnSelect:!0,elementsSelectable:n!=="readonly"&&i,nodesConnectable:n==="edit"&&i,nodesDraggable:n==="edit"&&i,connectionLineComponent:Bl,selectionMode:hy.Partial,multiSelectionKeyCode:"Shift",deleteKeyCode:"Delete",selectionKeyCode:null,snapToGrid:!0,snapGrid:[5,5],defaultViewport:jl,connectOnClick:!1,proOptions:{hideAttribution:!0},children:[Ie(fy,{gap:ql,size:Kl,color:Xl,bgColor:$l}),r&&Ie(my,{pannable:!0,zoomable:!0,position:Zl,className:"shadow-md rounded-md"}),ni("div",{className:"absolute z-10 bottom-4 left-1/2 -translate-x-1/2 flex gap-4",children:[n==="edit"&&Ie(ld,b({},g)),Ie(nd,{nodes:s,validateDiagram:p.validateDiagram,handleValidationComplete:p.handleValidationComplete}),Ie(cd,{})]}),Ie(y.HelperLines,{}),u.validationResult&&Ie("div",{className:"absolute top-6 right-6 z-[1000]",children:Ie(hd,{validationResult:u.validationResult,onClose:u.handleCloseValidationPanel})})]})),Ie(ud,{pendingDelete:u.pendingDelete,setPendingDelete:u.setPendingDelete,nodes:s,setNodes:l,setEdges:d,saveHistory:p.saveHistory})]})});ri.displayName="Editor";import{useStore as Ey}from"@xyflow/react";import{useEffect as by,useRef as _y}from"react";import{jsx as vy}from"react/jsx-runtime";var Ty=e=>({width:e.width,height:e.height,transform:e.transform}),ii="rgba(51, 103, 217, 0.4)",Ta=({horizontal:e,vertical:t})=>{let{width:o,height:n,transform:r}=Ey(Ty),i=_y(null);return by(()=>{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=ii,t&&(s.beginPath(),s.strokeStyle=t.color||ii,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||ii,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]),vy("canvas",{ref:i,className:"w-full h-full absolute z-10 pointer-events-none"})};import{i18n as Ny,Notification as wy,TooltipProvider as Iy}from"lecom-ui";import{createContext as Ay,useContext as Cy,useEffect as Sy,useState as My}from"react";import{jsx as yd,jsxs as Ly}from"react/jsx-runtime";var Me=new Map,xd=Ay(null),si=()=>{let e=Cy(xd);if(!e)throw new Error("useModeler must be used within an <ModelerProvider />");return e},Py=({locale:e,defaultMode:t="view",showNotification:o=!0,children:n})=>{let[r,i]=My(e||"pt_BR");Sy(()=>{e&&(i(e),Ny.changeLanguage(e))},[e]);let a=f=>{let y=Me.size;if(y===0)throw new Error("No modeler instances found");if(y===1||!f){let[m]=Me.values();return m}let g=Me.get(f);if(!g)throw new Error(`Modeler instance with ID "${f}" not found`);return g},s=(f,y)=>{let g=a(y);return g==null?void 0:g.selectElements(f)},l=async f=>{let y=a(f);return y==null?void 0:y.clearSelection()},c=(f,y)=>{let g=a(y);return g==null?void 0:g.configureElement(f)},d=(f,y)=>{let g=a(y);return g==null?void 0:g.getConfigureElement(f)},u=async(f,y)=>{let g=a(y);await(g==null?void 0:g.importFromMxGraph(f))},p=f=>{let y=a(f);return y==null?void 0:y.exportToMxGraph()};return yd(xd.Provider,{value:{defaultMode:t,locale:r,selectElements:s,clearSelection:l,configureElement:c,getConfigureElement:d,importDiagram:u,exportDiagram:p},children:Ly(Iy,{children:[o&&yd(wy,{type:"toast",placement:"topRight",enableClose:!0,showProgress:!0,pauseOnHover:!0}),n]})})};import{jsx as ai}from"react/jsx-runtime";var Ed=Dy(null),G=()=>{let e=Ry(Ed);if(!e)throw new Error("useModelerInstance must be used within an <Modeler />");return e},Gy=({selectorRef:e,initialDiagram:t,instanceId:o,mode:n,onElementChanges:r,onConfigureElement:i,onSubprocessValidationClick:a})=>{let{defaultMode:s}=si(),l=Oy(),[c]=Be(o||l),[d,u]=Be(n||s||"edit"),[p,f]=Be(!1),[y,g]=Be(!0),[m,h]=Be(!1),[x,E]=Be(!1),[T,_]=Be(!1),[N,w]=Be(!1),[S,P]=Be(!1);Vy(()=>{n&&u(n)},[n]);let L=Hy(()=>t||tc(),[t]),C={instanceId:c,initialDiagram:L,mode:d,isInitialized:p,setIsInitialized:f,isMinimapOpen:x,isMoveTool:y,isHandTool:m,isDragging:T,isMultipleSelection:S,isConnecting:N,setIsMinimapOpen:E,setIsMoveTool:g,setIsHandTool:h,setIsDragging:_,setIsConnecting:w,setIsMultipleSelection:P,onElementChanges:r,onConfigureElement:i,onSubprocessValidationClick:a};return ai(ky,{children:ai(Ed.Provider,{value:C,children:ai(ri,{ref:e})})})};export{ge as EditorMode,ar as ElementPosition,Co as ElementType,lr as GatewayElementVariant,Te as GatewayVariant,Gy as Modeler,Py as ModelerProvider,Fe as NodeAttribute,F as NodeType,_e as NodeVariant,cr as RoutingVariant,si as useModeler};
67
+ `),g.close()},"print")},isPrintingPng:n.png,isPrintingHtml:n.html,isPrinting:n.print}};import{jsx as ee,jsxs as Yt}from"react/jsx-runtime";function ed(){let{t:e}=w0(),{exportAsPng:t,exportAsHtml:o,printDiagram:n,isPrinting:r,isPrintingPng:i,isPrintingHtml:a}=jc(),[s,l]=M0(!1);return Yt(T0,{modal:!1,open:s,onOpenChange:l,children:[ee(N0,{asChild:!0,children:ee("div",{children:Yt(qn,{children:[ee(Jn,{asChild:!0,children:ee(_0,{size:"small",variant:"ghost",color:"grey",iconButton:!0,children:ee(C0,{})})}),!s&&ee(Zn,{color:"black",children:e("editor.controls.actions.export.title")})]})})}),Yt(v0,{align:"center",side:"top",sideOffset:16,className:"min-w-0 flex flex-col gap-2 p-2 shadow-sm",children:[Yt(qn,{children:[ee(Jn,{asChild:!0,children:ee(Jr,{className:"p-1.5",disabled:i,onClick:()=>t(),children:ee(A0,{})})}),ee(Zn,{side:"right",color:"black",children:e("editor.controls.actions.export.png")})]}),Yt(qn,{children:[ee(Jn,{asChild:!0,children:ee(Jr,{className:"p-1.5",disabled:a,onClick:()=>o(),children:ee(I0,{})})}),ee(Zn,{side:"right",color:"black",children:e("editor.controls.actions.export.html")})]}),Yt(qn,{children:[ee(Jn,{asChild:!0,children:ee(Jr,{className:"p-1.5",disabled:r,onClick:()=>n(),children:ee(S0,{})})}),ee(Zn,{side:"right",color:"black",children:e("editor.controls.actions.export.print")})]})]})]})}import{Fragment as nd,jsx as te,jsxs as Be}from"react/jsx-runtime";var rd=({nodes:e,validateDiagram:t,handleValidationComplete:o})=>{let{t:n}=L0(),{clearSelection:r}=Xe(),{mode:i,isMinimapOpen:a,setIsMinimapOpen:s,isMoveTool:l,isHandTool:c,setIsMoveTool:d,setIsHandTool:u}=G(),{getNodes:p,getEdges:f}=P0(),y=td(["v","V"]),g=td(["h","H"]),m=Qr(()=>{r(),u(!0),d(!1)},[r,u,d]),h=Qr(()=>{d(!0),u(!1)},[d,u]),x=Qr(()=>{let b=p(),T=f(),_=t({nodes:b,edges:T});o(_)},[p,f,t,o]);return od(()=>{y&&!l&&i==="edit"&&h()},[y,h,l,i]),od(()=>{g&&!c&&i==="edit"&&m()},[g,m,c,i]),Be("div",{className:"flex items-center gap-2 px-3 py-2 bg-white rounded-sm shadow-md",children:[i==="edit"&&Be(nd,{children:[Be(jn,{children:[te(tr,{asChild:!0,children:te(Qn,{size:"small",variant:"ghost",color:"grey",className:R(l&&"bg-grey-400"),iconButton:!0,onClick:h,children:te(V0,{})})}),Be(er,{color:"black",className:"flex items-center gap-2",children:[n("editor.controls.actions.move_tool"),te(qr,{shortcut:"V"})]})]}),Be(jn,{children:[te(tr,{asChild:!0,children:te(Qn,{size:"small",variant:"ghost",color:"grey",className:R(c&&"bg-grey-400"),iconButton:!0,onClick:m,children:te(k0,{})})}),Be(er,{color:"black",className:"flex items-center gap-2",children:[n("editor.controls.actions.hand_tool")," ",te(qr,{shortcut:"H"})]})]})]}),te(ed,{}),i==="edit"&&Be(nd,{children:[Be(jn,{children:[te(tr,{asChild:!0,children:te(Qn,{size:"small",variant:"ghost",color:"grey",iconButton:!0,onClick:x,children:te(D0,{})})}),te(er,{color:"black",children:n("editor.controls.actions.check")})]}),te(Jc,{disabled:e.length>0})]}),Be(jn,{children:[te(tr,{asChild:!0,children:te(Qn,{size:"small",variant:"ghost",color:"grey",className:R(a&&"bg-grey-400"),iconButton:!0,onClick:()=>s(!a),children:te(R0,{})})}),te(er,{color:"black",children:n(a?"editor.controls.actions.minimap.close":"editor.controls.actions.minimap.open")})]})]})};import{Button as id,Tooltip as sd,TooltipContent as ad,TooltipTrigger as ld,useTranslation as O0}from"lecom-ui";import{RedoIcon as H0,UndoIcon as G0}from"lucide-react";import{jsx as Je,jsxs as jr}from"react/jsx-runtime";var cd=({undo:e,redo:t,canUndo:o,canRedo:n})=>{let{t:r}=O0();return jr("div",{className:"flex items-center gap-2 px-3 py-2 bg-white rounded-sm shadow-md",children:[jr(sd,{children:[Je(ld,{asChild:!0,children:Je(id,{size:"small",variant:"ghost",color:"grey",iconButton:!0,disabled:!o,onClick:e,children:Je(G0,{})})}),Je(ad,{color:"black",children:r("editor.controls.history.undo")})]}),jr(sd,{children:[Je(ld,{asChild:!0,children:Je(id,{size:"small",variant:"ghost",color:"grey",iconButton:!0,disabled:!n,onClick:t,children:Je(H0,{})})}),Je(ad,{color:"black",children:r("editor.controls.history.redo")})]})]})};import{useReactFlow as B0}from"@xyflow/react";import{Button as or,Tooltip as nr,TooltipContent as rr,TooltipTrigger as ir,useTranslation as z0}from"lecom-ui";import{ScanIcon as F0,ZoomIn as W0,ZoomOut as Y0}from"lucide-react";import{jsx as se,jsxs as Ao}from"react/jsx-runtime";var dd=()=>{let{t:e}=z0(),{zoomIn:t,zoomOut:o,zoomTo:n,fitView:r}=B0();return Ao("div",{className:"flex items-center gap-2 px-3 py-2 bg-white rounded-sm shadow-md",children:[Ao(nr,{children:[se(ir,{asChild:!0,children:se(or,{size:"small",variant:"ghost",color:"grey",iconButton:!0,onClick:()=>r(),children:se(F0,{})})}),se(rr,{color:"black",children:e("editor.controls.zoom.fit")})]}),Ao(nr,{children:[se(ir,{asChild:!0,children:se(or,{size:"small",variant:"ghost",color:"grey",iconButton:!0,onClick:()=>o(),children:se(Y0,{})})}),se(rr,{color:"black",children:e("editor.controls.zoom.out")})]}),Ao(nr,{children:[se(ir,{asChild:!0,children:se(or,{size:"small",variant:"ghost",color:"grey",iconButton:!0,onClick:()=>n(1),children:se(Ti,{})})}),se(rr,{color:"black",children:e("editor.controls.zoom.reset")})]}),Ao(nr,{children:[se(ir,{asChild:!0,children:se(or,{size:"small",variant:"ghost",color:"grey",iconButton:!0,onClick:()=>t(),children:se(W0,{})})}),se(rr,{color:"black",children:e("editor.controls.zoom.in")})]})]})};import{Button as ud,Dialog as U0,DialogContent as $0,DialogFooter as X0,DialogHeader as K0,DialogTitle as q0,Notification as Z0,Typography as ei,useTranslation as J0}from"lecom-ui";import{jsx as Le,jsxs as ti}from"react/jsx-runtime";var pd=({pendingDelete:e,setPendingDelete:t,nodes:o,setNodes:n,setEdges:r,saveHistory:i})=>{let{t:a}=J0(),{forceRebuildIndex:s}=vt(),{emitElementChanges:l}=Ft(),c=!!e,d=()=>{let{nodes:y}=e||{};if(y!=null&&y.length){let g=o.filter(m=>!y.some(h=>h.id===m.id));y.forEach(m=>{(m==null?void 0:m.type)==="LANE"&&(m!=null&&m.parentId)&&(g=st(m.parentId,g))}),n(Ge(g))}},u=()=>{let{edges:y}=e||{};y!=null&&y.length&&r(g=>g.filter(m=>!y.some(h=>h.id===m.id)))},p=()=>{d(),u(),i("forceSave"),s(),l(),t(null)},f=()=>{t(null)};return Le(U0,{open:c,onOpenChange:f,children:ti($0,{className:"w-[488px] max-w-fit gap-2",children:[Le(K0,{children:Le(q0,{children:Le(ei,{variant:"heading-small-600",textColor:"text-grey-950",children:a("editor.modals.delete_elements.title")})})}),ti("div",{className:"flex flex-col gap-2",children:[Le("div",{className:"py-2",children:Le(Z0,{type:"callout",variant:"warning",content:a("editor.modals.delete_elements.callout")})}),Le(ei,{variant:"body-large-400",textColor:"text-grey-800",className:"py-2",children:a("editor.modals.delete_elements.content")})]}),ti(X0,{className:"flex items-center flex-row justify-end w-full gap-2",children:[Le(ud,{variant:"outlined",color:"grey",disabled:!1,size:"small",onClick:f,children:Le(ei,{variant:"body-medium-500",textColor:"text-grey-800",children:a("editor.modals.delete_elements.cancel")})}),Le(ud,{size:"small",variant:"filled",color:"destructive",autoFocus:!0,onClick:p,children:a("editor.modals.delete_elements.confirm")})]})]})})};import{useReactFlow as Q0}from"@xyflow/react";import{Button as j0,Tooltip as ey,TooltipContent as ty,TooltipTrigger as oy,useTranslation as ny}from"lecom-ui";import{useRef as ry,useState as iy}from"react";import{jsx as ft,jsxs as fd}from"react/jsx-runtime";var md=()=>{let e=ry(null),{t}=ny(),{setDraggableNode:o}=kt(),{getNodes:n}=Q0(),{setIsDragging:r}=G(),[i,a]=iy(void 0),s=n(),l=gn(s),c=[{type:"START_EVENT",icon:ko,label:t("bpmn.start_event.variant.default")},{type:"END_EVENT",icon:gt,label:t("bpmn.end_event.variant.default")},{type:"TASK",icon:Kt,label:t("bpmn.task.variant.default")},{type:"TASK",variant:"SUBPROCESS",icon:Ai,label:t("bpmn.task.variant.subprocess")},{type:"TASK",variant:"SCRIPT",icon:Ii,label:t("bpmn.task.variant.script")},{type:"TASK",attribute:"LOOP",icon:wi,label:t("bpmn.task.attribute.loop")},{type:"GATEWAY",variant:"EXCLUSIVE",icon:yt,label:t("bpmn.gateway.variant.exclusive")},{type:"GATEWAY",variant:"PARALLEL",icon:xt,label:t("bpmn.gateway.variant.parallel")},{type:"GATEWAY",variant:"COMPLEX",icon:ht,label:t("bpmn.gateway.variant.complex")},{type:"LANE",icon:_i,label:t("bpmn.lane.variant.default")},{type:"ANNOTATION",icon:Po,label:t("bpmn.annotation.variant.default")}],d=(u,p)=>{o({type:p.type,variant:p.variant,attribute:p.attribute,icon:p.icon}),a(ft(p.icon,{})),u.dataTransfer.effectAllowed="move",e.current&&u.dataTransfer.setDragImage(e.current,10,10),setTimeout(()=>{r(!0)},100)};return fd("aside",{className:"sidebar absolute z-[1] top-4 left-4",children:[ft("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",y=f?t("editor.toolbar.start_event_already_exists"):u.label;return fd(ey,{children:[ft(oy,{asChild:!0,children:ft(j0,{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:ft(u.icon,{})},p)}),ft(ty,{color:"black",side:"right",children:y})]},p)})}),ft("div",{ref:e,className:"absolute w-0 h-0 top-0 left-0 z-[-1] bg-transparent",children:i})]})};import{Button as sy,useTranslation as ay}from"lecom-ui";import{AlertCircleIcon as ly,CircleCheckIcon as cy,XIcon as dy}from"lucide-react";import{useEffect as gd,useRef as uy,useState as hd}from"react";import{jsx as we,jsxs as oi}from"react/jsx-runtime";var py=5e3,yd=({validationResult:e,onClose:t})=>{let{t:o}=ay(),[n,r]=hd(!1),[i,a]=hd(!1),s=uy(null);gd(()=>{e&&r(!0)},[e]),gd(()=>(n&&!i&&(s.current=setTimeout(()=>{r(!1),t()},py)),()=>{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 oi("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:[oi("div",{className:"flex flex-row items-start gap-4",children:[we("div",{className:"flex-shrink-0",children:d?we(cy,{className:"text-green-500 size-5"}):we(ly,{className:"text-red-500 size-5"})}),oi("div",{className:"body-medium-500 text-grey-800",children:[we("div",{children:o(d?"validation.success.title":"validation.errors.title")}),!d&&we("div",{children:o("validation.errors.subtitle")})]}),we(sy,{variant:"ghost",size:"small",color:"grey",className:"size-5 hover:bg-transparent",iconButton:!0,onClick:()=>{r(!1),t()},children:we(dy,{})})]}),we("div",{className:"max-h-80 overflow-y-auto mt-2 px-9 body-medium-400 text-grey-800",children:d?we("p",{children:o("validation.success.message")}):we("div",{className:"list-disc list-inside",children:u.map(p=>we("li",{className:"mb-1",children:p.message},p.id))})})]})};import{jsx as Ie,jsxs as ni}from"react/jsx-runtime";var ri=yy((e,t)=>{let{instanceId:o,mode:n,isMinimapOpen:r,isMoveTool:i,isHandTool:a}=G(),{nodes:s,setNodes:l,edges:c,setEdges:d,ui:u,actions:p,events:f,components:y,controls:g}=Vc();return xy(t,()=>({selectElements:p.selectElements,clearSelection:p.clearSelection})),ni("div",{className:"w-full h-full",children:[n==="edit"&&Ie(md,{}),Ie(Hc,{}),ni(gy,v(E({},f),{id:`modeler-${o}`,edges:c,nodes:s,nodeTypes:$l,edgeTypes:Xl,minZoom:jl,maxZoom:ec,panOnDrag:a||n!=="edit"?!0:oc,panOnScroll:!0,selectionOnDrag:!0,elevateEdgesOnSelect:!0,elevateNodesOnSelect:!0,elementsSelectable:n!=="readonly"&&i,nodesConnectable:n==="edit"&&i,nodesDraggable:n==="edit"&&i,connectionLineComponent:Fl,selectionMode:hy.Partial,multiSelectionKeyCode:"Shift",deleteKeyCode:"Delete",selectionKeyCode:null,snapToGrid:!0,snapGrid:[5,5],defaultViewport:tc,connectOnClick:!1,proOptions:{hideAttribution:!0},children:[Ie(fy,{gap:Jl,size:Zl,color:ql,bgColor:Kl}),r&&Ie(my,{pannable:!0,zoomable:!0,position:Ql,className:"shadow-md rounded-md"}),ni("div",{className:"absolute z-10 bottom-4 left-1/2 -translate-x-1/2 flex gap-4",children:[n==="edit"&&Ie(cd,E({},g)),Ie(rd,{nodes:s,validateDiagram:p.validateDiagram,handleValidationComplete:p.handleValidationComplete}),Ie(dd,{})]}),Ie(y.HelperLines,{}),u.validationResult&&Ie("div",{className:"absolute top-6 right-6 z-[1000]",children:Ie(yd,{validationResult:u.validationResult,onClose:u.handleCloseValidationPanel})})]})),Ie(pd,{pendingDelete:u.pendingDelete,setPendingDelete:u.setPendingDelete,nodes:s,setNodes:l,setEdges:d,saveHistory:p.saveHistory})]})});ri.displayName="Editor";import{useStore as Ey}from"@xyflow/react";import{useEffect as by,useRef as _y}from"react";import{jsx as vy}from"react/jsx-runtime";var Ty=e=>({width:e.width,height:e.height,transform:e.transform}),ii="rgba(51, 103, 217, 0.4)",Ta=({horizontal:e,vertical:t})=>{let{width:o,height:n,transform:r}=Ey(Ty),i=_y(null);return by(()=>{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=ii,t&&(s.beginPath(),s.strokeStyle=t.color||ii,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||ii,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]),vy("canvas",{ref:i,className:"w-full h-full absolute z-10 pointer-events-none"})};import{i18n as Ny,Notification as wy,TooltipProvider as Iy}from"lecom-ui";import{createContext as Ay,useContext as Cy,useEffect as Sy,useState as My}from"react";import{jsx as xd,jsxs as Ly}from"react/jsx-runtime";var Me=new Map,Ed=Ay(null),si=()=>{let e=Cy(Ed);if(!e)throw new Error("useModeler must be used within an <ModelerProvider />");return e},Py=({locale:e,defaultMode:t="view",showNotification:o=!0,children:n})=>{let[r,i]=My(e||"pt_BR");Sy(()=>{e&&(i(e),Ny.changeLanguage(e))},[e]);let a=f=>{let y=Me.size;if(y===0)throw new Error("No modeler instances found");if(y===1||!f){let[m]=Me.values();return m}let g=Me.get(f);if(!g)throw new Error(`Modeler instance with ID "${f}" not found`);return g},s=(f,y)=>{let g=a(y);return g==null?void 0:g.selectElements(f)},l=async f=>{let y=a(f);return y==null?void 0:y.clearSelection()},c=(f,y)=>{let g=a(y);return g==null?void 0:g.configureElement(f)},d=(f,y)=>{let g=a(y);return g==null?void 0:g.getConfigureElement(f)},u=async(f,y)=>{let g=a(y);await(g==null?void 0:g.importFromMxGraph(f))},p=f=>{let y=a(f);return y==null?void 0:y.exportToMxGraph()};return xd(Ed.Provider,{value:{defaultMode:t,locale:r,selectElements:s,clearSelection:l,configureElement:c,getConfigureElement:d,importDiagram:u,exportDiagram:p},children:Ly(Iy,{children:[o&&xd(wy,{type:"toast",placement:"topRight",enableClose:!0,showProgress:!0,pauseOnHover:!0}),n]})})};import{jsx as ai}from"react/jsx-runtime";var bd=Dy(null),G=()=>{let e=Ry(bd);if(!e)throw new Error("useModelerInstance must be used within an <Modeler />");return e},Gy=({selectorRef:e,initialDiagram:t,instanceId:o,mode:n,onElementChanges:r,onConfigureElement:i,onSubprocessValidationClick:a})=>{let{defaultMode:s}=si(),l=Oy(),[c]=ke(o||l),[d,u]=ke(n||s||"edit"),[p,f]=ke(bo),[y,g]=ke(!1),[m,h]=ke(!0),[x,b]=ke(!1),[T,_]=ke(!1),[N,w]=ke(!1),[S,P]=ke(!1),[L,C]=ke(!1);Vy(()=>{n&&u(n)},[n]);let I=Hy(()=>t||cl(),[t]),M={instanceId:c,initialDiagram:I,mode:d,lastElementId:p,isInitialized:y,isMinimapOpen:T,isMoveTool:m,isHandTool:x,isDragging:N,isMultipleSelection:L,isConnecting:S,setLastElementId:f,setIsInitialized:g,setIsMinimapOpen:_,setIsMoveTool:h,setIsHandTool:b,setIsDragging:w,setIsConnecting:P,setIsMultipleSelection:C,onElementChanges:r,onConfigureElement:i,onSubprocessValidationClick:a};return ai(ky,{children:ai(bd.Provider,{value:M,children:ai(ri,{ref:e})})})};export{ge as EditorMode,lr as ElementPosition,So as ElementType,cr as GatewayElementVariant,Te as GatewayVariant,Gy as Modeler,Py as ModelerProvider,Fe as NodeAttribute,F as NodeType,_e as NodeVariant,dr as RoutingVariant,si as useModeler};