lecom-modeler 0.8.3 → 0.8.4

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 ld=Object.defineProperty,cd=Object.defineProperties;var dd=Object.getOwnPropertyDescriptors;var Eo=Object.getOwnPropertySymbols;var jr=Object.prototype.hasOwnProperty,ei=Object.prototype.propertyIsEnumerable;var Qr=(e,t,o)=>t in e?ld(e,t,{enumerable:!0,configurable:!0,writable:!0,value:o}):e[t]=o,b=(e,t)=>{for(var o in t||(t={}))jr.call(t,o)&&Qr(e,o,t[o]);if(Eo)for(var o of Eo(t))ei.call(t,o)&&Qr(e,o,t[o]);return e},v=(e,t)=>cd(e,dd(t));var Te=(e,t)=>{var o={};for(var n in e)jr.call(e,n)&&t.indexOf(n)<0&&(o[n]=e[n]);if(e!=null&&Eo)for(var n of Eo(e))t.indexOf(n)<0&&ei.call(e,n)&&(o[n]=e[n]);return o};var Xn=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 ud,Translations as pd}from"lecom-ui";var ti={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",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 oi={translations:{general:{layout:{title:"Modeler"}},editor:{toolbar:{delete:"Eliminar",configure_node:"Configurar actividad",configure_edge:"Configurar enrutamiento",initial_task:"Actividad Inicial",gateway_limit_reached:"Compuerta exclusiva no puede tener m\xE1s de 2 conexiones de salida",task_limit_reached:"Actividad no puede tener m\xE1s de 2 conexiones de salida",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 ni={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",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 ri={pt_BR:ni,en_US:ti,es_ES:oi};var ii,si,fd=(si=(ii=Xn("LecomUserLanguage"))!=null?ii:Xn("org.springframework.web.servlet.i18n.CookieLocaleResolver.LOCALE"))!=null?si:pd.PT_BR;ud({lng:fd,resources:ri});var pe=(n=>(n.EDIT="edit",n.VIEW="view",n.READONLY="readonly",n))(pe||{});var bo=(r=>(r.ACTIVITY="activity",r.ROUTING="routing",r.GATEWAY="gateway",r.SUB_PROCESS="sub_process",r))(bo||{}),Kn=(n=>(n.START="start",n.END="end",n.BETWEEN="between",n))(Kn||{}),qn=(n=>(n.SCRIPT="script",n.LOOP="loop",n.SCRIPT_LOOP="script_loop",n))(qn||{}),Zn=(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))(Zn||{});import{RotateCcw as wd,ScrollText as Ad,SquarePlus as Id}from"lucide-react";import{jsx as _o,jsxs as md}from"react/jsx-runtime";var To=({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:[_o("path",{strokeWidth:"2",d:"M16 3V3.5085V11.9998V20.4915V21H16.5411H21.4592H22V19.123H21.4592H17.9974V11.9998V4.8773H21.4592H22V3H21.4592H16.5411H16Z"}),_o("path",{d:"M4.41026 16.9999L2 18.7861L3.89693 21.1103L6.3072 19.324L4.41026 16.9999Z"}),_o("path",{d:"M8.41026 13.9999L6 15.7861L7.89693 18.1103L10.3072 16.324L8.41026 13.9999Z"}),_o("path",{d:"M12.4313 10.954L10.021 12.7402L11.9179 15.0644L14.3282 13.2781L12.4313 10.954Z"})]});import{jsx as ai}from"react/jsx-runtime";var ct=({size:e=24,className:t})=>ai("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:ai("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 Gt,jsxs as gd}from"react/jsx-runtime";var dt=({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:[Gt("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"}),Gt("path",{d:"M12 8V16",strokeLinecap:"round",strokeLinejoin:"round"}),Gt("path",{d:"M8 12H16",strokeLinecap:"round",strokeLinejoin:"round"}),Gt("path",{d:"M9.17139 9.17188L14.8282 14.8287",strokeLinecap:"round",strokeLinejoin:"round"}),Gt("path",{d:"M14.8281 9.17188L9.17127 14.8287",strokeLinecap:"round",strokeLinejoin:"round"})]});import{jsx as Jn,jsxs as hd}from"react/jsx-runtime";var ut=({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:[Jn("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"}),Jn("path",{d:"M14.8286 9.17188L9.17176 14.8287",strokeLinecap:"round",strokeLinejoin:"round"}),Jn("path",{d:"M9.17139 9.17188L14.8282 14.8287",strokeLinecap:"round",strokeLinejoin:"round"})]});import{jsx as Qn,jsxs as yd}from"react/jsx-runtime";var pt=({size:e=24,className:t})=>yd("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:[Qn("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"}),Qn("path",{d:"M12 8V16",strokeLinecap:"round",strokeLinejoin:"round"}),Qn("path",{d:"M8 12H16",strokeLinecap:"round",strokeLinejoin:"round"})]});import{jsx as jn,jsxs as xd}from"react/jsx-runtime";var li=({size:e=24,className:t})=>jn("svg",{width:e,height:e,viewBox:"0 0 34 24",xmlns:"http://www.w3.org/2000/svg",fill:"currentColor",className:t,children:xd("g",{children:[jn("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"}),jn("path",{d:"M24.5 4.5L28 1M28 1L31.5 4.5M28 1V8",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round"})]})});import{clsx as Ed}from"clsx";import{twMerge as bd}from"tailwind-merge";function D(...e){return bd(Ed(e))}var Ve=(e=0,t=0)=>e<t?t:e,No=(e=1e3)=>new Promise(t=>{setTimeout(t,e)});import{jsx as ci,jsxs as _d}from"react/jsx-runtime";var di=({size:e=24,className:t})=>_d("svg",{width:e,height:e,viewBox:"0 0 24 24",fill:"none",stroke:"#6b7280",strokeWidth:2,xmlns:"http://www.w3.org/2000/svg",className:D("stroke-2",t),children:[ci("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"}),ci("path",{d:"M9 3V21",strokeLinecap:"round",strokeLinejoin:"round"})]});import{jsx as er}from"react/jsx-runtime";var ui=({size:e=24,className:t})=>er("svg",{width:e,height:e,viewBox:"0 0 24 24",xmlns:"http://www.w3.org/2000/svg",stroke:"currentColor",className:t,children:er("g",{children:er("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 pi}from"react/jsx-runtime";var vo=({size:e=24,className:t})=>pi("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:pi("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 fi}from"react/jsx-runtime";var Bt=({size:e=24,className:t})=>fi("svg",{width:e,height:e,viewBox:"0 0 24 24",xmlns:"http://www.w3.org/2000/svg",fill:"white",stroke:"#6b7280",className:D("stroke-2",t),children:fi("path",{d:"M20 3H4C2.89543 3 2 4.34315 2 6V18C2 19.6569 2.89543 21 4 21H20C21.1046 21 22 19.6569 22 18V6C22 4.34315 21.1046 3 20 3Z",strokeLinecap:"round",strokeLinejoin:"round"})});import{jsx as tr,jsxs as Td}from"react/jsx-runtime";var mi=({size:e=24,className:t})=>Td("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:[tr("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"}),tr("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"}),tr("path",{d:"M7.5 7.5V10H10",strokeWidth:"1.5",fill:"none",strokeLinecap:"round",strokeLinejoin:"round"})]});import{jsx as zt,jsxs as Nd}from"react/jsx-runtime";var gi=({size:e=24,className:t})=>Nd("svg",{width:e,height:e,viewBox:"0 0 24 24",xmlns:"http://www.w3.org/2000/svg",fill:"white",stroke:"#6b7280",strokeWidth:"2",className:t,children:[zt("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"}),zt("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"}),zt("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"}),zt("path",{d:"M13.5 12H11",strokeWidth:"1",strokeLinecap:"round",strokeLinejoin:"round"}),zt("path",{d:"M13.5 10H11",strokeWidth:"1",strokeLinecap:"round",strokeLinejoin:"round"})]});import{jsx as wo,jsxs as vd}from"react/jsx-runtime";var hi=({size:e=24,className:t})=>vd("svg",{width:e,height:e,viewBox:"0 0 24 24",xmlns:"http://www.w3.org/2000/svg",fill:"white",stroke:"#6b7280",strokeWidth:2,className:t,children:[wo("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"}),wo("path",{d:"M8 21V14C8 13.4477 8.44772 13 9 13H15C15.5523 13 16 13.4477 16 14V21",strokeWidth:"1",fill:"none"}),wo("path",{d:"M10.2222 17H13.7777",strokeWidth:"1",strokeLinecap:"round",strokeLinejoin:"round"}),wo("path",{d:"M12 15.2227V18.7782",strokeWidth:"1",strokeLinecap:"round",strokeLinejoin:"round"})]});var O=(a=>(a.START_EVENT="START_EVENT",a.END_EVENT="END_EVENT",a.TASK="TASK",a.LANE="LANE",a.GATEWAY="GATEWAY",a.ANNOTATION="ANNOTATION",a.UNSUPPORTED="UNSUPPORTED",a))(O||{}),ge=(o=>(o.SCRIPT="SCRIPT",o.SUBPROCESS="SUBPROCESS",o))(ge||{}),Ao={SCRIPT:{icon:Ad},SUBPROCESS:{icon:Id}},Oe=(t=>(t.LOOP="LOOP",t))(Oe||{}),Io={LOOP:{icon:wd}},he=(n=>(n.EXCLUSIVE="EXCLUSIVE",n.PARALLEL="PARALLEL",n.COMPLEX="COMPLEX",n))(he||{}),or={EXCLUSIVE:{icon:ut},PARALLEL:{icon:pt},COMPLEX:{icon:dt}};import{ReactFlowProvider as by}from"@xyflow/react";import{createContext as _y,useContext as Ty,useEffect as Ny,useId as vy,useMemo as wy,useState as ke}from"react";import{Background as ey,MiniMap as ty,ReactFlow as oy,SelectionMode as ny}from"@xyflow/react";import{forwardRef as ry,useImperativeHandle as iy}from"react";import{useEdgesState as bh,useNodesState as _h,useOnSelectionChange as Th,useReactFlow as Nh}from"@xyflow/react";import{useCallback as kt,useEffect as vh,useRef as wh,useState as Ah}from"react";import{useDebouncedCallback as Ih}from"use-debounce";import{create as Cd}from"zustand";import{useReactFlow as Sd}from"@xyflow/react";import{useCallback as Md}from"react";var Co=()=>{let{setEdges:e}=Sd();return Md(()=>{let o=Xe.getState().pathEdgeIds;e(n=>n.map(r=>v(b({},r),{selected:o.includes(r.id)})))},[e])},Xe=Cd((e,t)=>({statusByNodeId:{},statusData:{},pathEdgeIds:[],setTaskStatuses:o=>{o!=null&&o.length&&e(n=>{let r=b({},n.statusByNodeId),i=b({},n.statusData),s=!1;return o.forEach(a=>{let l=`${a.diagramId}-${a.activityId}`;r[a.diagramId]!==a.status&&(r[a.diagramId]=a.status,i[l]=a,s=!0)}),s?{statusByNodeId:r,statusData:i}:n})},getTaskStatus:o=>t().statusByNodeId[o]||null,clearTaskStatuses:()=>e({statusByNodeId:{},statusData:{},pathEdgeIds:[]}),setPathEdges:o=>{e({pathEdgeIds:o})},getPathEdgeIds:()=>t().pathEdgeIds,clearPathEdges:()=>{e({pathEdgeIds:[]})},calculateFlowPath:(o,n)=>{if(!o.length||!n.length)return;t().clearPathEdges();let r=n.filter(d=>t().statusByNodeId[d]);if(r.length<=1)return;let i=[],s={};o.forEach(d=>{s[d.source]||(s[d.source]=[]),s[d.source].push({targetId:d.target,edgeId:d.id})});let a=r[0],l=r[r.length-1];o.forEach(d=>{d.target===a&&i.push(d.id)}),o.forEach(d=>{d.source===l&&i.push(d.id)});let c=(d,p)=>{let u=[],f=new Set;for(u.push({node:d,path:[]}),f.add(d);u.length>0;){let{node:y,path:g}=u.shift();if(y===p)return g;let m=s[y]||[];for(let{targetId:_,edgeId:h}of m)f.has(_)||(f.add(_),u.push({node:_,path:[...g,h]}))}return[]};for(let d=0;d<r.length-1;d++){let p=r[d],u=r[d+1],f=c(p,u);f.length>0&&i.push(...f)}i.length>0&&e({pathEdgeIds:i})}}));import{useNodesInitialized as Up,useReactFlow as $p,useStore as Xp}from"@xyflow/react";var Pd={value:()=>{}};function xi(){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 So(o)}function So(e){this._=e}function Ld(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}})}So.prototype=xi.prototype={constructor:So,on:function(e,t){var o=this._,n=Ld(e+"",o),r,i=-1,s=n.length;if(arguments.length<2){for(;++i<s;)if((r=(e=n[i]).type)&&(r=Dd(o[r],e.name)))return r;return}if(t!=null&&typeof t!="function")throw new Error("invalid callback: "+t);for(;++i<s;)if(r=(e=n[i]).type)o[r]=yi(o[r],e.name,t);else if(t==null)for(r in o)o[r]=yi(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 So(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 Dd(e,t){for(var o=0,n=e.length,r;o<n;++o)if((r=e[o]).name===t)return r.value}function yi(e,t,o){for(var n=0,r=e.length;n<r;++n)if(e[n].name===t){e[n]=Pd,e=e.slice(0,n).concat(e.slice(n+1));break}return o!=null&&e.push({name:t,value:o}),e}var nr=xi;var Mo="http://www.w3.org/1999/xhtml",rr={svg:"http://www.w3.org/2000/svg",xhtml:Mo,xlink:"http://www.w3.org/1999/xlink",xml:"http://www.w3.org/XML/1998/namespace",xmlns:"http://www.w3.org/2000/xmlns/"};function Ce(e){var t=e+="",o=t.indexOf(":");return o>=0&&(t=e.slice(0,o))!=="xmlns"&&(e=e.slice(o+1)),rr.hasOwnProperty(t)?{space:rr[t],local:e}:e}function kd(e){return function(){var t=this.ownerDocument,o=this.namespaceURI;return o===Mo&&t.documentElement.namespaceURI===Mo?t.createElement(e):t.createElementNS(o,e)}}function Rd(e){return function(){return this.ownerDocument.createElementNS(e.space,e.local)}}function Po(e){var t=Ce(e);return(t.local?Rd:kd)(t)}function Vd(){}function Ke(e){return e==null?Vd:function(){return this.querySelector(e)}}function Ei(e){typeof e!="function"&&(e=Ke(e));for(var t=this._groups,o=t.length,n=new Array(o),r=0;r<o;++r)for(var i=t[r],s=i.length,a=n[r]=new Array(s),l,c,d=0;d<s;++d)(l=i[d])&&(c=e.call(l,l.__data__,d,i))&&("__data__"in l&&(c.__data__=l.__data__),a[d]=c);return new q(n,this._parents)}function ir(e){return e==null?[]:Array.isArray(e)?e:Array.from(e)}function Od(){return[]}function Ft(e){return e==null?Od:function(){return this.querySelectorAll(e)}}function Hd(e){return function(){return ir(e.apply(this,arguments))}}function bi(e){typeof e=="function"?e=Hd(e):e=Ft(e);for(var t=this._groups,o=t.length,n=[],r=[],i=0;i<o;++i)for(var s=t[i],a=s.length,l,c=0;c<a;++c)(l=s[c])&&(n.push(e.call(l,l.__data__,c,s)),r.push(l));return new q(n,r)}function Wt(e){return function(){return this.matches(e)}}function Lo(e){return function(t){return t.matches(e)}}var Gd=Array.prototype.find;function Bd(e){return function(){return Gd.call(this.children,e)}}function zd(){return this.firstElementChild}function _i(e){return this.select(e==null?zd:Bd(typeof e=="function"?e:Lo(e)))}var Fd=Array.prototype.filter;function Wd(){return Array.from(this.children)}function Yd(e){return function(){return Fd.call(this.children,e)}}function Ti(e){return this.selectAll(e==null?Wd:Yd(typeof e=="function"?e:Lo(e)))}function Ni(e){typeof e!="function"&&(e=Wt(e));for(var t=this._groups,o=t.length,n=new Array(o),r=0;r<o;++r)for(var i=t[r],s=i.length,a=n[r]=[],l,c=0;c<s;++c)(l=i[c])&&e.call(l,l.__data__,c,i)&&a.push(l);return new q(n,this._parents)}function Do(e){return new Array(e.length)}function vi(){return new q(this._enter||this._groups.map(Do),this._parents)}function Yt(e,t){this.ownerDocument=e.ownerDocument,this.namespaceURI=e.namespaceURI,this._next=null,this._parent=e,this.__data__=t}Yt.prototype={constructor:Yt,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 wi(e){return function(){return e}}function Ud(e,t,o,n,r,i){for(var s=0,a,l=t.length,c=i.length;s<c;++s)(a=t[s])?(a.__data__=i[s],n[s]=a):o[s]=new Yt(e,i[s]);for(;s<l;++s)(a=t[s])&&(r[s]=a)}function $d(e,t,o,n,r,i,s){var a,l,c=new Map,d=t.length,p=i.length,u=new Array(d),f;for(a=0;a<d;++a)(l=t[a])&&(u[a]=f=s.call(l,l.__data__,a,t)+"",c.has(f)?r[a]=l:c.set(f,l));for(a=0;a<p;++a)f=s.call(e,i[a],a,i)+"",(l=c.get(f))?(n[a]=l,l.__data__=i[a],c.delete(f)):o[a]=new Yt(e,i[a]);for(a=0;a<d;++a)(l=t[a])&&c.get(u[a])===l&&(r[a]=l)}function Xd(e){return e.__data__}function Ai(e,t){if(!arguments.length)return Array.from(this,Xd);var o=t?$d:Ud,n=this._parents,r=this._groups;typeof e!="function"&&(e=wi(e));for(var i=r.length,s=new Array(i),a=new Array(i),l=new Array(i),c=0;c<i;++c){var d=n[c],p=r[c],u=p.length,f=Kd(e.call(d,d&&d.__data__,c,n)),y=f.length,g=a[c]=new Array(y),m=s[c]=new Array(y),_=l[c]=new Array(u);o(d,p,g,m,_,f,t);for(var h=0,E=0,T,N;h<y;++h)if(T=g[h]){for(h>=E&&(E=h+1);!(N=m[E])&&++E<y;);T._next=N||null}}return s=new q(s,n),s._enter=a,s._exit=l,s}function Kd(e){return typeof e=="object"&&"length"in e?e:Array.from(e)}function Ii(){return new q(this._exit||this._groups.map(Do),this._parents)}function Ci(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 Si(e){for(var t=e.selection?e.selection():e,o=this._groups,n=t._groups,r=o.length,i=n.length,s=Math.min(r,i),a=new Array(r),l=0;l<s;++l)for(var c=o[l],d=n[l],p=c.length,u=a[l]=new Array(p),f,y=0;y<p;++y)(f=c[y]||d[y])&&(u[y]=f);for(;l<r;++l)a[l]=o[l];return new q(a,this._parents)}function Mi(){for(var e=this._groups,t=-1,o=e.length;++t<o;)for(var n=e[t],r=n.length-1,i=n[r],s;--r>=0;)(s=n[r])&&(i&&s.compareDocumentPosition(i)^4&&i.parentNode.insertBefore(s,i),i=s);return this}function Pi(e){e||(e=qd);function t(p,u){return p&&u?e(p.__data__,u.__data__):!p-!u}for(var o=this._groups,n=o.length,r=new Array(n),i=0;i<n;++i){for(var s=o[i],a=s.length,l=r[i]=new Array(a),c,d=0;d<a;++d)(c=s[d])&&(l[d]=c);l.sort(t)}return new q(r,this._parents).order()}function qd(e,t){return e<t?-1:e>t?1:e>=t?0:NaN}function Li(){var e=arguments[0];return arguments[0]=this,e.apply(null,arguments),this}function Di(){return Array.from(this)}function ki(){for(var e=this._groups,t=0,o=e.length;t<o;++t)for(var n=e[t],r=0,i=n.length;r<i;++r){var s=n[r];if(s)return s}return null}function Ri(){let e=0;for(let t of this)++e;return e}function Vi(){return!this.node()}function Oi(e){for(var t=this._groups,o=0,n=t.length;o<n;++o)for(var r=t[o],i=0,s=r.length,a;i<s;++i)(a=r[i])&&e.call(a,a.__data__,i,r);return this}function Zd(e){return function(){this.removeAttribute(e)}}function Jd(e){return function(){this.removeAttributeNS(e.space,e.local)}}function Qd(e,t){return function(){this.setAttribute(e,t)}}function jd(e,t){return function(){this.setAttributeNS(e.space,e.local,t)}}function eu(e,t){return function(){var o=t.apply(this,arguments);o==null?this.removeAttribute(e):this.setAttribute(e,o)}}function tu(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 Hi(e,t){var o=Ce(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?Jd:Zd:typeof t=="function"?o.local?tu:eu:o.local?jd:Qd)(o,t))}function ko(e){return e.ownerDocument&&e.ownerDocument.defaultView||e.document&&e||e.defaultView}function ou(e){return function(){this.style.removeProperty(e)}}function nu(e,t,o){return function(){this.style.setProperty(e,t,o)}}function ru(e,t,o){return function(){var n=t.apply(this,arguments);n==null?this.style.removeProperty(e):this.style.setProperty(e,n,o)}}function Gi(e,t,o){return arguments.length>1?this.each((t==null?ou:typeof t=="function"?ru:nu)(e,t,o==null?"":o)):He(this.node(),e)}function He(e,t){return e.style.getPropertyValue(t)||ko(e).getComputedStyle(e,null).getPropertyValue(t)}function iu(e){return function(){delete this[e]}}function su(e,t){return function(){this[e]=t}}function au(e,t){return function(){var o=t.apply(this,arguments);o==null?delete this[e]:this[e]=o}}function Bi(e,t){return arguments.length>1?this.each((t==null?iu:typeof t=="function"?au:su)(e,t)):this.node()[e]}function zi(e){return e.trim().split(/^|\s+/)}function sr(e){return e.classList||new Fi(e)}function Fi(e){this._node=e,this._names=zi(e.getAttribute("class")||"")}Fi.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 Wi(e,t){for(var o=sr(e),n=-1,r=t.length;++n<r;)o.add(t[n])}function Yi(e,t){for(var o=sr(e),n=-1,r=t.length;++n<r;)o.remove(t[n])}function lu(e){return function(){Wi(this,e)}}function cu(e){return function(){Yi(this,e)}}function du(e,t){return function(){(t.apply(this,arguments)?Wi:Yi)(this,e)}}function Ui(e,t){var o=zi(e+"");if(arguments.length<2){for(var n=sr(this.node()),r=-1,i=o.length;++r<i;)if(!n.contains(o[r]))return!1;return!0}return this.each((typeof t=="function"?du:t?lu:cu)(o,t))}function uu(){this.textContent=""}function pu(e){return function(){this.textContent=e}}function fu(e){return function(){var t=e.apply(this,arguments);this.textContent=t==null?"":t}}function $i(e){return arguments.length?this.each(e==null?uu:(typeof e=="function"?fu:pu)(e)):this.node().textContent}function mu(){this.innerHTML=""}function gu(e){return function(){this.innerHTML=e}}function hu(e){return function(){var t=e.apply(this,arguments);this.innerHTML=t==null?"":t}}function Xi(e){return arguments.length?this.each(e==null?mu:(typeof e=="function"?hu:gu)(e)):this.node().innerHTML}function yu(){this.nextSibling&&this.parentNode.appendChild(this)}function Ki(){return this.each(yu)}function xu(){this.previousSibling&&this.parentNode.insertBefore(this,this.parentNode.firstChild)}function qi(){return this.each(xu)}function Zi(e){var t=typeof e=="function"?e:Po(e);return this.select(function(){return this.appendChild(t.apply(this,arguments))})}function Eu(){return null}function Ji(e,t){var o=typeof e=="function"?e:Po(e),n=t==null?Eu:typeof t=="function"?t:Ke(t);return this.select(function(){return this.insertBefore(o.apply(this,arguments),n.apply(this,arguments)||null)})}function bu(){var e=this.parentNode;e&&e.removeChild(this)}function Qi(){return this.each(bu)}function _u(){var e=this.cloneNode(!1),t=this.parentNode;return t?t.insertBefore(e,this.nextSibling):e}function Tu(){var e=this.cloneNode(!0),t=this.parentNode;return t?t.insertBefore(e,this.nextSibling):e}function ji(e){return this.select(e?Tu:_u)}function es(e){return arguments.length?this.property("__data__",e):this.node().__data__}function Nu(e){return function(t){e.call(this,t,this.__data__)}}function vu(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 wu(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 Au(e,t,o){return function(){var n=this.__on,r,i=Nu(t);if(n){for(var s=0,a=n.length;s<a;++s)if((r=n[s]).type===e.type&&r.name===e.name){this.removeEventListener(r.type,r.listener,r.options),this.addEventListener(r.type,r.listener=i,r.options=o),r.value=t;return}}this.addEventListener(e.type,i,o),r={type:e.type,name:e.name,value:t,listener:i,options:o},n?n.push(r):this.__on=[r]}}function ts(e,t,o){var n=vu(e+""),r,i=n.length,s;if(arguments.length<2){var a=this.node().__on;if(a){for(var l=0,c=a.length,d;l<c;++l)for(r=0,d=a[l];r<i;++r)if((s=n[r]).type===d.type&&s.name===d.name)return d.value}return}for(a=t?Au:wu,r=0;r<i;++r)this.each(a(n[r],t,o));return this}function os(e,t,o){var n=ko(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 Iu(e,t){return function(){return os(this,e,t)}}function Cu(e,t){return function(){return os(this,e,t.apply(this,arguments))}}function ns(e,t){return this.each((typeof t=="function"?Cu:Iu)(e,t))}function*rs(){for(var e=this._groups,t=0,o=e.length;t<o;++t)for(var n=e[t],r=0,i=n.length,s;r<i;++r)(s=n[r])&&(yield s)}var Su=[null];function q(e,t){this._groups=e,this._parents=t}function is(){return new q([[document.documentElement]],Su)}function Mu(){return this}q.prototype=is.prototype={constructor:q,select:Ei,selectAll:bi,selectChild:_i,selectChildren:Ti,filter:Ni,data:Ai,enter:vi,exit:Ii,join:Ci,merge:Si,selection:Mu,order:Mi,sort:Pi,call:Li,nodes:Di,node:ki,size:Ri,empty:Vi,each:Oi,attr:Hi,style:Gi,property:Bi,classed:Ui,text:$i,html:Xi,raise:Ki,lower:qi,append:Zi,insert:Ji,remove:Qi,clone:ji,datum:es,on:ts,dispatch:ns,[Symbol.iterator]:rs};var Se=is;function Ro(e,t,o){e.prototype=t.prototype=o,o.constructor=e}function ar(e,t){var o=Object.create(e.prototype);for(var n in t)o[n]=t[n];return o}function Xt(){}var Ut=.7,Ho=1/Ut,ft="\\s*([+-]?\\d+)\\s*",$t="\\s*([+-]?(?:\\d*\\.)?\\d+(?:[eE][+-]?\\d+)?)\\s*",Ne="\\s*([+-]?(?:\\d*\\.)?\\d+(?:[eE][+-]?\\d+)?)%\\s*",Pu=/^#([0-9a-f]{3,8})$/,Lu=new RegExp(`^rgb\\(${ft},${ft},${ft}\\)$`),Du=new RegExp(`^rgb\\(${Ne},${Ne},${Ne}\\)$`),ku=new RegExp(`^rgba\\(${ft},${ft},${ft},${$t}\\)$`),Ru=new RegExp(`^rgba\\(${Ne},${Ne},${Ne},${$t}\\)$`),Vu=new RegExp(`^hsl\\(${$t},${Ne},${Ne}\\)$`),Ou=new RegExp(`^hsla\\(${$t},${Ne},${Ne},${$t}\\)$`),ss={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};Ro(Xt,Ge,{copy(e){return Object.assign(new this.constructor,this,e)},displayable(){return this.rgb().displayable()},hex:as,formatHex:as,formatHex8:Hu,formatHsl:Gu,formatRgb:ls,toString:ls});function as(){return this.rgb().formatHex()}function Hu(){return this.rgb().formatHex8()}function Gu(){return ms(this).formatHsl()}function ls(){return this.rgb().formatRgb()}function Ge(e){var t,o;return e=(e+"").trim().toLowerCase(),(t=Pu.exec(e))?(o=t[1].length,t=parseInt(t[1],16),o===6?cs(t):o===3?new ie(t>>8&15|t>>4&240,t>>4&15|t&240,(t&15)<<4|t&15,1):o===8?Vo(t>>24&255,t>>16&255,t>>8&255,(t&255)/255):o===4?Vo(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=Lu.exec(e))?new ie(t[1],t[2],t[3],1):(t=Du.exec(e))?new ie(t[1]*255/100,t[2]*255/100,t[3]*255/100,1):(t=ku.exec(e))?Vo(t[1],t[2],t[3],t[4]):(t=Ru.exec(e))?Vo(t[1]*255/100,t[2]*255/100,t[3]*255/100,t[4]):(t=Vu.exec(e))?ps(t[1],t[2]/100,t[3]/100,1):(t=Ou.exec(e))?ps(t[1],t[2]/100,t[3]/100,t[4]):ss.hasOwnProperty(e)?cs(ss[e]):e==="transparent"?new ie(NaN,NaN,NaN,0):null}function cs(e){return new ie(e>>16&255,e>>8&255,e&255,1)}function Vo(e,t,o,n){return n<=0&&(e=t=o=NaN),new ie(e,t,o,n)}function Bu(e){return e instanceof Xt||(e=Ge(e)),e?(e=e.rgb(),new ie(e.r,e.g,e.b,e.opacity)):new ie}function mt(e,t,o,n){return arguments.length===1?Bu(e):new ie(e,t,o,n==null?1:n)}function ie(e,t,o,n){this.r=+e,this.g=+t,this.b=+o,this.opacity=+n}Ro(ie,mt,ar(Xt,{brighter(e){return e=e==null?Ho:Math.pow(Ho,e),new ie(this.r*e,this.g*e,this.b*e,this.opacity)},darker(e){return e=e==null?Ut:Math.pow(Ut,e),new ie(this.r*e,this.g*e,this.b*e,this.opacity)},rgb(){return this},clamp(){return new ie(Ze(this.r),Ze(this.g),Ze(this.b),Go(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:ds,formatHex:ds,formatHex8:zu,formatRgb:us,toString:us}));function ds(){return`#${qe(this.r)}${qe(this.g)}${qe(this.b)}`}function zu(){return`#${qe(this.r)}${qe(this.g)}${qe(this.b)}${qe((isNaN(this.opacity)?1:this.opacity)*255)}`}function us(){let e=Go(this.opacity);return`${e===1?"rgb(":"rgba("}${Ze(this.r)}, ${Ze(this.g)}, ${Ze(this.b)}${e===1?")":`, ${e})`}`}function Go(e){return isNaN(e)?1:Math.max(0,Math.min(1,e))}function Ze(e){return Math.max(0,Math.min(255,Math.round(e)||0))}function qe(e){return e=Ze(e),(e<16?"0":"")+e.toString(16)}function ps(e,t,o,n){return n<=0?e=t=o=NaN:o<=0||o>=1?e=t=NaN:t<=0&&(e=NaN),new ye(e,t,o,n)}function ms(e){if(e instanceof ye)return new ye(e.h,e.s,e.l,e.opacity);if(e instanceof Xt||(e=Ge(e)),!e)return new ye;if(e instanceof ye)return e;e=e.rgb();var t=e.r/255,o=e.g/255,n=e.b/255,r=Math.min(t,o,n),i=Math.max(t,o,n),s=NaN,a=i-r,l=(i+r)/2;return a?(t===i?s=(o-n)/a+(o<n)*6:o===i?s=(n-t)/a+2:s=(t-o)/a+4,a/=l<.5?i+r:2-i-r,s*=60):a=l>0&&l<1?0:s,new ye(s,a,l,e.opacity)}function gs(e,t,o,n){return arguments.length===1?ms(e):new ye(e,t,o,n==null?1:n)}function ye(e,t,o,n){this.h=+e,this.s=+t,this.l=+o,this.opacity=+n}Ro(ye,gs,ar(Xt,{brighter(e){return e=e==null?Ho:Math.pow(Ho,e),new ye(this.h,this.s,this.l*e,this.opacity)},darker(e){return e=e==null?Ut:Math.pow(Ut,e),new ye(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 ie(lr(e>=240?e-240:e+120,r,n),lr(e,r,n),lr(e<120?e+240:e-120,r,n),this.opacity)},clamp(){return new ye(fs(this.h),Oo(this.s),Oo(this.l),Go(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=Go(this.opacity);return`${e===1?"hsl(":"hsla("}${fs(this.h)}, ${Oo(this.s)*100}%, ${Oo(this.l)*100}%${e===1?")":`, ${e})`}`}}));function fs(e){return e=(e||0)%360,e<0?e+360:e}function Oo(e){return Math.max(0,Math.min(1,e||0))}function lr(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 cr(e,t,o,n,r){var i=e*e,s=i*e;return((1-3*e+3*i-s)*t+(4-6*i+3*s)*o+(1+3*e+3*i-3*s)*n+s*r)/6}function hs(e){var t=e.length-1;return function(o){var n=o<=0?o=0:o>=1?(o=1,t-1):Math.floor(o*t),r=e[n],i=e[n+1],s=n>0?e[n-1]:2*r-i,a=n<t-1?e[n+2]:2*i-r;return cr((o-n/t)*t,s,r,i,a)}}function ys(e){var t=e.length;return function(o){var n=Math.floor(((o%=1)<0?++o:o)*t),r=e[(n+t-1)%t],i=e[n%t],s=e[(n+1)%t],a=e[(n+2)%t];return cr((o-n/t)*t,r,i,s,a)}}var dr=e=>()=>e;function Fu(e,t){return function(o){return e+o*t}}function Wu(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 xs(e){return(e=+e)==1?Bo:function(t,o){return o-t?Wu(t,o,e):dr(isNaN(t)?o:t)}}function Bo(e,t){var o=t-e;return o?Fu(e,o):dr(isNaN(e)?t:e)}var zo=function e(t){var o=xs(t);function n(r,i){var s=o((r=mt(r)).r,(i=mt(i)).r),a=o(r.g,i.g),l=o(r.b,i.b),c=Bo(r.opacity,i.opacity);return function(d){return r.r=s(d),r.g=a(d),r.b=l(d),r.opacity=c(d),r+""}}return n.gamma=e,n}(1);function Es(e){return function(t){var o=t.length,n=new Array(o),r=new Array(o),i=new Array(o),s,a;for(s=0;s<o;++s)a=mt(t[s]),n[s]=a.r||0,r[s]=a.g||0,i[s]=a.b||0;return n=e(n),r=e(r),i=e(i),a.opacity=1,function(l){return a.r=n(l),a.g=r(l),a.b=i(l),a+""}}}var Yu=Es(hs),Uu=Es(ys);function fe(e,t){return e=+e,t=+t,function(o){return e*(1-o)+t*o}}var pr=/[-+]?(?:\d+\.?\d*|\.?\d+)(?:[eE][-+]?\d+)?/g,ur=new RegExp(pr.source,"g");function $u(e){return function(){return e}}function Xu(e){return function(t){return e(t)+""}}function fr(e,t){var o=pr.lastIndex=ur.lastIndex=0,n,r,i,s=-1,a=[],l=[];for(e=e+"",t=t+"";(n=pr.exec(e))&&(r=ur.exec(t));)(i=r.index)>o&&(i=t.slice(o,i),a[s]?a[s]+=i:a[++s]=i),(n=n[0])===(r=r[0])?a[s]?a[s]+=r:a[++s]=r:(a[++s]=null,l.push({i:s,x:fe(n,r)})),o=ur.lastIndex;return o<t.length&&(i=t.slice(o),a[s]?a[s]+=i:a[++s]=i),a.length<2?l[0]?Xu(l[0].x):$u(t):(t=l.length,function(c){for(var d=0,p;d<t;++d)a[(p=l[d]).i]=p.x(c);return a.join("")})}var bs=180/Math.PI,Fo={translateX:0,translateY:0,rotate:0,skewX:0,scaleX:1,scaleY:1};function mr(e,t,o,n,r,i){var s,a,l;return(s=Math.sqrt(e*e+t*t))&&(e/=s,t/=s),(l=e*o+t*n)&&(o-=e*l,n-=t*l),(a=Math.sqrt(o*o+n*n))&&(o/=a,n/=a,l/=a),e*n<t*o&&(e=-e,t=-t,l=-l,s=-s),{translateX:r,translateY:i,rotate:Math.atan2(t,e)*bs,skewX:Math.atan(l)*bs,scaleX:s,scaleY:a}}var Wo;function _s(e){let t=new(typeof DOMMatrix=="function"?DOMMatrix:WebKitCSSMatrix)(e+"");return t.isIdentity?Fo:mr(t.a,t.b,t.c,t.d,t.e,t.f)}function Ts(e){return e==null?Fo:(Wo||(Wo=document.createElementNS("http://www.w3.org/2000/svg","g")),Wo.setAttribute("transform",e),(e=Wo.transform.baseVal.consolidate())?(e=e.matrix,mr(e.a,e.b,e.c,e.d,e.e,e.f)):Fo)}function Ns(e,t,o,n){function r(c){return c.length?c.pop()+" ":""}function i(c,d,p,u,f,y){if(c!==p||d!==u){var g=f.push("translate(",null,t,null,o);y.push({i:g-4,x:fe(c,p)},{i:g-2,x:fe(d,u)})}else(p||u)&&f.push("translate("+p+t+u+o)}function s(c,d,p,u){c!==d?(c-d>180?d+=360:d-c>180&&(c+=360),u.push({i:p.push(r(p)+"rotate(",null,n)-2,x:fe(c,d)})):d&&p.push(r(p)+"rotate("+d+n)}function a(c,d,p,u){c!==d?u.push({i:p.push(r(p)+"skewX(",null,n)-2,x:fe(c,d)}):d&&p.push(r(p)+"skewX("+d+n)}function l(c,d,p,u,f,y){if(c!==p||d!==u){var g=f.push(r(f)+"scale(",null,",",null,")");y.push({i:g-4,x:fe(c,p)},{i:g-2,x:fe(d,u)})}else(p!==1||u!==1)&&f.push(r(f)+"scale("+p+","+u+")")}return function(c,d){var p=[],u=[];return c=e(c),d=e(d),i(c.translateX,c.translateY,d.translateX,d.translateY,p,u),s(c.rotate,d.rotate,p,u),a(c.skewX,d.skewX,p,u),l(c.scaleX,c.scaleY,d.scaleX,d.scaleY,p,u),c=d=null,function(f){for(var y=-1,g=u.length,m;++y<g;)p[(m=u[y]).i]=m.x(f);return p.join("")}}}var gr=Ns(_s,"px, ","px)","deg)"),hr=Ns(Ts,", ",")",")");var gt=0,qt=0,Kt=0,ws=1e3,Yo,Zt,Uo=0,Je=0,$o=0,Jt=typeof performance=="object"&&performance.now?performance:Date,As=typeof window=="object"&&window.requestAnimationFrame?window.requestAnimationFrame.bind(window):function(e){setTimeout(e,17)};function jt(){return Je||(As(Ku),Je=Jt.now()+$o)}function Ku(){Je=0}function Qt(){this._call=this._time=this._next=null}Qt.prototype=Xo.prototype={constructor:Qt,restart:function(e,t,o){if(typeof e!="function")throw new TypeError("callback is not a function");o=(o==null?jt():+o)+(t==null?0:+t),!this._next&&Zt!==this&&(Zt?Zt._next=this:Yo=this,Zt=this),this._call=e,this._time=o,yr()},stop:function(){this._call&&(this._call=null,this._time=1/0,yr())}};function Xo(e,t,o){var n=new Qt;return n.restart(e,t,o),n}function Is(){jt(),++gt;for(var e=Yo,t;e;)(t=Je-e._time)>=0&&e._call.call(void 0,t),e=e._next;--gt}function vs(){Je=(Uo=Jt.now())+$o,gt=qt=0;try{Is()}finally{gt=0,Zu(),Je=0}}function qu(){var e=Jt.now(),t=e-Uo;t>ws&&($o-=t,Uo=e)}function Zu(){for(var e,t=Yo,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:Yo=o);Zt=e,yr(n)}function yr(e){if(!gt){qt&&(qt=clearTimeout(qt));var t=e-Je;t>24?(e<1/0&&(qt=setTimeout(vs,e-Jt.now()-$o)),Kt&&(Kt=clearInterval(Kt))):(Kt||(Uo=Jt.now(),Kt=setInterval(qu,ws)),gt=1,As(vs))}}function Ko(e,t,o){var n=new Qt;return t=t==null?0:+t,n.restart(r=>{n.stop(),e(r+t)},t,o),n}var Ju=nr("start","end","cancel","interrupt"),Qu=[],Ms=0,Cs=1,Zo=2,qo=3,Ss=4,Jo=5,eo=6;function Be(e,t,o,n,r,i){var s=e.__transition;if(!s)e.__transition={};else if(o in s)return;ju(e,o,{name:t,index:n,group:r,on:Ju,tween:Qu,time:i.time,delay:i.delay,duration:i.duration,ease:i.ease,timer:null,state:Ms})}function to(e,t){var o=Z(e,t);if(o.state>Ms)throw new Error("too late; already scheduled");return o}function j(e,t){var o=Z(e,t);if(o.state>qo)throw new Error("too late; already running");return o}function Z(e,t){var o=e.__transition;if(!o||!(o=o[t]))throw new Error("transition not found");return o}function ju(e,t,o){var n=e.__transition,r;n[t]=o,o.timer=Xo(i,0,o.time);function i(c){o.state=Cs,o.timer.restart(s,o.delay,o.time),o.delay<=c&&s(c-o.delay)}function s(c){var d,p,u,f;if(o.state!==Cs)return l();for(d in n)if(f=n[d],f.name===o.name){if(f.state===qo)return Ko(s);f.state===Ss?(f.state=eo,f.timer.stop(),f.on.call("interrupt",e,e.__data__,f.index,f.group),delete n[d]):+d<t&&(f.state=eo,f.timer.stop(),f.on.call("cancel",e,e.__data__,f.index,f.group),delete n[d])}if(Ko(function(){o.state===qo&&(o.state=Ss,o.timer.restart(a,o.delay,o.time),a(c))}),o.state=Zo,o.on.call("start",e,e.__data__,o.index,o.group),o.state===Zo){for(o.state=qo,r=new Array(u=o.tween.length),d=0,p=-1;d<u;++d)(f=o.tween[d].value.call(e,e.__data__,o.index,o.group))&&(r[++p]=f);r.length=p+1}}function a(c){for(var d=c<o.duration?o.ease.call(null,c/o.duration):(o.timer.restart(l),o.state=Jo,1),p=-1,u=r.length;++p<u;)r[p].call(e,d);o.state===Jo&&(o.on.call("end",e,e.__data__,o.index,o.group),l())}function l(){o.state=eo,o.timer.stop(),delete n[t];for(var c in n)return;delete e.__transition}}function xr(e,t){var o=e.__transition,n,r,i=!0,s;if(o){t=t==null?null:t+"";for(s in o){if((n=o[s]).name!==t){i=!1;continue}r=n.state>Zo&&n.state<Jo,n.state=eo,n.timer.stop(),n.on.call(r?"interrupt":"cancel",e,e.__data__,n.index,n.group),delete o[s]}i&&delete e.__transition}}function Ps(e){return this.each(function(){xr(this,e)})}function ep(e,t){var o,n;return function(){var r=j(this,e),i=r.tween;if(i!==o){n=o=i;for(var s=0,a=n.length;s<a;++s)if(n[s].name===t){n=n.slice(),n.splice(s,1);break}}r.tween=n}}function tp(e,t,o){var n,r;if(typeof o!="function")throw new Error;return function(){var i=j(this,e),s=i.tween;if(s!==n){r=(n=s).slice();for(var a={name:t,value:o},l=0,c=r.length;l<c;++l)if(r[l].name===t){r[l]=a;break}l===c&&r.push(a)}i.tween=r}}function Ls(e,t){var o=this._id;if(e+="",arguments.length<2){for(var n=Z(this.node(),o).tween,r=0,i=n.length,s;r<i;++r)if((s=n[r]).name===e)return s.value;return null}return this.each((t==null?ep:tp)(o,e,t))}function ht(e,t,o){var n=e._id;return e.each(function(){var r=j(this,n);(r.value||(r.value={}))[t]=o.apply(this,arguments)}),function(r){return Z(r,n).value[t]}}function Qo(e,t){var o;return(typeof t=="number"?fe:t instanceof Ge?zo:(o=Ge(t))?(t=o,zo):fr)(e,t)}function op(e){return function(){this.removeAttribute(e)}}function np(e){return function(){this.removeAttributeNS(e.space,e.local)}}function rp(e,t,o){var n,r=o+"",i;return function(){var s=this.getAttribute(e);return s===r?null:s===n?i:i=t(n=s,o)}}function ip(e,t,o){var n,r=o+"",i;return function(){var s=this.getAttributeNS(e.space,e.local);return s===r?null:s===n?i:i=t(n=s,o)}}function sp(e,t,o){var n,r,i;return function(){var s,a=o(this),l;return a==null?void this.removeAttribute(e):(s=this.getAttribute(e),l=a+"",s===l?null:s===n&&l===r?i:(r=l,i=t(n=s,a)))}}function ap(e,t,o){var n,r,i;return function(){var s,a=o(this),l;return a==null?void this.removeAttributeNS(e.space,e.local):(s=this.getAttributeNS(e.space,e.local),l=a+"",s===l?null:s===n&&l===r?i:(r=l,i=t(n=s,a)))}}function Ds(e,t){var o=Ce(e),n=o==="transform"?hr:Qo;return this.attrTween(e,typeof t=="function"?(o.local?ap:sp)(o,n,ht(this,"attr."+e,t)):t==null?(o.local?np:op)(o):(o.local?ip:rp)(o,n,t))}function lp(e,t){return function(o){this.setAttribute(e,t.call(this,o))}}function cp(e,t){return function(o){this.setAttributeNS(e.space,e.local,t.call(this,o))}}function dp(e,t){var o,n;function r(){var i=t.apply(this,arguments);return i!==n&&(o=(n=i)&&cp(e,i)),o}return r._value=t,r}function up(e,t){var o,n;function r(){var i=t.apply(this,arguments);return i!==n&&(o=(n=i)&&lp(e,i)),o}return r._value=t,r}function ks(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=Ce(e);return this.tween(o,(n.local?dp:up)(n,t))}function pp(e,t){return function(){to(this,e).delay=+t.apply(this,arguments)}}function fp(e,t){return t=+t,function(){to(this,e).delay=t}}function Rs(e){var t=this._id;return arguments.length?this.each((typeof e=="function"?pp:fp)(t,e)):Z(this.node(),t).delay}function mp(e,t){return function(){j(this,e).duration=+t.apply(this,arguments)}}function gp(e,t){return t=+t,function(){j(this,e).duration=t}}function Vs(e){var t=this._id;return arguments.length?this.each((typeof e=="function"?mp:gp)(t,e)):Z(this.node(),t).duration}function hp(e,t){if(typeof t!="function")throw new Error;return function(){j(this,e).ease=t}}function Os(e){var t=this._id;return arguments.length?this.each(hp(t,e)):Z(this.node(),t).ease}function yp(e,t){return function(){var o=t.apply(this,arguments);if(typeof o!="function")throw new Error;j(this,e).ease=o}}function Hs(e){if(typeof e!="function")throw new Error;return this.each(yp(this._id,e))}function Gs(e){typeof e!="function"&&(e=Wt(e));for(var t=this._groups,o=t.length,n=new Array(o),r=0;r<o;++r)for(var i=t[r],s=i.length,a=n[r]=[],l,c=0;c<s;++c)(l=i[c])&&e.call(l,l.__data__,c,i)&&a.push(l);return new ne(n,this._parents,this._name,this._id)}function Bs(e){if(e._id!==this._id)throw new Error;for(var t=this._groups,o=e._groups,n=t.length,r=o.length,i=Math.min(n,r),s=new Array(n),a=0;a<i;++a)for(var l=t[a],c=o[a],d=l.length,p=s[a]=new Array(d),u,f=0;f<d;++f)(u=l[f]||c[f])&&(p[f]=u);for(;a<n;++a)s[a]=t[a];return new ne(s,this._parents,this._name,this._id)}function xp(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 Ep(e,t,o){var n,r,i=xp(t)?to:j;return function(){var s=i(this,e),a=s.on;a!==n&&(r=(n=a).copy()).on(t,o),s.on=r}}function zs(e,t){var o=this._id;return arguments.length<2?Z(this.node(),o).on.on(e):this.each(Ep(o,e,t))}function bp(e){return function(){var t=this.parentNode;for(var o in this.__transition)if(+o!==e)return;t&&t.removeChild(this)}}function Fs(){return this.on("end.remove",bp(this._id))}function Ws(e){var t=this._name,o=this._id;typeof e!="function"&&(e=Ke(e));for(var n=this._groups,r=n.length,i=new Array(r),s=0;s<r;++s)for(var a=n[s],l=a.length,c=i[s]=new Array(l),d,p,u=0;u<l;++u)(d=a[u])&&(p=e.call(d,d.__data__,u,a))&&("__data__"in d&&(p.__data__=d.__data__),c[u]=p,Be(c[u],t,o,u,c,Z(d,o)));return new ne(i,this._parents,t,o)}function Ys(e){var t=this._name,o=this._id;typeof e!="function"&&(e=Ft(e));for(var n=this._groups,r=n.length,i=[],s=[],a=0;a<r;++a)for(var l=n[a],c=l.length,d,p=0;p<c;++p)if(d=l[p]){for(var u=e.call(d,d.__data__,p,l),f,y=Z(d,o),g=0,m=u.length;g<m;++g)(f=u[g])&&Be(f,t,o,g,u,y);i.push(u),s.push(d)}return new ne(i,s,t,o)}var _p=Se.prototype.constructor;function Us(){return new _p(this._groups,this._parents)}function Tp(e,t){var o,n,r;return function(){var i=He(this,e),s=(this.style.removeProperty(e),He(this,e));return i===s?null:i===o&&s===n?r:r=t(o=i,n=s)}}function $s(e){return function(){this.style.removeProperty(e)}}function Np(e,t,o){var n,r=o+"",i;return function(){var s=He(this,e);return s===r?null:s===n?i:i=t(n=s,o)}}function vp(e,t,o){var n,r,i;return function(){var s=He(this,e),a=o(this),l=a+"";return a==null&&(l=a=(this.style.removeProperty(e),He(this,e))),s===l?null:s===n&&l===r?i:(r=l,i=t(n=s,a))}}function wp(e,t){var o,n,r,i="style."+t,s="end."+i,a;return function(){var l=j(this,e),c=l.on,d=l.value[i]==null?a||(a=$s(t)):void 0;(c!==o||r!==d)&&(n=(o=c).copy()).on(s,r=d),l.on=n}}function Xs(e,t,o){var n=(e+="")=="transform"?gr:Qo;return t==null?this.styleTween(e,Tp(e,n)).on("end.style."+e,$s(e)):typeof t=="function"?this.styleTween(e,vp(e,n,ht(this,"style."+e,t))).each(wp(this._id,e)):this.styleTween(e,Np(e,n,t),o).on("end.style."+e,null)}function Ap(e,t,o){return function(n){this.style.setProperty(e,t.call(this,n),o)}}function Ip(e,t,o){var n,r;function i(){var s=t.apply(this,arguments);return s!==r&&(n=(r=s)&&Ap(e,s,o)),n}return i._value=t,i}function Ks(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,Ip(e,t,o==null?"":o))}function Cp(e){return function(){this.textContent=e}}function Sp(e){return function(){var t=e(this);this.textContent=t==null?"":t}}function qs(e){return this.tween("text",typeof e=="function"?Sp(ht(this,"text",e)):Cp(e==null?"":e+""))}function Mp(e){return function(t){this.textContent=e.call(this,t)}}function Pp(e){var t,o;function n(){var r=e.apply(this,arguments);return r!==o&&(t=(o=r)&&Mp(r)),t}return n._value=e,n}function Zs(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,Pp(e))}function Js(){for(var e=this._name,t=this._id,o=jo(),n=this._groups,r=n.length,i=0;i<r;++i)for(var s=n[i],a=s.length,l,c=0;c<a;++c)if(l=s[c]){var d=Z(l,t);Be(l,e,o,c,s,{time:d.time+d.delay+d.duration,delay:0,duration:d.duration,ease:d.ease})}return new ne(n,this._parents,e,o)}function Qs(){var e,t,o=this,n=o._id,r=o.size();return new Promise(function(i,s){var a={value:s},l={value:function(){--r===0&&i()}};o.each(function(){var c=j(this,n),d=c.on;d!==e&&(t=(e=d).copy(),t._.cancel.push(a),t._.interrupt.push(a),t._.end.push(l)),c.on=t}),r===0&&i()})}var Lp=0;function ne(e,t,o,n){this._groups=e,this._parents=t,this._name=o,this._id=n}function js(e){return Se().transition(e)}function jo(){return++Lp}var Me=Se.prototype;ne.prototype=js.prototype={constructor:ne,select:Ws,selectAll:Ys,selectChild:Me.selectChild,selectChildren:Me.selectChildren,filter:Gs,merge:Bs,selection:Us,transition:Js,call:Me.call,nodes:Me.nodes,node:Me.node,size:Me.size,empty:Me.empty,each:Me.each,on:zs,attr:Ds,attrTween:ks,style:Xs,styleTween:Ks,text:qs,textTween:Zs,remove:Fs,tween:Ls,delay:Rs,duration:Vs,ease:Os,easeVarying:Hs,end:Qs,[Symbol.iterator]:Me[Symbol.iterator]};function en(e){return((e*=2)<=1?e*e*e:(e-=2)*e*e+2)/2}var Dp={time:null,delay:0,duration:250,ease:en};function kp(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 ea(e){var t,o;e instanceof ne?(t=e._id,e=e._name):(t=jo(),(o=Dp).time=jt(),e=e==null?null:e+"");for(var n=this._groups,r=n.length,i=0;i<r;++i)for(var s=n[i],a=s.length,l,c=0;c<a;++c)(l=s[c])&&Be(l,e,t,c,s,o||kp(l,t));return new ne(n,this._parents,e,t)}Se.prototype.interrupt=Ps;Se.prototype.transition=ea;function ze(e,t,o){this.k=e,this.x=t,this.y=o}ze.prototype={constructor:ze,scale:function(e){return e===1?this:new ze(this.k*e,this.x,this.y)},translate:function(e,t){return e===0&t===0?this:new ze(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 tn=new ze(1,0,0);on.prototype=ze.prototype;function on(e){for(;!e.__zoom;)if(!(e=e.parentNode))return tn;return e.__zoom}var Vp=[[Number.NEGATIVE_INFINITY,Number.NEGATIVE_INFINITY],[Number.POSITIVE_INFINITY,Number.POSITIVE_INFINITY]];var ta;(function(e){e.Strict="strict",e.Loose="loose"})(ta||(ta={}));var oa;(function(e){e.Free="free",e.Vertical="vertical",e.Horizontal="horizontal"})(oa||(oa={}));var na;(function(e){e.Partial="partial",e.Full="full"})(na||(na={}));var ra;(function(e){e.Bezier="default",e.Straight="straight",e.Step="step",e.SmoothStep="smoothstep",e.SimpleBezier="simplebezier"})(ra||(ra={}));var ia;(function(e){e.Arrow="arrow",e.ArrowClosed="arrowclosed"})(ia||(ia={}));var se;(function(e){e.Left="left",e.Top="top",e.Right="right",e.Bottom="bottom"})(se||(se={}));var tN={[se.Left]:se.Right,[se.Right]:se.Left,[se.Top]:se.Bottom,[se.Bottom]:se.Top};var Op=e=>"id"in e&&"internals"in e&&!("source"in e)&&!("target"in e);var Hp=(e,t=[0,0])=>{var a;let{width:o,height:n}=Gp(e),r=(a=e.origin)!=null?a:t,i=o*r[0],s=n*r[1];return{x:e.position.x-i,y:e.position.y-s}};var de=(e,t=[0,0])=>{var r,i,s,a,l,c,d,p;let{x:o,y:n}=Op(e)?e.internals.positionAbsolute:Hp(e,t);return{x:o,y:n,x2:o+((a=(s=(i=(r=e.measured)==null?void 0:r.width)!=null?i:e.width)!=null?s:e.initialWidth)!=null?a:0),y2:n+((p=(d=(c=(l=e.measured)==null?void 0:l.height)!=null?c:e.height)!=null?d:e.initialHeight)!=null?p:0)}};function Gp(e){var t,o,n,r,i,s,a,l;return{width:(r=(n=(o=(t=e.measured)==null?void 0:t.width)!=null?o:e.width)!=null?n:e.initialWidth)!=null?r:0,height:(l=(a=(s=(i=e.measured)==null?void 0:i.height)!=null?s:e.height)!=null?a:e.initialHeight)!=null?l:0}}var oN={[se.Left]:{x:-1,y:0},[se.Right]:{x:1,y:0},[se.Top]:{x:0,y:-1},[se.Bottom]:{x:0,y:1}};var Bp={nodeOrigin:[0,0],nodeExtent:Vp,elevateNodesOnSelect:!0,defaults:{}},nN=v(b({},Bp),{checkEquality:!0});var sa;(function(e){e.Line="line",e.Handle="handle"})(sa||(sa={}));var zp={width:0,height:0,x:0,y:0},rN=v(b({},zp),{pointerX:0,pointerY:0,aspectRatio:1});import{useCallback as oo,useEffect as Kp,useRef as qp,useState as da}from"react";import{shallow as Zp}from"zustand/shallow";var Fp=(e,t)=>e.x<t.x2&&e.x2>t.x&&e.y<t.y2&&e.y2>t.y;function Wp(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 Yp(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 nn=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,[s,a]=t==="horizontal"?[r.y,r.y2]:[r.x,r.x2],l=[];for(let u of i){if(u.position<s)continue;if(u.position>a)break;if(u.node.id===n.id||u.node.parentId===n.id||!Fp(u.nodeBox,r))continue;let f=Math.abs(u.position-o);if(f>rn)continue;let g=Wp(u.nodeBox,de(n))>0?0:Yp(u.nodeBox,de(n));l.push({line:u,lineDist:f,nodeDist:g})}let c=.5,d=t==="horizontal"?this.lastHorizontalLine:this.lastVerticalLine;l.sort((u,f)=>{if(d){if(u.line===d&&f.line!==d)return-1;if(f.line===d&&u.line!==d)return 1}return Math.abs(u.lineDist-f.lineDist)<=c?u.nodeDist-f.nodeDist:u.lineDist-f.lineDist});let p=l.length>0?l[0].line:void 0;return p&&(t==="horizontal"?this.lastHorizontalLine=p:this.lastVerticalLine=p),p}};function aa(e,t=Qe,o){let n=[];return e==null||e.forEach(r=>{let i=o(r.id);if(!i)throw new Error(`Node with id ${r.id} not found in internal nodes.`);let s=de(i);Object.entries(t).forEach(([a,l])=>{var c;n.push({nodeBox:s,node:r,orientation:l.orientation,position:l.resolve(r,s),color:(c=r.style)==null?void 0:c.backgroundColor,anchorName:a})})}),n}function la(e,t,o,n,r=Object.keys(Qe)){let i=[];for(let a of r){let l=Qe[a],c=l.resolve(o,n),d=e.search(l.orientation,c,o,t);d&&i.push({anchorName:a,sourcePosition:c,anchor:l,line:d})}let s={horizontal:void 0,vertical:void 0};for(let a of i){let l=s[a.anchor.orientation],c=Math.abs(a.sourcePosition-a.line.position);(!l||c<Math.abs(l.sourcePosition-l.line.position))&&(s[a.anchor.orientation]=a)}return s}function ca(e,t,o,n,r,i,s,a){var p,u,f,y,g,m,_,h;if(!(o!=null&&o.position))return{snappedX:!1,snappedY:!1};let l=!1,c=!1,d={x:o.position.x,y:o.position.y,x2:o.position.x+((u=(p=e.measured)==null?void 0:p.width)!=null?u:0),y2:o.position.y+((y=(f=e.measured)==null?void 0:f.height)!=null?y:0)};if(s){let T=s.anchor.resolve(e,d)-s.line.position;if(Math.abs(T)<=rn){if(o.position.y-=T,r!=null&&r.dimensions)if(n){let N=t.internals.positionAbsolute.y+((m=(g=e.measured)==null?void 0:g.height)!=null?m:0);r.dimensions.height=N-s.line.position}else r.dimensions.height=s.line.position-t.internals.positionAbsolute.y;c=!0}}if(a){let T=a.anchor.resolve(e,d)-a.line.position;if(Math.abs(T)<=rn){if(o.position.x-=T,r!=null&&r.dimensions)if(n){let N=t.internals.positionAbsolute.x+((h=(_=e.measured)==null?void 0:_.width)!=null?h:0);r.dimensions.width=N-a.line.position}else r.dimensions.width=a.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 rn=10,Qe={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 Qp}from"react/jsx-runtime";var Jp=new nn;function yt(){let[e,t]=da(void 0),[o,n]=da(void 0),{width:r,height:i}=Xp(m=>({width:m.width,height:m.height}),Zp),s=Up(),a=qp(Jp),{screenToFlowPosition:l,getInternalNode:c,getNodes:d}=$p(),p=oo(()=>{t(void 0),n(void 0)},[]),u=oo(m=>{let _=m!=null?m:d();p();let h=aa(_,Qe,c);a.current.initialize(h)},[c,p,d]),f=oo(()=>{setTimeout(()=>{u()},100)},[u]);Kp(()=>{s&&u(d())},[s,u,d]);let y=oo((m,_)=>{var W,B,F,$,K;if(!a.current||m.length===0||m.length>2)return m;p();let h,E,T=Object.keys(Qe);m.length===1?m[0].type==="position"?h=m[0]:m[0].type==="dimensions"&&(E=m[0],T=["right","bottom"]):m[0].type==="position"&&m[1].type==="dimensions"&&m[1].dimensions&&(h=m[0],E=m[1],T=["top","left"]);let N=_.find(U=>U.id===m[0].id);if(!N)return m;let w=c(N.id);if(!w)throw new Error(`Node with id ${N.id} not found in internal nodes`);let x=c((W=w.parentId)!=null?W:""),I=de(w);E!=null&&E.dimensions&&(I.x2=I.x+E.dimensions.width,I.y2=I.y+E.dimensions.height);let{x:R,y:k}=l({x:0,y:0}),{x:A,y:S}=l({x:r,y:i}),P={x:R,y:k,x2:A,y2:S},{horizontal:C,vertical:M}=la(a.current,P,N,I,T),L={id:N.id,type:"position",position:{x:w.internals.positionAbsolute.x,y:w.internals.positionAbsolute.y},dragging:!1};h!=null&&h.position&&L.position&&(x?(L.position.x=h.position.x+((F=(B=x==null?void 0:x.position)==null?void 0:B.x)!=null?F:0),L.position.y=h.position.y+((K=($=x==null?void 0:x.position)==null?void 0:$.y)!=null?K:0)):(L.position.x=h.position.x,L.position.y=h.position.y));let{snappedX:z,snappedY:H}=ca(N,w,L,h,E,x,C,M);if(z||H){if((E!=null&&E.resizing||h!=null&&h.dragging)&&(z&&n(M==null?void 0:M.line),H&&t(C==null?void 0:C.line)),E&&h)return[L,E];if(h)return[L];if(E)return[E]}return m},[l,c,r,i,t,n,p]),g=oo(()=>Qp(ua,{horizontal:e,vertical:o}),[e,o]);return{rebuildIndex:u,forceRebuildIndex:f,updateHelperLines:y,helperLineHorizontal:e,helperLineVertical:o,HelperLines:g}}import{addEdge as Yg,useReactFlow as Ug}from"@xyflow/react";import{useCallback as Yl}from"react";import{BaseEdge as wf,EdgeLabelRenderer as Af,getStraightPath as If,useInternalNode as ma,useViewport as Cf}from"@xyflow/react";import{Position as no}from"@xyflow/react";function pa(e,t){var E,T,N,w;let{width:o=0,height:n=0}=e.measured||{width:0,height:0},r=e.internals.positionAbsolute,i=t.internals.positionAbsolute,s=o/2,a=n/2,l=r.x+s,c=r.y+a,d=i.x+((T=(E=t==null?void 0:t.measured)==null?void 0:E.width)!=null?T:0)/2,p=i.y+((w=(N=t==null?void 0:t.measured)==null?void 0:N.height)!=null?w:0)/2,u=(d-l)/(2*s)-(p-c)/(2*a),f=(d-l)/(2*s)+(p-c)/(2*a),y=1/(Math.abs(u)+Math.abs(f)||1),g=y*u,m=y*f,_=s*(g+m)+l,h=a*(-g+m)+c;return{x:_,y:h}}function fa(e,t){var c,d,p,u;let{positionAbsolute:o}=e.internals,n=(d=(c=e.measured)==null?void 0:c.width)!=null?d:0,r=(u=(p=e.measured)==null?void 0:p.height)!=null?u:0,i=Math.round(o.x),s=Math.round(o.y),a=Math.round(t.x),l=Math.round(t.y);return a<=i+1?no.Left:a>=i+n-1?no.Right:l<=s+1?no.Top:l>=s+r-1?no.Bottom:no.Top}function Pe(e,t){let o=pa(e,t),n=pa(t,e),r=fa(e,o),i=fa(t,n);return{sx:o.x,sy:o.y,tx:n.x,ty:n.y,sourcePos:r,targetPos:i}}import{Button as tf,Tooltip as of,TooltipContent as nf,TooltipTrigger as rf,useTranslation as sf}from"lecom-ui";import{Settings as af}from"lucide-react";import{getIncomers as sn,getOutgoers as an,useReactFlow as ef}from"@xyflow/react";import{useReactFlow as jp}from"@xyflow/react";var Fe=()=>{let{getNodes:e,setNodes:t,getEdges:o,setEdges:n}=jp();return{selectElements:s=>{let a=e().map(c=>v(b({},c),{selected:s.includes(c.id)})),l=o().map(c=>v(b({},c),{selected:s.includes(c.id)}));return t(a),n(l),!0},clearSelection:async()=>{let s=e().map(l=>v(b({},l),{selected:!1})),a=o().map(l=>v(b({},l),{selected:!1}));return t(s),n(a),await No(),!0}}};var ln=()=>{let{getNode:e,getEdge:t,getNodes:o,getEdges:n}=ef(),{selectElements:r}=Fe(),i=m=>{let _=o(),h=n(),E=sn(m,_,h),T=an(m,_,h),N=E.some(x=>x.type==="START_EVENT"),w=T.some(x=>x.type==="END_EVENT");return N?"start":w?"end":"between"},s=(m,_,h)=>{var N,w,x,I;if(!m)return;let E={type:m.type,variant:(N=m.data)==null?void 0:N.variant,attribute:(w=m.data)==null?void 0:w.attribute},T={id:m.id,position:i(m),label:(x=m.data)==null?void 0:x.label,node:E};return m.type==="TASK"&&((I=m.data)==null?void 0:I.variant)==="SUBPROCESS"?v(b({},T),{type:"sub_process"}):m.type==="GATEWAY"?v(b({},T),{type:"gateway",variant:a(m,_,h)}):v(b({},T),{type:"activity"})},a=(m,_,h)=>{if(m.type!=="GATEWAY")return;let E=sn(m,_,h),T=!1,N=!1;if(E.forEach(w=>{var x,I;w.type==="TASK"&&(((x=w.data)==null?void 0:x.variant)==="SCRIPT"&&(T=!0),((I=w.data)==null?void 0:I.attribute)==="LOOP"&&(N=!0))}),T&&N)return"script_loop";if(T)return"script";if(N)return"loop"},l=(m,_,h)=>{var x,I,R,k;let E=e(m.source),T=e(m.target);if(!E||!T)return"simple";if(an(E,_,h).some(A=>A.type==="END_EVENT"))return"final";if(E.type==="GATEWAY")switch((x=E.data)==null?void 0:x.variant){case"PARALLEL":return"parallel";case"EXCLUSIVE":return"exclusive";case"COMPLEX":return"complex";default:return"simple"}if(E.type==="TASK"){let A=(I=E.data)==null?void 0:I.variant,S=(R=E.data)==null?void 0:R.attribute;if(T.type==="TASK"&&((k=T.data)==null?void 0:k.variant)==="SUBPROCESS")return"to_sub_process";let P=A==="SCRIPT",C=S==="LOOP";return P&&C?"script_loop":P?"script":C?"loop":"simple"}return"simple"},c=(m,_,h)=>{let E=[];function T(w,x,I=0){let R=s(w,_,h);if(R.depth=I,x.push(R),w.type==="TASK"){E.push([...x]),x.pop();return}let k=sn(w,_,h);if(k.length)for(let A of k)T(A,x,I+1);x.pop()}let N=sn(m,_,h);for(let w of N)T(w,[]);return E},d=(m,_,h)=>{let E=[];function T(w,x,I=0){let R=s(w,_,h);if(R.depth=I,x.push(R),w.type==="TASK"){E.push([...x]),x.pop();return}let k=an(w,_,h);if(k.length)for(let A of k)T(A,x,I+1);x.pop()}let N=an(m,_,h);for(let w of N)T(w,[]);return E},p=(m,_,h)=>{h=h.filter(T=>T.source===m.id);let E=h.map(T=>{var x;let N=e(T.target),w;return N&&(w=s(N,_,h)),{id:T.id,type:"routing",variant:l(T,_,h),label:(x=T.data)==null?void 0:x.label,target:w}});return console.log(E),E},u=m=>{let _=e(m);if(!_)return;let h=o(),E=n(),T=s(_,h,E);return T.sources=c(_,h,E),T.targets=d(_,h,E),T.edgeTargets=p(_,h,E),_.type==="GATEWAY"&&(T.variant=a(_,h,E)),T},f=m=>{let _=t(m);if(!_)return;let h=o(),E=n(),T=l(_,h,E),w={id:_.id,type:"routing",variant:T,gatewayVariant:void 0},x=e(_.source);if(x){let R=s(x,h,E),k=c(x,h,E),A=a(x,h,E);w.source=R,w.sources=k.length?k:[[R]],w.gatewayVariant=A}let I=e(_.target);if(I){let R=s(I,h,E),k=d(I,h,E);w.target=R,w.targets=k.length?k:[[R]]}return w},y=m=>{let _=e(m);if(_)return u(_.id);let h=t(m);if(h)return f(h.id)};return{configureElement:m=>{let _=y(m);if(_)return r([m]),_},getConfigureElement:y,getNodeConfigure:u,getEdgeConfigure:f}};import{jsx as cn,jsxs as lf}from"react/jsx-runtime";var We=({elementId:e,elementType:t="node"})=>{let{t:o}=sf(),{onConfigureElement:n}=V(),{getConfigureElement:r}=ln();return lf(of,{children:[cn(rf,{asChild:!0,children:cn(tf,{variant:"ghost",color:"grey",size:"small",iconButton:!0,onClick:()=>{let s=r(e);s&&(n==null||n(s))},children:cn(af,{size:16})})}),cn(nf,{color:"black",children:o(t==="node"?"editor.toolbar.configure_node":"editor.toolbar.configure_edge")})]})};import{useReactFlow as cf}from"@xyflow/react";import{Button as df,Tooltip as uf,TooltipContent as pf,TooltipTrigger as ff,useTranslation as mf}from"lecom-ui";import{TrashIcon as gf}from"lucide-react";import{jsx as dn,jsxs as hf}from"react/jsx-runtime";var un=({elementId:e,elementType:t="node"})=>{let{t:o}=mf(),{deleteElements:n}=cf();return hf(uf,{children:[dn(ff,{asChild:!0,children:dn(df,{variant:"ghost",color:"destructive",size:"small",iconButton:!0,onClick:()=>{n(t==="node"?{nodes:[{id:e}]}:{edges:[{id:e}]})},children:dn(gf,{size:16})})}),dn(pf,{color:"black",children:o("editor.toolbar.delete")})]})};import{Button as yf,Tooltip as xf,TooltipContent as Ef,TooltipTrigger as bf,useTranslation as _f}from"lecom-ui";import{MoveUpRightIcon as Tf}from"lucide-react";import{useCallback as Nf}from"react";import{jsx as pn,jsxs as vf}from"react/jsx-runtime";var ro=({nodeId:e})=>{let{t}=_f(),o=Nf(n=>{n.stopPropagation();let r=document.querySelector(`[data-id="${e}"]`);if(!r)return;let i=r.querySelector(".react-flow__handle.source");if(!i)return;let s=i.getBoundingClientRect(),a=s.left+s.width/2,l=s.top+s.height/2,c=new MouseEvent("mousedown",{clientX:a,clientY:l,bubbles:!0,cancelable:!0});i.dispatchEvent(c)},[e]);return vf(xf,{children:[pn(bf,{asChild:!0,children:pn(yf,{variant:"ghost",color:"grey",size:"small",iconButton:!0,onMouseDown:o,children:pn(Tf,{size:16})})}),pn(Ef,{color:"black",children:t("editor.toolbar.connect_node")})]})};import{jsx as io}from"react/jsx-runtime";var xt=i=>{var s=i,{edgeId:e,edgeType:t,sourceNode:o,targetNode:n}=s,r=Te(s,["edgeId","edgeType","sourceNode","targetNode"]);let{mode:a}=V(),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",p=(o==null?void 0:o.type)==="TASK"&&(n==null?void 0:n.type)==="GATEWAY",u=!l&&!c&&!d&&!p,f=[{component:io(un,{elementId:e,elementType:"edge"})}],y=()=>a==="view"?u?[{component:io(We,{elementId:e,elementType:"edge"})}]:[]:u?[{component:io(We,{elementId:e,elementType:"edge"})},...f]:f,m=(_=>{switch(_){case"SEQUENCE_EDGE":return y();case"MESSAGE_EDGE":return a==="view"?[]:[...f];case"ANNOTATION_EDGE":return a==="view"?[]:[...f];default:return[]}})(t);if(!(m.length===0||a==="view"))return io("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)=>io("div",{children:_.component},h))}))};import{jsx as fn,jsxs as Sf}from"react/jsx-runtime";var Et={type:"ANNOTATION_EDGE",reconnectable:!0},ga=({id:e,source:t,target:o,selected:n,data:r})=>{let{zoom:i}=Cf(),{isMultipleSelection:s}=V(),a=ma(t),l=ma(o);if(!a||!l)return null;let{sx:c,sy:d,tx:p,ty:u}=Pe(a,l),[f,y,g]=If({sourceX:c,sourceY:d,targetX:p,targetY:u}),m=n||(a==null?void 0:a.selected)||(l==null?void 0:l.selected),_=1/i;return Sf("g",{className:D("text-grey-400 hover:text-grey-500",{"text-blue-500 hover:text-blue-600":m}),children:[fn(wf,{id:e,path:f,strokeDasharray:4,className:D("stroke-2 stroke-current transition-colors duration-75",{"stroke-red-500 hover:stroke-red-600":r==null?void 0:r.hasError,"stroke-blue-500 hover:stroke-blue-600 drop-shadow-[0_0_3px_rgba(59,130,246,0.5)]":m&&!(r!=null&&r.hasError)})}),fn(Af,{children:fn("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&&!s&&fn(xt,{edgeId:e,edgeType:"ANNOTATION_EDGE",style:{transform:`scale(${_})`}})})})]})};import{useState as Ea,useCallback as Df,useMemo as Tr,useEffect as kf,useRef as ba}from"react";import{BaseEdge as Rf,EdgeLabelRenderer as Vf,MarkerType as _a,useInternalNode as Ta,useReactFlow as Of,useViewport as Hf,Position as Na}from"@xyflow/react";import{useEffect as ha,useRef as Mf,useState as Pf}from"react";import{jsx as ya}from"react/jsx-runtime";var te=({value:e,maxLength:t,style:o,className:n,contentClassName:r,isEditing:i,onChange:s,onBlur:a})=>{let l=Mf(null),[c,d]=Pf(!1);ha(()=>{d(i!=null?i:!1)},[i]),ha(()=>{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 p=g=>{g.stopPropagation(),c||d(!0)},u=g=>{let m=g.currentTarget.innerText.trim(),_=t&&m.length>=t,h=["Backspace","Delete","ArrowLeft","ArrowRight","ArrowUp","ArrowDown","Home","End","Tab","Enter","Escape","Shift"],E=g.ctrlKey||g.metaKey,T=E&&g.key==="a",N=E&&g.key==="c",w=E&&g.key==="x",x=E&&g.key==="v";function I(k){return/\w/.test(k)}if(m.length===0&&!I(g.key)&&!h.includes(g.key)&&!E){g.preventDefault();return}_&&(h.includes(g.key)||T||N||w||x||g.preventDefault())},f=g=>{if(!t)return;g.preventDefault();let m=g.clipboardData.getData("text/plain"),_=g.currentTarget.innerText,h=window.getSelection();if(!h||h.rangeCount===0)return;let E=h.getRangeAt(0);if((_.substring(0,E.startOffset)+m+_.substring(E.endOffset)).length>t){let N=t-(_.length-(E.endOffset-E.startOffset)),w=m.substring(0,Math.max(0,N));w&&(E.deleteContents(),E.insertNode(document.createTextNode(w)),E.setStartAfter(E.endContainer),E.collapse(!0),h.removeAllRanges(),h.addRange(E))}else E.deleteContents(),E.insertNode(document.createTextNode(m)),E.setStartAfter(E.endContainer),E.collapse(!0),h.removeAllRanges(),h.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,a==null||a(),m!==e&&(s==null||s(m))};return ya("div",{className:D("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:p,children:ya("div",{ref:l,className:D("outline-none whitespace-pre-wrap overflow-hidden",r,{"nodrag nopan cursor-text":c}),contentEditable:!0,suppressContentEditableWarning:!0,onKeyDown:u,onPaste:f,onBlur:y,children:e})})};import{Position as mn}from"@xyflow/react";var gn=e=>e===mn.Left||e===mn.Right,Er=(e,t=30)=>e===mn.Right||e===mn.Bottom?t:-t,br=(e,t,o,n=1)=>Math.abs(e[o]-t[o])<n,hn=(e,t)=>Math.sqrt((t.x-e.x)**2+(t.y-e.y)**2),yn=(e,t)=>({x:(e.x+t.x)/2,y:(e.y+t.y)/2});var je={OFFSET:30,TOLERANCE:1,MOVE_THRESHOLD:5,MIN_SEGMENT_LENGTH:15};function Lf(e,t,o,n,r,i){let s=Er(r,je.OFFSET),a=Er(i,je.OFFSET),l=gn(r),c=gn(i),d={x:e,y:t},p={x:o,y:n};if(l&&c){let u=(t+n)/2;return[d,{x:e+s,y:t},{x:e+s,y:u},{x:o+a,y:u},{x:o+a,y:n},p]}if(!l&&!c){let u=(e+o)/2;return[d,{x:e,y:t+s},{x:u,y:t+s},{x:u,y:n+a},{x:o,y:n+a},p]}return l?[d,{x:e+s,y:t},{x:e+s,y:n+a},{x:o,y:n+a},p]:[d,{x:e,y:t+s},{x:o+a,y:t+s},{x:o+a,y:n},p]}function _r(e,t,o,n,r,i,s){let a=Lf(e,t,o,n,r,i);if(!(s!=null&&s.length)||s.length!==a.length-2)return a;let l=[{x:e,y:t},...s,{x:o,y:n}],c=gn(r);for(let d=0;d<l.length-1;d++){let p=l[d],u=l[d+1];if(Math.abs(u.x-p.x)>je.TOLERANCE&&Math.abs(u.y-p.y)>je.TOLERANCE){let y=d%2===0===c;l[d+1]=y?{x:u.x,y:p.y}:{x:p.x,y:u.y}}}return l}var xa=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{Fragment as Bf,jsx as Ye,jsxs as En}from"react/jsx-runtime";var xe={type:"SEQUENCE_EDGE",reconnectable:!0,markerStart:{type:_a.ArrowClosed},markerEnd:{type:_a.Arrow},data:{label:""}},{TOLERANCE:va,MOVE_THRESHOLD:xn,MIN_SEGMENT_LENGTH:Gf}=je,wa=({id:e,source:t,target:o,data:n,selected:r})=>{var S;let{zoom:i}=Hf(),{updateEdgeData:s}=Of(),{isMultipleSelection:a,mode:l}=V(),[c,d]=Ea(!1),[p,u]=Ea(null),f=ba(null),y=ba(null),g=Ta(t),m=Ta(o),{sx:_,sy:h,tx:E,ty:T,sourcePos:N,targetPos:w}=Tr(()=>g&&m?Pe(g,m):{sx:0,sy:0,tx:0,ty:0,sourcePos:Na.Right,targetPos:Na.Left},[g,m]);kf(()=>{var M;if(!y.current){y.current={sx:_,sy:h,tx:E,ty:T,sourcePos:N,targetPos:w};return}let P=y.current;(Math.abs(_-P.sx)>xn||Math.abs(h-P.sy)>xn||Math.abs(E-P.tx)>xn||Math.abs(T-P.ty)>xn||P.sourcePos!==N||P.targetPos!==w)&&((M=n==null?void 0:n.points)!=null&&M.length)&&s(e,v(b({},n),{points:void 0})),y.current={sx:_,sy:h,tx:E,ty:T,sourcePos:N,targetPos:w}},[_,h,E,T,N,w,n,e,s]);let x=Tr(()=>{var P;if((P=n==null?void 0:n.points)!=null&&P.length&&m){let M={internals:{positionAbsolute:n.points[n.points.length-1]},measured:{width:1,height:1}},L=Pe(M,m);return _r(_,h,L.tx,L.ty,N,L.targetPos,n.points)}return _r(_,h,E,T,N,w,n==null?void 0:n.points)},[_,h,E,T,N,w,n==null?void 0:n.points,m]),I=Tr(()=>{if(x.length<2)return yn({x:_,y:h},{x:E,y:T});let P=0;for(let L=0;L<x.length-1;L++)P+=hn(x[L],x[L+1]);let C=P/2,M=0;for(let L=0;L<x.length-1;L++){let z=hn(x[L],x[L+1]);if(M+z>=C){let H=(C-M)/z,W=x[L],B=x[L+1];return{x:W.x+(B.x-W.x)*H,y:W.y+(B.y-W.y)*H}}M+=z}return yn({x:_,y:h},{x:E,y:T})},[x,_,h,E,T]),R=Df((P,C)=>{if(l!=="edit"||C.button!==0)return;C.stopPropagation(),C.preventDefault();let M=x[P],L=x[P+1],z=br(M,L,"y"),H=z?M.y:M.x;u(P);let W=F=>{let $=H+(z?F.clientY-C.clientY:F.clientX-C.clientX)/i;f.current=z?{x:(M.x+L.x)/2,y:$}:{x:$,y:(M.y+L.y)/2};let K=x.map((U,Re)=>Re===0||Re===x.length-1?U:(z?Math.abs(U.y-H)<va:Math.abs(U.x-H)<va)?z?v(b({},U),{y:$}):v(b({},U),{x:$}):U);s(e,v(b({},n),{points:K.slice(1,-1)}))},B=()=>{u(null),f.current=null,document.removeEventListener("mousemove",W),document.removeEventListener("mouseup",B)};document.addEventListener("mousemove",W),document.addEventListener("mouseup",B)},[l,x,i,n,e,s]);if(!g||!m)return null;let k=xa(x),A=r||g.selected||m.selected;return En(Bf,{children:[En("g",{className:D("text-grey-400 hover:text-grey-500",{"text-blue-500 hover:text-blue-600":A}),onBlur:()=>d(!1),onDoubleClick:()=>d(!0),children:[Ye(Rf,{id:e,path:k,markerEnd:`url(#${A?"sequence-edge-marker-highlighted":"sequence-edge-marker"})`,className:D("stroke-2 stroke-current transition-colors duration-75",{"stroke-red-500 hover:stroke-red-600":n==null?void 0:n.hasError,"stroke-blue-500 hover:stroke-blue-600 drop-shadow-[0_0_3px_rgba(59,130,246,0.5)]":A&&!(n!=null&&n.hasError)})}),r&&!a&&l==="edit"&&Ye("g",{children:x.slice(0,-1).map((P,C)=>{let M=x[C+1];if(C===0||C===x.length-2||hn(P,M)<Gf)return null;let L=br(P,M,"y"),z=p===C,H=z&&f.current?f.current:yn(P,M);return En("g",{children:[Ye("line",{x1:P.x,y1:P.y,x2:M.x,y2:M.y,stroke:"transparent",strokeWidth:20/i,className:D("cursor-pointer",{"cursor-ns-resize":L,"cursor-ew-resize":!L}),onMouseDown:W=>R(C,W)}),Ye("circle",{cx:H.x,cy:H.y,r:4/i,fill:z?"#3b82f6":"#fff",stroke:"#3b82f6",strokeWidth:2/i,className:"pointer-events-none"}),Ye("circle",{cx:H.x,cy:H.y,r:6/i,fill:"none",stroke:"#3b82f6",strokeWidth:1/i,opacity:z?.6:.3,className:"pointer-events-none"})]},C)})})]}),Ye(Vf,{children:En("div",{className:"absolute z-[3000] pointer-events-auto flex flex-col items-center gap-1",style:{transform:`translate(-50%, -50%) translate(${I.x}px, ${I.y}px)`},children:[r&&!a&&Ye(xt,{edgeId:e,edgeType:"SEQUENCE_EDGE",sourceNode:g,targetNode:m,style:{transform:`scale(${1/i})`}}),(c||((S=n==null?void 0:n.label)==null?void 0:S.trim()))&&Ye(te,{value:n==null?void 0:n.label,className:"min-w-8 max-w-56 bg-white rounded-md px-2 py-1 text-xs",isEditing:c,onChange:P=>s(e,{label:P.trim()})})]})})]})};var ao=e=>new Map(e.map(t=>[t.id,t])),bn=e=>e.some(t=>t.type==="START_EVENT"),Aa=(e,t,o,n)=>{let r=ao(o),i=r.get(e);if(!i||i.type!=="START_EVENT")return!1;let s=r.get(t);return(s==null?void 0:s.type)==="ANNOTATION"?!1:n.filter(l=>{if(l.source!==e)return!1;let c=r.get(l.target);return(c==null?void 0:c.type)!=="ANNOTATION"}).length>=1},_n=(e,t,o)=>{var i;let n=t.find(s=>s.id===e);return!n||n.type!=="GATEWAY"||((i=n.data)==null?void 0:i.variant)!=="EXCLUSIVE"?!1:o.filter(s=>s.source===e).length>=2},Ia=(e,t,o)=>{var s,a,l,c;let n=ao(o),r=n.get(e),i=n.get(t);return(r==null?void 0:r.type)!=="GATEWAY"||(i==null?void 0:i.type)!=="GATEWAY"||((s=r==null?void 0:r.data)==null?void 0:s.variant)==="EXCLUSIVE"&&((a=i==null?void 0:i.data)==null?void 0:a.variant)==="PARALLEL"||((l=r==null?void 0:r.data)==null?void 0:l.variant)==="COMPLEX"&&((c=i==null?void 0:i.data)==null?void 0:c.variant)==="PARALLEL"},Tn=(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"},Nn=(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"},vn=(e,t,o)=>{let n=ao(t),r=n.get(e);return!r||r.type!=="TASK"?!1:o.filter(s=>s.target===e).some(s=>{let a=n.get(s.source);return(a==null?void 0:a.type)==="START_EVENT"})},wn=(e,t,o)=>{let n=ao(t),r=n.get(e);return!r||r.type!=="TASK"?!1:o.filter(s=>s.source===e).some(s=>{let a=n.get(s.target);return(a==null?void 0:a.type)==="END_EVENT"})},An=(e,t)=>t.filter(n=>n.source===e).length>0,In=(e,t,o,n)=>{let r=ao(o),i=r.get(e);if(!i||i.type!=="TASK")return!1;let s=t?r.get(t):null;return(s==null?void 0:s.type)==="ANNOTATION"?!1:n.filter(l=>{if(l.source!==e)return!1;let c=r.get(l.target);return(c==null?void 0:c.type)!=="ANNOTATION"}).length>=2};var zf=[e=>({isValid:e.sourceNodeId!==e.targetNodeId,reason:"self_connection_not_allowed"}),e=>({isValid:!Aa(e.sourceNodeId,e.targetNodeId,e.nodes,e.edges),reason:"start_event_limit_reached"}),e=>({isValid:!_n(e.sourceNodeId,e.nodes,e.edges),reason:"gateway_limit_reached"}),e=>({isValid:!In(e.sourceNodeId,e.targetNodeId,e.nodes,e.edges),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:!(Tn(e.sourceNodeId,e.nodes)&&e.targetNodeType==="END_EVENT"),reason:"script_to_end_not_allowed"}),e=>({isValid:!(Nn(e.sourceNodeId,e.nodes)&&e.targetNodeType==="END_EVENT"),reason:"loop_to_end_not_allowed"}),e=>({isValid:!(vn(e.sourceNodeId,e.nodes,e.edges)&&e.targetNodeType==="END_EVENT"),reason:"initial_activity_to_end_not_allowed"}),e=>({isValid:!(wn(e.sourceNodeId,e.nodes,e.edges)&&e.targetNodeType!=="ANNOTATION"),reason:"final_activity_cannot_connect"}),e=>({isValid:!(An(e.sourceNodeId,e.edges)&&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"})],Ca=e=>{for(let t of zf){let o=t(e);if(!o.isValid)return o}return{isValid:!0}};var Ff=[{sourceTypes:["GATEWAY"],targetTypes:["TASK","GATEWAY"],validate:e=>({shouldDisable:_n(e.sourceNodeId,e.nodes,e.edges),reason:"gateway_limit_reached"})},{targetTypes:["START_EVENT"],validate:e=>({shouldDisable:bn(e.nodes),reason:"start_event_already_exists"})},{sourceTypes:["TASK"],targetTypes:["END_EVENT"],validate:e=>({shouldDisable:Tn(e.sourceNodeId,e.nodes),reason:"script_to_end_not_allowed"})},{sourceTypes:["TASK"],targetTypes:["END_EVENT"],validate:e=>({shouldDisable:Nn(e.sourceNodeId,e.nodes),reason:"loop_to_end_not_allowed"})},{sourceTypes:["TASK"],targetTypes:["END_EVENT"],validate:e=>({shouldDisable:vn(e.sourceNodeId,e.nodes,e.edges),reason:"initial_activity_to_end_not_allowed"})},{sourceTypes:["TASK"],validate:e=>({shouldDisable:wn(e.sourceNodeId,e.nodes,e.edges)&&e.targetNodeType!=="ANNOTATION",reason:"final_activity_cannot_connect"})},{targetTypes:["END_EVENT"],validate:e=>({shouldDisable:An(e.sourceNodeId,e.edges),reason:"activity_has_outgoing_connections"})},{sourceTypes:["TASK"],validate:e=>({shouldDisable:In(e.sourceNodeId,null,e.nodes,e.edges)&&e.targetNodeType!=="ANNOTATION",reason:"task_limit_reached"})}],Sa=e=>{let t=Ff.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{useDebouncedCallback as Fg}from"use-debounce";import{useReactFlow as zg}from"@xyflow/react";import{useCallback as Fl}from"react";var lo=(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))(lo||{});import{xml2json as Wf,json2xml as Yf}from"xml-js";var Ma={compact:!0,spaces:4},Uf=e=>e.replaceAll(`
2
- `,"&#xA;");function Cn(e,t=Ma){if(e)return JSON.parse(Wf(e,v(b({},t),{attributeValueFn:Uf})))}function Pa(e,t=Ma){return e?Yf(e,t):""}import{v7 as Jf}from"uuid";var $f={MIN_WIDTH:36,MIN_HEIGHT:36},Xf={MIN_WIDTH:36,MIN_HEIGHT:36},Kf={MIN_WIDTH:56,MIN_HEIGHT:56},Sn={MIN_WIDTH:176,MIN_HEIGHT:96},Mn={HEADER_WIDTH:40,MIN_WIDTH:840,MIN_HEIGHT:256},X={HEADER_WIDTH:40,MIN_WIDTH:800,MIN_HEIGHT:256},Pn={MIN_WIDTH:176,MIN_HEIGHT:64},qf={MIN_WIDTH:128,MIN_HEIGHT:64},G={START_EVENT:$f,END_EVENT:Xf,GATEWAY:Kf,TASK:Sn,LANE:X,ANNOTATION:Pn,UNSUPPORTED:qf};var La={"attribute-loop":"LOOP"},Da={"task-script":"SCRIPT","subprocess-collapsed":"SUBPROCESS"},ka={"gateway-exclusive":"EXCLUSIVE","gateway-parallel":"PARALLEL","gateway-complex":"COMPLEX"},Ra={SCRIPT:"task-script",SUBPROCESS:"subprocess-collapsed"},Va={EXCLUSIVE:"gateway-exclusive",PARALLEL:"gateway-parallel",COMPLEX:"gateway-complex"};var bt=(e,t,o)=>{let n=e._attributes.width||0,r=e._attributes.height||0,i=Ve(Number(n),t),s=Ve(Number(r),o);return{width:i,height:s,measured:{width:i,height:s}}},_t=e=>{let{_attributes:t,mxGeometry:o}=e,{id:n,parent:r,value:i}=t,s={x:Number(o._attributes.x||0),y:Number(o._attributes.y||0)},a={id:n,position:s,data:{label:i||""}},l=r==="1"?void 0:r;return l&&(a.parentId=l),a},Qf=e=>{let{mxGeometry:t}=e,o=_t(e),n=bt(t,G.START_EVENT.MIN_WIDTH,G.START_EVENT.MIN_HEIGHT);return v(b(b({},o),n),{type:"START_EVENT"})},jf=e=>{let{mxGeometry:t}=e,o=_t(e),n=bt(t,G.END_EVENT.MIN_WIDTH,G.END_EVENT.MIN_HEIGHT);return v(b(b({},o),n),{type:"END_EVENT"})},Nr=(e,t)=>{let{_attributes:o,mxGeometry:n}=e,r=_t(e),i=bt(n,G.TASK.MIN_WIDTH,G.TASK.MIN_HEIGHT),s=t==null?void 0:t.find(l=>{let{parent:c}=l._attributes;return c===e._attributes.id});if(s){let{style:l}=s._attributes,c=La[l];c&&(r.data.attribute=c)}let a=Da[o.style];return a&&(r.data.variant=a),v(b(b({},r),i),{type:"TASK"})},vr=e=>{let{_attributes:t,mxGeometry:o}=e,{style:n}=t,r=_t(e),i=bt(o,G.GATEWAY.MIN_WIDTH,G.GATEWAY.MIN_HEIGHT);return r.data.variant=ka[n],v(b(b({},r),i),{type:"GATEWAY"})},em=e=>{let{mxGeometry:t}=e,o=_t(e),n=bt(t,G.ANNOTATION.MIN_WIDTH,G.ANNOTATION.MIN_HEIGHT);return v(b(b({},o),n),{type:"ANNOTATION"})},tm=e=>{let{mxGeometry:t}=e,o=_t(e),n=bt(t,G.LANE.MIN_WIDTH,G.LANE.MIN_HEIGHT);return v(b(b({},o),n),{type:"LANE"})},Oa={task:Nr,"task-script":Nr,"subprocess-collapsed":Nr,"start-event":Qf,"end-event-terminate":jf,"gateway-parallel":vr,"gateway-exclusive":vr,"gateway-complex":vr,annotation:em,lane:tm},Ha=e=>{var d;let{_attributes:t,mxGeometry:o}=e,{id:n,source:r,target:i,value:s,style:a}=t,l=(d=o==null?void 0:o.Array)==null?void 0:d.map(p=>({x:Number(p._attributes.x),y:Number(p._attributes.y)})),c={id:n,source:r,target:i,data:b({label:s||""},l&&l.length>0?{points:l}:{})};return a.includes("association")&&a.includes('endArrow=""')?b(b({},Et),c):b(b({},xe),c)},Ga=(e,t)=>{let{id:o,type:n,source:r,target:i,data:s}=e,a=t==null?void 0:t.find(p=>p.id===r),l="";n==="ANNOTATION_EDGE"&&(l='association;endArrow=""');let c={_attributes:{as:"geometry",relative:"1"}};return s!=null&&s.points&&Array.isArray(s.points)&&s.points.length>0&&(c.Array=s.points.map(p=>({_attributes:{as:"mxPoint",x:p.x,y:p.y}}))),{_attributes:{id:o,parent:(a==null?void 0:a.parentId)||"1",edge:"1",style:l,source:r,target:i,value:(s==null?void 0:s.label)||""},mxGeometry:c}},Tt=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}}}},om=e=>{let{variant:t}=e.data,o=Tt(e);return v(b({},o),{_attributes:v(b({},o._attributes),{style:Ra[t]||"task"})})},nm=e=>{let t=Tt(e);return v(b({},t),{_attributes:v(b({},t._attributes),{style:"start-event"})})},rm=e=>{let t=Tt(e);return v(b({},t),{_attributes:v(b({},t._attributes),{style:"end-event-terminate"})})},im=e=>{let{variant:t}=e.data,o=Tt(e);return v(b({},o),{_attributes:v(b({},o._attributes),{style:Va[t]})})},sm=e=>{let t=Tt(e);return v(b({},t),{_attributes:v(b({},t._attributes),{style:"lane"})})},am=e=>{let t=Tt(e);return v(b({},t),{_attributes:v(b({},t._attributes),{style:"annotation"})})},Ba={TASK:om,START_EVENT:nm,END_EVENT:rm,GATEWAY:im,ANNOTATION:am,LANE:sm},za=e=>{var i,s;let n=((i=e.measured)==null?void 0:i.width)||0,r=((s=e.measured)==null?void 0:s.height)||0;return{_attributes:{id:Jf(),parent:e.id,style:"attribute-loop",connectable:"0"},mxGeometry:{_attributes:{as:"geometry",x:n/2-22/2,y:r-22,width:22,height:22}}}};import Ya from"@dagrejs/dagre";import{getNodesBounds as um}from"@xyflow/react";import{orderBy as pm}from"lodash";import{orderBy as lm}from"lodash";var Le=e=>{var t,o,n,r,i,s,a,l;return{x:(o=(t=e.internals)==null?void 0:t.positionAbsolute.x)!=null?o:0,y:(r=(n=e.internals)==null?void 0:n.positionAbsolute.y)!=null?r:0,w:(s=(i=e.measured)==null?void 0:i.width)!=null?s:0,h:(l=(a=e.measured)==null?void 0:a.height)!=null?l:0}},De=e=>lm(e,[o=>{let n=o.type==="LANE";return n&&!o.parentId?0:n?1:2}],["asc"]),Fa=(e,t)=>{let{x:o,y:n}=Le(e),{x:r,y:i}=Le(t);return{x:o-r,y:n-i}};var Nt=({parentId:e,nodes:t,includeTypes:o=[...Object.values(O)],excludeTypes:n=[]})=>t.some(r=>r.parentId===e&&(!o.length||o.includes(r.type))&&!n.includes(r.type)),cm=(e,t)=>{let{x:o,y:n}=Le(e),{x:r,y:i}=Le(t),s=o-r,a=n-i;return Math.sqrt(s*s+a*a)},dm=(e,t)=>{let{x:o,y:n,w:r,h:i}=Le(e),{x:s,y:a,w:l,h:c}=Le(t);return o<s+l&&s<o+r&&n<a+c&&a<n+i},co=(e,t)=>{let o=null,n=1/0;for(let r of t)if(r.id!==e.id&&dm(e,r)){let i=cm(e,r);i<n&&(n=i,o=r)}return o},Wa=(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 Ua=(e=[],t=[],o="LR")=>{let n=new Ya.graphlib.Graph;return n.setDefaultEdgeLabel(()=>({})),n.setGraph({rankdir:o}),e.forEach(({id:i,width:s,height:a})=>n.setNode(i,{width:s,height:a})),t.forEach(i=>n.setEdge(i.source,i.target)),Ya.layout(n),{nodes:e.map(i=>{let s=n.node(i.id);return v(b({},i),{position:{x:s.x-i.width/2,y:s.y-i.height/2}})}),edges:t}},uo=e=>{let t=e.filter(n=>n.type==="LANE"&&!n.parentId),o=[...e];return t.forEach(n=>{o=et(n.id,o)}),o},et=(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=pm(r,["position.y"]),s=Math.max((y=(f=n.measured)==null?void 0:f.width)!=null?y:0,Mn.MIN_WIDTH),a=Wa(e,i)||X.MIN_WIDTH,l=Math.max(s,a),c=s-X.HEADER_WIDTH>=a,d=0,p=0;i.forEach(g=>{var m,_,h,E;o=o.map(T=>T.id===g.id?v(b({},T),{width:c?l-X.HEADER_WIDTH:l,measured:v(b({},T.measured),{width:c?l-X.HEADER_WIDTH:l}),position:{x:X.HEADER_WIDTH,y:d}}):T),d+=(_=(m=g.measured)==null?void 0:m.height)!=null?_:0,p+=(E=(h=g.measured)==null?void 0:h.height)!=null?E:0}),o=o.map(g=>g.id===e?v(b({},g),{height:p,width:c?l:l+X.HEADER_WIDTH,measured:v(b({},g.measured),{height:p,width:c?l:l+X.HEADER_WIDTH})}):g);let u=o.find(g=>g.id===e);return u!=null&&u.parentId&&(o=et(u.parentId,o)),o},$a=(e,t,o)=>{if(e.type==="LANE")return o;let n=de(t),r=de(e);return r.y<n.y&&(e.position.y=0),r.x<n.x+X.HEADER_WIDTH&&(e.position.x=X.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},Xa=()=>{let e=document.querySelector(".react-flow__viewport");return e||(console.error("Flow element (.react-flow__viewport) not found."),null)},fm=50,Ka=(e,t=fm)=>{let o=um(e);return{x:o.x-t,y:o.y-t,width:o.width+t*2,height:o.height+t*2}};var mm=e=>{let t=Object.values(lo),o=e.filter(i=>{var a;let s=(a=i._attributes)==null?void 0:a.style;return t.includes(s)}),n=e.filter(i=>{var a;let s=(a=i._attributes)==null?void 0:a.style;return["attribute-loop"].includes(s)}),r=[];for(let i of o){let{style:s}=i._attributes,a=Oa[s],l=a==null?void 0:a(i,n);if(!l){console.warn(`Node ${s} not supported`);continue}r.push(l)}return r},gm=(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=Ha(r),s=t.find(l=>l.id===i.source),a=t.find(l=>l.id===i.target);(s==null?void 0:s.type)==="LANE"||(a==null?void 0:a.type)==="LANE"||n.push(i)}return n},hm=e=>{let t=[];return e.forEach(o=>{var i,s;let n=(s=(i=Ba)[o.type])==null?void 0:s.call(i,o);if(!n){console.warn(`Node ${o.type} not supported`);return}if(t.push(n),o.type==="TASK"&&o.data.attribute==="LOOP"){let a=za(o);t.push(a)}}),t},ym=(e,t)=>{let o=[];return e.forEach(n=>{let r=Ga(n,t);o.push(r)}),o},qa=(e=[],t=[],o)=>{let n=hm(e),r=ym(t,e),i={mxGraphModel:{root:{_attributes:{version:"1.1",lastId:o},mxCell:[{_attributes:{id:"0"}},{_attributes:{id:"1",parent:"0"}},...n,...r]}}};return Pa(JSON.stringify(i),{compact:!0,spaces:0})},Za=async e=>{var s,a;let t=await Cn(e),o=((a=(s=t==null?void 0:t.mxGraphModel)==null?void 0:s.root)==null?void 0:a.mxCell)||[],n=mm(o),r=gm(o,n);return{nodes:De(uo(n)),edges:r}};import{Position as Zm,useConnection as Jm,useReactFlow as Qm}from"@xyflow/react";import{Handle as Ja,useReactFlow as xm}from"@xyflow/react";import{jsx as Qa}from"react/jsx-runtime";var ee=i=>{var s=i,{type:e,position:t,className:o,nodeType:n}=s,r=Te(s,["type","position","className","nodeType"]);let a=n==="TASK";return Qa(Ja,b({type:e,position:t,className:D("size-2.5 border border-grey-400 bg-white relative",{"before:content-[''] before:absolute before:inset-[-16px] before:bg-transparent":a,"before:content-[''] before:absolute before:inset-[-4px] before:bg-transparent":!a},o)},r))},Ln=a=>{var l=a,{nodeId:e,nodeType:t,gatewayVariant:o,type:n,position:r,className:i}=l,s=Te(l,["nodeId","nodeType","gatewayVariant","type","position","className"]);let{getEdges:c}=xm(),p=(()=>{if(n!=="source")return!1;let u=c();return t==="TASK"?u.filter(y=>y.source===e).length>=2:t==="GATEWAY"&&o==="EXCLUSIVE"?u.filter(y=>y.source===e).length>=2:!1})();return Qa(Ja,b({type:n,position:r,className:D("size-2.5 border border-grey-400 bg-white transition-all duration-200 relative",{"before:content-[''] before:absolute before:inset-[-16px] before:bg-transparent":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"}},s))};import{NodeResizer as Em,useReactFlow as bm}from"@xyflow/react";import{orderBy as _m}from"lodash";import{jsx as Tm}from"react/jsx-runtime";var vt=n=>{var r=n,{nodeId:e,isVisible:t}=r,o=Te(r,["nodeId","isVisible"]);let{getNode:i,getNodes:s,setNodes:a}=bm(),{isMultipleSelection:l}=V(),c=({width:p,height:u})=>{if(!e)return;let f=i(e);if((f==null?void 0:f.type)!=="LANE")return;let y=[...s()],g=!f.parentId,m=g?f.id:f.parentId,_=y.filter(T=>T.type==="LANE"&&T.parentId===m);if(!_.length)return;let h=_m(_,["position.y"]),E=0;h.forEach((T,N)=>{var I,R;let w=N===h.length-1,x=(R=(I=T.measured)==null?void 0:I.height)!=null?R:0;y=y.map(k=>{if(k.id===T.id){let A=g?p-X.HEADER_WIDTH:p,S=v(b({},k),{width:A,measured:v(b({},k.measured),{width:A}),position:v(b({},k.position),{y:E})});return w&&g&&(S.height=u-E),S}return k}),E+=x}),y=y.map(T=>{if(T.id===m){let N=g?p:p+X.HEADER_WIDTH;return v(b({},T),{width:N,height:g?u:E,measured:{width:N,height:g?u:E}})}return T}),a(y)};return Tm(Em,b({nodeId:e,handleClassName:"size-1.5 bg-blue-400",lineClassName:"border-blue-400/90 border-dashed",isVisible:!l&&t,onResizeEnd:(p,u)=>c(u)},o))};import{NodeToolbar as Bm,useReactFlow as zm}from"@xyflow/react";import{Button as Fm,Tooltip as Wm,TooltipContent as Ym,TooltipTrigger as Um,useTranslation as $m}from"lecom-ui";import{useCallback as Xm,useRef as nl,useState as Km}from"react";import{create as Nm}from"zustand";var wt=Nm(e=>({draggableNode:null,setDraggableNode:t=>{e({draggableNode:t})}}));import{useEffect as vm,useState as wm}from"react";var ja=(e,t=!1)=>{let[o,n]=wm({width:0,height:0});return vm(()=>{if(e.current&&t){let r=e.current.getBoundingClientRect();n({width:r.width,height:r.height})}},[t,e]),{dimensions:o}};import{Position as po,useReactFlow as Am}from"@xyflow/react";import{useMemo as Im}from"react";var Cm=120,Sm=12,el=(e,t=!1,o)=>{let{getNode:n,getViewport:r}=Am(),{instanceId:i}=V();return Im(()=>{var f,y;if(!t)return{position:po.Right,align:"start"};let s=n(e);if(!s)return{position:po.Right,align:"start"};let a=r(),l=s.position.x*a.zoom+a.x,c=(((f=s.measured)==null?void 0:f.width)||s.width||100)*a.zoom,d=(y=document.getElementById(`modeler-${i}`))==null?void 0:y.clientWidth;if(!d)return{position:po.Right,align:"start"};let p=(o==null?void 0:o.width)||Cm;return{position:l+c+p+Sm>d?po.Left:po.Right}},[i,e,t,o,n,r])};import{useNodesData as Mm,useReactFlow as Pm}from"@xyflow/react";import{Button as tl,DropdownMenu as Lm,DropdownMenuContent as Dm,DropdownMenuGroup as km,DropdownMenuItem as Rm,DropdownMenuLabel as Vm,DropdownMenuTrigger as Om,Tooltip as wr,TooltipContent as Ar,TooltipTrigger as Ir,useTranslation as Hm}from"lecom-ui";import{WrenchIcon as Gm}from"lucide-react";import{jsx as re,jsxs as tt}from"react/jsx-runtime";var ol=({nodeId:e})=>{let{t}=Hm(),{updateNodeData:o,getEdges:n,getNode:r}=Pm(),i=Mm(e),a=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=p=>{o(e,{variant:(i==null?void 0:i.data.variant)===p?"":p})},d=p=>{o(e,{attribute:(i==null?void 0:i.data.attribute)===p?"":p})};return tt(Lm,{children:[tt(wr,{children:[re(Ir,{asChild:!0,children:re(Om,{asChild:!0,children:re(tl,{variant:"ghost",color:"grey",size:"small",iconButton:!0,children:re(Gm,{})})})}),re(Ar,{color:"black",children:t("bpmn.task.menu.title")})]}),tt(Dm,{align:"start",className:"w-60 bg-white text-grey-600",children:[tt(Vm,{className:"flex items-center gap-1",children:[re("div",{className:"flex-1 text-sm font-semibold",children:t("bpmn.task.menu.title")}),re("div",{className:"flex items-center gap-1",children:Object.entries(Io).map(([p,u])=>{let f=p==="LOOP"&&(a||l),g=(()=>{if(p==="LOOP"&&a)return t("editor.task_menu.loop_not_allowed_when_connected_to_end");if(p==="LOOP"&&l)return t("editor.task_menu.loop_not_allowed_when_subprocess")})();return tt(wr,{children:[re(Ir,{asChild:!0,children:re(tl,{variant:"ghost",color:"grey",size:"small",iconButton:!0,disabled:f,className:D({"bg-grey-100 text-blue-500":(i==null?void 0:i.data.attribute)===p,"opacity-50 cursor-not-allowed":f}),onClick:f?void 0:()=>d(p),children:re(u.icon,{className:"stroke-inherit"})})}),g&&re(Ar,{color:"black",children:g})]},p)})})]}),re(km,{children:tt(wr,{children:[re(Ir,{asChild:!0,children:tt(Rm,{className:D({"bg-grey-100 text-blue-500":(i==null?void 0:i.data.variant)==="SCRIPT","opacity-50 cursor-not-allowed":a}),disabled:a,onClick:a?void 0:()=>c("SCRIPT"),children:[re(Ao.SCRIPT.icon,{className:"stroke-current"}),t(`bpmn.task.variant.${"SCRIPT".toLowerCase()}`)]})}),a&&re(Ar,{color:"black",children:t("editor.task_menu.script_not_allowed_when_connected_to_end")})]})})]})]})};import{jsx as J,jsxs as rl}from"react/jsx-runtime";var ot={START_EVENT:{type:"START_EVENT",icon:Bt,label:"bpmn.start_event.variant.default"},END_EVENT:{type:"END_EVENT",icon:ct,label:"bpmn.end_event.variant.default"},TASK:{type:"TASK",icon:Bt,label:"bpmn.task.variant.default"},ANNOTATION:{type:"ANNOTATION",icon:To,label:"bpmn.annotation.variant.default"}},qm={EXCLUSIVE:{type:"GATEWAY",variant:"EXCLUSIVE",icon:ut,label:"bpmn.gateway.variant.exclusive"},PARALLEL:{type:"GATEWAY",variant:"PARALLEL",icon:pt,label:"bpmn.gateway.variant.parallel"},COMPLEX:{type:"GATEWAY",variant:"COMPLEX",icon:dt,label:"bpmn.gateway.variant.complex"}},ae=({nodeId:e,nodeType:t,nodeVariant:o,isChild:n,isVisible:r})=>{let i=nl(null),s=nl(null),{t:a}=$m(),{setDraggableNode:l}=wt(),{getEdges:c,getNodes:d}=zm(),{setIsDragging:p,mode:u}=V(),{dimensions:f}=ja(i,r),{position:y}=el(e,r,f),[g,m]=Km(void 0),_=d(),h=c(),E=o==="SUBPROCESS",T=Xm((M,L)=>{l({type:L.type,variant:L.variant,attribute:L.attribute,icon:L.icon}),L.icon&&m(J(L.icon,{})),M.dataTransfer.effectAllowed="move",M.dataTransfer.setData("sourceId",e),s.current&&M.dataTransfer.setDragImage(s.current,10,10),setTimeout(()=>{p(!0)},100)},[e,l,p]),N=[{component:J(un,{elementId:e})}],w=()=>u==="view"?[]:[{component:J(ro,{nodeId:e})},ot.TASK,ot.ANNOTATION,...N],x=()=>u==="view"?[{component:J(We,{elementId:e})}]:[{component:J(We,{elementId:e})},...E?[]:[{component:J(ol,{nodeId:e})}],{component:J(ro,{nodeId:e})},ot.TASK,...Object.values(qm),...N],I=()=>u==="view"?[{component:J(We,{elementId:e})}]:[{component:J(We,{elementId:e})},{component:J(ro,{nodeId:e})},ot.TASK,ot.ANNOTATION,...N],R=()=>u==="view"?[]:[{component:J(ro,{nodeId:e})},ot.ANNOTATION,...N],k=()=>u==="view"?[]:[...n?[]:[ot.ANNOTATION],...N],A=()=>u==="view"?[]:[...N],S=()=>u==="view"?[]:[...N],C=(M=>{switch(M){case"START_EVENT":return w();case"TASK":return x();case"GATEWAY":return I();case"END_EVENT":return R();case"LANE":return k();case"ANNOTATION":return A();case"UNSUPPORTED":return S();default:return[]}})(t);if(!(C.length===0||u==="readonly"))return rl(Bm,{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:C.map((M,L)=>{if(M.component)return J("div",{children:M.component},L);let z={sourceNodeType:t,targetNodeType:M.type,sourceNodeId:e,nodes:_,edges:h},H=Sa(z),W={gateway_limit_reached:a("editor.toolbar.gateway_limit_reached"),start_event_already_exists:a("editor.toolbar.start_event_already_exists"),script_to_end_not_allowed:a("editor.toolbar.script_to_end_not_allowed"),loop_to_end_not_allowed:a("editor.toolbar.loop_to_end_not_allowed"),initial_activity_to_end_not_allowed:a("editor.toolbar.initial_activity_to_end_not_allowed"),final_activity_cannot_connect:a("editor.toolbar.final_activity_cannot_connect"),activity_has_outgoing_connections:a("editor.toolbar.activity_has_outgoing_connections"),task_limit_reached:a("editor.toolbar.task_limit_reached")},B=H.shouldDisable&&H.reason?W[H.reason]||a(M.label):a(M.label)||"";return rl(Wm,{children:[J(Um,{asChild:!0,children:J(Fm,{variant:"ghost",color:"grey",size:"small",iconButton:!0,draggable:!H.shouldDisable,disabled:H.shouldDisable,className:H.shouldDisable?"opacity-50 cursor-not-allowed":"",onDragStart:H.shouldDisable?void 0:F=>T(F,M),children:M.icon&&J(M.icon,{size:16})})}),J(Ym,{color:"black",children:B})]},L)})}),J("div",{ref:s,className:"absolute w-0 h-0 top-0 left-0 z-[-1] bg-transparent",children:g})]})};import{jsx as Dn,jsxs as jm}from"react/jsx-runtime";var il=({id:e,data:t,selected:o,dragging:n})=>{let{updateNodeData:r}=Qm(),{inProgress:i,fromNode:s}=Jm(),{mode:a,isConnecting:l,isDragging:c,isMultipleSelection:d}=V(),p=i&&(s==null?void 0:s.id)!==e,u=y=>{r(e,{label:y})},f=!l&&!c&&!d;return jm("div",{className:D("relative w-full h-full min-w-44 min-h-16 flex text-grey-400 hover:text-grey-500 bg-white rounded-sm border-l-2 border-current before:absolute before:top-0 before:left-0 before:w-4 before:border-t-2 before:border-current after:absolute after:bottom-0 after:left-0 after:w-4 after:border-t-2 after:border-current hover:shadow-md transition-colors duration-75",{"text-blue-500 hover:text-blue-600 shadow-md":o,"border-red-500 border-l-[3px] shadow-[0_0_5px_rgba(255,0,0,0.5)] before:absolute before:top-0 before:left-0 before:w-4 before:border-t-2 before:border-red-500 after:absolute after:bottom-0 after:left-0 after:w-4 after:border-t-2 after:border-red-500":t.hasError}),children:[Dn(te,{value:t.label,className:"m-1 text-grey-600",onChange:u}),f&&Dn(ae,{nodeId:e,nodeType:"ANNOTATION",isVisible:!n&&o}),a==="edit"&&Dn(vt,{minWidth:Pn.MIN_WIDTH,minHeight:Pn.MIN_HEIGHT,isVisible:!n&&o}),(!i||p)&&Dn(ee,{type:"target",position:Zm.Left,className:D({"annotation-handle":p})})]})};import{Position as sl,useConnection as eg,useReactFlow as tg}from"@xyflow/react";import{useState as og}from"react";import{jsx as At,jsxs as ng}from"react/jsx-runtime";var al=({id:e,data:t,selected:o,dragging:n})=>{let{updateNodeData:r}=tg(),{inProgress:i,fromNode:s}=eg(),{isConnecting:a,isDragging:l,isMultipleSelection:c}=V(),[d,p]=og(!1),u=i&&(s==null?void 0:s.id)!==e,f=_=>{r(e,{label:_})},y=()=>{p(!0)},g=()=>{p(!1)},m=!a&&!l&&!c;return ng("div",{className:"relative",onBlur:g,onDoubleClick:y,children:[At(ct,{className:D("size-9 hover:stroke-[#d33b3b] transition-colors duration-75",{"stroke-blue-500 hover:stroke-blue-600":o,"stroke-red-500 hover:stroke-red-600 drop-shadow-[0_0_3px_rgba(255,0,0,0.5)] fill-red-100":t.hasError})}),At("div",{className:"absolute top-9 left-1/2 -translate-x-1/2 max-w-80 w-max",children:At(te,{value:t.label,isEditing:d,onChange:f})}),m&&At(ae,{nodeId:e,nodeType:"END_EVENT",isVisible:!n&&o}),(!i||u)&&At(ee,{type:"target",position:sl.Left,className:D({"event-handle":u})}),!i&&At(ee,{type:"source",position:sl.Right})]})};import{Position as ll,useConnection as rg,useReactFlow as ig}from"@xyflow/react";import{useCallback as sg,useState as ag}from"react";import{jsx as It,jsxs as lg}from"react/jsx-runtime";var cl=({id:e,data:t,selected:o,dragging:n})=>{let r=or[t.variant].icon,{updateNodeData:i}=ig(),{inProgress:s,fromNode:a}=rg(),{isConnecting:l,isDragging:c,isMultipleSelection:d}=V(),[p,u]=ag(!1),f=s&&(a==null?void 0:a.id)!==e,y=sg(h=>{i(e,{label:h})},[e,i]),g=()=>{u(!0)},m=()=>{u(!1)},_=!l&&!c&&!d;return lg("div",{className:"relative",onBlur:m,onDoubleClick:g,children:[It(r,{className:D("size-14 stroke-1 stroke-grey-400 hover:stroke-grey-500 transition-colors duration-75",{"stroke-blue-500 hover:stroke-blue-600":o,"stroke-red-500 hover:stroke-red-600 drop-shadow-[0_0_3px_rgba(255,0,0,0.5)]":t.hasError})}),It("div",{className:"absolute top-14 left-1/2 -translate-x-1/2 max-w-80 w-max",children:It(te,{value:t.label,isEditing:p,onChange:y})}),_&&It(ae,{nodeId:e,nodeType:"GATEWAY",isVisible:!n&&o}),(!s||f)&&It(ee,{type:"target",position:ll.Left,className:D({"gateway-handle":f})}),!s&&It(Ln,{type:"source",position:ll.Right,nodeId:e,nodeType:"GATEWAY",gatewayVariant:t.variant})]})};import{useNodesData as ZA,useReactFlow as JA}from"@xyflow/react";import{Button as jA,DropdownMenu as eI,DropdownMenuContent as tI,DropdownMenuGroup as oI,DropdownMenuItem as nI,DropdownMenuLabel as rI,DropdownMenuTrigger as iI,Tooltip as sI,TooltipContent as aI,TooltipTrigger as lI,useTranslation as cI}from"lecom-ui";import{WrenchIcon as uI}from"lucide-react";import{jsx as gI,jsxs as hI}from"react/jsx-runtime";import{Position as dl,useConnection as cg,useReactFlow as dg}from"@xyflow/react";import{useState as ug}from"react";import{jsx as Ct,jsxs as pg}from"react/jsx-runtime";var ul=({id:e,data:t,selected:o,dragging:n})=>{let{updateNodeData:r}=dg(),{inProgress:i,fromNode:s}=cg(),{isConnecting:a,isDragging:l,isMultipleSelection:c}=V(),[d,p]=ug(!1),u=i&&(s==null?void 0:s.id)!==e,f=_=>{r(e,{label:_})},y=()=>{p(!0)},g=()=>{p(!1)},m=!a&&!l&&!c;return pg("div",{className:"relative",onBlur:g,onDoubleClick:y,children:[Ct(vo,{className:D("size-9 hover:stroke-[#54890b] transition-colors duration-75",{"stroke-blue-500 hover:stroke-blue-600":o,"stroke-red-500 hover:stroke-red-600 drop-shadow-[0_0_3px_rgba(255,0,0,0.5)] fill-red-100":t.hasError})}),Ct("div",{className:"absolute top-9 left-1/2 -translate-x-1/2 max-w-80 w-max",children:Ct(te,{value:t.label,isEditing:d,onChange:f})}),m&&Ct(ae,{nodeId:e,nodeType:"START_EVENT",isVisible:!n&&o}),(!i||u)&&Ct(ee,{type:"target",position:dl.Left,className:D({"event-handle":u})}),!i&&Ct(ee,{type:"source",position:dl.Right})]})};import{Position as xl,useConnection as gg,useReactFlow as hg}from"@xyflow/react";import{useTranslation as yg}from"lecom-ui";import{useCallback as xg}from"react";var kn=(e,t)=>{let n=e.filter(i=>i.type==="TASK").map(i=>{var a;let s=(a=i.data)==null?void 0:a.label;if(s&&s.startsWith(`${t} `)){let l=s.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}`},St=(e,t)=>{let n=t.filter(a=>a.type==="TASK").map(a=>{var l;return(l=a.data)==null?void 0:l.label}).filter(Boolean);if(!n.includes(e))return e;let r=e.replace(/\s+\(\d+\)$/,""),i=n.filter(a=>a===r||a.startsWith(`${r} (`)).map(a=>{if(a===r)return 1;let l=a.match(/\s+\((\d+)\)$/);return l?parseInt(l[1],10):0}).filter(a=>a>0),s=2;for(;i.includes(s);)s++;return`${r} (${s})`};import{jsx as pl,jsxs as fg}from"react/jsx-runtime";var fl=e=>fg("svg",v(b({width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",xmlns:"http://www.w3.org/2000/svg"},e),{children:[pl("circle",{cx:"12",cy:"12",r:"10",fill:"#10B981"}),pl("path",{d:"M7 12L10 15L17 8",stroke:"white",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"})]}));import{jsx as ml}from"react/jsx-runtime";var gl=e=>ml("svg",v(b({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 hl,jsxs as mg}from"react/jsx-runtime";var yl=e=>mg("svg",v(b({width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",xmlns:"http://www.w3.org/2000/svg"},e),{children:[hl("circle",{cx:"12",cy:"12",r:"10",fill:"#EF4444"}),hl("path",{d:"M8 8L16 16M8 16L16 8",stroke:"white",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"})]}));import{jsx as me,jsxs as bg}from"react/jsx-runtime";var Eg={APROVADO:fl,EM_ANDAMENTO:gl,REJEITADO:yl},Cr={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)]"},El=({id:e,data:t,selected:o,dragging:n})=>{let{t:r}=yg(),{updateNodeData:i,getNodes:s}=hg(),{inProgress:a,fromNode:l}=gg(),{mode:c,isConnecting:d,isDragging:p,isMultipleSelection:u,onSubprocessValidationClick:f}=V(),{getTaskStatus:y}=Xe(),g=a&&(l==null?void 0:l.id)!==e,m=xg(A=>{let S=A.trim(),P=t.label||"";if(S===P)return;let C=s(),M=S;S||(M=kn(C,r("bpmn.task.label.prefix")));let L=St(M,C);L!==P&&i(e,{label:L})},[t.label,s,e,r,i]),_=y(e),h=_?Eg[_]:null,E=t.variant?Ao[t.variant].icon:null,T=t.attribute?Io[t.attribute].icon:null,N=t.variant==="SUBPROCESS",w=E&&!N,x=T||N,I=()=>t.hasError?Cr.error:_?Cr[_]:Cr.default,R=()=>{f==null||f({id:e,type:"sub_process",label:t.label})},k=!d&&!p&&!u;return bg("div",{className:D("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",I(),{"border-blue-500 hover:border-blue-600 shadow-md":o,"border-red-500 hover:border-red-600 shadow-[0_0_5px_rgba(255,0,0,0.5)]":t.hasError}),children:[me(te,{value:t.label,maxLength:60,className:D("m-1",{"py-6":w||x}),onChange:m}),E&&me("div",{className:D("absolute flex items-center p-1",N?"bottom-0":"top-0 left-0"),children:me(E,{size:16,className:D(t.hasError?"text-red-500":"text-grey-500",N&&"cursor-pointer"),onClick:N?R:void 0})}),T&&me("div",{className:"absolute bottom-0 left-0 w-full flex items-center justify-center",children:me("div",{className:D("flex items-center w-16 p-1",N?"justify-between":"justify-center"),children:me(T,{size:16,className:D(t.hasError?"text-red-500":"text-grey-500")})})}),h&&me("div",{className:"absolute top-0 right-0 flex items-center p-1",children:me(h,{})}),k&&me(ae,{nodeId:e,nodeType:"TASK",nodeVariant:t.variant,isVisible:!n&&o}),c==="edit"&&me(vt,{minWidth:Sn.MIN_WIDTH,minHeight:Sn.MIN_HEIGHT,isVisible:!n&&o}),(!a||g)&&me(ee,{type:"target",position:xl.Left,className:D({"task-handle":g})}),!a&&me(Ln,{type:"source",position:xl.Right,nodeId:e,nodeType:"TASK"})]})};import{Position as bl}from"@xyflow/react";import{Fragment as _g,jsx as Rn,jsxs as Tg}from"react/jsx-runtime";var _l=({id:e,data:t,selected:o,dragging:n})=>{let{isConnecting:r,isDragging:i,isMultipleSelection:s}=V(),a=!r&&!i&&!s;return Tg(_g,{children:[Rn("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}),a&&Rn(ae,{nodeId:e,nodeType:"UNSUPPORTED",isVisible:!n&&o}),Rn(ee,{type:"source",position:bl.Right}),Rn(ee,{type:"target",position:bl.Left})]})};import{BaseEdge as Ng,EdgeLabelRenderer as vg,getSmoothStepPath as wg,MarkerType as Ag,useInternalNode as Tl,useReactFlow as Ig,useViewport as Cg}from"@xyflow/react";import{useState as Sg}from"react";import{jsx as Vn,jsxs as Nl}from"react/jsx-runtime";var XC={type:"MESSAGE_EDGE",markerEnd:{type:Ag.Arrow},data:{label:""}},vl=({id:e,source:t,target:o,data:n,selected:r})=>{let{zoom:i}=Cg(),{updateEdgeData:s}=Ig(),{isMultipleSelection:a}=V(),[l,c]=Sg(!1),d=Tl(t),p=Tl(o);if(!d||!p)return null;let{sx:u,sy:f,tx:y,ty:g,sourcePos:m,targetPos:_}=Pe(d,p),[h,E,T]=wg({sourceX:u,sourceY:f,targetX:y,targetY:g,sourcePosition:m,targetPosition:_}),N=r||(d==null?void 0:d.selected)||(p==null?void 0:p.selected),w=N?"sequence-edge-marker-highlighted":"sequence-edge-marker",x=l||(n==null?void 0:n.label.trim().length)>0,I=1/i,R=()=>{c(!0)},k=()=>{c(!1)},A=S=>{s(e,{label:S.trim()})};return Nl("g",{className:D("text-grey-400 hover:text-grey-500",{"text-blue-500 hover:text-blue-600":N}),onBlur:k,onDoubleClick:R,children:[Vn(Ng,{id:e,path:h,markerEnd:`url(#${w})`,strokeDasharray:4,className:D("stroke-2 stroke-current transition-colors duration-75",{"stroke-red-500 hover:stroke-red-600":n==null?void 0:n.hasError,"stroke-blue-500 hover:stroke-blue-600 drop-shadow-[0_0_3px_rgba(59,130,246,0.5)]":N&&!(n!=null&&n.hasError)})}),Vn(vg,{children:Nl("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&&!a&&Vn(xt,{edgeId:e,edgeType:"MESSAGE_EDGE",style:{transform:`scale(${I})`}}),x&&Vn(te,{value:n==null?void 0:n.label,className:"min-w-8 max-w-56 bg-white rounded-md px-2 py-1 text-xs",isEditing:l,onChange:A})]})})]})};import{getBezierPath as Mg}from"@xyflow/react";import{jsx as wl,jsxs as Pg}from"react/jsx-runtime";var Al=({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:s,sy:a,tx:l,ty:c,sourcePos:d,targetPos:p}=Pe(r,i),[u]=Mg({sourceX:s,sourceY:a,sourcePosition:d||o,targetPosition:p||n,targetX:l||e,targetY:c||t});return Pg("g",{children:[wl("path",{fill:"none",className:"stroke-2 stroke-grey-400 animated",d:u}),wl("circle",{cx:l||e,cy:c||t,fill:"none",r:4,className:"stroke-2 stroke-grey-500"})]})};import{Position as Lg,useReactFlow as Dg}from"@xyflow/react";import{orderBy as kg}from"lodash";import{useMemo as Il,useState as Rg}from"react";import{Fragment as Vg,jsx as nt,jsxs as Cl}from"react/jsx-runtime";var Sl=({id:e,data:t,selected:o,dragging:n,parentId:r})=>{let{updateNodeData:i,getNodes:s}=Dg(),{mode:a,isConnecting:l,isDragging:c,isMultipleSelection:d}=V(),[p,u]=Rg(!1),f=s(),y=!r,g=Il(()=>kg([...f.filter(w=>w.parentId===e&&w.type==="LANE")],"position.y","asc"),[f,e]),m=y?Mn.MIN_WIDTH:X.MIN_WIDTH,_=Il(()=>{if(y&&g.length>1){let w=[...g];return w.pop(),w.reduce((I,R)=>{var k,A;return I+((A=(k=R.measured)==null?void 0:k.height)!=null?A:0)},0)+X.MIN_HEIGHT}return X.MIN_HEIGHT},[y,g]),h=w=>{i(e,{label:w})},E=()=>{u(!0)},T=()=>{u(!1)},N=!l&&!c&&!d;return Cl(Vg,{children:[Cl("div",{className:D("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:[nt("div",{className:"flex align-items justify-center w-10 border-r-2 border-grey-400",onBlur:T,onDoubleClick:E,children:nt("div",{className:D("relative flex-1",{"[writing-mode:vertical-rl] [text-orientation:sideways] transform rotate-180":!p}),children:nt(te,{value:t.label,className:"w-full h-full pointer-events-none self-auto",contentClassName:D({"whitespace-nowrap":p}),isEditing:p,onChange:h})})}),nt("div",{className:"flex-1"})]}),N&&nt(ae,{nodeId:e,nodeType:"LANE",isChild:!y,isVisible:!n&&o}),a==="edit"&&nt(vt,{nodeId:e,minWidth:m,minHeight:_,isVisible:!n&&o}),y&&nt(ee,{type:"source",position:Lg.Right})]})};var Ml={START_EVENT:ul,END_EVENT:al,TASK:El,GATEWAY:cl,ANNOTATION:il,LANE:Sl,UNSUPPORTED:_l},Pl={SEQUENCE_EDGE:wa,MESSAGE_EDGE:vl,ANNOTATION_EDGE:ga},Ll="#fafafa",Dl="#bebebe",kl=1,Rl=10,Vl="bottom-left",Ol=.2,Hl=5,Mt=.5,Gl={x:0,y:0,zoom:.75},Og=1,Hg=2,Bl=[Og,Hg];import{useReactFlow as Bg}from"@xyflow/react";var Gg=1,zl=()=>`<mxGraphModel>
1
+ var ld=Object.defineProperty,cd=Object.defineProperties;var dd=Object.getOwnPropertyDescriptors;var Eo=Object.getOwnPropertySymbols;var jr=Object.prototype.hasOwnProperty,ei=Object.prototype.propertyIsEnumerable;var Qr=(e,t,o)=>t in e?ld(e,t,{enumerable:!0,configurable:!0,writable:!0,value:o}):e[t]=o,b=(e,t)=>{for(var o in t||(t={}))jr.call(t,o)&&Qr(e,o,t[o]);if(Eo)for(var o of Eo(t))ei.call(t,o)&&Qr(e,o,t[o]);return e},v=(e,t)=>cd(e,dd(t));var we=(e,t)=>{var o={};for(var n in e)jr.call(e,n)&&t.indexOf(n)<0&&(o[n]=e[n]);if(e!=null&&Eo)for(var n of Eo(e))t.indexOf(n)<0&&ei.call(e,n)&&(o[n]=e[n]);return o};var $n=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 ud,Translations as pd}from"lecom-ui";var ti={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",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 oi={translations:{general:{layout:{title:"Modeler"}},editor:{toolbar:{delete:"Eliminar",configure_node:"Configurar actividad",configure_edge:"Configurar enrutamiento",initial_task:"Actividad Inicial",gateway_limit_reached:"Compuerta exclusiva no puede tener m\xE1s de 2 conexiones de salida",task_limit_reached:"Actividad no puede tener m\xE1s de 2 conexiones de salida",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 ni={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",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 ri={pt_BR:ni,en_US:ti,es_ES:oi};var ii,si,fd=(si=(ii=$n("LecomUserLanguage"))!=null?ii:$n("org.springframework.web.servlet.i18n.CookieLocaleResolver.LOCALE"))!=null?si:pd.PT_BR;ud({lng:fd,resources:ri});var fe=(n=>(n.EDIT="edit",n.VIEW="view",n.READONLY="readonly",n))(fe||{});var bo=(r=>(r.ACTIVITY="activity",r.ROUTING="routing",r.GATEWAY="gateway",r.SUB_PROCESS="sub_process",r))(bo||{}),Xn=(n=>(n.START="start",n.END="end",n.BETWEEN="between",n))(Xn||{}),Kn=(n=>(n.SCRIPT="script",n.LOOP="loop",n.SCRIPT_LOOP="script_loop",n))(Kn||{}),qn=(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))(qn||{});import{RotateCcw as wd,ScrollText as Ad,SquarePlus as Id}from"lucide-react";import{jsx as _o,jsxs as md}from"react/jsx-runtime";var To=({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:[_o("path",{strokeWidth:"2",d:"M16 3V3.5085V11.9998V20.4915V21H16.5411H21.4592H22V19.123H21.4592H17.9974V11.9998V4.8773H21.4592H22V3H21.4592H16.5411H16Z"}),_o("path",{d:"M4.41026 16.9999L2 18.7861L3.89693 21.1103L6.3072 19.324L4.41026 16.9999Z"}),_o("path",{d:"M8.41026 13.9999L6 15.7861L7.89693 18.1103L10.3072 16.324L8.41026 13.9999Z"}),_o("path",{d:"M12.4313 10.954L10.021 12.7402L11.9179 15.0644L14.3282 13.2781L12.4313 10.954Z"})]});import{jsx as ai}from"react/jsx-runtime";var ct=({size:e=24,className:t})=>ai("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:ai("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 Gt,jsxs as gd}from"react/jsx-runtime";var dt=({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:[Gt("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"}),Gt("path",{d:"M12 8V16",strokeLinecap:"round",strokeLinejoin:"round"}),Gt("path",{d:"M8 12H16",strokeLinecap:"round",strokeLinejoin:"round"}),Gt("path",{d:"M9.17139 9.17188L14.8282 14.8287",strokeLinecap:"round",strokeLinejoin:"round"}),Gt("path",{d:"M14.8281 9.17188L9.17127 14.8287",strokeLinecap:"round",strokeLinejoin:"round"})]});import{jsx as Zn,jsxs as hd}from"react/jsx-runtime";var ut=({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:[Zn("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"}),Zn("path",{d:"M14.8286 9.17188L9.17176 14.8287",strokeLinecap:"round",strokeLinejoin:"round"}),Zn("path",{d:"M9.17139 9.17188L14.8282 14.8287",strokeLinecap:"round",strokeLinejoin:"round"})]});import{jsx as Jn,jsxs as yd}from"react/jsx-runtime";var pt=({size:e=24,className:t})=>yd("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:[Jn("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"}),Jn("path",{d:"M12 8V16",strokeLinecap:"round",strokeLinejoin:"round"}),Jn("path",{d:"M8 12H16",strokeLinecap:"round",strokeLinejoin:"round"})]});import{jsx as Qn,jsxs as xd}from"react/jsx-runtime";var li=({size:e=24,className:t})=>Qn("svg",{width:e,height:e,viewBox:"0 0 34 24",xmlns:"http://www.w3.org/2000/svg",fill:"currentColor",className:t,children:xd("g",{children:[Qn("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"}),Qn("path",{d:"M24.5 4.5L28 1M28 1L31.5 4.5M28 1V8",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round"})]})});import{clsx as Ed}from"clsx";import{twMerge as bd}from"tailwind-merge";function L(...e){return bd(Ed(e))}var Ve=(e=0,t=0)=>e<t?t:e,No=(e=1e3)=>new Promise(t=>{setTimeout(t,e)});import{jsx as ci,jsxs as _d}from"react/jsx-runtime";var di=({size:e=24,className:t})=>_d("svg",{width:e,height:e,viewBox:"0 0 24 24",fill:"none",stroke:"#6b7280",strokeWidth:2,xmlns:"http://www.w3.org/2000/svg",className:L("stroke-2",t),children:[ci("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"}),ci("path",{d:"M9 3V21",strokeLinecap:"round",strokeLinejoin:"round"})]});import{jsx as jn}from"react/jsx-runtime";var ui=({size:e=24,className:t})=>jn("svg",{width:e,height:e,viewBox:"0 0 24 24",xmlns:"http://www.w3.org/2000/svg",stroke:"currentColor",className:t,children:jn("g",{children:jn("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 pi}from"react/jsx-runtime";var vo=({size:e=24,className:t})=>pi("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:pi("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 fi}from"react/jsx-runtime";var Bt=({size:e=24,className:t})=>fi("svg",{width:e,height:e,viewBox:"0 0 24 24",xmlns:"http://www.w3.org/2000/svg",fill:"white",stroke:"#6b7280",className:L("stroke-2",t),children:fi("path",{d:"M20 3H4C2.89543 3 2 4.34315 2 6V18C2 19.6569 2.89543 21 4 21H20C21.1046 21 22 19.6569 22 18V6C22 4.34315 21.1046 3 20 3Z",strokeLinecap:"round",strokeLinejoin:"round"})});import{jsx as er,jsxs as Td}from"react/jsx-runtime";var mi=({size:e=24,className:t})=>Td("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:[er("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"}),er("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"}),er("path",{d:"M7.5 7.5V10H10",strokeWidth:"1.5",fill:"none",strokeLinecap:"round",strokeLinejoin:"round"})]});import{jsx as zt,jsxs as Nd}from"react/jsx-runtime";var gi=({size:e=24,className:t})=>Nd("svg",{width:e,height:e,viewBox:"0 0 24 24",xmlns:"http://www.w3.org/2000/svg",fill:"white",stroke:"#6b7280",strokeWidth:"2",className:t,children:[zt("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"}),zt("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"}),zt("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"}),zt("path",{d:"M13.5 12H11",strokeWidth:"1",strokeLinecap:"round",strokeLinejoin:"round"}),zt("path",{d:"M13.5 10H11",strokeWidth:"1",strokeLinecap:"round",strokeLinejoin:"round"})]});import{jsx as wo,jsxs as vd}from"react/jsx-runtime";var hi=({size:e=24,className:t})=>vd("svg",{width:e,height:e,viewBox:"0 0 24 24",xmlns:"http://www.w3.org/2000/svg",fill:"white",stroke:"#6b7280",strokeWidth:2,className:t,children:[wo("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"}),wo("path",{d:"M8 21V14C8 13.4477 8.44772 13 9 13H15C15.5523 13 16 13.4477 16 14V21",strokeWidth:"1",fill:"none"}),wo("path",{d:"M10.2222 17H13.7777",strokeWidth:"1",strokeLinecap:"round",strokeLinejoin:"round"}),wo("path",{d:"M12 15.2227V18.7782",strokeWidth:"1",strokeLinecap:"round",strokeLinejoin:"round"})]});var G=(a=>(a.START_EVENT="START_EVENT",a.END_EVENT="END_EVENT",a.TASK="TASK",a.LANE="LANE",a.GATEWAY="GATEWAY",a.ANNOTATION="ANNOTATION",a.UNSUPPORTED="UNSUPPORTED",a))(G||{}),Ee=(o=>(o.SCRIPT="SCRIPT",o.SUBPROCESS="SUBPROCESS",o))(Ee||{}),Ao={SCRIPT:{icon:Ad},SUBPROCESS:{icon:Id}},Oe=(t=>(t.LOOP="LOOP",t))(Oe||{}),Io={LOOP:{icon:wd}},be=(n=>(n.EXCLUSIVE="EXCLUSIVE",n.PARALLEL="PARALLEL",n.COMPLEX="COMPLEX",n))(be||{}),tr={EXCLUSIVE:{icon:ut},PARALLEL:{icon:pt},COMPLEX:{icon:dt}};import{ReactFlowProvider as xy}from"@xyflow/react";import{createContext as Ey,useContext as by,useEffect as _y,useId as Ty,useMemo as Ny,useState as Re}from"react";import{Background as Q0,MiniMap as j0,ReactFlow as ey,SelectionMode as ty}from"@xyflow/react";import{forwardRef as oy,useImperativeHandle as ny}from"react";import{useEdgesState as xh,useNodesState as Eh,useOnSelectionChange as bh,useReactFlow as _h}from"@xyflow/react";import{useCallback as kt,useEffect as Th,useRef as Nh,useState as vh}from"react";import{useDebouncedCallback as wh}from"use-debounce";import{create as Cd}from"zustand";import{useReactFlow as Sd}from"@xyflow/react";import{useCallback as Md}from"react";var Co=()=>{let{setEdges:e}=Sd();return Md(()=>{let o=Xe.getState().pathEdgeIds;e(n=>n.map(r=>v(b({},r),{selected:o.includes(r.id)})))},[e])},Xe=Cd((e,t)=>({statusByNodeId:{},statusData:{},pathEdgeIds:[],setTaskStatuses:o=>{o!=null&&o.length&&e(n=>{let r=b({},n.statusByNodeId),i=b({},n.statusData),s=!1;return o.forEach(a=>{let l=`${a.diagramId}-${a.activityId}`;r[a.diagramId]!==a.status&&(r[a.diagramId]=a.status,i[l]=a,s=!0)}),s?{statusByNodeId:r,statusData:i}:n})},getTaskStatus:o=>t().statusByNodeId[o]||null,clearTaskStatuses:()=>e({statusByNodeId:{},statusData:{},pathEdgeIds:[]}),setPathEdges:o=>{e({pathEdgeIds:o})},getPathEdgeIds:()=>t().pathEdgeIds,clearPathEdges:()=>{e({pathEdgeIds:[]})},calculateFlowPath:(o,n)=>{if(!o.length||!n.length)return;t().clearPathEdges();let r=n.filter(d=>t().statusByNodeId[d]);if(r.length<=1)return;let i=[],s={};o.forEach(d=>{s[d.source]||(s[d.source]=[]),s[d.source].push({targetId:d.target,edgeId:d.id})});let a=r[0],l=r[r.length-1];o.forEach(d=>{d.target===a&&i.push(d.id)}),o.forEach(d=>{d.source===l&&i.push(d.id)});let c=(d,p)=>{let u=[],f=new Set;for(u.push({node:d,path:[]}),f.add(d);u.length>0;){let{node:y,path:g}=u.shift();if(y===p)return g;let m=s[y]||[];for(let{targetId:_,edgeId:h}of m)f.has(_)||(f.add(_),u.push({node:_,path:[...g,h]}))}return[]};for(let d=0;d<r.length-1;d++){let p=r[d],u=r[d+1],f=c(p,u);f.length>0&&i.push(...f)}i.length>0&&e({pathEdgeIds:i})}}));import{useNodesInitialized as Up,useReactFlow as $p,useStore as Xp}from"@xyflow/react";var Pd={value:()=>{}};function xi(){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 So(o)}function So(e){this._=e}function Ld(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}})}So.prototype=xi.prototype={constructor:So,on:function(e,t){var o=this._,n=Ld(e+"",o),r,i=-1,s=n.length;if(arguments.length<2){for(;++i<s;)if((r=(e=n[i]).type)&&(r=Dd(o[r],e.name)))return r;return}if(t!=null&&typeof t!="function")throw new Error("invalid callback: "+t);for(;++i<s;)if(r=(e=n[i]).type)o[r]=yi(o[r],e.name,t);else if(t==null)for(r in o)o[r]=yi(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 So(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 Dd(e,t){for(var o=0,n=e.length,r;o<n;++o)if((r=e[o]).name===t)return r.value}function yi(e,t,o){for(var n=0,r=e.length;n<r;++n)if(e[n].name===t){e[n]=Pd,e=e.slice(0,n).concat(e.slice(n+1));break}return o!=null&&e.push({name:t,value:o}),e}var or=xi;var Mo="http://www.w3.org/1999/xhtml",nr={svg:"http://www.w3.org/2000/svg",xhtml:Mo,xlink:"http://www.w3.org/1999/xlink",xml:"http://www.w3.org/XML/1998/namespace",xmlns:"http://www.w3.org/2000/xmlns/"};function Se(e){var t=e+="",o=t.indexOf(":");return o>=0&&(t=e.slice(0,o))!=="xmlns"&&(e=e.slice(o+1)),nr.hasOwnProperty(t)?{space:nr[t],local:e}:e}function kd(e){return function(){var t=this.ownerDocument,o=this.namespaceURI;return o===Mo&&t.documentElement.namespaceURI===Mo?t.createElement(e):t.createElementNS(o,e)}}function Rd(e){return function(){return this.ownerDocument.createElementNS(e.space,e.local)}}function Po(e){var t=Se(e);return(t.local?Rd:kd)(t)}function Vd(){}function Ke(e){return e==null?Vd:function(){return this.querySelector(e)}}function Ei(e){typeof e!="function"&&(e=Ke(e));for(var t=this._groups,o=t.length,n=new Array(o),r=0;r<o;++r)for(var i=t[r],s=i.length,a=n[r]=new Array(s),l,c,d=0;d<s;++d)(l=i[d])&&(c=e.call(l,l.__data__,d,i))&&("__data__"in l&&(c.__data__=l.__data__),a[d]=c);return new q(n,this._parents)}function rr(e){return e==null?[]:Array.isArray(e)?e:Array.from(e)}function Od(){return[]}function Ft(e){return e==null?Od:function(){return this.querySelectorAll(e)}}function Hd(e){return function(){return rr(e.apply(this,arguments))}}function bi(e){typeof e=="function"?e=Hd(e):e=Ft(e);for(var t=this._groups,o=t.length,n=[],r=[],i=0;i<o;++i)for(var s=t[i],a=s.length,l,c=0;c<a;++c)(l=s[c])&&(n.push(e.call(l,l.__data__,c,s)),r.push(l));return new q(n,r)}function Wt(e){return function(){return this.matches(e)}}function Lo(e){return function(t){return t.matches(e)}}var Gd=Array.prototype.find;function Bd(e){return function(){return Gd.call(this.children,e)}}function zd(){return this.firstElementChild}function _i(e){return this.select(e==null?zd:Bd(typeof e=="function"?e:Lo(e)))}var Fd=Array.prototype.filter;function Wd(){return Array.from(this.children)}function Yd(e){return function(){return Fd.call(this.children,e)}}function Ti(e){return this.selectAll(e==null?Wd:Yd(typeof e=="function"?e:Lo(e)))}function Ni(e){typeof e!="function"&&(e=Wt(e));for(var t=this._groups,o=t.length,n=new Array(o),r=0;r<o;++r)for(var i=t[r],s=i.length,a=n[r]=[],l,c=0;c<s;++c)(l=i[c])&&e.call(l,l.__data__,c,i)&&a.push(l);return new q(n,this._parents)}function Do(e){return new Array(e.length)}function vi(){return new q(this._enter||this._groups.map(Do),this._parents)}function Yt(e,t){this.ownerDocument=e.ownerDocument,this.namespaceURI=e.namespaceURI,this._next=null,this._parent=e,this.__data__=t}Yt.prototype={constructor:Yt,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 wi(e){return function(){return e}}function Ud(e,t,o,n,r,i){for(var s=0,a,l=t.length,c=i.length;s<c;++s)(a=t[s])?(a.__data__=i[s],n[s]=a):o[s]=new Yt(e,i[s]);for(;s<l;++s)(a=t[s])&&(r[s]=a)}function $d(e,t,o,n,r,i,s){var a,l,c=new Map,d=t.length,p=i.length,u=new Array(d),f;for(a=0;a<d;++a)(l=t[a])&&(u[a]=f=s.call(l,l.__data__,a,t)+"",c.has(f)?r[a]=l:c.set(f,l));for(a=0;a<p;++a)f=s.call(e,i[a],a,i)+"",(l=c.get(f))?(n[a]=l,l.__data__=i[a],c.delete(f)):o[a]=new Yt(e,i[a]);for(a=0;a<d;++a)(l=t[a])&&c.get(u[a])===l&&(r[a]=l)}function Xd(e){return e.__data__}function Ai(e,t){if(!arguments.length)return Array.from(this,Xd);var o=t?$d:Ud,n=this._parents,r=this._groups;typeof e!="function"&&(e=wi(e));for(var i=r.length,s=new Array(i),a=new Array(i),l=new Array(i),c=0;c<i;++c){var d=n[c],p=r[c],u=p.length,f=Kd(e.call(d,d&&d.__data__,c,n)),y=f.length,g=a[c]=new Array(y),m=s[c]=new Array(y),_=l[c]=new Array(u);o(d,p,g,m,_,f,t);for(var h=0,E=0,T,N;h<y;++h)if(T=g[h]){for(h>=E&&(E=h+1);!(N=m[E])&&++E<y;);T._next=N||null}}return s=new q(s,n),s._enter=a,s._exit=l,s}function Kd(e){return typeof e=="object"&&"length"in e?e:Array.from(e)}function Ii(){return new q(this._exit||this._groups.map(Do),this._parents)}function Ci(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 Si(e){for(var t=e.selection?e.selection():e,o=this._groups,n=t._groups,r=o.length,i=n.length,s=Math.min(r,i),a=new Array(r),l=0;l<s;++l)for(var c=o[l],d=n[l],p=c.length,u=a[l]=new Array(p),f,y=0;y<p;++y)(f=c[y]||d[y])&&(u[y]=f);for(;l<r;++l)a[l]=o[l];return new q(a,this._parents)}function Mi(){for(var e=this._groups,t=-1,o=e.length;++t<o;)for(var n=e[t],r=n.length-1,i=n[r],s;--r>=0;)(s=n[r])&&(i&&s.compareDocumentPosition(i)^4&&i.parentNode.insertBefore(s,i),i=s);return this}function Pi(e){e||(e=qd);function t(p,u){return p&&u?e(p.__data__,u.__data__):!p-!u}for(var o=this._groups,n=o.length,r=new Array(n),i=0;i<n;++i){for(var s=o[i],a=s.length,l=r[i]=new Array(a),c,d=0;d<a;++d)(c=s[d])&&(l[d]=c);l.sort(t)}return new q(r,this._parents).order()}function qd(e,t){return e<t?-1:e>t?1:e>=t?0:NaN}function Li(){var e=arguments[0];return arguments[0]=this,e.apply(null,arguments),this}function Di(){return Array.from(this)}function ki(){for(var e=this._groups,t=0,o=e.length;t<o;++t)for(var n=e[t],r=0,i=n.length;r<i;++r){var s=n[r];if(s)return s}return null}function Ri(){let e=0;for(let t of this)++e;return e}function Vi(){return!this.node()}function Oi(e){for(var t=this._groups,o=0,n=t.length;o<n;++o)for(var r=t[o],i=0,s=r.length,a;i<s;++i)(a=r[i])&&e.call(a,a.__data__,i,r);return this}function Zd(e){return function(){this.removeAttribute(e)}}function Jd(e){return function(){this.removeAttributeNS(e.space,e.local)}}function Qd(e,t){return function(){this.setAttribute(e,t)}}function jd(e,t){return function(){this.setAttributeNS(e.space,e.local,t)}}function eu(e,t){return function(){var o=t.apply(this,arguments);o==null?this.removeAttribute(e):this.setAttribute(e,o)}}function tu(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 Hi(e,t){var o=Se(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?Jd:Zd:typeof t=="function"?o.local?tu:eu:o.local?jd:Qd)(o,t))}function ko(e){return e.ownerDocument&&e.ownerDocument.defaultView||e.document&&e||e.defaultView}function ou(e){return function(){this.style.removeProperty(e)}}function nu(e,t,o){return function(){this.style.setProperty(e,t,o)}}function ru(e,t,o){return function(){var n=t.apply(this,arguments);n==null?this.style.removeProperty(e):this.style.setProperty(e,n,o)}}function Gi(e,t,o){return arguments.length>1?this.each((t==null?ou:typeof t=="function"?ru:nu)(e,t,o==null?"":o)):He(this.node(),e)}function He(e,t){return e.style.getPropertyValue(t)||ko(e).getComputedStyle(e,null).getPropertyValue(t)}function iu(e){return function(){delete this[e]}}function su(e,t){return function(){this[e]=t}}function au(e,t){return function(){var o=t.apply(this,arguments);o==null?delete this[e]:this[e]=o}}function Bi(e,t){return arguments.length>1?this.each((t==null?iu:typeof t=="function"?au:su)(e,t)):this.node()[e]}function zi(e){return e.trim().split(/^|\s+/)}function ir(e){return e.classList||new Fi(e)}function Fi(e){this._node=e,this._names=zi(e.getAttribute("class")||"")}Fi.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 Wi(e,t){for(var o=ir(e),n=-1,r=t.length;++n<r;)o.add(t[n])}function Yi(e,t){for(var o=ir(e),n=-1,r=t.length;++n<r;)o.remove(t[n])}function lu(e){return function(){Wi(this,e)}}function cu(e){return function(){Yi(this,e)}}function du(e,t){return function(){(t.apply(this,arguments)?Wi:Yi)(this,e)}}function Ui(e,t){var o=zi(e+"");if(arguments.length<2){for(var n=ir(this.node()),r=-1,i=o.length;++r<i;)if(!n.contains(o[r]))return!1;return!0}return this.each((typeof t=="function"?du:t?lu:cu)(o,t))}function uu(){this.textContent=""}function pu(e){return function(){this.textContent=e}}function fu(e){return function(){var t=e.apply(this,arguments);this.textContent=t==null?"":t}}function $i(e){return arguments.length?this.each(e==null?uu:(typeof e=="function"?fu:pu)(e)):this.node().textContent}function mu(){this.innerHTML=""}function gu(e){return function(){this.innerHTML=e}}function hu(e){return function(){var t=e.apply(this,arguments);this.innerHTML=t==null?"":t}}function Xi(e){return arguments.length?this.each(e==null?mu:(typeof e=="function"?hu:gu)(e)):this.node().innerHTML}function yu(){this.nextSibling&&this.parentNode.appendChild(this)}function Ki(){return this.each(yu)}function xu(){this.previousSibling&&this.parentNode.insertBefore(this,this.parentNode.firstChild)}function qi(){return this.each(xu)}function Zi(e){var t=typeof e=="function"?e:Po(e);return this.select(function(){return this.appendChild(t.apply(this,arguments))})}function Eu(){return null}function Ji(e,t){var o=typeof e=="function"?e:Po(e),n=t==null?Eu:typeof t=="function"?t:Ke(t);return this.select(function(){return this.insertBefore(o.apply(this,arguments),n.apply(this,arguments)||null)})}function bu(){var e=this.parentNode;e&&e.removeChild(this)}function Qi(){return this.each(bu)}function _u(){var e=this.cloneNode(!1),t=this.parentNode;return t?t.insertBefore(e,this.nextSibling):e}function Tu(){var e=this.cloneNode(!0),t=this.parentNode;return t?t.insertBefore(e,this.nextSibling):e}function ji(e){return this.select(e?Tu:_u)}function es(e){return arguments.length?this.property("__data__",e):this.node().__data__}function Nu(e){return function(t){e.call(this,t,this.__data__)}}function vu(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 wu(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 Au(e,t,o){return function(){var n=this.__on,r,i=Nu(t);if(n){for(var s=0,a=n.length;s<a;++s)if((r=n[s]).type===e.type&&r.name===e.name){this.removeEventListener(r.type,r.listener,r.options),this.addEventListener(r.type,r.listener=i,r.options=o),r.value=t;return}}this.addEventListener(e.type,i,o),r={type:e.type,name:e.name,value:t,listener:i,options:o},n?n.push(r):this.__on=[r]}}function ts(e,t,o){var n=vu(e+""),r,i=n.length,s;if(arguments.length<2){var a=this.node().__on;if(a){for(var l=0,c=a.length,d;l<c;++l)for(r=0,d=a[l];r<i;++r)if((s=n[r]).type===d.type&&s.name===d.name)return d.value}return}for(a=t?Au:wu,r=0;r<i;++r)this.each(a(n[r],t,o));return this}function os(e,t,o){var n=ko(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 Iu(e,t){return function(){return os(this,e,t)}}function Cu(e,t){return function(){return os(this,e,t.apply(this,arguments))}}function ns(e,t){return this.each((typeof t=="function"?Cu:Iu)(e,t))}function*rs(){for(var e=this._groups,t=0,o=e.length;t<o;++t)for(var n=e[t],r=0,i=n.length,s;r<i;++r)(s=n[r])&&(yield s)}var Su=[null];function q(e,t){this._groups=e,this._parents=t}function is(){return new q([[document.documentElement]],Su)}function Mu(){return this}q.prototype=is.prototype={constructor:q,select:Ei,selectAll:bi,selectChild:_i,selectChildren:Ti,filter:Ni,data:Ai,enter:vi,exit:Ii,join:Ci,merge:Si,selection:Mu,order:Mi,sort:Pi,call:Li,nodes:Di,node:ki,size:Ri,empty:Vi,each:Oi,attr:Hi,style:Gi,property:Bi,classed:Ui,text:$i,html:Xi,raise:Ki,lower:qi,append:Zi,insert:Ji,remove:Qi,clone:ji,datum:es,on:ts,dispatch:ns,[Symbol.iterator]:rs};var Me=is;function Ro(e,t,o){e.prototype=t.prototype=o,o.constructor=e}function sr(e,t){var o=Object.create(e.prototype);for(var n in t)o[n]=t[n];return o}function Xt(){}var Ut=.7,Ho=1/Ut,ft="\\s*([+-]?\\d+)\\s*",$t="\\s*([+-]?(?:\\d*\\.)?\\d+(?:[eE][+-]?\\d+)?)\\s*",Ae="\\s*([+-]?(?:\\d*\\.)?\\d+(?:[eE][+-]?\\d+)?)%\\s*",Pu=/^#([0-9a-f]{3,8})$/,Lu=new RegExp(`^rgb\\(${ft},${ft},${ft}\\)$`),Du=new RegExp(`^rgb\\(${Ae},${Ae},${Ae}\\)$`),ku=new RegExp(`^rgba\\(${ft},${ft},${ft},${$t}\\)$`),Ru=new RegExp(`^rgba\\(${Ae},${Ae},${Ae},${$t}\\)$`),Vu=new RegExp(`^hsl\\(${$t},${Ae},${Ae}\\)$`),Ou=new RegExp(`^hsla\\(${$t},${Ae},${Ae},${$t}\\)$`),ss={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};Ro(Xt,Ge,{copy(e){return Object.assign(new this.constructor,this,e)},displayable(){return this.rgb().displayable()},hex:as,formatHex:as,formatHex8:Hu,formatHsl:Gu,formatRgb:ls,toString:ls});function as(){return this.rgb().formatHex()}function Hu(){return this.rgb().formatHex8()}function Gu(){return ms(this).formatHsl()}function ls(){return this.rgb().formatRgb()}function Ge(e){var t,o;return e=(e+"").trim().toLowerCase(),(t=Pu.exec(e))?(o=t[1].length,t=parseInt(t[1],16),o===6?cs(t):o===3?new ie(t>>8&15|t>>4&240,t>>4&15|t&240,(t&15)<<4|t&15,1):o===8?Vo(t>>24&255,t>>16&255,t>>8&255,(t&255)/255):o===4?Vo(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=Lu.exec(e))?new ie(t[1],t[2],t[3],1):(t=Du.exec(e))?new ie(t[1]*255/100,t[2]*255/100,t[3]*255/100,1):(t=ku.exec(e))?Vo(t[1],t[2],t[3],t[4]):(t=Ru.exec(e))?Vo(t[1]*255/100,t[2]*255/100,t[3]*255/100,t[4]):(t=Vu.exec(e))?ps(t[1],t[2]/100,t[3]/100,1):(t=Ou.exec(e))?ps(t[1],t[2]/100,t[3]/100,t[4]):ss.hasOwnProperty(e)?cs(ss[e]):e==="transparent"?new ie(NaN,NaN,NaN,0):null}function cs(e){return new ie(e>>16&255,e>>8&255,e&255,1)}function Vo(e,t,o,n){return n<=0&&(e=t=o=NaN),new ie(e,t,o,n)}function Bu(e){return e instanceof Xt||(e=Ge(e)),e?(e=e.rgb(),new ie(e.r,e.g,e.b,e.opacity)):new ie}function mt(e,t,o,n){return arguments.length===1?Bu(e):new ie(e,t,o,n==null?1:n)}function ie(e,t,o,n){this.r=+e,this.g=+t,this.b=+o,this.opacity=+n}Ro(ie,mt,sr(Xt,{brighter(e){return e=e==null?Ho:Math.pow(Ho,e),new ie(this.r*e,this.g*e,this.b*e,this.opacity)},darker(e){return e=e==null?Ut:Math.pow(Ut,e),new ie(this.r*e,this.g*e,this.b*e,this.opacity)},rgb(){return this},clamp(){return new ie(Ze(this.r),Ze(this.g),Ze(this.b),Go(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:ds,formatHex:ds,formatHex8:zu,formatRgb:us,toString:us}));function ds(){return`#${qe(this.r)}${qe(this.g)}${qe(this.b)}`}function zu(){return`#${qe(this.r)}${qe(this.g)}${qe(this.b)}${qe((isNaN(this.opacity)?1:this.opacity)*255)}`}function us(){let e=Go(this.opacity);return`${e===1?"rgb(":"rgba("}${Ze(this.r)}, ${Ze(this.g)}, ${Ze(this.b)}${e===1?")":`, ${e})`}`}function Go(e){return isNaN(e)?1:Math.max(0,Math.min(1,e))}function Ze(e){return Math.max(0,Math.min(255,Math.round(e)||0))}function qe(e){return e=Ze(e),(e<16?"0":"")+e.toString(16)}function ps(e,t,o,n){return n<=0?e=t=o=NaN:o<=0||o>=1?e=t=NaN:t<=0&&(e=NaN),new _e(e,t,o,n)}function ms(e){if(e instanceof _e)return new _e(e.h,e.s,e.l,e.opacity);if(e instanceof Xt||(e=Ge(e)),!e)return new _e;if(e instanceof _e)return e;e=e.rgb();var t=e.r/255,o=e.g/255,n=e.b/255,r=Math.min(t,o,n),i=Math.max(t,o,n),s=NaN,a=i-r,l=(i+r)/2;return a?(t===i?s=(o-n)/a+(o<n)*6:o===i?s=(n-t)/a+2:s=(t-o)/a+4,a/=l<.5?i+r:2-i-r,s*=60):a=l>0&&l<1?0:s,new _e(s,a,l,e.opacity)}function gs(e,t,o,n){return arguments.length===1?ms(e):new _e(e,t,o,n==null?1:n)}function _e(e,t,o,n){this.h=+e,this.s=+t,this.l=+o,this.opacity=+n}Ro(_e,gs,sr(Xt,{brighter(e){return e=e==null?Ho:Math.pow(Ho,e),new _e(this.h,this.s,this.l*e,this.opacity)},darker(e){return e=e==null?Ut:Math.pow(Ut,e),new _e(this.h,this.s,this.l*e,this.opacity)},rgb(){var e=this.h%360+(this.h<0)*360,t=isNaN(e)||isNaN(this.s)?0:this.s,o=this.l,n=o+(o<.5?o:1-o)*t,r=2*o-n;return new ie(ar(e>=240?e-240:e+120,r,n),ar(e,r,n),ar(e<120?e+240:e-120,r,n),this.opacity)},clamp(){return new _e(fs(this.h),Oo(this.s),Oo(this.l),Go(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=Go(this.opacity);return`${e===1?"hsl(":"hsla("}${fs(this.h)}, ${Oo(this.s)*100}%, ${Oo(this.l)*100}%${e===1?")":`, ${e})`}`}}));function fs(e){return e=(e||0)%360,e<0?e+360:e}function Oo(e){return Math.max(0,Math.min(1,e||0))}function ar(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 lr(e,t,o,n,r){var i=e*e,s=i*e;return((1-3*e+3*i-s)*t+(4-6*i+3*s)*o+(1+3*e+3*i-3*s)*n+s*r)/6}function hs(e){var t=e.length-1;return function(o){var n=o<=0?o=0:o>=1?(o=1,t-1):Math.floor(o*t),r=e[n],i=e[n+1],s=n>0?e[n-1]:2*r-i,a=n<t-1?e[n+2]:2*i-r;return lr((o-n/t)*t,s,r,i,a)}}function ys(e){var t=e.length;return function(o){var n=Math.floor(((o%=1)<0?++o:o)*t),r=e[(n+t-1)%t],i=e[n%t],s=e[(n+1)%t],a=e[(n+2)%t];return lr((o-n/t)*t,r,i,s,a)}}var cr=e=>()=>e;function Fu(e,t){return function(o){return e+o*t}}function Wu(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 xs(e){return(e=+e)==1?Bo:function(t,o){return o-t?Wu(t,o,e):cr(isNaN(t)?o:t)}}function Bo(e,t){var o=t-e;return o?Fu(e,o):cr(isNaN(e)?t:e)}var zo=function e(t){var o=xs(t);function n(r,i){var s=o((r=mt(r)).r,(i=mt(i)).r),a=o(r.g,i.g),l=o(r.b,i.b),c=Bo(r.opacity,i.opacity);return function(d){return r.r=s(d),r.g=a(d),r.b=l(d),r.opacity=c(d),r+""}}return n.gamma=e,n}(1);function Es(e){return function(t){var o=t.length,n=new Array(o),r=new Array(o),i=new Array(o),s,a;for(s=0;s<o;++s)a=mt(t[s]),n[s]=a.r||0,r[s]=a.g||0,i[s]=a.b||0;return n=e(n),r=e(r),i=e(i),a.opacity=1,function(l){return a.r=n(l),a.g=r(l),a.b=i(l),a+""}}}var Yu=Es(hs),Uu=Es(ys);function me(e,t){return e=+e,t=+t,function(o){return e*(1-o)+t*o}}var ur=/[-+]?(?:\d+\.?\d*|\.?\d+)(?:[eE][-+]?\d+)?/g,dr=new RegExp(ur.source,"g");function $u(e){return function(){return e}}function Xu(e){return function(t){return e(t)+""}}function pr(e,t){var o=ur.lastIndex=dr.lastIndex=0,n,r,i,s=-1,a=[],l=[];for(e=e+"",t=t+"";(n=ur.exec(e))&&(r=dr.exec(t));)(i=r.index)>o&&(i=t.slice(o,i),a[s]?a[s]+=i:a[++s]=i),(n=n[0])===(r=r[0])?a[s]?a[s]+=r:a[++s]=r:(a[++s]=null,l.push({i:s,x:me(n,r)})),o=dr.lastIndex;return o<t.length&&(i=t.slice(o),a[s]?a[s]+=i:a[++s]=i),a.length<2?l[0]?Xu(l[0].x):$u(t):(t=l.length,function(c){for(var d=0,p;d<t;++d)a[(p=l[d]).i]=p.x(c);return a.join("")})}var bs=180/Math.PI,Fo={translateX:0,translateY:0,rotate:0,skewX:0,scaleX:1,scaleY:1};function fr(e,t,o,n,r,i){var s,a,l;return(s=Math.sqrt(e*e+t*t))&&(e/=s,t/=s),(l=e*o+t*n)&&(o-=e*l,n-=t*l),(a=Math.sqrt(o*o+n*n))&&(o/=a,n/=a,l/=a),e*n<t*o&&(e=-e,t=-t,l=-l,s=-s),{translateX:r,translateY:i,rotate:Math.atan2(t,e)*bs,skewX:Math.atan(l)*bs,scaleX:s,scaleY:a}}var Wo;function _s(e){let t=new(typeof DOMMatrix=="function"?DOMMatrix:WebKitCSSMatrix)(e+"");return t.isIdentity?Fo:fr(t.a,t.b,t.c,t.d,t.e,t.f)}function Ts(e){return e==null?Fo:(Wo||(Wo=document.createElementNS("http://www.w3.org/2000/svg","g")),Wo.setAttribute("transform",e),(e=Wo.transform.baseVal.consolidate())?(e=e.matrix,fr(e.a,e.b,e.c,e.d,e.e,e.f)):Fo)}function Ns(e,t,o,n){function r(c){return c.length?c.pop()+" ":""}function i(c,d,p,u,f,y){if(c!==p||d!==u){var g=f.push("translate(",null,t,null,o);y.push({i:g-4,x:me(c,p)},{i:g-2,x:me(d,u)})}else(p||u)&&f.push("translate("+p+t+u+o)}function s(c,d,p,u){c!==d?(c-d>180?d+=360:d-c>180&&(c+=360),u.push({i:p.push(r(p)+"rotate(",null,n)-2,x:me(c,d)})):d&&p.push(r(p)+"rotate("+d+n)}function a(c,d,p,u){c!==d?u.push({i:p.push(r(p)+"skewX(",null,n)-2,x:me(c,d)}):d&&p.push(r(p)+"skewX("+d+n)}function l(c,d,p,u,f,y){if(c!==p||d!==u){var g=f.push(r(f)+"scale(",null,",",null,")");y.push({i:g-4,x:me(c,p)},{i:g-2,x:me(d,u)})}else(p!==1||u!==1)&&f.push(r(f)+"scale("+p+","+u+")")}return function(c,d){var p=[],u=[];return c=e(c),d=e(d),i(c.translateX,c.translateY,d.translateX,d.translateY,p,u),s(c.rotate,d.rotate,p,u),a(c.skewX,d.skewX,p,u),l(c.scaleX,c.scaleY,d.scaleX,d.scaleY,p,u),c=d=null,function(f){for(var y=-1,g=u.length,m;++y<g;)p[(m=u[y]).i]=m.x(f);return p.join("")}}}var mr=Ns(_s,"px, ","px)","deg)"),gr=Ns(Ts,", ",")",")");var gt=0,qt=0,Kt=0,ws=1e3,Yo,Zt,Uo=0,Je=0,$o=0,Jt=typeof performance=="object"&&performance.now?performance:Date,As=typeof window=="object"&&window.requestAnimationFrame?window.requestAnimationFrame.bind(window):function(e){setTimeout(e,17)};function jt(){return Je||(As(Ku),Je=Jt.now()+$o)}function Ku(){Je=0}function Qt(){this._call=this._time=this._next=null}Qt.prototype=Xo.prototype={constructor:Qt,restart:function(e,t,o){if(typeof e!="function")throw new TypeError("callback is not a function");o=(o==null?jt():+o)+(t==null?0:+t),!this._next&&Zt!==this&&(Zt?Zt._next=this:Yo=this,Zt=this),this._call=e,this._time=o,hr()},stop:function(){this._call&&(this._call=null,this._time=1/0,hr())}};function Xo(e,t,o){var n=new Qt;return n.restart(e,t,o),n}function Is(){jt(),++gt;for(var e=Yo,t;e;)(t=Je-e._time)>=0&&e._call.call(void 0,t),e=e._next;--gt}function vs(){Je=(Uo=Jt.now())+$o,gt=qt=0;try{Is()}finally{gt=0,Zu(),Je=0}}function qu(){var e=Jt.now(),t=e-Uo;t>ws&&($o-=t,Uo=e)}function Zu(){for(var e,t=Yo,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:Yo=o);Zt=e,hr(n)}function hr(e){if(!gt){qt&&(qt=clearTimeout(qt));var t=e-Je;t>24?(e<1/0&&(qt=setTimeout(vs,e-Jt.now()-$o)),Kt&&(Kt=clearInterval(Kt))):(Kt||(Uo=Jt.now(),Kt=setInterval(qu,ws)),gt=1,As(vs))}}function Ko(e,t,o){var n=new Qt;return t=t==null?0:+t,n.restart(r=>{n.stop(),e(r+t)},t,o),n}var Ju=or("start","end","cancel","interrupt"),Qu=[],Ms=0,Cs=1,Zo=2,qo=3,Ss=4,Jo=5,eo=6;function Be(e,t,o,n,r,i){var s=e.__transition;if(!s)e.__transition={};else if(o in s)return;ju(e,o,{name:t,index:n,group:r,on:Ju,tween:Qu,time:i.time,delay:i.delay,duration:i.duration,ease:i.ease,timer:null,state:Ms})}function to(e,t){var o=Z(e,t);if(o.state>Ms)throw new Error("too late; already scheduled");return o}function j(e,t){var o=Z(e,t);if(o.state>qo)throw new Error("too late; already running");return o}function Z(e,t){var o=e.__transition;if(!o||!(o=o[t]))throw new Error("transition not found");return o}function ju(e,t,o){var n=e.__transition,r;n[t]=o,o.timer=Xo(i,0,o.time);function i(c){o.state=Cs,o.timer.restart(s,o.delay,o.time),o.delay<=c&&s(c-o.delay)}function s(c){var d,p,u,f;if(o.state!==Cs)return l();for(d in n)if(f=n[d],f.name===o.name){if(f.state===qo)return Ko(s);f.state===Ss?(f.state=eo,f.timer.stop(),f.on.call("interrupt",e,e.__data__,f.index,f.group),delete n[d]):+d<t&&(f.state=eo,f.timer.stop(),f.on.call("cancel",e,e.__data__,f.index,f.group),delete n[d])}if(Ko(function(){o.state===qo&&(o.state=Ss,o.timer.restart(a,o.delay,o.time),a(c))}),o.state=Zo,o.on.call("start",e,e.__data__,o.index,o.group),o.state===Zo){for(o.state=qo,r=new Array(u=o.tween.length),d=0,p=-1;d<u;++d)(f=o.tween[d].value.call(e,e.__data__,o.index,o.group))&&(r[++p]=f);r.length=p+1}}function a(c){for(var d=c<o.duration?o.ease.call(null,c/o.duration):(o.timer.restart(l),o.state=Jo,1),p=-1,u=r.length;++p<u;)r[p].call(e,d);o.state===Jo&&(o.on.call("end",e,e.__data__,o.index,o.group),l())}function l(){o.state=eo,o.timer.stop(),delete n[t];for(var c in n)return;delete e.__transition}}function yr(e,t){var o=e.__transition,n,r,i=!0,s;if(o){t=t==null?null:t+"";for(s in o){if((n=o[s]).name!==t){i=!1;continue}r=n.state>Zo&&n.state<Jo,n.state=eo,n.timer.stop(),n.on.call(r?"interrupt":"cancel",e,e.__data__,n.index,n.group),delete o[s]}i&&delete e.__transition}}function Ps(e){return this.each(function(){yr(this,e)})}function ep(e,t){var o,n;return function(){var r=j(this,e),i=r.tween;if(i!==o){n=o=i;for(var s=0,a=n.length;s<a;++s)if(n[s].name===t){n=n.slice(),n.splice(s,1);break}}r.tween=n}}function tp(e,t,o){var n,r;if(typeof o!="function")throw new Error;return function(){var i=j(this,e),s=i.tween;if(s!==n){r=(n=s).slice();for(var a={name:t,value:o},l=0,c=r.length;l<c;++l)if(r[l].name===t){r[l]=a;break}l===c&&r.push(a)}i.tween=r}}function Ls(e,t){var o=this._id;if(e+="",arguments.length<2){for(var n=Z(this.node(),o).tween,r=0,i=n.length,s;r<i;++r)if((s=n[r]).name===e)return s.value;return null}return this.each((t==null?ep:tp)(o,e,t))}function ht(e,t,o){var n=e._id;return e.each(function(){var r=j(this,n);(r.value||(r.value={}))[t]=o.apply(this,arguments)}),function(r){return Z(r,n).value[t]}}function Qo(e,t){var o;return(typeof t=="number"?me:t instanceof Ge?zo:(o=Ge(t))?(t=o,zo):pr)(e,t)}function op(e){return function(){this.removeAttribute(e)}}function np(e){return function(){this.removeAttributeNS(e.space,e.local)}}function rp(e,t,o){var n,r=o+"",i;return function(){var s=this.getAttribute(e);return s===r?null:s===n?i:i=t(n=s,o)}}function ip(e,t,o){var n,r=o+"",i;return function(){var s=this.getAttributeNS(e.space,e.local);return s===r?null:s===n?i:i=t(n=s,o)}}function sp(e,t,o){var n,r,i;return function(){var s,a=o(this),l;return a==null?void this.removeAttribute(e):(s=this.getAttribute(e),l=a+"",s===l?null:s===n&&l===r?i:(r=l,i=t(n=s,a)))}}function ap(e,t,o){var n,r,i;return function(){var s,a=o(this),l;return a==null?void this.removeAttributeNS(e.space,e.local):(s=this.getAttributeNS(e.space,e.local),l=a+"",s===l?null:s===n&&l===r?i:(r=l,i=t(n=s,a)))}}function Ds(e,t){var o=Se(e),n=o==="transform"?gr:Qo;return this.attrTween(e,typeof t=="function"?(o.local?ap:sp)(o,n,ht(this,"attr."+e,t)):t==null?(o.local?np:op)(o):(o.local?ip:rp)(o,n,t))}function lp(e,t){return function(o){this.setAttribute(e,t.call(this,o))}}function cp(e,t){return function(o){this.setAttributeNS(e.space,e.local,t.call(this,o))}}function dp(e,t){var o,n;function r(){var i=t.apply(this,arguments);return i!==n&&(o=(n=i)&&cp(e,i)),o}return r._value=t,r}function up(e,t){var o,n;function r(){var i=t.apply(this,arguments);return i!==n&&(o=(n=i)&&lp(e,i)),o}return r._value=t,r}function ks(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=Se(e);return this.tween(o,(n.local?dp:up)(n,t))}function pp(e,t){return function(){to(this,e).delay=+t.apply(this,arguments)}}function fp(e,t){return t=+t,function(){to(this,e).delay=t}}function Rs(e){var t=this._id;return arguments.length?this.each((typeof e=="function"?pp:fp)(t,e)):Z(this.node(),t).delay}function mp(e,t){return function(){j(this,e).duration=+t.apply(this,arguments)}}function gp(e,t){return t=+t,function(){j(this,e).duration=t}}function Vs(e){var t=this._id;return arguments.length?this.each((typeof e=="function"?mp:gp)(t,e)):Z(this.node(),t).duration}function hp(e,t){if(typeof t!="function")throw new Error;return function(){j(this,e).ease=t}}function Os(e){var t=this._id;return arguments.length?this.each(hp(t,e)):Z(this.node(),t).ease}function yp(e,t){return function(){var o=t.apply(this,arguments);if(typeof o!="function")throw new Error;j(this,e).ease=o}}function Hs(e){if(typeof e!="function")throw new Error;return this.each(yp(this._id,e))}function Gs(e){typeof e!="function"&&(e=Wt(e));for(var t=this._groups,o=t.length,n=new Array(o),r=0;r<o;++r)for(var i=t[r],s=i.length,a=n[r]=[],l,c=0;c<s;++c)(l=i[c])&&e.call(l,l.__data__,c,i)&&a.push(l);return new ne(n,this._parents,this._name,this._id)}function Bs(e){if(e._id!==this._id)throw new Error;for(var t=this._groups,o=e._groups,n=t.length,r=o.length,i=Math.min(n,r),s=new Array(n),a=0;a<i;++a)for(var l=t[a],c=o[a],d=l.length,p=s[a]=new Array(d),u,f=0;f<d;++f)(u=l[f]||c[f])&&(p[f]=u);for(;a<n;++a)s[a]=t[a];return new ne(s,this._parents,this._name,this._id)}function xp(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 Ep(e,t,o){var n,r,i=xp(t)?to:j;return function(){var s=i(this,e),a=s.on;a!==n&&(r=(n=a).copy()).on(t,o),s.on=r}}function zs(e,t){var o=this._id;return arguments.length<2?Z(this.node(),o).on.on(e):this.each(Ep(o,e,t))}function bp(e){return function(){var t=this.parentNode;for(var o in this.__transition)if(+o!==e)return;t&&t.removeChild(this)}}function Fs(){return this.on("end.remove",bp(this._id))}function Ws(e){var t=this._name,o=this._id;typeof e!="function"&&(e=Ke(e));for(var n=this._groups,r=n.length,i=new Array(r),s=0;s<r;++s)for(var a=n[s],l=a.length,c=i[s]=new Array(l),d,p,u=0;u<l;++u)(d=a[u])&&(p=e.call(d,d.__data__,u,a))&&("__data__"in d&&(p.__data__=d.__data__),c[u]=p,Be(c[u],t,o,u,c,Z(d,o)));return new ne(i,this._parents,t,o)}function Ys(e){var t=this._name,o=this._id;typeof e!="function"&&(e=Ft(e));for(var n=this._groups,r=n.length,i=[],s=[],a=0;a<r;++a)for(var l=n[a],c=l.length,d,p=0;p<c;++p)if(d=l[p]){for(var u=e.call(d,d.__data__,p,l),f,y=Z(d,o),g=0,m=u.length;g<m;++g)(f=u[g])&&Be(f,t,o,g,u,y);i.push(u),s.push(d)}return new ne(i,s,t,o)}var _p=Me.prototype.constructor;function Us(){return new _p(this._groups,this._parents)}function Tp(e,t){var o,n,r;return function(){var i=He(this,e),s=(this.style.removeProperty(e),He(this,e));return i===s?null:i===o&&s===n?r:r=t(o=i,n=s)}}function $s(e){return function(){this.style.removeProperty(e)}}function Np(e,t,o){var n,r=o+"",i;return function(){var s=He(this,e);return s===r?null:s===n?i:i=t(n=s,o)}}function vp(e,t,o){var n,r,i;return function(){var s=He(this,e),a=o(this),l=a+"";return a==null&&(l=a=(this.style.removeProperty(e),He(this,e))),s===l?null:s===n&&l===r?i:(r=l,i=t(n=s,a))}}function wp(e,t){var o,n,r,i="style."+t,s="end."+i,a;return function(){var l=j(this,e),c=l.on,d=l.value[i]==null?a||(a=$s(t)):void 0;(c!==o||r!==d)&&(n=(o=c).copy()).on(s,r=d),l.on=n}}function Xs(e,t,o){var n=(e+="")=="transform"?mr:Qo;return t==null?this.styleTween(e,Tp(e,n)).on("end.style."+e,$s(e)):typeof t=="function"?this.styleTween(e,vp(e,n,ht(this,"style."+e,t))).each(wp(this._id,e)):this.styleTween(e,Np(e,n,t),o).on("end.style."+e,null)}function Ap(e,t,o){return function(n){this.style.setProperty(e,t.call(this,n),o)}}function Ip(e,t,o){var n,r;function i(){var s=t.apply(this,arguments);return s!==r&&(n=(r=s)&&Ap(e,s,o)),n}return i._value=t,i}function Ks(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,Ip(e,t,o==null?"":o))}function Cp(e){return function(){this.textContent=e}}function Sp(e){return function(){var t=e(this);this.textContent=t==null?"":t}}function qs(e){return this.tween("text",typeof e=="function"?Sp(ht(this,"text",e)):Cp(e==null?"":e+""))}function Mp(e){return function(t){this.textContent=e.call(this,t)}}function Pp(e){var t,o;function n(){var r=e.apply(this,arguments);return r!==o&&(t=(o=r)&&Mp(r)),t}return n._value=e,n}function Zs(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,Pp(e))}function Js(){for(var e=this._name,t=this._id,o=jo(),n=this._groups,r=n.length,i=0;i<r;++i)for(var s=n[i],a=s.length,l,c=0;c<a;++c)if(l=s[c]){var d=Z(l,t);Be(l,e,o,c,s,{time:d.time+d.delay+d.duration,delay:0,duration:d.duration,ease:d.ease})}return new ne(n,this._parents,e,o)}function Qs(){var e,t,o=this,n=o._id,r=o.size();return new Promise(function(i,s){var a={value:s},l={value:function(){--r===0&&i()}};o.each(function(){var c=j(this,n),d=c.on;d!==e&&(t=(e=d).copy(),t._.cancel.push(a),t._.interrupt.push(a),t._.end.push(l)),c.on=t}),r===0&&i()})}var Lp=0;function ne(e,t,o,n){this._groups=e,this._parents=t,this._name=o,this._id=n}function js(e){return Me().transition(e)}function jo(){return++Lp}var Pe=Me.prototype;ne.prototype=js.prototype={constructor:ne,select:Ws,selectAll:Ys,selectChild:Pe.selectChild,selectChildren:Pe.selectChildren,filter:Gs,merge:Bs,selection:Us,transition:Js,call:Pe.call,nodes:Pe.nodes,node:Pe.node,size:Pe.size,empty:Pe.empty,each:Pe.each,on:zs,attr:Ds,attrTween:ks,style:Xs,styleTween:Ks,text:qs,textTween:Zs,remove:Fs,tween:Ls,delay:Rs,duration:Vs,ease:Os,easeVarying:Hs,end:Qs,[Symbol.iterator]:Pe[Symbol.iterator]};function en(e){return((e*=2)<=1?e*e*e:(e-=2)*e*e+2)/2}var Dp={time:null,delay:0,duration:250,ease:en};function kp(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 ea(e){var t,o;e instanceof ne?(t=e._id,e=e._name):(t=jo(),(o=Dp).time=jt(),e=e==null?null:e+"");for(var n=this._groups,r=n.length,i=0;i<r;++i)for(var s=n[i],a=s.length,l,c=0;c<a;++c)(l=s[c])&&Be(l,e,t,c,s,o||kp(l,t));return new ne(n,this._parents,e,t)}Me.prototype.interrupt=Ps;Me.prototype.transition=ea;function ze(e,t,o){this.k=e,this.x=t,this.y=o}ze.prototype={constructor:ze,scale:function(e){return e===1?this:new ze(this.k*e,this.x,this.y)},translate:function(e,t){return e===0&t===0?this:new ze(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 tn=new ze(1,0,0);on.prototype=ze.prototype;function on(e){for(;!e.__zoom;)if(!(e=e.parentNode))return tn;return e.__zoom}var Vp=[[Number.NEGATIVE_INFINITY,Number.NEGATIVE_INFINITY],[Number.POSITIVE_INFINITY,Number.POSITIVE_INFINITY]];var ta;(function(e){e.Strict="strict",e.Loose="loose"})(ta||(ta={}));var oa;(function(e){e.Free="free",e.Vertical="vertical",e.Horizontal="horizontal"})(oa||(oa={}));var na;(function(e){e.Partial="partial",e.Full="full"})(na||(na={}));var ra;(function(e){e.Bezier="default",e.Straight="straight",e.Step="step",e.SmoothStep="smoothstep",e.SimpleBezier="simplebezier"})(ra||(ra={}));var ia;(function(e){e.Arrow="arrow",e.ArrowClosed="arrowclosed"})(ia||(ia={}));var se;(function(e){e.Left="left",e.Top="top",e.Right="right",e.Bottom="bottom"})(se||(se={}));var jT={[se.Left]:se.Right,[se.Right]:se.Left,[se.Top]:se.Bottom,[se.Bottom]:se.Top};var Op=e=>"id"in e&&"internals"in e&&!("source"in e)&&!("target"in e);var Hp=(e,t=[0,0])=>{var a;let{width:o,height:n}=Gp(e),r=(a=e.origin)!=null?a:t,i=o*r[0],s=n*r[1];return{x:e.position.x-i,y:e.position.y-s}};var de=(e,t=[0,0])=>{var r,i,s,a,l,c,d,p;let{x:o,y:n}=Op(e)?e.internals.positionAbsolute:Hp(e,t);return{x:o,y:n,x2:o+((a=(s=(i=(r=e.measured)==null?void 0:r.width)!=null?i:e.width)!=null?s:e.initialWidth)!=null?a:0),y2:n+((p=(d=(c=(l=e.measured)==null?void 0:l.height)!=null?c:e.height)!=null?d:e.initialHeight)!=null?p:0)}};function Gp(e){var t,o,n,r,i,s,a,l;return{width:(r=(n=(o=(t=e.measured)==null?void 0:t.width)!=null?o:e.width)!=null?n:e.initialWidth)!=null?r:0,height:(l=(a=(s=(i=e.measured)==null?void 0:i.height)!=null?s:e.height)!=null?a:e.initialHeight)!=null?l:0}}var eN={[se.Left]:{x:-1,y:0},[se.Right]:{x:1,y:0},[se.Top]:{x:0,y:-1},[se.Bottom]:{x:0,y:1}};var Bp={nodeOrigin:[0,0],nodeExtent:Vp,elevateNodesOnSelect:!0,defaults:{}},tN=v(b({},Bp),{checkEquality:!0});var sa;(function(e){e.Line="line",e.Handle="handle"})(sa||(sa={}));var zp={width:0,height:0,x:0,y:0},oN=v(b({},zp),{pointerX:0,pointerY:0,aspectRatio:1});import{useCallback as oo,useEffect as Kp,useRef as qp,useState as da}from"react";import{shallow as Zp}from"zustand/shallow";var Fp=(e,t)=>e.x<t.x2&&e.x2>t.x&&e.y<t.y2&&e.y2>t.y;function Wp(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 Yp(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 nn=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,[s,a]=t==="horizontal"?[r.y,r.y2]:[r.x,r.x2],l=[];for(let u of i){if(u.position<s)continue;if(u.position>a)break;if(u.node.id===n.id||u.node.parentId===n.id||!Fp(u.nodeBox,r))continue;let f=Math.abs(u.position-o);if(f>rn)continue;let g=Wp(u.nodeBox,de(n))>0?0:Yp(u.nodeBox,de(n));l.push({line:u,lineDist:f,nodeDist:g})}let c=.5,d=t==="horizontal"?this.lastHorizontalLine:this.lastVerticalLine;l.sort((u,f)=>{if(d){if(u.line===d&&f.line!==d)return-1;if(f.line===d&&u.line!==d)return 1}return Math.abs(u.lineDist-f.lineDist)<=c?u.nodeDist-f.nodeDist:u.lineDist-f.lineDist});let p=l.length>0?l[0].line:void 0;return p&&(t==="horizontal"?this.lastHorizontalLine=p:this.lastVerticalLine=p),p}};function aa(e,t=Qe,o){let n=[];return e==null||e.forEach(r=>{let i=o(r.id);if(!i)throw new Error(`Node with id ${r.id} not found in internal nodes.`);let s=de(i);Object.entries(t).forEach(([a,l])=>{var c;n.push({nodeBox:s,node:r,orientation:l.orientation,position:l.resolve(r,s),color:(c=r.style)==null?void 0:c.backgroundColor,anchorName:a})})}),n}function la(e,t,o,n,r=Object.keys(Qe)){let i=[];for(let a of r){let l=Qe[a],c=l.resolve(o,n),d=e.search(l.orientation,c,o,t);d&&i.push({anchorName:a,sourcePosition:c,anchor:l,line:d})}let s={horizontal:void 0,vertical:void 0};for(let a of i){let l=s[a.anchor.orientation],c=Math.abs(a.sourcePosition-a.line.position);(!l||c<Math.abs(l.sourcePosition-l.line.position))&&(s[a.anchor.orientation]=a)}return s}function ca(e,t,o,n,r,i,s,a){var p,u,f,y,g,m,_,h;if(!(o!=null&&o.position))return{snappedX:!1,snappedY:!1};let l=!1,c=!1,d={x:o.position.x,y:o.position.y,x2:o.position.x+((u=(p=e.measured)==null?void 0:p.width)!=null?u:0),y2:o.position.y+((y=(f=e.measured)==null?void 0:f.height)!=null?y:0)};if(s){let T=s.anchor.resolve(e,d)-s.line.position;if(Math.abs(T)<=rn){if(o.position.y-=T,r!=null&&r.dimensions)if(n){let N=t.internals.positionAbsolute.y+((m=(g=e.measured)==null?void 0:g.height)!=null?m:0);r.dimensions.height=N-s.line.position}else r.dimensions.height=s.line.position-t.internals.positionAbsolute.y;c=!0}}if(a){let T=a.anchor.resolve(e,d)-a.line.position;if(Math.abs(T)<=rn){if(o.position.x-=T,r!=null&&r.dimensions)if(n){let N=t.internals.positionAbsolute.x+((h=(_=e.measured)==null?void 0:_.width)!=null?h:0);r.dimensions.width=N-a.line.position}else r.dimensions.width=a.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 rn=10,Qe={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 Qp}from"react/jsx-runtime";var Jp=new nn;function yt(){let[e,t]=da(void 0),[o,n]=da(void 0),{width:r,height:i}=Xp(m=>({width:m.width,height:m.height}),Zp),s=Up(),a=qp(Jp),{screenToFlowPosition:l,getInternalNode:c,getNodes:d}=$p(),p=oo(()=>{t(void 0),n(void 0)},[]),u=oo(m=>{let _=m!=null?m:d();p();let h=aa(_,Qe,c);a.current.initialize(h)},[c,p,d]),f=oo(()=>{setTimeout(()=>{u()},100)},[u]);Kp(()=>{s&&u(d())},[s,u,d]);let y=oo((m,_)=>{var W,B,z,X,U;if(!a.current||m.length===0||m.length>2)return m;p();let h,E,T=Object.keys(Qe);m.length===1?m[0].type==="position"?h=m[0]:m[0].type==="dimensions"&&(E=m[0],T=["right","bottom"]):m[0].type==="position"&&m[1].type==="dimensions"&&m[1].dimensions&&(h=m[0],E=m[1],T=["top","left"]);let N=_.find(K=>K.id===m[0].id);if(!N)return m;let w=c(N.id);if(!w)throw new Error(`Node with id ${N.id} not found in internal nodes`);let x=c((W=w.parentId)!=null?W:""),C=de(w);E!=null&&E.dimensions&&(C.x2=C.x+E.dimensions.width,C.y2=C.y+E.dimensions.height);let{x:k,y:D}=l({x:0,y:0}),{x:A,y:S}=l({x:r,y:i}),O={x:k,y:D,x2:A,y2:S},{horizontal:I,vertical:M}=la(a.current,O,N,C,T),P={id:N.id,type:"position",position:{x:w.internals.positionAbsolute.x,y:w.internals.positionAbsolute.y},dragging:!1};h!=null&&h.position&&P.position&&(x?(P.position.x=h.position.x+((z=(B=x==null?void 0:x.position)==null?void 0:B.x)!=null?z:0),P.position.y=h.position.y+((U=(X=x==null?void 0:x.position)==null?void 0:X.y)!=null?U:0)):(P.position.x=h.position.x,P.position.y=h.position.y));let{snappedX:V,snappedY:H}=ca(N,w,P,h,E,x,I,M);if(V||H){if((E!=null&&E.resizing||h!=null&&h.dragging)&&(V&&n(M==null?void 0:M.line),H&&t(I==null?void 0:I.line)),E&&h)return[P,E];if(h)return[P];if(E)return[E]}return m},[l,c,r,i,t,n,p]),g=oo(()=>Qp(ua,{horizontal:e,vertical:o}),[e,o]);return{rebuildIndex:u,forceRebuildIndex:f,updateHelperLines:y,helperLineHorizontal:e,helperLineVertical:o,HelperLines:g}}import{useReactFlow as Wg}from"@xyflow/react";import{useCallback as Yl}from"react";var no=e=>new Map(e.map(t=>[t.id,t])),sn=e=>e.some(t=>t.type==="START_EVENT"),pa=(e,t,o,n)=>{let r=no(o),i=r.get(e);if(!i||i.type!=="START_EVENT")return!1;let s=r.get(t);return(s==null?void 0:s.type)==="ANNOTATION"?!1:n.filter(l=>{if(l.source!==e)return!1;let c=r.get(l.target);return(c==null?void 0:c.type)!=="ANNOTATION"}).length>=1},an=(e,t,o)=>{var i;let n=t.find(s=>s.id===e);return!n||n.type!=="GATEWAY"||((i=n.data)==null?void 0:i.variant)!=="EXCLUSIVE"?!1:o.filter(s=>s.source===e).length>=2},fa=(e,t,o)=>{var s,a,l,c;let n=no(o),r=n.get(e),i=n.get(t);return(r==null?void 0:r.type)!=="GATEWAY"||(i==null?void 0:i.type)!=="GATEWAY"||((s=r==null?void 0:r.data)==null?void 0:s.variant)==="EXCLUSIVE"&&((a=i==null?void 0:i.data)==null?void 0:a.variant)==="PARALLEL"||((l=r==null?void 0:r.data)==null?void 0:l.variant)==="COMPLEX"&&((c=i==null?void 0:i.data)==null?void 0:c.variant)==="PARALLEL"},ln=(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"},cn=(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"},dn=(e,t,o)=>{let n=no(t),r=n.get(e);return!r||r.type!=="TASK"?!1:o.filter(s=>s.target===e).some(s=>{let a=n.get(s.source);return(a==null?void 0:a.type)==="START_EVENT"})},un=(e,t,o)=>{let n=no(t),r=n.get(e);return!r||r.type!=="TASK"?!1:o.filter(s=>s.source===e).some(s=>{let a=n.get(s.target);return(a==null?void 0:a.type)==="END_EVENT"})},pn=(e,t)=>t.filter(n=>n.source===e).length>0,fn=(e,t,o,n)=>{let r=no(o),i=r.get(e);if(!i||i.type!=="TASK")return!1;let s=t?r.get(t):null;return(s==null?void 0:s.type)==="ANNOTATION"?!1:n.filter(l=>{if(l.source!==e)return!1;let c=r.get(l.target);return(c==null?void 0:c.type)!=="ANNOTATION"}).length>=2};var jp=[e=>({isValid:e.sourceNodeId!==e.targetNodeId,reason:"self_connection_not_allowed"}),e=>({isValid:!pa(e.sourceNodeId,e.targetNodeId,e.nodes,e.edges),reason:"start_event_limit_reached"}),e=>({isValid:!an(e.sourceNodeId,e.nodes,e.edges),reason:"gateway_limit_reached"}),e=>({isValid:!fn(e.sourceNodeId,e.targetNodeId,e.nodes,e.edges),reason:"task_limit_reached"}),e=>({isValid:fa(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:!(ln(e.sourceNodeId,e.nodes)&&e.targetNodeType==="END_EVENT"),reason:"script_to_end_not_allowed"}),e=>({isValid:!(cn(e.sourceNodeId,e.nodes)&&e.targetNodeType==="END_EVENT"),reason:"loop_to_end_not_allowed"}),e=>({isValid:!(dn(e.sourceNodeId,e.nodes,e.edges)&&e.targetNodeType==="END_EVENT"),reason:"initial_activity_to_end_not_allowed"}),e=>({isValid:!(un(e.sourceNodeId,e.nodes,e.edges)&&e.targetNodeType!=="ANNOTATION"),reason:"final_activity_cannot_connect"}),e=>({isValid:!(pn(e.sourceNodeId,e.edges)&&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"})],ma=e=>{for(let t of jp){let o=t(e);if(!o.isValid)return o}return{isValid:!0}};var ef=[{sourceTypes:["GATEWAY"],targetTypes:["TASK","GATEWAY"],validate:e=>({shouldDisable:an(e.sourceNodeId,e.nodes,e.edges),reason:"gateway_limit_reached"})},{targetTypes:["START_EVENT"],validate:e=>({shouldDisable:sn(e.nodes),reason:"start_event_already_exists"})},{sourceTypes:["TASK"],targetTypes:["END_EVENT"],validate:e=>({shouldDisable:ln(e.sourceNodeId,e.nodes),reason:"script_to_end_not_allowed"})},{sourceTypes:["TASK"],targetTypes:["END_EVENT"],validate:e=>({shouldDisable:cn(e.sourceNodeId,e.nodes),reason:"loop_to_end_not_allowed"})},{sourceTypes:["TASK"],targetTypes:["END_EVENT"],validate:e=>({shouldDisable:dn(e.sourceNodeId,e.nodes,e.edges),reason:"initial_activity_to_end_not_allowed"})},{sourceTypes:["TASK"],validate:e=>({shouldDisable:un(e.sourceNodeId,e.nodes,e.edges)&&e.targetNodeType!=="ANNOTATION",reason:"final_activity_cannot_connect"})},{targetTypes:["END_EVENT"],validate:e=>({shouldDisable:pn(e.sourceNodeId,e.edges),reason:"activity_has_outgoing_connections"})},{sourceTypes:["TASK"],validate:e=>({shouldDisable:fn(e.sourceNodeId,null,e.nodes,e.edges)&&e.targetNodeType!=="ANNOTATION",reason:"task_limit_reached"})}],ga=e=>{let t=ef.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 If,EdgeLabelRenderer as Cf,getStraightPath as Sf,useInternalNode as xa,useViewport as Mf}from"@xyflow/react";import{Position as ro}from"@xyflow/react";function ha(e,t){var E,T,N,w;let{width:o=0,height:n=0}=e.measured||{width:0,height:0},r=e.internals.positionAbsolute,i=t.internals.positionAbsolute,s=o/2,a=n/2,l=r.x+s,c=r.y+a,d=i.x+((T=(E=t==null?void 0:t.measured)==null?void 0:E.width)!=null?T:0)/2,p=i.y+((w=(N=t==null?void 0:t.measured)==null?void 0:N.height)!=null?w:0)/2,u=(d-l)/(2*s)-(p-c)/(2*a),f=(d-l)/(2*s)+(p-c)/(2*a),y=1/(Math.abs(u)+Math.abs(f)||1),g=y*u,m=y*f,_=s*(g+m)+l,h=a*(-g+m)+c;return{x:_,y:h}}function ya(e,t){var c,d,p,u;let{positionAbsolute:o}=e.internals,n=(d=(c=e.measured)==null?void 0:c.width)!=null?d:0,r=(u=(p=e.measured)==null?void 0:p.height)!=null?u:0,i=Math.round(o.x),s=Math.round(o.y),a=Math.round(t.x),l=Math.round(t.y);return a<=i+1?ro.Left:a>=i+n-1?ro.Right:l<=s+1?ro.Top:l>=s+r-1?ro.Bottom:ro.Top}function Le(e,t){let o=ha(e,t),n=ha(t,e),r=ya(e,o),i=ya(t,n);return{sx:o.x,sy:o.y,tx:n.x,ty:n.y,sourcePos:r,targetPos:i}}import{Button as nf,Tooltip as rf,TooltipContent as sf,TooltipTrigger as af,useTranslation as lf}from"lecom-ui";import{Settings as cf}from"lucide-react";import{getIncomers as mn,getOutgoers as gn,useReactFlow as of}from"@xyflow/react";import{useReactFlow as tf}from"@xyflow/react";var Fe=()=>{let{getNodes:e,setNodes:t,getEdges:o,setEdges:n}=tf();return{selectElements:s=>{let a=e().map(c=>v(b({},c),{selected:s.includes(c.id)})),l=o().map(c=>v(b({},c),{selected:s.includes(c.id)}));return t(a),n(l),!0},clearSelection:async()=>{let s=e().map(l=>v(b({},l),{selected:!1})),a=o().map(l=>v(b({},l),{selected:!1}));return t(s),n(a),await No(),!0}}};var hn=()=>{let{getNode:e,getEdge:t,getNodes:o,getEdges:n}=of(),{selectElements:r}=Fe(),i=m=>{let _=o(),h=n(),E=mn(m,_,h),T=gn(m,_,h),N=E.some(x=>x.type==="START_EVENT"),w=T.some(x=>x.type==="END_EVENT");return N?"start":w?"end":"between"},s=(m,_,h)=>{var N,w,x,C;if(!m)return;let E={type:m.type,variant:(N=m.data)==null?void 0:N.variant,attribute:(w=m.data)==null?void 0:w.attribute},T={id:m.id,position:i(m),label:(x=m.data)==null?void 0:x.label,node:E};return m.type==="TASK"&&((C=m.data)==null?void 0:C.variant)==="SUBPROCESS"?v(b({},T),{type:"sub_process"}):m.type==="GATEWAY"?v(b({},T),{type:"gateway",variant:a(m,_,h)}):v(b({},T),{type:"activity"})},a=(m,_,h)=>{if(m.type!=="GATEWAY")return;let E=mn(m,_,h),T=!1,N=!1;if(E.forEach(w=>{var x,C;w.type==="TASK"&&(((x=w.data)==null?void 0:x.variant)==="SCRIPT"&&(T=!0),((C=w.data)==null?void 0:C.attribute)==="LOOP"&&(N=!0))}),T&&N)return"script_loop";if(T)return"script";if(N)return"loop"},l=(m,_,h)=>{var x,C,k,D;let E=e(m.source),T=e(m.target);if(!E||!T)return"simple";if(gn(E,_,h).some(A=>A.type==="END_EVENT"))return"final";if(E.type==="GATEWAY")switch((x=E.data)==null?void 0:x.variant){case"PARALLEL":return"parallel";case"EXCLUSIVE":return"exclusive";case"COMPLEX":return"complex";default:return"simple"}if(E.type==="TASK"){let A=(C=E.data)==null?void 0:C.variant,S=(k=E.data)==null?void 0:k.attribute;if(T.type==="TASK"&&((D=T.data)==null?void 0:D.variant)==="SUBPROCESS")return"to_sub_process";let O=A==="SCRIPT",I=S==="LOOP";return O&&I?"script_loop":O?"script":I?"loop":"simple"}return"simple"},c=(m,_,h)=>{let E=[];function T(w,x,C=0){let k=s(w,_,h);if(k.depth=C,x.push(k),w.type==="TASK"){E.push([...x]),x.pop();return}let D=mn(w,_,h);if(D.length)for(let A of D)T(A,x,C+1);x.pop()}let N=mn(m,_,h);for(let w of N)T(w,[]);return E},d=(m,_,h)=>{let E=[];function T(w,x,C=0){let k=s(w,_,h);if(k.depth=C,x.push(k),w.type==="TASK"){E.push([...x]),x.pop();return}let D=gn(w,_,h);if(D.length)for(let A of D)T(A,x,C+1);x.pop()}let N=gn(m,_,h);for(let w of N)T(w,[]);return E},p=(m,_,h)=>{h=h.filter(T=>T.source===m.id);let E=h.map(T=>{var x;let N=e(T.target),w;return N&&(w=s(N,_,h)),{id:T.id,type:"routing",variant:l(T,_,h),label:(x=T.data)==null?void 0:x.label,target:w}});return console.log(E),E},u=m=>{let _=e(m);if(!_)return;let h=o(),E=n(),T=s(_,h,E);return T.sources=c(_,h,E),T.targets=d(_,h,E),T.edgeTargets=p(_,h,E),_.type==="GATEWAY"&&(T.variant=a(_,h,E)),T},f=m=>{let _=t(m);if(!_)return;let h=o(),E=n(),T=l(_,h,E),w={id:_.id,type:"routing",variant:T,gatewayVariant:void 0},x=e(_.source);if(x){let k=s(x,h,E),D=c(x,h,E),A=a(x,h,E);w.source=k,w.sources=D.length?D:[[k]],w.gatewayVariant=A}let C=e(_.target);if(C){let k=s(C,h,E),D=d(C,h,E);w.target=k,w.targets=D.length?D:[[k]]}return w},y=m=>{let _=e(m);if(_)return u(_.id);let h=t(m);if(h)return f(h.id)};return{configureElement:m=>{let _=y(m);if(_)return r([m]),_},getConfigureElement:y,getNodeConfigure:u,getEdgeConfigure:f}};import{jsx as yn,jsxs as df}from"react/jsx-runtime";var We=({elementId:e,elementType:t="node"})=>{let{t:o}=lf(),{onConfigureElement:n}=R(),{getConfigureElement:r}=hn();return df(rf,{children:[yn(af,{asChild:!0,children:yn(nf,{variant:"ghost",color:"grey",size:"small",iconButton:!0,onClick:()=>{let s=r(e);s&&(n==null||n(s))},children:yn(cf,{size:16})})}),yn(sf,{color:"black",children:o(t==="node"?"editor.toolbar.configure_node":"editor.toolbar.configure_edge")})]})};import{useReactFlow as uf}from"@xyflow/react";import{Button as pf,Tooltip as ff,TooltipContent as mf,TooltipTrigger as gf,useTranslation as hf}from"lecom-ui";import{TrashIcon as yf}from"lucide-react";import{jsx as xn,jsxs as xf}from"react/jsx-runtime";var En=({elementId:e,elementType:t="node"})=>{let{t:o}=hf(),{deleteElements:n}=uf();return xf(ff,{children:[xn(gf,{asChild:!0,children:xn(pf,{variant:"ghost",color:"destructive",size:"small",iconButton:!0,onClick:()=>{n(t==="node"?{nodes:[{id:e}]}:{edges:[{id:e}]})},children:xn(yf,{size:16})})}),xn(mf,{color:"black",children:o("editor.toolbar.delete")})]})};import{Button as Ef,Tooltip as bf,TooltipContent as _f,TooltipTrigger as Tf,useTranslation as Nf}from"lecom-ui";import{MoveUpRightIcon as vf}from"lucide-react";import{useCallback as wf}from"react";import{jsx as bn,jsxs as Af}from"react/jsx-runtime";var io=({nodeId:e})=>{let{t}=Nf(),o=wf(n=>{n.stopPropagation();let r=document.querySelector(`[data-id="${e}"]`);if(!r)return;let i=r.querySelector(".react-flow__handle.source");if(!i)return;let s=i.getBoundingClientRect(),a=s.left+s.width/2,l=s.top+s.height/2,c=new MouseEvent("mousedown",{clientX:a,clientY:l,bubbles:!0,cancelable:!0});i.dispatchEvent(c)},[e]);return Af(bf,{children:[bn(Tf,{asChild:!0,children:bn(Ef,{variant:"ghost",color:"grey",size:"small",iconButton:!0,onMouseDown:o,children:bn(vf,{size:16})})}),bn(_f,{color:"black",children:t("editor.toolbar.connect_node")})]})};import{jsx as so}from"react/jsx-runtime";var xt=i=>{var s=i,{edgeId:e,edgeType:t,sourceNode:o,targetNode:n}=s,r=we(s,["edgeId","edgeType","sourceNode","targetNode"]);let{mode:a}=R(),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",p=(o==null?void 0:o.type)==="TASK"&&(n==null?void 0:n.type)==="GATEWAY",u=!l&&!c&&!d&&!p,f=[{component:so(En,{elementId:e,elementType:"edge"})}],y=()=>a==="view"?u?[{component:so(We,{elementId:e,elementType:"edge"})}]:[]:u?[{component:so(We,{elementId:e,elementType:"edge"})},...f]:f,m=(_=>{switch(_){case"SEQUENCE_EDGE":return y();case"MESSAGE_EDGE":return a==="view"?[]:[...f];case"ANNOTATION_EDGE":return a==="view"?[]:[...f];default:return[]}})(t);if(!(m.length===0||a==="view"))return so("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)=>so("div",{children:_.component},h))}))};import{jsx as _n,jsxs as Pf}from"react/jsx-runtime";var Et={type:"ANNOTATION_EDGE",reconnectable:!0},Ea=({id:e,source:t,target:o,selected:n,data:r})=>{let{zoom:i}=Mf(),{isMultipleSelection:s}=R(),a=xa(t),l=xa(o);if(!a||!l)return null;let{sx:c,sy:d,tx:p,ty:u}=Le(a,l),[f,y,g]=Sf({sourceX:c,sourceY:d,targetX:p,targetY:u}),m=n||(a==null?void 0:a.selected)||(l==null?void 0:l.selected),_=1/i;return Pf("g",{className:L("text-grey-400 hover:text-grey-500",{"text-blue-500 hover:text-blue-600":m}),children:[_n(If,{id:e,path:f,strokeDasharray:4,className:L("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)})}),_n(Cf,{children:_n("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&&!s&&_n(xt,{edgeId:e,edgeType:"ANNOTATION_EDGE",style:{transform:`scale(${_})`}})})})]})};import{useState as Na,useCallback as Rf,useMemo as _r,useEffect as Vf,useRef as va}from"react";import{BaseEdge as Of,EdgeLabelRenderer as Hf,MarkerType as wa,useInternalNode as Aa,useReactFlow as Gf,useViewport as Bf,Position as Ia}from"@xyflow/react";import{useEffect as ba,useRef as Lf,useState as Df}from"react";import{jsx as _a}from"react/jsx-runtime";var te=({value:e,maxLength:t,style:o,className:n,contentClassName:r,isEditing:i,onChange:s,onBlur:a})=>{let l=Lf(null),[c,d]=Df(!1);ba(()=>{d(i!=null?i:!1)},[i]),ba(()=>{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 p=g=>{g.stopPropagation(),c||d(!0)},u=g=>{let m=g.currentTarget.innerText.trim(),_=t&&m.length>=t,h=["Backspace","Delete","ArrowLeft","ArrowRight","ArrowUp","ArrowDown","Home","End","Tab","Enter","Escape","Shift"],E=g.ctrlKey||g.metaKey,T=E&&g.key==="a",N=E&&g.key==="c",w=E&&g.key==="x",x=E&&g.key==="v";function C(D){return/\w/.test(D)}if(m.length===0&&!C(g.key)&&!h.includes(g.key)&&!E){g.preventDefault();return}_&&(h.includes(g.key)||T||N||w||x||g.preventDefault())},f=g=>{if(!t)return;g.preventDefault();let m=g.clipboardData.getData("text/plain"),_=g.currentTarget.innerText,h=window.getSelection();if(!h||h.rangeCount===0)return;let E=h.getRangeAt(0);if((_.substring(0,E.startOffset)+m+_.substring(E.endOffset)).length>t){let N=t-(_.length-(E.endOffset-E.startOffset)),w=m.substring(0,Math.max(0,N));w&&(E.deleteContents(),E.insertNode(document.createTextNode(w)),E.setStartAfter(E.endContainer),E.collapse(!0),h.removeAllRanges(),h.addRange(E))}else E.deleteContents(),E.insertNode(document.createTextNode(m)),E.setStartAfter(E.endContainer),E.collapse(!0),h.removeAllRanges(),h.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,a==null||a(),m!==e&&(s==null||s(m))};return _a("div",{className:L("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:p,children:_a("div",{ref:l,className:L("outline-none whitespace-pre-wrap overflow-hidden",r,{"nodrag nopan cursor-text":c}),contentEditable:!0,suppressContentEditableWarning:!0,onKeyDown:u,onPaste:f,onBlur:y,children:e})})};import{Position as Tn}from"@xyflow/react";var Nn=e=>e===Tn.Left||e===Tn.Right,xr=(e,t=30)=>e===Tn.Right||e===Tn.Bottom?t:-t,Er=(e,t,o,n=1)=>Math.abs(e[o]-t[o])<n,vn=(e,t)=>Math.sqrt((t.x-e.x)**2+(t.y-e.y)**2),wn=(e,t)=>({x:(e.x+t.x)/2,y:(e.y+t.y)/2});var je={OFFSET:30,TOLERANCE:1,MOVE_THRESHOLD:5,MIN_SEGMENT_LENGTH:15};function kf(e,t,o,n,r,i){let s=xr(r,je.OFFSET),a=xr(i,je.OFFSET),l=Nn(r),c=Nn(i),d={x:e,y:t},p={x:o,y:n};if(l&&c){let u=(t+n)/2;return[d,{x:e+s,y:t},{x:e+s,y:u},{x:o+a,y:u},{x:o+a,y:n},p]}if(!l&&!c){let u=(e+o)/2;return[d,{x:e,y:t+s},{x:u,y:t+s},{x:u,y:n+a},{x:o,y:n+a},p]}return l?[d,{x:e+s,y:t},{x:e+s,y:n+a},{x:o,y:n+a},p]:[d,{x:e,y:t+s},{x:o+a,y:t+s},{x:o+a,y:n},p]}function br(e,t,o,n,r,i,s){let a=kf(e,t,o,n,r,i);if(!(s!=null&&s.length)||s.length!==a.length-2)return a;let l=[{x:e,y:t},...s,{x:o,y:n}],c=Nn(r);for(let d=0;d<l.length-1;d++){let p=l[d],u=l[d+1];if(Math.abs(u.x-p.x)>je.TOLERANCE&&Math.abs(u.y-p.y)>je.TOLERANCE){let y=d%2===0===c;l[d+1]=y?{x:u.x,y:p.y}:{x:p.x,y:u.y}}}return l}var Ta=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{jsx as Ye,jsxs as Tr}from"react/jsx-runtime";var Te={type:"SEQUENCE_EDGE",reconnectable:!0,markerStart:{type:wa.ArrowClosed},markerEnd:{type:wa.Arrow},data:{label:""}},{TOLERANCE:Ca,MOVE_THRESHOLD:An,MIN_SEGMENT_LENGTH:zf}=je,Sa=({id:e,source:t,target:o,data:n,selected:r})=>{let{zoom:i}=Bf(),{updateEdgeData:s}=Gf(),{isMultipleSelection:a,mode:l}=R(),[c,d]=Na(!1),[p,u]=Na(null),f=va(null),y=va(null),g=Aa(t),m=Aa(o),{sx:_,sy:h,tx:E,ty:T,sourcePos:N,targetPos:w}=_r(()=>g&&m?Le(g,m):{sx:0,sy:0,tx:0,ty:0,sourcePos:Ia.Right,targetPos:Ia.Left},[g,m]);Vf(()=>{var P;if(!y.current){y.current={sx:_,sy:h,tx:E,ty:T,sourcePos:N,targetPos:w};return}let I=y.current;(Math.abs(_-I.sx)>An||Math.abs(h-I.sy)>An||Math.abs(E-I.tx)>An||Math.abs(T-I.ty)>An||I.sourcePos!==N||I.targetPos!==w)&&((P=n==null?void 0:n.points)!=null&&P.length)&&s(e,v(b({},n),{points:void 0})),y.current={sx:_,sy:h,tx:E,ty:T,sourcePos:N,targetPos:w}},[_,h,E,T,N,w,n,e,s]);let x=_r(()=>{var I;if((I=n==null?void 0:n.points)!=null&&I.length&&m){let P={internals:{positionAbsolute:n.points[n.points.length-1]},measured:{width:1,height:1}},V=Le(P,m);return br(_,h,V.tx,V.ty,N,V.targetPos,n.points)}return br(_,h,E,T,N,w,n==null?void 0:n.points)},[_,h,E,T,N,w,n==null?void 0:n.points,m]),C=_r(()=>{if(x.length<2)return wn({x:_,y:h},{x:E,y:T});let I=0;for(let V=0;V<x.length-1;V++)I+=vn(x[V],x[V+1]);let M=I/2,P=0;for(let V=0;V<x.length-1;V++){let H=vn(x[V],x[V+1]);if(P+H>=M){let W=(M-P)/H,B=x[V],z=x[V+1];return{x:B.x+(z.x-B.x)*W,y:B.y+(z.y-B.y)*W}}P+=H}return wn({x:_,y:h},{x:E,y:T})},[x,_,h,E,T]),k=Rf((I,M)=>{if(l!=="edit"||M.button!==0)return;M.stopPropagation(),M.preventDefault();let P=x[I],V=x[I+1],H=Er(P,V,"y"),W=H?P.y:P.x;u(I);let B=X=>{let U=W+(H?X.clientY-M.clientY:X.clientX-M.clientX)/i;f.current=H?{x:(P.x+V.x)/2,y:U}:{x:U,y:(P.y+V.y)/2};let K=x.map((pe,ye)=>ye===0||ye===x.length-1?pe:(H?Math.abs(pe.y-W)<Ca:Math.abs(pe.x-W)<Ca)?H?v(b({},pe),{y:U}):v(b({},pe),{x:U}):pe);s(e,v(b({},n),{points:K.slice(1,-1)}))},z=()=>{u(null),f.current=null,document.removeEventListener("mousemove",B),document.removeEventListener("mouseup",z)};document.addEventListener("mousemove",B),document.addEventListener("mouseup",z)},[l,x,i,n,e,s]),D=I=>{s(e,{label:I.trim()})};if(!g||!m)return null;let A=Ta(x),S=r||g.selected||m.selected,O=c||(n==null?void 0:n.label.trim().length)>0;return Tr("g",{className:L("text-grey-400 hover:text-grey-500 nopan",{"text-blue-500 hover:text-blue-600":S}),onBlur:()=>d(!1),onDoubleClick:()=>d(!0),children:[Ye(Of,{id:e,path:A,markerEnd:`url(#${S?"sequence-edge-marker-highlighted":"sequence-edge-marker"})`,className:L("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)]":S&&!(n!=null&&n.hasError)})}),r&&!a&&l==="edit"&&Ye("g",{children:x.slice(0,-1).map((I,M)=>{let P=x[M+1];if(M===0||M===x.length-2||vn(I,P)<zf)return null;let V=Er(I,P,"y"),H=p===M,W=H&&f.current?f.current:wn(I,P);return Tr("g",{children:[Ye("line",{x1:I.x,y1:I.y,x2:P.x,y2:P.y,stroke:"transparent",strokeWidth:20/i,className:L("cursor-pointer",{"cursor-ns-resize":V,"cursor-ew-resize":!V}),onMouseDown:B=>k(M,B)}),Ye("circle",{cx:W.x,cy:W.y,r:4/i,fill:H?"#3b82f6":"#fff",stroke:"#3b82f6",strokeWidth:2/i,className:"pointer-events-none"}),Ye("circle",{cx:W.x,cy:W.y,r:6/i,fill:"none",stroke:"#3b82f6",strokeWidth:1/i,opacity:H?.6:.3,className:"pointer-events-none"})]},M)})}),Ye(Hf,{children:Tr("div",{className:"absolute z-[3000] pointer-events-auto flex flex-col items-center gap-1",style:{transform:`translate(-50%, -50%) translate(${C.x}px, ${C.y}px)`},children:[r&&!a&&Ye(xt,{edgeId:e,edgeType:"SEQUENCE_EDGE",sourceNode:g,targetNode:m,style:{transform:`scale(${1/i})`}}),O&&Ye(te,{value:n==null?void 0:n.label,className:"min-w-8 max-w-56 bg-white rounded-md px-2 py-1 text-xs",isEditing:c,onChange:D})]})})]})};import{useDebouncedCallback as zg}from"use-debounce";import{useReactFlow as Bg}from"@xyflow/react";import{useCallback as Fl}from"react";var lo=(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))(lo||{});import{xml2json as Ff,json2xml as Wf}from"xml-js";var Ma={compact:!0,spaces:4},Yf=e=>e.replaceAll(`
2
+ `,"&#xA;");function In(e,t=Ma){if(e)return JSON.parse(Ff(e,v(b({},t),{attributeValueFn:Yf})))}function Pa(e,t=Ma){return e?Wf(e,t):""}import{v7 as Zf}from"uuid";var Uf={MIN_WIDTH:36,MIN_HEIGHT:36},$f={MIN_WIDTH:36,MIN_HEIGHT:36},Xf={MIN_WIDTH:56,MIN_HEIGHT:56},Cn={MIN_WIDTH:176,MIN_HEIGHT:96},Sn={HEADER_WIDTH:40,MIN_WIDTH:840,MIN_HEIGHT:256},$={HEADER_WIDTH:40,MIN_WIDTH:800,MIN_HEIGHT:256},Mn={MIN_WIDTH:176,MIN_HEIGHT:64},Kf={MIN_WIDTH:128,MIN_HEIGHT:64},F={START_EVENT:Uf,END_EVENT:$f,GATEWAY:Xf,TASK:Cn,LANE:$,ANNOTATION:Mn,UNSUPPORTED:Kf};var La={"attribute-loop":"LOOP"},Da={"task-script":"SCRIPT","subprocess-collapsed":"SUBPROCESS"},ka={"gateway-exclusive":"EXCLUSIVE","gateway-parallel":"PARALLEL","gateway-complex":"COMPLEX"},Ra={SCRIPT:"task-script",SUBPROCESS:"subprocess-collapsed"},Va={EXCLUSIVE:"gateway-exclusive",PARALLEL:"gateway-parallel",COMPLEX:"gateway-complex"};var bt=(e,t,o)=>{let n=e._attributes.width||0,r=e._attributes.height||0,i=Ve(Number(n),t),s=Ve(Number(r),o);return{width:i,height:s,measured:{width:i,height:s}}},_t=e=>{let{_attributes:t,mxGeometry:o}=e,{id:n,parent:r,value:i}=t,s={x:Number(o._attributes.x||0),y:Number(o._attributes.y||0)},a={id:n,position:s,data:{label:i||""}},l=r==="1"?void 0:r;return l&&(a.parentId=l),a},Jf=e=>{let{mxGeometry:t}=e,o=_t(e),n=bt(t,F.START_EVENT.MIN_WIDTH,F.START_EVENT.MIN_HEIGHT);return v(b(b({},o),n),{type:"START_EVENT"})},Qf=e=>{let{mxGeometry:t}=e,o=_t(e),n=bt(t,F.END_EVENT.MIN_WIDTH,F.END_EVENT.MIN_HEIGHT);return v(b(b({},o),n),{type:"END_EVENT"})},Nr=(e,t)=>{let{_attributes:o,mxGeometry:n}=e,r=_t(e),i=bt(n,F.TASK.MIN_WIDTH,F.TASK.MIN_HEIGHT),s=t==null?void 0:t.find(l=>{let{parent:c}=l._attributes;return c===e._attributes.id});if(s){let{style:l}=s._attributes,c=La[l];c&&(r.data.attribute=c)}let a=Da[o.style];return a&&(r.data.variant=a),v(b(b({},r),i),{type:"TASK"})},vr=e=>{let{_attributes:t,mxGeometry:o}=e,{style:n}=t,r=_t(e),i=bt(o,F.GATEWAY.MIN_WIDTH,F.GATEWAY.MIN_HEIGHT);return r.data.variant=ka[n],v(b(b({},r),i),{type:"GATEWAY"})},jf=e=>{let{mxGeometry:t}=e,o=_t(e),n=bt(t,F.ANNOTATION.MIN_WIDTH,F.ANNOTATION.MIN_HEIGHT);return v(b(b({},o),n),{type:"ANNOTATION"})},em=e=>{let{mxGeometry:t}=e,o=_t(e),n=bt(t,F.LANE.MIN_WIDTH,F.LANE.MIN_HEIGHT);return v(b(b({},o),n),{type:"LANE"})},Oa={task:Nr,"task-script":Nr,"subprocess-collapsed":Nr,"start-event":Jf,"end-event-terminate":Qf,"gateway-parallel":vr,"gateway-exclusive":vr,"gateway-complex":vr,annotation:jf,lane:em},Ha=e=>{var d;let{_attributes:t,mxGeometry:o}=e,{id:n,source:r,target:i,value:s,style:a}=t,l=(d=o==null?void 0:o.Array)==null?void 0:d.map(p=>({x:Number(p._attributes.x),y:Number(p._attributes.y)})),c={id:n,source:r,target:i,data:b({label:s||""},l&&l.length>0?{points:l}:{})};return a.includes("association")&&a.includes('endArrow=""')?b(b({},Et),c):b(b({},Te),c)},Ga=(e,t)=>{let{id:o,type:n,source:r,target:i,data:s}=e,a=t==null?void 0:t.find(p=>p.id===r),l="";n==="ANNOTATION_EDGE"&&(l='association;endArrow=""');let c={_attributes:{as:"geometry",relative:"1"}};return s!=null&&s.points&&Array.isArray(s.points)&&s.points.length>0&&(c.Array=s.points.map(p=>({_attributes:{as:"mxPoint",x:p.x,y:p.y}}))),{_attributes:{id:o,parent:(a==null?void 0:a.parentId)||"1",edge:"1",style:l,source:r,target:i,value:(s==null?void 0:s.label)||""},mxGeometry:c}},Tt=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}}}},tm=e=>{let{variant:t}=e.data,o=Tt(e);return v(b({},o),{_attributes:v(b({},o._attributes),{style:Ra[t]||"task"})})},om=e=>{let t=Tt(e);return v(b({},t),{_attributes:v(b({},t._attributes),{style:"start-event"})})},nm=e=>{let t=Tt(e);return v(b({},t),{_attributes:v(b({},t._attributes),{style:"end-event-terminate"})})},rm=e=>{let{variant:t}=e.data,o=Tt(e);return v(b({},o),{_attributes:v(b({},o._attributes),{style:Va[t]})})},im=e=>{let t=Tt(e);return v(b({},t),{_attributes:v(b({},t._attributes),{style:"lane"})})},sm=e=>{let t=Tt(e);return v(b({},t),{_attributes:v(b({},t._attributes),{style:"annotation"})})},Ba={TASK:tm,START_EVENT:om,END_EVENT:nm,GATEWAY:rm,ANNOTATION:sm,LANE:im},za=e=>{var i,s;let n=((i=e.measured)==null?void 0:i.width)||0,r=((s=e.measured)==null?void 0:s.height)||0;return{_attributes:{id:Zf(),parent:e.id,style:"attribute-loop",connectable:"0"},mxGeometry:{_attributes:{as:"geometry",x:n/2-22/2,y:r-22,width:22,height:22}}}};import Ya from"@dagrejs/dagre";import{getNodesBounds as dm}from"@xyflow/react";import{orderBy as um}from"lodash";import{orderBy as am}from"lodash";var De=e=>{var t,o,n,r,i,s,a,l;return{x:(o=(t=e.internals)==null?void 0:t.positionAbsolute.x)!=null?o:0,y:(r=(n=e.internals)==null?void 0:n.positionAbsolute.y)!=null?r:0,w:(s=(i=e.measured)==null?void 0:i.width)!=null?s:0,h:(l=(a=e.measured)==null?void 0:a.height)!=null?l:0}},ke=e=>am(e,[o=>{let n=o.type==="LANE";return n&&!o.parentId?0:n?1:2}],["asc"]),Fa=(e,t)=>{let{x:o,y:n}=De(e),{x:r,y:i}=De(t);return{x:o-r,y:n-i}};var Nt=({parentId:e,nodes:t,includeTypes:o=[...Object.values(G)],excludeTypes:n=[]})=>t.some(r=>r.parentId===e&&(!o.length||o.includes(r.type))&&!n.includes(r.type)),lm=(e,t)=>{let{x:o,y:n}=De(e),{x:r,y:i}=De(t),s=o-r,a=n-i;return Math.sqrt(s*s+a*a)},cm=(e,t)=>{let{x:o,y:n,w:r,h:i}=De(e),{x:s,y:a,w:l,h:c}=De(t);return o<s+l&&s<o+r&&n<a+c&&a<n+i},co=(e,t)=>{let o=null,n=1/0;for(let r of t)if(r.id!==e.id&&cm(e,r)){let i=lm(e,r);i<n&&(n=i,o=r)}return o},Wa=(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 Ua=(e=[],t=[],o="LR")=>{let n=new Ya.graphlib.Graph;return n.setDefaultEdgeLabel(()=>({})),n.setGraph({rankdir:o}),e.forEach(({id:i,width:s,height:a})=>n.setNode(i,{width:s,height:a})),t.forEach(i=>n.setEdge(i.source,i.target)),Ya.layout(n),{nodes:e.map(i=>{let s=n.node(i.id);return v(b({},i),{position:{x:s.x-i.width/2,y:s.y-i.height/2}})}),edges:t}},uo=e=>{let t=e.filter(n=>n.type==="LANE"&&!n.parentId),o=[...e];return t.forEach(n=>{o=et(n.id,o)}),o},et=(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=um(r,["position.y"]),s=Math.max((y=(f=n.measured)==null?void 0:f.width)!=null?y:0,Sn.MIN_WIDTH),a=Wa(e,i)||$.MIN_WIDTH,l=Math.max(s,a),c=s-$.HEADER_WIDTH>=a,d=0,p=0;i.forEach(g=>{var m,_,h,E;o=o.map(T=>T.id===g.id?v(b({},T),{width:c?l-$.HEADER_WIDTH:l,measured:v(b({},T.measured),{width:c?l-$.HEADER_WIDTH:l}),position:{x:$.HEADER_WIDTH,y:d}}):T),d+=(_=(m=g.measured)==null?void 0:m.height)!=null?_:0,p+=(E=(h=g.measured)==null?void 0:h.height)!=null?E:0}),o=o.map(g=>g.id===e?v(b({},g),{height:p,width:c?l:l+$.HEADER_WIDTH,measured:v(b({},g.measured),{height:p,width:c?l:l+$.HEADER_WIDTH})}):g);let u=o.find(g=>g.id===e);return u!=null&&u.parentId&&(o=et(u.parentId,o)),o},$a=(e,t,o)=>{if(e.type==="LANE")return o;let n=de(t),r=de(e);return r.y<n.y&&(e.position.y=0),r.x<n.x+$.HEADER_WIDTH&&(e.position.x=$.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},Xa=()=>{let e=document.querySelector(".react-flow__viewport");return e||(console.error("Flow element (.react-flow__viewport) not found."),null)},pm=50,Ka=(e,t=pm)=>{let o=dm(e);return{x:o.x-t,y:o.y-t,width:o.width+t*2,height:o.height+t*2}};var fm=e=>{let t=Object.values(lo),o=e.filter(i=>{var a;let s=(a=i._attributes)==null?void 0:a.style;return t.includes(s)}),n=e.filter(i=>{var a;let s=(a=i._attributes)==null?void 0:a.style;return["attribute-loop"].includes(s)}),r=[];for(let i of o){let{style:s}=i._attributes,a=Oa[s],l=a==null?void 0:a(i,n);if(!l){console.warn(`Node ${s} 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=Ha(r),s=t.find(l=>l.id===i.source),a=t.find(l=>l.id===i.target);(s==null?void 0:s.type)==="LANE"||(a==null?void 0:a.type)==="LANE"||n.push(i)}return n},gm=e=>{let t=[];return e.forEach(o=>{var i,s;let n=(s=(i=Ba)[o.type])==null?void 0:s.call(i,o);if(!n){console.warn(`Node ${o.type} not supported`);return}if(t.push(n),o.type==="TASK"&&o.data.attribute==="LOOP"){let a=za(o);t.push(a)}}),t},hm=(e,t)=>{let o=[];return e.forEach(n=>{let r=Ga(n,t);o.push(r)}),o},qa=(e=[],t=[],o)=>{let n=gm(e),r=hm(t,e),i={mxGraphModel:{root:{_attributes:{version:"1.1",lastId:o},mxCell:[{_attributes:{id:"0"}},{_attributes:{id:"1",parent:"0"}},...n,...r]}}};return Pa(JSON.stringify(i),{compact:!0,spaces:0})},Za=async e=>{var s,a;let t=await In(e),o=((a=(s=t==null?void 0:t.mxGraphModel)==null?void 0:s.root)==null?void 0:a.mxCell)||[],n=fm(o),r=mm(o,n);return{nodes:ke(uo(n)),edges:r}};import{Position as qm,useConnection as Zm,useReactFlow as Jm}from"@xyflow/react";import{Handle as Ja,useReactFlow as ym}from"@xyflow/react";import{jsx as Qa}from"react/jsx-runtime";var ee=i=>{var s=i,{type:e,position:t,className:o,nodeType:n}=s,r=we(s,["type","position","className","nodeType"]);let a=n==="TASK";return Qa(Ja,b({type:e,position:t,className:L("size-2.5 border border-grey-400 bg-white relative",{"before:content-[''] before:absolute before:inset-[-16px] before:bg-transparent":a,"before:content-[''] before:absolute before:inset-[-4px] before:bg-transparent":!a},o)},r))},Pn=a=>{var l=a,{nodeId:e,nodeType:t,gatewayVariant:o,type:n,position:r,className:i}=l,s=we(l,["nodeId","nodeType","gatewayVariant","type","position","className"]);let{getEdges:c}=ym(),p=(()=>{if(n!=="source")return!1;let u=c();return t==="TASK"?u.filter(y=>y.source===e).length>=2:t==="GATEWAY"&&o==="EXCLUSIVE"?u.filter(y=>y.source===e).length>=2:!1})();return Qa(Ja,b({type:n,position:r,className:L("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"}},s))};import{NodeResizer as xm,useReactFlow as Em}from"@xyflow/react";import{orderBy as bm}from"lodash";import{jsx as _m}from"react/jsx-runtime";var vt=n=>{var r=n,{nodeId:e,isVisible:t}=r,o=we(r,["nodeId","isVisible"]);let{getNode:i,getNodes:s,setNodes:a}=Em(),{isMultipleSelection:l}=R(),c=({width:p,height:u})=>{if(!e)return;let f=i(e);if((f==null?void 0:f.type)!=="LANE")return;let y=[...s()],g=!f.parentId,m=g?f.id:f.parentId,_=y.filter(T=>T.type==="LANE"&&T.parentId===m);if(!_.length)return;let h=bm(_,["position.y"]),E=0;h.forEach((T,N)=>{var C,k;let w=N===h.length-1,x=(k=(C=T.measured)==null?void 0:C.height)!=null?k:0;y=y.map(D=>{if(D.id===T.id){let A=g?p-$.HEADER_WIDTH:p,S=v(b({},D),{width:A,measured:v(b({},D.measured),{width:A}),position:v(b({},D.position),{y:E})});return w&&g&&(S.height=u-E),S}return D}),E+=x}),y=y.map(T=>{if(T.id===m){let N=g?p:p+$.HEADER_WIDTH;return v(b({},T),{width:N,height:g?u:E,measured:{width:N,height:g?u:E}})}return T}),a(y)};return _m(xm,b({nodeId:e,handleClassName:"size-1.5 bg-blue-400",lineClassName:"border-blue-400/90 border-dashed",isVisible:!l&&t,onResizeEnd:(p,u)=>c(u)},o))};import{NodeToolbar as Gm,useReactFlow as Bm}from"@xyflow/react";import{Button as zm,Tooltip as Fm,TooltipContent as Wm,TooltipTrigger as Ym,useTranslation as Um}from"lecom-ui";import{useCallback as $m,useRef as nl,useState as Xm}from"react";import{create as Tm}from"zustand";var wt=Tm(e=>({draggableNode:null,setDraggableNode:t=>{e({draggableNode:t})}}));import{useEffect as Nm,useState as vm}from"react";var ja=(e,t=!1)=>{let[o,n]=vm({width:0,height:0});return Nm(()=>{if(e.current&&t){let r=e.current.getBoundingClientRect();n({width:r.width,height:r.height})}},[t,e]),{dimensions:o}};import{Position as po,useReactFlow as wm}from"@xyflow/react";import{useMemo as Am}from"react";var Im=120,Cm=12,el=(e,t=!1,o)=>{let{getNode:n,getViewport:r}=wm(),{instanceId:i}=R();return Am(()=>{var f,y;if(!t)return{position:po.Right,align:"start"};let s=n(e);if(!s)return{position:po.Right,align:"start"};let a=r(),l=s.position.x*a.zoom+a.x,c=(((f=s.measured)==null?void 0:f.width)||s.width||100)*a.zoom,d=(y=document.getElementById(`modeler-${i}`))==null?void 0:y.clientWidth;if(!d)return{position:po.Right,align:"start"};let p=(o==null?void 0:o.width)||Im;return{position:l+c+p+Cm>d?po.Left:po.Right}},[i,e,t,o,n,r])};import{useNodesData as Sm,useReactFlow as Mm}from"@xyflow/react";import{Button as tl,DropdownMenu as Pm,DropdownMenuContent as Lm,DropdownMenuGroup as Dm,DropdownMenuItem as km,DropdownMenuLabel as Rm,DropdownMenuTrigger as Vm,Tooltip as wr,TooltipContent as Ar,TooltipTrigger as Ir,useTranslation as Om}from"lecom-ui";import{WrenchIcon as Hm}from"lucide-react";import{jsx as re,jsxs as tt}from"react/jsx-runtime";var ol=({nodeId:e})=>{let{t}=Om(),{updateNodeData:o,getEdges:n,getNode:r}=Mm(),i=Sm(e),a=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=p=>{o(e,{variant:(i==null?void 0:i.data.variant)===p?"":p})},d=p=>{o(e,{attribute:(i==null?void 0:i.data.attribute)===p?"":p})};return tt(Pm,{children:[tt(wr,{children:[re(Ir,{asChild:!0,children:re(Vm,{asChild:!0,children:re(tl,{variant:"ghost",color:"grey",size:"small",iconButton:!0,children:re(Hm,{})})})}),re(Ar,{color:"black",children:t("bpmn.task.menu.title")})]}),tt(Lm,{align:"start",className:"w-60 bg-white text-grey-600",children:[tt(Rm,{className:"flex items-center gap-1",children:[re("div",{className:"flex-1 text-sm font-semibold",children:t("bpmn.task.menu.title")}),re("div",{className:"flex items-center gap-1",children:Object.entries(Io).map(([p,u])=>{let f=p==="LOOP"&&(a||l),g=(()=>{if(p==="LOOP"&&a)return t("editor.task_menu.loop_not_allowed_when_connected_to_end");if(p==="LOOP"&&l)return t("editor.task_menu.loop_not_allowed_when_subprocess")})();return tt(wr,{children:[re(Ir,{asChild:!0,children:re(tl,{variant:"ghost",color:"grey",size:"small",iconButton:!0,disabled:f,className:L({"bg-grey-100 text-blue-500":(i==null?void 0:i.data.attribute)===p,"opacity-50 cursor-not-allowed":f}),onClick:f?void 0:()=>d(p),children:re(u.icon,{className:"stroke-inherit"})})}),g&&re(Ar,{color:"black",children:g})]},p)})})]}),re(Dm,{children:tt(wr,{children:[re(Ir,{asChild:!0,children:tt(km,{className:L({"bg-grey-100 text-blue-500":(i==null?void 0:i.data.variant)==="SCRIPT","opacity-50 cursor-not-allowed":a}),disabled:a,onClick:a?void 0:()=>c("SCRIPT"),children:[re(Ao.SCRIPT.icon,{className:"stroke-current"}),t(`bpmn.task.variant.${"SCRIPT".toLowerCase()}`)]})}),a&&re(Ar,{color:"black",children:t("editor.task_menu.script_not_allowed_when_connected_to_end")})]})})]})]})};import{jsx as J,jsxs as rl}from"react/jsx-runtime";var ot={START_EVENT:{type:"START_EVENT",icon:Bt,label:"bpmn.start_event.variant.default"},END_EVENT:{type:"END_EVENT",icon:ct,label:"bpmn.end_event.variant.default"},TASK:{type:"TASK",icon:Bt,label:"bpmn.task.variant.default"},ANNOTATION:{type:"ANNOTATION",icon:To,label:"bpmn.annotation.variant.default"}},Km={EXCLUSIVE:{type:"GATEWAY",variant:"EXCLUSIVE",icon:ut,label:"bpmn.gateway.variant.exclusive"},PARALLEL:{type:"GATEWAY",variant:"PARALLEL",icon:pt,label:"bpmn.gateway.variant.parallel"},COMPLEX:{type:"GATEWAY",variant:"COMPLEX",icon:dt,label:"bpmn.gateway.variant.complex"}},ae=({nodeId:e,nodeType:t,nodeVariant:o,isChild:n,isVisible:r})=>{let i=nl(null),s=nl(null),{t:a}=Um(),{setDraggableNode:l}=wt(),{getEdges:c,getNodes:d}=Bm(),{setIsDragging:p,mode:u}=R(),{dimensions:f}=ja(i,r),{position:y}=el(e,r,f),[g,m]=Xm(void 0),_=d(),h=c(),E=o==="SUBPROCESS",T=$m((M,P)=>{l({type:P.type,variant:P.variant,attribute:P.attribute,icon:P.icon}),P.icon&&m(J(P.icon,{})),M.dataTransfer.effectAllowed="move",M.dataTransfer.setData("sourceId",e),s.current&&M.dataTransfer.setDragImage(s.current,10,10),setTimeout(()=>{p(!0)},100)},[e,l,p]),N=[{component:J(En,{elementId:e})}],w=()=>u==="view"?[]:[{component:J(io,{nodeId:e})},ot.TASK,ot.ANNOTATION,...N],x=()=>u==="view"?[{component:J(We,{elementId:e})}]:[{component:J(We,{elementId:e})},...E?[]:[{component:J(ol,{nodeId:e})}],{component:J(io,{nodeId:e})},ot.TASK,...Object.values(Km),...N],C=()=>u==="view"?[{component:J(We,{elementId:e})}]:[{component:J(We,{elementId:e})},{component:J(io,{nodeId:e})},ot.TASK,ot.ANNOTATION,...N],k=()=>u==="view"?[]:[{component:J(io,{nodeId:e})},ot.ANNOTATION,...N],D=()=>u==="view"?[]:[...n?[]:[ot.ANNOTATION],...N],A=()=>u==="view"?[]:[...N],S=()=>u==="view"?[]:[...N],I=(M=>{switch(M){case"START_EVENT":return w();case"TASK":return x();case"GATEWAY":return C();case"END_EVENT":return k();case"LANE":return D();case"ANNOTATION":return A();case"UNSUPPORTED":return S();default:return[]}})(t);if(!(I.length===0||u==="readonly"))return rl(Gm,{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:I.map((M,P)=>{if(M.component)return J("div",{children:M.component},P);let V={sourceNodeType:t,targetNodeType:M.type,sourceNodeId:e,nodes:_,edges:h},H=ga(V),W={gateway_limit_reached:a("editor.toolbar.gateway_limit_reached"),start_event_already_exists:a("editor.toolbar.start_event_already_exists"),script_to_end_not_allowed:a("editor.toolbar.script_to_end_not_allowed"),loop_to_end_not_allowed:a("editor.toolbar.loop_to_end_not_allowed"),initial_activity_to_end_not_allowed:a("editor.toolbar.initial_activity_to_end_not_allowed"),final_activity_cannot_connect:a("editor.toolbar.final_activity_cannot_connect"),activity_has_outgoing_connections:a("editor.toolbar.activity_has_outgoing_connections"),task_limit_reached:a("editor.toolbar.task_limit_reached")},B=H.shouldDisable&&H.reason?W[H.reason]||a(M.label):a(M.label)||"";return rl(Fm,{children:[J(Ym,{asChild:!0,children:J(zm,{variant:"ghost",color:"grey",size:"small",iconButton:!0,draggable:!H.shouldDisable,disabled:H.shouldDisable,className:H.shouldDisable?"opacity-50 cursor-not-allowed":"",onDragStart:H.shouldDisable?void 0:z=>T(z,M),children:M.icon&&J(M.icon,{size:16})})}),J(Wm,{color:"black",children:B})]},P)})}),J("div",{ref:s,className:"absolute w-0 h-0 top-0 left-0 z-[-1] bg-transparent",children:g})]})};import{jsx as Ln,jsxs as Qm}from"react/jsx-runtime";var il=({id:e,data:t,selected:o,dragging:n})=>{let{updateNodeData:r}=Jm(),{inProgress:i,fromNode:s}=Zm(),{mode:a,isConnecting:l,isDragging:c,isMultipleSelection:d}=R(),p=i&&(s==null?void 0:s.id)!==e,u=y=>{r(e,{label:y})},f=!l&&!c&&!d;return Qm("div",{className:L("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:[Ln(te,{value:t.label,className:"m-1 text-grey-600",onChange:u}),f&&Ln(ae,{nodeId:e,nodeType:"ANNOTATION",isVisible:!n&&o}),a==="edit"&&Ln(vt,{minWidth:Mn.MIN_WIDTH,minHeight:Mn.MIN_HEIGHT,isVisible:!n&&o}),(!i||p)&&Ln(ee,{type:"target",position:qm.Left,className:L({"annotation-handle":p})})]})};import{Position as sl,useConnection as jm,useReactFlow as eg}from"@xyflow/react";import{useState as tg}from"react";import{jsx as At,jsxs as og}from"react/jsx-runtime";var al=({id:e,data:t,selected:o,dragging:n})=>{let{updateNodeData:r}=eg(),{inProgress:i,fromNode:s}=jm(),{isConnecting:a,isDragging:l,isMultipleSelection:c}=R(),[d,p]=tg(!1),u=i&&(s==null?void 0:s.id)!==e,f=_=>{r(e,{label:_})},y=()=>{p(!0)},g=()=>{p(!1)},m=!a&&!l&&!c;return og("div",{className:"relative",onBlur:g,onDoubleClick:y,children:[At(ct,{className:L("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})}),At("div",{className:"absolute top-9 left-1/2 -translate-x-1/2 max-w-80 w-max",children:At(te,{value:t.label,isEditing:d,onChange:f})}),m&&At(ae,{nodeId:e,nodeType:"END_EVENT",isVisible:!n&&o}),(!i||u)&&At(ee,{type:"target",position:sl.Left,className:L({"event-handle":u})}),!i&&At(ee,{type:"source",position:sl.Right})]})};import{Position as ll,useConnection as ng,useReactFlow as rg}from"@xyflow/react";import{useCallback as ig,useState as sg}from"react";import{jsx as It,jsxs as ag}from"react/jsx-runtime";var cl=({id:e,data:t,selected:o,dragging:n})=>{let r=tr[t.variant].icon,{updateNodeData:i}=rg(),{inProgress:s,fromNode:a}=ng(),{isConnecting:l,isDragging:c,isMultipleSelection:d}=R(),[p,u]=sg(!1),f=s&&(a==null?void 0:a.id)!==e,y=ig(h=>{i(e,{label:h})},[e,i]),g=()=>{u(!0)},m=()=>{u(!1)},_=!l&&!c&&!d;return ag("div",{className:"relative",onBlur:m,onDoubleClick:g,children:[It(r,{className:L("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})}),It("div",{className:"absolute top-14 left-1/2 -translate-x-1/2 max-w-80 w-max",children:It(te,{value:t.label,isEditing:p,onChange:y})}),_&&It(ae,{nodeId:e,nodeType:"GATEWAY",isVisible:!n&&o}),(!s||f)&&It(ee,{type:"target",position:ll.Left,className:L({"gateway-handle":f})}),!s&&It(Pn,{type:"source",position:ll.Right,nodeId:e,nodeType:"GATEWAY",gatewayVariant:t.variant})]})};import{useNodesData as KA,useReactFlow as qA}from"@xyflow/react";import{Button as JA,DropdownMenu as QA,DropdownMenuContent as jA,DropdownMenuGroup as eI,DropdownMenuItem as tI,DropdownMenuLabel as oI,DropdownMenuTrigger as nI,Tooltip as rI,TooltipContent as iI,TooltipTrigger as sI,useTranslation as aI}from"lecom-ui";import{WrenchIcon as cI}from"lucide-react";import{jsx as fI,jsxs as mI}from"react/jsx-runtime";import{Position as dl,useConnection as lg,useReactFlow as cg}from"@xyflow/react";import{useState as dg}from"react";import{jsx as Ct,jsxs as ug}from"react/jsx-runtime";var ul=({id:e,data:t,selected:o,dragging:n})=>{let{updateNodeData:r}=cg(),{inProgress:i,fromNode:s}=lg(),{isConnecting:a,isDragging:l,isMultipleSelection:c}=R(),[d,p]=dg(!1),u=i&&(s==null?void 0:s.id)!==e,f=_=>{r(e,{label:_})},y=()=>{p(!0)},g=()=>{p(!1)},m=!a&&!l&&!c;return ug("div",{className:"relative",onBlur:g,onDoubleClick:y,children:[Ct(vo,{className:L("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})}),Ct("div",{className:"absolute top-9 left-1/2 -translate-x-1/2 max-w-80 w-max",children:Ct(te,{value:t.label,isEditing:d,onChange:f})}),m&&Ct(ae,{nodeId:e,nodeType:"START_EVENT",isVisible:!n&&o}),(!i||u)&&Ct(ee,{type:"target",position:dl.Left,className:L({"event-handle":u})}),!i&&Ct(ee,{type:"source",position:dl.Right})]})};import{Position as xl,useConnection as mg,useReactFlow as gg}from"@xyflow/react";import{useTranslation as hg}from"lecom-ui";import{useCallback as yg}from"react";var Dn=(e,t)=>{let n=e.filter(i=>i.type==="TASK").map(i=>{var a;let s=(a=i.data)==null?void 0:a.label;if(s&&s.startsWith(`${t} `)){let l=s.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}`},St=(e,t)=>{let n=t.filter(a=>a.type==="TASK").map(a=>{var l;return(l=a.data)==null?void 0:l.label}).filter(Boolean);if(!n.includes(e))return e;let r=e.replace(/\s+\(\d+\)$/,""),i=n.filter(a=>a===r||a.startsWith(`${r} (`)).map(a=>{if(a===r)return 1;let l=a.match(/\s+\((\d+)\)$/);return l?parseInt(l[1],10):0}).filter(a=>a>0),s=2;for(;i.includes(s);)s++;return`${r} (${s})`};import{jsx as pl,jsxs as pg}from"react/jsx-runtime";var fl=e=>pg("svg",v(b({width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",xmlns:"http://www.w3.org/2000/svg"},e),{children:[pl("circle",{cx:"12",cy:"12",r:"10",fill:"#10B981"}),pl("path",{d:"M7 12L10 15L17 8",stroke:"white",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"})]}));import{jsx as ml}from"react/jsx-runtime";var gl=e=>ml("svg",v(b({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 hl,jsxs as fg}from"react/jsx-runtime";var yl=e=>fg("svg",v(b({width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",xmlns:"http://www.w3.org/2000/svg"},e),{children:[hl("circle",{cx:"12",cy:"12",r:"10",fill:"#EF4444"}),hl("path",{d:"M8 8L16 16M8 16L16 8",stroke:"white",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"})]}));import{jsx as ge,jsxs as Eg}from"react/jsx-runtime";var xg={APROVADO:fl,EM_ANDAMENTO:gl,REJEITADO:yl},Cr={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)]"},El=({id:e,data:t,selected:o,dragging:n})=>{let{t:r}=hg(),{updateNodeData:i,getNodes:s}=gg(),{inProgress:a,fromNode:l}=mg(),{mode:c,isConnecting:d,isDragging:p,isMultipleSelection:u,onSubprocessValidationClick:f}=R(),{getTaskStatus:y}=Xe(),g=a&&(l==null?void 0:l.id)!==e,m=yg(A=>{let S=A.trim(),O=t.label||"";if(S===O)return;let I=s(),M=S;S||(M=Dn(I,r("bpmn.task.label.prefix")));let P=St(M,I);P!==O&&i(e,{label:P})},[t.label,s,e,r,i]),_=y(e),h=_?xg[_]:null,E=t.variant?Ao[t.variant].icon:null,T=t.attribute?Io[t.attribute].icon:null,N=t.variant==="SUBPROCESS",w=E&&!N,x=T||N,C=()=>t.hasError?Cr.error:_?Cr[_]:Cr.default,k=()=>{f==null||f({id:e,type:"sub_process",label:t.label})},D=!d&&!p&&!u;return Eg("div",{className:L("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",C(),{"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:[ge(te,{value:t.label,maxLength:60,className:L("m-1",{"py-6":w||x}),onChange:m}),E&&ge("div",{className:L("absolute flex items-center p-1",N?"bottom-0":"top-0 left-0"),children:ge(E,{size:16,className:L(t.hasError?"text-red-500":"text-grey-500",N&&"cursor-pointer"),onClick:N?k:void 0})}),T&&ge("div",{className:"absolute bottom-0 left-0 w-full flex items-center justify-center",children:ge("div",{className:L("flex items-center w-16 p-1",N?"justify-between":"justify-center"),children:ge(T,{size:16,className:L(t.hasError?"text-red-500":"text-grey-500")})})}),h&&ge("div",{className:"absolute top-0 right-0 flex items-center p-1",children:ge(h,{})}),D&&ge(ae,{nodeId:e,nodeType:"TASK",nodeVariant:t.variant,isVisible:!n&&o}),c==="edit"&&ge(vt,{minWidth:Cn.MIN_WIDTH,minHeight:Cn.MIN_HEIGHT,isVisible:!n&&o}),(!a||g)&&ge(ee,{type:"target",position:xl.Left,className:L({"task-handle":g})}),!a&&ge(Pn,{type:"source",position:xl.Right,nodeId:e,nodeType:"TASK"})]})};import{Position as bl}from"@xyflow/react";import{Fragment as bg,jsx as kn,jsxs as _g}from"react/jsx-runtime";var _l=({id:e,data:t,selected:o,dragging:n})=>{let{isConnecting:r,isDragging:i,isMultipleSelection:s}=R(),a=!r&&!i&&!s;return _g(bg,{children:[kn("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}),a&&kn(ae,{nodeId:e,nodeType:"UNSUPPORTED",isVisible:!n&&o}),kn(ee,{type:"source",position:bl.Right}),kn(ee,{type:"target",position:bl.Left})]})};import{BaseEdge as Tg,EdgeLabelRenderer as Ng,getSmoothStepPath as vg,MarkerType as wg,useInternalNode as Tl,useReactFlow as Ag,useViewport as Ig}from"@xyflow/react";import{useState as Cg}from"react";import{jsx as Rn,jsxs as Nl}from"react/jsx-runtime";var UC={type:"MESSAGE_EDGE",markerEnd:{type:wg.Arrow},data:{label:""}},vl=({id:e,source:t,target:o,data:n,selected:r})=>{let{zoom:i}=Ig(),{updateEdgeData:s}=Ag(),{isMultipleSelection:a}=R(),[l,c]=Cg(!1),d=Tl(t),p=Tl(o);if(!d||!p)return null;let{sx:u,sy:f,tx:y,ty:g,sourcePos:m,targetPos:_}=Le(d,p),[h,E,T]=vg({sourceX:u,sourceY:f,targetX:y,targetY:g,sourcePosition:m,targetPosition:_}),N=r||(d==null?void 0:d.selected)||(p==null?void 0:p.selected),w=N?"sequence-edge-marker-highlighted":"sequence-edge-marker",x=l||(n==null?void 0:n.label.trim().length)>0,C=1/i,k=()=>{c(!0)},D=()=>{c(!1)},A=S=>{s(e,{label:S.trim()})};return Nl("g",{className:L("text-grey-400 hover:text-grey-500",{"text-blue-500 hover:text-blue-600":N}),onBlur:D,onDoubleClick:k,children:[Rn(Tg,{id:e,path:h,markerEnd:`url(#${w})`,strokeDasharray:4,className:L("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&&!(n!=null&&n.hasError)})}),Rn(Ng,{children:Nl("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&&!a&&Rn(xt,{edgeId:e,edgeType:"MESSAGE_EDGE",style:{transform:`scale(${C})`}}),x&&Rn(te,{value:n==null?void 0:n.label,className:"min-w-8 max-w-56 bg-white rounded-md px-2 py-1 text-xs",isEditing:l,onChange:A})]})})]})};import{getBezierPath as Sg}from"@xyflow/react";import{jsx as wl,jsxs as Mg}from"react/jsx-runtime";var Al=({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:s,sy:a,tx:l,ty:c,sourcePos:d,targetPos:p}=Le(r,i),[u]=Sg({sourceX:s,sourceY:a,sourcePosition:d||o,targetPosition:p||n,targetX:l||e,targetY:c||t});return Mg("g",{children:[wl("path",{fill:"none",className:"stroke-2 stroke-grey-400 animated",d:u}),wl("circle",{cx:l||e,cy:c||t,fill:"none",r:4,className:"stroke-2 stroke-grey-500"})]})};import{Position as Pg,useReactFlow as Lg}from"@xyflow/react";import{orderBy as Dg}from"lodash";import{useMemo as Il,useState as kg}from"react";import{Fragment as Rg,jsx as nt,jsxs as Cl}from"react/jsx-runtime";var Sl=({id:e,data:t,selected:o,dragging:n,parentId:r})=>{let{updateNodeData:i,getNodes:s}=Lg(),{mode:a,isConnecting:l,isDragging:c,isMultipleSelection:d}=R(),[p,u]=kg(!1),f=s(),y=!r,g=Il(()=>Dg([...f.filter(w=>w.parentId===e&&w.type==="LANE")],"position.y","asc"),[f,e]),m=y?Sn.MIN_WIDTH:$.MIN_WIDTH,_=Il(()=>{if(y&&g.length>1){let w=[...g];return w.pop(),w.reduce((C,k)=>{var D,A;return C+((A=(D=k.measured)==null?void 0:D.height)!=null?A:0)},0)+$.MIN_HEIGHT}return $.MIN_HEIGHT},[y,g]),h=w=>{i(e,{label:w})},E=()=>{u(!0)},T=()=>{u(!1)},N=!l&&!c&&!d;return Cl(Rg,{children:[Cl("div",{className:L("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:[nt("div",{className:"flex align-items justify-center w-10 border-r-2 border-grey-400",onBlur:T,onDoubleClick:E,children:nt("div",{className:L("relative flex-1",{"[writing-mode:vertical-rl] [text-orientation:sideways] transform rotate-180":!p}),children:nt(te,{value:t.label,className:"w-full h-full pointer-events-none self-auto",contentClassName:L({"whitespace-nowrap":p}),isEditing:p,onChange:h})})}),nt("div",{className:"flex-1"})]}),N&&nt(ae,{nodeId:e,nodeType:"LANE",isChild:!y,isVisible:!n&&o}),a==="edit"&&nt(vt,{nodeId:e,minWidth:m,minHeight:_,isVisible:!n&&o}),y&&nt(ee,{type:"source",position:Pg.Right})]})};var Ml={START_EVENT:ul,END_EVENT:al,TASK:El,GATEWAY:cl,ANNOTATION:il,LANE:Sl,UNSUPPORTED:_l},Pl={SEQUENCE_EDGE:Sa,MESSAGE_EDGE:vl,ANNOTATION_EDGE:Ea},Ll="#fafafa",Dl="#bebebe",kl=1,Rl=10,Vl="bottom-left",Ol=.2,Hl=5,Mt=.5,Gl={x:0,y:0,zoom:.75},Vg=1,Og=2,Bl=[Vg,Og];import{useReactFlow as Gg}from"@xyflow/react";var Hg=1,zl=()=>`<mxGraphModel>
3
3
  <root version="1.1">
4
4
  <mxCell id="0" />
5
5
  <mxCell id="1" parent="0" />
@@ -32,9 +32,9 @@ var ld=Object.defineProperty,cd=Object.defineProperties;var dd=Object.getOwnProp
32
32
  <mxGeometry as="geometry" relative="1" />
33
33
  </mxCell>
34
34
  </root>
35
- </mxGraphModel>`,Sr=(e,t)=>{if(!e.length&&!t.length)return Gg;let o=[...e.map(r=>r.id),...t.map(r=>r.id)];return Math.max(...o.map(r=>Number(r)))};var ve=()=>{let{getEdges:e,getNodes:t}=Bg();return{getLastId:()=>Sr(t(),e()),getNextId:()=>{let n=t(),r=e();return Sr(n,r)+1}}};var Pt=()=>{let{getNodes:e,getEdges:t,setNodes:o,setEdges:n,fitView:r}=zg(),{getLastId:i}=ve(),s=Fl(async(l="")=>{let{nodes:c,edges:d}=await Za(l);o(c),n(d),r({padding:Mt})},[o,n,r]),a=Fl((l,c)=>{let d=l||e()||[],p=c||t()||[],u=i();return qa(d,p,u)},[e,t,i]);return{importFromMxGraph:s,exportToMxGraph:a}};import{useCallback as Wl}from"react";var Wg=500,Lt=()=>{let{isInitialized:e,onElementChanges:t}=V(),{exportToMxGraph:o}=Pt(),n=Fg(()=>{if(!e)return;let s=o();t==null||t(s)},Wg),r=Wl(s=>{s.every(c=>c.type==="select")||s.some(c=>c.type==="position"&&c.dragging)||n()},[n]),i=Wl(s=>{s.some(l=>l.type==="select")||n()},[n]);return{emitElementChanges:n,handleNodeChanges:r,handleEdgeChanges:i}};var Ul=({setEdges:e})=>{let{getNode:t,getEdges:o,getNodes:n}=Ug(),{emitElementChanges:r}=Lt(),i=Yl(a=>{let l=t(a.source),c=t(a.target);if(!l||!c)return!1;let d={sourceNodeId:l.id,targetNodeId:c.id,sourceNodeType:l.type,targetNodeType:c.type,nodes:n(),edges:o()};return Ca(d).isValid},[t,o,n]),s=Yl(a=>{e(l=>{let c=t(a.target),d=(c==null?void 0:c.type)==="ANNOTATION"?Et:xe;return Yg(b(b({},a),d),l)}),r()},[t,e,r]);return{isValidConnection:i,onConnect:s}};import{useReactFlow as $g}from"@xyflow/react";import{useTranslation as Xg}from"lecom-ui";import{useCallback as Mr,useState as ec}from"react";var fo=(e=[])=>e.filter(t=>t.type==="START_EVENT"),rt=(e=[])=>e.filter(t=>t.type==="END_EVENT"),Ue=(e=[])=>e.filter(t=>t.type==="TASK")||[],$l=(e=[])=>e.filter(t=>{var o;return t.type==="TASK"&&((o=t.properties)==null?void 0:o.variant)==="SCRIPT"}),Xl=(e=[])=>e.filter(t=>{var o;return t.type==="TASK"&&((o=t.properties)==null?void 0:o.variant)==="SUBPROCESS"}),On=(e=[])=>e.filter(t=>t.type==="GATEWAY"),Kl=(e=[])=>e.filter(t=>{var o;return t.type==="GATEWAY"&&((o=t.properties)==null?void 0:o.variant)==="EXCLUSIVE"}),ue=(e,t=[])=>t.filter(o=>o.source===e),mo=(e,t=[])=>t.filter(o=>o.target===e),ql=(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"},Zl=(e,t)=>{let o=ue(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},Jl=e=>e?/\w/g.test(e.trim()):!1,Y=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:[]}},we=(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)}},Ql=(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 go=[{id:"start_event_not_found",validate:e=>{let t=fo(e.nodes);return Y({isValid:t.length>=1})}},{id:"end_event_not_found",validate:e=>{let t=rt(e.nodes);return Y({isValid:t.length>=1})}},{id:"multiple_start_event_not_allowed",validate:e=>{let t=fo(e.nodes),o=t.length===1;if(t.length===0)return Y({isValid:!0});if(!o)return Y({isValid:!1,nodeIds:t.map(i=>i.id)});let n=ue(t[0].id,e.edges);if(!(n.length<=1)){let i=[...t.map(s=>s.id),...n.map(s=>s.target)];return Y({isValid:!1,nodeIds:[...new Set(i)]})}return Y({isValid:!0})}},{id:"task_flows_limit_exceeds",validate:e=>{let t=Ue(e.nodes),o=we(t,n=>ue(n.id,e.edges).length<=2);return Y({isValid:o.isValid,nodeIds:o.invalidIds})}},{id:"task_label_empty",highlightRelatedEdges:!1,validate:e=>{let t=Ue(e.nodes),o=we(t,n=>!!n.label&&n.label.trim()!=="");return Y({isValid:o.isValid,nodeIds:o.invalidIds})}},{id:"task_label_length",highlightRelatedEdges:!1,validate:e=>{let o=Ue(e.nodes),n=we(o,r=>!r.label||r.label.length<=60);return Y({isValid:n.isValid,nodeIds:n.invalidIds})}},{id:"duplicate_task_name",highlightRelatedEdges:!1,validate:e=>{let t=Ue(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 Y({isValid:n.length===0,nodeIds:n})}},{id:"nested_gateway",validate:e=>{let t=On(e.nodes),o=[],n=[];for(let r of t){let i=ue(r.id,e.edges);for(let s of i){let a=e.nodes.find(l=>l.id===s.target);a&&a.type==="GATEWAY"&&(o.push(r.id,a.id),n.push(s.id))}}return Y({isValid:o.length===0,nodeIds:o.length>0?[...new Set(o)]:[],edgeIds:n})}},{id:"events_nested",validate:e=>{let t=[...fo(e.nodes),...rt(e.nodes)],o=[],n=[];for(let r of t){let i=ue(r.id,e.edges);for(let s of i){let a=e.nodes.find(l=>l.id===s.target);a&&(a.type==="START_EVENT"||a.type==="END_EVENT")&&(o.push(r.id,a.id),n.push(s.id))}}return Y({isValid:o.length===0,nodeIds:o.length>0?[...new Set(o)]:[],edgeIds:n})}},{id:"flows_on_end_tasks_not_allowed",validate:e=>{let t=rt(e.nodes),o=[],n=[];for(let r of t){let i=mo(r.id,e.edges);for(let s of i){let a=e.nodes.find(l=>l.id===s.source);if(a&&a.type==="TASK"){let l=ue(a.id,e.edges);l.length>1&&(o.push(a.id),l.forEach(c=>n.push(c.id)))}}}return Y({isValid:o.length===0,nodeIds:o,edgeIds:n})}},{id:"conditions_flows_limit_exceeds",validate:e=>{let t=Kl(e.nodes),o=we(t,r=>ue(r.id,e.edges).length<=2),n=o.invalidIds.flatMap(r=>ue(r,e.edges).map(i=>i.id));return Y({isValid:o.isValid,nodeIds:o.invalidIds,edgeIds:n})}},{id:"activity_name_invalid",validate:e=>{let t=Ue(e.nodes),o=we(t,n=>!n.label||Jl(n.label));return Y({isValid:o.isValid,nodeIds:o.invalidIds})}},{id:"final_activity_has_loop",validate:e=>{var s,a;if(!((s=e==null?void 0:e.nodes)!=null&&s.length)||!((a=e==null?void 0:e.edges)!=null&&a.length))return Y({isValid:!0});let t=rt(e.nodes)[0];if(!t)return Y({isValid:!0});let o=mo(t.id,e.edges);if(!o.length)return Y({isValid:!0});let r=Ue(e.nodes).filter(l=>o.some(c=>c.source===l.id)),i=we(r,l=>!ql(l.id,e));return Y({isValid:i.isValid,nodeIds:i.isValid?[]:[t.id,...i.invalidIds]})}},{id:"concurrent_initial_and_final_event",validate:e=>{let t=Ue(e.nodes),o=rt(e.nodes)[0];if(!o)return Y({isValid:!0});let n=t.filter(l=>{let c=mo(l.id,e.edges),d=ue(l.id,e.edges),p=c.some(f=>{var y;return((y=e.nodes.find(g=>g.id===f.source))==null?void 0:y.type)==="START_EVENT"}),u=d.some(f=>{var y;return((y=e.nodes.find(g=>g.id===f.target))==null?void 0:y.type)==="END_EVENT"});return p&&u}),r=mo(o.id,e.edges),i=r.length>1,s=r.map(l=>l.source),a={isValid:n.length===0&&!i,nodeIds:[...n.map(l=>l.id),...i?s:[]]};return Y(a)}},{id:"gateway_flow_to_event",validate:e=>{let t=On(e.nodes),o=[],n=[];for(let r of t){let i=ue(r.id,e.edges);for(let s of i){let a=e.nodes.find(l=>l.id===s.target);a&&a.type==="END_EVENT"&&(o.push(r.id,a.id),n.push(s.id))}}return Y({isValid:o.length===0,nodeIds:o.length>0?[...new Set(o)]:[],edgeIds:n})}},{id:"gateway_missing_output_streams",validate:e=>{let t=On(e.nodes),o=we(t,n=>ue(n.id,e.edges).length>=1);return Y({isValid:o.isValid,nodeIds:o.invalidIds})}},{id:"event_to_condition",validate:e=>{let t=[...fo(e.nodes),...rt(e.nodes)],o=[],n=[];for(let r of t){let i=ue(r.id,e.edges);for(let s of i){let a=e.nodes.find(l=>l.id===s.target);a&&a.type==="GATEWAY"&&(o.push(r.id,a.id),n.push(s.id))}}return Y({isValid:o.length===0,nodeIds:o.length>0?[...new Set(o)]:[],edgeIds:n})}},{id:"script_in_final_activity",validate:e=>{let t=$l(e.nodes),o=we(t,n=>!Zl(n.id,e));return Y({isValid:o.isValid,nodeIds:o.invalidIds})}},{id:"subprocess_referenced_not_configured",validate:e=>{let t=Xl(e.nodes),o=we(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 Y({isValid:o.isValid,nodeIds:o.invalidIds})}}];var jl=e=>{e=e||{nodes:[],edges:[]},e.nodes=e.nodes||[],e.edges=e.edges||[];let t=[];for(let n of go){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 tc=()=>{let{t:e}=Xg(),{setNodes:t,setEdges:o,getNodes:n,getEdges:r}=$g(),[i,s]=ec(null),[a,l]=ec(!1),c=Mr(u=>{let f=Ql(u.nodes,u.edges),y=jl(f),g=y.errors.map(m=>v(b({},m),{message:e(`validation.errors.${m.id}`)}));return a||l(!0),{isValid:y.isValid,errors:g}},[a,e]),d=Mr(u=>{if(s(u),!u)return;let f=[],y=[];u.errors.forEach(x=>{x.nodeIds&&x.nodeIds.length>0&&x.nodeIds.forEach(I=>f.push(I)),x.edgeIds&&x.edgeIds.length>0&&x.edgeIds.forEach(I=>y.push(I))});let g=[...new Set(f)];t(x=>x.map(I=>v(b({},I),{data:v(b({},I.data),{hasError:!1})}))),o(x=>x.map(I=>v(b({},I),{data:v(b({},I.data),{hasError:!1})})));let m=n(),_=r(),h=new Set(g),E=new Set;u.errors.forEach(x=>{var k,A;let I=go.find(S=>S.id===x.id);(I==null?void 0:I.highlightRelatedEdges)!==!1&&((k=x.edgeIds)==null||k.forEach(S=>E.add(S)),(A=x.nodeIds)==null||A.forEach(S=>{_.forEach(P=>{(P.source===S||P.target===S)&&E.add(P.id)})}))});let T=new Set,N=new Set,w=new Set;m.forEach(x=>{x.type==="START_EVENT"?T.add(x.id):x.type==="END_EVENT"&&N.add(x.id)}),_.forEach(x=>{T.has(x.source)&&w.add(x.target),N.has(x.target)&&w.add(x.source)}),w.forEach(x=>{var I,R;if(h.has(x)){let k=(I=u.errors.find(S=>{var P;return(P=S.nodeIds)==null?void 0:P.includes(x)}))==null?void 0:I.id;((R=go.find(S=>S.id===k))==null?void 0:R.highlightRelatedEdges)!==!1&&_.forEach(S=>{S.source===x&&N.has(S.target)&&(h.add(S.target),E.add(S.id)),S.target===x&&T.has(S.source)&&(h.add(S.source),E.add(S.id))})}}),h.size>0&&t(x=>x.map(I=>v(b({},I),{data:v(b({},I.data),{hasError:h.has(I.id)})}))),E.size>0&&o(x=>x.map(I=>v(b({},I),{data:v(b({},I.data),{hasError:E.has(I.id)})})))},[r,n,o,t]),p=Mr(()=>{s(null),l(!1),t(u=>u.map(f=>v(b({},f),{data:v(b({},f.data),{hasError:!1})}))),o(u=>u.map(f=>v(b({},f),{data:v(b({},f.data),{hasError:!1})})))},[o,t]);return{validationResult:i,validateDiagram:c,handleValidationComplete:d,clearValidation:p,isAutoValidationEnabled:a}};import{useReactFlow as Kg}from"@xyflow/react";import{useTranslation as qg}from"lecom-ui";import{useEffect as Zg}from"react";var Jg=15,oc="bpmn:selection",Qg=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},nc=e=>{if(!Qg(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},rc=({offset:e=Jg}={})=>{let{t}=qg(),{getNodes:o,setNodes:n,getEdges:r,setEdges:i}=Kg(),{getNextId:s}=ve();Zg(()=>{let a=c=>{var m,_;if(!nc(c))return;let d=o(),p=r(),u=d.filter(h=>h.selected);if(!u.length)return;c.preventDefault(),c.stopPropagation();let f=p.filter(h=>u.some(E=>E.id===h.source)&&u.some(E=>E.id===h.target)),g=JSON.stringify({nodes:u,edges:f});(m=c.clipboardData)==null||m.setData(oc,g),(_=c.clipboardData)==null||_.setData("text/plain",`BPMN Selection: ${u.length} nodes`)},l=c=>{var N,w;if(!nc(c))return;let d=(N=c.clipboardData)==null?void 0:N.getData(oc);if(!d)return;c.preventDefault(),c.stopPropagation();let p;try{p=JSON.parse(d)}catch(x){return}if(!((w=p.nodes)!=null&&w.length))return;let u=new Map,f=o(),y=[],g=f.some(x=>x.type==="START_EVENT"),m=p.nodes.filter(x=>x.type==="START_EVENT"),_=p.nodes;if(g&&m.length>0&&(_=p.nodes.filter(x=>x.type!=="START_EVENT"),_.length===0))return;let h=s(),E=_.map(x=>{var k;let I=String(h++);u.set(x.id,I);let R=v(b({},x),{id:I,selected:!0,position:{x:x.position.x+e,y:x.position.y+e}});if(x.type==="TASK"){let A=(k=x.data)==null?void 0:k.label,S=St(A||t("bpmn.task.label.prefix"),[...f,...y]);R.data=v(b({},x.data),{label:S})}return y.push(R),R}),T=p.edges.map(x=>v(b({},x),{id:String(h++),selected:!0,source:u.get(x.source)||x.source,target:u.get(x.target)||x.target}));n(x=>[...x.map(I=>v(b({},I),{selected:!1})),...E]),i(x=>[...x.map(I=>v(b({},I),{selected:!1})),...T])};return document.addEventListener("copy",a,!0),document.addEventListener("paste",l,!0),()=>{document.removeEventListener("copy",a,!0),document.removeEventListener("paste",l,!0)}},[o,n,r,i,s,e,t])};import{useReactFlow as jg,useStoreApi as eh}from"@xyflow/react";import{useTranslation as th}from"lecom-ui";import{useState as oh}from"react";var ic=({nodes:e,setNodes:t,setEdges:o})=>{let n=eh(),{draggableNode:r,setDraggableNode:i}=wt(),{t:s}=th(),{getInternalNode:a,screenToFlowPosition:l}=jg(),{getNextId:c}=ve(),{setIsDragging:d}=V(),{rebuildIndex:p,forceRebuildIndex:u}=yt(),[f,y]=oh(null),g=(A,S=!1)=>{let P=S?"[&>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(C=>C.map(M=>v(b({},M),{className:M.id===A?P:""})))},m=()=>{let{nodeLookup:A}=n.getState();return Array.from(A.values())},_=A=>{let S=a(A.id),P=m();if(A.type==="LANE"){if(Nt({parentId:A.id,nodes:e,includeTypes:["LANE"]})){g();return}let W=P.filter($=>$.id!==A.id&&$.type==="LANE"&&!$.parentId),B=co(S,W);if(!B){g();return}if(Nt({parentId:B.id,nodes:e,excludeTypes:["LANE"]})){g(B.id,!0);return}g(B.id);return}let M=P.filter(H=>H.id!==A.id&&H.type==="LANE"),L=co(S,M);if(!L){g();return}if(Nt({parentId:L.id,nodes:e,includeTypes:["LANE"]})){g();return}g(L.id)},h=A=>A.map(S=>v(b({},S),{className:void 0})),E=A=>A.some(P=>P.dragging)?A.map(P=>P.dragging?v(b({},P),{dragging:!1}):P):A,T=A=>{A.preventDefault(),A.dataTransfer.dropEffect="move"},N=(A,S)=>{A.preventDefault(),_(S)},w=(A,S,P)=>{var H,W;let C=[...P];if(A.parentId===S.id)return C=$a(A,S,C),C=uo(C),h(C);if(A.type==="LANE"){if(Nt({parentId:S.id,nodes:C,excludeTypes:["LANE"]})){let U=de(S),Re=50,Ie=50;return C.map(_e=>{var Ot,lt;return _e.id===A.id?v(b({},_e),{position:{x:(Ot=f==null?void 0:f.x)!=null?Ot:U.x+Re,y:(lt=f==null?void 0:f.y)!=null?lt:U.y2+Ie}}):_e})}let $=C.filter(U=>U.parentId===S.id).reduce((U,Re)=>{var Ie,_e;return U+((_e=(Ie=Re.measured)==null?void 0:Ie.height)!=null?_e:0)},0),K={x:X.HEADER_WIDTH,y:$};return C=C.map(U=>U.id===A.id?v(b({},U),{parentId:S.id,position:K,className:void 0}):v(b({},U),{className:void 0})),C=et(S.id,C),C}if(Nt({parentId:S.id,nodes:C,includeTypes:["LANE"]})){let B;if(A.parentId){let F=a(A.parentId),{x:$,y:K}=Le(F);B={x:$+((H=A.position.x)!=null?H:0),y:K+((W=A.position.y)!=null?W:0)}}return C=C.map(F=>F.id===A.id?v(b({},F),{position:B!=null?B:F.position,parentId:void 0,className:void 0}):v(b({},F),{className:void 0})),C}let z=Fa(A,S);return C=C.map(B=>{if(B.id===A.id){let F=de(A),$=de(S);return F.y<$.y&&(z.y=0),F.x<$.x+X.HEADER_WIDTH&&(z.x=X.HEADER_WIDTH),v(b({},B),{parentId:S.id,position:z,className:void 0})}return v(b({},B),{className:void 0})}),C=uo(C),C},x=A=>{if(A.preventDefault(),!(r!=null&&r.type))return;let S=l({x:A.clientX,y:A.clientY}),P={width:G[r.type].MIN_WIDTH,height:G[r.type].MIN_HEIGHT},C=c(),M={id:String(C),type:r.type,position:S,measured:P,data:{label:r.type==="TASK"?kn(e,s("bpmn.task.label.prefix")):"",variant:r.variant,attribute:r.attribute},selected:!0},L=v(b({},M),{internals:{positionAbsolute:S}}),z=m(),H=r.type==="LANE",W=z.filter(K=>H?K.type==="LANE"&&!K.parentId:K.type==="LANE"),B=co(L,W),F=[...e.map(K=>v(b({},K),{selected:!1})),M];B&&(F=w(L,B,F)),F=De(F),t(F),u();let $=A.dataTransfer.getData("sourceId");if($){let K={id:String(C+1),source:$,target:M.id};if(r.type==="ANNOTATION"){o(U=>U.concat(b(b({},K),Et)));return}o(U=>U.concat(b(b({},K),xe)))}d(!1),i(null)},I=async(A,S,P)=>{let C=[...e];P.forEach(M=>{let L=m(),z=a(M.id),H=M.type==="LANE",W=L.filter(F=>F.id!==M.id&&(H?F.type==="LANE"&&!F.parentId:F.type==="LANE")),B=co(z,W);if(B){C=w(z,B,C);return}M.parentId&&(C=k(M,C))}),C=E(C),C=De(C),C=h(C),t(C),p(C),y(null)},R=(A,S)=>{y({x:S.position.x,y:S.position.y})},k=(A,S)=>{var z,H;let P=a(A.parentId),{x:C,y:M}=Le(P),L={x:C+((z=A.position.x)!=null?z:0),y:M+((H=A.position.y)!=null?H:0)};return S=S.map(W=>W.id===A.id?v(b({},W),{position:L,parentId:void 0}):W),S=et(A.parentId,S),S};return{onDragOver:T,onDrop:x,onNodeDrag:N,onNodeDragStart:R,onNodeDragStop:I}};import{useReactFlow as nh}from"@xyflow/react";import{useTranslation as rh}from"lecom-ui";import{useEffect as ih}from"react";var sh=30,ah=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},lh=e=>!ah(e.target),sc=({offset:e=sh}={})=>{let{t}=rh(),{getNodes:o,setNodes:n,getEdges:r,setEdges:i}=nh(),{getNextId:s}=ve();ih(()=>{let a=l=>{if(l.ctrlKey&&l.key.toLowerCase()==="d"&&lh(l)){l.preventDefault(),l.stopPropagation();let c=o(),d=r(),p=c.filter(N=>N.selected);if(!p.length)return;let u=new Map,f=[],y=c.some(N=>N.type==="START_EVENT"),g=p.filter(N=>N.type==="START_EVENT"),m=p;if(y&&g.length>0&&(m=p.filter(N=>N.type!=="START_EVENT"),m.length===0))return;let _=d.filter(N=>m.some(w=>w.id===N.source)&&m.some(w=>w.id===N.target)),h=s(),E=m.map(N=>{var I;let w=String(h++);u.set(N.id,w);let x=v(b({},N),{id:w,selected:!0,position:{x:N.position.x+e,y:N.position.y+e}});if(N.type==="TASK"){let R=(I=N.data)==null?void 0:I.label,k=St(R||t("bpmn.task.label.prefix"),[...c,...f]);x.data=v(b({},N.data),{label:k})}return f.push(x),x}),T=_.map(N=>v(b({},N),{id:String(h++),selected:!0,source:u.get(N.source)||N.source,target:u.get(N.target)||N.target}));n(N=>[...N.map(w=>v(b({},w),{selected:!1})),...E]),i(N=>[...N.map(w=>v(b({},w),{selected:!1})),...T])}};return document.addEventListener("keydown",a,!0),()=>{document.removeEventListener("keydown",a,!0)}},[o,n,r,i,s,e,t])};import{useReactFlow as dh}from"@xyflow/react";var lc={"start-event":"START_EVENT","end-event":"END_EVENT",task:"TASK","gateway-exclusive":"GATEWAY"},cc={"start-event":"","end-event":"",task:"","gateway-exclusive":"EXCLUSIVE"},ac=(e,t)=>{if(!e){console.warn("Step not found");return}e=e.trim();let o=e.match(/(\<.*?\>)/)||[],n=e.match(/(\[.*?\])/)||[],r=e.match(/(\{.*?\})/)||[],i=e.match(/(--.*|\|.*?\|)/i)||[],s="",a="",l="";if(o.length){switch(o[1]){case"<start>":s="start-event";break;case"<end>":s="end-event";break}e=e.replace(o[1],"")}return n.length&&(s="task",a=n[1].replace(/\[|\]/g,""),e=e.replace(n[1],"")),r.length&&(s="gateway-exclusive",a=r[1].replace(/\{|\}/g,""),e=e.replace(r[1],"")),s||(s="task",a=e),i.length&&(l=i[1].replace(/(\||--)/g,""),e=e.replace(i[1],"")),e=e.trim(),t[e]||(t[e]={type:s,label:a}),{step:e,type:s,label:a,edgeLabel:l}},ch=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 s=ac(i[0],o),a=ac(i[1],o);s&&a&&n.push({sourceId:s.step,targetId:a.step,label:s.edgeLabel||a.edgeLabel||""})}),{components:o,connections:n}},dc=e=>{let{components:t,connections:o}=ch(e);return{nodes:t,edges:o}};var uc=()=>{let{setNodes:e,setEdges:t,fitView:o}=dh(),{getNextId:n}=ve();return{importFromLia:i=>{let s=typeof i=="string"?i:i.diagramXml||"",{nodes:a,edges:l}=dc(s),c=[],d=new Map,p=!1,u=n();for(let[m,_]of Object.entries(a)){let h=String(u++),E=lc[_.type],T=cc[_.type];E==="START_EVENT"&&(p=!0),d.set(m,h);let N=G[E].MIN_WIDTH,w=G[E].MIN_HEIGHT;c.push({id:h,type:E,data:{label:_.label||"",variant:T,attribute:""},position:{x:0,y:0},width:N,height:w,measured:{width:N,height:w}})}let f=[];for(let m of l){let _=v(b({},xe),{id:String(u++),source:d.get(m.sourceId)||m.sourceId,target:d.get(m.targetId)||m.targetId});f.push(_)}if(!p&&c.length>0){let m=String(u++),_={id:m,type:"START_EVENT",data:{label:"",variant:"",attribute:""},position:{x:0,y:0},width:G.START_EVENT.MIN_WIDTH,height:G.START_EVENT.MIN_HEIGHT,measured:{width:G.START_EVENT.MIN_WIDTH,height:G.START_EVENT.MIN_HEIGHT}};c.unshift(_);let h=c[1];if(h){let E=v(b({},xe),{id:String(u++),source:m,target:h.id});f.unshift(E)}}let{nodes:y,edges:g}=Ua(c,f);e(y),t(g),o({padding:Mt})}}};import{useEffect as uh,useCallback as ph}from"react";var fh={origin:"*",debug:!1};function pc(e,t=fh){let{origin:o,debug:n}=t,r=ph((i,s)=>{let a={event:i,data:[i,{event:i,data:s}]};window.parent.postMessage(a,o||"*")},[o]);return uh(()=>{let i=s=>{let a=s.data;if(!(a!=null&&a.event)||!(a!=null&&a.data))return;let{event:l,data:c}=a,d;if(Array.isArray(c)){let[,p]=c;d=p.data}else d=c;n&&(console.debug("[postMessage] received:",a),console.debug("[postMessage] eventData:",d)),l&&e[l]&&e[l](d)};return window.addEventListener("message",i),()=>window.removeEventListener("message",i)},[e,n]),{sendMessage:r}}import{useNodesInitialized as mh}from"@xyflow/react";import{useEffect as fc}from"react";var mc=()=>{let e=mh(),{initialDiagram:t,setIsInitialized:o}=V(),{importFromMxGraph:n}=Pt();fc(()=>{t&&n(t)},[t,n,o]),fc(()=>{if(!e)return;(async()=>{await No(),o(!0)})()},[e,o])};import{useCallback as gc}from"react";import{useReactFlow as gh}from"@xyflow/react";function hc(){let{setTaskStatuses:e,clearTaskStatuses:t,calculateFlowPath:o}=Xe(),{getEdges:n}=gh(),r=Co(),i=gc(a=>{if(!(a!=null&&a.activities))return;e(a.activities);let l=a.activities.map(d=>d.diagramId),c=n();o(c,l),setTimeout(()=>{r()},0)},[e,o,n,r]),s=gc(()=>{t(),setTimeout(()=>{r()},0)},[t,r]);return{handleTasksStatus:i,handleClearTaskStatus:s}}import{useReactFlow as hh}from"@xyflow/react";import{useCallback as Dt,useState as yc,useEffect as yh}from"react";import{useDebouncedCallback as xh}from"use-debounce";var xc=[{nodes:[],edges:[]}],Eh=500,Ec=100,bc=(e=xc)=>{let{getNodes:t,getEdges:o,setNodes:n,setEdges:r}=hh(),[i,s]=yc(e),[a,l]=yc(0),c=i[a],d=a>0,p=a<i.length-1,u=Dt(T=>{n(i[T].nodes),r(i[T].edges)},[i,n,r]),f=Dt(()=>{if(a>0){let T=a-1;l(T),u(T)}},[a,u]),y=Dt(()=>{if(a<i.length-1){let T=a+1;l(T),u(T)}},[i,a,u]),g=T=>{let w=[...i.slice(0,a+1),T],x=w.length>Ec?w.slice(w.length-Ec):w;s(x),l(x.length-1)},m=xh(()=>{let T=t(),N=o(),w=T.map(R=>v(b({},R),{selected:!1,className:""})),x={nodes:De(w),edges:N};JSON.stringify(c)!==JSON.stringify(x)&&g(x)},Eh),_=Dt(T=>{if(T==="forceSave"){m();return}T.some(x=>x.type==="select")||T.some(x=>x.type==="position"&&x.dragging)||m()},[m]),h=Dt(T=>{s(T||xc),l(0)},[]),E=Dt(()=>{s([]),l(0)},[]);return yh(()=>{let T=N=>{(N.ctrlKey||N.metaKey)&&(N.shiftKey&&N.key.toLowerCase()==="z"?(N.preventDefault(),y()):N.key.toLowerCase()==="z"&&(N.preventDefault(),f()))};return document.addEventListener("keydown",T),()=>{document.removeEventListener("keydown",T)}},[f,y]),{history:i,undo:f,redo:y,canUndo:d,canRedo:p,saveHistory:_,resetHistory:h,clearHistory:E}};var Ch=500,_c=()=>{let e=wh(!1),[t,o,n]=_h([]),[r,i,s]=bh([]),[a,l]=Ah(null),{getNodes:c,getEdges:d}=Nh(),{instanceId:p,setIsConnecting:u,setIsMultipleSelection:f}=V(),{updateHelperLines:y,HelperLines:g}=yt(),{undo:m,redo:_,canUndo:h,canRedo:E,saveHistory:T}=bc(),{onNodeDrag:N,onDrop:w,onDragOver:x,onNodeDragStop:I,onNodeDragStart:R}=ic({nodes:t,setNodes:o,setEdges:i}),{isValidConnection:k,onConnect:A}=Ul({setEdges:i}),{validationResult:S,handleValidationComplete:P,clearValidation:C,isAutoValidationEnabled:M,validateDiagram:L}=tc(),{importFromLia:z}=uc(),{handleTasksStatus:H,handleClearTaskStatus:W}=hc(),{clearPathEdges:B}=Xe(),F=Co(),{emitElementChanges:$,handleNodeChanges:K,handleEdgeChanges:U}=Lt();rc(),sc(),mc();let Re=kt(()=>{o([]),i([]),B(),setTimeout(()=>{F()},0)},[o,i,B,F]);pc({LIA_CREATE_DIAGRAM:z,CLEAR_DIAGRAM:Re,TASKS_STATUS:H,CLEAR_TASKS_STATUS:W});let{selectElements:Ie,clearSelection:_e}=Fe(),{importFromMxGraph:Ot,exportToMxGraph:lt}=Pt(),{configureElement:qr,getConfigureElement:Zr}=ln();vh(()=>(Rt.set(p,{importFromMxGraph:Ot,exportToMxGraph:lt,selectElements:Ie,clearSelection:_e,configureElement:qr,getConfigureElement:Zr}),()=>{Rt.delete(p)}),[p,Ot,lt,Ie,_e,qr,Zr]);let rd=kt(()=>{if(!M){e.current=!1;return}let ce=L({nodes:c(),edges:d()});P(ce),e.current=!1},[M,c,d,L,P]),Jr=Ih(rd,Ch),xo=kt(()=>{M&&!e.current&&(e.current=!0,Jr())},[M,Jr]),id=kt(ce=>{let Ht=y(ce,t);n(Ht),T(ce),xo(),K(ce)},[t,n,T,xo,y,K]),sd=kt(ce=>{s(ce),T(ce),xo(),U(ce)},[s,T,xo,U]);Th({onChange:({nodes:ce,edges:Ht})=>{f(ce.length+Ht.length>1)}});let ad=kt(async({nodes:ce,edges:Ht})=>(l({nodes:ce,edges:Ht}),!1),[l]);return{nodes:t,setNodes:o,edges:r,setEdges:i,events:{isValidConnection:k,onConnect:A,onDrop:w,onDragOver:x,onNodeDrag:N,onNodeDragStop:I,onNodeDragStart:R,onDropCapture:()=>{T("forceSave"),$()},onConnectStart:()=>{u(!0)},onConnectEnd:()=>{u(!1)},onBeforeDelete:ad,onNodesChange:id,onEdgesChange:sd},ui:{pendingDelete:a,setPendingDelete:l,validationResult:S,handleCloseValidationPanel:C},controls:{undo:m,redo:_,canUndo:h,canRedo:E},components:{HelperLines:g},actions:{saveHistory:T,selectElements:Ie,clearSelection:_e,exportToMxGraph:lt,validateDiagram:L,handleValidationComplete:P}}};import{jsx as Tc}from"react/jsx-runtime";var Pr=({id:e,className:t})=>Tc("marker",{id:e,className:D("react-flow__arrowhead",t),viewBox:"0 0 10 10",refX:"9",refY:"5",markerWidth:"7",markerHeight:"7",orient:"auto",markerUnits:"userSpaceOnUse",fill:"currentColor",stroke:"currentColor",children:Tc("path",{d:"M 0 0 L 10 5 L 0 10 Z"})});import{jsx as Lr,jsxs as Sh}from"react/jsx-runtime";var Nc=()=>Lr("svg",{style:{position:"absolute",top:0,left:0},children:Sh("defs",{children:[Lr(Pr,{id:"sequence-edge-marker",className:"text-grey-400"}),Lr(Pr,{id:"sequence-edge-marker-highlighted",className:"text-blue-500"})]})});import{useKeyPress as Bc}from"@xyflow/react";import{Button as Vr,Tooltip as Or,TooltipContent as Hr,TooltipTrigger as Gr,useTranslation as E0}from"lecom-ui";import{HandIcon as b0,MapIcon as _0,MousePointerIcon as T0}from"lucide-react";import{useCallback as zc,useEffect as Fc}from"react";import{Tooltip as Zh,TooltipContent as Jh,TooltipTrigger as Qh,useNotificationToast as jh,useTranslation as e0}from"lecom-ui";var ho=(h=>(h.START_EVENT="START_EVENT",h.END_EVENT="END_EVENT",h.TASK="TASK",h.SUBPROCESS="SUBPROCESS",h.GATEWAY="GATEWAY",h.LANE="LANE",h.ANNOTATION="ANNOTATION",h.CONNECTION="CONNECTION",h.INTERMEDIATE_EVENT="INTERMEDIATE_EVENT",h.ACTIVITY="ACTIVITY",h.PROCESS_INTERFACE="PROCESS_INTERFACE",h.WORKFLOW_INTERFACE="WORKFLOW_INTERFACE",h.VARIANT_ACTIVITY="VARIANT_ACTIVITY",h.AUTO_ACTIVITY="AUTO_ACTIVITY",h.DATA_STORE="DATA_STORE",h.DATA_OBJECT="DATA_OBJECT",h.DATA_OUTPUT="DATA_OUTPUT",h.DATA_INPUT="DATA_INPUT",h))(ho||{});import{useReactFlow as zh}from"@xyflow/react";import{useNotificationToast as Fh,useTranslation as Wh,Button as Yh}from"lecom-ui";var vc=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 wc({columns:e=[],rows:t=[],fileName:o="report"}){if(!e.length||!t.length)return;let r="data:text/csv;charset=utf-8,"+[e,...t].map(s=>s.join(",")).join(`
37
- `),i=encodeURI(r);Hn(i,`${o}.csv`)}var Hn=(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 Ac(e){return e==null?void 0:e.replaceAll("&#xA;"," ")}var v6={START_EVENT:"START_EVENT",END_EVENT:"END_EVENT",TASK:"TASK",GATEWAY:"GATEWAY",ANNOTATION:"ANNOTATION"},Ic={script:"SCRIPT",subprocess:"SUBPROCESS"},Cc={complex:"COMPLEX",none:"EXCLUSIVE",exclusive:"EXCLUSIVE",parallel:"PARALLEL"};var it=({cell:e,type:t,variant:o=""})=>{let{_attributes:n,mxGeometry:r}=e,{value:i,parent:s}=n,a=Number(r._attributes.width),l=Number(r._attributes.height),c=s==="1"?void 0:s;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:a,height:l,measured:{width:a,height:l}}},Ph=e=>{let{subType:t,style:o}=e._attributes,n="imported";return["none"].includes(t)||(n="adapted"),e.mxGeometry._attributes.width=G.START_EVENT.MIN_WIDTH,e.mxGeometry._attributes.height=G.START_EVENT.MIN_HEIGHT,{node:it({cell:e,type:"START_EVENT"}),status:n,originalType:o}},Lh=e=>{let{subType:t,style:o}=e==null?void 0:e._attributes,n="imported";return["none"].includes(t)||(n="adapted"),e.mxGeometry._attributes.width=G.END_EVENT.MIN_WIDTH,e.mxGeometry._attributes.height=G.END_EVENT.MIN_HEIGHT,{node:it({cell:e,type:"END_EVENT"}),status:n,originalType:o}},Dh=e=>{let{subType:t,style:o}=e==null?void 0:e._attributes,n=Ic[t],r="imported";return["script","none"].includes(t)||(r="adapted"),e.mxGeometry._attributes.width=Ve(e.mxGeometry._attributes.width||0,G.TASK.MIN_WIDTH),e.mxGeometry._attributes.height=Ve(e.mxGeometry._attributes.height||0,G.TASK.MIN_HEIGHT),{node:it({cell:e,type:"TASK",variant:n}),status:r,originalType:o}},kh=e=>{let{style:t,subType:o}=e==null?void 0:e._attributes,n=Cc[o],r=["none","inclusive","event-based"],i="imported";return r.includes(o)&&(i="adapted"),e.mxGeometry._attributes.width=G.GATEWAY.MIN_WIDTH,e.mxGeometry._attributes.height=G.GATEWAY.MIN_HEIGHT,{node:it({cell:e,type:"GATEWAY",variant:n}),status:i,originalType:t}},Rh=e=>{let{style:t}=e==null?void 0:e._attributes;return{node:it({cell:e,type:"LANE"}),status:"imported",originalType:t}},Vh=e=>{let{style:t}=e==null?void 0:e._attributes;return e.mxGeometry._attributes.width=Ve(e.mxGeometry._attributes.width||0,G.ANNOTATION.MIN_WIDTH),e.mxGeometry._attributes.height=Ve(e.mxGeometry._attributes.height||0,G.ANNOTATION.MIN_HEIGHT),{node:it({cell:e,type:"ANNOTATION"}),status:"imported",originalType:t}},Sc=e=>{let{style:t}=e==null?void 0:e._attributes;return e.mxGeometry._attributes.width=G.UNSUPPORTED.MIN_WIDTH,e.mxGeometry._attributes.height=G.UNSUPPORTED.MIN_HEIGHT,{node:it({cell:e,type:"UNSUPPORTED"}),status:"unsupported",originalType:t}},Mc=(e,t)=>{let{id:o,source:n,target:r,value:i}=e._attributes;return v(b({},xe),{id:o,source:t.get(n)||n,target:t.get(r)||r,data:{label:i||""}})},Pc={TASK:Dh,GATEWAY:kh,START_EVENT:Ph,END_EVENT:Lh,LANE:Rh,ANNOTATION:Vh};var Oh=e=>{let t=new Map,o=Object.values(ho),n=e.filter(s=>{var l;let a=(l=s._attributes)==null?void 0:l.type;return o.includes(a)}),r=[],i=[];for(let s of n){let{type:a}=s._attributes,l=Pc[a]||Sc,{node:c,status:d,originalType:p}=l(s);i.push(c),r.push({originalType:p,type:c.type,variant:c.data.variant,value:Ac(c.data.label),status:d})}return{nodes:i,governanceIdToNodeIdMap:t,summary:r}},Hh=(e,t)=>e.filter(r=>{var i;return(i=r._attributes)==null?void 0:i.edge}).map(r=>Mc(r,t)),Gh=e=>{let{mxGraphModel:t}=e,{nodes:o,governanceIdToNodeIdMap:n,summary:r}=Oh(t.root.mxCell),i=Hh(t.root.mxCell,n);return{nodes:o,edges:i,summary:r}},Bh=async e=>{let t=await vc(e),o=Cn(t);if(!o)throw new Error("EMPTY_FILE");let{metadata:n,mxGraphModel:r}=o.modeler||{},i=(n==null?void 0:n.app)&&(n==null?void 0:n.diagramType)&&(n==null?void 0:n.version),s=r==null?void 0:r.root;if(!i||!s)throw new Error("INVALID_FILE");if(!Object.keys(r.root.mxCell||{}).length)throw new Error("CONTAIN_NO_CELLS");return{metadata:n,mxGraphModel:r}},Lc=async e=>{try{let t=await Bh(e),{nodes:o,edges:n,summary:r}=Gh(t)||{};return{nodes:o,edges:n,summary:r}}catch(t){throw t}};import{jsx as Uh}from"react/jsx-runtime";var Dc=()=>{let{t:e}=Wh(),{toast:t}=Fh(),{setNodes:o,setEdges:n,fitView:r}=zh(),i=a=>{let l=[e("adapter.governance.report.columns.type"),e("adapter.governance.report.columns.value"),e("adapter.governance.report.columns.status")],c=a.map(d=>[d.originalType,d.value,e(`adapter.governance.report.status.${d.status.toLowerCase()}`)]);t({variant:"warning",content:e("adapter.governance.success.incompatible_cells"),duration:1e3*60*1,action:Uh(Yh,{size:"small",variant:"ghost",onClick:()=>wc({columns:l,rows:c,fileName:"governance-imported-cells"}),children:e("adapter.governance.action.download")})})};return{importFromGovernance:async a=>{try{let{nodes:l,edges:c,summary:d}=await Lc(a);if(o(u=>u.concat(l)),n(u=>u.concat(c)),r({padding:Mt}),d.some(u=>u.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 $h}from"lecom-ui";import{useRef as Xh}from"react";import{Fragment as Kh,jsx as kc,jsxs as qh}from"react/jsx-runtime";var Rc=a=>{var l=a,{children:e,accept:t="*",multiple:o=!1,disabled:n=!1,onClick:r,onFilesSelected:i}=l,s=Te(l,["children","accept","multiple","disabled","onClick","onFilesSelected"]);let c=Xh(null),d=u=>{let f=u.target.files;f!=null&&f.length&&i(f),c.current&&(c.current.value="")};return qh(Kh,{children:[kc($h,v(b({onClick:u=>{var f;(f=c.current)==null||f.click(),r==null||r(u)}},s),{children:e})),kc("input",{type:"file",ref:c,className:"sr-only",accept:t,multiple:o,disabled:n,onChange:d})]})};import{jsx as Gn,jsxs as t0}from"react/jsx-runtime";var Vc=({disabled:e=!1})=>{let{t}=e0(),{toast:o}=jh(),{importFromGovernance:n}=Dc(),r=()=>{if(e){o({variant:"error",content:t("adapter.governance.error.ALREADY_INITIALIZED")});return}},i=s=>{let a=s[0];if(!a){o({variant:"error",content:t("adapter.governance.error.NO_FILE")});return}n(a)};return t0(Zh,{children:[Gn(Qh,{asChild:!0,children:Gn(Rc,{className:"[&>svg]:size-7 p-0",variant:"ghost",size:"small",color:"grey",iconButton:!0,accept:".mdr",disabled:e,onClick:r,onFilesSelected:i,children:Gn(li,{})})}),Gn(Jh,{color:"black",children:t("editor.controls.actions.import_governance")})]})};import{jsx as o0}from"react/jsx-runtime";var Dr=({shortcut:e})=>o0("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 c0,DropdownMenu as d0,DropdownMenuContent as u0,DropdownMenuItem as Rr,DropdownMenuTrigger as p0,Tooltip as Bn,TooltipContent as zn,TooltipTrigger as Fn,useTranslation as f0}from"lecom-ui";import{FileCodeIcon as m0,FileImageIcon as g0,FolderOutputIcon as h0,PrinterIcon as y0}from"lucide-react";import{useState as x0}from"react";import{useReactFlow as n0}from"@xyflow/react";import{toPng as Oc,toSvg as r0}from"html-to-image";import{toast as i0,useTranslation as s0}from"lecom-ui";import{useState as a0}from"react";var l0=3,kr="diagram",Hc=()=>{let{t:e}=s0(),{getNodes:t}=n0(),{clearSelection:o}=Fe(),[n,r]=a0({png:!1,html:!1,print:!1}),i=()=>{let{x:d,y:p,width:u,height:f}=Ka(t());return{width:u,height:f,style:{width:`${u}px`,height:`${f}px`,transform:`translate(${-d}px, ${-p}px)`}}},s=async(d,p)=>{r(v(b({},n),{[p]:!0})),await o();try{let u=Xa();if(!u)throw new Error("Flow element not found");let f=i();return await d(u,f)}catch(u){i0({content:e("editor.controls.actions.export.feedback.error"),variant:"error"})}finally{r(v(b({},n),{[p]:!1}))}};return{exportAsPng:async(d=kr)=>{await s(async(p,u)=>{let f=await Oc(p,v(b({},u),{backgroundColor:"#fcfcfc"}));Hn(f,`${d}.png`)},"png")},exportAsHtml:async(d=kr)=>{await s(async(p,u)=>{let f=await r0(p,v(b({},u),{backgroundColor:"#fcfcfc"})),y=`
35
+ </mxGraphModel>`,Sr=(e,t)=>{if(!e.length&&!t.length)return Hg;let o=[...e.map(r=>r.id),...t.map(r=>r.id)];return Math.max(...o.map(r=>Number(r)))};var he=()=>{let{getEdges:e,getNodes:t}=Gg();return{getLastId:()=>Sr(t(),e()),getNextId:()=>{let n=t(),r=e();return Sr(n,r)+1}}};var Pt=()=>{let{getNodes:e,getEdges:t,setNodes:o,setEdges:n,fitView:r}=Bg(),{getLastId:i}=he(),s=Fl(async(l="")=>{let{nodes:c,edges:d}=await Za(l);o(c),n(d),r({padding:Mt})},[o,n,r]),a=Fl((l,c)=>{let d=l||e()||[],p=c||t()||[],u=i();return qa(d,p,u)},[e,t,i]);return{importFromMxGraph:s,exportToMxGraph:a}};import{useCallback as Wl}from"react";var Fg=500,Lt=()=>{let{isInitialized:e,onElementChanges:t}=R(),{exportToMxGraph:o}=Pt(),n=zg(()=>{if(!e)return;let s=o();t==null||t(s)},Fg),r=Wl(s=>{s.every(c=>c.type==="select")||s.some(c=>c.type==="position"&&c.dragging)||n()},[n]),i=Wl(s=>{s.some(l=>l.type==="select")||n()},[n]);return{emitElementChanges:n,handleNodeChanges:r,handleEdgeChanges:i}};var Ul=({setEdges:e})=>{let{getNode:t,getEdges:o,getNodes:n}=Wg(),{emitElementChanges:r}=Lt(),{getNextId:i}=he(),s=Yl(l=>{let c=t(l.source),d=t(l.target);if(!c||!d)return!1;let p={sourceNodeId:c.id,targetNodeId:d.id,sourceNodeType:c.type,targetNodeType:d.type,nodes:n(),edges:o()};return ma(p).isValid},[t,o,n]),a=Yl(l=>{let c=i(),d=t(l.target),p=(d==null?void 0:d.type)==="ANNOTATION"?Et:Te,u=v(b(b({},l),p),{id:String(c)});e(f=>f.concat(u)),r()},[t,i,e,r]);return{isValidConnection:s,onConnect:a}};import{useReactFlow as Yg}from"@xyflow/react";import{useTranslation as Ug}from"lecom-ui";import{useCallback as Mr,useState as ec}from"react";var fo=(e=[])=>e.filter(t=>t.type==="START_EVENT"),rt=(e=[])=>e.filter(t=>t.type==="END_EVENT"),Ue=(e=[])=>e.filter(t=>t.type==="TASK")||[],$l=(e=[])=>e.filter(t=>{var o;return t.type==="TASK"&&((o=t.properties)==null?void 0:o.variant)==="SCRIPT"}),Xl=(e=[])=>e.filter(t=>{var o;return t.type==="TASK"&&((o=t.properties)==null?void 0:o.variant)==="SUBPROCESS"}),Vn=(e=[])=>e.filter(t=>t.type==="GATEWAY"),Kl=(e=[])=>e.filter(t=>{var o;return t.type==="GATEWAY"&&((o=t.properties)==null?void 0:o.variant)==="EXCLUSIVE"}),ue=(e,t=[])=>t.filter(o=>o.source===e),mo=(e,t=[])=>t.filter(o=>o.target===e),ql=(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"},Zl=(e,t)=>{let o=ue(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},Jl=e=>e?/\w/g.test(e.trim()):!1,Y=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:[]}},Ie=(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)}},Ql=(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 go=[{id:"start_event_not_found",validate:e=>{let t=fo(e.nodes);return Y({isValid:t.length>=1})}},{id:"end_event_not_found",validate:e=>{let t=rt(e.nodes);return Y({isValid:t.length>=1})}},{id:"multiple_start_event_not_allowed",validate:e=>{let t=fo(e.nodes),o=t.length===1;if(t.length===0)return Y({isValid:!0});if(!o)return Y({isValid:!1,nodeIds:t.map(i=>i.id)});let n=ue(t[0].id,e.edges);if(!(n.length<=1)){let i=[...t.map(s=>s.id),...n.map(s=>s.target)];return Y({isValid:!1,nodeIds:[...new Set(i)]})}return Y({isValid:!0})}},{id:"task_flows_limit_exceeds",validate:e=>{let t=Ue(e.nodes),o=Ie(t,n=>ue(n.id,e.edges).length<=2);return Y({isValid:o.isValid,nodeIds:o.invalidIds})}},{id:"task_label_empty",highlightRelatedEdges:!1,validate:e=>{let t=Ue(e.nodes),o=Ie(t,n=>!!n.label&&n.label.trim()!=="");return Y({isValid:o.isValid,nodeIds:o.invalidIds})}},{id:"task_label_length",highlightRelatedEdges:!1,validate:e=>{let o=Ue(e.nodes),n=Ie(o,r=>!r.label||r.label.length<=60);return Y({isValid:n.isValid,nodeIds:n.invalidIds})}},{id:"duplicate_task_name",highlightRelatedEdges:!1,validate:e=>{let t=Ue(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 Y({isValid:n.length===0,nodeIds:n})}},{id:"nested_gateway",validate:e=>{let t=Vn(e.nodes),o=[],n=[];for(let r of t){let i=ue(r.id,e.edges);for(let s of i){let a=e.nodes.find(l=>l.id===s.target);a&&a.type==="GATEWAY"&&(o.push(r.id,a.id),n.push(s.id))}}return Y({isValid:o.length===0,nodeIds:o.length>0?[...new Set(o)]:[],edgeIds:n})}},{id:"events_nested",validate:e=>{let t=[...fo(e.nodes),...rt(e.nodes)],o=[],n=[];for(let r of t){let i=ue(r.id,e.edges);for(let s of i){let a=e.nodes.find(l=>l.id===s.target);a&&(a.type==="START_EVENT"||a.type==="END_EVENT")&&(o.push(r.id,a.id),n.push(s.id))}}return Y({isValid:o.length===0,nodeIds:o.length>0?[...new Set(o)]:[],edgeIds:n})}},{id:"flows_on_end_tasks_not_allowed",validate:e=>{let t=rt(e.nodes),o=[],n=[];for(let r of t){let i=mo(r.id,e.edges);for(let s of i){let a=e.nodes.find(l=>l.id===s.source);if(a&&a.type==="TASK"){let l=ue(a.id,e.edges);l.length>1&&(o.push(a.id),l.forEach(c=>n.push(c.id)))}}}return Y({isValid:o.length===0,nodeIds:o,edgeIds:n})}},{id:"conditions_flows_limit_exceeds",validate:e=>{let t=Kl(e.nodes),o=Ie(t,r=>ue(r.id,e.edges).length<=2),n=o.invalidIds.flatMap(r=>ue(r,e.edges).map(i=>i.id));return Y({isValid:o.isValid,nodeIds:o.invalidIds,edgeIds:n})}},{id:"activity_name_invalid",validate:e=>{let t=Ue(e.nodes),o=Ie(t,n=>!n.label||Jl(n.label));return Y({isValid:o.isValid,nodeIds:o.invalidIds})}},{id:"final_activity_has_loop",validate:e=>{var s,a;if(!((s=e==null?void 0:e.nodes)!=null&&s.length)||!((a=e==null?void 0:e.edges)!=null&&a.length))return Y({isValid:!0});let t=rt(e.nodes)[0];if(!t)return Y({isValid:!0});let o=mo(t.id,e.edges);if(!o.length)return Y({isValid:!0});let r=Ue(e.nodes).filter(l=>o.some(c=>c.source===l.id)),i=Ie(r,l=>!ql(l.id,e));return Y({isValid:i.isValid,nodeIds:i.isValid?[]:[t.id,...i.invalidIds]})}},{id:"concurrent_initial_and_final_event",validate:e=>{let t=Ue(e.nodes),o=rt(e.nodes)[0];if(!o)return Y({isValid:!0});let n=t.filter(l=>{let c=mo(l.id,e.edges),d=ue(l.id,e.edges),p=c.some(f=>{var y;return((y=e.nodes.find(g=>g.id===f.source))==null?void 0:y.type)==="START_EVENT"}),u=d.some(f=>{var y;return((y=e.nodes.find(g=>g.id===f.target))==null?void 0:y.type)==="END_EVENT"});return p&&u}),r=mo(o.id,e.edges),i=r.length>1,s=r.map(l=>l.source),a={isValid:n.length===0&&!i,nodeIds:[...n.map(l=>l.id),...i?s:[]]};return Y(a)}},{id:"gateway_flow_to_event",validate:e=>{let t=Vn(e.nodes),o=[],n=[];for(let r of t){let i=ue(r.id,e.edges);for(let s of i){let a=e.nodes.find(l=>l.id===s.target);a&&a.type==="END_EVENT"&&(o.push(r.id,a.id),n.push(s.id))}}return Y({isValid:o.length===0,nodeIds:o.length>0?[...new Set(o)]:[],edgeIds:n})}},{id:"gateway_missing_output_streams",validate:e=>{let t=Vn(e.nodes),o=Ie(t,n=>ue(n.id,e.edges).length>=1);return Y({isValid:o.isValid,nodeIds:o.invalidIds})}},{id:"event_to_condition",validate:e=>{let t=[...fo(e.nodes),...rt(e.nodes)],o=[],n=[];for(let r of t){let i=ue(r.id,e.edges);for(let s of i){let a=e.nodes.find(l=>l.id===s.target);a&&a.type==="GATEWAY"&&(o.push(r.id,a.id),n.push(s.id))}}return Y({isValid:o.length===0,nodeIds:o.length>0?[...new Set(o)]:[],edgeIds:n})}},{id:"script_in_final_activity",validate:e=>{let t=$l(e.nodes),o=Ie(t,n=>!Zl(n.id,e));return Y({isValid:o.isValid,nodeIds:o.invalidIds})}},{id:"subprocess_referenced_not_configured",validate:e=>{let t=Xl(e.nodes),o=Ie(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 Y({isValid:o.isValid,nodeIds:o.invalidIds})}}];var jl=e=>{e=e||{nodes:[],edges:[]},e.nodes=e.nodes||[],e.edges=e.edges||[];let t=[];for(let n of go){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 tc=()=>{let{t:e}=Ug(),{setNodes:t,setEdges:o,getNodes:n,getEdges:r}=Yg(),[i,s]=ec(null),[a,l]=ec(!1),c=Mr(u=>{let f=Ql(u.nodes,u.edges),y=jl(f),g=y.errors.map(m=>v(b({},m),{message:e(`validation.errors.${m.id}`)}));return a||l(!0),{isValid:y.isValid,errors:g}},[a,e]),d=Mr(u=>{if(s(u),!u)return;let f=[],y=[];u.errors.forEach(x=>{x.nodeIds&&x.nodeIds.length>0&&x.nodeIds.forEach(C=>f.push(C)),x.edgeIds&&x.edgeIds.length>0&&x.edgeIds.forEach(C=>y.push(C))});let g=[...new Set(f)];t(x=>x.map(C=>v(b({},C),{data:v(b({},C.data),{hasError:!1})}))),o(x=>x.map(C=>v(b({},C),{data:v(b({},C.data),{hasError:!1})})));let m=n(),_=r(),h=new Set(g),E=new Set;u.errors.forEach(x=>{var D,A;let C=go.find(S=>S.id===x.id);(C==null?void 0:C.highlightRelatedEdges)!==!1&&((D=x.edgeIds)==null||D.forEach(S=>E.add(S)),(A=x.nodeIds)==null||A.forEach(S=>{_.forEach(O=>{(O.source===S||O.target===S)&&E.add(O.id)})}))});let T=new Set,N=new Set,w=new Set;m.forEach(x=>{x.type==="START_EVENT"?T.add(x.id):x.type==="END_EVENT"&&N.add(x.id)}),_.forEach(x=>{T.has(x.source)&&w.add(x.target),N.has(x.target)&&w.add(x.source)}),w.forEach(x=>{var C,k;if(h.has(x)){let D=(C=u.errors.find(S=>{var O;return(O=S.nodeIds)==null?void 0:O.includes(x)}))==null?void 0:C.id;((k=go.find(S=>S.id===D))==null?void 0:k.highlightRelatedEdges)!==!1&&_.forEach(S=>{S.source===x&&N.has(S.target)&&(h.add(S.target),E.add(S.id)),S.target===x&&T.has(S.source)&&(h.add(S.source),E.add(S.id))})}}),h.size>0&&t(x=>x.map(C=>v(b({},C),{data:v(b({},C.data),{hasError:h.has(C.id)})}))),E.size>0&&o(x=>x.map(C=>v(b({},C),{data:v(b({},C.data),{hasError:E.has(C.id)})})))},[r,n,o,t]),p=Mr(()=>{s(null),l(!1),t(u=>u.map(f=>v(b({},f),{data:v(b({},f.data),{hasError:!1})}))),o(u=>u.map(f=>v(b({},f),{data:v(b({},f.data),{hasError:!1})})))},[o,t]);return{validationResult:i,validateDiagram:c,handleValidationComplete:d,clearValidation:p,isAutoValidationEnabled:a}};import{useReactFlow as $g}from"@xyflow/react";import{useTranslation as Xg}from"lecom-ui";import{useEffect as Kg}from"react";var qg=15,oc="bpmn:selection",Zg=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},nc=e=>{if(!Zg(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},rc=({offset:e=qg}={})=>{let{t}=Xg(),{getNodes:o,setNodes:n,getEdges:r,setEdges:i}=$g(),{getNextId:s}=he();Kg(()=>{let a=c=>{var m,_;if(!nc(c))return;let d=o(),p=r(),u=d.filter(h=>h.selected);if(!u.length)return;c.preventDefault(),c.stopPropagation();let f=p.filter(h=>u.some(E=>E.id===h.source)&&u.some(E=>E.id===h.target)),g=JSON.stringify({nodes:u,edges:f});(m=c.clipboardData)==null||m.setData(oc,g),(_=c.clipboardData)==null||_.setData("text/plain",`BPMN Selection: ${u.length} nodes`)},l=c=>{var N,w;if(!nc(c))return;let d=(N=c.clipboardData)==null?void 0:N.getData(oc);if(!d)return;c.preventDefault(),c.stopPropagation();let p;try{p=JSON.parse(d)}catch(x){return}if(!((w=p.nodes)!=null&&w.length))return;let u=new Map,f=o(),y=[],g=f.some(x=>x.type==="START_EVENT"),m=p.nodes.filter(x=>x.type==="START_EVENT"),_=p.nodes;if(g&&m.length>0&&(_=p.nodes.filter(x=>x.type!=="START_EVENT"),_.length===0))return;let h=s(),E=_.map(x=>{var D;let C=String(h++);u.set(x.id,C);let k=v(b({},x),{id:C,selected:!0,position:{x:x.position.x+e,y:x.position.y+e}});if(x.type==="TASK"){let A=(D=x.data)==null?void 0:D.label,S=St(A||t("bpmn.task.label.prefix"),[...f,...y]);k.data=v(b({},x.data),{label:S})}return y.push(k),k}),T=p.edges.map(x=>v(b({},x),{id:String(h++),selected:!0,source:u.get(x.source)||x.source,target:u.get(x.target)||x.target}));n(x=>[...x.map(C=>v(b({},C),{selected:!1})),...E]),i(x=>[...x.map(C=>v(b({},C),{selected:!1})),...T])};return document.addEventListener("copy",a,!0),document.addEventListener("paste",l,!0),()=>{document.removeEventListener("copy",a,!0),document.removeEventListener("paste",l,!0)}},[o,n,r,i,s,e,t])};import{useReactFlow as Jg,useStoreApi as Qg}from"@xyflow/react";import{useTranslation as jg}from"lecom-ui";import{useState as eh}from"react";var ic=({nodes:e,setNodes:t,setEdges:o})=>{let n=Qg(),{draggableNode:r,setDraggableNode:i}=wt(),{t:s}=jg(),{getInternalNode:a,screenToFlowPosition:l}=Jg(),{getNextId:c}=he(),{setIsDragging:d}=R(),{rebuildIndex:p,forceRebuildIndex:u}=yt(),[f,y]=eh(null),g=(A,S=!1)=>{let O=S?"[&>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(I=>I.map(M=>v(b({},M),{className:M.id===A?O:""})))},m=()=>{let{nodeLookup:A}=n.getState();return Array.from(A.values())},_=A=>{let S=a(A.id),O=m();if(A.type==="LANE"){if(Nt({parentId:A.id,nodes:e,includeTypes:["LANE"]})){g();return}let W=O.filter(X=>X.id!==A.id&&X.type==="LANE"&&!X.parentId),B=co(S,W);if(!B){g();return}if(Nt({parentId:B.id,nodes:e,excludeTypes:["LANE"]})){g(B.id,!0);return}g(B.id);return}let M=O.filter(H=>H.id!==A.id&&H.type==="LANE"),P=co(S,M);if(!P){g();return}if(Nt({parentId:P.id,nodes:e,includeTypes:["LANE"]})){g();return}g(P.id)},h=A=>A.map(S=>v(b({},S),{className:void 0})),E=A=>A.some(O=>O.dragging)?A.map(O=>O.dragging?v(b({},O),{dragging:!1}):O):A,T=A=>{A.preventDefault(),A.dataTransfer.dropEffect="move"},N=(A,S)=>{A.preventDefault(),_(S)},w=(A,S,O)=>{var H,W;let I=[...O];if(A.parentId===S.id)return I=$a(A,S,I),I=uo(I),h(I);if(A.type==="LANE"){if(Nt({parentId:S.id,nodes:I,excludeTypes:["LANE"]})){let K=de(S),pe=50,ye=50;return I.map(xe=>{var Ot,lt;return xe.id===A.id?v(b({},xe),{position:{x:(Ot=f==null?void 0:f.x)!=null?Ot:K.x+pe,y:(lt=f==null?void 0:f.y)!=null?lt:K.y2+ye}}):xe})}let X=I.filter(K=>K.parentId===S.id).reduce((K,pe)=>{var ye,xe;return K+((xe=(ye=pe.measured)==null?void 0:ye.height)!=null?xe:0)},0),U={x:$.HEADER_WIDTH,y:X};return I=I.map(K=>K.id===A.id?v(b({},K),{parentId:S.id,position:U,className:void 0}):v(b({},K),{className:void 0})),I=et(S.id,I),I}if(Nt({parentId:S.id,nodes:I,includeTypes:["LANE"]})){let B;if(A.parentId){let z=a(A.parentId),{x:X,y:U}=De(z);B={x:X+((H=A.position.x)!=null?H:0),y:U+((W=A.position.y)!=null?W:0)}}return I=I.map(z=>z.id===A.id?v(b({},z),{position:B!=null?B:z.position,parentId:void 0,className:void 0}):v(b({},z),{className:void 0})),I}let V=Fa(A,S);return I=I.map(B=>{if(B.id===A.id){let z=de(A),X=de(S);return z.y<X.y&&(V.y=0),z.x<X.x+$.HEADER_WIDTH&&(V.x=$.HEADER_WIDTH),v(b({},B),{parentId:S.id,position:V,className:void 0})}return v(b({},B),{className:void 0})}),I=uo(I),I},x=A=>{if(A.preventDefault(),!(r!=null&&r.type))return;let S=l({x:A.clientX,y:A.clientY}),O={width:F[r.type].MIN_WIDTH,height:F[r.type].MIN_HEIGHT},I=c(),M={id:String(I),type:r.type,position:S,measured:O,data:{label:r.type==="TASK"?Dn(e,s("bpmn.task.label.prefix")):"",variant:r.variant,attribute:r.attribute},selected:!0},P=v(b({},M),{internals:{positionAbsolute:S}}),V=m(),H=r.type==="LANE",W=V.filter(U=>H?U.type==="LANE"&&!U.parentId:U.type==="LANE"),B=co(P,W),z=[...e.map(U=>v(b({},U),{selected:!1})),M];B&&(z=w(P,B,z)),z=ke(z),t(z),u();let X=A.dataTransfer.getData("sourceId");if(X){let U={id:String(I+1),source:X,target:M.id};if(r.type==="ANNOTATION"){o(K=>K.concat(b(b({},U),Et)));return}o(K=>K.concat(b(b({},U),Te)))}d(!1),i(null)},C=async(A,S,O)=>{let I=[...e];O.forEach(M=>{let P=m(),V=a(M.id),H=M.type==="LANE",W=P.filter(z=>z.id!==M.id&&(H?z.type==="LANE"&&!z.parentId:z.type==="LANE")),B=co(V,W);if(B){I=w(V,B,I);return}M.parentId&&(I=D(M,I))}),I=E(I),I=ke(I),I=h(I),t(I),p(I),y(null)},k=(A,S)=>{y({x:S.position.x,y:S.position.y})},D=(A,S)=>{var V,H;let O=a(A.parentId),{x:I,y:M}=De(O),P={x:I+((V=A.position.x)!=null?V:0),y:M+((H=A.position.y)!=null?H:0)};return S=S.map(W=>W.id===A.id?v(b({},W),{position:P,parentId:void 0}):W),S=et(A.parentId,S),S};return{onDragOver:T,onDrop:x,onNodeDrag:N,onNodeDragStart:k,onNodeDragStop:C}};import{useReactFlow as th}from"@xyflow/react";import{useTranslation as oh}from"lecom-ui";import{useEffect as nh}from"react";var rh=30,ih=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},sh=e=>!ih(e.target),sc=({offset:e=rh}={})=>{let{t}=oh(),{getNodes:o,setNodes:n,getEdges:r,setEdges:i}=th(),{getNextId:s}=he();nh(()=>{let a=l=>{if(l.ctrlKey&&l.key.toLowerCase()==="d"&&sh(l)){l.preventDefault(),l.stopPropagation();let c=o(),d=r(),p=c.filter(N=>N.selected);if(!p.length)return;let u=new Map,f=[],y=c.some(N=>N.type==="START_EVENT"),g=p.filter(N=>N.type==="START_EVENT"),m=p;if(y&&g.length>0&&(m=p.filter(N=>N.type!=="START_EVENT"),m.length===0))return;let _=d.filter(N=>m.some(w=>w.id===N.source)&&m.some(w=>w.id===N.target)),h=s(),E=m.map(N=>{var C;let w=String(h++);u.set(N.id,w);let x=v(b({},N),{id:w,selected:!0,position:{x:N.position.x+e,y:N.position.y+e}});if(N.type==="TASK"){let k=(C=N.data)==null?void 0:C.label,D=St(k||t("bpmn.task.label.prefix"),[...c,...f]);x.data=v(b({},N.data),{label:D})}return f.push(x),x}),T=_.map(N=>v(b({},N),{id:String(h++),selected:!0,source:u.get(N.source)||N.source,target:u.get(N.target)||N.target}));n(N=>[...N.map(w=>v(b({},w),{selected:!1})),...E]),i(N=>[...N.map(w=>v(b({},w),{selected:!1})),...T])}};return document.addEventListener("keydown",a,!0),()=>{document.removeEventListener("keydown",a,!0)}},[o,n,r,i,s,e,t])};import{useReactFlow as lh}from"@xyflow/react";var lc={"start-event":"START_EVENT","end-event":"END_EVENT",task:"TASK","gateway-exclusive":"GATEWAY"},cc={"start-event":"","end-event":"",task:"","gateway-exclusive":"EXCLUSIVE"},ac=(e,t)=>{if(!e){console.warn("Step not found");return}e=e.trim();let o=e.match(/(\<.*?\>)/)||[],n=e.match(/(\[.*?\])/)||[],r=e.match(/(\{.*?\})/)||[],i=e.match(/(--.*|\|.*?\|)/i)||[],s="",a="",l="";if(o.length){switch(o[1]){case"<start>":s="start-event";break;case"<end>":s="end-event";break}e=e.replace(o[1],"")}return n.length&&(s="task",a=n[1].replace(/\[|\]/g,""),e=e.replace(n[1],"")),r.length&&(s="gateway-exclusive",a=r[1].replace(/\{|\}/g,""),e=e.replace(r[1],"")),s||(s="task",a=e),i.length&&(l=i[1].replace(/(\||--)/g,""),e=e.replace(i[1],"")),e=e.trim(),t[e]||(t[e]={type:s,label:a}),{step:e,type:s,label:a,edgeLabel:l}},ah=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 s=ac(i[0],o),a=ac(i[1],o);s&&a&&n.push({sourceId:s.step,targetId:a.step,label:s.edgeLabel||a.edgeLabel||""})}),{components:o,connections:n}},dc=e=>{let{components:t,connections:o}=ah(e);return{nodes:t,edges:o}};var uc=()=>{let{setNodes:e,setEdges:t,fitView:o}=lh(),{getNextId:n}=he();return{importFromLia:i=>{let s=typeof i=="string"?i:i.diagramXml||"",{nodes:a,edges:l}=dc(s),c=[],d=new Map,p=!1,u=n();for(let[m,_]of Object.entries(a)){let h=String(u++),E=lc[_.type],T=cc[_.type];E==="START_EVENT"&&(p=!0),d.set(m,h);let N=F[E].MIN_WIDTH,w=F[E].MIN_HEIGHT;c.push({id:h,type:E,data:{label:_.label||"",variant:T,attribute:""},position:{x:0,y:0},width:N,height:w,measured:{width:N,height:w}})}let f=[];for(let m of l){let _=v(b({},Te),{id:String(u++),source:d.get(m.sourceId)||m.sourceId,target:d.get(m.targetId)||m.targetId});f.push(_)}if(!p&&c.length>0){let m=String(u++),_={id:m,type:"START_EVENT",data:{label:"",variant:"",attribute:""},position:{x:0,y:0},width:F.START_EVENT.MIN_WIDTH,height:F.START_EVENT.MIN_HEIGHT,measured:{width:F.START_EVENT.MIN_WIDTH,height:F.START_EVENT.MIN_HEIGHT}};c.unshift(_);let h=c[1];if(h){let E=v(b({},Te),{id:String(u++),source:m,target:h.id});f.unshift(E)}}let{nodes:y,edges:g}=Ua(c,f);e(y),t(g),o({padding:Mt})}}};import{useEffect as ch,useCallback as dh}from"react";var uh={origin:"*",debug:!1};function pc(e,t=uh){let{origin:o,debug:n}=t,r=dh((i,s)=>{let a={event:i,data:[i,{event:i,data:s}]};window.parent.postMessage(a,o||"*")},[o]);return ch(()=>{let i=s=>{let a=s.data;if(!(a!=null&&a.event)||!(a!=null&&a.data))return;let{event:l,data:c}=a,d;if(Array.isArray(c)){let[,p]=c;d=p.data}else d=c;n&&(console.debug("[postMessage] received:",a),console.debug("[postMessage] eventData:",d)),l&&e[l]&&e[l](d)};return window.addEventListener("message",i),()=>window.removeEventListener("message",i)},[e,n]),{sendMessage:r}}import{useNodesInitialized as ph}from"@xyflow/react";import{useEffect as fc}from"react";var mc=()=>{let e=ph(),{initialDiagram:t,setIsInitialized:o}=R(),{importFromMxGraph:n}=Pt();fc(()=>{t&&n(t)},[t,n,o]),fc(()=>{if(!e)return;(async()=>{await No(),o(!0)})()},[e,o])};import{useCallback as gc}from"react";import{useReactFlow as fh}from"@xyflow/react";function hc(){let{setTaskStatuses:e,clearTaskStatuses:t,calculateFlowPath:o}=Xe(),{getEdges:n}=fh(),r=Co(),i=gc(a=>{if(!(a!=null&&a.activities))return;e(a.activities);let l=a.activities.map(d=>d.diagramId),c=n();o(c,l),setTimeout(()=>{r()},0)},[e,o,n,r]),s=gc(()=>{t(),setTimeout(()=>{r()},0)},[t,r]);return{handleTasksStatus:i,handleClearTaskStatus:s}}import{useReactFlow as mh}from"@xyflow/react";import{useCallback as Dt,useState as yc,useEffect as gh}from"react";import{useDebouncedCallback as hh}from"use-debounce";var xc=[{nodes:[],edges:[]}],yh=500,Ec=100,bc=(e=xc)=>{let{getNodes:t,getEdges:o,setNodes:n,setEdges:r}=mh(),[i,s]=yc(e),[a,l]=yc(0),c=i[a],d=a>0,p=a<i.length-1,u=Dt(T=>{n(i[T].nodes),r(i[T].edges)},[i,n,r]),f=Dt(()=>{if(a>0){let T=a-1;l(T),u(T)}},[a,u]),y=Dt(()=>{if(a<i.length-1){let T=a+1;l(T),u(T)}},[i,a,u]),g=T=>{let w=[...i.slice(0,a+1),T],x=w.length>Ec?w.slice(w.length-Ec):w;s(x),l(x.length-1)},m=hh(()=>{let T=t(),N=o(),w=T.map(k=>v(b({},k),{selected:!1,className:""})),x={nodes:ke(w),edges:N};JSON.stringify(c)!==JSON.stringify(x)&&g(x)},yh),_=Dt(T=>{if(T==="forceSave"){m();return}T.some(x=>x.type==="select")||T.some(x=>x.type==="position"&&x.dragging)||m()},[m]),h=Dt(T=>{s(T||xc),l(0)},[]),E=Dt(()=>{s([]),l(0)},[]);return gh(()=>{let T=N=>{(N.ctrlKey||N.metaKey)&&(N.shiftKey&&N.key.toLowerCase()==="z"?(N.preventDefault(),y()):N.key.toLowerCase()==="z"&&(N.preventDefault(),f()))};return document.addEventListener("keydown",T),()=>{document.removeEventListener("keydown",T)}},[f,y]),{history:i,undo:f,redo:y,canUndo:d,canRedo:p,saveHistory:_,resetHistory:h,clearHistory:E}};var Ah=500,_c=()=>{let e=Nh(!1),[t,o,n]=Eh([]),[r,i,s]=xh([]),[a,l]=vh(null),{getNodes:c,getEdges:d}=_h(),{instanceId:p,setIsConnecting:u,setIsMultipleSelection:f}=R(),{updateHelperLines:y,HelperLines:g}=yt(),{undo:m,redo:_,canUndo:h,canRedo:E,saveHistory:T}=bc(),{onNodeDrag:N,onDrop:w,onDragOver:x,onNodeDragStop:C,onNodeDragStart:k}=ic({nodes:t,setNodes:o,setEdges:i}),{isValidConnection:D,onConnect:A}=Ul({setEdges:i}),{validationResult:S,handleValidationComplete:O,clearValidation:I,isAutoValidationEnabled:M,validateDiagram:P}=tc(),{importFromLia:V}=uc(),{handleTasksStatus:H,handleClearTaskStatus:W}=hc(),{clearPathEdges:B}=Xe(),z=Co(),{emitElementChanges:X,handleNodeChanges:U,handleEdgeChanges:K}=Lt();rc(),sc(),mc();let pe=kt(()=>{o([]),i([]),B(),setTimeout(()=>{z()},0)},[o,i,B,z]);pc({LIA_CREATE_DIAGRAM:V,CLEAR_DIAGRAM:pe,TASKS_STATUS:H,CLEAR_TASKS_STATUS:W});let{selectElements:ye,clearSelection:xe}=Fe(),{importFromMxGraph:Ot,exportToMxGraph:lt}=Pt(),{configureElement:qr,getConfigureElement:Zr}=hn();Th(()=>(Rt.set(p,{importFromMxGraph:Ot,exportToMxGraph:lt,selectElements:ye,clearSelection:xe,configureElement:qr,getConfigureElement:Zr}),()=>{Rt.delete(p)}),[p,Ot,lt,ye,xe,qr,Zr]);let rd=kt(()=>{if(!M){e.current=!1;return}let ce=P({nodes:c(),edges:d()});O(ce),e.current=!1},[M,c,d,P,O]),Jr=wh(rd,Ah),xo=kt(()=>{M&&!e.current&&(e.current=!0,Jr())},[M,Jr]),id=kt(ce=>{let Ht=y(ce,t);n(Ht),T(ce),xo(),U(ce)},[t,n,T,xo,y,U]),sd=kt(ce=>{s(ce),T(ce),xo(),K(ce)},[s,T,xo,K]);bh({onChange:({nodes:ce,edges:Ht})=>{f(ce.length+Ht.length>1)}});let ad=kt(async({nodes:ce,edges:Ht})=>(l({nodes:ce,edges:Ht}),!1),[l]);return{nodes:t,setNodes:o,edges:r,setEdges:i,events:{isValidConnection:D,onConnect:A,onDrop:w,onDragOver:x,onNodeDrag:N,onNodeDragStop:C,onNodeDragStart:k,onDropCapture:()=>{T("forceSave"),X()},onConnectStart:()=>{u(!0)},onConnectEnd:()=>{u(!1)},onBeforeDelete:ad,onNodesChange:id,onEdgesChange:sd},ui:{pendingDelete:a,setPendingDelete:l,validationResult:S,handleCloseValidationPanel:I},controls:{undo:m,redo:_,canUndo:h,canRedo:E},components:{HelperLines:g},actions:{saveHistory:T,selectElements:ye,clearSelection:xe,exportToMxGraph:lt,validateDiagram:P,handleValidationComplete:O}}};import{jsx as Tc}from"react/jsx-runtime";var Pr=({id:e,className:t})=>Tc("marker",{id:e,className:L("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:Tc("path",{d:"M 0 0 L 10 5 L 0 10 Z"})});import{jsx as Lr,jsxs as Ih}from"react/jsx-runtime";var Nc=()=>Lr("svg",{style:{position:"absolute",top:0,left:0},children:Ih("defs",{children:[Lr(Pr,{id:"sequence-edge-marker",className:"text-grey-400"}),Lr(Pr,{id:"sequence-edge-marker-highlighted",className:"text-blue-500"})]})});import{useKeyPress as Bc}from"@xyflow/react";import{Button as Vr,Tooltip as Or,TooltipContent as Hr,TooltipTrigger as Gr,useTranslation as y0}from"lecom-ui";import{HandIcon as x0,MapIcon as E0,MousePointerIcon as b0}from"lucide-react";import{useCallback as zc,useEffect as Fc}from"react";import{Tooltip as Kh,TooltipContent as qh,TooltipTrigger as Zh,useNotificationToast as Jh,useTranslation as Qh}from"lecom-ui";var ho=(h=>(h.START_EVENT="START_EVENT",h.END_EVENT="END_EVENT",h.TASK="TASK",h.SUBPROCESS="SUBPROCESS",h.GATEWAY="GATEWAY",h.LANE="LANE",h.ANNOTATION="ANNOTATION",h.CONNECTION="CONNECTION",h.INTERMEDIATE_EVENT="INTERMEDIATE_EVENT",h.ACTIVITY="ACTIVITY",h.PROCESS_INTERFACE="PROCESS_INTERFACE",h.WORKFLOW_INTERFACE="WORKFLOW_INTERFACE",h.VARIANT_ACTIVITY="VARIANT_ACTIVITY",h.AUTO_ACTIVITY="AUTO_ACTIVITY",h.DATA_STORE="DATA_STORE",h.DATA_OBJECT="DATA_OBJECT",h.DATA_OUTPUT="DATA_OUTPUT",h.DATA_INPUT="DATA_INPUT",h))(ho||{});import{useReactFlow as Gh}from"@xyflow/react";import{useNotificationToast as Bh,useTranslation as zh,Button as Fh}from"lecom-ui";var vc=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 wc({columns:e=[],rows:t=[],fileName:o="report"}){if(!e.length||!t.length)return;let r="data:text/csv;charset=utf-8,"+[e,...t].map(s=>s.join(",")).join(`
37
+ `),i=encodeURI(r);On(i,`${o}.csv`)}var On=(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 Ac(e){return e==null?void 0:e.replaceAll("&#xA;"," ")}var N6={START_EVENT:"START_EVENT",END_EVENT:"END_EVENT",TASK:"TASK",GATEWAY:"GATEWAY",ANNOTATION:"ANNOTATION"},Ic={script:"SCRIPT",subprocess:"SUBPROCESS"},Cc={complex:"COMPLEX",none:"EXCLUSIVE",exclusive:"EXCLUSIVE",parallel:"PARALLEL"};var it=({cell:e,type:t,variant:o=""})=>{let{_attributes:n,mxGeometry:r}=e,{value:i,parent:s}=n,a=Number(r._attributes.width),l=Number(r._attributes.height),c=s==="1"?void 0:s;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:a,height:l,measured:{width:a,height:l}}},Sh=e=>{let{subType:t,style:o}=e._attributes,n="imported";return["none"].includes(t)||(n="adapted"),e.mxGeometry._attributes.width=F.START_EVENT.MIN_WIDTH,e.mxGeometry._attributes.height=F.START_EVENT.MIN_HEIGHT,{node:it({cell:e,type:"START_EVENT"}),status:n,originalType:o}},Mh=e=>{let{subType:t,style:o}=e==null?void 0:e._attributes,n="imported";return["none"].includes(t)||(n="adapted"),e.mxGeometry._attributes.width=F.END_EVENT.MIN_WIDTH,e.mxGeometry._attributes.height=F.END_EVENT.MIN_HEIGHT,{node:it({cell:e,type:"END_EVENT"}),status:n,originalType:o}},Ph=e=>{let{subType:t,style:o}=e==null?void 0:e._attributes,n=Ic[t],r="imported";return["script","none"].includes(t)||(r="adapted"),e.mxGeometry._attributes.width=Ve(e.mxGeometry._attributes.width||0,F.TASK.MIN_WIDTH),e.mxGeometry._attributes.height=Ve(e.mxGeometry._attributes.height||0,F.TASK.MIN_HEIGHT),{node:it({cell:e,type:"TASK",variant:n}),status:r,originalType:o}},Lh=e=>{let{style:t,subType:o}=e==null?void 0:e._attributes,n=Cc[o],r=["none","inclusive","event-based"],i="imported";return r.includes(o)&&(i="adapted"),e.mxGeometry._attributes.width=F.GATEWAY.MIN_WIDTH,e.mxGeometry._attributes.height=F.GATEWAY.MIN_HEIGHT,{node:it({cell:e,type:"GATEWAY",variant:n}),status:i,originalType:t}},Dh=e=>{let{style:t}=e==null?void 0:e._attributes;return{node:it({cell:e,type:"LANE"}),status:"imported",originalType:t}},kh=e=>{let{style:t}=e==null?void 0:e._attributes;return e.mxGeometry._attributes.width=Ve(e.mxGeometry._attributes.width||0,F.ANNOTATION.MIN_WIDTH),e.mxGeometry._attributes.height=Ve(e.mxGeometry._attributes.height||0,F.ANNOTATION.MIN_HEIGHT),{node:it({cell:e,type:"ANNOTATION"}),status:"imported",originalType:t}},Sc=e=>{let{style:t}=e==null?void 0:e._attributes;return e.mxGeometry._attributes.width=F.UNSUPPORTED.MIN_WIDTH,e.mxGeometry._attributes.height=F.UNSUPPORTED.MIN_HEIGHT,{node:it({cell:e,type:"UNSUPPORTED"}),status:"unsupported",originalType:t}},Mc=(e,t)=>{let{id:o,source:n,target:r,value:i}=e._attributes;return v(b({},Te),{id:o,source:t.get(n)||n,target:t.get(r)||r,data:{label:i||""}})},Pc={TASK:Ph,GATEWAY:Lh,START_EVENT:Sh,END_EVENT:Mh,LANE:Dh,ANNOTATION:kh};var Rh=e=>{let t=new Map,o=Object.values(ho),n=e.filter(s=>{var l;let a=(l=s._attributes)==null?void 0:l.type;return o.includes(a)}),r=[],i=[];for(let s of n){let{type:a}=s._attributes,l=Pc[a]||Sc,{node:c,status:d,originalType:p}=l(s);i.push(c),r.push({originalType:p,type:c.type,variant:c.data.variant,value:Ac(c.data.label),status:d})}return{nodes:i,governanceIdToNodeIdMap:t,summary:r}},Vh=(e,t)=>e.filter(r=>{var i;return(i=r._attributes)==null?void 0:i.edge}).map(r=>Mc(r,t)),Oh=e=>{let{mxGraphModel:t}=e,{nodes:o,governanceIdToNodeIdMap:n,summary:r}=Rh(t.root.mxCell),i=Vh(t.root.mxCell,n);return{nodes:o,edges:i,summary:r}},Hh=async e=>{let t=await vc(e),o=In(t);if(!o)throw new Error("EMPTY_FILE");let{metadata:n,mxGraphModel:r}=o.modeler||{},i=(n==null?void 0:n.app)&&(n==null?void 0:n.diagramType)&&(n==null?void 0:n.version),s=r==null?void 0:r.root;if(!i||!s)throw new Error("INVALID_FILE");if(!Object.keys(r.root.mxCell||{}).length)throw new Error("CONTAIN_NO_CELLS");return{metadata:n,mxGraphModel:r}},Lc=async e=>{try{let t=await Hh(e),{nodes:o,edges:n,summary:r}=Oh(t)||{};return{nodes:o,edges:n,summary:r}}catch(t){throw t}};import{jsx as Wh}from"react/jsx-runtime";var Dc=()=>{let{t:e}=zh(),{toast:t}=Bh(),{setNodes:o,setEdges:n,fitView:r}=Gh(),i=a=>{let l=[e("adapter.governance.report.columns.type"),e("adapter.governance.report.columns.value"),e("adapter.governance.report.columns.status")],c=a.map(d=>[d.originalType,d.value,e(`adapter.governance.report.status.${d.status.toLowerCase()}`)]);t({variant:"warning",content:e("adapter.governance.success.incompatible_cells"),duration:1e3*60*1,action:Wh(Fh,{size:"small",variant:"ghost",onClick:()=>wc({columns:l,rows:c,fileName:"governance-imported-cells"}),children:e("adapter.governance.action.download")})})};return{importFromGovernance:async a=>{try{let{nodes:l,edges:c,summary:d}=await Lc(a);if(o(u=>u.concat(l)),n(u=>u.concat(c)),r({padding:Mt}),d.some(u=>u.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 Yh}from"lecom-ui";import{useRef as Uh}from"react";import{Fragment as $h,jsx as kc,jsxs as Xh}from"react/jsx-runtime";var Rc=a=>{var l=a,{children:e,accept:t="*",multiple:o=!1,disabled:n=!1,onClick:r,onFilesSelected:i}=l,s=we(l,["children","accept","multiple","disabled","onClick","onFilesSelected"]);let c=Uh(null),d=u=>{let f=u.target.files;f!=null&&f.length&&i(f),c.current&&(c.current.value="")};return Xh($h,{children:[kc(Yh,v(b({onClick:u=>{var f;(f=c.current)==null||f.click(),r==null||r(u)}},s),{children:e})),kc("input",{type:"file",ref:c,className:"sr-only",accept:t,multiple:o,disabled:n,onChange:d})]})};import{jsx as Hn,jsxs as jh}from"react/jsx-runtime";var Vc=({disabled:e=!1})=>{let{t}=Qh(),{toast:o}=Jh(),{importFromGovernance:n}=Dc(),r=()=>{if(e){o({variant:"error",content:t("adapter.governance.error.ALREADY_INITIALIZED")});return}},i=s=>{let a=s[0];if(!a){o({variant:"error",content:t("adapter.governance.error.NO_FILE")});return}n(a)};return jh(Kh,{children:[Hn(Zh,{asChild:!0,children:Hn(Rc,{className:"[&>svg]:size-7 p-0",variant:"ghost",size:"small",color:"grey",iconButton:!0,accept:".mdr",disabled:e,onClick:r,onFilesSelected:i,children:Hn(li,{})})}),Hn(qh,{color:"black",children:t("editor.controls.actions.import_governance")})]})};import{jsx as e0}from"react/jsx-runtime";var Dr=({shortcut:e})=>e0("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 a0,DropdownMenu as l0,DropdownMenuContent as c0,DropdownMenuItem as Rr,DropdownMenuTrigger as d0,Tooltip as Gn,TooltipContent as Bn,TooltipTrigger as zn,useTranslation as u0}from"lecom-ui";import{FileCodeIcon as p0,FileImageIcon as f0,FolderOutputIcon as m0,PrinterIcon as g0}from"lucide-react";import{useState as h0}from"react";import{useReactFlow as t0}from"@xyflow/react";import{toPng as Oc,toSvg as o0}from"html-to-image";import{toast as n0,useTranslation as r0}from"lecom-ui";import{useState as i0}from"react";var s0=3,kr="diagram",Hc=()=>{let{t:e}=r0(),{getNodes:t}=t0(),{clearSelection:o}=Fe(),[n,r]=i0({png:!1,html:!1,print:!1}),i=()=>{let{x:d,y:p,width:u,height:f}=Ka(t());return{width:u,height:f,style:{width:`${u}px`,height:`${f}px`,transform:`translate(${-d}px, ${-p}px)`}}},s=async(d,p)=>{r(v(b({},n),{[p]:!0})),await o();try{let u=Xa();if(!u)throw new Error("Flow element not found");let f=i();return await d(u,f)}catch(u){n0({content:e("editor.controls.actions.export.feedback.error"),variant:"error"})}finally{r(v(b({},n),{[p]:!1}))}};return{exportAsPng:async(d=kr)=>{await s(async(p,u)=>{let f=await Oc(p,v(b({},u),{backgroundColor:"#fcfcfc"}));On(f,`${d}.png`)},"png")},exportAsHtml:async(d=kr)=>{await s(async(p,u)=>{let f=await o0(p,v(b({},u),{backgroundColor:"#fcfcfc"})),y=`
38
38
  <!DOCTYPE html>
39
39
  <html>
40
40
  <head>
@@ -48,7 +48,7 @@ var ld=Object.defineProperty,cd=Object.defineProperties;var dd=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);Hn(m,`${d}.html`),setTimeout(()=>URL.revokeObjectURL(m),100)},"html")},printDiagram:async(d=kr)=>{await s(async(p,u)=>{let f=await Oc(p,v(b({},u),{pixelRatio:l0})),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);On(m,`${d}.html`),setTimeout(()=>URL.revokeObjectURL(m),100)},"html")},printDiagram:async(d=kr)=>{await s(async(p,u)=>{let f=await Oc(p,v(b({},u),{pixelRatio:s0})),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 ld=Object.defineProperty,cd=Object.defineProperties;var dd=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 Q,jsxs as Vt}from"react/jsx-runtime";function Gc(){let{t:e}=f0(),{exportAsPng:t,exportAsHtml:o,printDiagram:n,isPrinting:r,isPrintingPng:i,isPrintingHtml:s}=Hc(),[a,l]=x0(!1);return Vt(d0,{modal:!1,open:a,onOpenChange:l,children:[Q(p0,{asChild:!0,children:Q("div",{children:Vt(Bn,{children:[Q(Fn,{asChild:!0,children:Q(c0,{size:"small",variant:"ghost",color:"grey",iconButton:!0,children:Q(h0,{})})}),!a&&Q(zn,{color:"black",children:e("editor.controls.actions.export.title")})]})})}),Vt(u0,{align:"center",side:"top",sideOffset:16,className:"min-w-0 flex flex-col gap-2 p-2 shadow-sm",children:[Vt(Bn,{children:[Q(Fn,{asChild:!0,children:Q(Rr,{className:"p-1.5",disabled:i,onClick:()=>t(),children:Q(g0,{})})}),Q(zn,{side:"right",color:"black",children:e("editor.controls.actions.export.png")})]}),Vt(Bn,{children:[Q(Fn,{asChild:!0,children:Q(Rr,{className:"p-1.5",disabled:s,onClick:()=>o(),children:Q(m0,{})})}),Q(zn,{side:"right",color:"black",children:e("editor.controls.actions.export.html")})]}),Vt(Bn,{children:[Q(Fn,{asChild:!0,children:Q(Rr,{className:"p-1.5",disabled:r,onClick:()=>n(),children:Q(y0,{})})}),Q(zn,{side:"right",color:"black",children:e("editor.controls.actions.export.print")})]})]})]})}import{Fragment as N0,jsx as le,jsxs as st}from"react/jsx-runtime";var Wc=({nodes:e})=>{let{t}=E0(),{clearSelection:o}=Fe(),{mode:n,isMinimapOpen:r,setIsMinimapOpen:i,isMoveTool:s,isHandTool:a,setIsMoveTool:l,setIsHandTool:c}=V(),d=Bc(["v","V"]),p=Bc(["h","H"]),u=zc(()=>{o(),c(!0),l(!1)},[o,c,l]),f=zc(()=>{l(!0),c(!1)},[l,c]);return Fc(()=>{d&&!s&&n==="edit"&&f()},[d,f,s,n]),Fc(()=>{p&&!a&&n==="edit"&&u()},[p,u,a,n]),st("div",{className:"flex items-center gap-2 px-3 py-2 bg-white rounded-sm shadow-md",children:[n==="edit"&&st(N0,{children:[st(Or,{children:[le(Gr,{asChild:!0,children:le(Vr,{size:"small",variant:"ghost",color:"grey",className:D(s&&"bg-grey-400"),iconButton:!0,onClick:f,children:le(T0,{})})}),st(Hr,{color:"black",className:"flex items-center gap-2",children:[t("editor.controls.actions.move_tool"),le(Dr,{shortcut:"V"})]})]}),st(Or,{children:[le(Gr,{asChild:!0,children:le(Vr,{size:"small",variant:"ghost",color:"grey",className:D(a&&"bg-grey-400"),iconButton:!0,onClick:u,children:le(b0,{})})}),st(Hr,{color:"black",className:"flex items-center gap-2",children:[t("editor.controls.actions.hand_tool")," ",le(Dr,{shortcut:"H"})]})]})]}),le(Gc,{}),n==="edit"&&le(Vc,{disabled:e.length>0}),st(Or,{children:[le(Gr,{asChild:!0,children:le(Vr,{size:"small",variant:"ghost",color:"grey",className:D(r&&"bg-grey-400"),iconButton:!0,onClick:()=>i(!r),children:le(_0,{})})}),le(Hr,{color:"black",children:t(r?"editor.controls.actions.minimap.close":"editor.controls.actions.minimap.open")})]})]})};import{Button as Yc,Tooltip as Uc,TooltipContent as $c,TooltipTrigger as Xc,useTranslation as v0}from"lecom-ui";import{RedoIcon as w0,UndoIcon as A0}from"lucide-react";import{jsx as $e,jsxs as Br}from"react/jsx-runtime";var Kc=({undo:e,redo:t,canUndo:o,canRedo:n})=>{let{t:r}=v0();return Br("div",{className:"flex items-center gap-2 px-3 py-2 bg-white rounded-sm shadow-md",children:[Br(Uc,{children:[$e(Xc,{asChild:!0,children:$e(Yc,{size:"small",variant:"ghost",color:"grey",iconButton:!0,disabled:!o,onClick:e,children:$e(A0,{})})}),$e($c,{color:"black",children:r("editor.controls.history.undo")})]}),Br(Uc,{children:[$e(Xc,{asChild:!0,children:$e(Yc,{size:"small",variant:"ghost",color:"grey",iconButton:!0,disabled:!n,onClick:t,children:$e(w0,{})})}),$e($c,{color:"black",children:r("editor.controls.history.redo")})]})]})};import{useReactFlow as I0}from"@xyflow/react";import{Button as Wn,Tooltip as Yn,TooltipContent as Un,TooltipTrigger as $n,useTranslation as C0}from"lecom-ui";import{ScanIcon as S0,ZoomIn as M0,ZoomOut as P0}from"lucide-react";import{jsx as oe,jsxs as yo}from"react/jsx-runtime";var qc=()=>{let{t:e}=C0(),{zoomIn:t,zoomOut:o,zoomTo:n,fitView:r}=I0();return yo("div",{className:"flex items-center gap-2 px-3 py-2 bg-white rounded-sm shadow-md",children:[yo(Yn,{children:[oe($n,{asChild:!0,children:oe(Wn,{size:"small",variant:"ghost",color:"grey",iconButton:!0,onClick:()=>r(),children:oe(S0,{})})}),oe(Un,{color:"black",children:e("editor.controls.zoom.fit")})]}),yo(Yn,{children:[oe($n,{asChild:!0,children:oe(Wn,{size:"small",variant:"ghost",color:"grey",iconButton:!0,onClick:()=>o(),children:oe(P0,{})})}),oe(Un,{color:"black",children:e("editor.controls.zoom.out")})]}),yo(Yn,{children:[oe($n,{asChild:!0,children:oe(Wn,{size:"small",variant:"ghost",color:"grey",iconButton:!0,onClick:()=>n(1),children:oe(ui,{})})}),oe(Un,{color:"black",children:e("editor.controls.zoom.reset")})]}),yo(Yn,{children:[oe($n,{asChild:!0,children:oe(Wn,{size:"small",variant:"ghost",color:"grey",iconButton:!0,onClick:()=>t(),children:oe(M0,{})})}),oe(Un,{color:"black",children:e("editor.controls.zoom.in")})]})]})};import{Button as Zc,Dialog as L0,DialogContent as D0,DialogFooter as k0,DialogHeader as R0,DialogTitle as V0,Notification as O0,Typography as zr,useTranslation as H0}from"lecom-ui";import{jsx as Ae,jsxs as Fr}from"react/jsx-runtime";var Jc=({pendingDelete:e,setPendingDelete:t,nodes:o,setNodes:n,setEdges:r,saveHistory:i})=>{let{t:s}=H0(),{forceRebuildIndex:a}=yt(),{emitElementChanges:l}=Lt(),c=!!e,d=()=>{let{nodes:y}=e||{};if(y!=null&&y.length){let g=o.filter(m=>!y.some(_=>_.id===m.id));y.forEach(m=>{(m==null?void 0:m.type)==="LANE"&&(m!=null&&m.parentId)&&(g=et(m.parentId,g))}),n(De(g))}},p=()=>{let{edges:y}=e||{};y!=null&&y.length&&r(g=>g.filter(m=>!y.some(_=>_.id===m.id)))},u=()=>{d(),p(),i("forceSave"),a(),l(),t(null)},f=()=>{t(null)};return Ae(L0,{open:c,onOpenChange:f,children:Fr(D0,{className:"w-[488px] max-w-fit gap-2",children:[Ae(R0,{children:Ae(V0,{children:Ae(zr,{variant:"heading-small-600",textColor:"text-grey-950",children:s("editor.modals.delete_elements.title")})})}),Fr("div",{className:"flex flex-col gap-2",children:[Ae("div",{className:"py-2",children:Ae(O0,{type:"callout",variant:"warning",content:s("editor.modals.delete_elements.callout")})}),Ae(zr,{variant:"body-large-400",textColor:"text-grey-800",className:"py-2",children:s("editor.modals.delete_elements.content")})]}),Fr(k0,{className:"flex items-center flex-row justify-end w-full gap-2",children:[Ae(Zc,{variant:"outlined",color:"grey",disabled:!1,size:"small",onClick:f,children:Ae(zr,{variant:"body-medium-500",textColor:"text-grey-800",children:s("editor.modals.delete_elements.cancel")})}),Ae(Zc,{size:"small",variant:"filled",color:"destructive",autoFocus:!0,onClick:u,children:s("editor.modals.delete_elements.confirm")})]})]})})};import{useReactFlow as G0}from"@xyflow/react";import{Button as B0,Tooltip as z0,TooltipContent as F0,TooltipTrigger as W0,useTranslation as Y0}from"lecom-ui";import{useRef as U0,useState as $0}from"react";import{jsx as at,jsxs as Qc}from"react/jsx-runtime";var jc=()=>{let e=U0(null),{t}=Y0(),{setDraggableNode:o}=wt(),{getNodes:n}=G0(),{setIsDragging:r}=V(),[i,s]=$0(void 0),a=n(),l=bn(a),c=[{type:"START_EVENT",icon:vo,label:t("bpmn.start_event.variant.default")},{type:"END_EVENT",icon:ct,label:t("bpmn.end_event.variant.default")},{type:"TASK",icon:Bt,label:t("bpmn.task.variant.default")},{type:"TASK",variant:"SUBPROCESS",icon:hi,label:t("bpmn.task.variant.subprocess")},{type:"TASK",variant:"SCRIPT",icon:gi,label:t("bpmn.task.variant.script")},{type:"TASK",attribute:"LOOP",icon:mi,label:t("bpmn.task.attribute.loop")},{type:"GATEWAY",variant:"EXCLUSIVE",icon:ut,label:t("bpmn.gateway.variant.exclusive")},{type:"GATEWAY",variant:"PARALLEL",icon:pt,label:t("bpmn.gateway.variant.parallel")},{type:"GATEWAY",variant:"COMPLEX",icon:dt,label:t("bpmn.gateway.variant.complex")},{type:"LANE",icon:di,label:t("bpmn.lane.variant.default")},{type:"ANNOTATION",icon:To,label:t("bpmn.annotation.variant.default")}],d=(p,u)=>{o({type:u.type,variant:u.variant,attribute:u.attribute,icon:u.icon}),s(at(u.icon,{})),p.dataTransfer.effectAllowed="move",e.current&&p.dataTransfer.setDragImage(e.current,10,10),setTimeout(()=>{r(!0)},100)};return Qc("aside",{className:"sidebar absolute z-[1] top-4 left-4",children:[at("div",{className:"grid grid-cols-1 gap-2 p-2 bg-white rounded-md shadow-md",children:c.map((p,u)=>{let f=l&&p.type==="START_EVENT",y=f?t("editor.toolbar.start_event_already_exists"):p.label;return Qc(z0,{children:[at(W0,{asChild:!0,children:at(B0,{className:D("[&>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,p),children:at(p.icon,{})},u)}),at(F0,{color:"black",side:"right",children:y})]},u)})}),at("div",{ref:e,className:"absolute w-0 h-0 top-0 left-0 z-[-1] bg-transparent",children:i})]})};import{Button as X0,useTranslation as K0}from"lecom-ui";import{AlertCircleIcon as q0,CircleCheckIcon as Z0,XIcon as J0}from"lucide-react";import{useEffect as Q0,useState as j0}from"react";import{jsx as Ee,jsxs as Wr}from"react/jsx-runtime";var ed=({validationResult:e,onClose:t})=>{let{t:o}=K0(),[n,r]=j0(!1);if(Q0(()=>{e&&r(!0)},[e]),!n||!e)return null;let{isValid:i,errors:s}=e;return Wr("div",{className:D("w-72 max-w-[95vw] rounded-lg border px-4 py-2",{"bg-green-100":i,"bg-red-100":!i}),children:[Wr("div",{className:"flex flex-row items-start gap-4",children:[Ee("div",{className:"flex-shrink-0",children:i?Ee(Z0,{className:"text-green-500 size-5"}):Ee(q0,{className:"text-red-500 size-5"})}),Wr("div",{className:"body-medium-500 text-grey-800",children:[Ee("div",{children:o(i?"validation.success.title":"validation.errors.title")}),!i&&Ee("div",{children:o("validation.errors.subtitle")})]}),Ee(X0,{variant:"ghost",size:"small",color:"grey",className:"size-5 hover:bg-transparent",iconButton:!0,onClick:()=>{r(!1),t()},children:Ee(J0,{})})]}),Ee("div",{className:"max-h-80 overflow-y-auto mt-2 px-9 body-medium-400 text-grey-800",children:i?Ee("p",{children:o("validation.success.message")}):Ee("div",{className:"list-disc list-inside",children:s.map(a=>Ee("li",{className:"mb-1",children:a.message},a.id))})})]})};import{jsx as be,jsxs as Yr}from"react/jsx-runtime";var Ur=ry((e,t)=>{let{instanceId:o,mode:n,isMinimapOpen:r,isMoveTool:i,isHandTool:s}=V(),{nodes:a,setNodes:l,edges:c,setEdges:d,ui:p,actions:u,events:f,components:y,controls:g}=_c();iy(t,()=>({selectElements:u.selectElements,clearSelection:u.clearSelection}));let m={nodes:a,edges:c};return Yr("div",{className:"w-full h-full",children:[n==="edit"&&be(jc,{}),be(Nc,{}),Yr(oy,v(b({},f),{id:`modeler-${o}`,edges:c,nodes:a,nodeTypes:Ml,edgeTypes:Pl,minZoom:Ol,maxZoom:Hl,panOnDrag:s||n!=="edit"?!0:Bl,panOnScroll:!0,selectionOnDrag:!0,elevateEdgesOnSelect:!0,elevateNodesOnSelect:!0,elementsSelectable:n!=="readonly"&&i,nodesConnectable:n==="edit"&&i,nodesDraggable:n==="edit"&&i,connectionLineComponent:Al,selectionMode:ny.Partial,multiSelectionKeyCode:"Shift",deleteKeyCode:"Delete",selectionKeyCode:null,snapToGrid:!0,snapGrid:[5,5],defaultViewport:Gl,connectOnClick:!1,proOptions:{hideAttribution:!0},children:[be(ey,{gap:Rl,size:kl,color:Dl,bgColor:Ll}),r&&be(ty,{pannable:!0,zoomable:!0,position:Vl,className:"shadow-md rounded-md"}),Yr("div",{className:"absolute z-10 bottom-4 left-1/2 -translate-x-1/2 flex gap-4",children:[n==="edit"&&be(Kc,b({},g)),be(Wc,{nodes:a,diagram:m,onValidateDiagram:u.validateDiagram,onValidationComplete:u.handleValidationComplete}),be(qc,{})]}),be(y.HelperLines,{}),p.validationResult&&be("div",{className:"absolute top-6 right-6 z-[1000]",children:be(ed,{validationResult:p.validationResult,onClose:p.handleCloseValidationPanel})})]})),be(Jc,{pendingDelete:p.pendingDelete,setPendingDelete:p.setPendingDelete,nodes:a,setNodes:l,setEdges:d,saveHistory:u.saveHistory})]})});Ur.displayName="Editor";import{useStore as sy}from"@xyflow/react";import{useEffect as ay,useRef as ly}from"react";import{jsx as dy}from"react/jsx-runtime";var cy=e=>({width:e.width,height:e.height,transform:e.transform}),$r="rgba(51, 103, 217, 0.4)",ua=({horizontal:e,vertical:t})=>{let{width:o,height:n,transform:r}=sy(cy),i=ly(null);return ay(()=>{let s=i.current,a=s==null?void 0:s.getContext("2d");if(!a||!s)return;let l=window.devicePixelRatio;s.width=o*l,s.height=n*l,a.clearRect(0,0,o,n),a.scale(l,l),a.strokeStyle=$r,t&&(a.beginPath(),a.strokeStyle=t.color||$r,a.moveTo(t.position*r[2]+r[0],0),a.lineTo(t.position*r[2]+r[0],n),a.stroke()),e&&(a.beginPath(),a.strokeStyle=e.color||$r,a.moveTo(0,e.position*r[2]+r[1]),a.lineTo(o,e.position*r[2]+r[1]),a.stroke())},[o,n,r,e,t]),dy("canvas",{ref:i,className:"w-full h-full absolute z-10 pointer-events-none"})};import{i18n as uy,Notification as py,TooltipProvider as fy}from"lecom-ui";import{createContext as my,useContext as gy,useEffect as hy,useState as yy}from"react";import{jsx as td,jsxs as Ey}from"react/jsx-runtime";var Rt=new Map,od=my(null),Xr=()=>{let e=gy(od);if(!e)throw new Error("useModeler must be used within an <ModelerProvider />");return e},xy=({locale:e,defaultMode:t="view",showNotification:o=!0,children:n})=>{let[r,i]=yy(e||"pt_BR");hy(()=>{e&&(i(e),uy.changeLanguage(e))},[e]);let s=f=>{let y=Rt.size;if(y===0)throw new Error("No modeler instances found");if(y===1||!f){let[m]=Rt.values();return m}let g=Rt.get(f);if(!g)throw new Error(`Modeler instance with ID "${f}" not found`);return g},a=(f,y)=>{let g=s(y);return g==null?void 0:g.selectElements(f)},l=async f=>{let y=s(f);return y==null?void 0:y.clearSelection()},c=(f,y)=>{let g=s(y);return g==null?void 0:g.configureElement(f)},d=(f,y)=>{let g=s(y);return g==null?void 0:g.getConfigureElement(f)},p=async(f,y)=>{let g=s(y);await(g==null?void 0:g.importFromMxGraph(f))},u=f=>{let y=s(f);return y==null?void 0:y.exportToMxGraph()};return td(od.Provider,{value:{defaultMode:t,locale:r,selectElements:a,clearSelection:l,configureElement:c,getConfigureElement:d,importDiagram:p,exportDiagram:u},children:Ey(fy,{children:[o&&td(py,{type:"toast",placement:"topRight",enableClose:!0,showProgress:!0,pauseOnHover:!0}),n]})})};import{jsx as Kr}from"react/jsx-runtime";var nd=_y(null),V=()=>{let e=Ty(nd);if(!e)throw new Error("useModelerInstance must be used within an <Modeler />");return e},Ay=({selectorRef:e,initialDiagram:t,instanceId:o,mode:n,onElementChanges:r,onConfigureElement:i,onSubprocessValidationClick:s})=>{let{defaultMode:a}=Xr(),l=vy(),[c]=ke(o||l),[d,p]=ke(n||a||"edit"),[u,f]=ke(!1),[y,g]=ke(!0),[m,_]=ke(!1),[h,E]=ke(!1),[T,N]=ke(!1),[w,x]=ke(!1),[I,R]=ke(!1);Ny(()=>{n&&p(n)},[n]);let k=wy(()=>t||zl(),[t]),A={instanceId:c,initialDiagram:k,mode:d,isInitialized:u,setIsInitialized:f,isMinimapOpen:h,isMoveTool:y,isHandTool:m,isDragging:T,isMultipleSelection:I,isConnecting:w,setIsMinimapOpen:E,setIsMoveTool:g,setIsHandTool:_,setIsDragging:N,setIsConnecting:x,setIsMultipleSelection:R,onElementChanges:r,onConfigureElement:i,onSubprocessValidationClick:s};return Kr(by,{children:Kr(nd.Provider,{value:A,children:Kr(Ur,{ref:e})})})};export{pe as EditorMode,Kn as ElementPosition,bo as ElementType,qn as GatewayElementVariant,he as GatewayVariant,Ay as Modeler,xy as ModelerProvider,Oe as NodeAttribute,O as NodeType,ge as NodeVariant,Zn as RoutingVariant,Xr as useModeler};
67
+ `),g.close()},"print")},isPrintingPng:n.png,isPrintingHtml:n.html,isPrinting:n.print}};import{jsx as Q,jsxs as Vt}from"react/jsx-runtime";function Gc(){let{t:e}=u0(),{exportAsPng:t,exportAsHtml:o,printDiagram:n,isPrinting:r,isPrintingPng:i,isPrintingHtml:s}=Hc(),[a,l]=h0(!1);return Vt(l0,{modal:!1,open:a,onOpenChange:l,children:[Q(d0,{asChild:!0,children:Q("div",{children:Vt(Gn,{children:[Q(zn,{asChild:!0,children:Q(a0,{size:"small",variant:"ghost",color:"grey",iconButton:!0,children:Q(m0,{})})}),!a&&Q(Bn,{color:"black",children:e("editor.controls.actions.export.title")})]})})}),Vt(c0,{align:"center",side:"top",sideOffset:16,className:"min-w-0 flex flex-col gap-2 p-2 shadow-sm",children:[Vt(Gn,{children:[Q(zn,{asChild:!0,children:Q(Rr,{className:"p-1.5",disabled:i,onClick:()=>t(),children:Q(f0,{})})}),Q(Bn,{side:"right",color:"black",children:e("editor.controls.actions.export.png")})]}),Vt(Gn,{children:[Q(zn,{asChild:!0,children:Q(Rr,{className:"p-1.5",disabled:s,onClick:()=>o(),children:Q(p0,{})})}),Q(Bn,{side:"right",color:"black",children:e("editor.controls.actions.export.html")})]}),Vt(Gn,{children:[Q(zn,{asChild:!0,children:Q(Rr,{className:"p-1.5",disabled:r,onClick:()=>n(),children:Q(g0,{})})}),Q(Bn,{side:"right",color:"black",children:e("editor.controls.actions.export.print")})]})]})]})}import{Fragment as _0,jsx as le,jsxs as st}from"react/jsx-runtime";var Wc=({nodes:e})=>{let{t}=y0(),{clearSelection:o}=Fe(),{mode:n,isMinimapOpen:r,setIsMinimapOpen:i,isMoveTool:s,isHandTool:a,setIsMoveTool:l,setIsHandTool:c}=R(),d=Bc(["v","V"]),p=Bc(["h","H"]),u=zc(()=>{o(),c(!0),l(!1)},[o,c,l]),f=zc(()=>{l(!0),c(!1)},[l,c]);return Fc(()=>{d&&!s&&n==="edit"&&f()},[d,f,s,n]),Fc(()=>{p&&!a&&n==="edit"&&u()},[p,u,a,n]),st("div",{className:"flex items-center gap-2 px-3 py-2 bg-white rounded-sm shadow-md",children:[n==="edit"&&st(_0,{children:[st(Or,{children:[le(Gr,{asChild:!0,children:le(Vr,{size:"small",variant:"ghost",color:"grey",className:L(s&&"bg-grey-400"),iconButton:!0,onClick:f,children:le(b0,{})})}),st(Hr,{color:"black",className:"flex items-center gap-2",children:[t("editor.controls.actions.move_tool"),le(Dr,{shortcut:"V"})]})]}),st(Or,{children:[le(Gr,{asChild:!0,children:le(Vr,{size:"small",variant:"ghost",color:"grey",className:L(a&&"bg-grey-400"),iconButton:!0,onClick:u,children:le(x0,{})})}),st(Hr,{color:"black",className:"flex items-center gap-2",children:[t("editor.controls.actions.hand_tool")," ",le(Dr,{shortcut:"H"})]})]})]}),le(Gc,{}),n==="edit"&&le(Vc,{disabled:e.length>0}),st(Or,{children:[le(Gr,{asChild:!0,children:le(Vr,{size:"small",variant:"ghost",color:"grey",className:L(r&&"bg-grey-400"),iconButton:!0,onClick:()=>i(!r),children:le(E0,{})})}),le(Hr,{color:"black",children:t(r?"editor.controls.actions.minimap.close":"editor.controls.actions.minimap.open")})]})]})};import{Button as Yc,Tooltip as Uc,TooltipContent as $c,TooltipTrigger as Xc,useTranslation as T0}from"lecom-ui";import{RedoIcon as N0,UndoIcon as v0}from"lucide-react";import{jsx as $e,jsxs as Br}from"react/jsx-runtime";var Kc=({undo:e,redo:t,canUndo:o,canRedo:n})=>{let{t:r}=T0();return Br("div",{className:"flex items-center gap-2 px-3 py-2 bg-white rounded-sm shadow-md",children:[Br(Uc,{children:[$e(Xc,{asChild:!0,children:$e(Yc,{size:"small",variant:"ghost",color:"grey",iconButton:!0,disabled:!o,onClick:e,children:$e(v0,{})})}),$e($c,{color:"black",children:r("editor.controls.history.undo")})]}),Br(Uc,{children:[$e(Xc,{asChild:!0,children:$e(Yc,{size:"small",variant:"ghost",color:"grey",iconButton:!0,disabled:!n,onClick:t,children:$e(N0,{})})}),$e($c,{color:"black",children:r("editor.controls.history.redo")})]})]})};import{useReactFlow as w0}from"@xyflow/react";import{Button as Fn,Tooltip as Wn,TooltipContent as Yn,TooltipTrigger as Un,useTranslation as A0}from"lecom-ui";import{ScanIcon as I0,ZoomIn as C0,ZoomOut as S0}from"lucide-react";import{jsx as oe,jsxs as yo}from"react/jsx-runtime";var qc=()=>{let{t:e}=A0(),{zoomIn:t,zoomOut:o,zoomTo:n,fitView:r}=w0();return yo("div",{className:"flex items-center gap-2 px-3 py-2 bg-white rounded-sm shadow-md",children:[yo(Wn,{children:[oe(Un,{asChild:!0,children:oe(Fn,{size:"small",variant:"ghost",color:"grey",iconButton:!0,onClick:()=>r(),children:oe(I0,{})})}),oe(Yn,{color:"black",children:e("editor.controls.zoom.fit")})]}),yo(Wn,{children:[oe(Un,{asChild:!0,children:oe(Fn,{size:"small",variant:"ghost",color:"grey",iconButton:!0,onClick:()=>o(),children:oe(S0,{})})}),oe(Yn,{color:"black",children:e("editor.controls.zoom.out")})]}),yo(Wn,{children:[oe(Un,{asChild:!0,children:oe(Fn,{size:"small",variant:"ghost",color:"grey",iconButton:!0,onClick:()=>n(1),children:oe(ui,{})})}),oe(Yn,{color:"black",children:e("editor.controls.zoom.reset")})]}),yo(Wn,{children:[oe(Un,{asChild:!0,children:oe(Fn,{size:"small",variant:"ghost",color:"grey",iconButton:!0,onClick:()=>t(),children:oe(C0,{})})}),oe(Yn,{color:"black",children:e("editor.controls.zoom.in")})]})]})};import{Button as Zc,Dialog as M0,DialogContent as P0,DialogFooter as L0,DialogHeader as D0,DialogTitle as k0,Notification as R0,Typography as zr,useTranslation as V0}from"lecom-ui";import{jsx as Ce,jsxs as Fr}from"react/jsx-runtime";var Jc=({pendingDelete:e,setPendingDelete:t,nodes:o,setNodes:n,setEdges:r,saveHistory:i})=>{let{t:s}=V0(),{forceRebuildIndex:a}=yt(),{emitElementChanges:l}=Lt(),c=!!e,d=()=>{let{nodes:y}=e||{};if(y!=null&&y.length){let g=o.filter(m=>!y.some(_=>_.id===m.id));y.forEach(m=>{(m==null?void 0:m.type)==="LANE"&&(m!=null&&m.parentId)&&(g=et(m.parentId,g))}),n(ke(g))}},p=()=>{let{edges:y}=e||{};y!=null&&y.length&&r(g=>g.filter(m=>!y.some(_=>_.id===m.id)))},u=()=>{d(),p(),i("forceSave"),a(),l(),t(null)},f=()=>{t(null)};return Ce(M0,{open:c,onOpenChange:f,children:Fr(P0,{className:"w-[488px] max-w-fit gap-2",children:[Ce(D0,{children:Ce(k0,{children:Ce(zr,{variant:"heading-small-600",textColor:"text-grey-950",children:s("editor.modals.delete_elements.title")})})}),Fr("div",{className:"flex flex-col gap-2",children:[Ce("div",{className:"py-2",children:Ce(R0,{type:"callout",variant:"warning",content:s("editor.modals.delete_elements.callout")})}),Ce(zr,{variant:"body-large-400",textColor:"text-grey-800",className:"py-2",children:s("editor.modals.delete_elements.content")})]}),Fr(L0,{className:"flex items-center flex-row justify-end w-full gap-2",children:[Ce(Zc,{variant:"outlined",color:"grey",disabled:!1,size:"small",onClick:f,children:Ce(zr,{variant:"body-medium-500",textColor:"text-grey-800",children:s("editor.modals.delete_elements.cancel")})}),Ce(Zc,{size:"small",variant:"filled",color:"destructive",autoFocus:!0,onClick:u,children:s("editor.modals.delete_elements.confirm")})]})]})})};import{useReactFlow as O0}from"@xyflow/react";import{Button as H0,Tooltip as G0,TooltipContent as B0,TooltipTrigger as z0,useTranslation as F0}from"lecom-ui";import{useRef as W0,useState as Y0}from"react";import{jsx as at,jsxs as Qc}from"react/jsx-runtime";var jc=()=>{let e=W0(null),{t}=F0(),{setDraggableNode:o}=wt(),{getNodes:n}=O0(),{setIsDragging:r}=R(),[i,s]=Y0(void 0),a=n(),l=sn(a),c=[{type:"START_EVENT",icon:vo,label:t("bpmn.start_event.variant.default")},{type:"END_EVENT",icon:ct,label:t("bpmn.end_event.variant.default")},{type:"TASK",icon:Bt,label:t("bpmn.task.variant.default")},{type:"TASK",variant:"SUBPROCESS",icon:hi,label:t("bpmn.task.variant.subprocess")},{type:"TASK",variant:"SCRIPT",icon:gi,label:t("bpmn.task.variant.script")},{type:"TASK",attribute:"LOOP",icon:mi,label:t("bpmn.task.attribute.loop")},{type:"GATEWAY",variant:"EXCLUSIVE",icon:ut,label:t("bpmn.gateway.variant.exclusive")},{type:"GATEWAY",variant:"PARALLEL",icon:pt,label:t("bpmn.gateway.variant.parallel")},{type:"GATEWAY",variant:"COMPLEX",icon:dt,label:t("bpmn.gateway.variant.complex")},{type:"LANE",icon:di,label:t("bpmn.lane.variant.default")},{type:"ANNOTATION",icon:To,label:t("bpmn.annotation.variant.default")}],d=(p,u)=>{o({type:u.type,variant:u.variant,attribute:u.attribute,icon:u.icon}),s(at(u.icon,{})),p.dataTransfer.effectAllowed="move",e.current&&p.dataTransfer.setDragImage(e.current,10,10),setTimeout(()=>{r(!0)},100)};return Qc("aside",{className:"sidebar absolute z-[1] top-4 left-4",children:[at("div",{className:"grid grid-cols-1 gap-2 p-2 bg-white rounded-md shadow-md",children:c.map((p,u)=>{let f=l&&p.type==="START_EVENT",y=f?t("editor.toolbar.start_event_already_exists"):p.label;return Qc(G0,{children:[at(z0,{asChild:!0,children:at(H0,{className:L("[&>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,p),children:at(p.icon,{})},u)}),at(B0,{color:"black",side:"right",children:y})]},u)})}),at("div",{ref:e,className:"absolute w-0 h-0 top-0 left-0 z-[-1] bg-transparent",children:i})]})};import{Button as U0,useTranslation as $0}from"lecom-ui";import{AlertCircleIcon as X0,CircleCheckIcon as K0,XIcon as q0}from"lucide-react";import{useEffect as Z0,useState as J0}from"react";import{jsx as Ne,jsxs as Wr}from"react/jsx-runtime";var ed=({validationResult:e,onClose:t})=>{let{t:o}=$0(),[n,r]=J0(!1);if(Z0(()=>{e&&r(!0)},[e]),!n||!e)return null;let{isValid:i,errors:s}=e;return Wr("div",{className:L("w-72 max-w-[95vw] rounded-lg border px-4 py-2",{"bg-green-100":i,"bg-red-100":!i}),children:[Wr("div",{className:"flex flex-row items-start gap-4",children:[Ne("div",{className:"flex-shrink-0",children:i?Ne(K0,{className:"text-green-500 size-5"}):Ne(X0,{className:"text-red-500 size-5"})}),Wr("div",{className:"body-medium-500 text-grey-800",children:[Ne("div",{children:o(i?"validation.success.title":"validation.errors.title")}),!i&&Ne("div",{children:o("validation.errors.subtitle")})]}),Ne(U0,{variant:"ghost",size:"small",color:"grey",className:"size-5 hover:bg-transparent",iconButton:!0,onClick:()=>{r(!1),t()},children:Ne(q0,{})})]}),Ne("div",{className:"max-h-80 overflow-y-auto mt-2 px-9 body-medium-400 text-grey-800",children:i?Ne("p",{children:o("validation.success.message")}):Ne("div",{className:"list-disc list-inside",children:s.map(a=>Ne("li",{className:"mb-1",children:a.message},a.id))})})]})};import{jsx as ve,jsxs as Yr}from"react/jsx-runtime";var Ur=oy((e,t)=>{let{instanceId:o,mode:n,isMinimapOpen:r,isMoveTool:i,isHandTool:s}=R(),{nodes:a,setNodes:l,edges:c,setEdges:d,ui:p,actions:u,events:f,components:y,controls:g}=_c();ny(t,()=>({selectElements:u.selectElements,clearSelection:u.clearSelection}));let m={nodes:a,edges:c};return Yr("div",{className:"w-full h-full",children:[n==="edit"&&ve(jc,{}),ve(Nc,{}),Yr(ey,v(b({},f),{id:`modeler-${o}`,edges:c,nodes:a,nodeTypes:Ml,edgeTypes:Pl,minZoom:Ol,maxZoom:Hl,panOnDrag:s||n!=="edit"?!0:Bl,panOnScroll:!0,selectionOnDrag:!0,elevateEdgesOnSelect:!0,elevateNodesOnSelect:!0,elementsSelectable:n!=="readonly"&&i,nodesConnectable:n==="edit"&&i,nodesDraggable:n==="edit"&&i,connectionLineComponent:Al,selectionMode:ty.Partial,multiSelectionKeyCode:"Shift",deleteKeyCode:"Delete",selectionKeyCode:null,snapToGrid:!0,snapGrid:[5,5],defaultViewport:Gl,connectOnClick:!1,proOptions:{hideAttribution:!0},children:[ve(Q0,{gap:Rl,size:kl,color:Dl,bgColor:Ll}),r&&ve(j0,{pannable:!0,zoomable:!0,position:Vl,className:"shadow-md rounded-md"}),Yr("div",{className:"absolute z-10 bottom-4 left-1/2 -translate-x-1/2 flex gap-4",children:[n==="edit"&&ve(Kc,b({},g)),ve(Wc,{nodes:a,diagram:m,onValidateDiagram:u.validateDiagram,onValidationComplete:u.handleValidationComplete}),ve(qc,{})]}),ve(y.HelperLines,{}),p.validationResult&&ve("div",{className:"absolute top-6 right-6 z-[1000]",children:ve(ed,{validationResult:p.validationResult,onClose:p.handleCloseValidationPanel})})]})),ve(Jc,{pendingDelete:p.pendingDelete,setPendingDelete:p.setPendingDelete,nodes:a,setNodes:l,setEdges:d,saveHistory:u.saveHistory})]})});Ur.displayName="Editor";import{useStore as ry}from"@xyflow/react";import{useEffect as iy,useRef as sy}from"react";import{jsx as ly}from"react/jsx-runtime";var ay=e=>({width:e.width,height:e.height,transform:e.transform}),$r="rgba(51, 103, 217, 0.4)",ua=({horizontal:e,vertical:t})=>{let{width:o,height:n,transform:r}=ry(ay),i=sy(null);return iy(()=>{let s=i.current,a=s==null?void 0:s.getContext("2d");if(!a||!s)return;let l=window.devicePixelRatio;s.width=o*l,s.height=n*l,a.clearRect(0,0,o,n),a.scale(l,l),a.strokeStyle=$r,t&&(a.beginPath(),a.strokeStyle=t.color||$r,a.moveTo(t.position*r[2]+r[0],0),a.lineTo(t.position*r[2]+r[0],n),a.stroke()),e&&(a.beginPath(),a.strokeStyle=e.color||$r,a.moveTo(0,e.position*r[2]+r[1]),a.lineTo(o,e.position*r[2]+r[1]),a.stroke())},[o,n,r,e,t]),ly("canvas",{ref:i,className:"w-full h-full absolute z-10 pointer-events-none"})};import{i18n as cy,Notification as dy,TooltipProvider as uy}from"lecom-ui";import{createContext as py,useContext as fy,useEffect as my,useState as gy}from"react";import{jsx as td,jsxs as yy}from"react/jsx-runtime";var Rt=new Map,od=py(null),Xr=()=>{let e=fy(od);if(!e)throw new Error("useModeler must be used within an <ModelerProvider />");return e},hy=({locale:e,defaultMode:t="view",showNotification:o=!0,children:n})=>{let[r,i]=gy(e||"pt_BR");my(()=>{e&&(i(e),cy.changeLanguage(e))},[e]);let s=f=>{let y=Rt.size;if(y===0)throw new Error("No modeler instances found");if(y===1||!f){let[m]=Rt.values();return m}let g=Rt.get(f);if(!g)throw new Error(`Modeler instance with ID "${f}" not found`);return g},a=(f,y)=>{let g=s(y);return g==null?void 0:g.selectElements(f)},l=async f=>{let y=s(f);return y==null?void 0:y.clearSelection()},c=(f,y)=>{let g=s(y);return g==null?void 0:g.configureElement(f)},d=(f,y)=>{let g=s(y);return g==null?void 0:g.getConfigureElement(f)},p=async(f,y)=>{let g=s(y);await(g==null?void 0:g.importFromMxGraph(f))},u=f=>{let y=s(f);return y==null?void 0:y.exportToMxGraph()};return td(od.Provider,{value:{defaultMode:t,locale:r,selectElements:a,clearSelection:l,configureElement:c,getConfigureElement:d,importDiagram:p,exportDiagram:u},children:yy(uy,{children:[o&&td(dy,{type:"toast",placement:"topRight",enableClose:!0,showProgress:!0,pauseOnHover:!0}),n]})})};import{jsx as Kr}from"react/jsx-runtime";var nd=Ey(null),R=()=>{let e=by(nd);if(!e)throw new Error("useModelerInstance must be used within an <Modeler />");return e},vy=({selectorRef:e,initialDiagram:t,instanceId:o,mode:n,onElementChanges:r,onConfigureElement:i,onSubprocessValidationClick:s})=>{let{defaultMode:a}=Xr(),l=Ty(),[c]=Re(o||l),[d,p]=Re(n||a||"edit"),[u,f]=Re(!1),[y,g]=Re(!0),[m,_]=Re(!1),[h,E]=Re(!1),[T,N]=Re(!1),[w,x]=Re(!1),[C,k]=Re(!1);_y(()=>{n&&p(n)},[n]);let D=Ny(()=>t||zl(),[t]),A={instanceId:c,initialDiagram:D,mode:d,isInitialized:u,setIsInitialized:f,isMinimapOpen:h,isMoveTool:y,isHandTool:m,isDragging:T,isMultipleSelection:C,isConnecting:w,setIsMinimapOpen:E,setIsMoveTool:g,setIsHandTool:_,setIsDragging:N,setIsConnecting:x,setIsMultipleSelection:k,onElementChanges:r,onConfigureElement:i,onSubprocessValidationClick:s};return Kr(xy,{children:Kr(nd.Provider,{value:A,children:Kr(Ur,{ref:e})})})};export{fe as EditorMode,Xn as ElementPosition,bo as ElementType,Kn as GatewayElementVariant,be as GatewayVariant,vy as Modeler,hy as ModelerProvider,Oe as NodeAttribute,G as NodeType,Ee as NodeVariant,qn as RoutingVariant,Xr as useModeler};