lecom-modeler 0.30.3 → 0.31.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/lib/index.js CHANGED
@@ -1,9 +1,9 @@
1
- var sp=Object.defineProperty,ap=Object.defineProperties;var lp=Object.getOwnPropertyDescriptors;var Rn=Object.getOwnPropertySymbols;var ks=Object.prototype.hasOwnProperty,Rs=Object.prototype.propertyIsEnumerable;var Ls=(e,t,o)=>t in e?sp(e,t,{enumerable:!0,configurable:!0,writable:!0,value:o}):e[t]=o,b=(e,t)=>{for(var o in t||(t={}))ks.call(t,o)&&Ls(e,o,t[o]);if(Rn)for(var o of Rn(t))Rs.call(t,o)&&Ls(e,o,t[o]);return e},w=(e,t)=>ap(e,lp(t));var mt=(e,t)=>{var o={};for(var n in e)ks.call(e,n)&&t.indexOf(n)<0&&(o[n]=e[n]);if(e!=null&&Rn)for(var n of Rn(e))t.indexOf(n)<0&&Rs.call(e,n)&&(o[n]=e[n]);return o};var Ni=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 cp,Translations as dp}from"@produto-lecom/lecom-ui";var Ds={translations:{general:{layout:{title:"Modeler"}},editor:{toolbar:{delete:"Delete",configure_node:"Configure activity",configure_edge:"Configure routing",configure_gateway:"Configure routing",initial_task:"Initial Activity",gateway_limit_reached:"Exclusive gateway cannot have more than 2 outgoing connections",task_limit_reached:"Task cannot have more than 2 outgoing connections",start_event_limit_reached:"Start event can only connect to a single element",gateway_to_gateway_not_allowed:"Gateways cannot connect directly to other gateways",start_event_already_exists:"A start event already exists. Delete the current event to add another",script_to_end_not_allowed:"Script activities cannot connect directly to the end event",loop_to_end_not_allowed:"Loop activities cannot connect directly to the end event",initial_activity_to_end_not_allowed:"Initial activity cannot connect directly to the end event",final_activity_cannot_connect:"Final activity cannot connect to other elements",activity_has_outgoing_connections:"Activity with outgoing connections cannot connect to end event",end_event_cannot_connect_to_initial_activity:"End event cannot connect to an initial activity",initial_activity_cannot_connect_to_start_event:"Initial activity cannot connect to start event",concurrent_initial_and_final_activity:"An activity cannot be connected to both start and end events",duplicate_connection_not_allowed:"A connection already exists between these elements",connect_node:"Connect element",connecting:"Connecting...",delete_pool_lane_error:"Cannot delete the pool or lane while there are elements inside it."},controls:{zoom:{fit:"Fit zoom",in:"Zoom in",out:"Zoom out",reset:"Reset zoom"},actions:{move_tool:"Select elements",hand_tool:"Navigate the diagram",check:"Check diagram",check_loading:"Validating diagram...",export:{title:"Export diagram",print:"Print",html:"Export as HTML",png:"Export as PNG",feedback:{empty:"Cannot export an empty diagram",error:"Error exporting diagram"}},import_governance:"Import diagram from Governance platform",minimap:{label:"Minimap",open:"Open minimap",close:"Hide minimap"}},history:{undo:"Undo",redo:"Redo"}},modals:{delete_elements:{title:"Delete elements",callout:"When deleting, the activity and routing settings will be deleted.",content:"Are you sure you want to delete?",confirm:"Delete",cancel:"Cancel"}},task_menu:{loop_not_allowed_when_connected_to_end:"Cannot create loop on activity connected to end event",script_not_allowed_when_connected_to_end:"Cannot transform to Script activity connected to end event",loop_not_allowed_when_subprocess:"Cannot create loop on subprocess",loop:"Activity with loop"}},validation:{success:{title:"Validation Successful",message:"The diagram was validated successfully with no errors."},errors:{title:"The diagram contains errors",subtitle:"Please review the following:",task_label_length:"Task name exceeds the maximum character limit",multiple_start_event_not_allowed:"Multiple start events are not allowed",task_flows_limit_exceeds:"The number of output connections exceeds the limit of two",duplicate_task_name:"There are multiple activities with the same name",flows_on_end_tasks_not_allowed:"Activities connected to end events cannot have other connections",conditions_flows_limit_exceeds:"Exclusive gateway has too many output connections (maximum of two)",task_label_empty:"One or more activities have no name",activity_name_invalid:"Activity name is invalid",final_activity_has_loop:"Final activities cannot have loops",nested_gateway:"Connecting gateways directly is not allowed",concurrent_initial_and_final_event:"The same activity cannot have both initial and final events",gateway_flow_to_event:"Connecting a gateway to an output event is not allowed",gateway_missing_output_streams:"The gateway does not have the correct number of outputs",events_nested:"Connecting events directly is not allowed",event_to_condition:"Connecting an event directly to a gateway is not allowed",script_in_final_activity:"Final activity cannot be a script type",subprocess_not_configured:"The subprocess reference is not properly configured",cannot_validate_subprocess_reference:"Could not validate whether the subprocess reference is configured",start_event_not_found:"At least one start event is required",end_event_not_found:"At least one end event is required"}},bpmn:{start_event:{variant:{default:"Start event"}},end_event:{variant:{default:"End event"}},annotation:{variant:{default:"Annotation"}},gateway:{menu:{title:"Change gateway type"},variant:{default:"Gateway",exclusive:"Exclusive gateway",parallel:"Parallel gateway",complex:"Complex gateway"}},task:{menu:{title:"Change task type"},variant:{default:"Task",script:"Script task",subprocess:"Subprocess"},attribute:{loop:"Task with loop"},label:{prefix:"Activity"},feedback:{label_empty:{prefix:"Activity name was automatically set to"},label_already_exists:{prefix:"The name",middle:"already exists. The name was changed to"},invalid_first_character:"Activity name must start with a letter or number"}},lane:{variant:{default:"Pool / Lane"}},unsupported:{variant:{default:"Unsupported element"}}},adapter:{governance:{error:{DEFAULT:"Error importing diagram",NO_FILE:"No file selected",EMPTY_FILE:"Empty file",INVALID_FILE:"Invalid file",CONTAIN_NO_CELLS:"No cells found to be imported",ALREADY_INITIALIZED:"It is not possible to import the diagram from the Governance platform, since the diagram has already been initialized"},success:{default:"The diagram was imported from the Governance platform successfully and without any incompatibility detected.",incompatible_cells:"The diagram was imported from the Governance platform with incompatibilities. To know more details, click on the button below."},report:{columns:{type:"Type",value:"Value",status:"Status"},status:{imported:"Imported",adapted:"Adapted",unsupported:"Unsupported"}},action:{download:"Download report"}}}}};var Os={translations:{general:{layout:{title:"Modeler"}},editor:{toolbar:{delete:"Eliminar",configure_node:"Configurar actividad",configure_edge:"Configurar enrutamiento",configure_gateway:"Configurar enrutamiento",initial_task:"Actividad Inicial",gateway_limit_reached:"Compuerta exclusiva no puede tener m\xE1s de 2 conexiones de salida",task_limit_reached:"Actividad no puede tener m\xE1s de 2 conexiones de salida",start_event_limit_reached:"Evento inicial solo puede conectarse a un \xFAnico elemento",gateway_to_gateway_not_allowed:"Las compuertas no pueden conectarse directamente con otras compuertas",start_event_already_exists:"Ya existe un evento de inicio. Elimine el evento actual para agregar otro",script_to_end_not_allowed:"Las actividades Script no pueden conectarse directamente al evento final",loop_to_end_not_allowed:"Las actividades Loop no pueden conectarse directamente al evento final",initial_activity_to_end_not_allowed:"Actividad inicial no puede conectarse directamente al evento final",final_activity_cannot_connect:"Actividad final no puede conectarse a otros elementos",activity_has_outgoing_connections:"Actividad con conexiones de salida no puede conectarse al evento final",end_event_cannot_connect_to_initial_activity:"El evento final no puede conectarse a una actividad inicial",initial_activity_cannot_connect_to_start_event:"Actividad inicial no puede conectarse a evento de inicio",concurrent_initial_and_final_activity:"Una actividad no puede estar conectada al evento inicial y final al mismo tiempo",duplicate_connection_not_allowed:"Ya existe una conexi\xF3n entre estos elementos",connect_node:"Conectar elemento",connecting:"Conectando...",delete_pool_lane_error:"No se puede eliminar la piscina o carril mientras haya elementos dentro."},controls:{zoom:{fit:"Ajustar zoom",in:"Acercar",out:"Alejar",reset:"Restablecer zoom"},actions:{move_tool:"Seleccionar elementos",hand_tool:"Navegar por el diagrama",check:"Validar diagrama",check_loading:"Validando diagrama...",export:{title:"Exportar diagrama",print:"Imprimir",html:"Exportar como HTML",png:"Exportar como PNG",feedback:{empty:"No es posible exportar un diagrama vac\xEDo",error:"Error al exportar diagrama"}},import_governance:"Importar diagrama de la plataforma Governance",minimap:{label:"Minimapa",open:"Abrir minimapa",close:"Ocultar minimapa"}},history:{undo:"Deshacer",redo:"Rehacer"}},modals:{delete_elements:{title:"Eliminar elementos",callout:"Al eliminar, las configuraciones de actividades y enrutamiento ser\xE1n eliminadas.",content:"\xBFEst\xE1s seguro de querer eliminar?",confirm:"Eliminar",cancel:"Cancelar"}},task_menu:{loop_not_allowed_when_connected_to_end:"No se puede crear bucle en actividad conectada al evento final",script_not_allowed_when_connected_to_end:"No se puede transformar a Script actividad conectada al evento final",loop_not_allowed_when_subprocess:"No se puede crear bucle en subproceso",loop:"Actividad con loop"}},validation:{success:{title:"Validaci\xF3n exitosa",message:"El diagrama ha sido validado correctamente sin errores."},errors:{title:"El diagrama contiene errores",subtitle:"Revise lo siguiente:",task_label_length:"El nombre de la actividad excede el l\xEDmite m\xE1ximo de caracteres",multiple_start_event_not_allowed:"No se permite tener m\xE1s de un evento de inicio",task_flows_limit_exceeds:"El n\xFAmero de conexiones de salida supera el l\xEDmite de dos",duplicate_task_name:"Hay varias actividades con el mismo nombre",flows_on_end_tasks_not_allowed:"Las actividades conectadas a eventos finales no pueden tener otras conexiones",conditions_flows_limit_exceeds:"Compuerta exclusiva con exceso de conexiones de salida (m\xE1ximo de dos)",task_label_empty:"El nombre de una o m\xE1s actividades no ha sido completado",activity_name_invalid:"El nombre de la actividad no es v\xE1lido",final_activity_has_loop:"Las actividades finales no pueden tener bucles",nested_gateway:"No se permite conectar compuertas directamente",concurrent_initial_and_final_event:"Una misma actividad no puede tener eventos iniciales y finales",gateway_flow_to_event:"No se permite conectar una compuerta a un evento de salida",gateway_missing_output_streams:"La compuerta no tiene el n\xFAmero correcto de salidas",events_nested:"No se permite conectar eventos directamente",event_to_condition:"No se permite conectar un evento directamente a una compuerta",script_in_final_activity:"La actividad final no puede ser de tipo script",subprocess_not_configured:"La referencia al subproceso no est\xE1 configurada correctamente",cannot_validate_subprocess_reference:"No fue posible validar si la referencia al subproceso est\xE1 configurada",start_event_not_found:"Es necesario tener al menos un evento de inicio",end_event_not_found:"Es necesario tener al menos un evento final"}},bpmn:{start_event:{variant:{default:"Evento de inicio"}},end_event:{variant:{default:"Evento final"}},annotation:{variant:{default:"Anotaci\xF3n"}},gateway:{menu:{title:"Cambiar tipo de compuerta"},variant:{default:"Compuerta",exclusive:"Compuerta exclusiva",parallel:"Compuerta paralela",complex:"Compuerta compleja"}},task:{menu:{title:"Cambiar tipo de tarea"},variant:{default:"Tarea",script:"Tarea de script",subprocess:"Subproceso"},attribute:{loop:"Tarea con bucle"},label:{prefix:"Actividad"},feedback:{label_empty:{prefix:"El nombre de la actividad se estableci\xF3 autom\xE1ticamente como"},label_already_exists:{prefix:"El nombre",middle:"ya existe. El nombre fue cambiado a"},invalid_first_character:"El nombre de la actividad debe comenzar con una letra o n\xFAmero"}},lane:{variant:{default:"Piscina / Raia"}},unsupported:{variant:{default:"Elemento no soportado"}}},adapter:{governance:{error:{DEFAULT:"Error al importar diagrama",NO_FILE:"No se ha seleccionado ning\xFAn archivo",EMPTY_FILE:"Archivo vac\xEDo",INVALID_FILE:"Archivo inv\xE1lido",CONTAIN_NO_CELLS:"No se encontraron c\xE9lulas para importar",ALREADY_INITIALIZED:"No es posible importar el diagrama de la plataforma Governance, ya que el diagrama ya ha sido iniciado"},success:{default:"El diagrama se ha importado de la plataforma Governance correctamente y sin ninguna incompatibilidad detectada.",incompatible_cells:"El diagrama se ha importado de la plataforma Governance con incompatibilidades. Para saber m\xE1s detalles, haz click en el bot\xF3n de abajo."},report:{columns:{type:"Tipo",value:"Valor",status:"Estado"},status:{imported:"Importado",adapted:"Adaptado",unsupported:"No soportado"}},action:{download:"Descargar informe"}}}}};var Vs={translations:{general:{layout:{title:"Modeler"}},editor:{toolbar:{delete:"Excluir",configure_node:"Configurar atividade",configure_edge:"Configurar roteamento",configure_gateway:"Configurar roteamento",initial_task:"Atividade Inicial",gateway_limit_reached:"Gateway exclusivo n\xE3o pode ter mais de 2 conex\xF5es de sa\xEDda",task_limit_reached:"Atividade n\xE3o pode ter mais de 2 conex\xF5es de sa\xEDda",start_event_limit_reached:"Evento inicial s\xF3 pode se conectar a um \xFAnico elemento",gateway_to_gateway_not_allowed:"Gateways n\xE3o podem se conectar diretamente com outros gateways",start_event_already_exists:"J\xE1 existe um evento de in\xEDcio. Exclua o evento atual para adicionar outro",script_to_end_not_allowed:"Atividades Script n\xE3o podem se conectar diretamente ao evento final",loop_to_end_not_allowed:"Atividades Loop n\xE3o podem se conectar diretamente ao evento final",initial_activity_to_end_not_allowed:"Atividade inicial n\xE3o pode se conectar diretamente ao evento final",final_activity_cannot_connect:"Atividade final n\xE3o pode se conectar a outros elementos",activity_has_outgoing_connections:"Atividade com conex\xF5es de sa\xEDda n\xE3o pode se conectar a um evento final",end_event_cannot_connect_to_initial_activity:"O evento final n\xE3o pode ser conectado a uma atividade inicial",initial_activity_cannot_connect_to_start_event:"Atividade inicial n\xE3o pode se conectar a evento de in\xEDcio",concurrent_initial_and_final_activity:"Uma atividade n\xE3o pode estar conectada ao evento inicial e final ao mesmo tempo",duplicate_connection_not_allowed:"J\xE1 existe uma conex\xE3o entre esses elementos",start_event_to_subprocess_not_allowed:"Evento inicial n\xE3o pode se conectar a um subprocesso",connect_node:"Conectar elemento",connecting:"Conectando...",delete_pool_lane_error:"N\xE3o \xE9 poss\xEDvel excluir a piscina ou raia enquanto houver elementos dentro dela."},controls:{zoom:{fit:"Ajustar o zoom",in:"Aumentar o zoom",out:"Diminuir o zoom",reset:"Resetar o zoom"},actions:{move_tool:"Selecionar elementos",hand_tool:"Navegar pelo diagrama",check:"Validar diagrama",check_loading:"Validando diagrama...",export:{title:"Exportar diagrama",print:"Imprimir",html:"Exportar como HTML",png:"Exportar como PNG",feedback:{empty:"N\xE3o \xE9 poss\xEDvel exportar um diagrama vazio",error:"Erro ao exportar o diagrama"}},import_governance:"Importar diagrama da plataforma Governance",minimap:{label:"Minimapa",open:"Abrir minimapa",close:"Ocultar minimapa"}},history:{undo:"Desfazer",redo:"Refazer"}},modals:{delete_elements:{title:"Excluir elementos",callout:"Ao excluir, as configura\xE7\xF5es de atividades e roteamento ser\xE3o exclu\xEDdas.",content:"Deseja realmente excluir?",confirm:"Excluir",cancel:"Cancelar"}},task_menu:{loop_not_allowed_when_connected_to_end:"N\xE3o \xE9 poss\xEDvel criar loop em atividade conectada ao evento final",script_not_allowed_when_connected_to_end:"N\xE3o \xE9 poss\xEDvel transformar em Script atividade conectada ao evento final",loop_not_allowed_when_subprocess:"N\xE3o \xE9 poss\xEDvel criar loop em subprocesso",loop:"Atividade com loop"}},validation:{success:{title:"Diagrama v\xE1lidado com sucesso!",message:"Nenhum erro encontrado."},errors:{title:"O diagrama cont\xE9m erros",subtitle:"Veja abaixo o que precisa ser corrigido:",task_label_length:"O nome da atividade excede o limite m\xE1ximo de caracteres",multiple_start_event_not_allowed:"N\xE3o \xE9 permitido ter mais de um evento de in\xEDcio",task_flows_limit_exceeds:"O n\xFAmero de conex\xF5es de sa\xEDda ultrapassa o limite de dois",duplicate_task_name:"H\xE1 v\xE1rias atividades com o mesmo nome",flows_on_end_tasks_not_allowed:"Atividades conectadas a eventos finais n\xE3o podem ter outras conex\xF5es",conditions_flows_limit_exceeds:"Gateway exclusivo com excesso de conex\xF5es de sa\xEDda (m\xE1ximo de dois)",task_label_empty:"O nome de uma ou mais atividades n\xE3o foi preenchido",activity_name_invalid:"O nome da atividade n\xE3o \xE9 v\xE1lido",final_activity_has_loop:"Atividades finais n\xE3o podem ter loops",nested_gateway:"N\xE3o \xE9 permitido conectar gateways",concurrent_initial_and_final_event:"Uma mesma atividade n\xE3o pode ter eventos iniciais e finais",gateway_flow_to_event:"N\xE3o \xE9 permitido conectar um gateway a um evento de sa\xEDda",gateway_missing_output_streams:"O gateway n\xE3o possui o n\xFAmero correto de sa\xEDdas",events_nested:"N\xE3o \xE9 permitido conectar eventos",event_to_condition:"N\xE3o \xE9 permitido conectar um evento diretamente em um gateway",script_in_final_activity:"Atividade final n\xE3o pode ser do tipo script",subprocess_not_configured:"A refer\xEAncia ao subprocesso n\xE3o est\xE1 configurada corretamente",cannot_validate_subprocess_reference:"N\xE3o foi poss\xEDvel validar se a refer\xEAncia ao subprocesso est\xE1 configurada",start_event_not_found:"\xC9 necess\xE1rio ter ao menos um evento inicial",end_event_not_found:"\xC9 necess\xE1rio ter ao menos um evento final"}},bpmn:{start_event:{variant:{default:"Evento inicial"}},end_event:{variant:{default:"Evento final"}},annotation:{variant:{default:"Anota\xE7\xE3o"}},gateway:{menu:{title:"Alterar tipo de gateway"},variant:{default:"Gateway",exclusive:"Gateway exclusivo",parallel:"Gateway paralelo",complex:"Gateway complexo"}},task:{menu:{title:"Alterar tipo de atividade"},variant:{default:"Atividade",script:"Atividade de script",subprocess:"Subprocesso"},attribute:{loop:"Atividade com loop"},label:{prefix:"Atividade"},feedback:{label_empty:{prefix:"O nome da atividade foi definido automaticamente como"},label_already_exists:{prefix:"O nome",middle:"j\xE1 existe. O nome foi alterado para"},invalid_first_character:"O nome da atividade deve come\xE7ar com uma letra ou n\xFAmero"}},lane:{variant:{default:"Piscina / Raia"}},unsupported:{variant:{default:"Elemento n\xE3o suportado"}}},adapter:{governance:{error:{DEFAULT:"Erro ao importar diagrama",NO_FILE:"Nenhum arquivo selecionado",EMPTY_FILE:"Arquivo vazio",INVALID_FILE:"Arquivo inv\xE1lido",CONTAIN_NO_CELLS:"N\xE3o foram encontradas c\xE9lulas para serem importadas",ALREADY_INITIALIZED:"N\xE3o \xE9 poss\xEDvel importar o diagrama da plataforma Governance, pois o diagrama j\xE1 foi iniciado"},success:{default:"O diagrama foi importado da plataforma Governance com sucesso e sem nenhuma incompatibilidade detectada.",incompatible_cells:"O diagrama foi importado da plataforma Governance com incompatibilidades. Para saber mais detalhes, clique no bot\xE3o abaixo."},report:{columns:{type:"Tipo do elemento",value:"Valor",status:"Status"},status:{imported:"Importado",adapted:"Adaptado",unsupported:"N\xE3o suportado"}},action:{download:"Baixar relat\xF3rio"}}}}};var Hs={pt_BR:Vs,en_US:Ds,es_ES:Os};var Gs,Bs,up=(Bs=(Gs=Ni("LecomUserLanguage"))!=null?Gs:Ni("org.springframework.web.servlet.i18n.CookieLocaleResolver.LOCALE"))!=null?Bs:dp.PT_BR;cp({lng:up,resources:Hs});var we=(n=>(n.EDIT="edit",n.VIEW="view",n.READONLY="readonly",n))(we||{});var Dn=(r=>(r.ACTIVITY="activity",r.ROUTING="routing",r.GATEWAY="gateway",r.SUB_PROCESS="sub_process",r))(Dn||{}),Ti=(n=>(n.START="start",n.END="end",n.BETWEEN="between",n))(Ti||{}),vi=(n=>(n.SCRIPT="script",n.LOOP="loop",n.SCRIPT_LOOP="script_loop",n))(vi||{}),wi=(d=>(d.SIMPLE="simple",d.LOOP="loop",d.SCRIPT="script",d.SCRIPT_LOOP="script_loop",d.COMPLEX="complex",d.EXCLUSIVE="exclusive",d.PARALLEL="parallel",d.FINAL="final",d.TO_SUB_PROCESS="to_sub_process",d.FROM_SUB_PROCESS="from_sub_process",d))(wi||{});import{RotateCcw as Tp,ScrollText as vp,SquarePlus as wp}from"lucide-react";import{jsx as On,jsxs as pp}from"react/jsx-runtime";var Vn=({size:e=24,className:t})=>pp("svg",{width:e,height:e,viewBox:"0 0 24 24",xmlns:"http://www.w3.org/2000/svg",fill:"currentColor",className:t,children:[On("path",{strokeWidth:"2",d:"M16 3V3.5085V11.9998V20.4915V21H16.5411H21.4592H22V19.123H21.4592H17.9974V11.9998V4.8773H21.4592H22V3H21.4592H16.5411H16Z"}),On("path",{d:"M4.41026 16.9999L2 18.7861L3.89693 21.1103L6.3072 19.324L4.41026 16.9999Z"}),On("path",{d:"M8.41026 13.9999L6 15.7861L7.89693 18.1103L10.3072 16.324L8.41026 13.9999Z"}),On("path",{d:"M12.4313 10.954L10.021 12.7402L11.9179 15.0644L14.3282 13.2781L12.4313 10.954Z"})]});import{jsx as zs}from"react/jsx-runtime";var xo=({size:e=24,className:t})=>zs("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:zs("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 Ko,jsxs as fp}from"react/jsx-runtime";var Eo=({size:e=24,className:t})=>fp("svg",{width:e,height:e,viewBox:"0 0 24 24",xmlns:"http://www.w3.org/2000/svg",fill:"white",stroke:"currentColor",strokeWidth:2,className:t,children:[Ko("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"}),Ko("path",{d:"M12 8V16",strokeLinecap:"round",strokeLinejoin:"round"}),Ko("path",{d:"M8 12H16",strokeLinecap:"round",strokeLinejoin:"round"}),Ko("path",{d:"M9.17139 9.17188L14.8282 14.8287",strokeLinecap:"round",strokeLinejoin:"round"}),Ko("path",{d:"M14.8281 9.17188L9.17127 14.8287",strokeLinecap:"round",strokeLinejoin:"round"})]});import{jsx as Ii,jsxs as mp}from"react/jsx-runtime";var bo=({size:e=24,className:t})=>mp("svg",{width:e,height:e,viewBox:"0 0 24 24",xmlns:"http://www.w3.org/2000/svg",fill:"white",stroke:"currentColor",strokeWidth:2,className:t,children:[Ii("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"}),Ii("path",{d:"M14.8286 9.17188L9.17176 14.8287",strokeLinecap:"round",strokeLinejoin:"round"}),Ii("path",{d:"M9.17139 9.17188L14.8282 14.8287",strokeLinecap:"round",strokeLinejoin:"round"})]});import{jsx as Ai,jsxs as gp}from"react/jsx-runtime";var _o=({size:e=24,className:t})=>gp("svg",{width:e,height:e,viewBox:"0 0 24 24",xmlns:"http://www.w3.org/2000/svg",fill:"white",stroke:"currentColor",strokeWidth:2,className:t,children:[Ai("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"}),Ai("path",{d:"M12 8V16",strokeLinecap:"round",strokeLinejoin:"round"}),Ai("path",{d:"M8 12H16",strokeLinecap:"round",strokeLinejoin:"round"})]});import{jsx as Ci,jsxs as hp}from"react/jsx-runtime";var Ys=({size:e=24,className:t})=>Ci("svg",{width:e,height:e,viewBox:"0 0 34 24",xmlns:"http://www.w3.org/2000/svg",fill:"currentColor",className:t,children:hp("g",{children:[Ci("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"}),Ci("path",{d:"M24.5 4.5L28 1M28 1L31.5 4.5M28 1V8",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round"})]})});import{clsx as yp}from"clsx";import{twMerge as xp}from"tailwind-merge";function H(...e){return xp(yp(e))}var kt=(e=0,t=0)=>e<t?t:e,Hn=(e=1e3)=>new Promise(t=>{setTimeout(t,e)});import{jsx as Ws,jsxs as Ep}from"react/jsx-runtime";var Fs=({size:e=24,className:t})=>Ep("svg",{width:e,height:e,viewBox:"0 0 24 24",fill:"none",stroke:"#6b7280",strokeWidth:2,xmlns:"http://www.w3.org/2000/svg",className:H("stroke-2",t),children:[Ws("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"}),Ws("path",{d:"M9 3V21",strokeLinecap:"round",strokeLinejoin:"round"})]});import{jsx as Si}from"react/jsx-runtime";var Xs=({size:e=24,className:t})=>Si("svg",{width:e,height:e,viewBox:"0 0 24 24",xmlns:"http://www.w3.org/2000/svg",stroke:"currentColor",className:t,children:Si("g",{children:Si("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 Us}from"react/jsx-runtime";var Gn=({size:e=24,className:t})=>Us("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:Us("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 $s}from"react/jsx-runtime";var qo=({size:e=24,className:t})=>$s("svg",{width:e,height:e,viewBox:"0 0 24 24",xmlns:"http://www.w3.org/2000/svg",fill:"white",stroke:"currentColor",className:H("stroke-2",t),children:$s("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 Mi,jsxs as bp}from"react/jsx-runtime";var Ks=({size:e=24,className:t})=>bp("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:[Mi("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"}),Mi("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"}),Mi("path",{d:"M7.5 7.5V10H10",strokeWidth:"1.5",fill:"none",strokeLinecap:"round",strokeLinejoin:"round"})]});import{jsx as Zo,jsxs as _p}from"react/jsx-runtime";var qs=({size:e=24,className:t})=>_p("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:[Zo("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"}),Zo("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"}),Zo("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"}),Zo("path",{d:"M13.5 12H11",strokeWidth:"1",strokeLinecap:"round",strokeLinejoin:"round"}),Zo("path",{d:"M13.5 10H11",strokeWidth:"1",strokeLinecap:"round",strokeLinejoin:"round"})]});import{jsx as Bn,jsxs as Np}from"react/jsx-runtime";var Jo=({size:e=24,className:t})=>Np("svg",{width:e,height:e,viewBox:"0 0 24 24",xmlns:"http://www.w3.org/2000/svg",fill:"white",stroke:"currentColor",strokeWidth:2,className:t,children:[Bn("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"}),Bn("path",{d:"M8 21V14C8 13.4477 8.44772 13 9 13H15C15.5523 13 16 13.4477 16 14V21",strokeWidth:"1",fill:"none"}),Bn("path",{d:"M10.2222 17H13.7777",strokeWidth:"1",strokeLinecap:"round",strokeLinejoin:"round"}),Bn("path",{d:"M12 15.2227V18.7782",strokeWidth:"1",strokeLinecap:"round",strokeLinejoin:"round"})]});var se=(s=>(s.START_EVENT="START_EVENT",s.END_EVENT="END_EVENT",s.TASK="TASK",s.LANE="LANE",s.GATEWAY="GATEWAY",s.ANNOTATION="ANNOTATION",s.UNSUPPORTED="UNSUPPORTED",s))(se||{}),tt=(o=>(o.SCRIPT="SCRIPT",o.SUBPROCESS="SUBPROCESS",o))(tt||{}),zn={SCRIPT:{icon:vp},SUBPROCESS:{icon:wp}},gt=(t=>(t.LOOP="LOOP",t))(gt||{}),Yn={LOOP:{icon:Tp}},at=(n=>(n.EXCLUSIVE="EXCLUSIVE",n.PARALLEL="PARALLEL",n.COMPLEX="COMPLEX",n))(at||{}),Pi={EXCLUSIVE:{icon:bo},PARALLEL:{icon:_o},COMPLEX:{icon:Eo}};import{useTranslation as YE}from"@produto-lecom/lecom-ui";import{ReactFlowProvider as WE}from"@xyflow/react";import{createContext as FE,useContext as XE,useEffect as UE,useId as $E,useMemo as KE,useState as ut}from"react";import{Background as yE,MiniMap as xE,ReactFlow as EE,SelectionMode as bE,useKeyPress as _E}from"@xyflow/react";import{forwardRef as NE,useImperativeHandle as TE,useRef as Is}from"react";import{useTranslation as W0}from"@produto-lecom/lecom-ui";import{useEdgesState as F0,useNodesState as X0,useOnSelectionChange as U0,useReactFlow as $0,useStoreApi as K0}from"@xyflow/react";import{useCallback as Mt,useEffect as q0}from"react";import{Position as Qo}from"@xyflow/react";function Zs(e,t){var x,v,N,T;let{width:o=0,height:n=0}=e.measured||{width:0,height:0},r=e.internals.positionAbsolute,i=t.internals.positionAbsolute,a=o/2,s=n/2,l=r.x+a,c=r.y+s,d=i.x+((v=(x=t==null?void 0:t.measured)==null?void 0:x.width)!=null?v:0)/2,p=i.y+((T=(N=t==null?void 0:t.measured)==null?void 0:N.height)!=null?T:0)/2,m=(d-l)/(2*a)-(p-c)/(2*s),u=(d-l)/(2*a)+(p-c)/(2*s),g=1/(Math.abs(m)+Math.abs(u)||1),E=g*m,f=g*u,h=a*(E+f)+l,y=s*(-E+f)+c;return{x:h,y}}function Js(e,t){var c,d,p,m;let{positionAbsolute:o}=e.internals,n=(d=(c=e.measured)==null?void 0:c.width)!=null?d:0,r=(m=(p=e.measured)==null?void 0:p.height)!=null?m:0,i=Math.round(o.x),a=Math.round(o.y),s=Math.round(t.x),l=Math.round(t.y);return s<=i+1?Qo.Left:s>=i+n-1?Qo.Right:l<=a+1?Qo.Top:l>=a+r-1?Qo.Bottom:Qo.Top}function No(e,t){let o=Zs(e,t),n=Zs(t,e),r=Js(e,o),i=Js(t,n);return{sx:o.x,sy:o.y,tx:n.x,ty:n.y,sourcePos:r,targetPos:i}}function Wn(e,t){return{isFromStartEvent:(e==null?void 0:e.type)==="START_EVENT",isGatewayToGateway:(e==null?void 0:e.type)==="GATEWAY"&&(t==null?void 0:t.type)==="GATEWAY",isActiviyToAndGateway:(e==null?void 0:e.type)==="TASK"&&(t==null?void 0:t.type)==="GATEWAY",isToEndEvent:(t==null?void 0:t.type)==="END_EVENT"}}var Fn={MIN_WIDTH:36,MIN_HEIGHT:36},Xn={MIN_WIDTH:36,MIN_HEIGHT:36},To={MIN_WIDTH:56,MIN_HEIGHT:56},Rt={MIN_WIDTH:176,MIN_HEIGHT:96},Qs={HEADER_WIDTH:40,MIN_WIDTH:840,MIN_HEIGHT:256},ie={HEADER_WIDTH:40,MIN_WIDTH:800,MIN_HEIGHT:256},vo={MIN_WIDTH:176,MIN_HEIGHT:64},Ip={MIN_WIDTH:128,MIN_HEIGHT:64},pe={START_EVENT:Fn,END_EVENT:Xn,GATEWAY:To,TASK:Rt,LANE:ie,ANNOTATION:vo,UNSUPPORTED:Ip};import{orderBy as Ap}from"lodash";var js=e=>new Map(e.map(t=>[t.id,t])),ea=(e,t)=>e.map(o=>{var n;return(n=t.get(o.id))!=null?n:o}),ot=e=>{var t,o,n,r,i,a,s,l;return{x:(o=(t=e.internals)==null?void 0:t.positionAbsolute.x)!=null?o:0,y:(r=(n=e.internals)==null?void 0:n.positionAbsolute.y)!=null?r:0,w:(a=(i=e.measured)==null?void 0:i.width)!=null?a:0,h:(l=(s=e.measured)==null?void 0:s.height)!=null?l:0}},Qt=e=>Ap(e,[o=>{let n=o.type==="LANE";return n&&!o.parentId?0:n?1:2}],["asc"]),ta=(e,t)=>{let{x:o,y:n}=ot(e),{x:r,y:i}=ot(t);return{x:o-r,y:n-i}};var jt=({parentId:e,nodes:t,includeTypes:o=[...Object.values(se)],excludeTypes:n=[]})=>t.some(r=>r.parentId===e&&(!o.length||o.includes(r.type))&&!n.includes(r.type)),Cp=(e,t)=>{let{x:o,y:n}=ot(e),{x:r,y:i}=ot(t),a=o-r,s=n-i;return Math.sqrt(a*a+s*s)},Sp=(e,t)=>{let{x:o,y:n,w:r,h:i}=ot(e),{x:a,y:s,w:l,h:c}=ot(t),d=o+r/2,p=n+i/2;return d>=a&&d<=a+l&&p>=s&&p<=s+c},jo=(e,t)=>{let o=null,n=1/0;for(let r of t)if(r.id!==e.id&&Sp(e,r)){let i=Cp(e,r);i<n&&(n=i,o=r)}return o},oa=(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),na=(e,t)=>{let o=e.filter(c=>!c.parentId);if(o.length===0)return{nodes:e,edges:t};let n=o.filter(c=>c.type==="LANE"),r=n.length>0?n:o,i=Math.min(...r.map(c=>c.position.x||0)),a=Math.min(...r.map(c=>c.position.y||0)),s=e.map(c=>c.parentId?c:w(b({},c),{position:{x:c.position.x-i,y:c.position.y-a}})),l=t.map(c=>{let d=c.data;return d!=null&&d.points?w(b({},c),{data:w(b({},d),{points:d.points.map(p=>({x:p.x-i,y:p.y-a}))})}):c});return{nodes:s,edges:l}},ra=e=>{var l,c;let t=e.filter(d=>!d.parentId),o=t.filter(d=>d.type==="LANE"),n=o.length>0?o:t;if(n.length===0)return null;let r=1/0,i=1/0,a=-1/0,s=-1/0;for(let d of n){let p=d.position.x+((l=d.width)!=null?l:0),m=d.position.y+((c=d.height)!=null?c:0);d.position.x<r&&(r=d.position.x),d.position.y<i&&(i=d.position.y),p>a&&(a=p),m>s&&(s=m)}return{x:r,y:i,width:a-r,height:s-i}};var Li=(e,t)=>{let o=t.find(a=>a.id===e);if(!o||o.type!=="LANE"||o.parentId)return!1;let n=ot(o),r=n.x+n.w,i=n.y+n.h;return t.some(a=>{if(a.id===e||a.parentId||a.type==="LANE")return!1;let s=ot(a);return s.x<r&&s.x+s.w>n.x&&s.y<i&&s.y+s.h>n.y})};var Mp=50,eo=(e,t)=>{var m,u,g,E,f,h,y,x,v,N,T,_,I,S,P,R;let o=t.find(M=>M.id===e);if(!o)return t;let n=(u=(m=o.position)==null?void 0:m.x)!=null?u:0,r=(E=(g=o.position)==null?void 0:g.y)!=null?E:0,i=(h=(f=o.measured)==null?void 0:f.width)!=null?h:0,a=(x=(y=o.measured)==null?void 0:y.height)!=null?x:0,s=r+a,l=n+i,c=new Set,d=1/0;for(let M of t){if(M.id===e||M.parentId)continue;let B=(N=(v=M.position)==null?void 0:v.y)!=null?N:0,X=(_=(T=M.position)==null?void 0:T.x)!=null?_:0,U=(S=(I=M.measured)==null?void 0:I.width)!=null?S:0,Q=(R=(P=M.measured)==null?void 0:P.height)!=null?R:0;X<l&&X+U>n&&B<s&&B+Q>r&&(c.add(M.id),d=Math.min(d,B))}if(c.size===0)return t;let p=s+Mp-d;return t.map(M=>{var X,U,Q;if(!c.has(M.id))return M;let B=(U=(X=M.position)==null?void 0:X.y)!=null?U:0;return w(b({},M),{position:w(b({},(Q=M.position)!=null?Q:{x:0,y:0}),{y:B+p})})})},Ne=15,to=e=>[...e].sort((t,o)=>t.position.y-o.position.y),Pp=e=>{var t,o,n;return e.position.x+((n=(o=(t=e.measured)==null?void 0:t.width)!=null?o:e.width)!=null?n:0)},Lp=e=>{var t,o,n;return e.position.y+((n=(o=(t=e.measured)==null?void 0:t.height)!=null?o:e.height)!=null?n:0)},ki=(e,t,o)=>{var d,p,m,u,g,E,f,h,y,x,v,N,T,_,I;if(t.length===0)return e;let n=(m=(p=e.width)!=null?p:(d=e.measured)==null?void 0:d.width)!=null?m:0,r=(E=(g=e.height)!=null?g:(u=e.measured)==null?void 0:u.height)!=null?E:0,i=0,a=0;for(let S of t){let P=Pp(S),R=Lp(S);if(((h=(f=S.position)==null?void 0:f.y)!=null?h:0)<Ne&&(o.set(S.id,w(b({},S),{position:w(b({},S.position),{y:Ne})})),R=Ne+((x=(y=S.measured)==null?void 0:y.height)!=null?x:0)),((N=(v=S.position)==null?void 0:v.x)!=null?N:0)<ie.HEADER_WIDTH+Ne){let M=(T=o.get(S.id))!=null?T:S;o.set(S.id,w(b({},M),{position:w(b({},M.position),{x:ie.HEADER_WIDTH+Ne})})),P=ie.HEADER_WIDTH+Ne+((I=(_=S.measured)==null?void 0:_.width)!=null?I:0)}i=Math.max(i,P),a=Math.max(a,R)}let s=Math.max(n,ie.MIN_WIDTH),l=Math.max(r,ie.MIN_HEIGHT);i+Ne>s&&(s=i+Ne),a+Ne>l&&(l=a+Ne);let c=w(b({},e),{width:s,height:l,measured:w(b({},e.measured),{width:s,height:l})});return o.set(e.id,c),c},ia=(e,t,o)=>{var a,s;let n=to(e),r=new Map;for(let l of o)l.parentId&&(r.has(l.parentId)||r.set(l.parentId,[]),r.get(l.parentId).push(l));let i=0;for(let l of n){let c=(a=r.get(l.id))!=null?a:[],d=ki(l,c,t);t.set(d.id,w(b({},d),{position:{x:ie.HEADER_WIDTH,y:i}})),i+=(s=d.height)!=null?s:0}},sa=(e,t)=>{var g,E,f,h;let o=[];for(let y of t.values())y.parentId===e.id&&o.push(y);let n=to(o),r=((E=(g=e.measured)==null?void 0:g.width)!=null?E:0)-ie.HEADER_WIDTH,i=oa(e.id,o)||ie.MIN_WIDTH,a=o.reduce((y,x)=>{var v;return y+((v=x.height)!=null?v:ie.MIN_HEIGHT)},0),s=Math.max(r,i),l=a,c=r>i,d=c?s:s+ie.HEADER_WIDTH,p=c?s-ie.HEADER_WIDTH:s,m=0;for(let y=0;y<n.length;y++){let x=n[y],v=Math.max(ie.MIN_HEIGHT,(f=x.height)!=null?f:ie.MIN_HEIGHT),N=w(b({},x),{width:p,height:v,measured:w(b({},x.measured),{width:p,height:v}),position:{x:ie.HEADER_WIDTH,y:m}});if(y===o.length-1){let T=Math.max(ie.MIN_HEIGHT,l-m);N=w(b({},N),{height:T,measured:w(b({},x.measured),{width:p,height:T})})}t.set(x.id,N),m+=(h=N.height)!=null?h:0}let u=Math.max(l,m);t.set(e.id,w(b({},e),{width:d,height:u,measured:w(b({},e.measured),{width:d,height:u})}))},aa=(e,t,o,n,r)=>{var g,E;let i=!e.parentId,a=i?e.id:e.parentId,s=n.filter(f=>f.type==="LANE"&&f.parentId===a);if(!s.length)return n;let l=to(s),c=l.findIndex(f=>f.id===e.id),d=(E=(g=e.position)==null?void 0:g.y)!=null?E:0,p=!i&&r!==void 0&&c>0&&Math.abs(r-d)>.5,m=0,u=[...n];return l.forEach((f,h)=>{var T,_;let y=h===l.length-1,x=f.id===e.id,N=(_=(T=f.measured)==null?void 0:T.height)!=null?_:0;x?N=o:p&&h===c-1&&(N=Math.max(ie.MIN_HEIGHT,r-m)),y&&i&&(N=Math.max(ie.MIN_HEIGHT,o-m)),u=u.map(I=>{if(I.id===f.id){let S=i?t-ie.HEADER_WIDTH:t;return w(b({},I),{width:S,height:N,measured:w(b({},I.measured),{width:S,height:N}),position:{x:ie.HEADER_WIDTH,y:m}})}return I}),x&&p?m=r+o:m+=N}),u=u.map(f=>{if(f.id===a){let h=i?t:t+ie.HEADER_WIDTH;return w(b({},f),{width:h,height:i?o:m,measured:{width:h,height:i?o:m}})}return f}),u};var Ri=(e,t,o)=>{var s,l,c,d,p,m,u,g;if(e.type==="LANE")return o;let n=(l=(s=t.measured)==null?void 0:s.width)!=null?l:0,r=(d=(c=t.measured)==null?void 0:c.height)!=null?d:0;e.position.y<Ne&&(e.position.y=Ne),e.position.x<ie.HEADER_WIDTH+Ne&&(e.position.x=ie.HEADER_WIDTH+Ne);let i=e.position.x+((m=(p=e.measured)==null?void 0:p.width)!=null?m:0),a=e.position.y+((g=(u=e.measured)==null?void 0:u.height)!=null?g:0);return i+Ne>n&&(t.width=i+Ne,t.measured.width=i+Ne),a+Ne>r&&(t.height=a+Ne,t.measured.height=a+Ne),o=o.map(E=>E.id===t.id?w(b({},E),{height:t.height,width:t.width,measured:t.measured}):E.id===e.id?w(b({},E),{position:e.position}):E),o};import{create as kp}from"zustand";import{useReactFlow as Rp}from"@xyflow/react";import{useCallback as Dp}from"react";var Un=()=>{let{setEdges:e}=Rp();return Dp(()=>{let o=oo.getState().pathEdgeIds;e(n=>n.map(r=>w(b({},r),{selected:o.includes(r.id)})))},[e])},oo=kp((e,t)=>({statusByNodeId:{},statusData:{},pathEdgeIds:[],setTaskStatuses:o=>{o!=null&&o.length&&e(n=>{let r=b({},n.statusByNodeId),i=b({},n.statusData),a=!1;return o.forEach(s=>{let l=`${s.diagramId}-${s.activityId}`;r[s.diagramId]!==s.status&&(r[s.diagramId]=s.status,i[l]=s,a=!0)}),a?{statusByNodeId:r,statusData:i}:n})},getTaskStatus:o=>t().statusByNodeId[o]||null,clearTaskStatuses:()=>e({statusByNodeId:{},statusData:{},pathEdgeIds:[]}),setPathEdges:o=>{e({pathEdgeIds:o})},getPathEdgeIds:()=>t().pathEdgeIds,clearPathEdges:()=>{e({pathEdgeIds:[]})},calculateFlowPath:(o,n)=>{if(!o.length||!n.length)return;t().clearPathEdges();let r=n.filter(d=>t().statusByNodeId[d]);if(r.length<=1)return;let i=[],a={};o.forEach(d=>{a[d.source]||(a[d.source]=[]),a[d.source].push({targetId:d.target,edgeId:d.id})});let s=r[0],l=r[r.length-1];o.forEach(d=>{d.target===s&&i.push(d.id)}),o.forEach(d=>{d.source===l&&i.push(d.id)});let c=(d,p)=>{let m=[],u=new Set;for(m.push({node:d,path:[]}),u.add(d);m.length>0;){let{node:g,path:E}=m.shift();if(g===p)return E;let f=a[g]||[];for(let{targetId:h,edgeId:y}of f)u.has(h)||(u.add(h),m.push({node:h,path:[...E,y]}))}return[]};for(let d=0;d<r.length-1;d++){let p=r[d],m=r[d+1],u=c(p,m);u.length>0&&i.push(...u)}i.length>0&&e({pathEdgeIds:i})}}));import{useNodesInitialized as Jm,useReactFlow as Qm,useStore as jm}from"@xyflow/react";import{useCallback as gn,useEffect as eg,useRef as tg,useState as tc}from"react";import{shallow as og}from"zustand/shallow";var Op={value:()=>{}};function ca(){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 $n(o)}function $n(e){this._=e}function Vp(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}})}$n.prototype=ca.prototype={constructor:$n,on:function(e,t){var o=this._,n=Vp(e+"",o),r,i=-1,a=n.length;if(arguments.length<2){for(;++i<a;)if((r=(e=n[i]).type)&&(r=Hp(o[r],e.name)))return r;return}if(t!=null&&typeof t!="function")throw new Error("invalid callback: "+t);for(;++i<a;)if(r=(e=n[i]).type)o[r]=la(o[r],e.name,t);else if(t==null)for(r in o)o[r]=la(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 $n(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 Hp(e,t){for(var o=0,n=e.length,r;o<n;++o)if((r=e[o]).name===t)return r.value}function la(e,t,o){for(var n=0,r=e.length;n<r;++n)if(e[n].name===t){e[n]=Op,e=e.slice(0,n).concat(e.slice(n+1));break}return o!=null&&e.push({name:t,value:o}),e}var Di=ca;var Kn="http://www.w3.org/1999/xhtml",Oi={svg:"http://www.w3.org/2000/svg",xhtml:Kn,xlink:"http://www.w3.org/1999/xlink",xml:"http://www.w3.org/XML/1998/namespace",xmlns:"http://www.w3.org/2000/xmlns/"};function _t(e){var t=e+="",o=t.indexOf(":");return o>=0&&(t=e.slice(0,o))!=="xmlns"&&(e=e.slice(o+1)),Oi.hasOwnProperty(t)?{space:Oi[t],local:e}:e}function Gp(e){return function(){var t=this.ownerDocument,o=this.namespaceURI;return o===Kn&&t.documentElement.namespaceURI===Kn?t.createElement(e):t.createElementNS(o,e)}}function Bp(e){return function(){return this.ownerDocument.createElementNS(e.space,e.local)}}function qn(e){var t=_t(e);return(t.local?Bp:Gp)(t)}function zp(){}function no(e){return e==null?zp:function(){return this.querySelector(e)}}function da(e){typeof e!="function"&&(e=no(e));for(var t=this._groups,o=t.length,n=new Array(o),r=0;r<o;++r)for(var i=t[r],a=i.length,s=n[r]=new Array(a),l,c,d=0;d<a;++d)(l=i[d])&&(c=e.call(l,l.__data__,d,i))&&("__data__"in l&&(c.__data__=l.__data__),s[d]=c);return new Ie(n,this._parents)}function Vi(e){return e==null?[]:Array.isArray(e)?e:Array.from(e)}function Yp(){return[]}function en(e){return e==null?Yp:function(){return this.querySelectorAll(e)}}function Wp(e){return function(){return Vi(e.apply(this,arguments))}}function ua(e){typeof e=="function"?e=Wp(e):e=en(e);for(var t=this._groups,o=t.length,n=[],r=[],i=0;i<o;++i)for(var a=t[i],s=a.length,l,c=0;c<s;++c)(l=a[c])&&(n.push(e.call(l,l.__data__,c,a)),r.push(l));return new Ie(n,r)}function tn(e){return function(){return this.matches(e)}}function Zn(e){return function(t){return t.matches(e)}}var Fp=Array.prototype.find;function Xp(e){return function(){return Fp.call(this.children,e)}}function Up(){return this.firstElementChild}function pa(e){return this.select(e==null?Up:Xp(typeof e=="function"?e:Zn(e)))}var $p=Array.prototype.filter;function Kp(){return Array.from(this.children)}function qp(e){return function(){return $p.call(this.children,e)}}function fa(e){return this.selectAll(e==null?Kp:qp(typeof e=="function"?e:Zn(e)))}function ma(e){typeof e!="function"&&(e=tn(e));for(var t=this._groups,o=t.length,n=new Array(o),r=0;r<o;++r)for(var i=t[r],a=i.length,s=n[r]=[],l,c=0;c<a;++c)(l=i[c])&&e.call(l,l.__data__,c,i)&&s.push(l);return new Ie(n,this._parents)}function Jn(e){return new Array(e.length)}function ga(){return new Ie(this._enter||this._groups.map(Jn),this._parents)}function on(e,t){this.ownerDocument=e.ownerDocument,this.namespaceURI=e.namespaceURI,this._next=null,this._parent=e,this.__data__=t}on.prototype={constructor:on,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 ha(e){return function(){return e}}function Zp(e,t,o,n,r,i){for(var a=0,s,l=t.length,c=i.length;a<c;++a)(s=t[a])?(s.__data__=i[a],n[a]=s):o[a]=new on(e,i[a]);for(;a<l;++a)(s=t[a])&&(r[a]=s)}function Jp(e,t,o,n,r,i,a){var s,l,c=new Map,d=t.length,p=i.length,m=new Array(d),u;for(s=0;s<d;++s)(l=t[s])&&(m[s]=u=a.call(l,l.__data__,s,t)+"",c.has(u)?r[s]=l:c.set(u,l));for(s=0;s<p;++s)u=a.call(e,i[s],s,i)+"",(l=c.get(u))?(n[s]=l,l.__data__=i[s],c.delete(u)):o[s]=new on(e,i[s]);for(s=0;s<d;++s)(l=t[s])&&c.get(m[s])===l&&(r[s]=l)}function Qp(e){return e.__data__}function ya(e,t){if(!arguments.length)return Array.from(this,Qp);var o=t?Jp:Zp,n=this._parents,r=this._groups;typeof e!="function"&&(e=ha(e));for(var i=r.length,a=new Array(i),s=new Array(i),l=new Array(i),c=0;c<i;++c){var d=n[c],p=r[c],m=p.length,u=jp(e.call(d,d&&d.__data__,c,n)),g=u.length,E=s[c]=new Array(g),f=a[c]=new Array(g),h=l[c]=new Array(m);o(d,p,E,f,h,u,t);for(var y=0,x=0,v,N;y<g;++y)if(v=E[y]){for(y>=x&&(x=y+1);!(N=f[x])&&++x<g;);v._next=N||null}}return a=new Ie(a,n),a._enter=s,a._exit=l,a}function jp(e){return typeof e=="object"&&"length"in e?e:Array.from(e)}function xa(){return new Ie(this._exit||this._groups.map(Jn),this._parents)}function Ea(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 ba(e){for(var t=e.selection?e.selection():e,o=this._groups,n=t._groups,r=o.length,i=n.length,a=Math.min(r,i),s=new Array(r),l=0;l<a;++l)for(var c=o[l],d=n[l],p=c.length,m=s[l]=new Array(p),u,g=0;g<p;++g)(u=c[g]||d[g])&&(m[g]=u);for(;l<r;++l)s[l]=o[l];return new Ie(s,this._parents)}function _a(){for(var e=this._groups,t=-1,o=e.length;++t<o;)for(var n=e[t],r=n.length-1,i=n[r],a;--r>=0;)(a=n[r])&&(i&&a.compareDocumentPosition(i)^4&&i.parentNode.insertBefore(a,i),i=a);return this}function Na(e){e||(e=ef);function t(p,m){return p&&m?e(p.__data__,m.__data__):!p-!m}for(var o=this._groups,n=o.length,r=new Array(n),i=0;i<n;++i){for(var a=o[i],s=a.length,l=r[i]=new Array(s),c,d=0;d<s;++d)(c=a[d])&&(l[d]=c);l.sort(t)}return new Ie(r,this._parents).order()}function ef(e,t){return e<t?-1:e>t?1:e>=t?0:NaN}function Ta(){var e=arguments[0];return arguments[0]=this,e.apply(null,arguments),this}function va(){return Array.from(this)}function wa(){for(var e=this._groups,t=0,o=e.length;t<o;++t)for(var n=e[t],r=0,i=n.length;r<i;++r){var a=n[r];if(a)return a}return null}function Ia(){let e=0;for(let t of this)++e;return e}function Aa(){return!this.node()}function Ca(e){for(var t=this._groups,o=0,n=t.length;o<n;++o)for(var r=t[o],i=0,a=r.length,s;i<a;++i)(s=r[i])&&e.call(s,s.__data__,i,r);return this}function tf(e){return function(){this.removeAttribute(e)}}function of(e){return function(){this.removeAttributeNS(e.space,e.local)}}function nf(e,t){return function(){this.setAttribute(e,t)}}function rf(e,t){return function(){this.setAttributeNS(e.space,e.local,t)}}function sf(e,t){return function(){var o=t.apply(this,arguments);o==null?this.removeAttribute(e):this.setAttribute(e,o)}}function af(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 Sa(e,t){var o=_t(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?of:tf:typeof t=="function"?o.local?af:sf:o.local?rf:nf)(o,t))}function Qn(e){return e.ownerDocument&&e.ownerDocument.defaultView||e.document&&e||e.defaultView}function lf(e){return function(){this.style.removeProperty(e)}}function cf(e,t,o){return function(){this.style.setProperty(e,t,o)}}function df(e,t,o){return function(){var n=t.apply(this,arguments);n==null?this.style.removeProperty(e):this.style.setProperty(e,n,o)}}function Ma(e,t,o){return arguments.length>1?this.each((t==null?lf:typeof t=="function"?df:cf)(e,t,o==null?"":o)):Dt(this.node(),e)}function Dt(e,t){return e.style.getPropertyValue(t)||Qn(e).getComputedStyle(e,null).getPropertyValue(t)}function uf(e){return function(){delete this[e]}}function pf(e,t){return function(){this[e]=t}}function ff(e,t){return function(){var o=t.apply(this,arguments);o==null?delete this[e]:this[e]=o}}function Pa(e,t){return arguments.length>1?this.each((t==null?uf:typeof t=="function"?ff:pf)(e,t)):this.node()[e]}function La(e){return e.trim().split(/^|\s+/)}function Hi(e){return e.classList||new ka(e)}function ka(e){this._node=e,this._names=La(e.getAttribute("class")||"")}ka.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 Ra(e,t){for(var o=Hi(e),n=-1,r=t.length;++n<r;)o.add(t[n])}function Da(e,t){for(var o=Hi(e),n=-1,r=t.length;++n<r;)o.remove(t[n])}function mf(e){return function(){Ra(this,e)}}function gf(e){return function(){Da(this,e)}}function hf(e,t){return function(){(t.apply(this,arguments)?Ra:Da)(this,e)}}function Oa(e,t){var o=La(e+"");if(arguments.length<2){for(var n=Hi(this.node()),r=-1,i=o.length;++r<i;)if(!n.contains(o[r]))return!1;return!0}return this.each((typeof t=="function"?hf:t?mf:gf)(o,t))}function yf(){this.textContent=""}function xf(e){return function(){this.textContent=e}}function Ef(e){return function(){var t=e.apply(this,arguments);this.textContent=t==null?"":t}}function Va(e){return arguments.length?this.each(e==null?yf:(typeof e=="function"?Ef:xf)(e)):this.node().textContent}function bf(){this.innerHTML=""}function _f(e){return function(){this.innerHTML=e}}function Nf(e){return function(){var t=e.apply(this,arguments);this.innerHTML=t==null?"":t}}function Ha(e){return arguments.length?this.each(e==null?bf:(typeof e=="function"?Nf:_f)(e)):this.node().innerHTML}function Tf(){this.nextSibling&&this.parentNode.appendChild(this)}function Ga(){return this.each(Tf)}function vf(){this.previousSibling&&this.parentNode.insertBefore(this,this.parentNode.firstChild)}function Ba(){return this.each(vf)}function za(e){var t=typeof e=="function"?e:qn(e);return this.select(function(){return this.appendChild(t.apply(this,arguments))})}function wf(){return null}function Ya(e,t){var o=typeof e=="function"?e:qn(e),n=t==null?wf:typeof t=="function"?t:no(t);return this.select(function(){return this.insertBefore(o.apply(this,arguments),n.apply(this,arguments)||null)})}function If(){var e=this.parentNode;e&&e.removeChild(this)}function Wa(){return this.each(If)}function Af(){var e=this.cloneNode(!1),t=this.parentNode;return t?t.insertBefore(e,this.nextSibling):e}function Cf(){var e=this.cloneNode(!0),t=this.parentNode;return t?t.insertBefore(e,this.nextSibling):e}function Fa(e){return this.select(e?Cf:Af)}function Xa(e){return arguments.length?this.property("__data__",e):this.node().__data__}function Sf(e){return function(t){e.call(this,t,this.__data__)}}function Mf(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 Pf(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 Lf(e,t,o){return function(){var n=this.__on,r,i=Sf(t);if(n){for(var a=0,s=n.length;a<s;++a)if((r=n[a]).type===e.type&&r.name===e.name){this.removeEventListener(r.type,r.listener,r.options),this.addEventListener(r.type,r.listener=i,r.options=o),r.value=t;return}}this.addEventListener(e.type,i,o),r={type:e.type,name:e.name,value:t,listener:i,options:o},n?n.push(r):this.__on=[r]}}function Ua(e,t,o){var n=Mf(e+""),r,i=n.length,a;if(arguments.length<2){var s=this.node().__on;if(s){for(var l=0,c=s.length,d;l<c;++l)for(r=0,d=s[l];r<i;++r)if((a=n[r]).type===d.type&&a.name===d.name)return d.value}return}for(s=t?Lf:Pf,r=0;r<i;++r)this.each(s(n[r],t,o));return this}function $a(e,t,o){var n=Qn(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 kf(e,t){return function(){return $a(this,e,t)}}function Rf(e,t){return function(){return $a(this,e,t.apply(this,arguments))}}function Ka(e,t){return this.each((typeof t=="function"?Rf:kf)(e,t))}function*qa(){for(var e=this._groups,t=0,o=e.length;t<o;++t)for(var n=e[t],r=0,i=n.length,a;r<i;++r)(a=n[r])&&(yield a)}var Df=[null];function Ie(e,t){this._groups=e,this._parents=t}function Za(){return new Ie([[document.documentElement]],Df)}function Of(){return this}Ie.prototype=Za.prototype={constructor:Ie,select:da,selectAll:ua,selectChild:pa,selectChildren:fa,filter:ma,data:ya,enter:ga,exit:xa,join:Ea,merge:ba,selection:Of,order:_a,sort:Na,call:Ta,nodes:va,node:wa,size:Ia,empty:Aa,each:Ca,attr:Sa,style:Ma,property:Pa,classed:Oa,text:Va,html:Ha,raise:Ga,lower:Ba,append:za,insert:Ya,remove:Wa,clone:Fa,datum:Xa,on:Ua,dispatch:Ka,[Symbol.iterator]:qa};var Nt=Za;function jn(e,t,o){e.prototype=t.prototype=o,o.constructor=e}function Gi(e,t){var o=Object.create(e.prototype);for(var n in t)o[n]=t[n];return o}function sn(){}var nn=.7,or=1/nn,wo="\\s*([+-]?\\d+)\\s*",rn="\\s*([+-]?(?:\\d*\\.)?\\d+(?:[eE][+-]?\\d+)?)\\s*",ht="\\s*([+-]?(?:\\d*\\.)?\\d+(?:[eE][+-]?\\d+)?)%\\s*",Vf=/^#([0-9a-f]{3,8})$/,Hf=new RegExp(`^rgb\\(${wo},${wo},${wo}\\)$`),Gf=new RegExp(`^rgb\\(${ht},${ht},${ht}\\)$`),Bf=new RegExp(`^rgba\\(${wo},${wo},${wo},${rn}\\)$`),zf=new RegExp(`^rgba\\(${ht},${ht},${ht},${rn}\\)$`),Yf=new RegExp(`^hsl\\(${rn},${ht},${ht}\\)$`),Wf=new RegExp(`^hsla\\(${rn},${ht},${ht},${rn}\\)$`),Ja={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};jn(sn,Ot,{copy(e){return Object.assign(new this.constructor,this,e)},displayable(){return this.rgb().displayable()},hex:Qa,formatHex:Qa,formatHex8:Ff,formatHsl:Xf,formatRgb:ja,toString:ja});function Qa(){return this.rgb().formatHex()}function Ff(){return this.rgb().formatHex8()}function Xf(){return il(this).formatHsl()}function ja(){return this.rgb().formatRgb()}function Ot(e){var t,o;return e=(e+"").trim().toLowerCase(),(t=Vf.exec(e))?(o=t[1].length,t=parseInt(t[1],16),o===6?el(t):o===3?new ze(t>>8&15|t>>4&240,t>>4&15|t&240,(t&15)<<4|t&15,1):o===8?er(t>>24&255,t>>16&255,t>>8&255,(t&255)/255):o===4?er(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=Hf.exec(e))?new ze(t[1],t[2],t[3],1):(t=Gf.exec(e))?new ze(t[1]*255/100,t[2]*255/100,t[3]*255/100,1):(t=Bf.exec(e))?er(t[1],t[2],t[3],t[4]):(t=zf.exec(e))?er(t[1]*255/100,t[2]*255/100,t[3]*255/100,t[4]):(t=Yf.exec(e))?nl(t[1],t[2]/100,t[3]/100,1):(t=Wf.exec(e))?nl(t[1],t[2]/100,t[3]/100,t[4]):Ja.hasOwnProperty(e)?el(Ja[e]):e==="transparent"?new ze(NaN,NaN,NaN,0):null}function el(e){return new ze(e>>16&255,e>>8&255,e&255,1)}function er(e,t,o,n){return n<=0&&(e=t=o=NaN),new ze(e,t,o,n)}function Uf(e){return e instanceof sn||(e=Ot(e)),e?(e=e.rgb(),new ze(e.r,e.g,e.b,e.opacity)):new ze}function Io(e,t,o,n){return arguments.length===1?Uf(e):new ze(e,t,o,n==null?1:n)}function ze(e,t,o,n){this.r=+e,this.g=+t,this.b=+o,this.opacity=+n}jn(ze,Io,Gi(sn,{brighter(e){return e=e==null?or:Math.pow(or,e),new ze(this.r*e,this.g*e,this.b*e,this.opacity)},darker(e){return e=e==null?nn:Math.pow(nn,e),new ze(this.r*e,this.g*e,this.b*e,this.opacity)},rgb(){return this},clamp(){return new ze(io(this.r),io(this.g),io(this.b),nr(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:tl,formatHex:tl,formatHex8:$f,formatRgb:ol,toString:ol}));function tl(){return`#${ro(this.r)}${ro(this.g)}${ro(this.b)}`}function $f(){return`#${ro(this.r)}${ro(this.g)}${ro(this.b)}${ro((isNaN(this.opacity)?1:this.opacity)*255)}`}function ol(){let e=nr(this.opacity);return`${e===1?"rgb(":"rgba("}${io(this.r)}, ${io(this.g)}, ${io(this.b)}${e===1?")":`, ${e})`}`}function nr(e){return isNaN(e)?1:Math.max(0,Math.min(1,e))}function io(e){return Math.max(0,Math.min(255,Math.round(e)||0))}function ro(e){return e=io(e),(e<16?"0":"")+e.toString(16)}function nl(e,t,o,n){return n<=0?e=t=o=NaN:o<=0||o>=1?e=t=NaN:t<=0&&(e=NaN),new lt(e,t,o,n)}function il(e){if(e instanceof lt)return new lt(e.h,e.s,e.l,e.opacity);if(e instanceof sn||(e=Ot(e)),!e)return new lt;if(e instanceof lt)return e;e=e.rgb();var t=e.r/255,o=e.g/255,n=e.b/255,r=Math.min(t,o,n),i=Math.max(t,o,n),a=NaN,s=i-r,l=(i+r)/2;return s?(t===i?a=(o-n)/s+(o<n)*6:o===i?a=(n-t)/s+2:a=(t-o)/s+4,s/=l<.5?i+r:2-i-r,a*=60):s=l>0&&l<1?0:a,new lt(a,s,l,e.opacity)}function sl(e,t,o,n){return arguments.length===1?il(e):new lt(e,t,o,n==null?1:n)}function lt(e,t,o,n){this.h=+e,this.s=+t,this.l=+o,this.opacity=+n}jn(lt,sl,Gi(sn,{brighter(e){return e=e==null?or:Math.pow(or,e),new lt(this.h,this.s,this.l*e,this.opacity)},darker(e){return e=e==null?nn:Math.pow(nn,e),new lt(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 ze(Bi(e>=240?e-240:e+120,r,n),Bi(e,r,n),Bi(e<120?e+240:e-120,r,n),this.opacity)},clamp(){return new lt(rl(this.h),tr(this.s),tr(this.l),nr(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=nr(this.opacity);return`${e===1?"hsl(":"hsla("}${rl(this.h)}, ${tr(this.s)*100}%, ${tr(this.l)*100}%${e===1?")":`, ${e})`}`}}));function rl(e){return e=(e||0)%360,e<0?e+360:e}function tr(e){return Math.max(0,Math.min(1,e||0))}function Bi(e,t,o){return(e<60?t+(o-t)*e/60:e<180?o:e<240?t+(o-t)*(240-e)/60:t)*255}function zi(e,t,o,n,r){var i=e*e,a=i*e;return((1-3*e+3*i-a)*t+(4-6*i+3*a)*o+(1+3*e+3*i-3*a)*n+a*r)/6}function al(e){var t=e.length-1;return function(o){var n=o<=0?o=0:o>=1?(o=1,t-1):Math.floor(o*t),r=e[n],i=e[n+1],a=n>0?e[n-1]:2*r-i,s=n<t-1?e[n+2]:2*i-r;return zi((o-n/t)*t,a,r,i,s)}}function ll(e){var t=e.length;return function(o){var n=Math.floor(((o%=1)<0?++o:o)*t),r=e[(n+t-1)%t],i=e[n%t],a=e[(n+1)%t],s=e[(n+2)%t];return zi((o-n/t)*t,r,i,a,s)}}var Yi=e=>()=>e;function Kf(e,t){return function(o){return e+o*t}}function qf(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 cl(e){return(e=+e)==1?rr:function(t,o){return o-t?qf(t,o,e):Yi(isNaN(t)?o:t)}}function rr(e,t){var o=t-e;return o?Kf(e,o):Yi(isNaN(e)?t:e)}var ir=function e(t){var o=cl(t);function n(r,i){var a=o((r=Io(r)).r,(i=Io(i)).r),s=o(r.g,i.g),l=o(r.b,i.b),c=rr(r.opacity,i.opacity);return function(d){return r.r=a(d),r.g=s(d),r.b=l(d),r.opacity=c(d),r+""}}return n.gamma=e,n}(1);function dl(e){return function(t){var o=t.length,n=new Array(o),r=new Array(o),i=new Array(o),a,s;for(a=0;a<o;++a)s=Io(t[a]),n[a]=s.r||0,r[a]=s.g||0,i[a]=s.b||0;return n=e(n),r=e(r),i=e(i),s.opacity=1,function(l){return s.r=n(l),s.g=r(l),s.b=i(l),s+""}}}var Zf=dl(al),Jf=dl(ll);function nt(e,t){return e=+e,t=+t,function(o){return e*(1-o)+t*o}}var Fi=/[-+]?(?:\d+\.?\d*|\.?\d+)(?:[eE][-+]?\d+)?/g,Wi=new RegExp(Fi.source,"g");function Qf(e){return function(){return e}}function jf(e){return function(t){return e(t)+""}}function Xi(e,t){var o=Fi.lastIndex=Wi.lastIndex=0,n,r,i,a=-1,s=[],l=[];for(e=e+"",t=t+"";(n=Fi.exec(e))&&(r=Wi.exec(t));)(i=r.index)>o&&(i=t.slice(o,i),s[a]?s[a]+=i:s[++a]=i),(n=n[0])===(r=r[0])?s[a]?s[a]+=r:s[++a]=r:(s[++a]=null,l.push({i:a,x:nt(n,r)})),o=Wi.lastIndex;return o<t.length&&(i=t.slice(o),s[a]?s[a]+=i:s[++a]=i),s.length<2?l[0]?jf(l[0].x):Qf(t):(t=l.length,function(c){for(var d=0,p;d<t;++d)s[(p=l[d]).i]=p.x(c);return s.join("")})}var ul=180/Math.PI,sr={translateX:0,translateY:0,rotate:0,skewX:0,scaleX:1,scaleY:1};function Ui(e,t,o,n,r,i){var a,s,l;return(a=Math.sqrt(e*e+t*t))&&(e/=a,t/=a),(l=e*o+t*n)&&(o-=e*l,n-=t*l),(s=Math.sqrt(o*o+n*n))&&(o/=s,n/=s,l/=s),e*n<t*o&&(e=-e,t=-t,l=-l,a=-a),{translateX:r,translateY:i,rotate:Math.atan2(t,e)*ul,skewX:Math.atan(l)*ul,scaleX:a,scaleY:s}}var ar;function pl(e){let t=new(typeof DOMMatrix=="function"?DOMMatrix:WebKitCSSMatrix)(e+"");return t.isIdentity?sr:Ui(t.a,t.b,t.c,t.d,t.e,t.f)}function fl(e){return e==null?sr:(ar||(ar=document.createElementNS("http://www.w3.org/2000/svg","g")),ar.setAttribute("transform",e),(e=ar.transform.baseVal.consolidate())?(e=e.matrix,Ui(e.a,e.b,e.c,e.d,e.e,e.f)):sr)}function ml(e,t,o,n){function r(c){return c.length?c.pop()+" ":""}function i(c,d,p,m,u,g){if(c!==p||d!==m){var E=u.push("translate(",null,t,null,o);g.push({i:E-4,x:nt(c,p)},{i:E-2,x:nt(d,m)})}else(p||m)&&u.push("translate("+p+t+m+o)}function a(c,d,p,m){c!==d?(c-d>180?d+=360:d-c>180&&(c+=360),m.push({i:p.push(r(p)+"rotate(",null,n)-2,x:nt(c,d)})):d&&p.push(r(p)+"rotate("+d+n)}function s(c,d,p,m){c!==d?m.push({i:p.push(r(p)+"skewX(",null,n)-2,x:nt(c,d)}):d&&p.push(r(p)+"skewX("+d+n)}function l(c,d,p,m,u,g){if(c!==p||d!==m){var E=u.push(r(u)+"scale(",null,",",null,")");g.push({i:E-4,x:nt(c,p)},{i:E-2,x:nt(d,m)})}else(p!==1||m!==1)&&u.push(r(u)+"scale("+p+","+m+")")}return function(c,d){var p=[],m=[];return c=e(c),d=e(d),i(c.translateX,c.translateY,d.translateX,d.translateY,p,m),a(c.rotate,d.rotate,p,m),s(c.skewX,d.skewX,p,m),l(c.scaleX,c.scaleY,d.scaleX,d.scaleY,p,m),c=d=null,function(u){for(var g=-1,E=m.length,f;++g<E;)p[(f=m[g]).i]=f.x(u);return p.join("")}}}var $i=ml(pl,"px, ","px)","deg)"),Ki=ml(fl,", ",")",")");var Ao=0,ln=0,an=0,hl=1e3,lr,cn,cr=0,so=0,dr=0,dn=typeof performance=="object"&&performance.now?performance:Date,yl=typeof window=="object"&&window.requestAnimationFrame?window.requestAnimationFrame.bind(window):function(e){setTimeout(e,17)};function pn(){return so||(yl(em),so=dn.now()+dr)}function em(){so=0}function un(){this._call=this._time=this._next=null}un.prototype=ur.prototype={constructor:un,restart:function(e,t,o){if(typeof e!="function")throw new TypeError("callback is not a function");o=(o==null?pn():+o)+(t==null?0:+t),!this._next&&cn!==this&&(cn?cn._next=this:lr=this,cn=this),this._call=e,this._time=o,qi()},stop:function(){this._call&&(this._call=null,this._time=1/0,qi())}};function ur(e,t,o){var n=new un;return n.restart(e,t,o),n}function xl(){pn(),++Ao;for(var e=lr,t;e;)(t=so-e._time)>=0&&e._call.call(void 0,t),e=e._next;--Ao}function gl(){so=(cr=dn.now())+dr,Ao=ln=0;try{xl()}finally{Ao=0,om(),so=0}}function tm(){var e=dn.now(),t=e-cr;t>hl&&(dr-=t,cr=e)}function om(){for(var e,t=lr,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:lr=o);cn=e,qi(n)}function qi(e){if(!Ao){ln&&(ln=clearTimeout(ln));var t=e-so;t>24?(e<1/0&&(ln=setTimeout(gl,e-dn.now()-dr)),an&&(an=clearInterval(an))):(an||(cr=dn.now(),an=setInterval(tm,hl)),Ao=1,yl(gl))}}function pr(e,t,o){var n=new un;return t=t==null?0:+t,n.restart(r=>{n.stop(),e(r+t)},t,o),n}var nm=Di("start","end","cancel","interrupt"),rm=[],_l=0,El=1,mr=2,fr=3,bl=4,gr=5,fn=6;function Vt(e,t,o,n,r,i){var a=e.__transition;if(!a)e.__transition={};else if(o in a)return;im(e,o,{name:t,index:n,group:r,on:nm,tween:rm,time:i.time,delay:i.delay,duration:i.duration,ease:i.ease,timer:null,state:_l})}function mn(e,t){var o=Ae(e,t);if(o.state>_l)throw new Error("too late; already scheduled");return o}function Le(e,t){var o=Ae(e,t);if(o.state>fr)throw new Error("too late; already running");return o}function Ae(e,t){var o=e.__transition;if(!o||!(o=o[t]))throw new Error("transition not found");return o}function im(e,t,o){var n=e.__transition,r;n[t]=o,o.timer=ur(i,0,o.time);function i(c){o.state=El,o.timer.restart(a,o.delay,o.time),o.delay<=c&&a(c-o.delay)}function a(c){var d,p,m,u;if(o.state!==El)return l();for(d in n)if(u=n[d],u.name===o.name){if(u.state===fr)return pr(a);u.state===bl?(u.state=fn,u.timer.stop(),u.on.call("interrupt",e,e.__data__,u.index,u.group),delete n[d]):+d<t&&(u.state=fn,u.timer.stop(),u.on.call("cancel",e,e.__data__,u.index,u.group),delete n[d])}if(pr(function(){o.state===fr&&(o.state=bl,o.timer.restart(s,o.delay,o.time),s(c))}),o.state=mr,o.on.call("start",e,e.__data__,o.index,o.group),o.state===mr){for(o.state=fr,r=new Array(m=o.tween.length),d=0,p=-1;d<m;++d)(u=o.tween[d].value.call(e,e.__data__,o.index,o.group))&&(r[++p]=u);r.length=p+1}}function s(c){for(var d=c<o.duration?o.ease.call(null,c/o.duration):(o.timer.restart(l),o.state=gr,1),p=-1,m=r.length;++p<m;)r[p].call(e,d);o.state===gr&&(o.on.call("end",e,e.__data__,o.index,o.group),l())}function l(){o.state=fn,o.timer.stop(),delete n[t];for(var c in n)return;delete e.__transition}}function Zi(e,t){var o=e.__transition,n,r,i=!0,a;if(o){t=t==null?null:t+"";for(a in o){if((n=o[a]).name!==t){i=!1;continue}r=n.state>mr&&n.state<gr,n.state=fn,n.timer.stop(),n.on.call(r?"interrupt":"cancel",e,e.__data__,n.index,n.group),delete o[a]}i&&delete e.__transition}}function Nl(e){return this.each(function(){Zi(this,e)})}function sm(e,t){var o,n;return function(){var r=Le(this,e),i=r.tween;if(i!==o){n=o=i;for(var a=0,s=n.length;a<s;++a)if(n[a].name===t){n=n.slice(),n.splice(a,1);break}}r.tween=n}}function am(e,t,o){var n,r;if(typeof o!="function")throw new Error;return function(){var i=Le(this,e),a=i.tween;if(a!==n){r=(n=a).slice();for(var s={name:t,value:o},l=0,c=r.length;l<c;++l)if(r[l].name===t){r[l]=s;break}l===c&&r.push(s)}i.tween=r}}function Tl(e,t){var o=this._id;if(e+="",arguments.length<2){for(var n=Ae(this.node(),o).tween,r=0,i=n.length,a;r<i;++r)if((a=n[r]).name===e)return a.value;return null}return this.each((t==null?sm:am)(o,e,t))}function Co(e,t,o){var n=e._id;return e.each(function(){var r=Le(this,n);(r.value||(r.value={}))[t]=o.apply(this,arguments)}),function(r){return Ae(r,n).value[t]}}function hr(e,t){var o;return(typeof t=="number"?nt:t instanceof Ot?ir:(o=Ot(t))?(t=o,ir):Xi)(e,t)}function lm(e){return function(){this.removeAttribute(e)}}function cm(e){return function(){this.removeAttributeNS(e.space,e.local)}}function dm(e,t,o){var n,r=o+"",i;return function(){var a=this.getAttribute(e);return a===r?null:a===n?i:i=t(n=a,o)}}function um(e,t,o){var n,r=o+"",i;return function(){var a=this.getAttributeNS(e.space,e.local);return a===r?null:a===n?i:i=t(n=a,o)}}function pm(e,t,o){var n,r,i;return function(){var a,s=o(this),l;return s==null?void this.removeAttribute(e):(a=this.getAttribute(e),l=s+"",a===l?null:a===n&&l===r?i:(r=l,i=t(n=a,s)))}}function fm(e,t,o){var n,r,i;return function(){var a,s=o(this),l;return s==null?void this.removeAttributeNS(e.space,e.local):(a=this.getAttributeNS(e.space,e.local),l=s+"",a===l?null:a===n&&l===r?i:(r=l,i=t(n=a,s)))}}function vl(e,t){var o=_t(e),n=o==="transform"?Ki:hr;return this.attrTween(e,typeof t=="function"?(o.local?fm:pm)(o,n,Co(this,"attr."+e,t)):t==null?(o.local?cm:lm)(o):(o.local?um:dm)(o,n,t))}function mm(e,t){return function(o){this.setAttribute(e,t.call(this,o))}}function gm(e,t){return function(o){this.setAttributeNS(e.space,e.local,t.call(this,o))}}function hm(e,t){var o,n;function r(){var i=t.apply(this,arguments);return i!==n&&(o=(n=i)&&gm(e,i)),o}return r._value=t,r}function ym(e,t){var o,n;function r(){var i=t.apply(this,arguments);return i!==n&&(o=(n=i)&&mm(e,i)),o}return r._value=t,r}function wl(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=_t(e);return this.tween(o,(n.local?hm:ym)(n,t))}function xm(e,t){return function(){mn(this,e).delay=+t.apply(this,arguments)}}function Em(e,t){return t=+t,function(){mn(this,e).delay=t}}function Il(e){var t=this._id;return arguments.length?this.each((typeof e=="function"?xm:Em)(t,e)):Ae(this.node(),t).delay}function bm(e,t){return function(){Le(this,e).duration=+t.apply(this,arguments)}}function _m(e,t){return t=+t,function(){Le(this,e).duration=t}}function Al(e){var t=this._id;return arguments.length?this.each((typeof e=="function"?bm:_m)(t,e)):Ae(this.node(),t).duration}function Nm(e,t){if(typeof t!="function")throw new Error;return function(){Le(this,e).ease=t}}function Cl(e){var t=this._id;return arguments.length?this.each(Nm(t,e)):Ae(this.node(),t).ease}function Tm(e,t){return function(){var o=t.apply(this,arguments);if(typeof o!="function")throw new Error;Le(this,e).ease=o}}function Sl(e){if(typeof e!="function")throw new Error;return this.each(Tm(this._id,e))}function Ml(e){typeof e!="function"&&(e=tn(e));for(var t=this._groups,o=t.length,n=new Array(o),r=0;r<o;++r)for(var i=t[r],a=i.length,s=n[r]=[],l,c=0;c<a;++c)(l=i[c])&&e.call(l,l.__data__,c,i)&&s.push(l);return new Ve(n,this._parents,this._name,this._id)}function Pl(e){if(e._id!==this._id)throw new Error;for(var t=this._groups,o=e._groups,n=t.length,r=o.length,i=Math.min(n,r),a=new Array(n),s=0;s<i;++s)for(var l=t[s],c=o[s],d=l.length,p=a[s]=new Array(d),m,u=0;u<d;++u)(m=l[u]||c[u])&&(p[u]=m);for(;s<n;++s)a[s]=t[s];return new Ve(a,this._parents,this._name,this._id)}function vm(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 wm(e,t,o){var n,r,i=vm(t)?mn:Le;return function(){var a=i(this,e),s=a.on;s!==n&&(r=(n=s).copy()).on(t,o),a.on=r}}function Ll(e,t){var o=this._id;return arguments.length<2?Ae(this.node(),o).on.on(e):this.each(wm(o,e,t))}function Im(e){return function(){var t=this.parentNode;for(var o in this.__transition)if(+o!==e)return;t&&t.removeChild(this)}}function kl(){return this.on("end.remove",Im(this._id))}function Rl(e){var t=this._name,o=this._id;typeof e!="function"&&(e=no(e));for(var n=this._groups,r=n.length,i=new Array(r),a=0;a<r;++a)for(var s=n[a],l=s.length,c=i[a]=new Array(l),d,p,m=0;m<l;++m)(d=s[m])&&(p=e.call(d,d.__data__,m,s))&&("__data__"in d&&(p.__data__=d.__data__),c[m]=p,Vt(c[m],t,o,m,c,Ae(d,o)));return new Ve(i,this._parents,t,o)}function Dl(e){var t=this._name,o=this._id;typeof e!="function"&&(e=en(e));for(var n=this._groups,r=n.length,i=[],a=[],s=0;s<r;++s)for(var l=n[s],c=l.length,d,p=0;p<c;++p)if(d=l[p]){for(var m=e.call(d,d.__data__,p,l),u,g=Ae(d,o),E=0,f=m.length;E<f;++E)(u=m[E])&&Vt(u,t,o,E,m,g);i.push(m),a.push(d)}return new Ve(i,a,t,o)}var Am=Nt.prototype.constructor;function Ol(){return new Am(this._groups,this._parents)}function Cm(e,t){var o,n,r;return function(){var i=Dt(this,e),a=(this.style.removeProperty(e),Dt(this,e));return i===a?null:i===o&&a===n?r:r=t(o=i,n=a)}}function Vl(e){return function(){this.style.removeProperty(e)}}function Sm(e,t,o){var n,r=o+"",i;return function(){var a=Dt(this,e);return a===r?null:a===n?i:i=t(n=a,o)}}function Mm(e,t,o){var n,r,i;return function(){var a=Dt(this,e),s=o(this),l=s+"";return s==null&&(l=s=(this.style.removeProperty(e),Dt(this,e))),a===l?null:a===n&&l===r?i:(r=l,i=t(n=a,s))}}function Pm(e,t){var o,n,r,i="style."+t,a="end."+i,s;return function(){var l=Le(this,e),c=l.on,d=l.value[i]==null?s||(s=Vl(t)):void 0;(c!==o||r!==d)&&(n=(o=c).copy()).on(a,r=d),l.on=n}}function Hl(e,t,o){var n=(e+="")=="transform"?$i:hr;return t==null?this.styleTween(e,Cm(e,n)).on("end.style."+e,Vl(e)):typeof t=="function"?this.styleTween(e,Mm(e,n,Co(this,"style."+e,t))).each(Pm(this._id,e)):this.styleTween(e,Sm(e,n,t),o).on("end.style."+e,null)}function Lm(e,t,o){return function(n){this.style.setProperty(e,t.call(this,n),o)}}function km(e,t,o){var n,r;function i(){var a=t.apply(this,arguments);return a!==r&&(n=(r=a)&&Lm(e,a,o)),n}return i._value=t,i}function Gl(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,km(e,t,o==null?"":o))}function Rm(e){return function(){this.textContent=e}}function Dm(e){return function(){var t=e(this);this.textContent=t==null?"":t}}function Bl(e){return this.tween("text",typeof e=="function"?Dm(Co(this,"text",e)):Rm(e==null?"":e+""))}function Om(e){return function(t){this.textContent=e.call(this,t)}}function Vm(e){var t,o;function n(){var r=e.apply(this,arguments);return r!==o&&(t=(o=r)&&Om(r)),t}return n._value=e,n}function zl(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,Vm(e))}function Yl(){for(var e=this._name,t=this._id,o=yr(),n=this._groups,r=n.length,i=0;i<r;++i)for(var a=n[i],s=a.length,l,c=0;c<s;++c)if(l=a[c]){var d=Ae(l,t);Vt(l,e,o,c,a,{time:d.time+d.delay+d.duration,delay:0,duration:d.duration,ease:d.ease})}return new Ve(n,this._parents,e,o)}function Wl(){var e,t,o=this,n=o._id,r=o.size();return new Promise(function(i,a){var s={value:a},l={value:function(){--r===0&&i()}};o.each(function(){var c=Le(this,n),d=c.on;d!==e&&(t=(e=d).copy(),t._.cancel.push(s),t._.interrupt.push(s),t._.end.push(l)),c.on=t}),r===0&&i()})}var Hm=0;function Ve(e,t,o,n){this._groups=e,this._parents=t,this._name=o,this._id=n}function Fl(e){return Nt().transition(e)}function yr(){return++Hm}var Tt=Nt.prototype;Ve.prototype=Fl.prototype={constructor:Ve,select:Rl,selectAll:Dl,selectChild:Tt.selectChild,selectChildren:Tt.selectChildren,filter:Ml,merge:Pl,selection:Ol,transition:Yl,call:Tt.call,nodes:Tt.nodes,node:Tt.node,size:Tt.size,empty:Tt.empty,each:Tt.each,on:Ll,attr:vl,attrTween:wl,style:Hl,styleTween:Gl,text:Bl,textTween:zl,remove:kl,tween:Tl,delay:Il,duration:Al,ease:Cl,easeVarying:Sl,end:Wl,[Symbol.iterator]:Tt[Symbol.iterator]};function xr(e){return((e*=2)<=1?e*e*e:(e-=2)*e*e+2)/2}var Gm={time:null,delay:0,duration:250,ease:xr};function Bm(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 Xl(e){var t,o;e instanceof Ve?(t=e._id,e=e._name):(t=yr(),(o=Gm).time=pn(),e=e==null?null:e+"");for(var n=this._groups,r=n.length,i=0;i<r;++i)for(var a=n[i],s=a.length,l,c=0;c<s;++c)(l=a[c])&&Vt(l,e,t,c,a,o||Bm(l,t));return new Ve(n,this._parents,e,t)}Nt.prototype.interrupt=Nl;Nt.prototype.transition=Xl;function Ht(e,t,o){this.k=e,this.x=t,this.y=o}Ht.prototype={constructor:Ht,scale:function(e){return e===1?this:new Ht(this.k*e,this.x,this.y)},translate:function(e,t){return e===0&t===0?this:new Ht(this.k,this.x+this.k*e,this.y+this.k*t)},apply:function(e){return[e[0]*this.k+this.x,e[1]*this.k+this.y]},applyX:function(e){return e*this.k+this.x},applyY:function(e){return e*this.k+this.y},invert:function(e){return[(e[0]-this.x)/this.k,(e[1]-this.y)/this.k]},invertX:function(e){return(e-this.x)/this.k},invertY:function(e){return(e-this.y)/this.k},rescaleX:function(e){return e.copy().domain(e.range().map(this.invertX,this).map(e.invert,e))},rescaleY:function(e){return e.copy().domain(e.range().map(this.invertY,this).map(e.invert,e))},toString:function(){return"translate("+this.x+","+this.y+") scale("+this.k+")"}};var Er=new Ht(1,0,0);br.prototype=Ht.prototype;function br(e){for(;!e.__zoom;)if(!(e=e.parentNode))return Er;return e.__zoom}var Ym=[[Number.NEGATIVE_INFINITY,Number.NEGATIVE_INFINITY],[Number.POSITIVE_INFINITY,Number.POSITIVE_INFINITY]];var Ul;(function(e){e.Strict="strict",e.Loose="loose"})(Ul||(Ul={}));var $l;(function(e){e.Free="free",e.Vertical="vertical",e.Horizontal="horizontal"})($l||($l={}));var Kl;(function(e){e.Partial="partial",e.Full="full"})(Kl||(Kl={}));var ql;(function(e){e.Bezier="default",e.Straight="straight",e.Step="step",e.SmoothStep="smoothstep",e.SimpleBezier="simplebezier"})(ql||(ql={}));var Zl;(function(e){e.Arrow="arrow",e.ArrowClosed="arrowclosed"})(Zl||(Zl={}));var Ye;(function(e){e.Left="left",e.Top="top",e.Right="right",e.Bottom="bottom"})(Ye||(Ye={}));var Ow={[Ye.Left]:Ye.Right,[Ye.Right]:Ye.Left,[Ye.Top]:Ye.Bottom,[Ye.Bottom]:Ye.Top};var Wm=e=>"id"in e&&"internals"in e&&!("source"in e)&&!("target"in e);var Fm=(e,t=[0,0])=>{var s;let{width:o,height:n}=Xm(e),r=(s=e.origin)!=null?s:t,i=o*r[0],a=n*r[1];return{x:e.position.x-i,y:e.position.y-a}};var _r=(e,t=[0,0])=>{var r,i,a,s,l,c,d,p;let{x:o,y:n}=Wm(e)?e.internals.positionAbsolute:Fm(e,t);return{x:o,y:n,x2:o+((s=(a=(i=(r=e.measured)==null?void 0:r.width)!=null?i:e.width)!=null?a:e.initialWidth)!=null?s:0),y2:n+((p=(d=(c=(l=e.measured)==null?void 0:l.height)!=null?c:e.height)!=null?d:e.initialHeight)!=null?p:0)}};function Xm(e){var t,o,n,r,i,a,s,l;return{width:(r=(n=(o=(t=e.measured)==null?void 0:t.width)!=null?o:e.width)!=null?n:e.initialWidth)!=null?r:0,height:(l=(s=(a=(i=e.measured)==null?void 0:i.height)!=null?a:e.height)!=null?s:e.initialHeight)!=null?l:0}}var Vw={[Ye.Left]:{x:-1,y:0},[Ye.Right]:{x:1,y:0},[Ye.Top]:{x:0,y:-1},[Ye.Bottom]:{x:0,y:1}};var Um={nodeOrigin:[0,0],nodeExtent:Ym,elevateNodesOnSelect:!0,defaults:{}},Hw=w(b({},Um),{checkEquality:!0});var Jl;(function(e){e.Line="line",e.Handle="handle"})(Jl||(Jl={}));var $m={width:0,height:0,x:0,y:0},Gw=w(b({},$m),{pointerX:0,pointerY:0,aspectRatio:1});var Km=(e,t)=>e.x<t.x2&&e.x2>t.x&&e.y<t.y2&&e.y2>t.y;function qm(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 Zm(e,t){let o=Math.max(0,Math.max(e.x-t.x2,t.x-e.x2)),n=Math.max(0,Math.max(e.y-t.y2,t.y-e.y2));return Math.sqrt(o*o+n*n)}var Nr=class{constructor(){this.xLines=[];this.yLines=[]}initialize(t){this.xLines=t.filter(o=>o.orientation==="vertical"),this.yLines=t.filter(o=>o.orientation==="horizontal"),this.xLines.sort((o,n)=>o.position-n.position),this.yLines.sort((o,n)=>o.position-n.position),this.lastHorizontalLine=void 0,this.lastVerticalLine=void 0}search(t,o,n,r,i){let a=t==="horizontal"?this.yLines:this.xLines,[s,l]=t==="horizontal"?[r.y,r.y2]:[r.x,r.x2],c=[];for(let u of a){if(u.position<s)continue;if(u.position>l)break;if(i.has(u.node.id)||u.node.parentId&&i.has(u.node.parentId)||!Km(u.nodeBox,r))continue;let g=Math.abs(u.position-o);if(g>Tr)continue;let f=qm(u.nodeBox,n)>0?0:Zm(u.nodeBox,n);c.push({line:u,lineDist:g,nodeDist:f})}let d=.5,p=t==="horizontal"?this.lastHorizontalLine:this.lastVerticalLine;c.sort((u,g)=>{if(p){if(u.line===p&&g.line!==p)return-1;if(g.line===p&&u.line!==p)return 1}return Math.abs(u.lineDist-g.lineDist)<=d?u.nodeDist-g.nodeDist:u.lineDist-g.lineDist});let m=c.length>0?c[0].line:void 0;return m&&(t==="horizontal"?this.lastHorizontalLine=m:this.lastVerticalLine=m),m}};function Ql(e,t=ao,o){let n=[];return e==null||e.forEach(r=>{let i=o(r.id);if(!i)throw new Error(`Node with id ${r.id} not found in internal nodes.`);let a=_r(i);Object.entries(t).forEach(([s,l])=>{var c;n.push({position:l.resolve(r,a),color:(c=r.style)==null?void 0:c.backgroundColor,orientation:l.orientation,anchorName:s,nodeBox:a,node:r})})}),n}function jl(e,t,o,n,r=Object.keys(ao)){let i=[];for(let s of r){let l=ao[s],c=l.resolve(null,o),d=e.search(l.orientation,c,o,t,n);d&&i.push({sourcePosition:c,anchorName:s,anchor:l,line:d})}let a={horizontal:void 0,vertical:void 0};for(let s of i){let l=a[s.anchor.orientation],c=Math.abs(s.sourcePosition-s.line.position);(!l||c<Math.abs(l.sourcePosition-l.line.position))&&(a[s.anchor.orientation]=s)}return a}function ec(e,t,o){let n=0,r=0,i=!1,a=!1;if(t){let l=t.anchor.resolve(null,e)-t.line.position;Math.abs(l)<=Tr&&(r=l,a=!0)}if(o){let l=o.anchor.resolve(null,e)-o.line.position;Math.abs(l)<=Tr&&(n=l,i=!0)}return{deltaX:n,deltaY:r,snappedX:i,snappedY:a}}var Tr=10,ao={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 rg}from"react/jsx-runtime";var ng=new Nr;function vr(){let[e,t]=tc(void 0),[o,n]=tc(void 0),{width:r,height:i}=jm(f=>({width:f.width,height:f.height}),og),a=Jm(),s=tg(ng),{screenToFlowPosition:l,getInternalNode:c,getNodes:d}=Qm(),p=gn(()=>{t(void 0),n(void 0)},[]),m=gn(f=>{let h=f!=null?f:d();p();let y=Ql(h,ao,c);s.current.initialize(y)},[c,p,d]),u=gn(()=>{setTimeout(()=>{m()},100)},[m]);eg(()=>{a&&m(d())},[a,m,d]);let g=gn((f,h)=>{var G,z,L,V,j,Z,J,q,ee,ae;if(!s.current||f.length===0||f.filter(F=>F.type==="dimensions").length>1)return f;p();let x=f.filter(F=>F.type==="position"&&!!F.position),v=f.find(F=>F.type==="dimensions");if(x.length===0&&!v)return f;let N=Object.keys(ao),T=new Set,_=1/0,I=1/0,S=-1/0,P=-1/0;if(x.length>0)x.forEach(F=>{var re,fe,ue,ye,ve,Oe;let ne=h.find(Ge=>Ge.id===F.id);if(!ne)return;T.add(ne.id);let le=c(ne.id);if(!le)return;let K=le.parentId?c(le.parentId):void 0,xe=F.position.x+((re=K==null?void 0:K.internals.positionAbsolute.x)!=null?re:0),W=F.position.y+((fe=K==null?void 0:K.internals.positionAbsolute.y)!=null?fe:0),te=(ye=(ue=ne.measured)==null?void 0:ue.width)!=null?ye:0,ce=(Oe=(ve=ne.measured)==null?void 0:ve.height)!=null?Oe:0;_=Math.min(_,xe),I=Math.min(I,W),S=Math.max(S,xe+te),P=Math.max(P,W+ce)}),v&&(N=["top","left"]);else if(v){let F=h.find(te=>te.id===v.id);if(!F)return f;T.add(F.id);let ne=c(F.id);if(!ne)return f;let le=ne.internals.positionAbsolute.x,K=ne.internals.positionAbsolute.y,xe=(V=(L=(G=v.dimensions)==null?void 0:G.width)!=null?L:(z=F.measured)==null?void 0:z.width)!=null?V:0,W=(q=(J=(j=v.dimensions)==null?void 0:j.height)!=null?J:(Z=F.measured)==null?void 0:Z.height)!=null?q:0;_=le,I=K,S=le+xe,P=K+W,N=["right","bottom"]}if(_===1/0)return f;let R={x:_,y:I,x2:S,y2:P},{x:M,y:B}=l({x:0,y:0}),{x:X,y:U}=l({x:r,y:i}),Q={x:M,y:B,x2:X,y2:U},{horizontal:Y,vertical:C}=jl(s.current,Q,R,T,N),{deltaX:O,deltaY:D,snappedX:A,snappedY:k}=ec(R,Y,C);if(A||k){let F=x.some(le=>le.dragging),ne=!!(v!=null&&v.resizing);(F||ne)&&(A&&n(C==null?void 0:C.line),k&&t(Y==null?void 0:Y.line)),A&&(x.forEach(le=>{le.position&&(le.position.x-=O)}),(v==null?void 0:v.id)===((ee=x[0])==null?void 0:ee.id)?v.dimensions&&(v.dimensions.width+=O):v&&!x.length&&v.dimensions&&(v.dimensions.width-=O)),k&&(x.forEach(le=>{le.position&&(le.position.y-=D)}),(v==null?void 0:v.id)===((ae=x[0])==null?void 0:ae.id)?v.dimensions&&(v.dimensions.height+=D):v&&!x.length&&v.dimensions&&(v.dimensions.height-=D))}return f},[l,c,r,i,t,n,p]),E=gn(()=>rg(oc,{horizontal:e,vertical:o}),[e,o]);return{rebuildIndex:m,forceRebuildIndex:u,updateHelperLines:g,helperLineHorizontal:e,helperLineVertical:o,HelperLines:E}}import{reconnectEdge as i0,useReactFlow as s0}from"@xyflow/react";import{useCallback as mo,useRef as a0}from"react";var vt=e=>new Map(e.map(t=>[t.id,t])),hn=(e,t,o)=>t.filter(n=>!(n.source!==e||o&&n.id===o)),nc=(e,t,o)=>t.filter(n=>!(n.target!==e||o&&n.id===o)),Ji=e=>e.some(t=>t.type==="START_EVENT"),Gt=(e,t)=>e==="START_EVENT"?!Ji(t):!0,rc=(e,t,o,n,r)=>{let i=vt(o),a=i.get(e);if(!a||a.type!=="START_EVENT")return!1;let s=i.get(t);return(s==null?void 0:s.type)==="ANNOTATION"?!1:hn(e,n,r).filter(c=>{let d=i.get(c.target);return(d==null?void 0:d.type)!=="ANNOTATION"}).length>=1},ic=(e,t,o,n,r)=>{let i=vt(o),a=i.get(t);if(!a||a.type!=="END_EVENT")return!1;let s=i.get(e);return(s==null?void 0:s.type)==="ANNOTATION"?!1:nc(t,n,r).filter(c=>{let d=i.get(c.source);return(d==null?void 0:d.type)!=="ANNOTATION"}).length>=1},wr=(e,t,o,n,r)=>{var c;let i=vt(o),a=i.get(e);if(!a||a.type!=="GATEWAY"||((c=a.data)==null?void 0:c.variant)!=="EXCLUSIVE")return!1;let s=t?i.get(t):null;return(s==null?void 0:s.type)==="ANNOTATION"?!1:hn(e,n,r).filter(d=>{let p=i.get(d.target);return(p==null?void 0:p.type)!=="ANNOTATION"}).length>=2},sc=(e,t,o)=>{var a,s,l,c;let n=vt(o),r=n.get(e),i=n.get(t);return(r==null?void 0:r.type)!=="GATEWAY"||(i==null?void 0:i.type)!=="GATEWAY"||((a=r==null?void 0:r.data)==null?void 0:a.variant)==="EXCLUSIVE"&&((s=i==null?void 0:i.data)==null?void 0:s.variant)==="PARALLEL"||((l=r==null?void 0:r.data)==null?void 0:l.variant)==="COMPLEX"&&((c=i==null?void 0:i.data)==null?void 0:c.variant)==="PARALLEL"},Ir=(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"},ac=(e,t)=>{var n;let o=t.find(r=>r.id===e);return!o||o.type!=="TASK"?!1:((n=o.data)==null?void 0:n.variant)==="SUBPROCESS"},Ar=(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"},lo=(e,t,o,n)=>{let r=vt(t),i=r.get(e);return!i||i.type!=="TASK"?!1:nc(e,o,n).some(s=>{let l=r.get(s.source);return(l==null?void 0:l.type)==="START_EVENT"})},yn=(e,t,o,n)=>{let r=vt(t),i=r.get(e);return!i||i.type!=="TASK"?!1:hn(e,o,n).some(s=>{let l=r.get(s.target);return(l==null?void 0:l.type)==="END_EVENT"})},lc=(e,t,o,n,r)=>{let i=vt(o),a=i.get(e),s=i.get(t);return(a==null?void 0:a.type)==="START_EVENT"&&(s==null?void 0:s.type)==="TASK"?yn(t,o,n,r):(s==null?void 0:s.type)==="END_EVENT"&&(a==null?void 0:a.type)==="TASK"?lo(e,o,n,r):!1},Cr=(e,t,o)=>hn(e,t,o).length>0,Sr=(e,t,o,n,r)=>{let i=vt(o),a=i.get(e);if(!a||a.type!=="TASK")return!1;let s=t?i.get(t):null;return(s==null?void 0:s.type)==="ANNOTATION"?!1:hn(e,n,r).filter(c=>{let d=i.get(c.target);return(d==null?void 0:d.type)!=="ANNOTATION"}).length>=2};var cc=(e,t,o,n,r)=>{var s,l;let i=vt(n),a=((s=i.get(e))==null?void 0:s.type)==="ANNOTATION"||((l=i.get(t))==null?void 0:l.type)==="ANNOTATION";return o.some(c=>r&&c.id===r?!1:!!(c.source===e&&c.target===t||a&&c.source===t&&c.target===e))};var ig=[e=>({isValid:e.sourceNodeId!==e.targetNodeId,reason:"self_connection_not_allowed"}),e=>({isValid:!cc(e.sourceNodeId,e.targetNodeId,e.edges,e.nodes,e.reconnectingEdgeId),reason:"duplicate_connection_not_allowed"}),e=>({isValid:!rc(e.sourceNodeId,e.targetNodeId,e.nodes,e.edges,e.reconnectingEdgeId),reason:"start_event_limit_reached"}),e=>({isValid:!ic(e.sourceNodeId,e.targetNodeId,e.nodes,e.edges,e.reconnectingEdgeId),reason:"end_event_limit_reached"}),e=>({isValid:!wr(e.sourceNodeId,e.targetNodeId,e.nodes,e.edges,e.reconnectingEdgeId),reason:"gateway_limit_reached"}),e=>({isValid:!Sr(e.sourceNodeId,e.targetNodeId,e.nodes,e.edges,e.reconnectingEdgeId),reason:"task_limit_reached"}),e=>({isValid:sc(e.sourceNodeId,e.targetNodeId,e.nodes),reason:"gateway_to_gateway_not_allowed"}),e=>({isValid:!(e.sourceNodeType==="START_EVENT"&&e.targetNodeType==="END_EVENT"),reason:"start_to_end_not_allowed"}),e=>({isValid:!(e.sourceNodeType==="START_EVENT"&&ac(e.targetNodeId,e.nodes)),reason:"start_event_to_subprocess_not_allowed"}),e=>({isValid:!(e.sourceNodeType==="GATEWAY"&&e.targetNodeType==="END_EVENT"),reason:"gateway_to_end_not_allowed"}),e=>({isValid:!(e.sourceNodeType==="START_EVENT"&&e.targetNodeType==="GATEWAY"),reason:"start_to_gateway_not_allowed"}),e=>({isValid:!(Ir(e.sourceNodeId,e.nodes)&&e.targetNodeType==="END_EVENT"),reason:"script_to_end_not_allowed"}),e=>({isValid:!(Ar(e.sourceNodeId,e.nodes)&&e.targetNodeType==="END_EVENT"),reason:"loop_to_end_not_allowed"}),e=>({isValid:!(lo(e.sourceNodeId,e.nodes,e.edges,e.reconnectingEdgeId)&&e.targetNodeType==="END_EVENT"),reason:"initial_activity_to_end_not_allowed"}),e=>({isValid:!lc(e.sourceNodeId,e.targetNodeId,e.nodes,e.edges,e.reconnectingEdgeId),reason:"concurrent_initial_and_final_activity"}),e=>({isValid:!(yn(e.sourceNodeId,e.nodes,e.edges,e.reconnectingEdgeId)&&e.targetNodeType!=="ANNOTATION"),reason:"final_activity_cannot_connect"}),e=>({isValid:!(Cr(e.sourceNodeId,e.edges,e.reconnectingEdgeId)&&e.targetNodeType==="END_EVENT"),reason:"activity_has_outgoing_connections"}),e=>({isValid:({START_EVENT:["TASK","ANNOTATION"],END_EVENT:["ANNOTATION"],TASK:["TASK","END_EVENT","GATEWAY","ANNOTATION"],GATEWAY:["TASK","END_EVENT","ANNOTATION","GATEWAY"],LANE:["ANNOTATION"],ANNOTATION:["START_EVENT","END_EVENT","TASK","GATEWAY","LANE"],UNSUPPORTED:[]}[e.sourceNodeType]||[]).includes(e.targetNodeType),reason:"connection_type_not_allowed"})],Qi=e=>{for(let t of ig){let o=t(e);if(!o.isValid)return o}return{isValid:!0}};var sg=[{sourceTypes:["GATEWAY"],targetTypes:["TASK","GATEWAY"],validate:e=>({shouldDisable:wr(e.sourceNodeId,null,e.nodes,e.edges)&&e.targetNodeType!=="ANNOTATION",reason:"gateway_limit_reached"})},{sourceTypes:["START_EVENT"],validate:e=>({shouldDisable:e.edges.some(o=>{if(o.source!==e.sourceNodeId)return!1;let n=e.nodes.find(r=>r.id===o.target);return(n==null?void 0:n.type)!=="ANNOTATION"})&&e.targetNodeType!=="ANNOTATION",reason:"start_event_limit_reached"})},{targetTypes:["START_EVENT"],validate:e=>({shouldDisable:Ji(e.nodes),reason:"start_event_already_exists"})},{sourceTypes:["TASK"],targetTypes:["END_EVENT"],validate:e=>({shouldDisable:Ir(e.sourceNodeId,e.nodes),reason:"script_to_end_not_allowed"})},{sourceTypes:["TASK"],targetTypes:["END_EVENT"],validate:e=>({shouldDisable:Ar(e.sourceNodeId,e.nodes),reason:"loop_to_end_not_allowed"})},{sourceTypes:["TASK"],targetTypes:["END_EVENT"],validate:e=>({shouldDisable:lo(e.sourceNodeId,e.nodes,e.edges),reason:"initial_activity_to_end_not_allowed"})},{sourceTypes:["TASK"],validate:e=>({shouldDisable:yn(e.sourceNodeId,e.nodes,e.edges)&&e.targetNodeType!=="ANNOTATION",reason:"final_activity_cannot_connect"})},{targetTypes:["END_EVENT"],validate:e=>({shouldDisable:Cr(e.sourceNodeId,e.edges),reason:"activity_has_outgoing_connections"})},{sourceTypes:["TASK"],validate:e=>({shouldDisable:Sr(e.sourceNodeId,null,e.nodes,e.edges)&&e.targetNodeType!=="ANNOTATION",reason:"task_limit_reached"})}],dc=e=>{let t=sg.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 Og,EdgeLabelRenderer as Vg,getStraightPath as Hg,useInternalNode as pc,useViewport as Gg}from"@xyflow/react";import{Button as cg,Tooltip as dg,TooltipContent as ug,TooltipTrigger as pg,useTranslation as fg}from"@produto-lecom/lecom-ui";import{Settings as mg}from"lucide-react";import{getIncomers as Mr,getOutgoers as Pr,useReactFlow as lg}from"@xyflow/react";import{useStoreApi as ag}from"@xyflow/react";var Bt=()=>{let e=ag();return{selectElements:n=>{let{edges:r,nodes:i,triggerEdgeChanges:a,triggerNodeChanges:s}=e.getState(),l=i.reduce((d,p)=>[...d,{id:p.id,type:"select",selected:n.includes(p.id)}],[]),c=r.reduce((d,p)=>[...d,{id:p.id,type:"select",selected:n.includes(p.id)}],[]);return s(l),a(c),!0},clearSelection:async()=>{let{unselectNodesAndEdges:n}=e.getState();return n(),await Hn(),!0}}};var Lr=()=>{let{getNode:e,getEdge:t,getNodes:o,getEdges:n}=lg(),{selectElements:r}=Bt(),i=f=>{let h=o(),y=n(),x=Mr(f,h,y),v=Pr(f,h,y),N=x.some(_=>_.type==="START_EVENT"),T=v.some(_=>_.type==="END_EVENT");return N?"start":T?"end":"between"},a=(f,h,y)=>{var N,T,_,I;if(!f)return;let x={type:f.type,variant:(N=f.data)==null?void 0:N.variant,attribute:(T=f.data)==null?void 0:T.attribute},v={id:f.id,position:i(f),label:(_=f.data)==null?void 0:_.label,node:x};return f.type==="TASK"&&((I=f.data)==null?void 0:I.variant)==="SUBPROCESS"?w(b({},v),{type:"sub_process"}):f.type==="GATEWAY"?w(b({},v),{type:"gateway",variant:s(f,h,y)}):w(b({},v),{type:"activity"})},s=(f,h,y)=>{if(f.type!=="GATEWAY")return;let x=Mr(f,h,y),v=!1,N=!1;if(x.forEach(T=>{var _,I;T.type==="TASK"&&(((_=T.data)==null?void 0:_.variant)==="SCRIPT"&&(v=!0),((I=T.data)==null?void 0:I.attribute)==="LOOP"&&(N=!0))}),v&&N)return"script_loop";if(v)return"script";if(N)return"loop"},l=(f,h,y)=>{var _,I,S,P;let x=e(f.source),v=e(f.target);if(!x||!v)return"simple";if(Pr(x,h,y).some(R=>R.type==="END_EVENT"))return"final";if(x.type==="GATEWAY")switch((_=x.data)==null?void 0:_.variant){case"PARALLEL":return"parallel";case"EXCLUSIVE":return"exclusive";case"COMPLEX":return"complex";default:return"simple"}if(x.type==="TASK"){let R=(I=x.data)==null?void 0:I.variant,M=(S=x.data)==null?void 0:S.attribute;if(R==="SUBPROCESS")return"from_sub_process";if(v.type==="TASK"&&((P=v.data)==null?void 0:P.variant)==="SUBPROCESS")return"to_sub_process";let B=R==="SCRIPT",X=M==="LOOP";return B&&X?"script_loop":B?"script":X?"loop":"simple"}return"simple"},c=(f,h,y)=>{let x=[];function v(T,_,I=0){let S=a(T,h,y);if(S.depth=I,_.push(S),T.type==="TASK"){x.push([..._]),_.pop();return}let P=Mr(T,h,y);if(P.length)for(let R of P)v(R,_,I+1);_.pop()}let N=Mr(f,h,y);for(let T of N)v(T,[]);return x},d=(f,h,y)=>{let x=[];function v(T,_,I=0){let S=a(T,h,y);if(S.depth=I,_.push(S),T.type==="TASK"){x.push([..._]),_.pop();return}let P=Pr(T,h,y);if(P.length)for(let R of P)v(R,_,I+1);_.pop()}let N=Pr(f,h,y);for(let T of N)v(T,[]);return x},p=(f,h,y)=>(y=y.filter(v=>v.source===f.id),y.map(v=>{var _;let N=e(v.target),T;return N&&(T=a(N,h,y)),{id:v.id,type:"routing",variant:l(v,h,y),label:(_=v.data)==null?void 0:_.label,target:T}})),m=f=>{let h=e(f);if(!h)return;let y=o(),x=n(),v=a(h,y,x);return v.sources=c(h,y,x),v.targets=d(h,y,x),v.edgeTargets=p(h,y,x),h.type==="GATEWAY"&&(v.variant=s(h,y,x)),v},u=f=>{let h=t(f);if(!h)return;let y=o(),x=n(),v=l(h,y,x),T={id:h.id,type:"routing",variant:v,gatewayVariant:void 0},_=e(h.source);if(_){let S=a(_,y,x);T.source=S;let P=s(_,y,x);if(T.gatewayVariant=P,_.type==="TASK")T.sources=[[S]];else{let R=c(_,y,x);T.sources=R.length?R:[[S]]}}let I=e(h.target);if(I){let S=a(I,y,x);if(T.target=S,I.type==="TASK")T.targets=[[S]];else{let P=d(I,y,x);T.targets=P.length?P:[[S]]}}return T},g=f=>{let h=e(f);if(h)return m(h.id);let y=t(f);if(y)return u(y.id)};return{configureElement:f=>{let h=g(f);if(h)return r([f]),h},getConfigureElement:g,getNodeConfigure:m,getEdgeConfigure:u}};import{jsx as kr,jsxs as hg}from"react/jsx-runtime";var gg={node:"editor.toolbar.configure_node",edge:"editor.toolbar.configure_edge",gateway:"editor.toolbar.configure_gateway"},zt=({elementId:e,elementType:t="node"})=>{let{t:o}=fg(),{onConfigureElement:n}=$(),{getConfigureElement:r}=Lr();return hg(dg,{children:[kr(pg,{asChild:!0,children:kr(cg,{variant:"ghost",color:"grey",size:"small",iconButton:!0,onClick:()=>{let a=r(e);a&&(n==null||n(a))},children:kr(mg,{size:16})})}),kr(ug,{color:"black",children:o(gg[t])})]})};import{Button as xg,Tooltip as Eg,TooltipContent as bg,TooltipTrigger as _g,useTranslation as Ng}from"@produto-lecom/lecom-ui";import{useReactFlow as Tg}from"@xyflow/react";import{TrashIcon as vg}from"lucide-react";import{useNotificationToast as yg}from"@produto-lecom/lecom-ui";function We(){let{toast:e}=xn(),{toast:t}=yg();return{toast:e||t}}import{jsx as Rr,jsxs as wg}from"react/jsx-runtime";var Dr=({elementId:e,elementType:t="node"})=>{let{t:o}=Ng(),{toast:n}=We(),{deleteElements:r,getNodes:i}=Tg();return wg(Eg,{children:[Rr(_g,{asChild:!0,children:Rr(xg,{variant:"ghost",color:"destructive",size:"small",iconButton:!0,onClick:()=>{if(t==="node"){let s=i(),l=s.find(c=>c.id===e);if((l==null?void 0:l.type)==="LANE"&&s.some(d=>d.parentId===e)){n({variant:"error",title:o("validation.errors.title"),content:o("editor.toolbar.delete_pool_lane_error")});return}r({nodes:[{id:e}]})}else r({edges:[{id:e}]})},children:Rr(vg,{size:16})})}),Rr(bg,{color:"black",children:o("editor.toolbar.delete")})]})};import{Button as Ig,Tooltip as Ag,TooltipContent as Cg,TooltipTrigger as Sg,useTranslation as Mg}from"@produto-lecom/lecom-ui";import{MoveUpRightIcon as Pg}from"lucide-react";import{useCallback as Lg}from"react";import{jsx as Or,jsxs as kg}from"react/jsx-runtime";var So=({nodeId:e,disabled:t=!1,tooltipMessage:o})=>{let{t:n}=Mg(),r=Lg(i=>{i.stopPropagation();let a=document.querySelectorAll(`.react-flow__handle.source[data-nodeid="${e}"]`);if(a.length===0)return;let s=Array.from(a).reduce((m,u)=>{let g=m.getBoundingClientRect(),E=u.getBoundingClientRect(),f=Math.hypot(i.clientX-(g.left+g.width/2),i.clientY-(g.top+g.height/2));return Math.hypot(i.clientX-(E.left+E.width/2),i.clientY-(E.top+E.height/2))<f?u:m}),l=s.getBoundingClientRect(),c=l.left+l.width/2,d=l.top+l.height/2,p=new MouseEvent("mousedown",{clientX:c,clientY:d,bubbles:!0,cancelable:!0});s.dispatchEvent(p)},[e]);return kg(Ag,{children:[Or(Sg,{asChild:!0,children:Or(Ig,{variant:"ghost",color:"grey",size:"small",iconButton:!0,disabled:t,className:t?"opacity-50 cursor-not-allowed":"",onMouseDown:t?void 0:r,children:Or(Pg,{size:16})})}),Or(Cg,{color:"black",children:o||n("editor.toolbar.connect_node")})]})};import{jsx as En}from"react/jsx-runtime";var Mo=i=>{var a=i,{edgeId:e,edgeType:t,sourceNode:o,targetNode:n}=a,r=mt(a,["edgeId","edgeType","sourceNode","targetNode"]);let{mode:s}=$(),{isFromStartEvent:l,isGatewayToGateway:c,isActiviyToAndGateway:d,isToEndEvent:p}=Wn(o,n),m=!l&&!c&&!d&&!p,u=[{component:En(Dr,{elementId:e,elementType:"edge"})}],g=()=>s==="view"?m?[{component:En(zt,{elementId:e,elementType:"edge"})}]:[]:m?[{component:En(zt,{elementId:e,elementType:"edge"})},...u]:u,f=(h=>{switch(h){case"SEQUENCE_EDGE":return g();case"MESSAGE_EDGE":return s==="view"?[]:[...u];case"ANNOTATION_EDGE":return s==="view"?[]:[...u];default:return[]}})(t);if(!(f.length===0||s==="readonly"))return En("div",w(b({className:"flex items-center gap-1 w-fit px-3 py-2 bg-white rounded-sm shadow-md"},r),{children:f.map((h,y)=>En("div",{children:h.component},y))}))};import{useViewport as Rg}from"@xyflow/react";import{useMemo as Dg}from"react";import{jsx as uc}from"react/jsx-runtime";var yt=12,Po=({sx:e,sy:t,tx:o,ty:n,hasLabel:r=!1,children:i})=>{let{zoom:a}=Rg(),s=1/a,l=Dg(()=>t===n?{bottom:`${yt}px`,transform:"translateX(-50%)"}:e===o?{left:`${yt}px`,transform:r?"translateY(-100%)":"translateY(-50%)"}:n>t&&o>e?{left:`${yt}px`,bottom:`${yt}px`}:n>t&&o<e?{right:`${yt}px`,bottom:`${yt}px`}:t>n&&o>e?{right:`${yt}px`,bottom:`${yt}px`}:{left:`${yt}px`,bottom:`${yt}px`},[e,t,o,n,r]);return uc("div",{style:{transform:`scale(${s})`},children:uc("div",{className:"absolute pointer-events-auto",style:b({},l),children:i})})};import{Fragment as Bg,jsx as uo,jsxs as fc}from"react/jsx-runtime";var Lo={type:"ANNOTATION_EDGE",reconnectable:!0},mc=({id:e,source:t,target:o,selected:n,data:r})=>{let{isMultipleSelection:i}=$(),{zoom:a}=Gg(),s=pc(t),l=pc(o);if(!s||!l)return null;let{sx:c,sy:d,tx:p,ty:m}=No(s,l),[u,g,E]=Hg({sourceX:c,sourceY:d,targetX:p,targetY:m}),f=n||(s==null?void 0:s.selected)||(l==null?void 0:l.selected);return uo(Bg,{children:fc("g",{className:H("group bpmn-edge",{"is-highlighted":f}),children:[uo("path",{d:u,fill:"none",stroke:"transparent",strokeWidth:Math.max(12,12/a),style:{pointerEvents:"stroke",cursor:"pointer"}}),fc("g",{className:H("text-grey-500 transition-colors duration-75 group-hover:text-grey-800",{"text-blue-500 group-hover:text-blue-600":f}),children:[uo(Og,{id:e,path:u,interactionWidth:0,strokeDasharray:4,className:H("stroke-2 stroke-current transition-[stroke,filter] duration-75 group-hover:drop-shadow-[0_0_3px_rgba(0,0,0,0.2)]",{"stroke-red-500 hover:stroke-red-600":r==null?void 0:r.hasError,"stroke-blue-500 hover:stroke-blue-600 drop-shadow-[0_0_3px_rgba(59,130,246,0.5)]":f&&!(r!=null&&r.hasError)})}),uo(Vg,{children:uo("div",{className:"absolute z-[3000] pointer-events-auto flex flex-col items-center gap-1",style:{transform:`translate(-50%, -50%) translate(${g}px, ${E}px)`},children:n&&!i&&uo(Po,{sx:c,sy:d,tx:p,ty:m,children:uo(Mo,{edgeId:e,edgeType:"ANNOTATION_EDGE"})})})})]})]})})};import{useState as vc,useCallback as wc,useMemo as ts,useEffect as nh,useRef as os}from"react";import{BaseEdge as rh,EdgeLabelRenderer as ih,MarkerType as Ic,useInternalNode as Ac,useReactFlow as sh,useViewport as ah,useEdges as lh,useNodes as ch,Position as Oo}from"@xyflow/react";import{useCallback as zg,useEffect as ji,useRef as gc,useState as Yg}from"react";import{jsx as yc}from"react/jsx-runtime";var es=/[a-zA-Z0-9À-ÖØ-öø-ÿ]/,hc=["Backspace","Delete","ArrowLeft","ArrowRight","ArrowUp","ArrowDown","Home","End","Tab","Escape","Shift"],ke=({value:e,maxLength:t,style:o,className:n,contentClassName:r,isEditing:i,onChange:a,onBlur:s,onInput:l,onInvalidFirstCharacter:c,skipFirstCharValidation:d})=>{let p=gc(null),m=gc(null),[u,g]=Yg(!1);ji(()=>()=>{m.current&&clearTimeout(m.current)},[]),ji(()=>{g(i!=null?i:!1)},[i]),ji(()=>{if(u&&p.current){p.current.focus();let N=document.createRange();N.selectNodeContents(p.current);let T=window.getSelection();T&&(T.removeAllRanges(),T.addRange(N))}},[u]);let E=zg(()=>{m.current||(c==null||c(),m.current=setTimeout(()=>{m.current=null},500))},[c]),f=N=>{N.stopPropagation(),u||g(!0)},h=N=>{let T=N.currentTarget.innerText.replace(/\n$/,""),_=t&&T.length>=t,I=window.getSelection(),S=(I==null?void 0:I.toString())||"",P=S.length>0,R=(N.ctrlKey||N.metaKey)&&!N.altKey,M=R&&N.key==="a",B=R&&N.key==="c",X=R&&N.key==="x",U=R&&N.key==="v",Q=T.length===0||P&&S.length===T.length;if(!d&&Q&&!es.test(N.key)&&!hc.includes(N.key)&&!R){N.preventDefault(),E();return}_&&!P&&(hc.includes(N.key)||M||B||X||U||N.preventDefault())},y=N=>{N.preventDefault();let T=N.clipboardData.getData("text/plain").replace(/\r\n/g,`
1
+ var lp=Object.defineProperty,cp=Object.defineProperties;var dp=Object.getOwnPropertyDescriptors;var Vn=Object.getOwnPropertySymbols;var Os=Object.prototype.hasOwnProperty,Vs=Object.prototype.propertyIsEnumerable;var Ds=(e,t,o)=>t in e?lp(e,t,{enumerable:!0,configurable:!0,writable:!0,value:o}):e[t]=o,_=(e,t)=>{for(var o in t||(t={}))Os.call(t,o)&&Ds(e,o,t[o]);if(Vn)for(var o of Vn(t))Vs.call(t,o)&&Ds(e,o,t[o]);return e},w=(e,t)=>cp(e,dp(t));var gt=(e,t)=>{var o={};for(var n in e)Os.call(e,n)&&t.indexOf(n)<0&&(o[n]=e[n]);if(e!=null&&Vn)for(var n of Vn(e))t.indexOf(n)<0&&Vs.call(e,n)&&(o[n]=e[n]);return o};var Ai=e=>{if(typeof document=="undefined")return;let t=document.cookie.match(new RegExp(`(?:^|; )${e.replace(/([.$?*|{}()[\]\\/+^])/g,"\\$1")}=([^;]*)`));return t?decodeURIComponent(t[1]):void 0};import{initializeI18n as up,Translations as pp}from"@produto-lecom/lecom-ui";var Hs={translations:{general:{layout:{title:"Modeler"}},editor:{toolbar:{delete:"Delete",configure_node:"Configure activity",configure_edge:"Configure routing",configure_gateway:"Configure routing",initial_task:"Initial Activity",gateway_limit_reached:"Exclusive gateway cannot have more than 2 outgoing connections",task_limit_reached:"Task cannot have more than 2 outgoing connections",start_event_limit_reached:"Start event can only connect to a single element",gateway_to_gateway_not_allowed:"Gateways cannot connect directly to other gateways",start_event_already_exists:"A start event already exists. Delete the current event to add another",script_to_end_not_allowed:"Script activities cannot connect directly to the end event",loop_to_end_not_allowed:"Loop activities cannot connect directly to the end event",initial_activity_to_end_not_allowed:"Initial activity cannot connect directly to the end event",final_activity_cannot_connect:"Final activity cannot connect to other elements",activity_has_outgoing_connections:"Activity with outgoing connections cannot connect to end event",end_event_cannot_connect_to_initial_activity:"End event cannot connect to an initial activity",initial_activity_cannot_connect_to_start_event:"Initial activity cannot connect to start event",concurrent_initial_and_final_activity:"An activity cannot be connected to both start and end events",duplicate_connection_not_allowed:"A connection already exists between these elements",connect_node:"Connect element",connecting:"Connecting...",delete_pool_lane_error:"Cannot delete the pool or lane while there are elements inside it."},controls:{zoom:{fit:"Fit zoom",in:"Zoom in",out:"Zoom out",reset:"Reset zoom"},actions:{move_tool:"Select elements",hand_tool:"Navigate the diagram",check:"Check diagram",check_loading:"Validating diagram...",export:{title:"Export diagram",print:"Print",html:"Export as HTML",png:"Export as PNG",feedback:{empty:"Cannot export an empty diagram",error:"Error exporting diagram"}},import_governance:"Import diagram from Governance platform",minimap:{label:"Minimap",open:"Open minimap",close:"Hide minimap"}},history:{undo:"Undo",redo:"Redo"}},modals:{delete_elements:{title:"Delete elements",callout:"When deleting, the activity and routing settings will be deleted.",content:"Are you sure you want to delete?",confirm:"Delete",cancel:"Cancel"}},task_menu:{loop_not_allowed_when_connected_to_end:"Cannot create loop on activity connected to end event",script_not_allowed_when_connected_to_end:"Cannot transform to Script activity connected to end event",loop_not_allowed_when_subprocess:"Cannot create loop on subprocess",loop:"Activity with loop"}},validation:{success:{title:"Validation Successful",message:"The diagram was validated successfully with no errors."},errors:{title:"The diagram contains errors",subtitle:"Please review the following:",task_label_length:"Task name exceeds the maximum character limit",multiple_start_event_not_allowed:"Multiple start events are not allowed",task_flows_limit_exceeds:"The number of output connections exceeds the limit of two",duplicate_task_name:"There are multiple activities with the same name",flows_on_end_tasks_not_allowed:"Activities connected to end events cannot have other connections",conditions_flows_limit_exceeds:"Exclusive gateway has too many output connections (maximum of two)",task_label_empty:"One or more activities have no name",activity_name_invalid:"Activity name is invalid",final_activity_has_loop:"Final activities cannot have loops",nested_gateway:"Connecting gateways directly is not allowed",concurrent_initial_and_final_event:"The same activity cannot have both initial and final events",gateway_flow_to_event:"Connecting a gateway to an output event is not allowed",gateway_missing_output_streams:"The gateway does not have the correct number of outputs",events_nested:"Connecting events directly is not allowed",event_to_condition:"Connecting an event directly to a gateway is not allowed",script_in_final_activity:"Final activity cannot be a script type",subprocess_not_configured:"The subprocess reference is not properly configured",cannot_validate_subprocess_reference:"Could not validate whether the subprocess reference is configured",start_event_not_found:"At least one start event is required",end_event_not_found:"At least one end event is required"}},bpmn:{start_event:{variant:{default:"Start event"}},end_event:{variant:{default:"End event"}},annotation:{variant:{default:"Annotation"}},gateway:{menu:{title:"Change gateway type"},variant:{default:"Gateway",exclusive:"Exclusive gateway",parallel:"Parallel gateway",complex:"Complex gateway"}},task:{menu:{title:"Change task type"},variant:{default:"Task",script:"Script task",subprocess:"Subprocess"},attribute:{loop:"Task with loop"},label:{prefix:"Activity"},feedback:{label_empty:{prefix:"Activity name was automatically set to"},label_already_exists:{prefix:"The name",middle:"already exists. The name was changed to"},invalid_first_character:"Activity name must start with a letter or number"}},lane:{variant:{default:"Pool / Lane"}},unsupported:{variant:{default:"Unsupported element"}}},adapter:{governance:{error:{DEFAULT:"Error importing diagram",NO_FILE:"No file selected",EMPTY_FILE:"Empty file",INVALID_FILE:"Invalid file",CONTAIN_NO_CELLS:"No cells found to be imported",ALREADY_INITIALIZED:"It is not possible to import the diagram from the Governance platform, since the diagram has already been initialized"},success:{default:"The diagram was imported from the Governance platform successfully and without any incompatibility detected.",incompatible_cells:"The diagram was imported from the Governance platform with incompatibilities. To know more details, click on the button below."},report:{columns:{type:"Type",value:"Value",status:"Status"},status:{imported:"Imported",adapted:"Adapted",unsupported:"Unsupported"}},action:{download:"Download report"}}}}};var Gs={translations:{general:{layout:{title:"Modeler"}},editor:{toolbar:{delete:"Eliminar",configure_node:"Configurar actividad",configure_edge:"Configurar enrutamiento",configure_gateway:"Configurar enrutamiento",initial_task:"Actividad Inicial",gateway_limit_reached:"Compuerta exclusiva no puede tener m\xE1s de 2 conexiones de salida",task_limit_reached:"Actividad no puede tener m\xE1s de 2 conexiones de salida",start_event_limit_reached:"Evento inicial solo puede conectarse a un \xFAnico elemento",gateway_to_gateway_not_allowed:"Las compuertas no pueden conectarse directamente con otras compuertas",start_event_already_exists:"Ya existe un evento de inicio. Elimine el evento actual para agregar otro",script_to_end_not_allowed:"Las actividades Script no pueden conectarse directamente al evento final",loop_to_end_not_allowed:"Las actividades Loop no pueden conectarse directamente al evento final",initial_activity_to_end_not_allowed:"Actividad inicial no puede conectarse directamente al evento final",final_activity_cannot_connect:"Actividad final no puede conectarse a otros elementos",activity_has_outgoing_connections:"Actividad con conexiones de salida no puede conectarse al evento final",end_event_cannot_connect_to_initial_activity:"El evento final no puede conectarse a una actividad inicial",initial_activity_cannot_connect_to_start_event:"Actividad inicial no puede conectarse a evento de inicio",concurrent_initial_and_final_activity:"Una actividad no puede estar conectada al evento inicial y final al mismo tiempo",duplicate_connection_not_allowed:"Ya existe una conexi\xF3n entre estos elementos",connect_node:"Conectar elemento",connecting:"Conectando...",delete_pool_lane_error:"No se puede eliminar la piscina o carril mientras haya elementos dentro."},controls:{zoom:{fit:"Ajustar zoom",in:"Acercar",out:"Alejar",reset:"Restablecer zoom"},actions:{move_tool:"Seleccionar elementos",hand_tool:"Navegar por el diagrama",check:"Validar diagrama",check_loading:"Validando diagrama...",export:{title:"Exportar diagrama",print:"Imprimir",html:"Exportar como HTML",png:"Exportar como PNG",feedback:{empty:"No es posible exportar un diagrama vac\xEDo",error:"Error al exportar diagrama"}},import_governance:"Importar diagrama de la plataforma Governance",minimap:{label:"Minimapa",open:"Abrir minimapa",close:"Ocultar minimapa"}},history:{undo:"Deshacer",redo:"Rehacer"}},modals:{delete_elements:{title:"Eliminar elementos",callout:"Al eliminar, las configuraciones de actividades y enrutamiento ser\xE1n eliminadas.",content:"\xBFEst\xE1s seguro de querer eliminar?",confirm:"Eliminar",cancel:"Cancelar"}},task_menu:{loop_not_allowed_when_connected_to_end:"No se puede crear bucle en actividad conectada al evento final",script_not_allowed_when_connected_to_end:"No se puede transformar a Script actividad conectada al evento final",loop_not_allowed_when_subprocess:"No se puede crear bucle en subproceso",loop:"Actividad con loop"}},validation:{success:{title:"Validaci\xF3n exitosa",message:"El diagrama ha sido validado correctamente sin errores."},errors:{title:"El diagrama contiene errores",subtitle:"Revise lo siguiente:",task_label_length:"El nombre de la actividad excede el l\xEDmite m\xE1ximo de caracteres",multiple_start_event_not_allowed:"No se permite tener m\xE1s de un evento de inicio",task_flows_limit_exceeds:"El n\xFAmero de conexiones de salida supera el l\xEDmite de dos",duplicate_task_name:"Hay varias actividades con el mismo nombre",flows_on_end_tasks_not_allowed:"Las actividades conectadas a eventos finales no pueden tener otras conexiones",conditions_flows_limit_exceeds:"Compuerta exclusiva con exceso de conexiones de salida (m\xE1ximo de dos)",task_label_empty:"El nombre de una o m\xE1s actividades no ha sido completado",activity_name_invalid:"El nombre de la actividad no es v\xE1lido",final_activity_has_loop:"Las actividades finales no pueden tener bucles",nested_gateway:"No se permite conectar compuertas directamente",concurrent_initial_and_final_event:"Una misma actividad no puede tener eventos iniciales y finales",gateway_flow_to_event:"No se permite conectar una compuerta a un evento de salida",gateway_missing_output_streams:"La compuerta no tiene el n\xFAmero correcto de salidas",events_nested:"No se permite conectar eventos directamente",event_to_condition:"No se permite conectar un evento directamente a una compuerta",script_in_final_activity:"La actividad final no puede ser de tipo script",subprocess_not_configured:"La referencia al subproceso no est\xE1 configurada correctamente",cannot_validate_subprocess_reference:"No fue posible validar si la referencia al subproceso est\xE1 configurada",start_event_not_found:"Es necesario tener al menos un evento de inicio",end_event_not_found:"Es necesario tener al menos un evento final"}},bpmn:{start_event:{variant:{default:"Evento de inicio"}},end_event:{variant:{default:"Evento final"}},annotation:{variant:{default:"Anotaci\xF3n"}},gateway:{menu:{title:"Cambiar tipo de compuerta"},variant:{default:"Compuerta",exclusive:"Compuerta exclusiva",parallel:"Compuerta paralela",complex:"Compuerta compleja"}},task:{menu:{title:"Cambiar tipo de tarea"},variant:{default:"Tarea",script:"Tarea de script",subprocess:"Subproceso"},attribute:{loop:"Tarea con bucle"},label:{prefix:"Actividad"},feedback:{label_empty:{prefix:"El nombre de la actividad se estableci\xF3 autom\xE1ticamente como"},label_already_exists:{prefix:"El nombre",middle:"ya existe. El nombre fue cambiado a"},invalid_first_character:"El nombre de la actividad debe comenzar con una letra o n\xFAmero"}},lane:{variant:{default:"Piscina / Raia"}},unsupported:{variant:{default:"Elemento no soportado"}}},adapter:{governance:{error:{DEFAULT:"Error al importar diagrama",NO_FILE:"No se ha seleccionado ning\xFAn archivo",EMPTY_FILE:"Archivo vac\xEDo",INVALID_FILE:"Archivo inv\xE1lido",CONTAIN_NO_CELLS:"No se encontraron c\xE9lulas para importar",ALREADY_INITIALIZED:"No es posible importar el diagrama de la plataforma Governance, ya que el diagrama ya ha sido iniciado"},success:{default:"El diagrama se ha importado de la plataforma Governance correctamente y sin ninguna incompatibilidad detectada.",incompatible_cells:"El diagrama se ha importado de la plataforma Governance con incompatibilidades. Para saber m\xE1s detalles, haz click en el bot\xF3n de abajo."},report:{columns:{type:"Tipo",value:"Valor",status:"Estado"},status:{imported:"Importado",adapted:"Adaptado",unsupported:"No soportado"}},action:{download:"Descargar informe"}}}}};var Bs={translations:{general:{layout:{title:"Modeler"}},editor:{toolbar:{delete:"Excluir",configure_node:"Configurar atividade",configure_edge:"Configurar roteamento",configure_gateway:"Configurar roteamento",initial_task:"Atividade Inicial",gateway_limit_reached:"Gateway exclusivo n\xE3o pode ter mais de 2 conex\xF5es de sa\xEDda",task_limit_reached:"Atividade n\xE3o pode ter mais de 2 conex\xF5es de sa\xEDda",start_event_limit_reached:"Evento inicial s\xF3 pode se conectar a um \xFAnico elemento",gateway_to_gateway_not_allowed:"Gateways n\xE3o podem se conectar diretamente com outros gateways",start_event_already_exists:"J\xE1 existe um evento de in\xEDcio. Exclua o evento atual para adicionar outro",script_to_end_not_allowed:"Atividades Script n\xE3o podem se conectar diretamente ao evento final",loop_to_end_not_allowed:"Atividades Loop n\xE3o podem se conectar diretamente ao evento final",initial_activity_to_end_not_allowed:"Atividade inicial n\xE3o pode se conectar diretamente ao evento final",final_activity_cannot_connect:"Atividade final n\xE3o pode se conectar a outros elementos",activity_has_outgoing_connections:"Atividade com conex\xF5es de sa\xEDda n\xE3o pode se conectar a um evento final",end_event_cannot_connect_to_initial_activity:"O evento final n\xE3o pode ser conectado a uma atividade inicial",initial_activity_cannot_connect_to_start_event:"Atividade inicial n\xE3o pode se conectar a evento de in\xEDcio",concurrent_initial_and_final_activity:"Uma atividade n\xE3o pode estar conectada ao evento inicial e final ao mesmo tempo",duplicate_connection_not_allowed:"J\xE1 existe uma conex\xE3o entre esses elementos",start_event_to_subprocess_not_allowed:"Evento inicial n\xE3o pode se conectar a um subprocesso",connect_node:"Conectar elemento",connecting:"Conectando...",delete_pool_lane_error:"N\xE3o \xE9 poss\xEDvel excluir a piscina ou raia enquanto houver elementos dentro dela."},controls:{zoom:{fit:"Ajustar o zoom",in:"Aumentar o zoom",out:"Diminuir o zoom",reset:"Resetar o zoom"},actions:{move_tool:"Selecionar elementos",hand_tool:"Navegar pelo diagrama",check:"Validar diagrama",check_loading:"Validando diagrama...",export:{title:"Exportar diagrama",print:"Imprimir",html:"Exportar como HTML",png:"Exportar como PNG",feedback:{empty:"N\xE3o \xE9 poss\xEDvel exportar um diagrama vazio",error:"Erro ao exportar o diagrama"}},import_governance:"Importar diagrama da plataforma Governance",minimap:{label:"Minimapa",open:"Abrir minimapa",close:"Ocultar minimapa"}},history:{undo:"Desfazer",redo:"Refazer"}},modals:{delete_elements:{title:"Excluir elementos",callout:"Ao excluir, as configura\xE7\xF5es de atividades e roteamento ser\xE3o exclu\xEDdas.",content:"Deseja realmente excluir?",confirm:"Excluir",cancel:"Cancelar"}},task_menu:{loop_not_allowed_when_connected_to_end:"N\xE3o \xE9 poss\xEDvel criar loop em atividade conectada ao evento final",script_not_allowed_when_connected_to_end:"N\xE3o \xE9 poss\xEDvel transformar em Script atividade conectada ao evento final",loop_not_allowed_when_subprocess:"N\xE3o \xE9 poss\xEDvel criar loop em subprocesso",loop:"Atividade com loop"}},validation:{success:{title:"Diagrama v\xE1lidado com sucesso!",message:"Nenhum erro encontrado."},errors:{title:"O diagrama cont\xE9m erros",subtitle:"Veja abaixo o que precisa ser corrigido:",task_label_length:"O nome da atividade excede o limite m\xE1ximo de caracteres",multiple_start_event_not_allowed:"N\xE3o \xE9 permitido ter mais de um evento de in\xEDcio",task_flows_limit_exceeds:"O n\xFAmero de conex\xF5es de sa\xEDda ultrapassa o limite de dois",duplicate_task_name:"H\xE1 v\xE1rias atividades com o mesmo nome",flows_on_end_tasks_not_allowed:"Atividades conectadas a eventos finais n\xE3o podem ter outras conex\xF5es",conditions_flows_limit_exceeds:"Gateway exclusivo com excesso de conex\xF5es de sa\xEDda (m\xE1ximo de dois)",task_label_empty:"O nome de uma ou mais atividades n\xE3o foi preenchido",activity_name_invalid:"O nome da atividade n\xE3o \xE9 v\xE1lido",final_activity_has_loop:"Atividades finais n\xE3o podem ter loops",nested_gateway:"N\xE3o \xE9 permitido conectar gateways",concurrent_initial_and_final_event:"Uma mesma atividade n\xE3o pode ter eventos iniciais e finais",gateway_flow_to_event:"N\xE3o \xE9 permitido conectar um gateway a um evento de sa\xEDda",gateway_missing_output_streams:"O gateway n\xE3o possui o n\xFAmero correto de sa\xEDdas",events_nested:"N\xE3o \xE9 permitido conectar eventos",event_to_condition:"N\xE3o \xE9 permitido conectar um evento diretamente em um gateway",script_in_final_activity:"Atividade final n\xE3o pode ser do tipo script",subprocess_not_configured:"A refer\xEAncia ao subprocesso n\xE3o est\xE1 configurada corretamente",cannot_validate_subprocess_reference:"N\xE3o foi poss\xEDvel validar se a refer\xEAncia ao subprocesso est\xE1 configurada",start_event_not_found:"\xC9 necess\xE1rio ter ao menos um evento inicial",end_event_not_found:"\xC9 necess\xE1rio ter ao menos um evento final"}},bpmn:{start_event:{variant:{default:"Evento inicial"}},end_event:{variant:{default:"Evento final"}},annotation:{variant:{default:"Anota\xE7\xE3o"}},gateway:{menu:{title:"Alterar tipo de gateway"},variant:{default:"Gateway",exclusive:"Gateway exclusivo",parallel:"Gateway paralelo",complex:"Gateway complexo"}},task:{menu:{title:"Alterar tipo de atividade"},variant:{default:"Atividade",script:"Atividade de script",subprocess:"Subprocesso"},attribute:{loop:"Atividade com loop"},label:{prefix:"Atividade"},feedback:{label_empty:{prefix:"O nome da atividade foi definido automaticamente como"},label_already_exists:{prefix:"O nome",middle:"j\xE1 existe. O nome foi alterado para"},invalid_first_character:"O nome da atividade deve come\xE7ar com uma letra ou n\xFAmero"}},lane:{variant:{default:"Piscina / Raia"}},unsupported:{variant:{default:"Elemento n\xE3o suportado"}}},adapter:{governance:{error:{DEFAULT:"Erro ao importar diagrama",NO_FILE:"Nenhum arquivo selecionado",EMPTY_FILE:"Arquivo vazio",INVALID_FILE:"Arquivo inv\xE1lido",CONTAIN_NO_CELLS:"N\xE3o foram encontradas c\xE9lulas para serem importadas",ALREADY_INITIALIZED:"N\xE3o \xE9 poss\xEDvel importar o diagrama da plataforma Governance, pois o diagrama j\xE1 foi iniciado"},success:{default:"O diagrama foi importado da plataforma Governance com sucesso e sem nenhuma incompatibilidade detectada.",incompatible_cells:"O diagrama foi importado da plataforma Governance com incompatibilidades. Para saber mais detalhes, clique no bot\xE3o abaixo."},report:{columns:{type:"Tipo do elemento",value:"Valor",status:"Status"},status:{imported:"Importado",adapted:"Adaptado",unsupported:"N\xE3o suportado"}},action:{download:"Baixar relat\xF3rio"}}}}};var zs={pt_BR:Bs,en_US:Hs,es_ES:Gs};var Ys,Ws,fp=(Ws=(Ys=Ai("LecomUserLanguage"))!=null?Ys:Ai("org.springframework.web.servlet.i18n.CookieLocaleResolver.LOCALE"))!=null?Ws:pp.PT_BR;up({lng:fp,resources:zs});var we=(n=>(n.EDIT="edit",n.VIEW="view",n.READONLY="readonly",n))(we||{});var Hn=(r=>(r.ACTIVITY="activity",r.ROUTING="routing",r.GATEWAY="gateway",r.SUB_PROCESS="sub_process",r))(Hn||{}),Ci=(n=>(n.START="start",n.END="end",n.BETWEEN="between",n))(Ci||{}),Si=(n=>(n.SCRIPT="script",n.LOOP="loop",n.SCRIPT_LOOP="script_loop",n))(Si||{}),Mi=(d=>(d.SIMPLE="simple",d.LOOP="loop",d.SCRIPT="script",d.SCRIPT_LOOP="script_loop",d.COMPLEX="complex",d.EXCLUSIVE="exclusive",d.PARALLEL="parallel",d.FINAL="final",d.TO_SUB_PROCESS="to_sub_process",d.FROM_SUB_PROCESS="from_sub_process",d))(Mi||{});import{RotateCcw as wp,ScrollText as Ip,SquarePlus as Ap}from"lucide-react";import{jsx as Gn,jsxs as mp}from"react/jsx-runtime";var Bn=({size:e=24,className:t})=>mp("svg",{width:e,height:e,viewBox:"0 0 24 24",xmlns:"http://www.w3.org/2000/svg",fill:"currentColor",className:t,children:[Gn("path",{strokeWidth:"2",d:"M16 3V3.5085V11.9998V20.4915V21H16.5411H21.4592H22V19.123H21.4592H17.9974V11.9998V4.8773H21.4592H22V3H21.4592H16.5411H16Z"}),Gn("path",{d:"M4.41026 16.9999L2 18.7861L3.89693 21.1103L6.3072 19.324L4.41026 16.9999Z"}),Gn("path",{d:"M8.41026 13.9999L6 15.7861L7.89693 18.1103L10.3072 16.324L8.41026 13.9999Z"}),Gn("path",{d:"M12.4313 10.954L10.021 12.7402L11.9179 15.0644L14.3282 13.2781L12.4313 10.954Z"})]});import{jsx as Fs}from"react/jsx-runtime";var _o=({size:e=24,className:t})=>Fs("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:Fs("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 Jo,jsxs as gp}from"react/jsx-runtime";var To=({size:e=24,className:t})=>gp("svg",{width:e,height:e,viewBox:"0 0 24 24",xmlns:"http://www.w3.org/2000/svg",fill:"white",stroke:"currentColor",strokeWidth:2,className:t,children:[Jo("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"}),Jo("path",{d:"M12 8V16",strokeLinecap:"round",strokeLinejoin:"round"}),Jo("path",{d:"M8 12H16",strokeLinecap:"round",strokeLinejoin:"round"}),Jo("path",{d:"M9.17139 9.17188L14.8282 14.8287",strokeLinecap:"round",strokeLinejoin:"round"}),Jo("path",{d:"M14.8281 9.17188L9.17127 14.8287",strokeLinecap:"round",strokeLinejoin:"round"})]});import{jsx as Pi,jsxs as hp}from"react/jsx-runtime";var No=({size:e=24,className:t})=>hp("svg",{width:e,height:e,viewBox:"0 0 24 24",xmlns:"http://www.w3.org/2000/svg",fill:"white",stroke:"currentColor",strokeWidth:2,className:t,children:[Pi("path",{d:"M2.69991 10.2997C2.47586 10.5235 2.29812 10.7893 2.17685 11.0818C2.05558 11.3744 1.99316 11.688 1.99316 12.0047C1.99316 12.3214 2.05558 12.635 2.17685 12.9275C2.29812 13.2201 2.47586 13.4859 2.69991 13.7097L10.2899 21.2997C10.5137 21.5237 10.7795 21.7015 11.0721 21.8227C11.3646 21.944 11.6782 22.0064 11.9949 22.0064C12.3116 22.0064 12.6252 21.944 12.9177 21.8227C13.2103 21.7015 13.4761 21.5237 13.6999 21.2997L21.2899 13.7097C21.514 13.4859 21.6917 13.2201 21.813 12.9275C21.9342 12.635 21.9967 12.3214 21.9967 12.0047C21.9967 11.688 21.9342 11.3744 21.813 11.0818C21.6917 10.7893 21.514 10.5235 21.2899 10.2997L13.6999 2.70968C13.4761 2.48562 13.2103 2.30788 12.9177 2.18662C12.6252 2.06535 12.3116 2.00293 11.9949 2.00293C11.6782 2.00293 11.3646 2.06535 11.0721 2.18662C10.7795 2.30788 10.5137 2.48562 10.2899 2.70968L2.69991 10.2997Z",strokeLinecap:"round",strokeLinejoin:"round"}),Pi("path",{d:"M14.8286 9.17188L9.17176 14.8287",strokeLinecap:"round",strokeLinejoin:"round"}),Pi("path",{d:"M9.17139 9.17188L14.8282 14.8287",strokeLinecap:"round",strokeLinejoin:"round"})]});import{jsx as Li,jsxs as yp}from"react/jsx-runtime";var vo=({size:e=24,className:t})=>yp("svg",{width:e,height:e,viewBox:"0 0 24 24",xmlns:"http://www.w3.org/2000/svg",fill:"white",stroke:"currentColor",strokeWidth:2,className:t,children:[Li("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"}),Li("path",{d:"M12 8V16",strokeLinecap:"round",strokeLinejoin:"round"}),Li("path",{d:"M8 12H16",strokeLinecap:"round",strokeLinejoin:"round"})]});import{jsx as ki,jsxs as xp}from"react/jsx-runtime";var Xs=({size:e=24,className:t})=>ki("svg",{width:e,height:e,viewBox:"0 0 34 24",xmlns:"http://www.w3.org/2000/svg",fill:"currentColor",className:t,children:xp("g",{children:[ki("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"}),ki("path",{d:"M24.5 4.5L28 1M28 1L31.5 4.5M28 1V8",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round"})]})});import{clsx as Ep}from"clsx";import{twMerge as bp}from"tailwind-merge";function H(...e){return bp(Ep(e))}var Lt=(e=0,t=0)=>e<t?t:e,zn=(e=1e3)=>new Promise(t=>{setTimeout(t,e)});import{jsx as Us,jsxs as _p}from"react/jsx-runtime";var $s=({size:e=24,className:t})=>_p("svg",{width:e,height:e,viewBox:"0 0 24 24",fill:"none",stroke:"#6b7280",strokeWidth:2,xmlns:"http://www.w3.org/2000/svg",className:H("stroke-2",t),children:[Us("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"}),Us("path",{d:"M9 3V21",strokeLinecap:"round",strokeLinejoin:"round"})]});import{jsx as Ri}from"react/jsx-runtime";var Ks=({size:e=24,className:t})=>Ri("svg",{width:e,height:e,viewBox:"0 0 24 24",xmlns:"http://www.w3.org/2000/svg",stroke:"currentColor",className:t,children:Ri("g",{children:Ri("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 qs}from"react/jsx-runtime";var Yn=({size:e=24,className:t})=>qs("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:qs("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 Zs}from"react/jsx-runtime";var Qo=({size:e=24,className:t})=>Zs("svg",{width:e,height:e,viewBox:"0 0 24 24",xmlns:"http://www.w3.org/2000/svg",fill:"white",stroke:"currentColor",className:H("stroke-2",t),children:Zs("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 Di,jsxs as Tp}from"react/jsx-runtime";var Js=({size:e=24,className:t})=>Tp("svg",{width:e,height:e,viewBox:"0 0 24 24",xmlns:"http://www.w3.org/2000/svg",fill:"white",stroke:"#6b7280",strokeWidth:"2",className:t,children:[Di("path",{d:"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"}),Di("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"}),Di("path",{d:"M7.5 7.5V10H10",strokeWidth:"1.5",fill:"none",strokeLinecap:"round",strokeLinejoin:"round"})]});import{jsx as jo,jsxs as Np}from"react/jsx-runtime";var Qs=({size:e=24,className:t})=>Np("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:[jo("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"}),jo("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"}),jo("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"}),jo("path",{d:"M13.5 12H11",strokeWidth:"1",strokeLinecap:"round",strokeLinejoin:"round"}),jo("path",{d:"M13.5 10H11",strokeWidth:"1",strokeLinecap:"round",strokeLinejoin:"round"})]});import{jsx as Wn,jsxs as vp}from"react/jsx-runtime";var en=({size:e=24,className:t})=>vp("svg",{width:e,height:e,viewBox:"0 0 24 24",xmlns:"http://www.w3.org/2000/svg",fill:"white",stroke:"currentColor",strokeWidth:2,className:t,children:[Wn("path",{d:"M20 3H4C2.89543 3 2 4.34315 2 6V18C2 19.6569 2.89543 21 4 21H20C21.1046 21 22 19.6569 22 18V6C22 4.34315 21.1046 3 20 3Z",strokeLinecap:"round",strokeLinejoin:"round"}),Wn("path",{d:"M8 21V14C8 13.4477 8.44772 13 9 13H15C15.5523 13 16 13.4477 16 14V21",strokeWidth:"1",fill:"none"}),Wn("path",{d:"M10.2222 17H13.7777",strokeWidth:"1",strokeLinecap:"round",strokeLinejoin:"round"}),Wn("path",{d:"M12 15.2227V18.7782",strokeWidth:"1",strokeLinecap:"round",strokeLinejoin:"round"})]});var le=(s=>(s.START_EVENT="START_EVENT",s.END_EVENT="END_EVENT",s.TASK="TASK",s.LANE="LANE",s.GATEWAY="GATEWAY",s.ANNOTATION="ANNOTATION",s.UNSUPPORTED="UNSUPPORTED",s))(le||{}),tt=(o=>(o.SCRIPT="SCRIPT",o.SUBPROCESS="SUBPROCESS",o))(tt||{}),Fn={SCRIPT:{icon:Ip},SUBPROCESS:{icon:Ap}},ht=(t=>(t.LOOP="LOOP",t))(ht||{}),Xn={LOOP:{icon:wp}},lt=(n=>(n.EXCLUSIVE="EXCLUSIVE",n.PARALLEL="PARALLEL",n.COMPLEX="COMPLEX",n))(lt||{}),Oi={EXCLUSIVE:{icon:No},PARALLEL:{icon:vo},COMPLEX:{icon:To}};import{useTranslation as JE}from"@produto-lecom/lecom-ui";import{ReactFlowProvider as QE}from"@xyflow/react";import{createContext as jE,useContext as e1,useEffect as t1,useId as o1,useMemo as n1,useState as pt}from"react";import{Background as IE,MiniMap as AE,ReactFlow as CE,SelectionMode as SE,useKeyPress as ME}from"@xyflow/react";import{forwardRef as PE,useImperativeHandle as LE,useRef as Ms}from"react";import{useTranslation as Z0}from"@produto-lecom/lecom-ui";import{useEdgesState as J0,useNodesState as Q0,useOnSelectionChange as j0,useReactFlow as ex,useStoreApi as tx}from"@xyflow/react";import{useCallback as bt,useEffect as ox}from"react";var Un={MIN_WIDTH:36,MIN_HEIGHT:36},$n={MIN_WIDTH:36,MIN_HEIGHT:36},wo={MIN_WIDTH:56,MIN_HEIGHT:56},kt={MIN_WIDTH:176,MIN_HEIGHT:96},js={HEADER_WIDTH:40,MIN_WIDTH:840,MIN_HEIGHT:256},se={HEADER_WIDTH:40,MIN_WIDTH:800,MIN_HEIGHT:256},Io={MIN_WIDTH:176,MIN_HEIGHT:64},Cp={MIN_WIDTH:128,MIN_HEIGHT:64},fe={START_EVENT:Un,END_EVENT:$n,GATEWAY:wo,TASK:kt,LANE:se,ANNOTATION:Io,UNSUPPORTED:Cp};import{Position as tn}from"@xyflow/react";function ea(e,t){var x,v,N,T;let{width:o=0,height:n=0}=e.measured||{width:0,height:0},r=e.internals.positionAbsolute,i=t.internals.positionAbsolute,a=o/2,s=n/2,l=r.x+a,c=r.y+s,d=i.x+((v=(x=t==null?void 0:t.measured)==null?void 0:x.width)!=null?v:0)/2,u=i.y+((T=(N=t==null?void 0:t.measured)==null?void 0:N.height)!=null?T:0)/2,m=(d-l)/(2*a)-(u-c)/(2*s),f=(d-l)/(2*a)+(u-c)/(2*s),g=1/(Math.abs(m)+Math.abs(f)||1),b=g*m,p=g*f,h=a*(b+p)+l,y=s*(-b+p)+c;return{x:h,y}}function ta(e,t){var c,d,u,m;let{positionAbsolute:o}=e.internals,n=(d=(c=e.measured)==null?void 0:c.width)!=null?d:0,r=(m=(u=e.measured)==null?void 0:u.height)!=null?m:0,i=Math.round(o.x),a=Math.round(o.y),s=Math.round(t.x),l=Math.round(t.y);return s<=i+1?tn.Left:s>=i+n-1?tn.Right:l<=a+1?tn.Top:l>=a+r-1?tn.Bottom:tn.Top}function Ao(e,t){let o=ea(e,t),n=ea(t,e),r=ta(e,o),i=ta(t,n);return{sx:o.x,sy:o.y,tx:n.x,ty:n.y,sourcePos:r,targetPos:i}}function Kn(e,t){return{isFromStartEvent:(e==null?void 0:e.type)==="START_EVENT",isGatewayToGateway:(e==null?void 0:e.type)==="GATEWAY"&&(t==null?void 0:t.type)==="GATEWAY",isActiviyToAndGateway:(e==null?void 0:e.type)==="TASK"&&(t==null?void 0:t.type)==="GATEWAY",isToEndEvent:(t==null?void 0:t.type)==="END_EVENT"}}import{orderBy as Sp}from"lodash";var oa=e=>new Map(e.map(t=>[t.id,t])),na=(e,t)=>e.map(o=>{var n;return(n=t.get(o.id))!=null?n:o}),ot=e=>{var t,o,n,r,i,a,s,l;return{x:(o=(t=e.internals)==null?void 0:t.positionAbsolute.x)!=null?o:0,y:(r=(n=e.internals)==null?void 0:n.positionAbsolute.y)!=null?r:0,w:(a=(i=e.measured)==null?void 0:i.width)!=null?a:0,h:(l=(s=e.measured)==null?void 0:s.height)!=null?l:0}},jt=e=>Sp(e,[o=>{let n=o.type==="LANE";return n&&!o.parentId?0:n?1:2}],["asc"]),ra=(e,t)=>{let{x:o,y:n}=ot(e),{x:r,y:i}=ot(t);return{x:o-r,y:n-i}};var eo=({parentId:e,nodes:t,includeTypes:o=[...Object.values(le)],excludeTypes:n=[]})=>t.some(r=>r.parentId===e&&(!o.length||o.includes(r.type))&&!n.includes(r.type)),Mp=(e,t)=>{let{x:o,y:n}=ot(e),{x:r,y:i}=ot(t),a=o-r,s=n-i;return Math.sqrt(a*a+s*s)},Pp=(e,t)=>{let{x:o,y:n,w:r,h:i}=ot(e),{x:a,y:s,w:l,h:c}=ot(t),d=o+r/2,u=n+i/2;return d>=a&&d<=a+l&&u>=s&&u<=s+c},on=(e,t)=>{let o=null,n=1/0;for(let r of t)if(r.id!==e.id&&Pp(e,r)){let i=Mp(e,r);i<n&&(n=i,o=r)}return o},ia=(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),sa=(e,t)=>{let o=e.filter(c=>!c.parentId);if(o.length===0)return{nodes:e,edges:t};let n=o.filter(c=>c.type==="LANE"),r=n.length>0?n:o,i=Math.min(...r.map(c=>c.position.x||0)),a=Math.min(...r.map(c=>c.position.y||0)),s=e.map(c=>c.parentId?c:w(_({},c),{position:{x:c.position.x-i,y:c.position.y-a}})),l=t.map(c=>{let d=c.data;return d!=null&&d.points?w(_({},c),{data:w(_({},d),{points:d.points.map(u=>({x:u.x-i,y:u.y-a}))})}):c});return{nodes:s,edges:l}},aa=e=>{var l,c;let t=e.filter(d=>!d.parentId),o=t.filter(d=>d.type==="LANE"),n=o.length>0?o:t;if(n.length===0)return null;let r=1/0,i=1/0,a=-1/0,s=-1/0;for(let d of n){let u=d.position.x+((l=d.width)!=null?l:0),m=d.position.y+((c=d.height)!=null?c:0);d.position.x<r&&(r=d.position.x),d.position.y<i&&(i=d.position.y),u>a&&(a=u),m>s&&(s=m)}return{x:r,y:i,width:a-r,height:s-i}};var Vi=(e,t)=>{let o=t.find(a=>a.id===e);if(!o||o.type!=="LANE"||o.parentId)return!1;let n=ot(o),r=n.x+n.w,i=n.y+n.h;return t.some(a=>{if(a.id===e||a.parentId||a.type==="LANE")return!1;let s=ot(a);return s.x<r&&s.x+s.w>n.x&&s.y<i&&s.y+s.h>n.y})};var Lp=50,to=(e,t)=>{var m,f,g,b,p,h,y,x,v,N,T,E,I,P,M,V;let o=t.find(C=>C.id===e);if(!o)return t;let n=(f=(m=o.position)==null?void 0:m.x)!=null?f:0,r=(b=(g=o.position)==null?void 0:g.y)!=null?b:0,i=(h=(p=o.measured)==null?void 0:p.width)!=null?h:0,a=(x=(y=o.measured)==null?void 0:y.height)!=null?x:0,s=r+a,l=n+i,c=new Set,d=1/0;for(let C of t){if(C.id===e||C.parentId)continue;let G=(N=(v=C.position)==null?void 0:v.y)!=null?N:0,K=(E=(T=C.position)==null?void 0:T.x)!=null?E:0,$=(P=(I=C.measured)==null?void 0:I.width)!=null?P:0,J=(V=(M=C.measured)==null?void 0:M.height)!=null?V:0;K<l&&K+$>n&&G<s&&G+J>r&&(c.add(C.id),d=Math.min(d,G))}if(c.size===0)return t;let u=s+Lp-d;return t.map(C=>{var K,$,J;if(!c.has(C.id))return C;let G=($=(K=C.position)==null?void 0:K.y)!=null?$:0;return w(_({},C),{position:w(_({},(J=C.position)!=null?J:{x:0,y:0}),{y:G+u})})})},_e=15,oo=e=>[...e].sort((t,o)=>t.position.y-o.position.y),kp=e=>{var t,o,n;return e.position.x+((n=(o=(t=e.measured)==null?void 0:t.width)!=null?o:e.width)!=null?n:0)},Rp=e=>{var t,o,n;return e.position.y+((n=(o=(t=e.measured)==null?void 0:t.height)!=null?o:e.height)!=null?n:0)},Hi=(e,t,o)=>{var d,u,m,f,g,b,p,h,y,x,v,N,T,E,I;if(t.length===0)return e;let n=(m=(u=e.width)!=null?u:(d=e.measured)==null?void 0:d.width)!=null?m:0,r=(b=(g=e.height)!=null?g:(f=e.measured)==null?void 0:f.height)!=null?b:0,i=0,a=0;for(let P of t){let M=kp(P),V=Rp(P);if(((h=(p=P.position)==null?void 0:p.y)!=null?h:0)<_e&&(o.set(P.id,w(_({},P),{position:w(_({},P.position),{y:_e})})),V=_e+((x=(y=P.measured)==null?void 0:y.height)!=null?x:0)),((N=(v=P.position)==null?void 0:v.x)!=null?N:0)<se.HEADER_WIDTH+_e){let C=(T=o.get(P.id))!=null?T:P;o.set(P.id,w(_({},C),{position:w(_({},C.position),{x:se.HEADER_WIDTH+_e})})),M=se.HEADER_WIDTH+_e+((I=(E=P.measured)==null?void 0:E.width)!=null?I:0)}i=Math.max(i,M),a=Math.max(a,V)}let s=Math.max(n,se.MIN_WIDTH),l=Math.max(r,se.MIN_HEIGHT);i+_e>s&&(s=i+_e),a+_e>l&&(l=a+_e);let c=w(_({},e),{width:s,height:l,measured:w(_({},e.measured),{width:s,height:l})});return o.set(e.id,c),c},la=(e,t,o)=>{var a,s;let n=oo(e),r=new Map;for(let l of o)l.parentId&&(r.has(l.parentId)||r.set(l.parentId,[]),r.get(l.parentId).push(l));let i=0;for(let l of n){let c=(a=r.get(l.id))!=null?a:[],d=Hi(l,c,t);t.set(d.id,w(_({},d),{position:{x:se.HEADER_WIDTH,y:i}})),i+=(s=d.height)!=null?s:0}},ca=(e,t)=>{var g,b,p,h;let o=[];for(let y of t.values())y.parentId===e.id&&o.push(y);let n=oo(o),r=((b=(g=e.measured)==null?void 0:g.width)!=null?b:0)-se.HEADER_WIDTH,i=ia(e.id,o)||se.MIN_WIDTH,a=o.reduce((y,x)=>{var v;return y+((v=x.height)!=null?v:se.MIN_HEIGHT)},0),s=Math.max(r,i),l=a,c=r>i,d=c?s:s+se.HEADER_WIDTH,u=c?s-se.HEADER_WIDTH:s,m=0;for(let y=0;y<n.length;y++){let x=n[y],v=Math.max(se.MIN_HEIGHT,(p=x.height)!=null?p:se.MIN_HEIGHT),N=w(_({},x),{width:u,height:v,measured:w(_({},x.measured),{width:u,height:v}),position:{x:se.HEADER_WIDTH,y:m}});if(y===o.length-1){let T=Math.max(se.MIN_HEIGHT,l-m);N=w(_({},N),{height:T,measured:w(_({},x.measured),{width:u,height:T})})}t.set(x.id,N),m+=(h=N.height)!=null?h:0}let f=Math.max(l,m);t.set(e.id,w(_({},e),{width:d,height:f,measured:w(_({},e.measured),{width:d,height:f})}))},da=(e,t,o,n,r)=>{var g,b;let i=!e.parentId,a=i?e.id:e.parentId,s=n.filter(p=>p.type==="LANE"&&p.parentId===a);if(!s.length)return n;let l=oo(s),c=l.findIndex(p=>p.id===e.id),d=(b=(g=e.position)==null?void 0:g.y)!=null?b:0,u=!i&&r!==void 0&&c>0&&Math.abs(r-d)>.5,m=0,f=[...n];return l.forEach((p,h)=>{var T,E;let y=h===l.length-1,x=p.id===e.id,N=(E=(T=p.measured)==null?void 0:T.height)!=null?E:0;x?N=o:u&&h===c-1&&(N=Math.max(se.MIN_HEIGHT,r-m)),y&&i&&(N=Math.max(se.MIN_HEIGHT,o-m)),f=f.map(I=>{if(I.id===p.id){let P=i?t-se.HEADER_WIDTH:t;return w(_({},I),{width:P,height:N,measured:w(_({},I.measured),{width:P,height:N}),position:{x:se.HEADER_WIDTH,y:m}})}return I}),x&&u?m=r+o:m+=N}),f=f.map(p=>{if(p.id===a){let h=i?t:t+se.HEADER_WIDTH;return w(_({},p),{width:h,height:i?o:m,measured:{width:h,height:i?o:m}})}return p}),f};var Gi=(e,t,o)=>{var s,l,c,d,u,m,f,g;if(e.type==="LANE")return o;let n=(l=(s=t.measured)==null?void 0:s.width)!=null?l:0,r=(d=(c=t.measured)==null?void 0:c.height)!=null?d:0;e.position.y<_e&&(e.position.y=_e),e.position.x<se.HEADER_WIDTH+_e&&(e.position.x=se.HEADER_WIDTH+_e);let i=e.position.x+((m=(u=e.measured)==null?void 0:u.width)!=null?m:0),a=e.position.y+((g=(f=e.measured)==null?void 0:f.height)!=null?g:0);return i+_e>n&&(t.width=i+_e,t.measured.width=i+_e),a+_e>r&&(t.height=a+_e,t.measured.height=a+_e),o=o.map(b=>b.id===t.id?w(_({},b),{height:t.height,width:t.width,measured:t.measured}):b.id===e.id?w(_({},b),{position:e.position}):b),o};import{create as Dp}from"zustand";import{useReactFlow as Op}from"@xyflow/react";import{useCallback as Vp}from"react";var qn=()=>{let{setEdges:e}=Op();return Vp(()=>{let o=no.getState().pathEdgeIds;e(n=>n.map(r=>w(_({},r),{selected:o.includes(r.id)})))},[e])},no=Dp((e,t)=>({statusByNodeId:{},statusData:{},pathEdgeIds:[],setTaskStatuses:o=>{o!=null&&o.length&&e(n=>{let r=_({},n.statusByNodeId),i=_({},n.statusData),a=!1;return o.forEach(s=>{let l=`${s.diagramId}-${s.activityId}`;r[s.diagramId]!==s.status&&(r[s.diagramId]=s.status,i[l]=s,a=!0)}),a?{statusByNodeId:r,statusData:i}:n})},getTaskStatus:o=>t().statusByNodeId[o]||null,clearTaskStatuses:()=>e({statusByNodeId:{},statusData:{},pathEdgeIds:[]}),setPathEdges:o=>{e({pathEdgeIds:o})},getPathEdgeIds:()=>t().pathEdgeIds,clearPathEdges:()=>{e({pathEdgeIds:[]})},calculateFlowPath:(o,n)=>{if(!o.length||!n.length)return;t().clearPathEdges();let r=n.filter(d=>t().statusByNodeId[d]);if(r.length<=1)return;let i=[],a={};o.forEach(d=>{a[d.source]||(a[d.source]=[]),a[d.source].push({targetId:d.target,edgeId:d.id})});let s=r[0],l=r[r.length-1];o.forEach(d=>{d.target===s&&i.push(d.id)}),o.forEach(d=>{d.source===l&&i.push(d.id)});let c=(d,u)=>{let m=[],f=new Set;for(m.push({node:d,path:[]}),f.add(d);m.length>0;){let{node:g,path:b}=m.shift();if(g===u)return b;let p=a[g]||[];for(let{targetId:h,edgeId:y}of p)f.has(h)||(f.add(h),m.push({node:h,path:[...b,y]}))}return[]};for(let d=0;d<r.length-1;d++){let u=r[d],m=r[d+1],f=c(u,m);f.length>0&&i.push(...f)}i.length>0&&e({pathEdgeIds:i})}}));import{useNodesInitialized as jm,useReactFlow as eg,useStore as tg}from"@xyflow/react";import{useCallback as xn,useEffect as og,useRef as ng,useState as rc}from"react";import{shallow as rg}from"zustand/shallow";var Hp={value:()=>{}};function pa(){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 Zn(o)}function Zn(e){this._=e}function Gp(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}})}Zn.prototype=pa.prototype={constructor:Zn,on:function(e,t){var o=this._,n=Gp(e+"",o),r,i=-1,a=n.length;if(arguments.length<2){for(;++i<a;)if((r=(e=n[i]).type)&&(r=Bp(o[r],e.name)))return r;return}if(t!=null&&typeof t!="function")throw new Error("invalid callback: "+t);for(;++i<a;)if(r=(e=n[i]).type)o[r]=ua(o[r],e.name,t);else if(t==null)for(r in o)o[r]=ua(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 Zn(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 Bp(e,t){for(var o=0,n=e.length,r;o<n;++o)if((r=e[o]).name===t)return r.value}function ua(e,t,o){for(var n=0,r=e.length;n<r;++n)if(e[n].name===t){e[n]=Hp,e=e.slice(0,n).concat(e.slice(n+1));break}return o!=null&&e.push({name:t,value:o}),e}var Bi=pa;var Jn="http://www.w3.org/1999/xhtml",zi={svg:"http://www.w3.org/2000/svg",xhtml:Jn,xlink:"http://www.w3.org/1999/xlink",xml:"http://www.w3.org/XML/1998/namespace",xmlns:"http://www.w3.org/2000/xmlns/"};function _t(e){var t=e+="",o=t.indexOf(":");return o>=0&&(t=e.slice(0,o))!=="xmlns"&&(e=e.slice(o+1)),zi.hasOwnProperty(t)?{space:zi[t],local:e}:e}function zp(e){return function(){var t=this.ownerDocument,o=this.namespaceURI;return o===Jn&&t.documentElement.namespaceURI===Jn?t.createElement(e):t.createElementNS(o,e)}}function Yp(e){return function(){return this.ownerDocument.createElementNS(e.space,e.local)}}function Qn(e){var t=_t(e);return(t.local?Yp:zp)(t)}function Wp(){}function ro(e){return e==null?Wp:function(){return this.querySelector(e)}}function fa(e){typeof e!="function"&&(e=ro(e));for(var t=this._groups,o=t.length,n=new Array(o),r=0;r<o;++r)for(var i=t[r],a=i.length,s=n[r]=new Array(a),l,c,d=0;d<a;++d)(l=i[d])&&(c=e.call(l,l.__data__,d,i))&&("__data__"in l&&(c.__data__=l.__data__),s[d]=c);return new Ie(n,this._parents)}function Yi(e){return e==null?[]:Array.isArray(e)?e:Array.from(e)}function Fp(){return[]}function nn(e){return e==null?Fp:function(){return this.querySelectorAll(e)}}function Xp(e){return function(){return Yi(e.apply(this,arguments))}}function ma(e){typeof e=="function"?e=Xp(e):e=nn(e);for(var t=this._groups,o=t.length,n=[],r=[],i=0;i<o;++i)for(var a=t[i],s=a.length,l,c=0;c<s;++c)(l=a[c])&&(n.push(e.call(l,l.__data__,c,a)),r.push(l));return new Ie(n,r)}function rn(e){return function(){return this.matches(e)}}function jn(e){return function(t){return t.matches(e)}}var Up=Array.prototype.find;function $p(e){return function(){return Up.call(this.children,e)}}function Kp(){return this.firstElementChild}function ga(e){return this.select(e==null?Kp:$p(typeof e=="function"?e:jn(e)))}var qp=Array.prototype.filter;function Zp(){return Array.from(this.children)}function Jp(e){return function(){return qp.call(this.children,e)}}function ha(e){return this.selectAll(e==null?Zp:Jp(typeof e=="function"?e:jn(e)))}function ya(e){typeof e!="function"&&(e=rn(e));for(var t=this._groups,o=t.length,n=new Array(o),r=0;r<o;++r)for(var i=t[r],a=i.length,s=n[r]=[],l,c=0;c<a;++c)(l=i[c])&&e.call(l,l.__data__,c,i)&&s.push(l);return new Ie(n,this._parents)}function er(e){return new Array(e.length)}function xa(){return new Ie(this._enter||this._groups.map(er),this._parents)}function sn(e,t){this.ownerDocument=e.ownerDocument,this.namespaceURI=e.namespaceURI,this._next=null,this._parent=e,this.__data__=t}sn.prototype={constructor:sn,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 Ea(e){return function(){return e}}function Qp(e,t,o,n,r,i){for(var a=0,s,l=t.length,c=i.length;a<c;++a)(s=t[a])?(s.__data__=i[a],n[a]=s):o[a]=new sn(e,i[a]);for(;a<l;++a)(s=t[a])&&(r[a]=s)}function jp(e,t,o,n,r,i,a){var s,l,c=new Map,d=t.length,u=i.length,m=new Array(d),f;for(s=0;s<d;++s)(l=t[s])&&(m[s]=f=a.call(l,l.__data__,s,t)+"",c.has(f)?r[s]=l:c.set(f,l));for(s=0;s<u;++s)f=a.call(e,i[s],s,i)+"",(l=c.get(f))?(n[s]=l,l.__data__=i[s],c.delete(f)):o[s]=new sn(e,i[s]);for(s=0;s<d;++s)(l=t[s])&&c.get(m[s])===l&&(r[s]=l)}function ef(e){return e.__data__}function ba(e,t){if(!arguments.length)return Array.from(this,ef);var o=t?jp:Qp,n=this._parents,r=this._groups;typeof e!="function"&&(e=Ea(e));for(var i=r.length,a=new Array(i),s=new Array(i),l=new Array(i),c=0;c<i;++c){var d=n[c],u=r[c],m=u.length,f=tf(e.call(d,d&&d.__data__,c,n)),g=f.length,b=s[c]=new Array(g),p=a[c]=new Array(g),h=l[c]=new Array(m);o(d,u,b,p,h,f,t);for(var y=0,x=0,v,N;y<g;++y)if(v=b[y]){for(y>=x&&(x=y+1);!(N=p[x])&&++x<g;);v._next=N||null}}return a=new Ie(a,n),a._enter=s,a._exit=l,a}function tf(e){return typeof e=="object"&&"length"in e?e:Array.from(e)}function _a(){return new Ie(this._exit||this._groups.map(er),this._parents)}function Ta(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 Na(e){for(var t=e.selection?e.selection():e,o=this._groups,n=t._groups,r=o.length,i=n.length,a=Math.min(r,i),s=new Array(r),l=0;l<a;++l)for(var c=o[l],d=n[l],u=c.length,m=s[l]=new Array(u),f,g=0;g<u;++g)(f=c[g]||d[g])&&(m[g]=f);for(;l<r;++l)s[l]=o[l];return new Ie(s,this._parents)}function va(){for(var e=this._groups,t=-1,o=e.length;++t<o;)for(var n=e[t],r=n.length-1,i=n[r],a;--r>=0;)(a=n[r])&&(i&&a.compareDocumentPosition(i)^4&&i.parentNode.insertBefore(a,i),i=a);return this}function wa(e){e||(e=of);function t(u,m){return u&&m?e(u.__data__,m.__data__):!u-!m}for(var o=this._groups,n=o.length,r=new Array(n),i=0;i<n;++i){for(var a=o[i],s=a.length,l=r[i]=new Array(s),c,d=0;d<s;++d)(c=a[d])&&(l[d]=c);l.sort(t)}return new Ie(r,this._parents).order()}function of(e,t){return e<t?-1:e>t?1:e>=t?0:NaN}function Ia(){var e=arguments[0];return arguments[0]=this,e.apply(null,arguments),this}function Aa(){return Array.from(this)}function Ca(){for(var e=this._groups,t=0,o=e.length;t<o;++t)for(var n=e[t],r=0,i=n.length;r<i;++r){var a=n[r];if(a)return a}return null}function Sa(){let e=0;for(let t of this)++e;return e}function Ma(){return!this.node()}function Pa(e){for(var t=this._groups,o=0,n=t.length;o<n;++o)for(var r=t[o],i=0,a=r.length,s;i<a;++i)(s=r[i])&&e.call(s,s.__data__,i,r);return this}function nf(e){return function(){this.removeAttribute(e)}}function rf(e){return function(){this.removeAttributeNS(e.space,e.local)}}function sf(e,t){return function(){this.setAttribute(e,t)}}function af(e,t){return function(){this.setAttributeNS(e.space,e.local,t)}}function lf(e,t){return function(){var o=t.apply(this,arguments);o==null?this.removeAttribute(e):this.setAttribute(e,o)}}function cf(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 La(e,t){var o=_t(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?rf:nf:typeof t=="function"?o.local?cf:lf:o.local?af:sf)(o,t))}function tr(e){return e.ownerDocument&&e.ownerDocument.defaultView||e.document&&e||e.defaultView}function df(e){return function(){this.style.removeProperty(e)}}function uf(e,t,o){return function(){this.style.setProperty(e,t,o)}}function pf(e,t,o){return function(){var n=t.apply(this,arguments);n==null?this.style.removeProperty(e):this.style.setProperty(e,n,o)}}function ka(e,t,o){return arguments.length>1?this.each((t==null?df:typeof t=="function"?pf:uf)(e,t,o==null?"":o)):Rt(this.node(),e)}function Rt(e,t){return e.style.getPropertyValue(t)||tr(e).getComputedStyle(e,null).getPropertyValue(t)}function ff(e){return function(){delete this[e]}}function mf(e,t){return function(){this[e]=t}}function gf(e,t){return function(){var o=t.apply(this,arguments);o==null?delete this[e]:this[e]=o}}function Ra(e,t){return arguments.length>1?this.each((t==null?ff:typeof t=="function"?gf:mf)(e,t)):this.node()[e]}function Da(e){return e.trim().split(/^|\s+/)}function Wi(e){return e.classList||new Oa(e)}function Oa(e){this._node=e,this._names=Da(e.getAttribute("class")||"")}Oa.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 Va(e,t){for(var o=Wi(e),n=-1,r=t.length;++n<r;)o.add(t[n])}function Ha(e,t){for(var o=Wi(e),n=-1,r=t.length;++n<r;)o.remove(t[n])}function hf(e){return function(){Va(this,e)}}function yf(e){return function(){Ha(this,e)}}function xf(e,t){return function(){(t.apply(this,arguments)?Va:Ha)(this,e)}}function Ga(e,t){var o=Da(e+"");if(arguments.length<2){for(var n=Wi(this.node()),r=-1,i=o.length;++r<i;)if(!n.contains(o[r]))return!1;return!0}return this.each((typeof t=="function"?xf:t?hf:yf)(o,t))}function Ef(){this.textContent=""}function bf(e){return function(){this.textContent=e}}function _f(e){return function(){var t=e.apply(this,arguments);this.textContent=t==null?"":t}}function Ba(e){return arguments.length?this.each(e==null?Ef:(typeof e=="function"?_f:bf)(e)):this.node().textContent}function Tf(){this.innerHTML=""}function Nf(e){return function(){this.innerHTML=e}}function vf(e){return function(){var t=e.apply(this,arguments);this.innerHTML=t==null?"":t}}function za(e){return arguments.length?this.each(e==null?Tf:(typeof e=="function"?vf:Nf)(e)):this.node().innerHTML}function wf(){this.nextSibling&&this.parentNode.appendChild(this)}function Ya(){return this.each(wf)}function If(){this.previousSibling&&this.parentNode.insertBefore(this,this.parentNode.firstChild)}function Wa(){return this.each(If)}function Fa(e){var t=typeof e=="function"?e:Qn(e);return this.select(function(){return this.appendChild(t.apply(this,arguments))})}function Af(){return null}function Xa(e,t){var o=typeof e=="function"?e:Qn(e),n=t==null?Af:typeof t=="function"?t:ro(t);return this.select(function(){return this.insertBefore(o.apply(this,arguments),n.apply(this,arguments)||null)})}function Cf(){var e=this.parentNode;e&&e.removeChild(this)}function Ua(){return this.each(Cf)}function Sf(){var e=this.cloneNode(!1),t=this.parentNode;return t?t.insertBefore(e,this.nextSibling):e}function Mf(){var e=this.cloneNode(!0),t=this.parentNode;return t?t.insertBefore(e,this.nextSibling):e}function $a(e){return this.select(e?Mf:Sf)}function Ka(e){return arguments.length?this.property("__data__",e):this.node().__data__}function Pf(e){return function(t){e.call(this,t,this.__data__)}}function Lf(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 kf(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 Rf(e,t,o){return function(){var n=this.__on,r,i=Pf(t);if(n){for(var a=0,s=n.length;a<s;++a)if((r=n[a]).type===e.type&&r.name===e.name){this.removeEventListener(r.type,r.listener,r.options),this.addEventListener(r.type,r.listener=i,r.options=o),r.value=t;return}}this.addEventListener(e.type,i,o),r={type:e.type,name:e.name,value:t,listener:i,options:o},n?n.push(r):this.__on=[r]}}function qa(e,t,o){var n=Lf(e+""),r,i=n.length,a;if(arguments.length<2){var s=this.node().__on;if(s){for(var l=0,c=s.length,d;l<c;++l)for(r=0,d=s[l];r<i;++r)if((a=n[r]).type===d.type&&a.name===d.name)return d.value}return}for(s=t?Rf:kf,r=0;r<i;++r)this.each(s(n[r],t,o));return this}function Za(e,t,o){var n=tr(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 Df(e,t){return function(){return Za(this,e,t)}}function Of(e,t){return function(){return Za(this,e,t.apply(this,arguments))}}function Ja(e,t){return this.each((typeof t=="function"?Of:Df)(e,t))}function*Qa(){for(var e=this._groups,t=0,o=e.length;t<o;++t)for(var n=e[t],r=0,i=n.length,a;r<i;++r)(a=n[r])&&(yield a)}var Vf=[null];function Ie(e,t){this._groups=e,this._parents=t}function ja(){return new Ie([[document.documentElement]],Vf)}function Hf(){return this}Ie.prototype=ja.prototype={constructor:Ie,select:fa,selectAll:ma,selectChild:ga,selectChildren:ha,filter:ya,data:ba,enter:xa,exit:_a,join:Ta,merge:Na,selection:Hf,order:va,sort:wa,call:Ia,nodes:Aa,node:Ca,size:Sa,empty:Ma,each:Pa,attr:La,style:ka,property:Ra,classed:Ga,text:Ba,html:za,raise:Ya,lower:Wa,append:Fa,insert:Xa,remove:Ua,clone:$a,datum:Ka,on:qa,dispatch:Ja,[Symbol.iterator]:Qa};var Tt=ja;function or(e,t,o){e.prototype=t.prototype=o,o.constructor=e}function Fi(e,t){var o=Object.create(e.prototype);for(var n in t)o[n]=t[n];return o}function cn(){}var an=.7,ir=1/an,Co="\\s*([+-]?\\d+)\\s*",ln="\\s*([+-]?(?:\\d*\\.)?\\d+(?:[eE][+-]?\\d+)?)\\s*",yt="\\s*([+-]?(?:\\d*\\.)?\\d+(?:[eE][+-]?\\d+)?)%\\s*",Gf=/^#([0-9a-f]{3,8})$/,Bf=new RegExp(`^rgb\\(${Co},${Co},${Co}\\)$`),zf=new RegExp(`^rgb\\(${yt},${yt},${yt}\\)$`),Yf=new RegExp(`^rgba\\(${Co},${Co},${Co},${ln}\\)$`),Wf=new RegExp(`^rgba\\(${yt},${yt},${yt},${ln}\\)$`),Ff=new RegExp(`^hsl\\(${ln},${yt},${yt}\\)$`),Xf=new RegExp(`^hsla\\(${ln},${yt},${yt},${ln}\\)$`),el={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};or(cn,Dt,{copy(e){return Object.assign(new this.constructor,this,e)},displayable(){return this.rgb().displayable()},hex:tl,formatHex:tl,formatHex8:Uf,formatHsl:$f,formatRgb:ol,toString:ol});function tl(){return this.rgb().formatHex()}function Uf(){return this.rgb().formatHex8()}function $f(){return ll(this).formatHsl()}function ol(){return this.rgb().formatRgb()}function Dt(e){var t,o;return e=(e+"").trim().toLowerCase(),(t=Gf.exec(e))?(o=t[1].length,t=parseInt(t[1],16),o===6?nl(t):o===3?new Ye(t>>8&15|t>>4&240,t>>4&15|t&240,(t&15)<<4|t&15,1):o===8?nr(t>>24&255,t>>16&255,t>>8&255,(t&255)/255):o===4?nr(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=Bf.exec(e))?new Ye(t[1],t[2],t[3],1):(t=zf.exec(e))?new Ye(t[1]*255/100,t[2]*255/100,t[3]*255/100,1):(t=Yf.exec(e))?nr(t[1],t[2],t[3],t[4]):(t=Wf.exec(e))?nr(t[1]*255/100,t[2]*255/100,t[3]*255/100,t[4]):(t=Ff.exec(e))?sl(t[1],t[2]/100,t[3]/100,1):(t=Xf.exec(e))?sl(t[1],t[2]/100,t[3]/100,t[4]):el.hasOwnProperty(e)?nl(el[e]):e==="transparent"?new Ye(NaN,NaN,NaN,0):null}function nl(e){return new Ye(e>>16&255,e>>8&255,e&255,1)}function nr(e,t,o,n){return n<=0&&(e=t=o=NaN),new Ye(e,t,o,n)}function Kf(e){return e instanceof cn||(e=Dt(e)),e?(e=e.rgb(),new Ye(e.r,e.g,e.b,e.opacity)):new Ye}function So(e,t,o,n){return arguments.length===1?Kf(e):new Ye(e,t,o,n==null?1:n)}function Ye(e,t,o,n){this.r=+e,this.g=+t,this.b=+o,this.opacity=+n}or(Ye,So,Fi(cn,{brighter(e){return e=e==null?ir:Math.pow(ir,e),new Ye(this.r*e,this.g*e,this.b*e,this.opacity)},darker(e){return e=e==null?an:Math.pow(an,e),new Ye(this.r*e,this.g*e,this.b*e,this.opacity)},rgb(){return this},clamp(){return new Ye(so(this.r),so(this.g),so(this.b),sr(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:rl,formatHex:rl,formatHex8:qf,formatRgb:il,toString:il}));function rl(){return`#${io(this.r)}${io(this.g)}${io(this.b)}`}function qf(){return`#${io(this.r)}${io(this.g)}${io(this.b)}${io((isNaN(this.opacity)?1:this.opacity)*255)}`}function il(){let e=sr(this.opacity);return`${e===1?"rgb(":"rgba("}${so(this.r)}, ${so(this.g)}, ${so(this.b)}${e===1?")":`, ${e})`}`}function sr(e){return isNaN(e)?1:Math.max(0,Math.min(1,e))}function so(e){return Math.max(0,Math.min(255,Math.round(e)||0))}function io(e){return e=so(e),(e<16?"0":"")+e.toString(16)}function sl(e,t,o,n){return n<=0?e=t=o=NaN:o<=0||o>=1?e=t=NaN:t<=0&&(e=NaN),new ct(e,t,o,n)}function ll(e){if(e instanceof ct)return new ct(e.h,e.s,e.l,e.opacity);if(e instanceof cn||(e=Dt(e)),!e)return new ct;if(e instanceof ct)return e;e=e.rgb();var t=e.r/255,o=e.g/255,n=e.b/255,r=Math.min(t,o,n),i=Math.max(t,o,n),a=NaN,s=i-r,l=(i+r)/2;return s?(t===i?a=(o-n)/s+(o<n)*6:o===i?a=(n-t)/s+2:a=(t-o)/s+4,s/=l<.5?i+r:2-i-r,a*=60):s=l>0&&l<1?0:a,new ct(a,s,l,e.opacity)}function cl(e,t,o,n){return arguments.length===1?ll(e):new ct(e,t,o,n==null?1:n)}function ct(e,t,o,n){this.h=+e,this.s=+t,this.l=+o,this.opacity=+n}or(ct,cl,Fi(cn,{brighter(e){return e=e==null?ir:Math.pow(ir,e),new ct(this.h,this.s,this.l*e,this.opacity)},darker(e){return e=e==null?an:Math.pow(an,e),new ct(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 Ye(Xi(e>=240?e-240:e+120,r,n),Xi(e,r,n),Xi(e<120?e+240:e-120,r,n),this.opacity)},clamp(){return new ct(al(this.h),rr(this.s),rr(this.l),sr(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=sr(this.opacity);return`${e===1?"hsl(":"hsla("}${al(this.h)}, ${rr(this.s)*100}%, ${rr(this.l)*100}%${e===1?")":`, ${e})`}`}}));function al(e){return e=(e||0)%360,e<0?e+360:e}function rr(e){return Math.max(0,Math.min(1,e||0))}function Xi(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 Ui(e,t,o,n,r){var i=e*e,a=i*e;return((1-3*e+3*i-a)*t+(4-6*i+3*a)*o+(1+3*e+3*i-3*a)*n+a*r)/6}function dl(e){var t=e.length-1;return function(o){var n=o<=0?o=0:o>=1?(o=1,t-1):Math.floor(o*t),r=e[n],i=e[n+1],a=n>0?e[n-1]:2*r-i,s=n<t-1?e[n+2]:2*i-r;return Ui((o-n/t)*t,a,r,i,s)}}function ul(e){var t=e.length;return function(o){var n=Math.floor(((o%=1)<0?++o:o)*t),r=e[(n+t-1)%t],i=e[n%t],a=e[(n+1)%t],s=e[(n+2)%t];return Ui((o-n/t)*t,r,i,a,s)}}var $i=e=>()=>e;function Zf(e,t){return function(o){return e+o*t}}function Jf(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 pl(e){return(e=+e)==1?ar:function(t,o){return o-t?Jf(t,o,e):$i(isNaN(t)?o:t)}}function ar(e,t){var o=t-e;return o?Zf(e,o):$i(isNaN(e)?t:e)}var lr=function e(t){var o=pl(t);function n(r,i){var a=o((r=So(r)).r,(i=So(i)).r),s=o(r.g,i.g),l=o(r.b,i.b),c=ar(r.opacity,i.opacity);return function(d){return r.r=a(d),r.g=s(d),r.b=l(d),r.opacity=c(d),r+""}}return n.gamma=e,n}(1);function fl(e){return function(t){var o=t.length,n=new Array(o),r=new Array(o),i=new Array(o),a,s;for(a=0;a<o;++a)s=So(t[a]),n[a]=s.r||0,r[a]=s.g||0,i[a]=s.b||0;return n=e(n),r=e(r),i=e(i),s.opacity=1,function(l){return s.r=n(l),s.g=r(l),s.b=i(l),s+""}}}var Qf=fl(dl),jf=fl(ul);function nt(e,t){return e=+e,t=+t,function(o){return e*(1-o)+t*o}}var qi=/[-+]?(?:\d+\.?\d*|\.?\d+)(?:[eE][-+]?\d+)?/g,Ki=new RegExp(qi.source,"g");function em(e){return function(){return e}}function tm(e){return function(t){return e(t)+""}}function Zi(e,t){var o=qi.lastIndex=Ki.lastIndex=0,n,r,i,a=-1,s=[],l=[];for(e=e+"",t=t+"";(n=qi.exec(e))&&(r=Ki.exec(t));)(i=r.index)>o&&(i=t.slice(o,i),s[a]?s[a]+=i:s[++a]=i),(n=n[0])===(r=r[0])?s[a]?s[a]+=r:s[++a]=r:(s[++a]=null,l.push({i:a,x:nt(n,r)})),o=Ki.lastIndex;return o<t.length&&(i=t.slice(o),s[a]?s[a]+=i:s[++a]=i),s.length<2?l[0]?tm(l[0].x):em(t):(t=l.length,function(c){for(var d=0,u;d<t;++d)s[(u=l[d]).i]=u.x(c);return s.join("")})}var ml=180/Math.PI,cr={translateX:0,translateY:0,rotate:0,skewX:0,scaleX:1,scaleY:1};function Ji(e,t,o,n,r,i){var a,s,l;return(a=Math.sqrt(e*e+t*t))&&(e/=a,t/=a),(l=e*o+t*n)&&(o-=e*l,n-=t*l),(s=Math.sqrt(o*o+n*n))&&(o/=s,n/=s,l/=s),e*n<t*o&&(e=-e,t=-t,l=-l,a=-a),{translateX:r,translateY:i,rotate:Math.atan2(t,e)*ml,skewX:Math.atan(l)*ml,scaleX:a,scaleY:s}}var dr;function gl(e){let t=new(typeof DOMMatrix=="function"?DOMMatrix:WebKitCSSMatrix)(e+"");return t.isIdentity?cr:Ji(t.a,t.b,t.c,t.d,t.e,t.f)}function hl(e){return e==null?cr:(dr||(dr=document.createElementNS("http://www.w3.org/2000/svg","g")),dr.setAttribute("transform",e),(e=dr.transform.baseVal.consolidate())?(e=e.matrix,Ji(e.a,e.b,e.c,e.d,e.e,e.f)):cr)}function yl(e,t,o,n){function r(c){return c.length?c.pop()+" ":""}function i(c,d,u,m,f,g){if(c!==u||d!==m){var b=f.push("translate(",null,t,null,o);g.push({i:b-4,x:nt(c,u)},{i:b-2,x:nt(d,m)})}else(u||m)&&f.push("translate("+u+t+m+o)}function a(c,d,u,m){c!==d?(c-d>180?d+=360:d-c>180&&(c+=360),m.push({i:u.push(r(u)+"rotate(",null,n)-2,x:nt(c,d)})):d&&u.push(r(u)+"rotate("+d+n)}function s(c,d,u,m){c!==d?m.push({i:u.push(r(u)+"skewX(",null,n)-2,x:nt(c,d)}):d&&u.push(r(u)+"skewX("+d+n)}function l(c,d,u,m,f,g){if(c!==u||d!==m){var b=f.push(r(f)+"scale(",null,",",null,")");g.push({i:b-4,x:nt(c,u)},{i:b-2,x:nt(d,m)})}else(u!==1||m!==1)&&f.push(r(f)+"scale("+u+","+m+")")}return function(c,d){var u=[],m=[];return c=e(c),d=e(d),i(c.translateX,c.translateY,d.translateX,d.translateY,u,m),a(c.rotate,d.rotate,u,m),s(c.skewX,d.skewX,u,m),l(c.scaleX,c.scaleY,d.scaleX,d.scaleY,u,m),c=d=null,function(f){for(var g=-1,b=m.length,p;++g<b;)u[(p=m[g]).i]=p.x(f);return u.join("")}}}var Qi=yl(gl,"px, ","px)","deg)"),ji=yl(hl,", ",")",")");var Mo=0,un=0,dn=0,El=1e3,ur,pn,pr=0,ao=0,fr=0,fn=typeof performance=="object"&&performance.now?performance:Date,bl=typeof window=="object"&&window.requestAnimationFrame?window.requestAnimationFrame.bind(window):function(e){setTimeout(e,17)};function gn(){return ao||(bl(om),ao=fn.now()+fr)}function om(){ao=0}function mn(){this._call=this._time=this._next=null}mn.prototype=mr.prototype={constructor:mn,restart:function(e,t,o){if(typeof e!="function")throw new TypeError("callback is not a function");o=(o==null?gn():+o)+(t==null?0:+t),!this._next&&pn!==this&&(pn?pn._next=this:ur=this,pn=this),this._call=e,this._time=o,es()},stop:function(){this._call&&(this._call=null,this._time=1/0,es())}};function mr(e,t,o){var n=new mn;return n.restart(e,t,o),n}function _l(){gn(),++Mo;for(var e=ur,t;e;)(t=ao-e._time)>=0&&e._call.call(void 0,t),e=e._next;--Mo}function xl(){ao=(pr=fn.now())+fr,Mo=un=0;try{_l()}finally{Mo=0,rm(),ao=0}}function nm(){var e=fn.now(),t=e-pr;t>El&&(fr-=t,pr=e)}function rm(){for(var e,t=ur,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:ur=o);pn=e,es(n)}function es(e){if(!Mo){un&&(un=clearTimeout(un));var t=e-ao;t>24?(e<1/0&&(un=setTimeout(xl,e-fn.now()-fr)),dn&&(dn=clearInterval(dn))):(dn||(pr=fn.now(),dn=setInterval(nm,El)),Mo=1,bl(xl))}}function gr(e,t,o){var n=new mn;return t=t==null?0:+t,n.restart(r=>{n.stop(),e(r+t)},t,o),n}var im=Bi("start","end","cancel","interrupt"),sm=[],vl=0,Tl=1,yr=2,hr=3,Nl=4,xr=5,hn=6;function Ot(e,t,o,n,r,i){var a=e.__transition;if(!a)e.__transition={};else if(o in a)return;am(e,o,{name:t,index:n,group:r,on:im,tween:sm,time:i.time,delay:i.delay,duration:i.duration,ease:i.ease,timer:null,state:vl})}function yn(e,t){var o=Ae(e,t);if(o.state>vl)throw new Error("too late; already scheduled");return o}function Le(e,t){var o=Ae(e,t);if(o.state>hr)throw new Error("too late; already running");return o}function Ae(e,t){var o=e.__transition;if(!o||!(o=o[t]))throw new Error("transition not found");return o}function am(e,t,o){var n=e.__transition,r;n[t]=o,o.timer=mr(i,0,o.time);function i(c){o.state=Tl,o.timer.restart(a,o.delay,o.time),o.delay<=c&&a(c-o.delay)}function a(c){var d,u,m,f;if(o.state!==Tl)return l();for(d in n)if(f=n[d],f.name===o.name){if(f.state===hr)return gr(a);f.state===Nl?(f.state=hn,f.timer.stop(),f.on.call("interrupt",e,e.__data__,f.index,f.group),delete n[d]):+d<t&&(f.state=hn,f.timer.stop(),f.on.call("cancel",e,e.__data__,f.index,f.group),delete n[d])}if(gr(function(){o.state===hr&&(o.state=Nl,o.timer.restart(s,o.delay,o.time),s(c))}),o.state=yr,o.on.call("start",e,e.__data__,o.index,o.group),o.state===yr){for(o.state=hr,r=new Array(m=o.tween.length),d=0,u=-1;d<m;++d)(f=o.tween[d].value.call(e,e.__data__,o.index,o.group))&&(r[++u]=f);r.length=u+1}}function s(c){for(var d=c<o.duration?o.ease.call(null,c/o.duration):(o.timer.restart(l),o.state=xr,1),u=-1,m=r.length;++u<m;)r[u].call(e,d);o.state===xr&&(o.on.call("end",e,e.__data__,o.index,o.group),l())}function l(){o.state=hn,o.timer.stop(),delete n[t];for(var c in n)return;delete e.__transition}}function ts(e,t){var o=e.__transition,n,r,i=!0,a;if(o){t=t==null?null:t+"";for(a in o){if((n=o[a]).name!==t){i=!1;continue}r=n.state>yr&&n.state<xr,n.state=hn,n.timer.stop(),n.on.call(r?"interrupt":"cancel",e,e.__data__,n.index,n.group),delete o[a]}i&&delete e.__transition}}function wl(e){return this.each(function(){ts(this,e)})}function lm(e,t){var o,n;return function(){var r=Le(this,e),i=r.tween;if(i!==o){n=o=i;for(var a=0,s=n.length;a<s;++a)if(n[a].name===t){n=n.slice(),n.splice(a,1);break}}r.tween=n}}function cm(e,t,o){var n,r;if(typeof o!="function")throw new Error;return function(){var i=Le(this,e),a=i.tween;if(a!==n){r=(n=a).slice();for(var s={name:t,value:o},l=0,c=r.length;l<c;++l)if(r[l].name===t){r[l]=s;break}l===c&&r.push(s)}i.tween=r}}function Il(e,t){var o=this._id;if(e+="",arguments.length<2){for(var n=Ae(this.node(),o).tween,r=0,i=n.length,a;r<i;++r)if((a=n[r]).name===e)return a.value;return null}return this.each((t==null?lm:cm)(o,e,t))}function Po(e,t,o){var n=e._id;return e.each(function(){var r=Le(this,n);(r.value||(r.value={}))[t]=o.apply(this,arguments)}),function(r){return Ae(r,n).value[t]}}function Er(e,t){var o;return(typeof t=="number"?nt:t instanceof Dt?lr:(o=Dt(t))?(t=o,lr):Zi)(e,t)}function dm(e){return function(){this.removeAttribute(e)}}function um(e){return function(){this.removeAttributeNS(e.space,e.local)}}function pm(e,t,o){var n,r=o+"",i;return function(){var a=this.getAttribute(e);return a===r?null:a===n?i:i=t(n=a,o)}}function fm(e,t,o){var n,r=o+"",i;return function(){var a=this.getAttributeNS(e.space,e.local);return a===r?null:a===n?i:i=t(n=a,o)}}function mm(e,t,o){var n,r,i;return function(){var a,s=o(this),l;return s==null?void this.removeAttribute(e):(a=this.getAttribute(e),l=s+"",a===l?null:a===n&&l===r?i:(r=l,i=t(n=a,s)))}}function gm(e,t,o){var n,r,i;return function(){var a,s=o(this),l;return s==null?void this.removeAttributeNS(e.space,e.local):(a=this.getAttributeNS(e.space,e.local),l=s+"",a===l?null:a===n&&l===r?i:(r=l,i=t(n=a,s)))}}function Al(e,t){var o=_t(e),n=o==="transform"?ji:Er;return this.attrTween(e,typeof t=="function"?(o.local?gm:mm)(o,n,Po(this,"attr."+e,t)):t==null?(o.local?um:dm)(o):(o.local?fm:pm)(o,n,t))}function hm(e,t){return function(o){this.setAttribute(e,t.call(this,o))}}function ym(e,t){return function(o){this.setAttributeNS(e.space,e.local,t.call(this,o))}}function xm(e,t){var o,n;function r(){var i=t.apply(this,arguments);return i!==n&&(o=(n=i)&&ym(e,i)),o}return r._value=t,r}function Em(e,t){var o,n;function r(){var i=t.apply(this,arguments);return i!==n&&(o=(n=i)&&hm(e,i)),o}return r._value=t,r}function Cl(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=_t(e);return this.tween(o,(n.local?xm:Em)(n,t))}function bm(e,t){return function(){yn(this,e).delay=+t.apply(this,arguments)}}function _m(e,t){return t=+t,function(){yn(this,e).delay=t}}function Sl(e){var t=this._id;return arguments.length?this.each((typeof e=="function"?bm:_m)(t,e)):Ae(this.node(),t).delay}function Tm(e,t){return function(){Le(this,e).duration=+t.apply(this,arguments)}}function Nm(e,t){return t=+t,function(){Le(this,e).duration=t}}function Ml(e){var t=this._id;return arguments.length?this.each((typeof e=="function"?Tm:Nm)(t,e)):Ae(this.node(),t).duration}function vm(e,t){if(typeof t!="function")throw new Error;return function(){Le(this,e).ease=t}}function Pl(e){var t=this._id;return arguments.length?this.each(vm(t,e)):Ae(this.node(),t).ease}function wm(e,t){return function(){var o=t.apply(this,arguments);if(typeof o!="function")throw new Error;Le(this,e).ease=o}}function Ll(e){if(typeof e!="function")throw new Error;return this.each(wm(this._id,e))}function kl(e){typeof e!="function"&&(e=rn(e));for(var t=this._groups,o=t.length,n=new Array(o),r=0;r<o;++r)for(var i=t[r],a=i.length,s=n[r]=[],l,c=0;c<a;++c)(l=i[c])&&e.call(l,l.__data__,c,i)&&s.push(l);return new Ve(n,this._parents,this._name,this._id)}function Rl(e){if(e._id!==this._id)throw new Error;for(var t=this._groups,o=e._groups,n=t.length,r=o.length,i=Math.min(n,r),a=new Array(n),s=0;s<i;++s)for(var l=t[s],c=o[s],d=l.length,u=a[s]=new Array(d),m,f=0;f<d;++f)(m=l[f]||c[f])&&(u[f]=m);for(;s<n;++s)a[s]=t[s];return new Ve(a,this._parents,this._name,this._id)}function Im(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 Am(e,t,o){var n,r,i=Im(t)?yn:Le;return function(){var a=i(this,e),s=a.on;s!==n&&(r=(n=s).copy()).on(t,o),a.on=r}}function Dl(e,t){var o=this._id;return arguments.length<2?Ae(this.node(),o).on.on(e):this.each(Am(o,e,t))}function Cm(e){return function(){var t=this.parentNode;for(var o in this.__transition)if(+o!==e)return;t&&t.removeChild(this)}}function Ol(){return this.on("end.remove",Cm(this._id))}function Vl(e){var t=this._name,o=this._id;typeof e!="function"&&(e=ro(e));for(var n=this._groups,r=n.length,i=new Array(r),a=0;a<r;++a)for(var s=n[a],l=s.length,c=i[a]=new Array(l),d,u,m=0;m<l;++m)(d=s[m])&&(u=e.call(d,d.__data__,m,s))&&("__data__"in d&&(u.__data__=d.__data__),c[m]=u,Ot(c[m],t,o,m,c,Ae(d,o)));return new Ve(i,this._parents,t,o)}function Hl(e){var t=this._name,o=this._id;typeof e!="function"&&(e=nn(e));for(var n=this._groups,r=n.length,i=[],a=[],s=0;s<r;++s)for(var l=n[s],c=l.length,d,u=0;u<c;++u)if(d=l[u]){for(var m=e.call(d,d.__data__,u,l),f,g=Ae(d,o),b=0,p=m.length;b<p;++b)(f=m[b])&&Ot(f,t,o,b,m,g);i.push(m),a.push(d)}return new Ve(i,a,t,o)}var Sm=Tt.prototype.constructor;function Gl(){return new Sm(this._groups,this._parents)}function Mm(e,t){var o,n,r;return function(){var i=Rt(this,e),a=(this.style.removeProperty(e),Rt(this,e));return i===a?null:i===o&&a===n?r:r=t(o=i,n=a)}}function Bl(e){return function(){this.style.removeProperty(e)}}function Pm(e,t,o){var n,r=o+"",i;return function(){var a=Rt(this,e);return a===r?null:a===n?i:i=t(n=a,o)}}function Lm(e,t,o){var n,r,i;return function(){var a=Rt(this,e),s=o(this),l=s+"";return s==null&&(l=s=(this.style.removeProperty(e),Rt(this,e))),a===l?null:a===n&&l===r?i:(r=l,i=t(n=a,s))}}function km(e,t){var o,n,r,i="style."+t,a="end."+i,s;return function(){var l=Le(this,e),c=l.on,d=l.value[i]==null?s||(s=Bl(t)):void 0;(c!==o||r!==d)&&(n=(o=c).copy()).on(a,r=d),l.on=n}}function zl(e,t,o){var n=(e+="")=="transform"?Qi:Er;return t==null?this.styleTween(e,Mm(e,n)).on("end.style."+e,Bl(e)):typeof t=="function"?this.styleTween(e,Lm(e,n,Po(this,"style."+e,t))).each(km(this._id,e)):this.styleTween(e,Pm(e,n,t),o).on("end.style."+e,null)}function Rm(e,t,o){return function(n){this.style.setProperty(e,t.call(this,n),o)}}function Dm(e,t,o){var n,r;function i(){var a=t.apply(this,arguments);return a!==r&&(n=(r=a)&&Rm(e,a,o)),n}return i._value=t,i}function Yl(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,Dm(e,t,o==null?"":o))}function Om(e){return function(){this.textContent=e}}function Vm(e){return function(){var t=e(this);this.textContent=t==null?"":t}}function Wl(e){return this.tween("text",typeof e=="function"?Vm(Po(this,"text",e)):Om(e==null?"":e+""))}function Hm(e){return function(t){this.textContent=e.call(this,t)}}function Gm(e){var t,o;function n(){var r=e.apply(this,arguments);return r!==o&&(t=(o=r)&&Hm(r)),t}return n._value=e,n}function Fl(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,Gm(e))}function Xl(){for(var e=this._name,t=this._id,o=br(),n=this._groups,r=n.length,i=0;i<r;++i)for(var a=n[i],s=a.length,l,c=0;c<s;++c)if(l=a[c]){var d=Ae(l,t);Ot(l,e,o,c,a,{time:d.time+d.delay+d.duration,delay:0,duration:d.duration,ease:d.ease})}return new Ve(n,this._parents,e,o)}function Ul(){var e,t,o=this,n=o._id,r=o.size();return new Promise(function(i,a){var s={value:a},l={value:function(){--r===0&&i()}};o.each(function(){var c=Le(this,n),d=c.on;d!==e&&(t=(e=d).copy(),t._.cancel.push(s),t._.interrupt.push(s),t._.end.push(l)),c.on=t}),r===0&&i()})}var Bm=0;function Ve(e,t,o,n){this._groups=e,this._parents=t,this._name=o,this._id=n}function $l(e){return Tt().transition(e)}function br(){return++Bm}var Nt=Tt.prototype;Ve.prototype=$l.prototype={constructor:Ve,select:Vl,selectAll:Hl,selectChild:Nt.selectChild,selectChildren:Nt.selectChildren,filter:kl,merge:Rl,selection:Gl,transition:Xl,call:Nt.call,nodes:Nt.nodes,node:Nt.node,size:Nt.size,empty:Nt.empty,each:Nt.each,on:Dl,attr:Al,attrTween:Cl,style:zl,styleTween:Yl,text:Wl,textTween:Fl,remove:Ol,tween:Il,delay:Sl,duration:Ml,ease:Pl,easeVarying:Ll,end:Ul,[Symbol.iterator]:Nt[Symbol.iterator]};function _r(e){return((e*=2)<=1?e*e*e:(e-=2)*e*e+2)/2}var zm={time:null,delay:0,duration:250,ease:_r};function Ym(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 Kl(e){var t,o;e instanceof Ve?(t=e._id,e=e._name):(t=br(),(o=zm).time=gn(),e=e==null?null:e+"");for(var n=this._groups,r=n.length,i=0;i<r;++i)for(var a=n[i],s=a.length,l,c=0;c<s;++c)(l=a[c])&&Ot(l,e,t,c,a,o||Ym(l,t));return new Ve(n,this._parents,e,t)}Tt.prototype.interrupt=wl;Tt.prototype.transition=Kl;function Vt(e,t,o){this.k=e,this.x=t,this.y=o}Vt.prototype={constructor:Vt,scale:function(e){return e===1?this:new Vt(this.k*e,this.x,this.y)},translate:function(e,t){return e===0&t===0?this:new Vt(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 Tr=new Vt(1,0,0);Nr.prototype=Vt.prototype;function Nr(e){for(;!e.__zoom;)if(!(e=e.parentNode))return Tr;return e.__zoom}var Fm=[[Number.NEGATIVE_INFINITY,Number.NEGATIVE_INFINITY],[Number.POSITIVE_INFINITY,Number.POSITIVE_INFINITY]];var ql;(function(e){e.Strict="strict",e.Loose="loose"})(ql||(ql={}));var Zl;(function(e){e.Free="free",e.Vertical="vertical",e.Horizontal="horizontal"})(Zl||(Zl={}));var Jl;(function(e){e.Partial="partial",e.Full="full"})(Jl||(Jl={}));var Ql;(function(e){e.Bezier="default",e.Straight="straight",e.Step="step",e.SmoothStep="smoothstep",e.SimpleBezier="simplebezier"})(Ql||(Ql={}));var jl;(function(e){e.Arrow="arrow",e.ArrowClosed="arrowclosed"})(jl||(jl={}));var We;(function(e){e.Left="left",e.Top="top",e.Right="right",e.Bottom="bottom"})(We||(We={}));var Xw={[We.Left]:We.Right,[We.Right]:We.Left,[We.Top]:We.Bottom,[We.Bottom]:We.Top};var Xm=e=>"id"in e&&"internals"in e&&!("source"in e)&&!("target"in e);var Um=(e,t=[0,0])=>{var s;let{width:o,height:n}=$m(e),r=(s=e.origin)!=null?s:t,i=o*r[0],a=n*r[1];return{x:e.position.x-i,y:e.position.y-a}};var vr=(e,t=[0,0])=>{var r,i,a,s,l,c,d,u;let{x:o,y:n}=Xm(e)?e.internals.positionAbsolute:Um(e,t);return{x:o,y:n,x2:o+((s=(a=(i=(r=e.measured)==null?void 0:r.width)!=null?i:e.width)!=null?a:e.initialWidth)!=null?s:0),y2:n+((u=(d=(c=(l=e.measured)==null?void 0:l.height)!=null?c:e.height)!=null?d:e.initialHeight)!=null?u:0)}};function $m(e){var t,o,n,r,i,a,s,l;return{width:(r=(n=(o=(t=e.measured)==null?void 0:t.width)!=null?o:e.width)!=null?n:e.initialWidth)!=null?r:0,height:(l=(s=(a=(i=e.measured)==null?void 0:i.height)!=null?a:e.height)!=null?s:e.initialHeight)!=null?l:0}}var Uw={[We.Left]:{x:-1,y:0},[We.Right]:{x:1,y:0},[We.Top]:{x:0,y:-1},[We.Bottom]:{x:0,y:1}};var Km={nodeOrigin:[0,0],nodeExtent:Fm,elevateNodesOnSelect:!0,defaults:{}},$w=w(_({},Km),{checkEquality:!0});var ec;(function(e){e.Line="line",e.Handle="handle"})(ec||(ec={}));var qm={width:0,height:0,x:0,y:0},Kw=w(_({},qm),{pointerX:0,pointerY:0,aspectRatio:1});var Zm=(e,t)=>e.x<t.x2&&e.x2>t.x&&e.y<t.y2&&e.y2>t.y;function Jm(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 Qm(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 wr=class{constructor(){this.xLines=[];this.yLines=[]}initialize(t){this.xLines=t.filter(o=>o.orientation==="vertical"),this.yLines=t.filter(o=>o.orientation==="horizontal"),this.xLines.sort((o,n)=>o.position-n.position),this.yLines.sort((o,n)=>o.position-n.position),this.lastHorizontalLine=void 0,this.lastVerticalLine=void 0}search(t,o,n,r,i){let a=t==="horizontal"?this.yLines:this.xLines,[s,l]=t==="horizontal"?[r.y,r.y2]:[r.x,r.x2],c=[];for(let f of a){if(f.position<s)continue;if(f.position>l)break;if(i.has(f.node.id)||f.node.parentId&&i.has(f.node.parentId)||!Zm(f.nodeBox,r))continue;let g=Math.abs(f.position-o);if(g>Ir)continue;let p=Jm(f.nodeBox,n)>0?0:Qm(f.nodeBox,n);c.push({line:f,lineDist:g,nodeDist:p})}let d=.5,u=t==="horizontal"?this.lastHorizontalLine:this.lastVerticalLine;c.sort((f,g)=>{if(u){if(f.line===u&&g.line!==u)return-1;if(g.line===u&&f.line!==u)return 1}return Math.abs(f.lineDist-g.lineDist)<=d?f.nodeDist-g.nodeDist:f.lineDist-g.lineDist});let m=c.length>0?c[0].line:void 0;return m&&(t==="horizontal"?this.lastHorizontalLine=m:this.lastVerticalLine=m),m}};function tc(e,t=lo,o){let n=[];return e==null||e.forEach(r=>{let i=o(r.id);if(!i)throw new Error(`Node with id ${r.id} not found in internal nodes.`);let a=vr(i);Object.entries(t).forEach(([s,l])=>{var c;n.push({position:l.resolve(r,a),color:(c=r.style)==null?void 0:c.backgroundColor,orientation:l.orientation,anchorName:s,nodeBox:a,node:r})})}),n}function oc(e,t,o,n,r=Object.keys(lo)){let i=[];for(let s of r){let l=lo[s],c=l.resolve(null,o),d=e.search(l.orientation,c,o,t,n);d&&i.push({sourcePosition:c,anchorName:s,anchor:l,line:d})}let a={horizontal:void 0,vertical:void 0};for(let s of i){let l=a[s.anchor.orientation],c=Math.abs(s.sourcePosition-s.line.position);(!l||c<Math.abs(l.sourcePosition-l.line.position))&&(a[s.anchor.orientation]=s)}return a}function nc(e,t,o){let n=0,r=0,i=!1,a=!1;if(t){let l=t.anchor.resolve(null,e)-t.line.position;Math.abs(l)<=Ir&&(r=l,a=!0)}if(o){let l=o.anchor.resolve(null,e)-o.line.position;Math.abs(l)<=Ir&&(n=l,i=!0)}return{deltaX:n,deltaY:r,snappedX:i,snappedY:a}}var Ir=10,lo={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 sg}from"react/jsx-runtime";var ig=new wr;function Ar(){let[e,t]=rc(void 0),[o,n]=rc(void 0),{width:r,height:i}=tg(p=>({width:p.width,height:p.height}),rg),a=jm(),s=ng(ig),{screenToFlowPosition:l,getInternalNode:c,getNodes:d}=eg(),u=xn(()=>{t(void 0),n(void 0)},[]),m=xn(p=>{let h=p!=null?p:d();u();let y=tc(h,lo,c);s.current.initialize(y)},[c,u,d]),f=xn(()=>{setTimeout(()=>{m()},100)},[m]);og(()=>{a&&m(d())},[a,m,d]);let g=xn((p,h)=>{var B,z,O,k,F,ee,U,Q,j,oe;if(!s.current||p.length===0||p.filter(X=>X.type==="dimensions").length>1)return p;u();let x=p.filter(X=>X.type==="position"&&!!X.position),v=p.find(X=>X.type==="dimensions");if(x.length===0&&!v)return p;let N=Object.keys(lo),T=new Set,E=1/0,I=1/0,P=-1/0,M=-1/0;if(x.length>0)x.forEach(X=>{var ie,ue,pe,he,Ne,ke;let ce=h.find(Ge=>Ge.id===X.id);if(!ce)return;T.add(ce.id);let ne=c(ce.id);if(!ne)return;let q=ne.parentId?c(ne.parentId):void 0,xe=X.position.x+((ie=q==null?void 0:q.internals.positionAbsolute.x)!=null?ie:0),W=X.position.y+((ue=q==null?void 0:q.internals.positionAbsolute.y)!=null?ue:0),ae=(he=(pe=ce.measured)==null?void 0:pe.width)!=null?he:0,re=(ke=(Ne=ce.measured)==null?void 0:Ne.height)!=null?ke:0;E=Math.min(E,xe),I=Math.min(I,W),P=Math.max(P,xe+ae),M=Math.max(M,W+re)}),v&&(N=["top","left"]);else if(v){let X=h.find(ae=>ae.id===v.id);if(!X)return p;T.add(X.id);let ce=c(X.id);if(!ce)return p;let ne=ce.internals.positionAbsolute.x,q=ce.internals.positionAbsolute.y,xe=(k=(O=(B=v.dimensions)==null?void 0:B.width)!=null?O:(z=X.measured)==null?void 0:z.width)!=null?k:0,W=(Q=(U=(F=v.dimensions)==null?void 0:F.height)!=null?U:(ee=X.measured)==null?void 0:ee.height)!=null?Q:0;E=ne,I=q,P=ne+xe,M=q+W,N=["right","bottom"]}if(E===1/0)return p;let V={x:E,y:I,x2:P,y2:M},{x:C,y:G}=l({x:0,y:0}),{x:K,y:$}=l({x:r,y:i}),J={x:C,y:G,x2:K,y2:$},{horizontal:Y,vertical:S}=oc(s.current,J,V,T,N),{deltaX:R,deltaY:D,snappedX:A,snappedY:L}=nc(V,Y,S);if(A||L){let X=x.some(ne=>ne.dragging),ce=!!(v!=null&&v.resizing);(X||ce)&&(A&&n(S==null?void 0:S.line),L&&t(Y==null?void 0:Y.line)),A&&(x.forEach(ne=>{ne.position&&(ne.position.x-=R)}),(v==null?void 0:v.id)===((j=x[0])==null?void 0:j.id)?v.dimensions&&(v.dimensions.width+=R):v&&!x.length&&v.dimensions&&(v.dimensions.width-=R)),L&&(x.forEach(ne=>{ne.position&&(ne.position.y-=D)}),(v==null?void 0:v.id)===((oe=x[0])==null?void 0:oe.id)?v.dimensions&&(v.dimensions.height+=D):v&&!x.length&&v.dimensions&&(v.dimensions.height-=D))}return p},[l,c,r,i,t,n,u]),b=xn(()=>sg(ic,{horizontal:e,vertical:o}),[e,o]);return{rebuildIndex:m,forceRebuildIndex:f,updateHelperLines:g,helperLineHorizontal:e,helperLineVertical:o,HelperLines:b}}import{reconnectEdge as u0,useReactFlow as p0}from"@xyflow/react";import{useCallback as go,useRef as f0}from"react";var vt=e=>new Map(e.map(t=>[t.id,t])),En=(e,t,o)=>t.filter(n=>!(n.source!==e||o&&n.id===o)),sc=(e,t,o)=>t.filter(n=>!(n.target!==e||o&&n.id===o)),os=e=>e.some(t=>t.type==="START_EVENT"),Ht=(e,t)=>e==="START_EVENT"?!os(t):!0,ac=(e,t,o,n,r)=>{let i=vt(o),a=i.get(e);if(!a||a.type!=="START_EVENT")return!1;let s=i.get(t);return(s==null?void 0:s.type)==="ANNOTATION"?!1:En(e,n,r).filter(c=>{let d=i.get(c.target);return(d==null?void 0:d.type)!=="ANNOTATION"}).length>=1},lc=(e,t,o,n,r)=>{let i=vt(o),a=i.get(t);if(!a||a.type!=="END_EVENT")return!1;let s=i.get(e);return(s==null?void 0:s.type)==="ANNOTATION"?!1:sc(t,n,r).filter(c=>{let d=i.get(c.source);return(d==null?void 0:d.type)!=="ANNOTATION"}).length>=1},Cr=(e,t,o,n,r)=>{var c;let i=vt(o),a=i.get(e);if(!a||a.type!=="GATEWAY"||((c=a.data)==null?void 0:c.variant)!=="EXCLUSIVE")return!1;let s=t?i.get(t):null;return(s==null?void 0:s.type)==="ANNOTATION"?!1:En(e,n,r).filter(d=>{let u=i.get(d.target);return(u==null?void 0:u.type)!=="ANNOTATION"}).length>=2},cc=(e,t,o)=>{var a,s,l,c;let n=vt(o),r=n.get(e),i=n.get(t);return(r==null?void 0:r.type)!=="GATEWAY"||(i==null?void 0:i.type)!=="GATEWAY"||((a=r==null?void 0:r.data)==null?void 0:a.variant)==="EXCLUSIVE"&&((s=i==null?void 0:i.data)==null?void 0:s.variant)==="PARALLEL"||((l=r==null?void 0:r.data)==null?void 0:l.variant)==="COMPLEX"&&((c=i==null?void 0:i.data)==null?void 0:c.variant)==="PARALLEL"},Sr=(e,t)=>{var n;let o=t.find(r=>r.id===e);return!o||o.type!=="TASK"?!1:((n=o.data)==null?void 0:n.variant)==="SCRIPT"},dc=(e,t)=>{var n;let o=t.find(r=>r.id===e);return!o||o.type!=="TASK"?!1:((n=o.data)==null?void 0:n.variant)==="SUBPROCESS"},Mr=(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"},co=(e,t,o,n)=>{let r=vt(t),i=r.get(e);return!i||i.type!=="TASK"?!1:sc(e,o,n).some(s=>{let l=r.get(s.source);return(l==null?void 0:l.type)==="START_EVENT"})},bn=(e,t,o,n)=>{let r=vt(t),i=r.get(e);return!i||i.type!=="TASK"?!1:En(e,o,n).some(s=>{let l=r.get(s.target);return(l==null?void 0:l.type)==="END_EVENT"})},uc=(e,t,o,n,r)=>{let i=vt(o),a=i.get(e),s=i.get(t);return(a==null?void 0:a.type)==="START_EVENT"&&(s==null?void 0:s.type)==="TASK"?bn(t,o,n,r):(s==null?void 0:s.type)==="END_EVENT"&&(a==null?void 0:a.type)==="TASK"?co(e,o,n,r):!1},Pr=(e,t,o)=>En(e,t,o).length>0,Lr=(e,t,o,n,r)=>{let i=vt(o),a=i.get(e);if(!a||a.type!=="TASK")return!1;let s=t?i.get(t):null;return(s==null?void 0:s.type)==="ANNOTATION"?!1:En(e,n,r).filter(c=>{let d=i.get(c.target);return(d==null?void 0:d.type)!=="ANNOTATION"}).length>=2};var pc=(e,t,o,n,r)=>{var s,l;let i=vt(n),a=((s=i.get(e))==null?void 0:s.type)==="ANNOTATION"||((l=i.get(t))==null?void 0:l.type)==="ANNOTATION";return o.some(c=>r&&c.id===r?!1:!!(c.source===e&&c.target===t||a&&c.source===t&&c.target===e))};var ag=[e=>({isValid:e.sourceNodeId!==e.targetNodeId,reason:"self_connection_not_allowed"}),e=>({isValid:!pc(e.sourceNodeId,e.targetNodeId,e.edges,e.nodes,e.reconnectingEdgeId),reason:"duplicate_connection_not_allowed"}),e=>({isValid:!ac(e.sourceNodeId,e.targetNodeId,e.nodes,e.edges,e.reconnectingEdgeId),reason:"start_event_limit_reached"}),e=>({isValid:!lc(e.sourceNodeId,e.targetNodeId,e.nodes,e.edges,e.reconnectingEdgeId),reason:"end_event_limit_reached"}),e=>({isValid:!Cr(e.sourceNodeId,e.targetNodeId,e.nodes,e.edges,e.reconnectingEdgeId),reason:"gateway_limit_reached"}),e=>({isValid:!Lr(e.sourceNodeId,e.targetNodeId,e.nodes,e.edges,e.reconnectingEdgeId),reason:"task_limit_reached"}),e=>({isValid:cc(e.sourceNodeId,e.targetNodeId,e.nodes),reason:"gateway_to_gateway_not_allowed"}),e=>({isValid:!(e.sourceNodeType==="START_EVENT"&&e.targetNodeType==="END_EVENT"),reason:"start_to_end_not_allowed"}),e=>({isValid:!(e.sourceNodeType==="START_EVENT"&&dc(e.targetNodeId,e.nodes)),reason:"start_event_to_subprocess_not_allowed"}),e=>({isValid:!(e.sourceNodeType==="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:!(Sr(e.sourceNodeId,e.nodes)&&e.targetNodeType==="END_EVENT"),reason:"script_to_end_not_allowed"}),e=>({isValid:!(Mr(e.sourceNodeId,e.nodes)&&e.targetNodeType==="END_EVENT"),reason:"loop_to_end_not_allowed"}),e=>({isValid:!(co(e.sourceNodeId,e.nodes,e.edges,e.reconnectingEdgeId)&&e.targetNodeType==="END_EVENT"),reason:"initial_activity_to_end_not_allowed"}),e=>({isValid:!uc(e.sourceNodeId,e.targetNodeId,e.nodes,e.edges,e.reconnectingEdgeId),reason:"concurrent_initial_and_final_activity"}),e=>({isValid:!(bn(e.sourceNodeId,e.nodes,e.edges,e.reconnectingEdgeId)&&e.targetNodeType!=="ANNOTATION"),reason:"final_activity_cannot_connect"}),e=>({isValid:!(Pr(e.sourceNodeId,e.edges,e.reconnectingEdgeId)&&e.targetNodeType==="END_EVENT"),reason:"activity_has_outgoing_connections"}),e=>({isValid:({START_EVENT:["TASK","ANNOTATION"],END_EVENT:["ANNOTATION"],TASK:["TASK","END_EVENT","GATEWAY","ANNOTATION"],GATEWAY:["TASK","END_EVENT","ANNOTATION","GATEWAY"],LANE:["ANNOTATION"],ANNOTATION:["START_EVENT","END_EVENT","TASK","GATEWAY","LANE"],UNSUPPORTED:[]}[e.sourceNodeType]||[]).includes(e.targetNodeType),reason:"connection_type_not_allowed"})],ns=e=>{for(let t of ag){let o=t(e);if(!o.isValid)return o}return{isValid:!0}};var lg=[{sourceTypes:["GATEWAY"],targetTypes:["TASK","GATEWAY"],validate:e=>({shouldDisable:Cr(e.sourceNodeId,null,e.nodes,e.edges)&&e.targetNodeType!=="ANNOTATION",reason:"gateway_limit_reached"})},{sourceTypes:["START_EVENT"],validate:e=>({shouldDisable:e.edges.some(o=>{if(o.source!==e.sourceNodeId)return!1;let n=e.nodes.find(r=>r.id===o.target);return(n==null?void 0:n.type)!=="ANNOTATION"})&&e.targetNodeType!=="ANNOTATION",reason:"start_event_limit_reached"})},{targetTypes:["START_EVENT"],validate:e=>({shouldDisable:os(e.nodes),reason:"start_event_already_exists"})},{sourceTypes:["TASK"],targetTypes:["END_EVENT"],validate:e=>({shouldDisable:Sr(e.sourceNodeId,e.nodes),reason:"script_to_end_not_allowed"})},{sourceTypes:["TASK"],targetTypes:["END_EVENT"],validate:e=>({shouldDisable:Mr(e.sourceNodeId,e.nodes),reason:"loop_to_end_not_allowed"})},{sourceTypes:["TASK"],targetTypes:["END_EVENT"],validate:e=>({shouldDisable:co(e.sourceNodeId,e.nodes,e.edges),reason:"initial_activity_to_end_not_allowed"})},{sourceTypes:["TASK"],validate:e=>({shouldDisable:bn(e.sourceNodeId,e.nodes,e.edges)&&e.targetNodeType!=="ANNOTATION",reason:"final_activity_cannot_connect"})},{targetTypes:["END_EVENT"],validate:e=>({shouldDisable:Pr(e.sourceNodeId,e.edges),reason:"activity_has_outgoing_connections"})},{sourceTypes:["TASK"],validate:e=>({shouldDisable:Lr(e.sourceNodeId,null,e.nodes,e.edges)&&e.targetNodeType!=="ANNOTATION",reason:"task_limit_reached"})}],fc=e=>{let t=lg.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 Hg,EdgeLabelRenderer as Gg,getStraightPath as Bg,useInternalNode as gc,useViewport as zg}from"@xyflow/react";import{Button as ug,Tooltip as pg,TooltipContent as fg,TooltipTrigger as mg,useTranslation as gg}from"@produto-lecom/lecom-ui";import{Settings as hg}from"lucide-react";import{getIncomers as kr,getOutgoers as Rr,useReactFlow as dg}from"@xyflow/react";import{useStoreApi as cg}from"@xyflow/react";var Gt=()=>{let e=cg();return{selectElements:n=>{let{edges:r,nodes:i,triggerEdgeChanges:a,triggerNodeChanges:s}=e.getState(),l=i.reduce((d,u)=>[...d,{id:u.id,type:"select",selected:n.includes(u.id)}],[]),c=r.reduce((d,u)=>[...d,{id:u.id,type:"select",selected:n.includes(u.id)}],[]);return s(l),a(c),!0},clearSelection:async()=>{let{unselectNodesAndEdges:n}=e.getState();return n(),await zn(),!0}}};var Dr=()=>{let{getNode:e,getEdge:t,getNodes:o,getEdges:n}=dg(),{selectElements:r}=Gt(),i=p=>{let h=o(),y=n(),x=kr(p,h,y),v=Rr(p,h,y),N=x.some(E=>E.type==="START_EVENT"),T=v.some(E=>E.type==="END_EVENT");return N?"start":T?"end":"between"},a=(p,h,y)=>{var N,T,E,I;if(!p)return;let x={type:p.type,variant:(N=p.data)==null?void 0:N.variant,attribute:(T=p.data)==null?void 0:T.attribute},v={id:p.id,position:i(p),label:(E=p.data)==null?void 0:E.label,node:x};return p.type==="TASK"&&((I=p.data)==null?void 0:I.variant)==="SUBPROCESS"?w(_({},v),{type:"sub_process"}):p.type==="GATEWAY"?w(_({},v),{type:"gateway",variant:s(p,h,y)}):w(_({},v),{type:"activity"})},s=(p,h,y)=>{if(p.type!=="GATEWAY")return;let x=kr(p,h,y),v=!1,N=!1;if(x.forEach(T=>{var E,I;T.type==="TASK"&&(((E=T.data)==null?void 0:E.variant)==="SCRIPT"&&(v=!0),((I=T.data)==null?void 0:I.attribute)==="LOOP"&&(N=!0))}),v&&N)return"script_loop";if(v)return"script";if(N)return"loop"},l=(p,h,y)=>{var E,I,P,M;let x=e(p.source),v=e(p.target);if(!x||!v)return"simple";if(Rr(x,h,y).some(V=>V.type==="END_EVENT"))return"final";if(x.type==="GATEWAY")switch((E=x.data)==null?void 0:E.variant){case"PARALLEL":return"parallel";case"EXCLUSIVE":return"exclusive";case"COMPLEX":return"complex";default:return"simple"}if(x.type==="TASK"){let V=(I=x.data)==null?void 0:I.variant,C=(P=x.data)==null?void 0:P.attribute;if(V==="SUBPROCESS")return"from_sub_process";if(v.type==="TASK"&&((M=v.data)==null?void 0:M.variant)==="SUBPROCESS")return"to_sub_process";let G=V==="SCRIPT",K=C==="LOOP";return G&&K?"script_loop":G?"script":K?"loop":"simple"}return"simple"},c=(p,h,y)=>{let x=[];function v(T,E,I=0){let P=a(T,h,y);if(P.depth=I,E.push(P),T.type==="TASK"){x.push([...E]),E.pop();return}let M=kr(T,h,y);if(M.length)for(let V of M)v(V,E,I+1);E.pop()}let N=kr(p,h,y);for(let T of N)v(T,[]);return x},d=(p,h,y)=>{let x=[];function v(T,E,I=0){let P=a(T,h,y);if(P.depth=I,E.push(P),T.type==="TASK"){x.push([...E]),E.pop();return}let M=Rr(T,h,y);if(M.length)for(let V of M)v(V,E,I+1);E.pop()}let N=Rr(p,h,y);for(let T of N)v(T,[]);return x},u=(p,h,y)=>(y=y.filter(v=>v.source===p.id),y.map(v=>{var E;let N=e(v.target),T;return N&&(T=a(N,h,y)),{id:v.id,type:"routing",variant:l(v,h,y),label:(E=v.data)==null?void 0:E.label,target:T}})),m=p=>{let h=e(p);if(!h)return;let y=o(),x=n(),v=a(h,y,x);return v.sources=c(h,y,x),v.targets=d(h,y,x),v.edgeTargets=u(h,y,x),h.type==="GATEWAY"&&(v.variant=s(h,y,x)),v},f=p=>{let h=t(p);if(!h)return;let y=o(),x=n(),v=l(h,y,x),T={id:h.id,type:"routing",variant:v,gatewayVariant:void 0},E=e(h.source);if(E){let P=a(E,y,x);T.source=P;let M=s(E,y,x);if(T.gatewayVariant=M,E.type==="TASK")T.sources=[[P]];else{let V=c(E,y,x);T.sources=V.length?V:[[P]]}}let I=e(h.target);if(I){let P=a(I,y,x);if(T.target=P,I.type==="TASK")T.targets=[[P]];else{let M=d(I,y,x);T.targets=M.length?M:[[P]]}}return T},g=p=>{let h=e(p);if(h)return m(h.id);let y=t(p);if(y)return f(y.id)};return{configureElement:p=>{let h=g(p);if(h)return r([p]),h},getConfigureElement:g,getNodeConfigure:m,getEdgeConfigure:f}};import{jsx as Or,jsxs as xg}from"react/jsx-runtime";var yg={node:"editor.toolbar.configure_node",edge:"editor.toolbar.configure_edge",gateway:"editor.toolbar.configure_gateway"},Bt=({elementId:e,elementType:t="node"})=>{let{t:o}=gg(),{onConfigureElement:n}=Z(),{getConfigureElement:r}=Dr();return xg(pg,{children:[Or(mg,{asChild:!0,children:Or(ug,{variant:"ghost",color:"grey",size:"small",iconButton:!0,onClick:()=>{let a=r(e);a&&(n==null||n(a))},children:Or(hg,{size:16})})}),Or(fg,{color:"black",children:o(yg[t])})]})};import{Button as bg,Tooltip as _g,TooltipContent as Tg,TooltipTrigger as Ng,useTranslation as vg}from"@produto-lecom/lecom-ui";import{useReactFlow as wg}from"@xyflow/react";import{TrashIcon as Ig}from"lucide-react";import{useNotificationToast as Eg}from"@produto-lecom/lecom-ui";function Fe(){let{toast:e}=_n(),{toast:t}=Eg();return{toast:e||t}}import{jsx as Vr,jsxs as Ag}from"react/jsx-runtime";var Hr=({elementId:e,elementType:t="node"})=>{let{t:o}=vg(),{toast:n}=Fe(),{deleteElements:r,getNodes:i}=wg();return Ag(_g,{children:[Vr(Ng,{asChild:!0,children:Vr(bg,{variant:"ghost",color:"destructive",size:"small",iconButton:!0,onClick:()=>{if(t==="node"){let s=i(),l=s.find(c=>c.id===e);if((l==null?void 0:l.type)==="LANE"&&s.some(d=>d.parentId===e)){n({variant:"error",title:o("validation.errors.title"),content:o("editor.toolbar.delete_pool_lane_error")});return}r({nodes:[{id:e}]})}else r({edges:[{id:e}]})},children:Vr(Ig,{size:16})})}),Vr(Tg,{color:"black",children:o("editor.toolbar.delete")})]})};import{Button as Cg,Tooltip as Sg,TooltipContent as Mg,TooltipTrigger as Pg,useTranslation as Lg}from"@produto-lecom/lecom-ui";import{MoveUpRightIcon as kg}from"lucide-react";import{useCallback as Rg}from"react";import{jsx as Gr,jsxs as Dg}from"react/jsx-runtime";var Lo=({nodeId:e,disabled:t=!1,tooltipMessage:o})=>{let{t:n}=Lg(),r=Rg(i=>{i.stopPropagation();let a=document.querySelectorAll(`.react-flow__handle.source[data-nodeid="${e}"]`);if(a.length===0)return;let s=Array.from(a).reduce((m,f)=>{let g=m.getBoundingClientRect(),b=f.getBoundingClientRect(),p=Math.hypot(i.clientX-(g.left+g.width/2),i.clientY-(g.top+g.height/2));return Math.hypot(i.clientX-(b.left+b.width/2),i.clientY-(b.top+b.height/2))<p?f:m}),l=s.getBoundingClientRect(),c=l.left+l.width/2,d=l.top+l.height/2,u=new MouseEvent("mousedown",{clientX:c,clientY:d,bubbles:!0,cancelable:!0});s.dispatchEvent(u)},[e]);return Dg(Sg,{children:[Gr(Pg,{asChild:!0,children:Gr(Cg,{variant:"ghost",color:"grey",size:"small",iconButton:!0,disabled:t,className:t?"opacity-50 cursor-not-allowed":"",onMouseDown:t?void 0:r,children:Gr(kg,{size:16})})}),Gr(Mg,{color:"black",children:o||n("editor.toolbar.connect_node")})]})};import{jsx as Tn}from"react/jsx-runtime";var ko=i=>{var a=i,{edgeId:e,edgeType:t,sourceNode:o,targetNode:n}=a,r=gt(a,["edgeId","edgeType","sourceNode","targetNode"]);let{mode:s}=Z(),{isFromStartEvent:l,isGatewayToGateway:c,isActiviyToAndGateway:d,isToEndEvent:u}=Kn(o,n),m=!l&&!c&&!d&&!u,f=[{component:Tn(Hr,{elementId:e,elementType:"edge"})}],g=()=>s==="view"?m?[{component:Tn(Bt,{elementId:e,elementType:"edge"})}]:[]:m?[{component:Tn(Bt,{elementId:e,elementType:"edge"})},...f]:f,p=(h=>{switch(h){case"SEQUENCE_EDGE":return g();case"MESSAGE_EDGE":return s==="view"?[]:[...f];case"ANNOTATION_EDGE":return s==="view"?[]:[...f];default:return[]}})(t);if(!(p.length===0||s==="readonly"))return Tn("div",w(_({className:"flex items-center gap-1 w-fit px-3 py-2 bg-white rounded-sm shadow-md"},r),{children:p.map((h,y)=>Tn("div",{children:h.component},y))}))};import{useViewport as Og}from"@xyflow/react";import{useMemo as Vg}from"react";import{jsx as mc}from"react/jsx-runtime";var xt=12,Ro=({sx:e,sy:t,tx:o,ty:n,hasLabel:r=!1,children:i})=>{let{zoom:a}=Og(),s=1/a,l=Vg(()=>t===n?{bottom:`${xt}px`,transform:"translateX(-50%)"}:e===o?{left:`${xt}px`,transform:r?"translateY(-100%)":"translateY(-50%)"}:n>t&&o>e?{left:`${xt}px`,bottom:`${xt}px`}:n>t&&o<e?{right:`${xt}px`,bottom:`${xt}px`}:t>n&&o>e?{right:`${xt}px`,bottom:`${xt}px`}:{left:`${xt}px`,bottom:`${xt}px`},[e,t,o,n,r]);return mc("div",{style:{transform:`scale(${s})`},children:mc("div",{className:"absolute pointer-events-auto",style:_({},l),children:i})})};import{Fragment as Yg,jsx as po,jsxs as hc}from"react/jsx-runtime";var Do={type:"ANNOTATION_EDGE",reconnectable:!0},yc=({id:e,source:t,target:o,selected:n,data:r})=>{let{isMultipleSelection:i}=Z(),{zoom:a}=zg(),s=gc(t),l=gc(o);if(!s||!l)return null;let{sx:c,sy:d,tx:u,ty:m}=Ao(s,l),[f,g,b]=Bg({sourceX:c,sourceY:d,targetX:u,targetY:m}),p=n||(s==null?void 0:s.selected)||(l==null?void 0:l.selected);return po(Yg,{children:hc("g",{className:H("group bpmn-edge",{"is-highlighted":p}),children:[po("path",{d:f,fill:"none",stroke:"transparent",strokeWidth:Math.max(12,12/a),style:{pointerEvents:"stroke",cursor:"pointer"}}),hc("g",{className:H("text-grey-500 transition-colors duration-75 group-hover:text-grey-800",{"text-blue-500 group-hover:text-blue-600":p}),children:[po(Hg,{id:e,path:f,interactionWidth:0,strokeDasharray:4,className:H("stroke-2 stroke-current transition-[stroke,filter] duration-75 group-hover:drop-shadow-[0_0_3px_rgba(0,0,0,0.2)]",{"stroke-red-500 hover:stroke-red-600":r==null?void 0:r.hasError,"stroke-blue-500 hover:stroke-blue-600 drop-shadow-[0_0_3px_rgba(59,130,246,0.5)]":p&&!(r!=null&&r.hasError)})}),po(Gg,{children:po("div",{className:"absolute z-[3000] pointer-events-auto flex flex-col items-center gap-1",style:{transform:`translate(-50%, -50%) translate(${g}px, ${b}px)`},children:n&&!i&&po(Ro,{sx:c,sy:d,tx:u,ty:m,children:po(ko,{edgeId:e,edgeType:"ANNOTATION_EDGE"})})})})]})]})})};import{useState as Ac,useCallback as Cc,useMemo as ss,useEffect as ih,useRef as as}from"react";import{BaseEdge as sh,EdgeLabelRenderer as ah,MarkerType as Sc,useInternalNode as Mc,useReactFlow as lh,useViewport as ch,useEdges as dh,useNodes as uh,Position as Go}from"@xyflow/react";import{useCallback as Wg,useEffect as rs,useRef as xc,useState as Fg}from"react";import{jsx as bc}from"react/jsx-runtime";var is=/[a-zA-Z0-9À-ÖØ-öø-ÿ]/,Ec=["Backspace","Delete","ArrowLeft","ArrowRight","ArrowUp","ArrowDown","Home","End","Tab","Escape","Shift"],Re=({value:e,maxLength:t,style:o,className:n,contentClassName:r,isEditing:i,onChange:a,onBlur:s,onInput:l,onInvalidFirstCharacter:c,skipFirstCharValidation:d})=>{let u=xc(null),m=xc(null),[f,g]=Fg(!1);rs(()=>()=>{m.current&&clearTimeout(m.current)},[]),rs(()=>{g(i!=null?i:!1)},[i]),rs(()=>{if(f&&u.current){u.current.focus();let N=document.createRange();N.selectNodeContents(u.current);let T=window.getSelection();T&&(T.removeAllRanges(),T.addRange(N))}},[f]);let b=Wg(()=>{m.current||(c==null||c(),m.current=setTimeout(()=>{m.current=null},500))},[c]),p=N=>{N.stopPropagation(),f||g(!0)},h=N=>{let T=N.currentTarget.innerText.replace(/\n$/,""),E=t&&T.length>=t,I=window.getSelection(),P=(I==null?void 0:I.toString())||"",M=P.length>0,V=(N.ctrlKey||N.metaKey)&&!N.altKey,C=V&&N.key==="a",G=V&&N.key==="c",K=V&&N.key==="x",$=V&&N.key==="v",J=T.length===0||M&&P.length===T.length;if(!d&&J&&!is.test(N.key)&&!Ec.includes(N.key)&&!V){N.preventDefault(),b();return}E&&!M&&(Ec.includes(N.key)||C||G||K||$||N.preventDefault())},y=N=>{N.preventDefault();let T=N.clipboardData.getData("text/plain").replace(/\r\n/g,`
2
2
  `).replace(/\r/g,`
3
- `),_=N.currentTarget.innerText.replace(/\n$/,""),I=window.getSelection();if(!I||I.rangeCount===0)return;let S=I.toString(),P=_.length-S.length,R=t?Math.max(0,t-P):1/0;if(R<=0&&S.length===0)return;let M=T;if(M.length>R&&(M=M.substring(0,R)),!M&&S.length===0)return;let B=I.getRangeAt(0),X=B.startOffset===0&&(B.startContainer===N.currentTarget||B.startContainer.parentNode===N.currentTarget);if(!d&&X&&M.length>0&&!es.test(M[0])){E();return}B.deleteContents();let U=document.createTextNode(M);B.insertNode(U),B.setStartAfter(U),B.collapse(!0),I.removeAllRanges(),I.addRange(B),l==null||l(N.currentTarget.innerText.replace(/\n$/,""))},x=N=>{let T=N.currentTarget,_=T.innerText.replace(/\n$/,"");if(!d&&_.length>0&&!es.test(_[0])){let I=_.slice(1);if(T.innerText=I,I.length>0&&T.firstChild){let S=document.createRange(),P=window.getSelection();S.setStart(T.firstChild,0),S.collapse(!0),P==null||P.removeAllRanges(),P==null||P.addRange(S)}E(),l==null||l(I);return}l==null||l(_)},v=N=>{g(!1);let T=N.currentTarget.innerText.replace(/\r\n/g,`
3
+ `),E=N.currentTarget.innerText.replace(/\n$/,""),I=window.getSelection();if(!I||I.rangeCount===0)return;let P=I.toString(),M=E.length-P.length,V=t?Math.max(0,t-M):1/0;if(V<=0&&P.length===0)return;let C=T;if(C.length>V&&(C=C.substring(0,V)),!C&&P.length===0)return;let G=I.getRangeAt(0),K=G.startOffset===0&&(G.startContainer===N.currentTarget||G.startContainer.parentNode===N.currentTarget);if(!d&&K&&C.length>0&&!is.test(C[0])){b();return}G.deleteContents();let $=document.createTextNode(C);G.insertNode($),G.setStartAfter($),G.collapse(!0),I.removeAllRanges(),I.addRange(G),l==null||l(N.currentTarget.innerText.replace(/\n$/,""))},x=N=>{let T=N.currentTarget,E=T.innerText.replace(/\n$/,"");if(!d&&E.length>0&&!is.test(E[0])){let I=E.slice(1);if(T.innerText=I,I.length>0&&T.firstChild){let P=document.createRange(),M=window.getSelection();P.setStart(T.firstChild,0),P.collapse(!0),M==null||M.removeAllRanges(),M==null||M.addRange(P)}b(),l==null||l(I);return}l==null||l(E)},v=N=>{g(!1);let T=N.currentTarget.innerText.replace(/\r\n/g,`
4
4
  `).replace(/\r/g,`
5
- `).trim();t&&T.length>t&&(T=T.substring(0,t)),N.currentTarget.innerText=T,s==null||s(),T!==e&&(a==null||a(T))};return yc("div",{className:H("flex-1 p-2 self-stretch flex items-center justify-center border border-transparent overflow-hidden text-ellipsis body-medium-400 text-center rounded-sm",{"border border-dashed border-grey-400 bg-white shadow-md":u,"bg-white":e.length>0},n),style:o,onDoubleClick:f,children:yc("div",{ref:p,className:H("outline-none whitespace-pre-wrap overflow-hidden",r,{"nodrag nopan cursor-text":u}),contentEditable:u,suppressContentEditableWarning:!0,onKeyDown:h,onPaste:y,onInput:x,onBlur:v,children:e})})};import{Position as PI}from"@xyflow/react";var ge=(e,t,o,n=1)=>Math.abs(e[o]-t[o])<n,ko=(e,t)=>Math.sqrt((t.x-e.x)**2+(t.y-e.y)**2),Vr=(e,t)=>({x:(e.x+t.x)/2,y:(e.y+t.y)/2}),Wg=(e,t,o)=>{let n=o.x-t.x,r=o.y-t.y,i=n*n+r*r;if(i===0)return ko(e,t);let a=Math.max(0,Math.min(1,((e.x-t.x)*n+(e.y-t.y)*r)/i));return ko(e,{x:t.x+a*n,y:t.y+a*r})},xc=(e,t)=>{let o=1/0;for(let n=0;n<t.length-1;n++)o=Math.min(o,Wg(e,t[n],t[n+1]));return o};import{Position as Hr}from"@xyflow/react";var Yt={OFFSET:30,TOLERANCE:1,MOVE_THRESHOLD:5,MIN_SEGMENT_LENGTH:15,PARALLEL_OFFSET:15,MAX_LABEL_DISTANCE:80};var{TOLERANCE:de}=Yt;function Fg(e,t,o){return ge(e,t,"x",de)&&ge(t,o,"x",de)&&ge(e,o,"x",de)}function Xg(e,t,o){return ge(e,t,"y",de)&&ge(t,o,"y",de)&&ge(e,o,"y",de)}function Ug(e,t,o){if(!Fg(e,t,o))return!1;let n=t.y-e.y,r=o.y-t.y;return Math.abs(n)<de||Math.abs(r)<de?!1:n*r<0}function $g(e,t,o){if(!Xg(e,t,o))return!1;let n=t.x-e.x,r=o.x-t.x;return Math.abs(n)<de||Math.abs(r)<de?!1:n*r<0}function Kg(e,t,o,n){let r=t.x!==0,i=t.x===-n.x&&t.y===-n.y,a=t.x===n.x&&t.y===n.y,s=120;if(i)if(r){if((o.x-e.x)*t.x>=0)return[{x:(e.x+o.x)/2,y:e.y},{x:(e.x+o.x)/2,y:o.y}];{let l=(e.y+o.y)/2,c=Math.abs(e.y-o.y)<s?Math.max(e.y,o.y)+s:l;return[{x:e.x,y:c},{x:o.x,y:c}]}}else{if((o.y-e.y)*t.y>=0)return[{x:e.x,y:(e.y+o.y)/2},{x:o.x,y:(e.y+o.y)/2}];{let l=(e.x+o.x)/2,c=Math.abs(e.x-o.x)<s?Math.max(e.x,o.x)+s:l;return[{x:c,y:e.y},{x:c,y:o.y}]}}else if(a)if(r)if((o.x-e.x)*t.x>0&&Math.abs(e.y-o.y)<s){let l=Math.max(e.y,o.y)+s,c=o.x+t.x*(s/2);return[{x:e.x,y:l},{x:c,y:l},{x:c,y:o.y}]}else{let l=t.x>0?Math.max(e.x,o.x):Math.min(e.x,o.x);return[{x:l,y:e.y},{x:l,y:o.y}]}else if((o.y-e.y)*t.y>0&&Math.abs(e.x-o.x)<s){let l=Math.max(e.x,o.x)+s,c=o.y+t.y*(s/2);return[{x:l,y:e.y},{x:l,y:c},{x:o.x,y:c}]}else{let l=t.y>0?Math.max(e.y,o.y):Math.min(e.y,o.y);return[{x:e.x,y:l},{x:o.x,y:l}]}else{let l=t.x!==0?o.x:e.x,c=t.y!==0?o.y:e.y,d=t.x!==0?(l-e.x)*t.x:(c-e.y)*t.y,p=n.x!==0?(l-o.x)*n.x:(c-o.y)*n.y;return d>=0&&p>=0?[{x:l,y:c}]:r?[{x:e.x,y:o.y}]:[{x:o.x,y:e.y}]}}function Ec(e){if(e.length<=2)return e;let t=[e[0]];for(let o=1;o<e.length-1;o++){let n=t[t.length-1],r=e[o],i=e[o+1];ge(n,r,"x",de)&&ge(r,i,"x",de)||ge(n,r,"y",de)&&ge(r,i,"y",de)||t.push(r)}return t.push(e[e.length-1]),t}function Gr(e){let t=[];for(let o of e){let n=t[t.length-1];(!n||Math.abs(n.x-o.x)>=de||Math.abs(n.y-o.y)>=de)&&t.push(o)}return t}function qg(e){let t=[...e],o=!0;for(;o;){o=!1;for(let n=1;n<t.length-1;n++){let r=t[n-1],i=t[n],a=t[n+1];if(Ug(r,i,a)||$g(r,i,a)){t.splice(n,1),o=!0;break}}}return t}function bc(e){let t=Gr(Ec([...e]));return t=qg(t),Gr(Ec(t))}function Br(e){switch(e){case Hr.Left:return{x:-1,y:0};case Hr.Right:return{x:1,y:0};case Hr.Top:return{x:0,y:-1};case Hr.Bottom:return{x:0,y:1};default:return{x:0,y:0}}}function _c(e,t,o,n){let r=Yt.OFFSET,i=Yt.OFFSET;if(t.x===-n.x&&t.y===-n.y)if(t.x!==0){let a=(o.x-e.x)*t.x;a>0&&a<2*Yt.OFFSET&&(r=a/2,i=a/2)}else{let a=(o.y-e.y)*t.y;a>0&&a<2*Yt.OFFSET&&(r=a/2,i=a/2)}return{sourceOffset:r,targetOffset:i}}function Zg(e,t,o,n,r,i,a=0){let s=Br(r),l=Br(i),c=s.x===0?a:0,d=s.y===0?a:0,p=l.x===0?a:0,m=l.y===0?a:0,u={x:e+c,y:t+d},g={x:o+p,y:n+m},{sourceOffset:E,targetOffset:f}=_c(u,s,g,l),h={x:u.x+s.x*E,y:u.y+s.y*E},y={x:g.x+l.x*f,y:g.y+l.y*f},x=Kg(h,s,y,l),v=[u,h,...x,y,g],N=bc(v);if(N.length===2&&zr(u,g)>de){let T=ge(u,h,"x",de)&&ge(h,y,"x",de)&&ge(y,g,"x",de),_=ge(u,h,"y",de)&&ge(h,y,"y",de)&&ge(y,g,"y",de);if(T||_){let I=_&&(y.x-h.x)*s.x<0,S=T&&(y.y-h.y)*s.y<0;if(!I&&!S)return Gr([u,h,y,g])}}return N}function Yr(e,t,o,n,r,i,a,s=0){if(!(a!=null&&a.length))return Zg(e,t,o,n,r,i,s);let l=Br(r),c=Br(i),d=l.x===0?s:0,p=l.y===0?s:0,m=c.x===0?s:0,u=c.y===0?s:0,g={x:e+d,y:t+p},E={x:o+m,y:n+u},{sourceOffset:f,targetOffset:h}=_c(g,l,E,c),y={x:g.x+l.x*f,y:g.y+l.y*f},x={x:E.x+c.x*h,y:E.y+c.y*h},v=[...a],N=v[0],T=l.y===0;T&&Math.abs(g.y-N.y)>de?v.unshift({x:N.x,y:g.y}):!T&&Math.abs(g.x-N.x)>de&&v.unshift({x:g.x,y:N.y});let _=v[v.length-1],I=c.y===0,S=[];(Math.abs(_.x-x.x)>de||Math.abs(_.y-x.y)>de)&&(I?S.push({x:x.x,y:_.y}):S.push({x:_.x,y:x.y})),S.push(x);let P=[g,...v,...S,E],R=bc(P);if(R.length===2&&zr(g,E)>de){let M=ge(g,y,"x",de)&&ge(y,x,"x",de)&&ge(x,E,"x",de),B=ge(g,y,"y",de)&&ge(y,x,"y",de)&&ge(x,E,"y",de);if(M||B){let X=B&&(x.x-y.x)*l.x<0,U=M&&(x.y-y.y)*l.y<0;if(!X&&!U)return Gr([g,y,x,E])}}return R}var zr=(e,t)=>Math.sqrt(Math.pow(t.x-e.x,2)+Math.pow(t.y-e.y,2));function Jg(e,t,o){return ge(e,t,"x",de)&&ge(t,o,"x",de)||ge(e,t,"y",de)&&ge(t,o,"y",de)}function Qg(e,t,o,n){if(Jg(e,t,o))return`L${t.x} ${t.y}`;let r=zr(e,t),i=zr(t,o),a=Math.min(r/2,i/2,n);if(a<1)return`L${t.x} ${t.y}`;let s=e.x-t.x,l=e.y-t.y,c=o.x-t.x,d=o.y-t.y,p={x:s/r,y:l/r},m={x:c/i,y:d/i},u={x:t.x+p.x*a,y:t.y+p.y*a},g={x:t.x+m.x*a,y:t.y+m.y*a},E=-p.x,f=-p.y,h=m.x,y=m.y,v=E*y-f*h>0?1:0;return`L${u.x} ${u.y}A${a} ${a} 0 0 ${v} ${g.x} ${g.y}`}var Nc=(e,t=5)=>e.length<2?"":e.reduce((o,n,r)=>{let i="";return r>0&&r<e.length-1?i=Qg(e[r-1],n,e[r+1],t):i=`${r===0?"M":"L"}${n.x} ${n.y}`,o+=i,o},"");import{useCallback as Ro,useEffect as Wr,useRef as bn,useState as Do}from"react";import{useReactFlow as jg,useStore as eh}from"@xyflow/react";var th=50,Tc=.1,oh=.6,Fr=({edgeId:e,source:t,target:o,instanceId:n,isReadOnly:r})=>{let{setEdges:i,getNode:a,getNodes:s,getEdge:l,screenToFlowPosition:c}=jg(),{setIsDragging:d,setReconnectingEdgeId:p}=$(),m=eh(D=>D.isValidConnection),[u,g]=Do(null),[E,f]=Do(null),[h,y]=Do(null),[x,v]=Do(null),[N,T]=Do(null),[_,I]=Do(!1),S=bn(null),P=bn(null),R=bn(null),M=bn(t),B=bn(o);Wr(()=>{M.current=t,B.current=o},[t,o]),Wr(()=>{S.current=u},[u]),Wr(()=>{P.current=N},[N]);let X=Ro(D=>{let A=s(),k=A.find(V=>V.id===D);if(!k)return{x:0,y:0};let G=k.position.x,z=k.position.y,L=k.parentId;for(;L;){let V=A.find(j=>j.id===L);if(!V)break;G+=V.position.x,z+=V.position.y,L=V.parentId}return{x:G,y:z}},[s]),U=Ro(D=>{var L,V,j,Z,J,q;let A=s(),k=null,G=th,z=A.filter(ee=>ee.type!=="LANE"&&ee.type!=="ANNOTATION");for(let ee of z){if(ee.id===e)continue;let ae=X(ee.id),F=(j=(V=(L=ee.measured)==null?void 0:L.width)!=null?V:ee.width)!=null?j:0,ne=(q=(J=(Z=ee.measured)==null?void 0:Z.height)!=null?J:ee.height)!=null?q:0;if(D.x>=ae.x&&D.x<=ae.x+F&&D.y>=ae.y&&D.y<=ae.y+ne)return ee.id;let K=Math.max(ae.x-D.x,0,D.x-(ae.x+F)),xe=Math.max(ae.y-D.y,0,D.y-(ae.y+ne)),W=Math.sqrt(K*K+xe*xe);W<G&&(G=W,k=ee.id)}return k},[s,X,e]),Q=Ro((D,A)=>{var K,xe,W,te,ce,re;let k=a(D);if(!k)return null;let G=X(D),z=(W=(xe=(K=k.measured)==null?void 0:K.width)!=null?xe:k.width)!=null?W:0,L=(re=(ce=(te=k.measured)==null?void 0:te.height)!=null?ce:k.height)!=null?re:0,V=Math.abs(G.x+z-A.x),j=Math.abs(A.x-G.x),Z=Math.abs(G.y+L-A.y),J=Math.abs(A.y-G.y),q={right:V,left:j,bottom:Z,top:J},ee=Object.entries(q).reduce((fe,[ue,ye])=>ye<fe[1]?[ue,ye]:fe,["right",q.right])[0],ae=R.current;if(ae&&ae!==ee){let fe=q[ee],ue=q[ae],ye=Math.abs(ue-fe),ve=Math.min(Math.abs(ue),Math.abs(fe));ye<ve*oh&&(ee=ae)}let F=ee,ne,le;if(F==="right"||F==="left"){let ue=(Math.max(G.y,Math.min(G.y+L,A.y))-G.y)/(L||1);Math.abs(ue-.5)<Tc&&(ue=.5),le=ue,ne={x:F==="right"?G.x+z:G.x,y:G.y+le*L}}else{let ue=(Math.max(G.x,Math.min(G.x+z,A.x))-G.x)/(z||1);Math.abs(ue-.5)<Tc&&(ue=.5),le=ue,ne={x:G.x+le*z,y:F==="bottom"?G.y+L:G.y}}return{side:F,snapPosition:ne,offset:le}},[a,X]),Y=Ro(D=>{var j,Z,J;let A=S.current;if(!A)return;let k=c({x:D.clientX,y:D.clientY}),G=U(k);y(G);let z=k,L=null,V=null;if(G){let q=Q(G,k);q&&(L=q.side,z=q.snapPosition,V=q.offset,R.current=L);let ee=l(e),ae={source:A==="source"?G:M.current,target:A==="target"?G:B.current,sourceHandle:A==="source"?L:(j=ee==null?void 0:ee.sourceHandle)!=null?j:null,targetHandle:A==="target"?L:(Z=ee==null?void 0:ee.targetHandle)!=null?Z:null},F=(J=m==null?void 0:m(ae))!=null?J:!0;I(F)}else R.current=null,I(!1);v(L),T(V),f(z)},[U,Q,l,e,c,m]),C=Ro(D=>{var L,V,j,Z,J;let A=S.current;if(!A)return;let k=c({x:D.clientX,y:D.clientY}),G=U(k);if(G){let q=Q(G,k),ee=(L=q==null?void 0:q.side)!=null?L:null,ae=(V=q==null?void 0:q.offset)!=null?V:.5,F=l(e),ne={source:A==="source"?G:M.current,target:A==="target"?G:B.current,sourceHandle:A==="source"?ee:(j=F==null?void 0:F.sourceHandle)!=null?j:null,targetHandle:A==="target"?ee:(Z=F==null?void 0:F.targetHandle)!=null?Z:null};((J=m==null?void 0:m(ne))==null||J)&&i(le=>le.map(K=>{var xe,W;return K.id===e?w(b({},K),{source:ne.source,target:ne.target,sourceHandle:ne.sourceHandle,targetHandle:ne.targetHandle,data:w(b({},K.data),{points:void 0,sourceOffset:A==="source"?ae:(xe=K.data)==null?void 0:xe.sourceOffset,targetOffset:A==="target"?ae:(W=K.data)==null?void 0:W.targetOffset})}):K}))}g(null),f(null),y(null),v(null),T(null),d(!1),I(!1),p(null),R.current=null,document.removeEventListener("mouseup",C),document.removeEventListener("mousemove",Y);let z=xt.get(n);z==null||z.clearReconnectingEdge()},[e,U,Q,l,i,n,Y,m,c,d,p]),O=Ro((D,A)=>{if(r||A.button!==0)return;A.stopPropagation(),A.preventDefault(),i(G=>G.map(z=>z.id===e?w(b({},z),{data:w(b({},z.data),{points:void 0})}):z)),g(D),p(e);let k=xt.get(n);k==null||k.setReconnectingEdge(e),document.addEventListener("mousemove",Y),document.addEventListener("mouseup",C)},[r,e,n,Y,C,p,i]);return Wr(()=>()=>{if(S.current){document.removeEventListener("mousemove",Y),document.removeEventListener("mouseup",C),p(null);let D=xt.get(n);D==null||D.clearReconnectingEdge()}},[n,Y,C,p]),{reconnectingHandle:u,cursorPosition:E,hoveredNodeId:h,reconnectingSide:x,reconnectingOffset:N,isValidReconnection:_,handleReconnectStart:O}};import{Fragment as Sc,jsx as Ce,jsxs as Wt}from"react/jsx-runtime";var rt={type:"SEQUENCE_EDGE",reconnectable:!0,markerStart:{type:Ic.ArrowClosed},markerEnd:{type:Ic.Arrow},data:{label:""}},{MOVE_THRESHOLD:Xr,MIN_SEGMENT_LENGTH:dh,PARALLEL_OFFSET:Cc,MAX_LABEL_DISTANCE:uh}=Yt;function ph(e,t,o,n,r){let i=r.find(d=>d.id===t),a=r.find(d=>d.id===o);if((i==null?void 0:i.type)==="GATEWAY"||(a==null?void 0:a.type)==="GATEWAY")return 0;let s=n.filter(d=>d.source===t&&d.target===o||d.source===o&&d.target===t);if(s.length<=1){let d=n.filter(u=>u.source===t);if(d.length<=1)return 0;let p=d.findIndex(u=>u.id===e);if(p<=0)return 0;let m=(d.length-1)/2;return(p-m)*Cc}let l=s.findIndex(d=>d.id===e),c=(s.length-1)/2;return(l-c)*Cc}var Mc=({id:e,source:t,target:o,data:n,selected:r,sourcePosition:i,targetPosition:a,sourceHandleId:s,targetHandleId:l})=>{var Z,J,q,ee,ae,F,ne,le,K,xe;let{zoom:c}=ah(),{updateEdgeData:d}=sh(),p=lh(),m=ch(),{isMultipleSelection:u,mode:g,instanceId:E}=$(),[f,h]=vc(!1),[y,x]=vc(null),v=os(null),N=os(n==null?void 0:n.labelOffset),T=os(null),_=g!=="edit",{reconnectingHandle:I,cursorPosition:S,hoveredNodeId:P,reconnectingSide:R,isValidReconnection:M,handleReconnectStart:B}=Fr({edgeId:e,source:t,target:o,instanceId:E,isReadOnly:_}),X=Ac(t),U=Ac(o),{sx:Q,sy:Y,tx:C,ty:O,sourcePos:D,targetPos:A}=ts(()=>{var $e,pt;let W=X&&U?No(X,U):{sx:0,sy:0,tx:0,ty:0,sourcePos:Oo.Right,targetPos:Oo.Left},te=s?i:W.sourcePos,ce=l?a:W.targetPos,re=(Ke,be,he)=>{var Be,ft,Lt,Et,bt,Ps;let{x:me,y:_e}=Ke.internals.positionAbsolute,qe=(Lt=(ft=(Be=Ke.measured)==null?void 0:Be.width)!=null?ft:Ke.width)!=null?Lt:0,et=(Ps=(bt=(Et=Ke.measured)==null?void 0:Et.height)!=null?bt:Ke.height)!=null?Ps:0;switch(be){case Oo.Top:return{x:me+qe*he,y:_e};case Oo.Bottom:return{x:me+qe*he,y:_e+et};case Oo.Left:return{x:me,y:_e+et*he};case Oo.Right:return{x:me+qe,y:_e+et*he};default:return{x:me+qe/2,y:_e+et/2}}},fe=($e=n==null?void 0:n.sourceOffset)!=null?$e:.5,ue=(pt=n==null?void 0:n.targetOffset)!=null?pt:.5,ye=X?re(X,te,fe).x:W.sx,ve=X?re(X,te,fe).y:W.sy,Oe=U?re(U,ce,ue).x:W.tx,Ge=U?re(U,ce,ue).y:W.ty;return I==="source"&&S?(ye=S.x,ve=S.y,R&&(te=R)):I==="target"&&S&&(Oe=S.x,Ge=S.y,R&&(ce=R)),{sx:ye,sy:ve,tx:Oe,ty:Ge,sourcePos:te,targetPos:ce}},[X,U,s,l,i,a,I,S,R,n==null?void 0:n.sourceOffset,n==null?void 0:n.targetOffset]);nh(()=>{var ce;if(!T.current){T.current={sx:Q,sy:Y,tx:C,ty:O,sourcePos:D,targetPos:A};return}let W=T.current;if(Math.abs(Q-W.sx)>Xr||Math.abs(Y-W.sy)>Xr||Math.abs(C-W.tx)>Xr||Math.abs(O-W.ty)>Xr||W.sourcePos!==D||W.targetPos!==A){let re={};(ce=n==null?void 0:n.points)!=null&&ce.length&&(re.points=void 0),n!=null&&n.labelOffset&&(re.labelOffset=void 0),Object.keys(re).length>0&&d(e,b(b({},n),re))}T.current={sx:Q,sy:Y,tx:C,ty:O,sourcePos:D,targetPos:A}},[Q,Y,C,O,D,A,n,e,d,I]);let k=ts(()=>{let W=ph(e,t,o,p,m);return Yr(Q,Y,C,O,D,A,n==null?void 0:n.points,W)},[Q,Y,C,O,D,A,n==null?void 0:n.points,p,m,e,t,o]),G=ts(()=>{if(k.length<2)return Vr({x:Q,y:Y},{x:C,y:O});let W=0;for(let re=0;re<k.length-1;re++)W+=ko(k[re],k[re+1]);let te=W/2,ce=0;for(let re=0;re<k.length-1;re++){let fe=ko(k[re],k[re+1]);if(ce+fe>=te){let ue=(te-ce)/fe,ye=k[re],ve=k[re+1];return{x:ye.x+(ve.x-ye.x)*ue,y:ye.y+(ve.y-ye.y)*ue}}ce+=fe}return Vr({x:Q,y:Y},{x:C,y:O})},[k,Q,Y,C,O]),z=wc((W,te)=>{if(g!=="edit"||te.button!==0)return;te.stopPropagation(),te.preventDefault();let ce=k[W],re=k[W+1],fe=ge(ce,re,"y"),ue=fe?ce.y:ce.x,ye=[...k],ve=ye.length,Oe=W,Ge=W+1;x(W);let $e=Ke=>{let be=ue+(fe?Ke.clientY-te.clientY:Ke.clientX-te.clientX)/c;v.current=fe?{x:(ce.x+re.x)/2,y:be}:{x:be,y:(ce.y+re.y)/2};let he=[];for(let me=1;me<ve-1;me++){let _e=ye[me];me===Oe||me===Ge?fe?he.push({x:_e.x,y:be}):he.push({x:be,y:_e.y}):he.push(b({},_e))}d(e,w(b({},n),{points:he}))},pt=()=>{x(null),v.current=null,document.removeEventListener("mousemove",$e),document.removeEventListener("mouseup",pt)};document.addEventListener("mousemove",$e),document.addEventListener("mouseup",pt)},[g,k,c,n,e,d]),L=wc(W=>{var $e,pt,Ke,be,he;if(f||_||W.button!==0||!(($e=n==null?void 0:n.label)!=null&&$e.trim()))return;W.stopPropagation(),W.preventDefault();let te=W.clientX,ce=W.clientY,re=(Ke=(pt=n==null?void 0:n.labelOffset)==null?void 0:pt.x)!=null?Ke:0,fe=(he=(be=n==null?void 0:n.labelOffset)==null?void 0:be.y)!=null?he:0,ue=[...k],ye={x:G.x,y:G.y},ve=!1,Oe=me=>{let _e=(me.clientX-te)/c,qe=(me.clientY-ce)/c;if(!ve&&Math.abs(_e)<3&&Math.abs(qe)<3)return;ve=!0;let et={x:re+_e,y:fe+qe};N.current=et,d(e,w(b({},n),{labelOffset:et}))},Ge=()=>{document.removeEventListener("mousemove",Oe),document.removeEventListener("mouseup",Ge);let me=N.current;if(!me)return;let _e={x:ye.x+me.x,y:ye.y+me.y};xc(_e,ue)>uh&&(N.current=void 0,d(e,w(b({},n),{labelOffset:void 0})))};document.addEventListener("mousemove",Oe),document.addEventListener("mouseup",Ge)},[f,_,c,n,e,d,k,G]);if(!X||!U)return null;let V=Nc(k),j=r||X.selected||U.selected;return Wt(Sc,{children:[Wt("g",{className:H("group bpmn-arrow-edge",{"is-highlighted":j}),onDoubleClick:()=>!_&&h(!0),children:[Ce("path",{d:V,fill:"none",stroke:"transparent",strokeWidth:Math.max(12,12/c),className:H({"nopan nodrag":!f&&!_&&!!((Z=n==null?void 0:n.label)!=null&&Z.trim())}),style:{pointerEvents:"stroke",cursor:!f&&!_&&((J=n==null?void 0:n.label)!=null&&J.trim())?"move":"pointer"},onMouseDown:L}),Wt("g",{className:H("text-grey-500 transition-colors duration-75 group-hover:text-grey-800",{"text-blue-500 group-hover:text-blue-600":j}),children:[Ce(rh,{id:e,path:V,interactionWidth:0,markerEnd:`url(#${j?"sequence-edge-marker-highlighted":"sequence-edge-marker"})`,className:H("stroke-2 stroke-current transition-[stroke,filter] duration-75 group-hover:drop-shadow-[0_0_3px_rgba(0,0,0,0.2)]",{"stroke-red-500 hover:stroke-red-600":(n==null?void 0:n.hasError)||I&&P&&!M,"stroke-green-500":I&&P&&M,"stroke-blue-500 hover:stroke-blue-600 drop-shadow-[0_0_3px_rgba(59,130,246,0.5)]":j&&!(n!=null&&n.hasError)&&!I})}),r&&!u&&!_&&Ce("g",{children:k.slice(0,-1).map((W,te)=>{let ce=k[te+1];if(te===0||te===k.length-2||ko(W,ce)<dh)return null;let re=ge(W,ce,"y"),fe=y===te,ue=fe&&v.current?v.current:Vr(W,ce);return Wt("g",{children:[Ce("line",{x1:W.x,y1:W.y,x2:ce.x,y2:ce.y,stroke:"transparent",strokeWidth:20/c,className:H("cursor-pointer",{"cursor-ns-resize":re,"cursor-ew-resize":!re}),onMouseDown:ye=>z(te,ye)}),Ce("circle",{cx:ue.x,cy:ue.y,r:4/c,fill:fe?"#3b82f6":"#fff",stroke:"#3b82f6",strokeWidth:2/c,className:"pointer-events-none"}),Ce("circle",{cx:ue.x,cy:ue.y,r:6/c,fill:"none",stroke:"#3b82f6",strokeWidth:1/c,opacity:fe?.6:.3,className:"pointer-events-none"})]},te)})})]})]}),Wt(ih,{children:[Ce("div",{className:"absolute z-[3000] pointer-events-none flex flex-col items-center gap-1",style:{transform:`translate(-50%, -50%) translate(${G.x}px, ${G.y}px)`},children:r&&!u&&Ce(Po,{sx:Q,sy:Y,tx:C,ty:O,hasLabel:!!((q=n==null?void 0:n.label)!=null&&q.trim()),children:Ce(Mo,{edgeId:e,edgeType:"SEQUENCE_EDGE",sourceNode:X,targetNode:U})})}),(f||((ee=n==null?void 0:n.label)==null?void 0:ee.trim()))&&Ce("div",{className:H("absolute nodrag nopan",!f&&!_&&((ae=n==null?void 0:n.label)!=null&&ae.trim())?"z-[10001] pointer-events-auto":"z-[3000] pointer-events-none"),style:{transform:`translate(-50%, -50%) translate(${G.x+((ne=(F=n==null?void 0:n.labelOffset)==null?void 0:F.x)!=null?ne:0)}px, ${G.y+((K=(le=n==null?void 0:n.labelOffset)==null?void 0:le.y)!=null?K:0)}px)`,cursor:!f&&!_&&((xe=n==null?void 0:n.label)!=null&&xe.trim())?"move":void 0},onMouseDown:!f&&!_?L:void 0,onDoubleClick:W=>{_||(W.stopPropagation(),h(!0))},children:Ce(ke,{value:n==null?void 0:n.label,className:H("min-w-8 max-w-56 px-2 py-1 body-small-400",{"pointer-events-auto":f,"pointer-events-none":!f}),isEditing:f,onBlur:()=>h(!1),onChange:W=>d(e,{label:W.trim()})})}),r&&!u&&!_&&Wt(Sc,{children:[Ce("div",{className:"absolute z-[10000] pointer-events-none",style:{transform:`translate(-50%, -50%) translate(${k[0].x}px, ${k[0].y}px)`},children:Wt("svg",{width:12/c,height:12/c,style:{overflow:"visible",position:"absolute",left:"50%",top:"50%",transform:"translate(-50%, -50%)"},children:[Ce("circle",{cx:6/c,cy:6/c,r:4/c,fill:I==="source"?"#3b82f6":"#fff",stroke:"#3b82f6",strokeWidth:2/c,className:"pointer-events-none"}),Ce("circle",{cx:6/c,cy:6/c,r:6/c,fill:"none",stroke:"#3b82f6",strokeWidth:1/c,opacity:I==="source"?.6:.3,className:"pointer-events-none"}),Ce("circle",{cx:6/c,cy:6/c,r:8/c,fill:"transparent",className:H("pointer-events-auto",{"cursor-move":!I||I!=="source","cursor-not-allowed":I==="source"&&P&&!M,"cursor-grabbing":I==="source"&&(!P||M)}),onMouseDown:W=>B("source",W.nativeEvent)})]})}),Ce("div",{className:"absolute z-[10000] pointer-events-none",style:{transform:`translate(-50%, -50%) translate(${k[k.length-1].x}px, ${k[k.length-1].y}px)`},children:Wt("svg",{width:12/c,height:12/c,style:{overflow:"visible",position:"absolute",left:"50%",top:"50%",transform:"translate(-50%, -50%)"},children:[Ce("circle",{cx:6/c,cy:6/c,r:4/c,fill:I==="target"?"#3b82f6":"#fff",stroke:"#3b82f6",strokeWidth:2/c,className:"pointer-events-none"}),Ce("circle",{cx:6/c,cy:6/c,r:6/c,fill:"none",stroke:"#3b82f6",strokeWidth:1/c,opacity:I==="target"?.6:.3,className:"pointer-events-none"}),Ce("circle",{cx:6/c,cy:6/c,r:8/c,fill:"transparent",className:H("pointer-events-auto",{"cursor-move":!I||I!=="target","cursor-not-allowed":I==="target"&&P&&!M,"cursor-grabbing":I==="target"&&(!P||M)}),onMouseDown:W=>B("target",W.nativeEvent)})]})})]})]})]})};import{Position as wt}from"@xyflow/react";var fh={right:wt.Right,left:wt.Left,top:wt.Top,bottom:wt.Bottom},Ur=e=>{var t;return(t=fh[e!=null?e:""])!=null?t:wt.Right},ns=(e,t,o=.5)=>{var l,c,d,p;let{x:n,y:r}=e.internals.positionAbsolute,i=(c=(l=e.measured)==null?void 0:l.width)!=null?c:0,a=(p=(d=e.measured)==null?void 0:d.height)!=null?p:0;switch(Ur(t)){case wt.Right:return{x:n+i,y:r+a*o};case wt.Left:return{x:n,y:r+a*o};case wt.Top:return{x:n+i*o,y:r};case wt.Bottom:return{x:n+i*o,y:r+a};default:return{x:n+i/2,y:r+a/2}}},Pc=(e,t,o)=>{var d,p;let{position:{x:n,y:r},measured:i}=e,a=(d=i.width)!=null?d:0,s=(p=i.height)!=null?p:0;return[{id:"left",x:n,y:r+s/2},{id:"right",x:n+a,y:r+s/2},{id:"top",x:n+a/2,y:r},{id:"bottom",x:n+a/2,y:r+s}].reduce((m,u)=>{let g=Math.hypot(t-m.x,o-m.y);return Math.hypot(t-u.x,o-u.y)<g?u:m}).id};import{useDebouncedCallback as n0}from"use-debounce";import{getViewportForBounds as e0,useReactFlow as t0,useStoreApi as o0}from"@xyflow/react";import{useCallback as Fd}from"react";var _n=(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))(_n||{});import{xml2json as mh,json2xml as gh}from"xml-js";var Lc={compact:!0,spaces:4},hh=e=>e.replace(/\n/g,"&#xA;");function $r(e,t=Lc){if(e)return JSON.parse(mh(e,t))}function kc(e,t=Lc){return e?gh(e,w(b({},t),{attributeValueFn:hh})):""}var Rc={"attribute-loop":"LOOP"},Dc={"task-script":"SCRIPT","subprocess-collapsed":"SUBPROCESS"},Oc={"gateway-exclusive":"EXCLUSIVE","gateway-parallel":"PARALLEL","gateway-complex":"COMPLEX"},Vc={SCRIPT:"task-script",SUBPROCESS:"subprocess-collapsed"},Hc={EXCLUSIVE:"gateway-exclusive",PARALLEL:"gateway-parallel",COMPLEX:"gateway-complex"};var Vo=(e,t,o,n,r,i)=>{let a=e._attributes.width||0,s=e._attributes.height||0,l=0,c=0;if(n&&r!==void 0&&i!==void 0){let g=n.split(`
6
- `),E=g.length;l=g.reduce((h,y)=>Math.max(h,y.length),0)*7+r,c=E*20+i}let d=Math.max(kt(Number(a),t),l),p=Math.max(kt(Number(s),o),c);return{width:d,height:p,measured:{width:d,height:p}}},Ho=e=>{let{_attributes:t,mxGeometry:o}=e,{id:n,parent:r,value:i}=t,a={x:Number(o._attributes.x||0),y:Number(o._attributes.y||0)},s={id:n,position:a,data:{label:i||""}},l=r==="1"?void 0:r;return l&&(s.parentId=l),s},xh=e=>{let{mxGeometry:t}=e,o=Ho(e),n=Vo(t,pe.START_EVENT.MIN_WIDTH,pe.START_EVENT.MIN_HEIGHT);return w(b(b({},o),n),{type:"START_EVENT"})},Eh=e=>{let{mxGeometry:t}=e,o=Ho(e),n=Vo(t,pe.END_EVENT.MIN_WIDTH,pe.END_EVENT.MIN_HEIGHT);return w(b(b({},o),n),{type:"END_EVENT"})},rs=(e,t)=>{let{_attributes:o,mxGeometry:n}=e,r=Ho(e),s=Vo(n,pe.TASK.MIN_WIDTH,pe.TASK.MIN_HEIGHT,r.data.label,48,24),l=t==null?void 0:t.find(d=>{let{parent:p}=d._attributes;return p===e._attributes.id});if(l){let{style:d}=l._attributes,p=Rc[d];p&&(r.data.attribute=p)}let c=Dc[o.style];return c&&(r.data.variant=c),w(b(b({},r),s),{type:"TASK"})},is=e=>{let{_attributes:t,mxGeometry:o}=e,{style:n}=t,r=Ho(e),i=Vo(o,pe.GATEWAY.MIN_WIDTH,pe.GATEWAY.MIN_HEIGHT);return r.data.variant=Oc[n],w(b(b({},r),i),{type:"GATEWAY"})},bh=e=>{let{mxGeometry:t}=e,o=Ho(e),i=Vo(t,pe.ANNOTATION.MIN_WIDTH,pe.ANNOTATION.MIN_HEIGHT,o.data.label,32,24);return w(b(b({},o),i),{type:"ANNOTATION"})},_h=e=>{let{mxGeometry:t}=e,o=Ho(e),n=Vo(t,pe.LANE.MIN_WIDTH,pe.LANE.MIN_HEIGHT);return w(b(b({},o),n),{type:"LANE"})},Gc={task:rs,"task-script":rs,"subprocess-collapsed":rs,"start-event":xh,"end-event-terminate":Eh,"gateway-parallel":is,"gateway-exclusive":is,"gateway-complex":is,annotation:bh,lane:_h},Nh=e=>{if(e&&Array.isArray(e))return e.map(t=>({x:Number(t._attributes.x),y:Number(t._attributes.y)}))},Bc=e=>{let{_attributes:t,mxGeometry:o}=e,{id:n,source:r,target:i,value:a,style:s,sourceHandle:l,targetHandle:c,sourceOffset:d,targetOffset:p,labelOffsetX:m,labelOffsetY:u}=t,g=Nh(o==null?void 0:o.Array),E=d!==void 0?Number(d):void 0,f=p!==void 0?Number(p):void 0,h=m!==void 0?Number(m):void 0,y=u!==void 0?Number(u):void 0,x=w(b(b({id:n,source:r,target:i},l?{sourceHandle:l}:{}),c?{targetHandle:c}:{}),{data:b(b(b(b({label:a||""},g&&g.length>0?{points:g}:{}),E!==void 0?{sourceOffset:E}:{}),f!==void 0?{targetOffset:f}:{}),h!==void 0&&y!==void 0?{labelOffset:{x:h,y}}:{})});return s.includes("association")&&s.includes('endArrow=""')?b(b({},Lo),x):b(b({},rt),x)},zc=(e,t)=>{var u,g;let{id:o,type:n,source:r,target:i,sourceHandle:a,targetHandle:s,data:l}=e,c=t==null?void 0:t.find(E=>E.id===r),d="";n==="ANNOTATION_EDGE"&&(d='association;endArrow=""');let p={_attributes:{as:"geometry",relative:"1"}};return l!=null&&l.points&&Array.isArray(l.points)&&l.points.length>0&&(p.Array=l.points.map(E=>({_attributes:{as:"mxPoint",x:E.x,y:E.y}}))),{_attributes:{id:o,parent:(c==null?void 0:c.parentId)||"1",edge:"1",style:d,source:r,target:i,value:(l==null?void 0:l.label)||"",sourceHandle:a!=null?a:void 0,targetHandle:s!=null?s:void 0,sourceOffset:(l==null?void 0:l.sourceOffset)!==void 0?String(l.sourceOffset):void 0,targetOffset:(l==null?void 0:l.targetOffset)!==void 0?String(l.targetOffset):void 0,labelOffsetX:((u=l==null?void 0:l.labelOffset)==null?void 0:u.x)!==void 0?String(l.labelOffset.x):void 0,labelOffsetY:((g=l==null?void 0:l.labelOffset)==null?void 0:g.y)!==void 0?String(l.labelOffset.y):void 0},mxGeometry:p}},Go=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}}}},Th=e=>{let{variant:t}=e.data,o=Go(e);return w(b({},o),{_attributes:w(b({},o._attributes),{style:Vc[t]||"task"})})},vh=e=>{let t=Go(e);return w(b({},t),{_attributes:w(b({},t._attributes),{style:"start-event"})})},wh=e=>{let t=Go(e);return w(b({},t),{_attributes:w(b({},t._attributes),{style:"end-event-terminate"})})},Ih=e=>{let{variant:t}=e.data,o=Go(e);return w(b({},o),{_attributes:w(b({},o._attributes),{style:Hc[t]})})},Ah=e=>{let t=Go(e);return w(b({},t),{_attributes:w(b({},t._attributes),{style:"lane"})})},Ch=e=>{let t=Go(e);return w(b({},t),{_attributes:w(b({},t._attributes),{style:"annotation"})})},Yc={TASK:Th,START_EVENT:vh,END_EVENT:wh,GATEWAY:Ih,ANNOTATION:Ch,LANE:Ah},Wc=(e,t)=>{var a,s;let r=((a=e.measured)==null?void 0:a.width)||0,i=((s=e.measured)==null?void 0:s.height)||0;return{_attributes:{id:`${t+1}`,parent:e.id,style:"attribute-loop",connectable:"0"},mxGeometry:{_attributes:{as:"geometry",x:r/2-22/2,y:i-22,width:22,height:22}}}};import Fc from"@dagrejs/dagre";import{getNodesBounds as ss}from"@xyflow/react";var Uc=(e=[],t=[],o="LR")=>{let n=new Fc.graphlib.Graph;return n.setDefaultEdgeLabel(()=>({})),n.setGraph({rankdir:o}),e.forEach(({id:i,width:a,height:s})=>n.setNode(i,{width:a,height:s})),t.forEach(i=>n.setEdge(i.source,i.target)),Fc.layout(n),{nodes:e.map(i=>{let a=n.node(i.id);return w(b({},i),{position:{x:a.x-i.width/2,y:a.y-i.height/2}})}),edges:t}},It=e=>{let t=e.filter(n=>n.type==="LANE"&&!n.parentId);if(t.length===0)return e;let o=js(e);for(let n of t){let r=[...o.values()],i=r.filter(s=>s.parentId===n.id);if(i.length===0)continue;let a=i.filter(s=>s.type==="LANE");if(a.length>0){ia(a,o,r),sa(n,o);continue}ki(n,i,o)}return ea(e,o)},$c=It,Kc=()=>{let e=document.querySelector(".react-flow__viewport");return e||(console.error("Flow element (.react-flow__viewport) not found."),null)};var Sh=e=>e.type==="LANE"&&!e.parentId,Mh=(e,t)=>{let o=e.x+e.width,n=e.y+e.height,r=t.x+t.width,i=t.y+t.height;return e.x<=t.x&&e.y<=t.y&&o>=r&&n>=i},Xc=e=>e.width*e.height,as=e=>{var m;let t=e.filter(Sh);if(t.length===0)return e;let o=new Map;for(let u of e){if(!u.parentId)continue;let g=(m=o.get(u.parentId))!=null?m:[];g.push(u.id),o.set(u.parentId,g)}let n=new Set,r=t.map(u=>u.id);for(;r.length>0;){let u=r.pop();if(!u||n.has(u))continue;n.add(u);let g=o.get(u);if(g)for(let E of g)n.has(E)||r.push(E)}let i=e.filter(u=>n.has(u.id));if(i.length===0)return e;let a=ss(i),l=e.filter(u=>!n.has(u.id)).filter(u=>{let g=ss([u]);return!Mh(a,g)});if(l.length===0)return i;let c=Xc(a),d=l.reduce((u,g)=>u+Xc(ss([g])),0);return l.some(u=>u.type!=="ANNOTATION")||l.length>1||d>=c*.05?e:i};var Nn=1,qc=e=>`<mxGraphModel>
5
+ `).trim();t&&T.length>t&&(T=T.substring(0,t)),N.currentTarget.innerText=T,s==null||s(),T!==e&&(a==null||a(T))};return bc("div",{className:H("flex-1 p-2 self-stretch flex items-center justify-center border border-transparent overflow-hidden text-ellipsis body-medium-400 text-center rounded-sm",{"border border-dashed border-grey-400 bg-white shadow-md":f,"bg-white":e.length>0},n),style:o,onDoubleClick:p,children:bc("div",{ref:u,className:H("outline-none whitespace-pre-wrap overflow-hidden",r,{"nodrag nopan cursor-text":f}),contentEditable:f,suppressContentEditableWarning:!0,onKeyDown:h,onPaste:y,onInput:x,onBlur:v,children:e})})};import{Position as BI}from"@xyflow/react";var ge=(e,t,o,n=1)=>Math.abs(e[o]-t[o])<n,Oo=(e,t)=>Math.sqrt((t.x-e.x)**2+(t.y-e.y)**2),Br=(e,t)=>({x:(e.x+t.x)/2,y:(e.y+t.y)/2}),Xg=(e,t,o)=>{let n=o.x-t.x,r=o.y-t.y,i=n*n+r*r;if(i===0)return Oo(e,t);let a=Math.max(0,Math.min(1,((e.x-t.x)*n+(e.y-t.y)*r)/i));return Oo(e,{x:t.x+a*n,y:t.y+a*r})},_c=(e,t)=>{let o=1/0;for(let n=0;n<t.length-1;n++)o=Math.min(o,Xg(e,t[n],t[n+1]));return o};import{Position as zr}from"@xyflow/react";var zt={OFFSET:30,TOLERANCE:1,MOVE_THRESHOLD:5,MIN_SEGMENT_LENGTH:15,PARALLEL_OFFSET:15,MAX_LABEL_DISTANCE:80};var{TOLERANCE:de}=zt;function Ug(e,t,o){return ge(e,t,"x",de)&&ge(t,o,"x",de)&&ge(e,o,"x",de)}function $g(e,t,o){return ge(e,t,"y",de)&&ge(t,o,"y",de)&&ge(e,o,"y",de)}function Kg(e,t,o){if(!Ug(e,t,o))return!1;let n=t.y-e.y,r=o.y-t.y;return Math.abs(n)<de||Math.abs(r)<de?!1:n*r<0}function qg(e,t,o){if(!$g(e,t,o))return!1;let n=t.x-e.x,r=o.x-t.x;return Math.abs(n)<de||Math.abs(r)<de?!1:n*r<0}function Zg(e,t,o,n){let r=t.x!==0,i=t.x===-n.x&&t.y===-n.y,a=t.x===n.x&&t.y===n.y,s=120;if(i)if(r){if((o.x-e.x)*t.x>=0)return[{x:(e.x+o.x)/2,y:e.y},{x:(e.x+o.x)/2,y:o.y}];{let l=(e.y+o.y)/2,c=Math.abs(e.y-o.y)<s?Math.max(e.y,o.y)+s:l;return[{x:e.x,y:c},{x:o.x,y:c}]}}else{if((o.y-e.y)*t.y>=0)return[{x:e.x,y:(e.y+o.y)/2},{x:o.x,y:(e.y+o.y)/2}];{let l=(e.x+o.x)/2,c=Math.abs(e.x-o.x)<s?Math.max(e.x,o.x)+s:l;return[{x:c,y:e.y},{x:c,y:o.y}]}}else if(a)if(r)if((o.x-e.x)*t.x>0&&Math.abs(e.y-o.y)<s){let l=Math.max(e.y,o.y)+s,c=o.x+t.x*(s/2);return[{x:e.x,y:l},{x:c,y:l},{x:c,y:o.y}]}else{let l=t.x>0?Math.max(e.x,o.x):Math.min(e.x,o.x);return[{x:l,y:e.y},{x:l,y:o.y}]}else if((o.y-e.y)*t.y>0&&Math.abs(e.x-o.x)<s){let l=Math.max(e.x,o.x)+s,c=o.y+t.y*(s/2);return[{x:l,y:e.y},{x:l,y:c},{x:o.x,y:c}]}else{let l=t.y>0?Math.max(e.y,o.y):Math.min(e.y,o.y);return[{x:e.x,y:l},{x:o.x,y:l}]}else{let l=t.x!==0?o.x:e.x,c=t.y!==0?o.y:e.y,d=t.x!==0?(l-e.x)*t.x:(c-e.y)*t.y,u=n.x!==0?(l-o.x)*n.x:(c-o.y)*n.y;return d>=0&&u>=0?[{x:l,y:c}]:r?[{x:e.x,y:o.y}]:[{x:o.x,y:e.y}]}}function Tc(e){if(e.length<=2)return e;let t=[e[0]];for(let o=1;o<e.length-1;o++){let n=t[t.length-1],r=e[o],i=e[o+1];ge(n,r,"x",de)&&ge(r,i,"x",de)||ge(n,r,"y",de)&&ge(r,i,"y",de)||t.push(r)}return t.push(e[e.length-1]),t}function Yr(e){let t=[];for(let o of e){let n=t[t.length-1];(!n||Math.abs(n.x-o.x)>=de||Math.abs(n.y-o.y)>=de)&&t.push(o)}return t}function Jg(e){let t=[...e],o=!0;for(;o;){o=!1;for(let n=1;n<t.length-1;n++){let r=t[n-1],i=t[n],a=t[n+1];if(Kg(r,i,a)||qg(r,i,a)){t.splice(n,1),o=!0;break}}}return t}function Nc(e){let t=Yr(Tc([...e]));return t=Jg(t),Yr(Tc(t))}function Wr(e){switch(e){case zr.Left:return{x:-1,y:0};case zr.Right:return{x:1,y:0};case zr.Top:return{x:0,y:-1};case zr.Bottom:return{x:0,y:1};default:return{x:0,y:0}}}function vc(e,t,o,n){let r=zt.OFFSET,i=zt.OFFSET;if(t.x===-n.x&&t.y===-n.y)if(t.x!==0){let a=(o.x-e.x)*t.x;a>0&&a<2*zt.OFFSET&&(r=a/2,i=a/2)}else{let a=(o.y-e.y)*t.y;a>0&&a<2*zt.OFFSET&&(r=a/2,i=a/2)}return{sourceOffset:r,targetOffset:i}}function Qg(e,t,o,n,r,i,a=0){let s=Wr(r),l=Wr(i),c=s.x===0?a:0,d=s.y===0?a:0,u=l.x===0?a:0,m=l.y===0?a:0,f={x:e+c,y:t+d},g={x:o+u,y:n+m},{sourceOffset:b,targetOffset:p}=vc(f,s,g,l),h={x:f.x+s.x*b,y:f.y+s.y*b},y={x:g.x+l.x*p,y:g.y+l.y*p},x=Zg(h,s,y,l),v=[f,h,...x,y,g],N=Nc(v);if(N.length===2&&Fr(f,g)>de){let T=ge(f,h,"x",de)&&ge(h,y,"x",de)&&ge(y,g,"x",de),E=ge(f,h,"y",de)&&ge(h,y,"y",de)&&ge(y,g,"y",de);if(T||E){let I=E&&(y.x-h.x)*s.x<0,P=T&&(y.y-h.y)*s.y<0;if(!I&&!P)return Yr([f,h,y,g])}}return N}function Xr(e,t,o,n,r,i,a,s=0){if(!(a!=null&&a.length))return Qg(e,t,o,n,r,i,s);let l=Wr(r),c=Wr(i),d=l.x===0?s:0,u=l.y===0?s:0,m=c.x===0?s:0,f=c.y===0?s:0,g={x:e+d,y:t+u},b={x:o+m,y:n+f},{sourceOffset:p,targetOffset:h}=vc(g,l,b,c),y={x:g.x+l.x*p,y:g.y+l.y*p},x={x:b.x+c.x*h,y:b.y+c.y*h},v=[...a],N=v[0],T=l.y===0;T&&Math.abs(g.y-N.y)>de?v.unshift({x:N.x,y:g.y}):!T&&Math.abs(g.x-N.x)>de&&v.unshift({x:g.x,y:N.y});let E=v[v.length-1],I=c.y===0,P=[];(Math.abs(E.x-x.x)>de||Math.abs(E.y-x.y)>de)&&(I?P.push({x:x.x,y:E.y}):P.push({x:E.x,y:x.y})),P.push(x);let M=[g,...v,...P,b],V=Nc(M);if(V.length===2&&Fr(g,b)>de){let C=ge(g,y,"x",de)&&ge(y,x,"x",de)&&ge(x,b,"x",de),G=ge(g,y,"y",de)&&ge(y,x,"y",de)&&ge(x,b,"y",de);if(C||G){let K=G&&(x.x-y.x)*l.x<0,$=C&&(x.y-y.y)*l.y<0;if(!K&&!$)return Yr([g,y,x,b])}}return V}var Fr=(e,t)=>Math.sqrt(Math.pow(t.x-e.x,2)+Math.pow(t.y-e.y,2));function jg(e,t,o){return ge(e,t,"x",de)&&ge(t,o,"x",de)||ge(e,t,"y",de)&&ge(t,o,"y",de)}function eh(e,t,o,n){if(jg(e,t,o))return`L${t.x} ${t.y}`;let r=Fr(e,t),i=Fr(t,o),a=Math.min(r/2,i/2,n);if(a<1)return`L${t.x} ${t.y}`;let s=e.x-t.x,l=e.y-t.y,c=o.x-t.x,d=o.y-t.y,u={x:s/r,y:l/r},m={x:c/i,y:d/i},f={x:t.x+u.x*a,y:t.y+u.y*a},g={x:t.x+m.x*a,y:t.y+m.y*a},b=-u.x,p=-u.y,h=m.x,y=m.y,v=b*y-p*h>0?1:0;return`L${f.x} ${f.y}A${a} ${a} 0 0 ${v} ${g.x} ${g.y}`}var wc=(e,t=5)=>e.length<2?"":e.reduce((o,n,r)=>{let i="";return r>0&&r<e.length-1?i=eh(e[r-1],n,e[r+1],t):i=`${r===0?"M":"L"}${n.x} ${n.y}`,o+=i,o},"");import{useCallback as Vo,useEffect as Ur,useRef as Nn,useState as Ho}from"react";import{useReactFlow as th,useStore as oh}from"@xyflow/react";var nh=50,Ic=.1,rh=.6,$r=({edgeId:e,source:t,target:o,instanceId:n,isReadOnly:r})=>{let{setEdges:i,getNode:a,getNodes:s,getEdge:l,screenToFlowPosition:c}=th(),{setIsDragging:d,setReconnectingEdgeId:u}=Z(),m=oh(D=>D.isValidConnection),[f,g]=Ho(null),[b,p]=Ho(null),[h,y]=Ho(null),[x,v]=Ho(null),[N,T]=Ho(null),[E,I]=Ho(!1),P=Nn(null),M=Nn(null),V=Nn(null),C=Nn(t),G=Nn(o);Ur(()=>{C.current=t,G.current=o},[t,o]),Ur(()=>{P.current=f},[f]),Ur(()=>{M.current=N},[N]);let K=Vo(D=>{let A=s(),L=A.find(k=>k.id===D);if(!L)return{x:0,y:0};let B=L.position.x,z=L.position.y,O=L.parentId;for(;O;){let k=A.find(F=>F.id===O);if(!k)break;B+=k.position.x,z+=k.position.y,O=k.parentId}return{x:B,y:z}},[s]),$=Vo(D=>{var O,k,F,ee,U,Q;let A=s(),L=null,B=nh,z=A.filter(j=>j.type!=="LANE"&&j.type!=="ANNOTATION");for(let j of z){if(j.id===e)continue;let oe=K(j.id),X=(F=(k=(O=j.measured)==null?void 0:O.width)!=null?k:j.width)!=null?F:0,ce=(Q=(U=(ee=j.measured)==null?void 0:ee.height)!=null?U:j.height)!=null?Q:0;if(D.x>=oe.x&&D.x<=oe.x+X&&D.y>=oe.y&&D.y<=oe.y+ce)return j.id;let q=Math.max(oe.x-D.x,0,D.x-(oe.x+X)),xe=Math.max(oe.y-D.y,0,D.y-(oe.y+ce)),W=Math.sqrt(q*q+xe*xe);W<B&&(B=W,L=j.id)}return L},[s,K,e]),J=Vo((D,A)=>{var q,xe,W,ae,re,ie;let L=a(D);if(!L)return null;let B=K(D),z=(W=(xe=(q=L.measured)==null?void 0:q.width)!=null?xe:L.width)!=null?W:0,O=(ie=(re=(ae=L.measured)==null?void 0:ae.height)!=null?re:L.height)!=null?ie:0,k=Math.abs(B.x+z-A.x),F=Math.abs(A.x-B.x),ee=Math.abs(B.y+O-A.y),U=Math.abs(A.y-B.y),Q={right:k,left:F,bottom:ee,top:U},j=Object.entries(Q).reduce((ue,[pe,he])=>he<ue[1]?[pe,he]:ue,["right",Q.right])[0],oe=V.current;if(oe&&oe!==j){let ue=Q[j],pe=Q[oe],he=Math.abs(pe-ue),Ne=Math.min(Math.abs(pe),Math.abs(ue));he<Ne*rh&&(j=oe)}let X=j,ce,ne;if(X==="right"||X==="left"){let pe=(Math.max(B.y,Math.min(B.y+O,A.y))-B.y)/(O||1);Math.abs(pe-.5)<Ic&&(pe=.5),ne=pe,ce={x:X==="right"?B.x+z:B.x,y:B.y+ne*O}}else{let pe=(Math.max(B.x,Math.min(B.x+z,A.x))-B.x)/(z||1);Math.abs(pe-.5)<Ic&&(pe=.5),ne=pe,ce={x:B.x+ne*z,y:X==="bottom"?B.y+O:B.y}}return{side:X,snapPosition:ce,offset:ne}},[a,K]),Y=Vo(D=>{var F,ee,U;let A=P.current;if(!A)return;let L=c({x:D.clientX,y:D.clientY}),B=$(L);y(B);let z=L,O=null,k=null;if(B){let Q=J(B,L);Q&&(O=Q.side,z=Q.snapPosition,k=Q.offset,V.current=O);let j=l(e),oe={source:A==="source"?B:C.current,target:A==="target"?B:G.current,sourceHandle:A==="source"?O:(F=j==null?void 0:j.sourceHandle)!=null?F:null,targetHandle:A==="target"?O:(ee=j==null?void 0:j.targetHandle)!=null?ee:null},X=(U=m==null?void 0:m(oe))!=null?U:!0;I(X)}else V.current=null,I(!1);v(O),T(k),p(z)},[$,J,l,e,c,m]),S=Vo(D=>{var O,k,F,ee,U;let A=P.current;if(!A)return;let L=c({x:D.clientX,y:D.clientY}),B=$(L);if(B){let Q=J(B,L),j=(O=Q==null?void 0:Q.side)!=null?O:null,oe=(k=Q==null?void 0:Q.offset)!=null?k:.5,X=l(e),ce={source:A==="source"?B:C.current,target:A==="target"?B:G.current,sourceHandle:A==="source"?j:(F=X==null?void 0:X.sourceHandle)!=null?F:null,targetHandle:A==="target"?j:(ee=X==null?void 0:X.targetHandle)!=null?ee:null};((U=m==null?void 0:m(ce))==null||U)&&i(ne=>ne.map(q=>{var xe,W;return q.id===e?w(_({},q),{source:ce.source,target:ce.target,sourceHandle:ce.sourceHandle,targetHandle:ce.targetHandle,data:w(_({},q.data),{points:void 0,sourceOffset:A==="source"?oe:(xe=q.data)==null?void 0:xe.sourceOffset,targetOffset:A==="target"?oe:(W=q.data)==null?void 0:W.targetOffset})}):q}))}g(null),p(null),y(null),v(null),T(null),d(!1),I(!1),u(null),V.current=null,document.removeEventListener("mouseup",S),document.removeEventListener("mousemove",Y);let z=Et.get(n);z==null||z.clearReconnectingEdge()},[e,$,J,l,i,n,Y,m,c,d,u]),R=Vo((D,A)=>{if(r||A.button!==0)return;A.stopPropagation(),A.preventDefault(),i(B=>B.map(z=>z.id===e?w(_({},z),{data:w(_({},z.data),{points:void 0})}):z)),g(D),u(e);let L=Et.get(n);L==null||L.setReconnectingEdge(e),document.addEventListener("mousemove",Y),document.addEventListener("mouseup",S)},[r,e,n,Y,S,u,i]);return Ur(()=>()=>{if(P.current){document.removeEventListener("mousemove",Y),document.removeEventListener("mouseup",S),u(null);let D=Et.get(n);D==null||D.clearReconnectingEdge()}},[n,Y,S,u]),{reconnectingHandle:f,cursorPosition:b,hoveredNodeId:h,reconnectingSide:x,reconnectingOffset:N,isValidReconnection:E,handleReconnectStart:R}};import{Fragment as Lc,jsx as Ce,jsxs as Yt}from"react/jsx-runtime";var rt={type:"SEQUENCE_EDGE",reconnectable:!0,markerStart:{type:Sc.ArrowClosed},markerEnd:{type:Sc.Arrow},data:{label:""}},{MOVE_THRESHOLD:Kr,MIN_SEGMENT_LENGTH:ph,PARALLEL_OFFSET:Pc,MAX_LABEL_DISTANCE:fh}=zt;function mh(e,t,o,n,r){let i=r.find(d=>d.id===t),a=r.find(d=>d.id===o);if((i==null?void 0:i.type)==="GATEWAY"||(a==null?void 0:a.type)==="GATEWAY")return 0;let s=n.filter(d=>d.source===t&&d.target===o||d.source===o&&d.target===t);if(s.length<=1){let d=n.filter(f=>f.source===t);if(d.length<=1)return 0;let u=d.findIndex(f=>f.id===e);if(u<=0)return 0;let m=(d.length-1)/2;return(u-m)*Pc}let l=s.findIndex(d=>d.id===e),c=(s.length-1)/2;return(l-c)*Pc}var kc=({id:e,source:t,target:o,data:n,selected:r,sourcePosition:i,targetPosition:a,sourceHandleId:s,targetHandleId:l})=>{var ee,U,Q,j,oe,X,ce,ne,q,xe;let{zoom:c}=ch(),{updateEdgeData:d}=lh(),u=dh(),m=uh(),{isMultipleSelection:f,mode:g,instanceId:b}=Z(),[p,h]=Ac(!1),[y,x]=Ac(null),v=as(null),N=as(n==null?void 0:n.labelOffset),T=as(null),E=g!=="edit",{reconnectingHandle:I,cursorPosition:P,hoveredNodeId:M,reconnectingSide:V,isValidReconnection:C,handleReconnectStart:G}=$r({edgeId:e,source:t,target:o,instanceId:b,isReadOnly:E}),K=Mc(t),$=Mc(o),{sx:J,sy:Y,tx:S,ty:R,sourcePos:D,targetPos:A}=ss(()=>{var Ke,ft;let W=K&&$?Ao(K,$):{sx:0,sy:0,tx:0,ty:0,sourcePos:Go.Right,targetPos:Go.Left},ae=s?i:W.sourcePos,re=l?a:W.targetPos,ie=(qe,at,Be)=>{var et,Jt,Qt,ze,mt,Pt;let{x:ve,y:me}=qe.internals.positionAbsolute,ye=(Qt=(Jt=(et=qe.measured)==null?void 0:et.width)!=null?Jt:qe.width)!=null?Qt:0,be=(Pt=(mt=(ze=qe.measured)==null?void 0:ze.height)!=null?mt:qe.height)!=null?Pt:0;switch(at){case Go.Top:return{x:ve+ye*Be,y:me};case Go.Bottom:return{x:ve+ye*Be,y:me+be};case Go.Left:return{x:ve,y:me+be*Be};case Go.Right:return{x:ve+ye,y:me+be*Be};default:return{x:ve+ye/2,y:me+be/2}}},ue=(Ke=n==null?void 0:n.sourceOffset)!=null?Ke:.5,pe=(ft=n==null?void 0:n.targetOffset)!=null?ft:.5,he=K?ie(K,ae,ue).x:W.sx,Ne=K?ie(K,ae,ue).y:W.sy,ke=$?ie($,re,pe).x:W.tx,Ge=$?ie($,re,pe).y:W.ty;return I==="source"&&P?(he=P.x,Ne=P.y,V&&(ae=V)):I==="target"&&P&&(ke=P.x,Ge=P.y,V&&(re=V)),{sx:he,sy:Ne,tx:ke,ty:Ge,sourcePos:ae,targetPos:re}},[K,$,s,l,i,a,I,P,V,n==null?void 0:n.sourceOffset,n==null?void 0:n.targetOffset]);ih(()=>{var re;if(!T.current){T.current={sx:J,sy:Y,tx:S,ty:R,sourcePos:D,targetPos:A};return}let W=T.current;if(Math.abs(J-W.sx)>Kr||Math.abs(Y-W.sy)>Kr||Math.abs(S-W.tx)>Kr||Math.abs(R-W.ty)>Kr||W.sourcePos!==D||W.targetPos!==A){let ie={};(re=n==null?void 0:n.points)!=null&&re.length&&(ie.points=void 0),n!=null&&n.labelOffset&&(ie.labelOffset=void 0),Object.keys(ie).length>0&&d(e,_(_({},n),ie))}T.current={sx:J,sy:Y,tx:S,ty:R,sourcePos:D,targetPos:A}},[J,Y,S,R,D,A,n,e,d,I]);let L=ss(()=>{let W=mh(e,t,o,u,m);return Xr(J,Y,S,R,D,A,n==null?void 0:n.points,W)},[J,Y,S,R,D,A,n==null?void 0:n.points,u,m,e,t,o]),B=ss(()=>{if(L.length<2)return Br({x:J,y:Y},{x:S,y:R});let W=0;for(let ie=0;ie<L.length-1;ie++)W+=Oo(L[ie],L[ie+1]);let ae=W/2,re=0;for(let ie=0;ie<L.length-1;ie++){let ue=Oo(L[ie],L[ie+1]);if(re+ue>=ae){let pe=(ae-re)/ue,he=L[ie],Ne=L[ie+1];return{x:he.x+(Ne.x-he.x)*pe,y:he.y+(Ne.y-he.y)*pe}}re+=ue}return Br({x:J,y:Y},{x:S,y:R})},[L,J,Y,S,R]),z=Cc((W,ae)=>{if(g!=="edit"||ae.button!==0)return;ae.stopPropagation(),ae.preventDefault();let re=L[W],ie=L[W+1],ue=ge(re,ie,"y"),pe=ue?re.y:re.x,he=[...L],Ne=he.length,ke=W,Ge=W+1;x(W);let Ke=qe=>{let at=pe+(ue?qe.clientY-ae.clientY:qe.clientX-ae.clientX)/c;v.current=ue?{x:(re.x+ie.x)/2,y:at}:{x:at,y:(re.y+ie.y)/2};let Be=[];for(let ve=1;ve<Ne-1;ve++){let me=he[ve];ve===ke||ve===Ge?ue?Be.push({x:me.x,y:at}):Be.push({x:at,y:me.y}):Be.push(_({},me))}d(e,w(_({},n),{points:Be}))},ft=()=>{x(null),v.current=null,document.removeEventListener("mousemove",Ke),document.removeEventListener("mouseup",ft)};document.addEventListener("mousemove",Ke),document.addEventListener("mouseup",ft)},[g,L,c,n,e,d]),O=Cc(W=>{var Ke,ft,qe,at,Be;if(p||E||W.button!==0||!((Ke=n==null?void 0:n.label)!=null&&Ke.trim()))return;W.stopPropagation(),W.preventDefault();let ae=W.clientX,re=W.clientY,ie=(qe=(ft=n==null?void 0:n.labelOffset)==null?void 0:ft.x)!=null?qe:0,ue=(Be=(at=n==null?void 0:n.labelOffset)==null?void 0:at.y)!=null?Be:0,pe=[...L],he={x:B.x,y:B.y},Ne=!1,ke=ve=>{let me=(ve.clientX-ae)/c,ye=(ve.clientY-re)/c;if(!Ne&&Math.abs(me)<3&&Math.abs(ye)<3)return;Ne=!0;let be={x:ie+me,y:ue+ye};N.current=be,d(e,w(_({},n),{labelOffset:be}))},Ge=()=>{document.removeEventListener("mousemove",ke),document.removeEventListener("mouseup",Ge);let ve=N.current;if(!ve)return;let me={x:he.x+ve.x,y:he.y+ve.y};_c(me,pe)>fh&&(N.current=void 0,d(e,w(_({},n),{labelOffset:void 0})))};document.addEventListener("mousemove",ke),document.addEventListener("mouseup",Ge)},[p,E,c,n,e,d,L,B]);if(!K||!$)return null;let k=wc(L),F=r||K.selected||$.selected;return Yt(Lc,{children:[Yt("g",{className:H("group bpmn-arrow-edge",{"is-highlighted":F}),onDoubleClick:()=>!E&&h(!0),children:[Ce("path",{d:k,fill:"none",stroke:"transparent",strokeWidth:Math.max(12,12/c),className:H({"nopan nodrag":!p&&!E&&!!((ee=n==null?void 0:n.label)!=null&&ee.trim())}),style:{pointerEvents:"stroke",cursor:!p&&!E&&((U=n==null?void 0:n.label)!=null&&U.trim())?"move":"pointer"},onMouseDown:O}),Yt("g",{className:H("text-grey-500 transition-colors duration-75 group-hover:text-grey-800",{"text-blue-500 group-hover:text-blue-600":F}),children:[Ce(sh,{id:e,path:k,interactionWidth:0,markerEnd:`url(#${F?"sequence-edge-marker-highlighted":"sequence-edge-marker"})`,className:H("stroke-2 stroke-current transition-[stroke,filter] duration-75 group-hover:drop-shadow-[0_0_3px_rgba(0,0,0,0.2)]",{"stroke-red-500 hover:stroke-red-600":(n==null?void 0:n.hasError)||I&&M&&!C,"stroke-green-500":I&&M&&C,"stroke-blue-500 hover:stroke-blue-600 drop-shadow-[0_0_3px_rgba(59,130,246,0.5)]":F&&!(n!=null&&n.hasError)&&!I})}),r&&!f&&!E&&Ce("g",{children:L.slice(0,-1).map((W,ae)=>{let re=L[ae+1];if(ae===0||ae===L.length-2||Oo(W,re)<ph)return null;let ie=ge(W,re,"y"),ue=y===ae,pe=ue&&v.current?v.current:Br(W,re);return Yt("g",{children:[Ce("line",{x1:W.x,y1:W.y,x2:re.x,y2:re.y,stroke:"transparent",strokeWidth:20/c,className:H("cursor-pointer",{"cursor-ns-resize":ie,"cursor-ew-resize":!ie}),onMouseDown:he=>z(ae,he)}),Ce("circle",{cx:pe.x,cy:pe.y,r:4/c,fill:ue?"#3b82f6":"#fff",stroke:"#3b82f6",strokeWidth:2/c,className:"pointer-events-none"}),Ce("circle",{cx:pe.x,cy:pe.y,r:6/c,fill:"none",stroke:"#3b82f6",strokeWidth:1/c,opacity:ue?.6:.3,className:"pointer-events-none"})]},ae)})})]})]}),Yt(ah,{children:[Ce("div",{className:"absolute z-[3000] pointer-events-none flex flex-col items-center gap-1",style:{transform:`translate(-50%, -50%) translate(${B.x}px, ${B.y}px)`},children:r&&!f&&Ce(Ro,{sx:J,sy:Y,tx:S,ty:R,hasLabel:!!((Q=n==null?void 0:n.label)!=null&&Q.trim()),children:Ce(ko,{edgeId:e,edgeType:"SEQUENCE_EDGE",sourceNode:K,targetNode:$})})}),(p||((j=n==null?void 0:n.label)==null?void 0:j.trim()))&&Ce("div",{className:H("absolute nodrag nopan",!p&&!E&&((oe=n==null?void 0:n.label)!=null&&oe.trim())?"z-[10001] pointer-events-auto":"z-[3000] pointer-events-none"),style:{transform:`translate(-50%, -50%) translate(${B.x+((ce=(X=n==null?void 0:n.labelOffset)==null?void 0:X.x)!=null?ce:0)}px, ${B.y+((q=(ne=n==null?void 0:n.labelOffset)==null?void 0:ne.y)!=null?q:0)}px)`,cursor:!p&&!E&&((xe=n==null?void 0:n.label)!=null&&xe.trim())?"move":void 0},onMouseDown:!p&&!E?O:void 0,onDoubleClick:W=>{E||(W.stopPropagation(),h(!0))},children:Ce(Re,{value:n==null?void 0:n.label,className:H("min-w-8 max-w-56 px-2 py-1 body-small-400",{"pointer-events-auto":p,"pointer-events-none":!p}),isEditing:p,onBlur:()=>h(!1),onChange:W=>d(e,{label:W.trim()})})}),r&&!f&&!E&&Yt(Lc,{children:[Ce("div",{className:"absolute z-[10000] pointer-events-none",style:{transform:`translate(-50%, -50%) translate(${L[0].x}px, ${L[0].y}px)`},children:Yt("svg",{width:12/c,height:12/c,style:{overflow:"visible",position:"absolute",left:"50%",top:"50%",transform:"translate(-50%, -50%)"},children:[Ce("circle",{cx:6/c,cy:6/c,r:4/c,fill:I==="source"?"#3b82f6":"#fff",stroke:"#3b82f6",strokeWidth:2/c,className:"pointer-events-none"}),Ce("circle",{cx:6/c,cy:6/c,r:6/c,fill:"none",stroke:"#3b82f6",strokeWidth:1/c,opacity:I==="source"?.6:.3,className:"pointer-events-none"}),Ce("circle",{cx:6/c,cy:6/c,r:8/c,fill:"transparent",className:H("pointer-events-auto",{"cursor-move":!I||I!=="source","cursor-not-allowed":I==="source"&&M&&!C,"cursor-grabbing":I==="source"&&(!M||C)}),onMouseDown:W=>G("source",W.nativeEvent)})]})}),Ce("div",{className:"absolute z-[10000] pointer-events-none",style:{transform:`translate(-50%, -50%) translate(${L[L.length-1].x}px, ${L[L.length-1].y}px)`},children:Yt("svg",{width:12/c,height:12/c,style:{overflow:"visible",position:"absolute",left:"50%",top:"50%",transform:"translate(-50%, -50%)"},children:[Ce("circle",{cx:6/c,cy:6/c,r:4/c,fill:I==="target"?"#3b82f6":"#fff",stroke:"#3b82f6",strokeWidth:2/c,className:"pointer-events-none"}),Ce("circle",{cx:6/c,cy:6/c,r:6/c,fill:"none",stroke:"#3b82f6",strokeWidth:1/c,opacity:I==="target"?.6:.3,className:"pointer-events-none"}),Ce("circle",{cx:6/c,cy:6/c,r:8/c,fill:"transparent",className:H("pointer-events-auto",{"cursor-move":!I||I!=="target","cursor-not-allowed":I==="target"&&M&&!C,"cursor-grabbing":I==="target"&&(!M||C)}),onMouseDown:W=>G("target",W.nativeEvent)})]})})]})]})]})};import{Position as wt}from"@xyflow/react";var gh={right:wt.Right,left:wt.Left,top:wt.Top,bottom:wt.Bottom},qr=e=>{var t;return(t=gh[e!=null?e:""])!=null?t:wt.Right},ls=(e,t,o=.5)=>{var l,c,d,u;let{x:n,y:r}=e.internals.positionAbsolute,i=(c=(l=e.measured)==null?void 0:l.width)!=null?c:0,a=(u=(d=e.measured)==null?void 0:d.height)!=null?u:0;switch(qr(t)){case wt.Right:return{x:n+i,y:r+a*o};case wt.Left:return{x:n,y:r+a*o};case wt.Top:return{x:n+i*o,y:r};case wt.Bottom:return{x:n+i*o,y:r+a};default:return{x:n+i/2,y:r+a/2}}},Rc=(e,t,o)=>{var d,u;let{position:{x:n,y:r},measured:i}=e,a=(d=i.width)!=null?d:0,s=(u=i.height)!=null?u:0;return[{id:"left",x:n,y:r+s/2},{id:"right",x:n+a,y:r+s/2},{id:"top",x:n+a/2,y:r},{id:"bottom",x:n+a/2,y:r+s}].reduce((m,f)=>{let g=Math.hypot(t-m.x,o-m.y);return Math.hypot(t-f.x,o-f.y)<g?f:m}).id};import{useDebouncedCallback as c0}from"use-debounce";import{getViewportForBounds as s0,useReactFlow as a0,useStoreApi as l0}from"@xyflow/react";import{useCallback as $d}from"react";var vn=(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))(vn||{});import{xml2json as hh,json2xml as yh}from"xml-js";var Dc={compact:!0,spaces:4},xh=e=>e.replace(/\n/g,"&#xA;");function Zr(e,t=Dc){if(e)return JSON.parse(hh(e,t))}function Oc(e,t=Dc){return e?yh(e,w(_({},t),{attributeValueFn:xh})):""}var Vc={"attribute-loop":"LOOP"},Hc={"task-script":"SCRIPT","subprocess-collapsed":"SUBPROCESS"},Gc={"gateway-exclusive":"EXCLUSIVE","gateway-parallel":"PARALLEL","gateway-complex":"COMPLEX"},Bc={SCRIPT:"task-script",SUBPROCESS:"subprocess-collapsed"},zc={EXCLUSIVE:"gateway-exclusive",PARALLEL:"gateway-parallel",COMPLEX:"gateway-complex"};var Bo=(e,t,o,n,r,i)=>{let a=e._attributes.width||0,s=e._attributes.height||0,l=0,c=0;if(n&&r!==void 0&&i!==void 0){let g=n.split(`
6
+ `),b=g.length;l=g.reduce((h,y)=>Math.max(h,y.length),0)*7+r,c=b*20+i}let d=Math.max(Lt(Number(a),t),l),u=Math.max(Lt(Number(s),o),c);return{width:d,height:u,measured:{width:d,height:u}}},zo=e=>{let{_attributes:t,mxGeometry:o}=e,{id:n,parent:r,value:i}=t,a={x:Number(o._attributes.x||0),y:Number(o._attributes.y||0)},s={id:n,position:a,data:{label:i||""}},l=r==="1"?void 0:r;return l&&(s.parentId=l),s},bh=e=>{let{mxGeometry:t}=e,o=zo(e),n=Bo(t,fe.START_EVENT.MIN_WIDTH,fe.START_EVENT.MIN_HEIGHT);return w(_(_({},o),n),{type:"START_EVENT"})},_h=e=>{let{mxGeometry:t}=e,o=zo(e),n=Bo(t,fe.END_EVENT.MIN_WIDTH,fe.END_EVENT.MIN_HEIGHT);return w(_(_({},o),n),{type:"END_EVENT"})},cs=(e,t)=>{let{_attributes:o,mxGeometry:n}=e,r=zo(e),s=Bo(n,fe.TASK.MIN_WIDTH,fe.TASK.MIN_HEIGHT,r.data.label,48,24),l=t==null?void 0:t.find(d=>{let{parent:u}=d._attributes;return u===e._attributes.id});if(l){let{style:d}=l._attributes,u=Vc[d];u&&(r.data.attribute=u)}let c=Hc[o.style];return c&&(r.data.variant=c),w(_(_({},r),s),{type:"TASK"})},ds=e=>{let{_attributes:t,mxGeometry:o}=e,{style:n}=t,r=zo(e),i=Bo(o,fe.GATEWAY.MIN_WIDTH,fe.GATEWAY.MIN_HEIGHT);return r.data.variant=Gc[n],w(_(_({},r),i),{type:"GATEWAY"})},Th=e=>{let{mxGeometry:t}=e,o=zo(e),i=Bo(t,fe.ANNOTATION.MIN_WIDTH,fe.ANNOTATION.MIN_HEIGHT,o.data.label,32,24);return w(_(_({},o),i),{type:"ANNOTATION"})},Nh=e=>{let{mxGeometry:t}=e,o=zo(e),n=Bo(t,fe.LANE.MIN_WIDTH,fe.LANE.MIN_HEIGHT);return w(_(_({},o),n),{type:"LANE"})},Yc={task:cs,"task-script":cs,"subprocess-collapsed":cs,"start-event":bh,"end-event-terminate":_h,"gateway-parallel":ds,"gateway-exclusive":ds,"gateway-complex":ds,annotation:Th,lane:Nh},vh=e=>{if(e&&Array.isArray(e))return e.map(t=>({x:Number(t._attributes.x),y:Number(t._attributes.y)}))},Wc=e=>{let{_attributes:t,mxGeometry:o}=e,{id:n,source:r,target:i,value:a,style:s,sourceHandle:l,targetHandle:c,sourceOffset:d,targetOffset:u,labelOffsetX:m,labelOffsetY:f}=t,g=vh(o==null?void 0:o.Array),b=d!==void 0?Number(d):void 0,p=u!==void 0?Number(u):void 0,h=m!==void 0?Number(m):void 0,y=f!==void 0?Number(f):void 0,x=w(_(_({id:n,source:r,target:i},l?{sourceHandle:l}:{}),c?{targetHandle:c}:{}),{data:_(_(_(_({label:a||""},g&&g.length>0?{points:g}:{}),b!==void 0?{sourceOffset:b}:{}),p!==void 0?{targetOffset:p}:{}),h!==void 0&&y!==void 0?{labelOffset:{x:h,y}}:{})});return s.includes("association")&&s.includes('endArrow=""')?_(_({},Do),x):_(_({},rt),x)},Fc=(e,t)=>{var f,g;let{id:o,type:n,source:r,target:i,sourceHandle:a,targetHandle:s,data:l}=e,c=t==null?void 0:t.find(b=>b.id===r),d="";n==="ANNOTATION_EDGE"&&(d='association;endArrow=""');let u={_attributes:{as:"geometry",relative:"1"}};return l!=null&&l.points&&Array.isArray(l.points)&&l.points.length>0&&(u.Array=l.points.map(b=>({_attributes:{as:"mxPoint",x:b.x,y:b.y}}))),{_attributes:{id:o,parent:(c==null?void 0:c.parentId)||"1",edge:"1",style:d,source:r,target:i,value:(l==null?void 0:l.label)||"",sourceHandle:a!=null?a:void 0,targetHandle:s!=null?s:void 0,sourceOffset:(l==null?void 0:l.sourceOffset)!==void 0?String(l.sourceOffset):void 0,targetOffset:(l==null?void 0:l.targetOffset)!==void 0?String(l.targetOffset):void 0,labelOffsetX:((f=l==null?void 0:l.labelOffset)==null?void 0:f.x)!==void 0?String(l.labelOffset.x):void 0,labelOffsetY:((g=l==null?void 0:l.labelOffset)==null?void 0:g.y)!==void 0?String(l.labelOffset.y):void 0},mxGeometry:u}},Yo=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}}}},wh=e=>{let{variant:t}=e.data,o=Yo(e);return w(_({},o),{_attributes:w(_({},o._attributes),{style:Bc[t]||"task"})})},Ih=e=>{let t=Yo(e);return w(_({},t),{_attributes:w(_({},t._attributes),{style:"start-event"})})},Ah=e=>{let t=Yo(e);return w(_({},t),{_attributes:w(_({},t._attributes),{style:"end-event-terminate"})})},Ch=e=>{let{variant:t}=e.data,o=Yo(e);return w(_({},o),{_attributes:w(_({},o._attributes),{style:zc[t]})})},Sh=e=>{let t=Yo(e);return w(_({},t),{_attributes:w(_({},t._attributes),{style:"lane"})})},Mh=e=>{let t=Yo(e);return w(_({},t),{_attributes:w(_({},t._attributes),{style:"annotation"})})},Xc={TASK:wh,START_EVENT:Ih,END_EVENT:Ah,GATEWAY:Ch,ANNOTATION:Mh,LANE:Sh},Uc=(e,t)=>{var a,s;let r=((a=e.measured)==null?void 0:a.width)||0,i=((s=e.measured)==null?void 0:s.height)||0;return{_attributes:{id:`${t+1}`,parent:e.id,style:"attribute-loop",connectable:"0"},mxGeometry:{_attributes:{as:"geometry",x:r/2-22/2,y:i-22,width:22,height:22}}}};import $c from"@dagrejs/dagre";import{getNodesBounds as Jr}from"@xyflow/react";var qc=(e=[],t=[],o="LR")=>{let n=new $c.graphlib.Graph;return n.setDefaultEdgeLabel(()=>({})),n.setGraph({rankdir:o}),e.forEach(({id:i,width:a,height:s})=>n.setNode(i,{width:a,height:s})),t.forEach(i=>n.setEdge(i.source,i.target)),$c.layout(n),{nodes:e.map(i=>{let a=n.node(i.id);return w(_({},i),{position:{x:a.x-i.width/2,y:a.y-i.height/2}})}),edges:t}},It=e=>{let t=e.filter(n=>n.type==="LANE"&&!n.parentId);if(t.length===0)return e;let o=oa(e);for(let n of t){let r=[...o.values()],i=r.filter(s=>s.parentId===n.id);if(i.length===0)continue;let a=i.filter(s=>s.type==="LANE");if(a.length>0){la(a,o,r),ca(n,o);continue}Hi(n,i,o)}return na(e,o)},Zc=It,Jc=()=>{let e=document.querySelector(".react-flow__viewport");return e||(console.error("Flow element (.react-flow__viewport) not found."),null)};var Ph=500;var Lh=e=>e.type==="LANE"&&!e.parentId,kh=(e,t)=>{let o=e.x+e.width,n=e.y+e.height,r=t.x+t.width,i=t.y+t.height;return e.x<=t.x&&e.y<=t.y&&o>=r&&n>=i},Rh=(e,t)=>{let o=e.x+e.width,n=e.y+e.height,r=t.x+t.width,i=t.y+t.height,a=Math.max(e.x-r,t.x-o,0),s=Math.max(e.y-i,t.y-n,0);return Math.hypot(a,s)},Dh=e=>{let t=new Set;for(let o of e)t.add(o.source),t.add(o.target);return t},Kc=(e,t,o)=>{if(e.type!=="ANNOTATION"||o.has(e.id))return!1;let n=Jr([e]);return Rh(t,n)>Ph},us=(e,t=[])=>{var b;let o=e.filter(Lh);if(o.length===0)return e;let n=new Map;for(let p of e){if(!p.parentId)continue;let h=(b=n.get(p.parentId))!=null?b:[];h.push(p.id),n.set(p.parentId,h)}let r=new Set,i=o.map(p=>p.id);for(;i.length>0;){let p=i.pop();if(!p||r.has(p))continue;r.add(p);let h=n.get(p);if(h)for(let y of h)r.has(y)||i.push(y)}let a=e.filter(p=>r.has(p.id));if(a.length===0)return e;let s=Dh(t),l=a.filter(p=>p.type!=="ANNOTATION"),c=Jr(l.length>0?l:a),d=a.filter(p=>!Kc(p,c,s)),u=Jr(d),g=e.filter(p=>!r.has(p.id)).filter(p=>{let h=Jr([p]);return!kh(u,h)}).filter(p=>!Kc(p,u,s));return[...d,...g]};var wn=1,Qc=e=>`<mxGraphModel>
7
7
  <root version="1.1">
8
8
  <mxCell id="0" />
9
9
  <mxCell id="1" parent="0" />
@@ -36,16 +36,16 @@ var sp=Object.defineProperty,ap=Object.defineProperties;var lp=Object.getOwnProp
36
36
  <mxGeometry as="geometry" relative="1" />
37
37
  </mxCell>
38
38
  </root>
39
- </mxGraphModel>`,Zc=(e,t)=>{if(!e.length&&!t.length)return Nn;let o=[...e.map(r=>r.id),...t.map(r=>r.id)];return Math.max(...o.map(r=>Number(r)))};var Ph=e=>{let t=Object.values(_n),o=e.filter(i=>{var s;let a=(s=i._attributes)==null?void 0:s.style;return t.includes(a)}),n=e.filter(i=>{var s;let a=(s=i._attributes)==null?void 0:s.style;return["attribute-loop"].includes(a)}),r=[];for(let i of o){let{style:a}=i._attributes,s=Gc[a],l=s==null?void 0:s(i,n);if(!l){console.warn(`Node ${a} not supported`);continue}r.push(l)}return r},Lh=(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=Bc(r),a=t.find(c=>c.id===i.source),s=t.find(c=>c.id===i.target);((a==null?void 0:a.type)==="LANE"||(s==null?void 0:s.type)==="LANE")&&i.type!=="ANNOTATION_EDGE"||n.push(i)}return n},kh=(e,t)=>{let o=[];return e.forEach(n=>{var a,s;let r=(s=(a=Yc)[n.type])==null?void 0:s.call(a,n);if(!r){console.warn(`Node ${n.type} not supported`);return}if(o.push(r),n.type==="TASK"&&n.data.attribute==="LOOP"){let l=Wc(n,t);o.push(l)}}),o},Rh=(e,t)=>{let o=[];return e.forEach(n=>{let r=zc(n,t);o.push(r)}),o},Dh=(e=[],t=[],o)=>{let n=kh(e,o),r=Rh(t,e);return{mxGraphModel:{root:{_attributes:{version:"1.1",lastId:o},mxCell:[{_attributes:{id:"0"}},{_attributes:{id:"1",parent:"0"}},...n,...r]}}}},Jc=(e=[],t=[],o)=>{let n=Dh(e,t,o);return kc(JSON.stringify(n),{compact:!0,spaces:0})},Qc=async e=>{var c,d,p,m,u;let t=await $r(e),o=((d=(c=t==null?void 0:t.mxGraphModel)==null?void 0:c.root)==null?void 0:d.mxCell)||[],n=Number(((u=(m=(p=t==null?void 0:t.mxGraphModel)==null?void 0:p.root)==null?void 0:m._attributes)==null?void 0:u.lastId)||Nn),r=Ph(o),i=Lh(o,r),a=$c(r),{nodes:s,edges:l}=na(a,i);return{lastElementId:n,edges:l,nodes:Qt(s)}};import{Position as Ft,useConnection as xy,useReactFlow as Ey}from"@xyflow/react";import{useCallback as ps}from"react";import{Handle as jc,useReactFlow as Oh}from"@xyflow/react";import{jsx as ed}from"react/jsx-runtime";var oe=i=>{var a=i,{type:e,position:t,className:o,nodeType:n}=a,r=mt(a,["type","position","className","nodeType"]);let s=n==="TASK";return ed(jc,b({type:e,position:t,className:H("size-2.5 border border-grey-400 bg-white relative",{"before:content-[''] before:absolute before:inset-[-16px] before:bg-transparent before:pointer-events-none":s,"before:content-[''] before:absolute before:inset-[-4px] before:bg-transparent before:pointer-events-none":!s},o)},r))},He=s=>{var l=s,{nodeId:e,nodeType:t,gatewayVariant:o,type:n,position:r,className:i}=l,a=mt(l,["nodeId","nodeType","gatewayVariant","type","position","className"]);let{getEdges:c,getNodes:d}=Oh(),m=(()=>{if(n!=="source")return!1;let u=c();if(t==="TASK")return u.filter(E=>E.source===e).length>=2;if(t==="GATEWAY"&&o==="EXCLUSIVE")return u.filter(E=>E.source===e).length>=2;if(t==="START_EVENT"){let g=d();return u.filter(f=>{if(f.source!==e)return!1;let h=g.find(y=>y.id===f.target);return(h==null?void 0:h.type)!=="ANNOTATION"}).length>=1}return!1})();return ed(jc,b({type:n,position:r,className:H("size-2.5 border border-grey-400 bg-white transition-all duration-200 relative",{"before:content-[''] before:absolute before:inset-[-16px] before:bg-transparent before:pointer-events-none":t==="TASK","before:content-[''] before:absolute before:inset-[-4px] before:bg-transparent before:pointer-events-none":t!=="TASK","opacity-50 cursor-not-allowed pointer-events-none":m,"hover:border-grey-500":!m},i),style:{pointerEvents:m?"none":"auto"}},a))};import{useRef as td}from"react";import{NodeResizeControl as od,ResizeControlVariant as Hh,useReactFlow as Gh,useStoreApi as Bh}from"@xyflow/react";import{useStoreApi as Vh}from"@xyflow/react";var Kr=()=>{let e=Vh();return{getInternalNodes:()=>{let{nodeLookup:o}=e.getState();return Array.from(o.values())}}};import{Fragment as Wh,jsxs as Fh}from"react/jsx-runtime";import{createElement as nd}from"react";var zh=["top","right","bottom","left"],Yh=["top-left","top-middle","top-right","right-middle","bottom-left","left-middle","bottom-right","bottom-middle"],it=r=>{var i=r,{nodeId:e,isVisible:t,offset:o=8}=i,n=mt(i,["nodeId","isVisible","offset"]);let{getInternalNode:a,setNodes:s}=Gh(),{getInternalNodes:l}=Kr(),{isMultipleSelection:c}=$(),d=Bh(),p=td(0),m=td([]),u=({y:h,width:y,height:x})=>{cancelAnimationFrame(p.current),p.current=requestAnimationFrame(()=>{var U,Q;if(!e)return;let{nodeLookup:v,onNodesChange:N}=d.getState(),T=v.get(e);if(!T||T.type!=="LANE")return;let _=!T.parentId,I=_?T.id:T.parentId;if(!I)return;let S=Array.from(v.values()).filter(Y=>Y.type==="LANE"&&Y.parentId===I);if(!S.length)return;m.current.length===0&&(m.current=to(S).map(Y=>Y.id));let P=m.current.map(Y=>S.find(C=>C.id===Y)).filter(Boolean),R=[],M=0,B=P.findIndex(Y=>Y.id===T.id),X=!_&&B>0&&Math.abs(h-T.position.y)>.5;for(let Y=0;Y<P.length;Y++){let C=P[Y],O=C.id===T.id,D=Y===P.length-1;if(O){M=X?h+x:M+x;continue}let A=(Q=(U=C.measured)==null?void 0:U.height)!=null?Q:0,k=_?y-ie.HEADER_WIDTH:y,G=A;_&&D&&(G=Math.max(ie.MIN_HEIGHT,x-M)),X&&Y===B-1&&(G=Math.max(ie.MIN_HEIGHT,h-M)),R.push({id:C.id,type:"dimensions",dimensions:{width:k,height:G},setAttributes:!0}),R.push({id:C.id,type:"position",position:{x:ie.HEADER_WIDTH,y:M}}),M+=G}_?R.push({id:I,type:"dimensions",dimensions:{width:y,height:x},setAttributes:!0}):R.push({id:I,type:"dimensions",dimensions:{width:y+ie.HEADER_WIDTH,height:M},setAttributes:!0}),N==null||N(R)})},g=({y:h,width:y,height:x})=>{var T;if(cancelAnimationFrame(p.current),m.current=[],!e)return;let v=a(e);if(!v||v.type!=="LANE"&&!v.parentId)return;let N=[...l()];if(v.type!=="LANE"){N=N.map(_=>_.id===e?w(b({},_),{width:y,height:x,measured:{width:y,height:x}}):_),N=It(N),s(N);return}N=aa(v,y,x,N,h),N=It(N),N=eo((T=v.parentId)!=null?T:v.id,N),s(N)};if(!(!c&&t))return null;let f={"--resize-offset":`${o}px`};return Fh(Wh,{children:[zh.map(h=>nd(od,w(b({},n),{key:h,nodeId:e,position:h,variant:Hh.Line,className:"border-blue-400/90 border-dashed",style:f,onResize:(y,x)=>u(x),onResizeEnd:(y,x)=>g(x)}))),Yh.map(h=>nd(od,w(b({},n),{key:h,nodeId:e,position:h,className:"size-1.5 bg-blue-400 relative before:content-[''] before:absolute before:w-5 before:h-5 before:left-1/2 before:top-1/2 before:-translate-x-1/2 before:-translate-y-1/2 before:cursor-[inherit]",style:f,onResize:(y,x)=>u(x),onResizeEnd:(y,x)=>g(x)})))]})};import{NodeToolbar as ly,useReactFlow as cy}from"@xyflow/react";import{Button as dy,Tooltip as uy,TooltipContent as py,TooltipTrigger as fy,useTranslation as my}from"@produto-lecom/lecom-ui";import{useCallback as us,useEffect as gy,useRef as qr,useState as hy}from"react";import{create as Xh}from"zustand";var Bo=Xh(e=>({draggableNode:null,setDraggableNode:t=>{e({draggableNode:t})}}));import{useEffect as Uh,useState as $h}from"react";var rd=(e,t=!1)=>{let[o,n]=$h({width:0,height:0});return Uh(()=>{if(e.current&&t){let r=e.current.getBoundingClientRect();n({width:r.width,height:r.height})}},[t,e]),{dimensions:o}};import{Position as Tn,useReactFlow as Kh}from"@xyflow/react";import{useMemo as qh}from"react";var Zh=120,Jh=12,id=(e,t=!1,o)=>{let{getNode:n,getViewport:r}=Kh(),{instanceId:i}=$();return qh(()=>{var u,g;if(!t)return{position:Tn.Right,align:"start"};let a=n(e);if(!a)return{position:Tn.Right,align:"start"};let s=r(),l=a.position.x*s.zoom+s.x,c=(((u=a.measured)==null?void 0:u.width)||a.width||100)*s.zoom,d=(g=document.getElementById(`modeler-${i}`))==null?void 0:g.clientWidth;if(!d)return{position:Tn.Right,align:"start"};let p=(o==null?void 0:o.width)||Zh;return{position:l+c+p+Jh>d?Tn.Left:Tn.Right}},[i,e,t,o,n,r])};import{useNodesData as Qh,useReactFlow as jh}from"@xyflow/react";import{Button as sd,DropdownMenu as ey,DropdownMenuContent as ty,DropdownMenuGroup as oy,DropdownMenuItem as ny,DropdownMenuLabel as ry,DropdownMenuTrigger as iy,Tooltip as ls,TooltipContent as cs,TooltipTrigger as ds,useTranslation as sy}from"@produto-lecom/lecom-ui";import{WrenchIcon as ay}from"lucide-react";import{jsx as Re,jsxs as po}from"react/jsx-runtime";var ad=({nodeId:e})=>{let{t}=sy(),{updateNodeData:o,getEdges:n,getNode:r}=jh(),i=Qh(e),s=n().filter(u=>u.source===e).some(u=>{let g=r(u.target);return(g==null?void 0:g.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 po(ey,{children:[po(ls,{children:[Re(ds,{asChild:!0,children:Re(iy,{asChild:!0,children:Re(sd,{variant:"ghost",color:"grey",size:"small",iconButton:!0,children:Re(ay,{})})})}),Re(cs,{color:"black",children:t("bpmn.task.menu.title")})]}),po(ty,{align:"start",className:"w-60 bg-white text-grey-600",children:[po(ry,{className:"flex items-center gap-1",children:[Re("div",{className:"flex-1 body-medium-500",children:t("bpmn.task.menu.title")}),Re("div",{className:"flex items-center gap-1",children:Object.entries(Yn).map(([p,m])=>{let u=p==="LOOP"&&(s||l),E=(()=>{if(p==="LOOP"&&s)return t("editor.task_menu.loop_not_allowed_when_connected_to_end");if(p==="LOOP"&&l)return t("editor.task_menu.loop_not_allowed_when_subprocess");if(p==="LOOP")return t("editor.task_menu.loop")})();return po(ls,{children:[Re(ds,{asChild:!0,children:Re(sd,{variant:"ghost",color:"grey",size:"small",iconButton:!0,disabled:u,className:H({"bg-grey-100 text-blue-500":(i==null?void 0:i.data.attribute)===p,"opacity-50 cursor-not-allowed":u}),onClick:u?void 0:()=>d(p),children:Re(m.icon,{className:"stroke-inherit"})})}),E&&Re(cs,{color:"black",children:E})]},p)})})]}),Re(oy,{children:po(ls,{children:[Re(ds,{asChild:!0,children:Re("div",{className:H({"cursor-not-allowed":s}),children:po(ny,{className:H({"bg-grey-100 text-blue-500":(i==null?void 0:i.data.variant)==="SCRIPT","opacity-50":s}),disabled:s,onClick:()=>c("SCRIPT"),children:[Re(zn.SCRIPT.icon,{className:"stroke-current"}),t(`bpmn.task.variant.${"SCRIPT".toLowerCase()}`)]})})}),s&&Re(cs,{color:"black",children:t("editor.task_menu.script_not_allowed_when_connected_to_end")})]})})]})]})};import{jsx as Se,jsxs as ld}from"react/jsx-runtime";var At={START_EVENT:{type:"START_EVENT",icon:qo,label:"bpmn.start_event.variant.default"},END_EVENT:{type:"END_EVENT",icon:xo,label:"bpmn.end_event.variant.default"},TASK:{type:"TASK",icon:qo,label:"bpmn.task.variant.default"},ANNOTATION:{type:"ANNOTATION",icon:Vn,label:"bpmn.annotation.variant.default"}},yy={EXCLUSIVE:{type:"GATEWAY",variant:"EXCLUSIVE",icon:bo,label:"bpmn.gateway.variant.exclusive"},PARALLEL:{type:"GATEWAY",variant:"PARALLEL",icon:_o,label:"bpmn.gateway.variant.parallel"},COMPLEX:{type:"GATEWAY",variant:"COMPLEX",icon:Eo,label:"bpmn.gateway.variant.complex"}},Fe=({nodeId:e,nodeType:t,nodeVariant:o,isChild:n})=>{let r=qr(null),i=qr(null),{t:a}=my(),{setDraggableNode:s}=Bo(),{getEdges:l,getNodes:c,getNode:d}=cy(),{setIsDragging:p,mode:m,isConnecting:u,isDragging:g,isMultipleSelection:E}=$(),f=d(e),h=!!(f!=null&&f.selected)&&!f.dragging&&!u&&!g&&!E,{dimensions:y}=rd(r,h),{position:x}=id(e,h,y),[v,N]=hy(void 0),T=c(),_=l(),I=o==="SUBPROCESS",S=qr(null),P=qr(!1),R=us(()=>{S.current!==null&&(clearTimeout(S.current),S.current=null),P.current=!1,p(!1),s(null),N(void 0)},[p,s]);gy(()=>{let L=V=>{P.current&&V.buttons===0&&R()};return document.addEventListener("dragend",R),document.addEventListener("mousemove",L),()=>{document.removeEventListener("dragend",R),document.removeEventListener("mousemove",L)}},[R]);let M=us((L,V)=>{P.current=!0,p(!1),s({type:V.type,variant:V.variant,attribute:V.attribute,icon:V.icon}),V.icon&&N(Se(V.icon,{})),L.dataTransfer.effectAllowed="move",L.dataTransfer.setData("sourceId",e),i.current&&L.dataTransfer.setDragImage(i.current,10,10),S.current=setTimeout(()=>{S.current=null,p(!0)},100)},[e,s,p]),B=us(()=>{R()},[R]),X=[{component:Se(Dr,{elementId:e})}],U=()=>{if(m==="view")return[];let L=!_.some(V=>{var j;return V.source===e&&((j=T.find(Z=>Z.id===V.target))==null?void 0:j.type)!=="ANNOTATION"});return[{component:Se(So,{nodeId:e,disabled:!L,tooltipMessage:L?void 0:a("editor.toolbar.start_event_limit_reached")})},At.TASK,At.ANNOTATION,...X]},Q=()=>m==="view"?[{component:Se(zt,{elementId:e})}]:[{component:Se(zt,{elementId:e})},...I?[]:[{component:Se(ad,{nodeId:e})}],{component:Se(So,{nodeId:e})},At.TASK,{type:"TASK",variant:"SUBPROCESS",icon:Jo,label:"bpmn.task.variant.subprocess"},At.ANNOTATION,...Object.values(yy),...lo(e,T,_)?[]:[At.END_EVENT],...X],Y=()=>m==="view"?[{component:Se(zt,{elementId:e,elementType:"gateway"})}]:[{component:Se(zt,{elementId:e,elementType:"gateway"})},{component:Se(So,{nodeId:e})},At.TASK,{type:"TASK",variant:"SUBPROCESS",icon:Jo,label:"bpmn.task.variant.subprocess"},At.ANNOTATION,...X],C=()=>m==="view"?[]:[At.ANNOTATION,...X],O=()=>m==="view"?[]:[...n?[]:[{component:Se(So,{nodeId:e})}],At.ANNOTATION,...X],D=()=>m==="view"?[]:[{component:Se(So,{nodeId:e})},...X],A=()=>m==="view"?[]:[...X],G=(L=>{switch(L){case"START_EVENT":return U();case"TASK":return Q();case"GATEWAY":return Y();case"END_EVENT":return C();case"LANE":return O();case"ANNOTATION":return D();case"UNSUPPORTED":return A();default:return[]}})(t),z=G.length>6;if(!(G.length===0||m==="readonly"))return ld(ly,{position:x,align:"start",className:z?"-top-[4.5rem]":"-top-8",isVisible:h,children:[Se("div",{ref:r,className:`${z?"grid grid-cols-6":"flex"} gap-1 px-2 py-2 bg-white rounded-sm shadow-md`,children:G.map((L,V)=>{if(L.component)return Se("div",{children:L.component},V);let j={sourceNodeType:t,targetNodeType:L.type,sourceNodeId:e,nodes:T,edges:_},Z=dc(j),J={gateway_limit_reached:a("editor.toolbar.gateway_limit_reached"),start_event_limit_reached:a("editor.toolbar.start_event_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")},q=Z.shouldDisable&&Z.reason?J[Z.reason]||a(L.label):a(L.label)||"";return ld(uy,{children:[Se(fy,{asChild:!0,children:Se(dy,{variant:"ghost",color:"grey",size:"small",iconButton:!0,draggable:!Z.shouldDisable,disabled:Z.shouldDisable,className:Z.shouldDisable?"opacity-50 cursor-not-allowed":"",onDragStart:Z.shouldDisable?void 0:ee=>M(ee,L),onDragEnd:Z.shouldDisable?void 0:B,children:L.icon&&Se(L.icon,{size:16})})}),Se(py,{color:"black",children:q})]},V)})}),Se("div",{ref:i,className:"absolute w-0 h-0 top-0 left-0 z-[-1] bg-transparent",children:v})]})};import{Fragment as cd,jsx as ct,jsxs as fs}from"react/jsx-runtime";var dd=({id:e,data:t,selected:o,dragging:n})=>{let{updateNodeData:r,setNodes:i}=Ey(),{inProgress:a,fromNode:s}=xy(),{mode:l}=$(),c=a&&(s==null?void 0:s.id)!==e,d=ps(u=>{let y=u.split(`
40
- `),x=y.reduce((_,I)=>Math.max(_,I.length),0),v=y.length,N=Math.max(vo.MIN_WIDTH,x*7+32),T=Math.max(vo.MIN_HEIGHT,v*20+24);i(_=>_.map(I=>I.id===e?w(b({},I),{width:N,height:T,style:w(b({},I.style),{width:N,height:T})}):I))},[e,i]),p=ps(u=>{r(e,{label:u}),d(u)},[e,r,d]),m=ps(u=>{d(u)},[d]);return fs("div",{className:H("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:[ct(ke,{value:t.label,className:"m-1 text-grey-600 text-left",onChange:p,onInput:m,skipFirstCharValidation:!0}),ct(Fe,{nodeId:e,nodeType:"ANNOTATION"}),l==="edit"&&ct(it,{nodeId:e,minWidth:vo.MIN_WIDTH,minHeight:vo.MIN_HEIGHT,isVisible:!n&&o}),!a&&fs(cd,{children:[ct(oe,{type:"source",position:Ft.Left,id:"left"}),ct(oe,{type:"source",position:Ft.Right,id:"right"}),ct(oe,{type:"source",position:Ft.Top,id:"top"}),ct(oe,{type:"source",position:Ft.Bottom,id:"bottom"})]}),(!a||c)&&fs(cd,{children:[ct(oe,{type:"target",position:Ft.Left,id:"left",className:H({"annotation-handle":c})}),ct(oe,{type:"target",position:Ft.Right,id:"right",className:H({"annotation-handle":c})}),ct(oe,{type:"target",position:Ft.Top,id:"top",className:H({"annotation-handle":c})}),ct(oe,{type:"target",position:Ft.Bottom,id:"bottom",className:H({"annotation-handle":c})})]})]})};import{Position as Xt,useConnection as by,useReactFlow as _y}from"@xyflow/react";import{useState as Ny}from"react";import{Fragment as ud,jsx as Ze,jsxs as ms}from"react/jsx-runtime";var pd=({id:e,data:t,selected:o,dragging:n})=>{let{updateNodeData:r}=_y(),{inProgress:i,fromNode:a}=by(),{mode:s,reconnectingEdgeId:l}=$(),[c,d]=Ny(!1),p=i&&(a==null?void 0:a.id)!==e||!!l,m=E=>{r(e,{label:E})},u=()=>{d(!0)},g=()=>{d(!1)};return ms("div",{className:"relative",onDoubleClick:u,children:[Ze(xo,{className:H("w-full h-full min-w-9 min-h-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})}),Ze("div",{className:"absolute mt-2 left-1/2 -translate-x-1/2 max-w-80 w-max",children:Ze(ke,{value:t.label,isEditing:c,onBlur:g,onChange:m})}),Ze(Fe,{nodeId:e,nodeType:"END_EVENT"}),s==="edit"&&Ze(it,{nodeId:e,isVisible:!n&&o,minWidth:Xn.MIN_WIDTH,minHeight:Xn.MIN_HEIGHT,offset:4,keepAspectRatio:!0}),(!i||p)&&ms(ud,{children:[Ze(oe,{type:"target",position:Xt.Left,id:"left",className:H({"event-handle":p})}),Ze(oe,{type:"target",position:Xt.Right,id:"right",className:H({"event-handle":p})}),Ze(oe,{type:"target",position:Xt.Top,id:"top",className:H({"event-handle":p})}),Ze(oe,{type:"target",position:Xt.Bottom,id:"bottom",className:H({"event-handle":p})})]}),!i&&ms(ud,{children:[Ze(oe,{type:"source",position:Xt.Left,id:"left"}),Ze(oe,{type:"source",position:Xt.Right,id:"right"}),Ze(oe,{type:"source",position:Xt.Top,id:"top"}),Ze(oe,{type:"source",position:Xt.Bottom,id:"bottom"})]})]})};import{Position as Ut,useConnection as Ty,useReactFlow as vy}from"@xyflow/react";import{useCallback as wy,useState as Iy}from"react";import{Fragment as fd,jsx as Je,jsxs as gs}from"react/jsx-runtime";var md=({id:e,data:t,width:o,height:n,selected:r,dragging:i})=>{let a=Pi[t.variant].icon,{updateNodeData:s}=vy(),{inProgress:l,fromNode:c}=Ty(),{mode:d,reconnectingEdgeId:p}=$(),[m,u]=Iy(!1),g=l&&(c==null?void 0:c.id)!==e||!!p,E=wy(y=>{s(e,{label:y})},[e,s]),f=()=>{u(!0)},h=()=>{u(!1)};return gs("div",{className:"relative",style:{width:o!=null?o:To.MIN_WIDTH,height:n!=null?n:To.MIN_HEIGHT},onDoubleClick:f,children:[Je(a,{className:H("w-full h-full min-w-14 min-h-14 stroke-1 stroke-grey-400 hover:stroke-grey-500 transition-colors duration-75",{"stroke-blue-500 hover:stroke-blue-600":r,"stroke-red-500 hover:stroke-red-600 drop-shadow-[0_0_3px_rgba(255,0,0,0.5)]":t.hasError})}),Je("div",{className:"absolute mt-2 left-1/2 -translate-x-1/2 max-w-80 w-max",children:Je(ke,{value:t.label,isEditing:m,onBlur:h,onChange:E})}),Je(Fe,{nodeId:e,nodeType:"GATEWAY",nodeVariant:t.variant}),d==="edit"&&Je(it,{nodeId:e,isVisible:!i&&r,minWidth:To.MIN_WIDTH,minHeight:To.MIN_HEIGHT,offset:2,keepAspectRatio:!0}),(!l||g)&&gs(fd,{children:[Je(oe,{type:"target",position:Ut.Left,id:"left",className:H({"gateway-handle":g})}),Je(oe,{type:"target",position:Ut.Right,id:"right",className:H({"gateway-handle":g})}),Je(oe,{type:"target",position:Ut.Top,id:"top",className:H({"gateway-handle":g})}),Je(oe,{type:"target",position:Ut.Bottom,id:"bottom",className:H({"gateway-handle":g})})]}),!l&&gs(fd,{children:[Je(He,{type:"source",position:Ut.Left,id:"left",nodeId:e,nodeType:"GATEWAY",gatewayVariant:t.variant}),Je(He,{type:"source",position:Ut.Right,id:"right",nodeId:e,nodeType:"GATEWAY",gatewayVariant:t.variant}),Je(He,{type:"source",position:Ut.Top,id:"top",nodeId:e,nodeType:"GATEWAY",gatewayVariant:t.variant}),Je(He,{type:"source",position:Ut.Bottom,id:"bottom",nodeId:e,nodeType:"GATEWAY",gatewayVariant:t.variant})]})]})};import{useNodesData as uM,useReactFlow as pM}from"@xyflow/react";import{Button as mM,DropdownMenu as gM,DropdownMenuContent as hM,DropdownMenuGroup as yM,DropdownMenuItem as xM,DropdownMenuLabel as EM,DropdownMenuTrigger as bM,Tooltip as _M,TooltipContent as NM,TooltipTrigger as TM,useTranslation as vM}from"@produto-lecom/lecom-ui";import{WrenchIcon as IM}from"lucide-react";import{jsx as MM,jsxs as PM}from"react/jsx-runtime";import{Position as $t,useConnection as Ay,useReactFlow as Cy}from"@xyflow/react";import{useState as Sy}from"react";import{Fragment as gd,jsx as Qe,jsxs as hs}from"react/jsx-runtime";var hd=({id:e,data:t,selected:o,dragging:n})=>{let{updateNodeData:r}=Cy(),{inProgress:i,fromNode:a}=Ay(),{mode:s,reconnectingEdgeId:l}=$(),[c,d]=Sy(!1),p=i&&(a==null?void 0:a.id)!==e||!!l,m=E=>{r(e,{label:E})},u=()=>{d(!0)},g=()=>{d(!1)};return hs("div",{className:"relative",onDoubleClick:u,children:[Qe(Gn,{className:H("w-full h-full min-w-9 min-h-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})}),Qe("div",{className:"absolute mt-2 left-1/2 -translate-x-1/2 max-w-80 w-max",children:Qe(ke,{value:t.label,isEditing:c,onBlur:g,onChange:m})}),Qe(Fe,{nodeId:e,nodeType:"START_EVENT"}),s==="edit"&&Qe(it,{nodeId:e,isVisible:!n&&o,minWidth:Fn.MIN_WIDTH,minHeight:Fn.MIN_HEIGHT,offset:4,keepAspectRatio:!0}),(!i||p)&&hs(gd,{children:[Qe(oe,{type:"target",position:$t.Left,id:"left",className:H({"event-handle":p})}),Qe(oe,{type:"target",position:$t.Right,id:"right",className:H({"event-handle":p})}),Qe(oe,{type:"target",position:$t.Top,id:"top",className:H({"event-handle":p})}),Qe(oe,{type:"target",position:$t.Bottom,id:"bottom",className:H({"event-handle":p})})]}),!i&&hs(gd,{children:[Qe(He,{type:"source",position:$t.Left,id:"left",nodeId:e,nodeType:"START_EVENT"}),Qe(He,{type:"source",position:$t.Right,id:"right",nodeId:e,nodeType:"START_EVENT"}),Qe(He,{type:"source",position:$t.Top,id:"top",nodeId:e,nodeType:"START_EVENT"}),Qe(He,{type:"source",position:$t.Bottom,id:"bottom",nodeId:e,nodeType:"START_EVENT"})]})]})};import{useTranslation as Ly}from"@produto-lecom/lecom-ui";import{Position as Kt,useConnection as ky,useReactFlow as Ry}from"@xyflow/react";import{useCallback as Jr}from"react";var vn=60,Zr=(e,t)=>{var a;let o=[],n=`${t} `;for(let s of e){if(!(s.type==="TASK"))continue;let c=(a=s.data)==null?void 0:a.label;if(c&&c.startsWith(n)){let d=c.substring(n.length);/^\d{1,15}$/.test(d)&&o.push(parseInt(d,10))}}let r=o.length>0?Math.max(...o)+1:1,i=`${t} ${r}`;return i.length<=vn?i:i.substring(0,vn).trim()},zo=(e,t)=>{var s;let o=new Set;for(let l of t)l.type==="TASK"&&((s=l.data)!=null&&s.label)&&o.add(l.data.label);let n=e;if(n.length>vn&&(n=n.substring(0,vn).trim()),!o.has(n))return n;let r=n.replace(/\s+\(\d+\)$/,""),i=2,a=o.size+2;for(;i<=a;){let l=` (${i})`,c=vn-l.length,p=`${r.substring(0,c).trim()}${l}`;if(!o.has(p))return p;i++}return n};import{jsx as yd,jsxs as My}from"react/jsx-runtime";var xd=e=>My("svg",w(b({width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",xmlns:"http://www.w3.org/2000/svg"},e),{children:[yd("circle",{cx:"12",cy:"12",r:"10",fill:"#10B981"}),yd("path",{d:"M7 12L10 15L17 8",stroke:"white",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"})]}));import{jsx as Ed}from"react/jsx-runtime";var bd=e=>Ed("svg",w(b({width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",xmlns:"http://www.w3.org/2000/svg"},e),{children:Ed("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 _d,jsxs as Py}from"react/jsx-runtime";var Nd=e=>Py("svg",w(b({width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",xmlns:"http://www.w3.org/2000/svg"},e),{children:[_d("circle",{cx:"12",cy:"12",r:"10",fill:"#EF4444"}),_d("path",{d:"M8 8L16 16M8 16L16 8",stroke:"white",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"})]}));import{Fragment as Qr,jsx as Te,jsxs as wn}from"react/jsx-runtime";var Dy={APROVADO:xd,EM_ANDAMENTO:bd,REJEITADO:Nd},ys={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)]"},Td=({id:e,data:t,width:o,height:n,selected:r,dragging:i})=>{let{t:a}=Ly(),{toast:s}=We(),{updateNodeData:l,getNodes:c,setNodes:d}=Ry(),{inProgress:p,fromNode:m}=ky(),{mode:u,onSubprocessValidationClick:g,reconnectingEdgeId:E}=$(),{getTaskStatus:f}=oo(),h=p&&(m==null?void 0:m.id)!==e||!!E,y=f(e),x=t.variant==="SUBPROCESS",v=!!t.variant&&!x||!!y,N=!!t.attribute||x,T=Jr(U=>{let O=v||N?80:40,D=U.split(`
41
- `),A=D.reduce((L,V)=>Math.max(L,V.length),0),k=D.length,G=Math.max(Rt.MIN_WIDTH,A*7+64),z=Math.max(Rt.MIN_HEIGHT,k*24+O);d(L=>L.map(V=>V.id===e?w(b({},V),{width:G,height:z,style:w(b({},V.style),{width:G,height:z})}):V))},[e,d,v,N]),_=Jr(U=>{let Q=U.trim(),Y=t.label||"";if(Q===Y)return;let C=Q,O=c();if(!(Q&&Q!=="")){C=Zr(O,a("bpmn.task.label.prefix")),l(e,{label:C}),T(C),s({variant:"warning",content:wn(Qr,{children:[a("bpmn.task.feedback.label_empty.prefix")," ",Te("strong",{children:C})]})});return}let A=zo(C,O);A===Y||(l(e,{label:A}),T(A),A!==C&&s({variant:"warning",content:wn(Qr,{children:[a("bpmn.task.feedback.label_already_exists.prefix")," ",Te("strong",{children:Q})," ",a("bpmn.task.feedback.label_already_exists.middle")," ",Te("strong",{children:A})]})}))},[t.label,c,e,a,l,T,s]),I=Jr(U=>{T(U)},[T]),S=Jr(()=>{s({variant:"error",content:a("bpmn.task.feedback.invalid_first_character")})},[a,s]),P=y?Dy[y]:null,R=t.variant?zn[t.variant].icon:null,M=t.attribute?Yn[t.attribute].icon:null,B=()=>t.hasError?ys.error:y?ys[y]:ys.default,X=()=>{g==null||g({id:e,type:"sub_process",label:t.label})};return wn("div",{className:H("relative w-full h-full min-w-44 min-h-24 flex flex-col items-stretch justify-stretch bg-white border-2 border-grey-400 hover:border-grey-500 rounded-md hover:shadow-md transition-colors duration-75",B(),{"border-blue-500 hover:border-blue-600 shadow-md":r,"border-red-500 hover:border-red-600 shadow-[0_0_5px_rgba(255,0,0,0.5)]":t.hasError}),style:{width:o!=null?o:Rt.MIN_WIDTH,height:n!=null?n:Rt.MIN_HEIGHT},children:[Te("div",{className:"flex-1 flex items-stretch justify-stretch overflow-hidden",children:Te(ke,{value:t.label,maxLength:60,className:H({"py-10 px-8":v||N}),onChange:_,onInput:I,onInvalidFirstCharacter:S})}),R&&Te("div",{className:H("absolute flex items-center p-1",x?"bottom-0 left-1/2 -translate-x-1/2":"top-0 left-0"),children:Te(R,{size:16,className:H(t.hasError?"text-red-500":"text-grey-500",x&&"cursor-pointer"),onClick:x?X:void 0})}),M&&Te("div",{className:"absolute bottom-0 left-0 w-full flex items-center justify-center",children:Te("div",{className:H("flex items-center w-16 p-1",x?"justify-between":"justify-center"),children:Te(M,{size:16,className:H(t.hasError?"text-red-500":"text-grey-500")})})}),P&&Te("div",{className:"absolute top-0 right-0 flex items-center p-1",children:Te(P,{})}),Te(Fe,{nodeId:e,nodeType:"TASK",nodeVariant:t.variant}),u==="edit"&&Te(it,{nodeId:e,isVisible:!i&&r,minWidth:Rt.MIN_WIDTH,minHeight:Rt.MIN_HEIGHT}),(!p||h)&&wn(Qr,{children:[Te(oe,{type:"target",position:Kt.Left,id:"left",className:H({"task-handle":h})}),Te(oe,{type:"target",position:Kt.Right,id:"right",className:H({"task-handle":h})}),Te(oe,{type:"target",position:Kt.Top,id:"top",className:H({"task-handle":h})}),Te(oe,{type:"target",position:Kt.Bottom,id:"bottom",className:H({"task-handle":h})})]}),!p&&wn(Qr,{children:[Te(He,{type:"source",position:Kt.Left,id:"left",nodeId:e,nodeType:"TASK"}),Te(He,{type:"source",position:Kt.Right,id:"right",nodeId:e,nodeType:"TASK"}),Te(He,{type:"source",position:Kt.Top,id:"top",nodeId:e,nodeType:"TASK"}),Te(He,{type:"source",position:Kt.Bottom,id:"bottom",nodeId:e,nodeType:"TASK"})]})]})};import{Position as vd}from"@xyflow/react";import{Fragment as Oy,jsx as jr,jsxs as Vy}from"react/jsx-runtime";var wd=({id:e,data:t})=>Vy(Oy,{children:[jr("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}),jr(Fe,{nodeId:e,nodeType:"UNSUPPORTED"}),jr(oe,{type:"source",position:vd.Right}),jr(oe,{type:"target",position:vd.Left})]});import{BaseEdge as Hy,EdgeLabelRenderer as Gy,getSmoothStepPath as By,MarkerType as zy,useInternalNode as Id,useReactFlow as Yy,useViewport as Wy,Position as Yo}from"@xyflow/react";import{useState as Fy,useMemo as Xy}from"react";import{Fragment as Ad,jsx as Xe,jsxs as fo}from"react/jsx-runtime";var gP={type:"MESSAGE_EDGE",reconnectable:!0,markerEnd:{type:zy.Arrow},data:{label:""}},Cd=({id:e,source:t,target:o,data:n,selected:r,sourcePosition:i,targetPosition:a,sourceHandleId:s,targetHandleId:l})=>{var G;let{zoom:c}=Wy(),{updateEdgeData:d}=Yy(),{isMultipleSelection:p,mode:m,instanceId:u}=$(),g=m!=="edit",[E,f]=Fy(!1),{reconnectingHandle:h,cursorPosition:y,hoveredNodeId:x,reconnectingSide:v,isValidReconnection:N,handleReconnectStart:T}=Fr({edgeId:e,source:t,target:o,instanceId:u,isReadOnly:g}),_=Id(t),I=Id(o),{sx:S,sy:P,tx:R,ty:M,sourcePos:B,targetPos:X}=Xy(()=>{var ne,le;if(!_||!I)return{sx:0,sy:0,tx:0,ty:0,sourcePos:Yo.Left,targetPos:Yo.Right};let z=No(_,I),L=s?i:z.sourcePos,V=l?a:z.targetPos,j=(K,xe,W)=>{var ue,ye,ve,Oe,Ge,$e;let{x:te,y:ce}=K.internals.positionAbsolute,re=(ve=(ye=(ue=K.measured)==null?void 0:ue.width)!=null?ye:K.width)!=null?ve:0,fe=($e=(Ge=(Oe=K.measured)==null?void 0:Oe.height)!=null?Ge:K.height)!=null?$e:0;switch(xe){case Yo.Top:return{x:te+re*W,y:ce};case Yo.Bottom:return{x:te+re*W,y:ce+fe};case Yo.Left:return{x:te,y:ce+fe*W};case Yo.Right:return{x:te+re,y:ce+fe*W};default:return{x:te+re/2,y:ce+fe/2}}},Z=(ne=n==null?void 0:n.sourceOffset)!=null?ne:.5,J=(le=n==null?void 0:n.targetOffset)!=null?le:.5,q=_?j(_,L,Z).x:z.sx,ee=_?j(_,L,Z).y:z.sy,ae=I?j(I,V,J).x:z.tx,F=I?j(I,V,J).y:z.ty;return h==="source"&&y?(q=y.x,ee=y.y,v&&(L=v)):h==="target"&&y&&(ae=y.x,F=y.y,v&&(V=v)),{sx:q,sy:ee,tx:ae,ty:F,sourcePos:L,targetPos:V}},[_,I,s,l,i,a,h,y,v,n==null?void 0:n.sourceOffset,n==null?void 0:n.targetOffset]);if(!_||!I)return null;let[U,Q,Y]=By({sourceX:S,sourceY:P,targetX:R,targetY:M,sourcePosition:B,targetPosition:X}),C=r||(_==null?void 0:_.selected)||(I==null?void 0:I.selected),O=C?"sequence-edge-marker-highlighted":"sequence-edge-marker",D=E||(n==null?void 0:n.label.trim().length)>0,A=()=>{f(!1)},k=z=>{d(e,{label:z.trim()})};return Xe(Ad,{children:fo("g",{className:H("group bpmn-arrow-edge",{"is-highlighted":C}),onDoubleClick:()=>!g&&f(!0),children:[Xe("path",{d:U,fill:"none",stroke:"transparent",strokeWidth:Math.max(12,12/c),style:{pointerEvents:"stroke",cursor:"pointer"}}),fo("g",{className:H("text-grey-500 transition-colors duration-75 group-hover:text-grey-800",{"text-blue-500 group-hover:text-blue-600":C}),children:[Xe(Hy,{id:e,path:U,interactionWidth:0,markerEnd:`url(#${O})`,strokeDasharray:4,className:H("stroke-2 stroke-current transition-[stroke,filter] duration-75 group-hover:drop-shadow-[0_0_3px_rgba(0,0,0,0.2)]",{"stroke-red-500 hover:stroke-red-600":(n==null?void 0:n.hasError)||h&&x&&!N,"stroke-green-500":h&&x&&N,"stroke-blue-500 hover:stroke-blue-600 drop-shadow-[0_0_3px_rgba(59,130,246,0.5)]":C&&!(n!=null&&n.hasError)&&!h})}),fo(Gy,{children:[fo("div",{className:"absolute z-[3000] pointer-events-auto flex flex-col items-center gap-1",style:{transform:`translate(-50%, -50%) translate(${Q}px, ${Y}px)`},children:[r&&!p&&Xe(Po,{sx:S,sy:P,tx:R,ty:M,hasLabel:!!((G=n==null?void 0:n.label)!=null&&G.trim()),children:Xe(Mo,{edgeId:e,edgeType:"MESSAGE_EDGE"})}),D&&Xe(ke,{value:n==null?void 0:n.label,className:"min-w-8 max-w-56 bg-white rounded-md px-2 py-1 text-xs",isEditing:E,onBlur:A,onChange:k})]}),r&&!p&&!g&&fo(Ad,{children:[Xe("div",{className:"absolute z-[1000] pointer-events-none",style:{transform:`translate(-50%, -50%) translate(${S}px, ${P}px)`},children:fo("svg",{width:12/c,height:12/c,style:{overflow:"visible",position:"absolute",left:"50%",top:"50%",transform:"translate(-50%, -50%)"},children:[Xe("circle",{cx:6/c,cy:6/c,r:4/c,fill:h==="source"?"#3b82f6":"#fff",stroke:"#3b82f6",strokeWidth:2/c,className:"pointer-events-none"}),Xe("circle",{cx:6/c,cy:6/c,r:6/c,fill:"none",stroke:"#3b82f6",strokeWidth:1/c,opacity:h==="source"?.6:.3,className:"pointer-events-none"}),Xe("circle",{cx:6/c,cy:6/c,r:8/c,fill:"transparent",className:H("pointer-events-auto",{"cursor-move":!h||h!=="source","cursor-not-allowed":h==="source"&&x&&!N,"cursor-grabbing":h==="source"&&(!x||N)}),onMouseDown:z=>T("source",z.nativeEvent)})]})}),Xe("div",{className:"absolute z-[1000] pointer-events-none",style:{transform:`translate(-50%, -50%) translate(${R}px, ${M}px)`},children:fo("svg",{width:12/c,height:12/c,style:{overflow:"visible",position:"absolute",left:"50%",top:"50%",transform:"translate(-50%, -50%)"},children:[Xe("circle",{cx:6/c,cy:6/c,r:4/c,fill:h==="target"?"#3b82f6":"#fff",stroke:"#3b82f6",strokeWidth:2/c,className:"pointer-events-none"}),Xe("circle",{cx:6/c,cy:6/c,r:6/c,fill:"none",stroke:"#3b82f6",strokeWidth:1/c,opacity:h==="target"?.6:.3,className:"pointer-events-none"}),Xe("circle",{cx:6/c,cy:6/c,r:8/c,fill:"transparent",className:H("pointer-events-auto",{"cursor-move":!h||h!=="target","cursor-not-allowed":h==="target"&&x&&!N,"cursor-grabbing":h==="target"&&(!x||N)}),onMouseDown:z=>T("target",z.nativeEvent)})]})})]})]})]})]})})};import{getStraightPath as Uy,Position as ei}from"@xyflow/react";import{jsx as Sd,jsxs as $y}from"react/jsx-runtime";var Md=({toX:e,toY:t,fromNode:o})=>{var p,m;if(!o)return null;let{internals:{positionAbsolute:{x:n,y:r}},measured:i}=o,a=(p=i.width)!=null?p:0,s=(m=i.height)!=null?m:0,c=[{x:n,y:r+s/2,pos:ei.Left},{x:n+a,y:r+s/2,pos:ei.Right},{x:n+a/2,y:r,pos:ei.Top},{x:n+a/2,y:r+s,pos:ei.Bottom}].reduce((u,g)=>{let E=Math.hypot(e-u.x,t-u.y);return Math.hypot(e-g.x,t-g.y)<E?g:u}),[d]=Uy({sourceX:c.x,sourceY:c.y,targetX:e,targetY:t});return $y("g",{className:"group",children:[Sd("path",{fill:"none",className:"stroke-2 stroke-grey-500 animated transition-[stroke,filter] duration-75",d}),Sd("circle",{cx:e,cy:t,fill:"none",r:4,className:"stroke-2 stroke-grey-600"})]})};import{Position as qt,useConnection as Ky,useReactFlow as qy}from"@xyflow/react";import{orderBy as Zy}from"lodash";import{useMemo as Pd,useState as Jy}from"react";import{Fragment as xs,jsx as Ue,jsxs as ti}from"react/jsx-runtime";var Ld=({id:e,data:t,selected:o,dragging:n,parentId:r})=>{let{updateNodeData:i,getNodes:a}=qy(),{mode:s}=$(),{inProgress:l,fromNode:c}=Ky(),d=l&&(c==null?void 0:c.id)!==e,[p,m]=Jy(!1),u=a(),g=!r,E=Pd(()=>Zy([...u.filter(N=>N.parentId===e&&N.type==="LANE")],"position.y","asc"),[u,e]),f=g?Qs.MIN_WIDTH:ie.MIN_WIDTH,h=Pd(()=>{if(g&&E.length>1){let N=[...E];return N.pop(),N.reduce((_,I)=>{var S,P;return _+((P=(S=I.measured)==null?void 0:S.height)!=null?P:0)},0)+ie.MIN_HEIGHT}return ie.MIN_HEIGHT},[g,E]),y=N=>{i(e,{label:N})},x=()=>{m(!0)},v=()=>{m(!1)};return ti(xs,{children:[ti("div",{className:H("flex h-full min-h-64 w-full min-w-[50rem] hover:shadow-md bg-white outline outline-1 outline-grey-300",{"outline-offset-2 outline-blue-500 shadow-sm":o}),children:[Ue("div",{className:"flex align-items justify-center w-10 border-r border-grey-300",onDoubleClick:x,children:Ue("div",{className:"relative flex-1 [writing-mode:vertical-rl] [text-orientation:sideways] transform rotate-180",children:Ue(ke,{value:t.label,className:"w-full h-full self-auto",contentClassName:H({"whitespace-nowrap":p}),isEditing:p,onBlur:v,onChange:y})})}),Ue("div",{className:"flex-1"})]}),Ue(Fe,{nodeId:e,nodeType:"LANE",isChild:!g}),s==="edit"&&Ue(it,{nodeId:e,isVisible:!n&&o,minWidth:f,minHeight:h,offset:10}),!l&&ti(xs,{children:[Ue(oe,{type:"source",position:qt.Left,id:"left"}),Ue(oe,{type:"source",position:qt.Right,id:"right"}),Ue(oe,{type:"source",position:qt.Top,id:"top"}),Ue(oe,{type:"source",position:qt.Bottom,id:"bottom"})]}),(!l||d)&&ti(xs,{children:[Ue(oe,{type:"target",position:qt.Left,id:"left",className:H({"annotation-handle":d})}),Ue(oe,{type:"target",position:qt.Right,id:"right",className:H({"annotation-handle":d})}),Ue(oe,{type:"target",position:qt.Top,id:"top",className:H({"annotation-handle":d})}),Ue(oe,{type:"target",position:qt.Bottom,id:"bottom",className:H({"annotation-handle":d})})]})]})};var kd={START_EVENT:hd,END_EVENT:pd,TASK:Td,GATEWAY:md,ANNOTATION:dd,LANE:Ld,UNSUPPORTED:wd},Rd={SEQUENCE_EDGE:Mc,MESSAGE_EDGE:Cd,ANNOTATION_EDGE:mc},Dd="#fafafa",Od="#bebebe",Vd=1,Hd=10,Gd="bottom-left",Es=.05,Bd=5,Wo=.5,Fo=Es,Xo=1,zd={x:0,y:0,zoom:.75},Yd=1,Wd=2,Qy={[Yd]:4,[Wd]:2},In=[Yd,Wd],bs=In.reduce((e,t)=>e|Qy[t],0);import{useReactFlow as jy}from"@xyflow/react";var st=()=>{let{getEdges:e,getNodes:t}=jy(),{lastElementId:o}=$(),n=()=>{let i=t(),a=e(),s=Zc(i,a);return Math.max(s,o)};return{getLastId:n,getNextId:()=>n()+1}};var Uo=()=>{let{getNodes:e,getEdges:t,setNodes:o,setEdges:n,setViewport:r}=t0(),{getLastId:i}=st(),a=o0(),{setLastElementId:s}=$(),l=Fd(async(d="")=>{let{nodes:p,edges:m,lastElementId:u}=await Qc(d),{width:g,height:E}=a.getState();if(g>0&&E>0){let f=ra(p);f&&r(e0(f,g,E,Fo,Xo,Wo))}o(p),n(m),s(u)},[o,n,s,a,r]),c=Fd(()=>{let d=e(),p=t(),m=i();return Jc(d,p,m)},[e,t,i]);return{importFromMxGraph:l,exportToMxGraph:c}};import{useCallback as Xd}from"react";var r0=500,oi=()=>{let{isInitialized:e,onElementChanges:t}=$(),{exportToMxGraph:o}=Uo(),n=n0(()=>{if(!e)return;let a=o();t==null||t(a)},r0),r=Xd(a=>{a.every(c=>c.type==="select")||a.some(c=>c.type==="position"&&c.dragging)||n()},[n]),i=Xd(a=>{a.some(l=>l.type==="select")||n()},[n]);return{emitElementChanges:n,handleNodeChanges:r,handleEdgeChanges:i}};var Ud=({setEdges:e,saveHistory:t})=>{let{getNode:o,getEdges:n,getNodes:r,getInternalNode:i}=s0(),{emitElementChanges:a}=oi(),s=a0(null),{getNextId:l}=st(),c=mo(f=>{var N;let h=o(f.source),y=o(f.target);if(!h||!y)return!1;let x={sourceNodeId:h.id,targetNodeId:y.id,sourceNodeType:h.type,targetNodeType:y.type,nodes:r(),edges:n(),reconnectingEdgeId:(N=s.current)!=null?N:void 0};return Qi(x).isValid},[o,n,r]),d=mo(f=>{var x,v;let h=l(),y=i(f.source);if(y){let N=i(f.target),T=N?N.internals.positionAbsolute.x+((x=N.measured.width)!=null?x:0)/2:0,_=N?N.internals.positionAbsolute.y+((v=N.measured.height)!=null?v:0)/2:0,I=Pc(y,T,_),S=(N==null?void 0:N.type)==="ANNOTATION"||(y==null?void 0:y.type)==="ANNOTATION",P=S?Lo:rt,R;if(!S&&N&&f.targetHandle){let X=Ur(I),U=Ur(f.targetHandle),{x:Q,y:Y}=ns(y,I),{x:C,y:O}=ns(N,f.targetHandle),A=Yr(Q,Y,C,O,X,U).slice(1,-1);A.length>0&&(R=A)}let M=w(b(b({},f),P),{id:String(h),sourceHandle:I,data:b(b({},S?{}:rt.data),R?{points:R}:{})}),B=n().concat(M);e(B),t("forceSave",{nodes:r(),edges:B}),a()}},[l,e,a,i,n,r,t]),p=mo((f,h)=>{s.current=h.id},[]),m=mo(()=>{s.current=null},[]),u=mo((f,h)=>{let y=o(h.source),x=o(h.target);if(!y||!x){s.current=null;return}let v={sourceNodeId:y.id,targetNodeId:x.id,sourceNodeType:y.type,targetNodeType:x.type,nodes:r(),edges:n(),reconnectingEdgeId:f.id};if(!Qi(v).isValid){s.current=null;return}let T=i0(f,h,n()).map(_=>_.id===f.id?w(b({},_),{data:w(b({},_.data),{points:void 0})}):_);e(T),t("forceSave",{nodes:r(),edges:T}),s.current=null,a()},[o,r,n,e,a,t]),g=mo(f=>{s.current=f},[]),E=mo(()=>{s.current=null},[]);return{isValidConnection:c,onConnect:d,onReconnect:u,onReconnectStart:p,onReconnectEnd:m,setReconnectingEdge:g,clearReconnectingEdge:E}};import{useTranslation as l0}from"@produto-lecom/lecom-ui";import{useReactFlow as c0}from"@xyflow/react";import{useCallback as Mn,useRef as tu,useState as d0}from"react";var An=(e=[])=>e.filter(t=>t.type==="START_EVENT"),go=(e=[])=>e.filter(t=>t.type==="END_EVENT"),Zt=(e=[])=>e.filter(t=>t.type==="TASK")||[],$d=(e=[])=>e.filter(t=>{var o;return t.type==="TASK"&&((o=t.properties)==null?void 0:o.variant)==="SCRIPT"});var ni=(e=[])=>e.filter(t=>t.type==="GATEWAY"),Kd=(e=[])=>e.filter(t=>{var o;return t.type==="GATEWAY"&&((o=t.properties)==null?void 0:o.variant)==="EXCLUSIVE"}),je=(e,t=[])=>t.filter(o=>o.source===e),Cn=(e,t=[])=>t.filter(o=>o.target===e),qd=(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"},Zd=(e,t)=>{let o=je(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},Jd=e=>e?/[^\s]/.test(e.trim()):!1,Ee=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:[]}},Ct=(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)}},Qd=(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 Sn=[{id:"start_event_not_found",validate:e=>{let t=An(e.nodes);return Ee({isValid:t.length>=1})}},{id:"end_event_not_found",validate:e=>{let t=go(e.nodes);return Ee({isValid:t.length>=1})}},{id:"multiple_start_event_not_allowed",validate:e=>{let t=An(e.nodes),o=t.length===1;if(t.length===0)return Ee({isValid:!0});if(!o)return Ee({isValid:!1,nodeIds:t.map(i=>i.id)});let n=je(t[0].id,e.edges);if(!(n.length<=1)){let i=[...t.map(a=>a.id),...n.map(a=>a.target)];return Ee({isValid:!1,nodeIds:[...new Set(i)]})}return Ee({isValid:!0})}},{id:"task_flows_limit_exceeds",validate:e=>{let t=Zt(e.nodes),o=Ct(t,n=>je(n.id,e.edges).length<=2);return Ee({isValid:o.isValid,nodeIds:o.invalidIds})}},{id:"task_label_empty",highlightRelatedEdges:!1,validate:e=>{let t=Zt(e.nodes),o=Ct(t,n=>!!n.label&&n.label.trim()!=="");return Ee({isValid:o.isValid,nodeIds:o.invalidIds})}},{id:"task_label_length",highlightRelatedEdges:!1,validate:e=>{let o=Zt(e.nodes),n=Ct(o,r=>!r.label||r.label.length<=60);return Ee({isValid:n.isValid,nodeIds:n.invalidIds})}},{id:"duplicate_task_name",highlightRelatedEdges:!1,validate:e=>{let t=Zt(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 Ee({isValid:n.length===0,nodeIds:n})}},{id:"nested_gateway",validate:e=>{let t=ni(e.nodes),o=[],n=[];for(let r of t){let i=je(r.id,e.edges);for(let a of i){let s=e.nodes.find(l=>l.id===a.target);s&&s.type==="GATEWAY"&&(o.push(r.id,s.id),n.push(a.id))}}return Ee({isValid:o.length===0,nodeIds:o.length>0?[...new Set(o)]:[],edgeIds:n})}},{id:"events_nested",validate:e=>{let t=[...An(e.nodes),...go(e.nodes)],o=[],n=[];for(let r of t){let i=je(r.id,e.edges);for(let a of i){let s=e.nodes.find(l=>l.id===a.target);s&&(s.type==="START_EVENT"||s.type==="END_EVENT")&&(o.push(r.id,s.id),n.push(a.id))}}return Ee({isValid:o.length===0,nodeIds:o.length>0?[...new Set(o)]:[],edgeIds:n})}},{id:"flows_on_end_tasks_not_allowed",validate:e=>{let t=go(e.nodes),o=[],n=[];for(let r of t){let i=Cn(r.id,e.edges);for(let a of i){let s=e.nodes.find(l=>l.id===a.source);if(s&&s.type==="TASK"){let l=je(s.id,e.edges);l.length>1&&(o.push(s.id),l.forEach(c=>n.push(c.id)))}}}return Ee({isValid:o.length===0,nodeIds:o,edgeIds:n})}},{id:"conditions_flows_limit_exceeds",validate:e=>{let t=Kd(e.nodes),o=Ct(t,r=>je(r.id,e.edges).length<=2),n=o.invalidIds.flatMap(r=>je(r,e.edges).map(i=>i.id));return Ee({isValid:o.isValid,nodeIds:o.invalidIds,edgeIds:n})}},{id:"activity_name_invalid",validate:e=>{let t=Zt(e.nodes),o=Ct(t,n=>!n.label||Jd(n.label));return Ee({isValid:o.isValid,nodeIds:o.invalidIds})}},{id:"final_activity_has_loop",validate:e=>{var a,s;if(!((a=e==null?void 0:e.nodes)!=null&&a.length)||!((s=e==null?void 0:e.edges)!=null&&s.length))return Ee({isValid:!0});let t=go(e.nodes)[0];if(!t)return Ee({isValid:!0});let o=Cn(t.id,e.edges);if(!o.length)return Ee({isValid:!0});let r=Zt(e.nodes).filter(l=>o.some(c=>c.source===l.id)),i=Ct(r,l=>!qd(l.id,e));return Ee({isValid:i.isValid,nodeIds:i.isValid?[]:[t.id,...i.invalidIds]})}},{id:"concurrent_initial_and_final_event",validate:e=>{let t=Zt(e.nodes),o=go(e.nodes)[0];if(!o)return Ee({isValid:!0});let n=t.filter(l=>{let c=Cn(l.id,e.edges),d=je(l.id,e.edges),p=c.some(u=>{var g;return((g=e.nodes.find(E=>E.id===u.source))==null?void 0:g.type)==="START_EVENT"}),m=d.some(u=>{var g;return((g=e.nodes.find(E=>E.id===u.target))==null?void 0:g.type)==="END_EVENT"});return p&&m}),r=Cn(o.id,e.edges),i=r.length>1,a=r.map(l=>l.source),s={isValid:n.length===0&&!i,nodeIds:[...n.map(l=>l.id),...i?a:[]]};return Ee(s)}},{id:"gateway_flow_to_event",validate:e=>{let t=ni(e.nodes),o=[],n=[];for(let r of t){let i=je(r.id,e.edges);for(let a of i){let s=e.nodes.find(l=>l.id===a.target);s&&s.type==="END_EVENT"&&(o.push(r.id,s.id),n.push(a.id))}}return Ee({isValid:o.length===0,nodeIds:o.length>0?[...new Set(o)]:[],edgeIds:n})}},{id:"gateway_missing_output_streams",validate:e=>{let t=ni(e.nodes),o=Ct(t,n=>je(n.id,e.edges).length>=1);return Ee({isValid:o.isValid,nodeIds:o.invalidIds})}},{id:"event_to_condition",validate:e=>{let t=[...An(e.nodes),...go(e.nodes)],o=[],n=[];for(let r of t){let i=je(r.id,e.edges);for(let a of i){let s=e.nodes.find(l=>l.id===a.target);s&&s.type==="GATEWAY"&&(o.push(r.id,s.id),n.push(a.id))}}return Ee({isValid:o.length===0,nodeIds:o.length>0?[...new Set(o)]:[],edgeIds:n})}},{id:"script_in_final_activity",validate:e=>{let t=$d(e.nodes),o=Ct(t,n=>!Zd(n.id,e));return Ee({isValid:o.isValid,nodeIds:o.invalidIds})}}];var jd=e=>{e=e||{nodes:[],edges:[]},e.nodes=e.nodes||[],e.edges=e.edges||[];let t=[];for(let n of Sn){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}},eu=async(e,t)=>{var n;let o=[];try{let r=await e(),i=(n=r==null?void 0:r.filter(a=>a.area==="DIAGRAM"))!=null?n:[];return i.length===0?{isValid:!0,errors:[]}:(i.forEach(a=>{var l,c;let s=(c=(l=a==null?void 0:a.detail)==null?void 0:l.phases)==null?void 0:c.map(d=>d.diagramCellId);o.push({id:a.code,message:a.code,nodeIds:s,edgeIds:[]})}),{isValid:!1,errors:o})}catch(r){return{isValid:!1,errors:[{id:"cannot_validate_subprocess_reference",message:"cannot_validate_subprocess_reference",nodeIds:t.map(i=>i.id)||[],edgeIds:[]}]}}};import{jsx as ri,jsxs as u0}from"react/jsx-runtime";var ou=()=>{let{t:e}=l0(),{toast:t}=We(),{setNodes:o,setEdges:n,getNodes:r,getEdges:i}=c0(),{validateCustomDiagram:a}=$(),[s,l]=d0(!1),c=tu(!1),d=tu(!1),p=Mn(async f=>{let h=Qd(f.nodes,f.edges),y=jd(h),x=f.nodes.filter(({type:N,data:T})=>N==="TASK"&&(T==null?void 0:T.variant)==="SUBPROCESS");if(a&&x.length>0){let N=await eu(a,x);y={isValid:y.isValid&&N.isValid,errors:[...y.errors,...N.errors]}}let v=y.errors.map(N=>w(b({},N),{message:e(`validation.errors.${N.id}`)}));return s||l(!0),{isValid:y.isValid,errors:v}},[s,e,a]),m=Mn((f,h=!0)=>{if(h&&f&&t({variant:f.isValid?"success":"error",duration:5e3,title:f.isValid?e("validation.success.title"):e("validation.errors.title"),content:u0("div",{className:"flex flex-col gap-1",children:[!f.isValid&&ri("span",{className:"body-small-500",children:e("validation.errors.subtitle")}),ri("ul",{className:"list-disc list-inside max-h-40 overflow-y-auto",children:f.isValid?ri("li",{children:e("validation.success.message")}):f.errors.map(M=>ri("li",{className:"text-xs",children:M.message},M.id))})]})}),!f)return;c.current=!0,d.current=!0;let y=[],x=[];f.errors.forEach(M=>{M.nodeIds&&M.nodeIds.length>0&&M.nodeIds.forEach(B=>y.push(B)),M.edgeIds&&M.edgeIds.length>0&&M.edgeIds.forEach(B=>x.push(B))});let v=[...new Set(y)];o(M=>M.map(B=>w(b({},B),{data:w(b({},B.data),{hasError:!1})}))),n(M=>M.map(B=>w(b({},B),{data:w(b({},B.data),{hasError:!1})})));let N=r(),T=i(),_=new Set(v),I=new Set;f.errors.forEach(M=>{var U,Q;let B=Sn.find(Y=>Y.id===M.id);(B==null?void 0:B.highlightRelatedEdges)!==!1&&((U=M.edgeIds)==null||U.forEach(Y=>I.add(Y)),(Q=M.nodeIds)==null||Q.forEach(Y=>{T.forEach(C=>{(C.source===Y||C.target===Y)&&I.add(C.id)})}))});let S=new Set,P=new Set,R=new Set;N.forEach(M=>{M.type==="START_EVENT"?S.add(M.id):M.type==="END_EVENT"&&P.add(M.id)}),T.forEach(M=>{S.has(M.source)&&R.add(M.target),P.has(M.target)&&R.add(M.source)}),R.forEach(M=>{var B,X;if(_.has(M)){let U=(B=f.errors.find(Y=>{var C;return(C=Y.nodeIds)==null?void 0:C.includes(M)}))==null?void 0:B.id;((X=Sn.find(Y=>Y.id===U))==null?void 0:X.highlightRelatedEdges)!==!1&&T.forEach(Y=>{Y.source===M&&P.has(Y.target)&&(_.add(Y.target),I.add(Y.id)),Y.target===M&&S.has(Y.source)&&(_.add(Y.source),I.add(Y.id))})}}),_.size>0&&o(M=>M.map(B=>w(b({},B),{data:w(b({},B.data),{hasError:_.has(B.id)})}))),I.size>0&&n(M=>M.map(B=>w(b({},B),{data:w(b({},B.data),{hasError:I.has(B.id)})}))),setTimeout(()=>{c.current=!1},0)},[e,i,r,n,o,t]),u=Mn(()=>{l(!1),d.current=!1,o(f=>f.map(h=>w(b({},h),{data:w(b({},h.data),{hasError:!1})}))),n(f=>f.map(h=>w(b({},h),{data:w(b({},h.data),{hasError:!1})})))},[n,o]),g=Mn(()=>{d.current&&(c.current=!0,d.current=!1,o(f=>f.map(h=>w(b({},h),{data:w(b({},h.data),{hasError:!1})}))),n(f=>f.map(h=>w(b({},h),{data:w(b({},h.data),{hasError:!1})}))),setTimeout(()=>{c.current=!1},0))},[n,o]),E=Mn(()=>c.current,[]);return{validateDiagram:p,handleValidationComplete:m,clearValidation:u,dismissValidationPanel:g,isAutoValidationEnabled:s,getIsClearingValidation:E}};import{useReactFlow as p0}from"@xyflow/react";import{useTranslation as f0}from"@produto-lecom/lecom-ui";import{useEffect as m0}from"react";var g0=15,nu="bpmn:selection",h0=e=>{if(!e||!(e instanceof HTMLElement))return!1;let t=e.tagName.toLowerCase(),o=t==="input"||t==="textarea",n=e.isContentEditable,r=t==="select",i=e.closest('[contenteditable="true"], input, textarea, select')!==null;return o||n||r||i},ru=e=>{if(!h0(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},iu=({offset:e=g0,saveHistory:t})=>{let{t:o}=f0(),{getNodes:n,setNodes:r,getEdges:i,setEdges:a}=p0(),{getNextId:s}=st(),{mode:l}=$();m0(()=>{if(l!=="edit")return;let c=p=>{var y,x;if(!ru(p))return;let m=n(),u=i(),g=m.filter(v=>v.selected);if(!g.length)return;p.preventDefault(),p.stopPropagation();let E=u.filter(v=>g.some(N=>N.id===v.source)&&g.some(N=>N.id===v.target)),h=JSON.stringify({nodes:g,edges:E});(y=p.clipboardData)==null||y.setData(nu,h),(x=p.clipboardData)==null||x.setData("text/plain",`BPMN Selection: ${g.length} nodes`)},d=p=>{var I,S;if(!ru(p))return;let m=(I=p.clipboardData)==null?void 0:I.getData(nu);if(!m)return;p.preventDefault(),p.stopPropagation();let u;try{u=JSON.parse(m)}catch(P){return}if(!((S=u.nodes)!=null&&S.length))return;let g=new Map,E=n(),f=[],h=u.nodes.filter(P=>Gt(P.type,E));if(h.length===0)return;let y=s(),x=h.map(P=>{var B;let R=String(y++);g.set(P.id,R);let M=w(b({},P),{id:R,selected:!0,position:{x:P.position.x+e,y:P.position.y+e}});if(P.type==="TASK"){let X=(B=P.data)==null?void 0:B.label,U=zo(X||o("bpmn.task.label.prefix"),[...E,...f]);M.data=w(b({},P.data),{label:U})}return f.push(M),M}),v=u.edges.map(P=>w(b({},P),{id:String(y++),selected:!0,source:g.get(P.source)||P.source,target:g.get(P.target)||P.target})),N=[...E.map(P=>w(b({},P),{selected:!1})),...x],_=[...i().map(P=>w(b({},P),{selected:!1})),...v];r(N),a(_),t("forceSave",{nodes:N,edges:_})};return document.addEventListener("copy",c,!0),document.addEventListener("paste",d,!0),()=>{document.removeEventListener("copy",c,!0),document.removeEventListener("paste",d,!0)}},[n,r,i,a,s,e,o,t,l])};import{useTranslation as y0}from"@produto-lecom/lecom-ui";import{useReactFlow as x0}from"@xyflow/react";import{useState as E0}from"react";var b0=50,su=({nodes:e,setNodes:t,setEdges:o,saveHistory:n})=>{let{draggableNode:r,setDraggableNode:i}=Bo(),{t:a}=y0(),{getInternalNode:s,getNodes:l,getEdges:c,screenToFlowPosition:d}=x0(),{getNextId:p}=st(),{setIsDragging:m}=$(),{getInternalNodes:u}=Kr(),{rebuildIndex:g,forceRebuildIndex:E}=vr(),[f,h]=E0(null),y=(C,O,D)=>{var z;if(C.parentId!==O)return null;let A=D.filter(L=>L.id!==C.id&&L.parentId===O&&L.type==="LANE").sort((L,V)=>L.position.y-V.position.y);if(A.length===0)return null;let k=(z=D.find(L=>L.id===C.id))!=null?z:C,G=A.find(L=>k.position.y<L.position.y);return G?{draggedLaneId:C.id,beforeLaneId:G.id}:{draggedLaneId:C.id,afterLaneId:A[A.length-1].id}},x=(C,O=!1,D)=>{let A=O?"node-drop-target-error":"node-drop-target",k=O?"node-drop-target-lane-error":"node-drop-target-lane";t(G=>{var L;let z=(L=D==null?void 0:D(G))!=null?L:null;return G.map(V=>{let j=[];return V.id===C&&j.push(A),C!==void 0&&V.parentId===C&&V.type==="LANE"&&V.id!==(z==null?void 0:z.draggedLaneId)&&j.push(k),V.id===(z==null?void 0:z.draggedLaneId)&&j.push("lane-reorder-dragging"),V.id===(z==null?void 0:z.beforeLaneId)&&j.push("lane-reorder-before"),V.id===(z==null?void 0:z.afterLaneId)&&j.push("lane-reorder-after"),w(b({},V),{className:j.join(" ")})})})},v=(C,O)=>{let D=u();if(C.type==="LANE"){if(O){x();return}let L=D.filter(Z=>Z.id!==C.id&&Z.type==="LANE"&&!Z.parentId),V=jo(C,L);if(!V){x();return}if(jt({parentId:V.id,nodes:e,excludeTypes:["LANE"]})){x(V.id,!0);return}x(V.id,!1,Z=>y(C,V.id,Z));return}let k=D.filter(L=>L.id!==C.id&&L.type==="LANE"),G=jo(C,k);if(!G){x();return}if(jt({parentId:G.id,nodes:e,includeTypes:["LANE"]})){x();return}x(G.id)},N=C=>{let O=s(C.id),D=C.type==="LANE"&&jt({parentId:C.id,nodes:e,includeTypes:["LANE"]});v(O,D)},T=C=>C.map(O=>w(b({},O),{className:void 0})),_=C=>C.some(D=>D.dragging)?C.map(D=>D.dragging?w(b({},D),{dragging:!1}):D):C,I=(C,O)=>{let D=0;for(let A of O){if(A.id===C||A.parentId||A.type==="LANE")continue;let k=ot(A),G=k.y+k.h;D=Math.max(D,G)}return D+b0},S=(C,O)=>{if(!Li(C,O))return O;let D=I(C,O);return O.map(A=>A.id===C?w(b({},A),{position:w(b({},A.position),{y:D})}):A)},P=C=>{if(C.preventDefault(),C.dataTransfer.dropEffect="move",!(r!=null&&r.type))return;let O=d({x:C.clientX,y:C.clientY}),D={id:"__sidebar_drag__",type:r.type,position:O,measured:{width:1,height:1},internals:{positionAbsolute:O}};v(D,!1)},R=C=>{let O=C.relatedTarget;(!O||!C.currentTarget.contains(O))&&x()},M=(C,O)=>{C.preventDefault(),N(O)},B=(C,O,D)=>{var j,Z;let A=[...D],k=O.parentId?O.parentId:O.id;if(C.parentId===O.id)return A=Ri(C,O,A),A=It(A),A=eo(k,A),T(A);if(C.type==="LANE"){if(jt({parentId:O.id,nodes:A,excludeTypes:["LANE"]})){let F=_r(O),ne=50,le=50;return A.map(K=>{var xe,W;return K.id===C.id?w(b({},K),{position:{x:(xe=f==null?void 0:f.x)!=null?xe:F.x+ne,y:(W=f==null?void 0:f.y)!=null?W:F.y2+le}}):K})}let ee=A.filter(F=>F.parentId===O.id).reduce((F,ne)=>{var le,K;return F+((K=(le=ne.measured)==null?void 0:le.height)!=null?K:0)},0),ae={x:ie.HEADER_WIDTH,y:ee};return A=A.map(F=>F.id===C.id?w(b({},F),{parentId:O.id,position:ae,className:void 0}):w(b({},F),{className:void 0})),A=It(A),A=S(k,A),A}if(jt({parentId:O.id,nodes:A,includeTypes:["LANE"]})){let J;if(C.parentId){let q=s(C.parentId),{x:ee,y:ae}=ot(q);J={x:ee+((j=C.position.x)!=null?j:0),y:ae+((Z=C.position.y)!=null?Z:0)}}return A=A.map(q=>q.id===C.id?w(b({},q),{position:J!=null?J:q.position,parentId:void 0,className:void 0}):w(b({},q),{className:void 0})),A=eo(k,A),A}let L=ta(C,O);A=A.map(J=>J.id===C.id?w(b({},J),{parentId:O.id,position:L,className:void 0}):w(b({},J),{className:void 0}));let V=A.find(J=>J.id===C.id);return A=Ri(V,O,A),A=It(A),A=eo(k,A),A},X=C=>{if(C.preventDefault(),!(r!=null&&r.type))return;if(!Gt(r.type,l())){m(!1),i(null);return}let O=d({x:C.clientX,y:C.clientY}),D={width:pe[r.type].MIN_WIDTH,height:pe[r.type].MIN_HEIGHT},A=p(),k={id:String(A),type:r.type,position:O,measured:D,data:{label:r.type==="TASK"?Zr(e,a("bpmn.task.label.prefix")):"",variant:r.variant,attribute:r.attribute},selected:!0},G=w(b({},k),{internals:{positionAbsolute:O}}),z=w(b({},G),{measured:{width:1,height:1}}),L=u(),V=r.type==="LANE",j=L.filter(F=>V?F.type==="LANE"&&!F.parentId:F.type==="LANE"),Z=jo(z,j),J=[...L.map(F=>w(b({},F),{selected:!1})),G];Z&&(J=B(G,Z,J)),J=Qt(J),V&&!Z&&(J=S(G.id,J)),J=T(J),t(J),E();let q=C.dataTransfer.getData("sourceId"),ee=c(),ae=ee;if(q){let F={id:String(A+1),source:q,target:k.id},ne=r.type==="ANNOTATION"?b(b({},F),Lo):b(b({},F),rt);ae=ee.concat(ne),o(ae)}n("forceSave",{nodes:J,edges:ae}),m(!1),i(null)},U=async(C,O,D)=>{let A=[...u()],k=new Set;D.forEach(L=>{let V=s(L.id),j=L.type==="LANE",Z=A.filter(q=>q.id!==L.id&&(j?q.type==="LANE"&&!q.parentId:q.type==="LANE")),J=jo(V,Z);if(J){if(j&&jt({parentId:L.id,nodes:A,includeTypes:["LANE"]})){L.parentId&&(A=Y(L,A),k.add(L.id));return}A=B(V,J,A);return}L.parentId&&(A=Y(L,A),L.type==="LANE"&&k.add(L.id))}),A=_(A);let G=D.filter(L=>L.type==="LANE"&&!L.parentId).map(L=>L.id);for(let L of G)Li(L,A)&&f&&(A=A.map(V=>V.id===L?w(b({},V),{position:b({},f)}):V));for(let L of k)A=S(L,A);if(D.some(L=>L.type!=="LANE"&&!L.parentId)){let L=A.filter(V=>V.type==="LANE"&&!V.parentId).map(V=>V.id);for(let V of L)A=eo(V,A)}A=Qt(A),A=T(A),t(A),g(A),h(null)},Q=(C,O)=>{h({x:O.position.x,y:O.position.y})},Y=(C,O)=>{var Z,J,q,ee,ae,F,ne,le;let D=s(C.parentId);if(!D)return O;let A=C.type==="LANE",k=O.filter(K=>K.parentId===D.id&&K.id!==C.id),G=k.filter(K=>K.type==="LANE"),z;if(A&&G.length===0)z=ie.MIN_HEIGHT;else if(A){let K=(J=(Z=C.measured)==null?void 0:Z.height)!=null?J:ie.MIN_HEIGHT;z=((ee=(q=D.measured)==null?void 0:q.height)!=null?ee:ie.MIN_HEIGHT)-K,z=Math.max(ie.MIN_HEIGHT,z)}else z=k.length>0?k.reduce((K,xe)=>{var W,te;return K+((te=(W=xe.measured)==null?void 0:W.height)!=null?te:0)},0)+Ne:Math.max(ie.MIN_HEIGHT,(F=(ae=D.measured)==null?void 0:ae.height)!=null?F:0);let{x:L,y:V}=ot(D),j={x:L+((ne=C.position.x)!=null?ne:0),y:V+((le=C.position.y)!=null?le:0)};return O=O.map(K=>K.id===C.id?w(b({},K),{position:j,parentId:void 0}):K.id===D.id?w(b({},K),{height:z,measured:w(b({},K.measured),{height:z})}):K),O=It(O),O};return{onDragOver:P,onDragLeave:R,onDrop:X,onNodeDrag:M,onNodeDragStart:Q,onNodeDragStop:U}};import{useReactFlow as _0}from"@xyflow/react";import{useTranslation as N0}from"@produto-lecom/lecom-ui";import{useEffect as T0}from"react";var v0=30,w0=e=>{if(!e||!(e instanceof HTMLElement))return!1;let t=e.tagName.toLowerCase(),o=t==="input"||t==="textarea",n=e.isContentEditable,r=t==="select",i=e.closest('[contenteditable="true"], input, textarea, select')!==null;return o||n||r||i},I0=e=>!w0(e.target),au=({offset:e=v0,saveHistory:t})=>{let{t:o}=N0(),{getNodes:n,setNodes:r,getEdges:i,setEdges:a}=_0(),{getNextId:s}=st(),{mode:l}=$();T0(()=>{if(l!=="edit")return;let c=d=>{if(d.ctrlKey&&d.key.toLowerCase()==="d"&&I0(d)){d.preventDefault(),d.stopPropagation();let p=n(),m=i(),u=p.filter(_=>_.selected);if(!u.length)return;let g=new Map,E=[],f=u.filter(_=>Gt(_.type,p));if(f.length===0)return;let h=m.filter(_=>f.some(I=>I.id===_.source)&&f.some(I=>I.id===_.target)),y=s(),x=f.map(_=>{var P;let I=String(y++);g.set(_.id,I);let S=w(b({},_),{id:I,selected:!0,position:{x:_.position.x+e,y:_.position.y+e}});if(_.type==="TASK"){let R=(P=_.data)==null?void 0:P.label,M=zo(R||o("bpmn.task.label.prefix"),[...p,...E]);S.data=w(b({},_.data),{label:M})}return E.push(S),S}),v=h.map(_=>w(b({},_),{id:String(y++),selected:!0,source:g.get(_.source)||_.source,target:g.get(_.target)||_.target})),N=[...p.map(_=>w(b({},_),{selected:!1})),...x],T=[...m.map(_=>w(b({},_),{selected:!1})),...v];r(N),a(T),t("forceSave",{nodes:N,edges:T})}};return document.addEventListener("keydown",c,!0),()=>{document.removeEventListener("keydown",c,!0)}},[n,r,i,a,s,e,o,t,l])};import{useEffect as A0,useRef as lu}from"react";import{useReactFlow as C0}from"@xyflow/react";var S0=20,M0=50,Pn={UP:"ArrowUp",DOWN:"ArrowDown",LEFT:"ArrowLeft",RIGHT:"ArrowRight"},P0=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},cu=e=>{let{getNodes:t}=C0(),{mode:o,isMoveTool:n}=$(),r=lu(0),i=lu(new Map);A0(()=>{let a=s=>{if(o!=="edit"||!n||P0(s.target)||!Object.values(Pn).includes(s.key))return;let p=t().filter(y=>y.selected);if(p.length===0){i.current.clear();return}s.preventDefault();let m=Date.now(),u=m-r.current<500;r.current=m;let g=s.shiftKey?M0:S0,E=0,f=0;switch(s.key){case Pn.UP:f=-g;break;case Pn.DOWN:f=g;break;case Pn.LEFT:E=-g;break;case Pn.RIGHT:E=g;break}let h=p.map(y=>{let x=i.current.get(y.id);(!u||!x)&&(x={x:y.position.x,y:y.position.y});let v={x:x.x+E,y:x.y+f};return i.current.set(y.id,v),{id:y.id,dragging:!0,type:"position",position:v}});e&&e(h)};return window.addEventListener("keydown",a),()=>{window.removeEventListener("keydown",a)}},[t,e,o,n])};import{useReactFlow as k0}from"@xyflow/react";var uu={"start-event":"START_EVENT","end-event":"END_EVENT",task:"TASK","gateway-exclusive":"GATEWAY"},pu={"start-event":"","end-event":"",task:"","gateway-exclusive":"EXCLUSIVE"},du=(e,t)=>{if(!e){console.warn("Step not found");return}e=e.trim();let o=e.match(/(\<.*?\>)/)||[],n=e.match(/(\[.*?\])/)||[],r=e.match(/(\{.*?\})/)||[],i=e.match(/(--.*|\|.*?\|)/i)||[],a="",s="",l="";if(o.length){switch(o[1]){case"<start>":a="start-event";break;case"<end>":a="end-event";break}e=e.replace(o[1],"")}return n.length&&(a="task",s=n[1].replace(/\[|\]/g,""),e=e.replace(n[1],"")),r.length&&(a="gateway-exclusive",s=r[1].replace(/\{|\}/g,""),e=e.replace(r[1],"")),a||(a="task",s=e),i.length&&(l=i[1].replace(/(\||--)/g,""),e=e.replace(i[1],"")),e=e.trim(),t[e]||(t[e]={type:a,label:s}),{step:e,type:a,label:s,edgeLabel:l}},L0=e=>{e=e||"";let t=e.trim().split(`
42
- `),o={},n=[];return t.forEach(r=>{r=r||"";let i=r.trim().split("-->");if(i.length!==2){console.warn("Invalid number of steps");return}let a=du(i[0],o),s=du(i[1],o);a&&s&&n.push({sourceId:a.step,targetId:s.step,label:a.edgeLabel||s.edgeLabel||""})}),{components:o,connections:n}},fu=e=>{let{components:t,connections:o}=L0(e);return{nodes:t,edges:o}};var mu=()=>{let{setNodes:e,setEdges:t,fitView:o}=k0(),{getNextId:n}=st();return{importFromLia:i=>{let a=typeof i=="string"?i:i.diagramXml||"",{nodes:s,edges:l}=fu(a),c=[],d=new Map,p=!1,m=n();for(let[f,h]of Object.entries(s)){let y=String(m++),x=uu[h.type],v=pu[h.type];x==="START_EVENT"&&(p=!0),d.set(f,y);let N=pe[x].MIN_WIDTH,T=pe[x].MIN_HEIGHT;c.push({id:y,type:x,data:{label:h.label||"",variant:v,attribute:""},position:{x:0,y:0},width:N,height:T,measured:{width:N,height:T}})}let u=[];for(let f of l){let h=w(b({},rt),{id:String(m++),source:d.get(f.sourceId)||f.sourceId,target:d.get(f.targetId)||f.targetId});u.push(h)}if(!p&&c.length>0){let f=String(m++),h={id:f,type:"START_EVENT",data:{label:"",variant:"",attribute:""},position:{x:0,y:0},width:pe.START_EVENT.MIN_WIDTH,height:pe.START_EVENT.MIN_HEIGHT,measured:{width:pe.START_EVENT.MIN_WIDTH,height:pe.START_EVENT.MIN_HEIGHT}};c.unshift(h);let y=c[1];if(y){let x=w(b({},rt),{id:String(m++),source:f,target:y.id});u.unshift(x)}}let{nodes:g,edges:E}=Uc(c,u);e(g),t(E),o({padding:Wo,minZoom:Fo,maxZoom:Xo})}}};import{useEffect as R0,useCallback as D0}from"react";var O0={origin:"*",debug:!1};function gu(e,t=O0){let{origin:o,debug:n}=t,r=D0((i,a)=>{let s={event:i,data:[i,{event:i,data:a}]};window.parent.postMessage(s,o||"*")},[o]);return R0(()=>{let i=a=>{let s=a.data;if(!(s!=null&&s.event)||(s==null?void 0:s.data)===void 0)return;let{event:l,data:c}=s,d;if(Array.isArray(c)){let[,p]=c;d=p.data}else d=c;n&&(console.debug("[postMessage] received:",s),console.debug("[postMessage] eventData:",d)),l&&e[l]&&e[l](d)};return window.addEventListener("message",i),()=>window.removeEventListener("message",i)},[e,n]),{sendMessage:r}}import{useNodesInitialized as V0}from"@xyflow/react";import{useEffect as hu}from"react";var yu=()=>{let e=V0(),{initialDiagram:t,setIsInitialized:o}=$(),{importFromMxGraph:n}=Uo();hu(()=>{t&&n(t)},[t,n,o]),hu(()=>{if(!e)return;(async()=>{await Hn(),o(!0)})()},[e,o])};import{useCallback as xu}from"react";import{useReactFlow as H0}from"@xyflow/react";function Eu(){let{setTaskStatuses:e,clearTaskStatuses:t,calculateFlowPath:o}=oo(),{getEdges:n}=H0(),r=Un(),i=xu(s=>{if(!(s!=null&&s.activities))return;e(s.activities);let l=s.activities.map(d=>d.diagramId),c=n();o(c,l),setTimeout(()=>{r()},0)},[e,o,n,r]),a=xu(()=>{t(),setTimeout(()=>{r()},0)},[t,r]);return{handleTasksStatus:i,handleClearTaskStatus:a}}import{useReactFlow as G0}from"@xyflow/react";import{useCallback as St,useState as B0,useEffect as bu}from"react";import{useDebouncedCallback as z0}from"use-debounce";var Y0=500,_u=100,Nu=(e=!1)=>{let{getNodes:t,getEdges:o,setNodes:n,setEdges:r}=G0(),{mode:i}=$(),[a,s]=B0({history:[],currentStep:0}),{history:l,currentStep:c}=a,d=c>0,p=c<l.length-1,m=St((T,_)=>{n(T[_].nodes),r(T[_].edges)},[n,r]),u=St(()=>{if(c>0){let T=c-1;s(_=>w(b({},_),{currentStep:T})),m(l,T)}},[c,l,m]),g=St(()=>{if(c<l.length-1){let T=c+1;s(_=>w(b({},_),{currentStep:T})),m(l,T)}},[l,c,m]),E=St(T=>{s(_=>{let I=_.history[_.currentStep];if(I&&JSON.stringify(I)===JSON.stringify(T))return _;let R=[..._.history.slice(0,_.currentStep+1),T],M=R.length>_u?R.slice(R.length-_u):R;return{history:M,currentStep:M.length-1}})},[]),f=St((T,_)=>{let I=T.map(P=>w(b({},P),{selected:!1,className:"",data:w(b({},P.data),{hasError:!1})})),S=_.map(P=>w(b({},P),{data:w(b({},P.data),{hasError:!1})}));return{nodes:Qt(I),edges:S}},[]),h=St(()=>f(t(),o()),[t,o,f]),y=z0(()=>{let T=h();E(T)},Y0),x=St((T,_)=>{if(!e)return;if(l.length===0){let P=h();s({history:[P],currentStep:0})}if(T==="forceSave"){if(_){E(f(_.nodes,_.edges));return}y();return}T.some(P=>P.type==="select")||T.some(P=>P.type==="position"&&P.dragging)||y()},[e,y,l.length,h,E,f]);bu(()=>{if(e&&l.length===0){let T=h();s({history:[T],currentStep:0})}},[e,l.length,h]);let v=St(T=>{s({history:T||[],currentStep:0})},[]),N=St(()=>{s({history:[],currentStep:0})},[]);return bu(()=>{if(i!=="edit")return;let T=_=>{(_.ctrlKey||_.metaKey)&&(_.shiftKey&&_.key.toLowerCase()==="z"?(_.preventDefault(),g()):_.key.toLowerCase()==="z"&&(_.preventDefault(),u()))};return document.addEventListener("keydown",T),()=>{document.removeEventListener("keydown",T)}},[u,g,i]),{history:l,undo:u,redo:g,canUndo:d,canRedo:p,saveHistory:x,resetHistory:v,clearHistory:N}};var Tu=()=>{let{t:e}=W0(),[t,o,n]=X0([]),[r,i,a]=F0([]),{getNodes:s,getNode:l}=$0(),{toast:c}=We(),d=K0(),{instanceId:p,isInitialized:m,setIsConnecting:u,setIsMultipleSelection:g,onElementClick:E}=$(),{updateHelperLines:f,HelperLines:h}=vr(),{undo:y,redo:x,canUndo:v,canRedo:N,saveHistory:T}=Nu(m),{onNodeDrag:_,onDrop:I,onDragOver:S,onDragLeave:P,onNodeDragStop:R,onNodeDragStart:M}=su({nodes:t,setNodes:o,setEdges:i,saveHistory:T}),{isValidConnection:B,onConnect:X,onReconnect:U,onReconnectStart:Q,onReconnectEnd:Y,setReconnectingEdge:C,clearReconnectingEdge:O}=Ud({setEdges:i,saveHistory:T}),{handleValidationComplete:D,clearValidation:A,dismissValidationPanel:k,validateDiagram:G,getIsClearingValidation:z}=ou(),{importFromLia:L}=mu(),{handleTasksStatus:V,handleClearTaskStatus:j}=Eu(),{clearPathEdges:Z}=oo(),{emitElementChanges:J,handleNodeChanges:q,handleEdgeChanges:ee}=oi(),ae=Un();iu({saveHistory:T}),au({saveHistory:T}),yu();let F=Mt(()=>{o([]),i([]),Z(),setTimeout(ae,0)},[o,i,Z,ae]);gu({LIA_CREATE_DIAGRAM:L,CLEAR_DIAGRAM:F,TASKS_STATUS:V,CLEAR_TASKS_STATUS:j});let{selectElements:ne,clearSelection:le}=Bt(),{importFromMxGraph:K,exportToMxGraph:xe}=Uo(),{configureElement:W,getConfigureElement:te}=Lr(),ce=Mt(()=>t.length+r.length,[t,r]);q0(()=>(xt.set(p,{importFromMxGraph:K,exportToMxGraph:xe,selectElements:ne,clearSelection:le,configureElement:W,getConfigureElement:te,getElementsCount:ce,setReconnectingEdge:C,clearReconnectingEdge:O}),()=>{xt.delete(p)}),[p,K,xe,ne,le,W,te,ce,C,O]);let re=Mt((be,he)=>{if(he.type!=="TASK"&&he.type!=="GATEWAY")return;let me=te(he.id);me&&(E==null||E(me))},[te,E]),fe=Mt((be,he)=>{if(he.type!=="SEQUENCE_EDGE")return;let me=l(he.source),_e=l(he.target),{isFromStartEvent:qe,isGatewayToGateway:et,isActiviyToAndGateway:Be,isToEndEvent:ft}=Wn(me,_e);if(!(!qe&&!et&&!Be&&!ft))return;let Et=te(he.id);Et&&(E==null||E(Et))},[te,l,E]),ue=Mt(be=>{let he=f(be,t);n(he),T(be),z()||k(),q(be)},[t,n,T,z,k,f,q]),ye=Mt(be=>{a(be),T(be),z()||k(),ee(be)},[a,T,z,k,ee]);cu(ue);let ve=Mt(({nodes:be,edges:he})=>{g(be.length+he.length>=2)},[g]);U0({onChange:ve});let Oe=Mt(async({nodes:be})=>be.some(me=>me.type==="LANE"&&t.some(_e=>_e.parentId===me.id))?(c({variant:"error",title:e("validation.errors.title"),content:e("editor.toolbar.delete_pool_lane_error")}),!1):!0,[t,e,c]),Ge=()=>{T("forceSave"),J(),k()},$e=()=>{u(!0)},pt=()=>{u(!1),k()},Ke=Mt(be=>{let he=new Set(be.filter(me=>me.type==="LANE"&&!!me.parentId).map(me=>me.parentId));he.size!==0&&setTimeout(()=>{var qe,et;let me=s(),_e=new Map(me.map(Be=>[Be.id,Be]));for(let Be of he){let ft=to(me.filter(bt=>bt.type==="LANE"&&bt.parentId===Be));if(ft.length===0)continue;let Lt=0;for(let bt of ft)_e.set(bt.id,w(b({},bt),{position:{x:ie.HEADER_WIDTH,y:Lt}})),Lt+=(et=(qe=bt.measured)==null?void 0:qe.height)!=null?et:0;let Et=_e.get(Be);Et&&_e.set(Be,w(b({},Et),{height:Lt,measured:w(b({},Et.measured),{height:Lt})}))}o(me.map(Be=>{var ft;return(ft=_e.get(Be.id))!=null?ft:Be}))},0)},[s,o]);return{nodes:t,setNodes:o,edges:r,setEdges:i,events:{isValidConnection:B,onConnect:X,onReconnect:U,onReconnectStart:Q,onReconnectEnd:Y,onDrop:I,onDragOver:S,onDragLeave:P,onNodeDrag:_,onNodeDragStop:R,onNodeDragStart:M,onNodeClick:re,onEdgeClick:fe,onDropCapture:Ge,onConnectStart:$e,onConnectEnd:pt,onSelectionEnd:()=>setTimeout(()=>d.setState({nodesSelectionActive:!1}),0),onNodesChange:ue,onEdgesChange:ye,onBeforeDelete:Oe,onNodesDelete:Ke},ui:{handleCloseValidationPanel:A},controls:{undo:y,redo:x,canUndo:v,canRedo:N},components:{HelperLines:h},actions:{saveHistory:T,selectElements:ne,clearSelection:le,exportToMxGraph:xe,validateDiagram:G,handleValidationComplete:D,setReconnectingEdge:C,clearReconnectingEdge:O}}};import{useReactFlow as Z0}from"@xyflow/react";import{useCallback as J0,useEffect as Q0,useRef as j0,useState as ex}from"react";var tx=".react-flow__node, .react-flow__edge, .react-flow__node-toolbar";function vu(e,t,o){let[n,r]=ex(!1),i=j0(null),{getViewport:a,setViewport:s}=Z0(),l=J0(()=>{i.current=null,r(!1)},[]);return Q0(()=>{let c=e.current;if(!c)return;let d=u=>{if(!In.some(E=>E===u.button)||t.current||o.current||(r(!0),!(u.target instanceof Element))||!u.target.closest(tx))return;u.preventDefault(),u.stopPropagation();let g=a();i.current={pointerX:u.clientX,pointerY:u.clientY,viewportX:g.x,viewportY:g.y,zoom:g.zoom}},p=u=>{let g=i.current;if(g){if((u.buttons&bs)===0){l();return}s({x:g.viewportX+(u.clientX-g.pointerX),y:g.viewportY+(u.clientY-g.pointerY),zoom:g.zoom})}},m=u=>{(u.buttons&bs)===0&&l()};return c.addEventListener("pointerdown",d,!0),window.addEventListener("pointermove",p),window.addEventListener("pointerup",m),window.addEventListener("pointercancel",l),window.addEventListener("blur",l),()=>{c.removeEventListener("pointerdown",d,!0),window.removeEventListener("pointermove",p),window.removeEventListener("pointerup",m),window.removeEventListener("pointercancel",l),window.removeEventListener("blur",l)}},[e,t,o,a,s,l]),n}import{jsx as wu}from"react/jsx-runtime";var ii=({id:e,className:t})=>wu("marker",{id:e,className:H("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:wu("path",{d:"M 0 0 L 10 5 L 0 10 Z"})});import{jsx as si,jsxs as ox}from"react/jsx-runtime";var Iu=()=>si("svg",{style:{position:"absolute",top:0,left:0},children:ox("defs",{children:[si(ii,{id:"sequence-edge-marker",className:"text-grey-500"}),si(ii,{id:"sequence-edge-marker-hovered",className:"text-grey-800"}),si(ii,{id:"sequence-edge-marker-highlighted",className:"text-blue-500"})]})});import{Tooltip as vE,TooltipContent as wE,TooltipTrigger as IE,useTranslation as AE}from"@produto-lecom/lecom-ui";import{useKeyPress as Xu,useReactFlow as Xx}from"@xyflow/react";import{Button as fi,Tooltip as mi,TooltipContent as gi,TooltipTrigger as hi,useTranslation as Ux}from"@produto-lecom/lecom-ui";import{HandIcon as $x,ListCheckIcon as Kx,Loader2Icon as qx,MapIcon as Zx,MousePointerIcon as Jx}from"lucide-react";import{useCallback as vs,useEffect as Uu,useState as Qx}from"react";import{Tooltip as Nx,TooltipContent as Tx,TooltipTrigger as vx,useTranslation as wx}from"@produto-lecom/lecom-ui";var Ln=(x=>(x.START_EVENT="START_EVENT",x.END_EVENT="END_EVENT",x.TASK="TASK",x.SUBPROCESS="SUBPROCESS",x.GATEWAY="GATEWAY",x.LANE="LANE",x.ANNOTATION="ANNOTATION",x.CONNECTION="CONNECTION",x.INTERMEDIATE_EVENT="INTERMEDIATE_EVENT",x.ACTIVITY="ACTIVITY",x.PROCESS_INTERFACE="PROCESS_INTERFACE",x.WORKFLOW_INTERFACE="WORKFLOW_INTERFACE",x.VARIANT_ACTIVITY="VARIANT_ACTIVITY",x.AUTO_ACTIVITY="AUTO_ACTIVITY",x.DATA_STORE="DATA_STORE",x.DATA_OBJECT="DATA_OBJECT",x.DATA_OUTPUT="DATA_OUTPUT",x.DATA_INPUT="DATA_INPUT",x.MARKER="MARKER",x))(Ln||{});import{Button as mx,useTranslation as gx}from"@produto-lecom/lecom-ui";import{useReactFlow as hx}from"@xyflow/react";var Au=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 Cu({columns:e=[],rows:t=[],fileName:o="report"}){if(!e.length||!t.length)return;let r="data:text/csv;charset=utf-8,"+[e,...t].map(a=>a.join(",")).join(`
43
- `),i=encodeURI(r);ai(i,`${o}.csv`)}var ai=(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 Su(e){return e==null?void 0:e.replaceAll("&#xA;"," ")}var MR={START_EVENT:"START_EVENT",END_EVENT:"END_EVENT",TASK:"TASK",GATEWAY:"GATEWAY",ANNOTATION:"ANNOTATION"},Mu={script:"SCRIPT",subprocess:"SUBPROCESS"},Pu={"marker-loop":"LOOP"},Lu={complex:"COMPLEX",none:"EXCLUSIVE",exclusive:"EXCLUSIVE",parallel:"PARALLEL",inclusive:"EXCLUSIVE"};var ho=({cell:e,type:t,variant:o="",attribute:n=""})=>{let{_attributes:r,mxGeometry:i}=e,{value:a,parent:s}=r,l=Number(i._attributes.width),c=Number(i._attributes.height),d=s==="1"?void 0:s;return{id:r.id,parentId:d,type:t,data:{label:a||"",variant:o,attribute:n},position:{x:Number(i._attributes.x)||0,y:Number(i._attributes.y)||0},width:l,height:c,measured:{width:l,height:c}}},rx=e=>{let{subType:t,style:o}=e._attributes,n="imported";return["none"].includes(t)||(n="adapted"),e.mxGeometry._attributes.width=pe.START_EVENT.MIN_WIDTH,e.mxGeometry._attributes.height=pe.START_EVENT.MIN_HEIGHT,{node:ho({cell:e,type:"START_EVENT"}),status:n,originalType:o}},ix=e=>{let{subType:t,style:o}=e==null?void 0:e._attributes,n="imported";return["none"].includes(t)||(n="adapted"),e.mxGeometry._attributes.width=pe.END_EVENT.MIN_WIDTH,e.mxGeometry._attributes.height=pe.END_EVENT.MIN_HEIGHT,{node:ho({cell:e,type:"END_EVENT"}),status:n,originalType:o}},sx=(e,t)=>{let{id:o,subType:n,style:r}=e==null?void 0:e._attributes,i=Mu[n],a=t.get(o)||"",s=Pu[a]||"",l=s==="LOOP",c="imported";return!["script","none"].includes(n)&&!l&&(c="adapted"),e.mxGeometry._attributes.width=kt(e.mxGeometry._attributes.width||0,pe.TASK.MIN_WIDTH),e.mxGeometry._attributes.height=kt(e.mxGeometry._attributes.height||0,pe.TASK.MIN_HEIGHT),{node:ho({cell:e,type:"TASK",variant:i,attribute:s}),status:c,originalType:r}},ax=e=>{let{style:t,subType:o}=e==null?void 0:e._attributes,n=Lu[o],r=["none","inclusive","event-based"],i="imported";return r.includes(o)&&(i="adapted"),e.mxGeometry._attributes.width=pe.GATEWAY.MIN_WIDTH,e.mxGeometry._attributes.height=pe.GATEWAY.MIN_HEIGHT,{node:ho({cell:e,type:"GATEWAY",variant:n}),status:i,originalType:t}},lx=e=>{let{style:t}=e==null?void 0:e._attributes;return{node:ho({cell:e,type:"LANE"}),status:"imported",originalType:t}},cx=e=>{let{style:t}=e==null?void 0:e._attributes;return e.mxGeometry._attributes.width=kt(e.mxGeometry._attributes.width||0,pe.ANNOTATION.MIN_WIDTH),e.mxGeometry._attributes.height=kt(e.mxGeometry._attributes.height||0,pe.ANNOTATION.MIN_HEIGHT),{node:ho({cell:e,type:"ANNOTATION"}),status:"imported",originalType:t}},ku=e=>{let{style:t}=e==null?void 0:e._attributes;return e.mxGeometry._attributes.width=pe.UNSUPPORTED.MIN_WIDTH,e.mxGeometry._attributes.height=pe.UNSUPPORTED.MIN_HEIGHT,{node:ho({cell:e,type:"UNSUPPORTED"}),status:"unsupported",originalType:t}},Ru=(e,t)=>{let{id:o,source:n,target:r,value:i}=e._attributes;return w(b({},rt),{id:o,source:t.get(n)||n,target:t.get(r)||r,data:{label:i||""}})},Du={TASK:sx,GATEWAY:ax,START_EVENT:rx,END_EVENT:ix,LANE:lx,ANNOTATION:cx};var dx=e=>{let t=new Map,o=Object.values(Ln),n=[],r=new Map;e.forEach(s=>{var c;let l=(c=s._attributes)==null?void 0:c.type;if(l==="MARKER"){r.set(s._attributes.parent,s._attributes.style);return}if(o.includes(l)){n.push(s);return}});let i=[],a=[];for(let s of n){let{type:l}=s._attributes,c=Du[l]||ku,{node:d,status:p,originalType:m}=c(s,r);a.push(d),i.push({originalType:m,type:d.type,variant:d.data.variant,value:Su(d.data.label),status:p})}return{nodes:a,governanceIdToNodeIdMap:t,summary:i}},ux=(e,t)=>e.filter(r=>{var i;return(i=r._attributes)==null?void 0:i.edge}).map(r=>Ru(r,t)),px=e=>{let{mxGraphModel:t}=e,{nodes:o,governanceIdToNodeIdMap:n,summary:r}=dx(t.root.mxCell),i=ux(t.root.mxCell,n);return{nodes:o,edges:i,summary:r}},fx=async e=>{let t=await Au(e),o=$r(t);if(!o)throw new Error("EMPTY_FILE");let{metadata:n,mxGraphModel:r}=o.modeler||{},i=(n==null?void 0:n.app)&&(n==null?void 0:n.diagramType)&&(n==null?void 0:n.version),a=r==null?void 0:r.root;if(!i||!a)throw new Error("INVALID_FILE");if(!Object.keys(r.root.mxCell||{}).length)throw new Error("CONTAIN_NO_CELLS");return{metadata:n,mxGraphModel:r}},Ou=async e=>{try{let t=await fx(e),{nodes:o,edges:n,summary:r}=px(t)||{};return{nodes:o,edges:n,summary:r}}catch(t){throw t}};import{jsx as yx}from"react/jsx-runtime";var Vu=()=>{let{t:e}=gx(),{toast:t}=We(),{setNodes:o,setEdges:n,fitView:r}=hx(),i=s=>{let l=[e("adapter.governance.report.columns.type"),e("adapter.governance.report.columns.value"),e("adapter.governance.report.columns.status")],c=s.map(d=>[d.originalType,d.value,e(`adapter.governance.report.status.${d.status.toLowerCase()}`)]);t({variant:"warning",content:e("adapter.governance.success.incompatible_cells"),duration:1e3*60*1,action:yx(mx,{size:"small",variant:"ghost",onClick:()=>Cu({columns:l,rows:c,fileName:"governance-imported-cells"}),children:e("adapter.governance.action.download")})})};return{importFromGovernance:async s=>{try{let{nodes:l,edges:c,summary:d}=await Ou(s);if(o(m=>m.concat(l)),n(m=>m.concat(c)),r({padding:Wo,minZoom:Fo,maxZoom:Xo}),d.some(m=>m.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 xx}from"@produto-lecom/lecom-ui";import{useRef as Ex}from"react";import{Fragment as bx,jsx as Hu,jsxs as _x}from"react/jsx-runtime";var Gu=s=>{var l=s,{children:e,accept:t="*",multiple:o=!1,disabled:n=!1,onClick:r,onFilesSelected:i}=l,a=mt(l,["children","accept","multiple","disabled","onClick","onFilesSelected"]);let c=Ex(null),d=m=>{let u=m.target.files;u!=null&&u.length&&i(u),c.current&&(c.current.value="")};return _x(bx,{children:[Hu(xx,w(b({disabled:n,onClick:m=>{var u;(u=c.current)==null||u.click(),r==null||r(m)}},a),{children:e})),Hu("input",{type:"file",ref:c,className:"sr-only",accept:t,multiple:o,disabled:n,onChange:d})]})};import{jsx as li,jsxs as Ix}from"react/jsx-runtime";var Bu=({disabled:e=!1})=>{let{t}=wx(),{toast:o}=We(),{importFromGovernance:n}=Vu(),r=()=>{if(e){o({variant:"error",content:t("adapter.governance.error.ALREADY_INITIALIZED")});return}},i=a=>{let s=a[0];if(!s){o({variant:"error",content:t("adapter.governance.error.NO_FILE")});return}n(s)};return Ix(Nx,{children:[li(vx,{asChild:!0,children:li(Gu,{className:"[&>svg]:size-7 p-0",variant:"ghost",size:"small",color:"grey",iconButton:!0,accept:".mdr",disabled:e,onClick:r,onFilesSelected:i,children:li(Ys,{})})}),li(Tx,{color:"black",children:t("editor.controls.actions.import_governance")})]})};import{jsx as Ax}from"react/jsx-runtime";var _s=({shortcut:e})=>Ax("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 Dx,DropdownMenu as Ox,DropdownMenuContent as Vx,DropdownMenuItem as Ts,DropdownMenuTrigger as Hx,Tooltip as di,TooltipContent as ui,TooltipTrigger as pi,useTranslation as Gx}from"@produto-lecom/lecom-ui";import{FileCodeIcon as Bx,FileImageIcon as zx,FolderOutputIcon as Yx,PrinterIcon as Wx}from"lucide-react";import{useState as Fx}from"react";import{useTranslation as Cx}from"@produto-lecom/lecom-ui";import{useReactFlow as Sx}from"@xyflow/react";import{toPng as zu,toSvg as Mx}from"html-to-image";import{useState as Px}from"react";var Lx=3,Ns="diagram",ci=50,kx=96,Rx=25.4,Yu=e=>e*Rx/kx,Wu=()=>{let{t:e}=Cx(),{toast:t}=We(),{getNodes:o,getNodesBounds:n}=Sx(),{clearSelection:r}=Bt(),[i,a]=Px({png:!1,html:!1,print:!1}),s=()=>{let m=as(o()),u=n(m),g=u.width+ci*2,E=u.height+ci*2,f=ci-u.x,h=ci-u.y;return{width:g,height:E,style:{width:`${g}px`,height:`${E}px`,transform:`translate(${f}px, ${h}px)`,transformOrigin:"top left"}}},l=async(m,u)=>{a(g=>w(b({},g),{[u]:!0})),await r();try{if(as(o()).length===0){t({content:e("editor.controls.actions.export.feedback.empty"),variant:"warning"});return}let E=Kc();if(!E)throw new Error("Flow element not found");let f=s();return await m(E,f)}catch(g){console.error("Diagram export failed",g),t({content:e("editor.controls.actions.export.feedback.error"),variant:"error"})}finally{a(g=>w(b({},g),{[u]:!1}))}};return{exportAsPng:async(m=Ns)=>{await l(async(u,g)=>{let E=await zu(u,w(b({},g),{backgroundColor:"#fcfcfc",skipFonts:!0}));ai(E,`${m}.png`)},"png")},exportAsHtml:async(m=Ns)=>{await l(async(u,g)=>{let E=await Mx(u,w(b({},g),{backgroundColor:"#fcfcfc",skipFonts:!0})),f=`
39
+ </mxGraphModel>`,jc=(e,t)=>{if(!e.length&&!t.length)return wn;let o=[...e.map(r=>r.id),...t.map(r=>r.id)];return Math.max(...o.map(r=>Number(r)))};var Oh=e=>{let t=Object.values(vn),o=e.filter(i=>{var s;let a=(s=i._attributes)==null?void 0:s.style;return t.includes(a)}),n=e.filter(i=>{var s;let a=(s=i._attributes)==null?void 0:s.style;return["attribute-loop"].includes(a)}),r=[];for(let i of o){let{style:a}=i._attributes,s=Yc[a],l=s==null?void 0:s(i,n);if(!l){console.warn(`Node ${a} not supported`);continue}r.push(l)}return r},Vh=(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=Wc(r),a=t.find(c=>c.id===i.source),s=t.find(c=>c.id===i.target);((a==null?void 0:a.type)==="LANE"||(s==null?void 0:s.type)==="LANE")&&i.type!=="ANNOTATION_EDGE"||n.push(i)}return n},Hh=(e,t)=>{let o=[];return e.forEach(n=>{var a,s;let r=(s=(a=Xc)[n.type])==null?void 0:s.call(a,n);if(!r){console.warn(`Node ${n.type} not supported`);return}if(o.push(r),n.type==="TASK"&&n.data.attribute==="LOOP"){let l=Uc(n,t);o.push(l)}}),o},Gh=(e,t)=>{let o=[];return e.forEach(n=>{let r=Fc(n,t);o.push(r)}),o},Bh=(e=[],t=[],o)=>{let n=Hh(e,o),r=Gh(t,e);return{mxGraphModel:{root:{_attributes:{version:"1.1",lastId:o},mxCell:[{_attributes:{id:"0"}},{_attributes:{id:"1",parent:"0"}},...n,...r]}}}},ed=(e=[],t=[],o)=>{let n=Bh(e,t,o);return Oc(JSON.stringify(n),{compact:!0,spaces:0})},td=async e=>{var c,d,u,m,f;let t=await Zr(e),o=((d=(c=t==null?void 0:t.mxGraphModel)==null?void 0:c.root)==null?void 0:d.mxCell)||[],n=Number(((f=(m=(u=t==null?void 0:t.mxGraphModel)==null?void 0:u.root)==null?void 0:m._attributes)==null?void 0:f.lastId)||wn),r=Oh(o),i=Vh(o,r),a=Zc(r),{nodes:s,edges:l}=sa(a,i);return{lastElementId:n,edges:l,nodes:jt(s)}};import{Position as Wt,useConnection as Ny,useReactFlow as vy}from"@xyflow/react";import{useCallback as hs}from"react";import{Handle as od,useReactFlow as zh}from"@xyflow/react";import{jsx as nd}from"react/jsx-runtime";var te=i=>{var a=i,{type:e,position:t,className:o,nodeType:n}=a,r=gt(a,["type","position","className","nodeType"]);let s=n==="TASK";return nd(od,_({type:e,position:t,className:H("size-2.5 border border-grey-400 bg-white relative",{"before:content-[''] before:absolute before:inset-[-16px] before:bg-transparent before:pointer-events-none":s,"before:content-[''] before:absolute before:inset-[-4px] before:bg-transparent before:pointer-events-none":!s},o)},r))},He=s=>{var l=s,{nodeId:e,nodeType:t,gatewayVariant:o,type:n,position:r,className:i}=l,a=gt(l,["nodeId","nodeType","gatewayVariant","type","position","className"]);let{getEdges:c,getNodes:d}=zh(),m=(()=>{if(n!=="source")return!1;let f=c();if(t==="TASK")return f.filter(b=>b.source===e).length>=2;if(t==="GATEWAY"&&o==="EXCLUSIVE")return f.filter(b=>b.source===e).length>=2;if(t==="START_EVENT"){let g=d();return f.filter(p=>{if(p.source!==e)return!1;let h=g.find(y=>y.id===p.target);return(h==null?void 0:h.type)!=="ANNOTATION"}).length>=1}return!1})();return nd(od,_({type:n,position:r,className:H("size-2.5 border border-grey-400 bg-white transition-all duration-200 relative",{"before:content-[''] before:absolute before:inset-[-16px] before:bg-transparent before:pointer-events-none":t==="TASK","before:content-[''] before:absolute before:inset-[-4px] before:bg-transparent before:pointer-events-none":t!=="TASK","opacity-50 cursor-not-allowed pointer-events-none":m,"hover:border-grey-500":!m},i),style:{pointerEvents:m?"none":"auto"}},a))};import{useRef as rd}from"react";import{NodeResizeControl as id,ResizeControlVariant as Wh,useReactFlow as Fh,useStoreApi as Xh}from"@xyflow/react";import{useStoreApi as Yh}from"@xyflow/react";var Qr=()=>{let e=Yh();return{getInternalNodes:()=>{let{nodeLookup:o}=e.getState();return Array.from(o.values())}}};import{Fragment as Kh,jsxs as qh}from"react/jsx-runtime";import{createElement as sd}from"react";var Uh=["top","right","bottom","left"],$h=["top-left","top-middle","top-right","right-middle","bottom-left","left-middle","bottom-right","bottom-middle"],it=r=>{var i=r,{nodeId:e,isVisible:t,offset:o=8}=i,n=gt(i,["nodeId","isVisible","offset"]);let{getInternalNode:a,setNodes:s}=Fh(),{getInternalNodes:l}=Qr(),{isMultipleSelection:c}=Z(),d=Xh(),u=rd(0),m=rd([]),f=({y:h,width:y,height:x})=>{cancelAnimationFrame(u.current),u.current=requestAnimationFrame(()=>{var $,J;if(!e)return;let{nodeLookup:v,onNodesChange:N}=d.getState(),T=v.get(e);if(!T||T.type!=="LANE")return;let E=!T.parentId,I=E?T.id:T.parentId;if(!I)return;let P=Array.from(v.values()).filter(Y=>Y.type==="LANE"&&Y.parentId===I);if(!P.length)return;m.current.length===0&&(m.current=oo(P).map(Y=>Y.id));let M=m.current.map(Y=>P.find(S=>S.id===Y)).filter(Boolean),V=[],C=0,G=M.findIndex(Y=>Y.id===T.id),K=!E&&G>0&&Math.abs(h-T.position.y)>.5;for(let Y=0;Y<M.length;Y++){let S=M[Y],R=S.id===T.id,D=Y===M.length-1;if(R){C=K?h+x:C+x;continue}let A=(J=($=S.measured)==null?void 0:$.height)!=null?J:0,L=E?y-se.HEADER_WIDTH:y,B=A;E&&D&&(B=Math.max(se.MIN_HEIGHT,x-C)),K&&Y===G-1&&(B=Math.max(se.MIN_HEIGHT,h-C)),V.push({id:S.id,type:"dimensions",dimensions:{width:L,height:B},setAttributes:!0}),V.push({id:S.id,type:"position",position:{x:se.HEADER_WIDTH,y:C}}),C+=B}E?V.push({id:I,type:"dimensions",dimensions:{width:y,height:x},setAttributes:!0}):V.push({id:I,type:"dimensions",dimensions:{width:y+se.HEADER_WIDTH,height:C},setAttributes:!0}),N==null||N(V)})},g=({y:h,width:y,height:x})=>{var T;if(cancelAnimationFrame(u.current),m.current=[],!e)return;let v=a(e);if(!v||v.type!=="LANE"&&!v.parentId)return;let N=[...l()];if(v.type!=="LANE"){N=N.map(E=>E.id===e?w(_({},E),{width:y,height:x,measured:{width:y,height:x}}):E),N=It(N),s(N);return}N=da(v,y,x,N,h),N=It(N),N=to((T=v.parentId)!=null?T:v.id,N),s(N)};if(!(!c&&t))return null;let p={"--resize-offset":`${o}px`};return qh(Kh,{children:[Uh.map(h=>sd(id,w(_({},n),{key:h,nodeId:e,position:h,variant:Wh.Line,className:"border-blue-400/90 border-dashed",style:p,onResize:(y,x)=>f(x),onResizeEnd:(y,x)=>g(x)}))),$h.map(h=>sd(id,w(_({},n),{key:h,nodeId:e,position:h,className:"size-1.5 bg-blue-400 relative before:content-[''] before:absolute before:w-5 before:h-5 before:left-1/2 before:top-1/2 before:-translate-x-1/2 before:-translate-y-1/2 before:cursor-[inherit]",style:p,onResize:(y,x)=>f(x),onResizeEnd:(y,x)=>g(x)})))]})};import{NodeToolbar as fy,useReactFlow as my}from"@xyflow/react";import{Button as gy,Tooltip as hy,TooltipContent as yy,TooltipTrigger as xy,useTranslation as Ey}from"@produto-lecom/lecom-ui";import{useCallback as gs,useEffect as by,useRef as jr,useState as _y}from"react";import{create as Zh}from"zustand";var Wo=Zh(e=>({draggableNode:null,setDraggableNode:t=>{e({draggableNode:t})}}));import{useEffect as Jh,useState as Qh}from"react";var ad=(e,t=!1)=>{let[o,n]=Qh({width:0,height:0});return Jh(()=>{if(e.current&&t){let r=e.current.getBoundingClientRect();n({width:r.width,height:r.height})}},[t,e]),{dimensions:o}};import{Position as In,useReactFlow as jh}from"@xyflow/react";import{useMemo as ey}from"react";var ty=120,oy=12,ld=(e,t=!1,o)=>{let{getNode:n,getViewport:r}=jh(),{instanceId:i}=Z();return ey(()=>{var f,g;if(!t)return{position:In.Right,align:"start"};let a=n(e);if(!a)return{position:In.Right,align:"start"};let s=r(),l=a.position.x*s.zoom+s.x,c=(((f=a.measured)==null?void 0:f.width)||a.width||100)*s.zoom,d=(g=document.getElementById(`modeler-${i}`))==null?void 0:g.clientWidth;if(!d)return{position:In.Right,align:"start"};let u=(o==null?void 0:o.width)||ty;return{position:l+c+u+oy>d?In.Left:In.Right}},[i,e,t,o,n,r])};import{useNodesData as ny,useReactFlow as ry}from"@xyflow/react";import{Button as cd,DropdownMenu as iy,DropdownMenuContent as sy,DropdownMenuGroup as ay,DropdownMenuItem as ly,DropdownMenuLabel as cy,DropdownMenuTrigger as dy,Tooltip as ps,TooltipContent as fs,TooltipTrigger as ms,useTranslation as uy}from"@produto-lecom/lecom-ui";import{WrenchIcon as py}from"lucide-react";import{jsx as De,jsxs as fo}from"react/jsx-runtime";var dd=({nodeId:e})=>{let{t}=uy(),{updateNodeData:o,getEdges:n,getNode:r}=ry(),i=ny(e),s=n().filter(f=>f.source===e).some(f=>{let g=r(f.target);return(g==null?void 0:g.type)==="END_EVENT"}),l=(i==null?void 0:i.data.variant)==="SUBPROCESS",c=u=>{o(e,{variant:(i==null?void 0:i.data.variant)===u?"":u})},d=u=>{o(e,{attribute:(i==null?void 0:i.data.attribute)===u?"":u})};return fo(iy,{children:[fo(ps,{children:[De(ms,{asChild:!0,children:De(dy,{asChild:!0,children:De(cd,{variant:"ghost",color:"grey",size:"small",iconButton:!0,children:De(py,{})})})}),De(fs,{color:"black",children:t("bpmn.task.menu.title")})]}),fo(sy,{align:"start",className:"w-60 bg-white text-grey-600",children:[fo(cy,{className:"flex items-center gap-1",children:[De("div",{className:"flex-1 body-medium-500",children:t("bpmn.task.menu.title")}),De("div",{className:"flex items-center gap-1",children:Object.entries(Xn).map(([u,m])=>{let f=u==="LOOP"&&(s||l),b=(()=>{if(u==="LOOP"&&s)return t("editor.task_menu.loop_not_allowed_when_connected_to_end");if(u==="LOOP"&&l)return t("editor.task_menu.loop_not_allowed_when_subprocess");if(u==="LOOP")return t("editor.task_menu.loop")})();return fo(ps,{children:[De(ms,{asChild:!0,children:De(cd,{variant:"ghost",color:"grey",size:"small",iconButton:!0,disabled:f,className:H({"bg-grey-100 text-blue-500":(i==null?void 0:i.data.attribute)===u,"opacity-50 cursor-not-allowed":f}),onClick:f?void 0:()=>d(u),children:De(m.icon,{className:"stroke-inherit"})})}),b&&De(fs,{color:"black",children:b})]},u)})})]}),De(ay,{children:fo(ps,{children:[De(ms,{asChild:!0,children:De("div",{className:H({"cursor-not-allowed":s}),children:fo(ly,{className:H({"bg-grey-100 text-blue-500":(i==null?void 0:i.data.variant)==="SCRIPT","opacity-50":s}),disabled:s,onClick:()=>c("SCRIPT"),children:[De(Fn.SCRIPT.icon,{className:"stroke-current"}),t(`bpmn.task.variant.${"SCRIPT".toLowerCase()}`)]})})}),s&&De(fs,{color:"black",children:t("editor.task_menu.script_not_allowed_when_connected_to_end")})]})})]})]})};import{jsx as Se,jsxs as ud}from"react/jsx-runtime";var At={START_EVENT:{type:"START_EVENT",icon:Qo,label:"bpmn.start_event.variant.default"},END_EVENT:{type:"END_EVENT",icon:_o,label:"bpmn.end_event.variant.default"},TASK:{type:"TASK",icon:Qo,label:"bpmn.task.variant.default"},ANNOTATION:{type:"ANNOTATION",icon:Bn,label:"bpmn.annotation.variant.default"}},Ty={EXCLUSIVE:{type:"GATEWAY",variant:"EXCLUSIVE",icon:No,label:"bpmn.gateway.variant.exclusive"},PARALLEL:{type:"GATEWAY",variant:"PARALLEL",icon:vo,label:"bpmn.gateway.variant.parallel"},COMPLEX:{type:"GATEWAY",variant:"COMPLEX",icon:To,label:"bpmn.gateway.variant.complex"}},Xe=({nodeId:e,nodeType:t,nodeVariant:o,isChild:n})=>{let r=jr(null),i=jr(null),{t:a}=Ey(),{setDraggableNode:s}=Wo(),{getEdges:l,getNodes:c,getNode:d,setNodes:u}=my(),{setIsDragging:m,mode:f,isConnecting:g,isDragging:b,isMultipleSelection:p}=Z(),h=d(e),y=!!(h!=null&&h.selected)&&!h.dragging&&!g&&!b&&!p,{dimensions:x}=ad(r,y),{position:v}=ld(e,y,x),[N,T]=_y(void 0),E=c(),I=l(),P=o==="SUBPROCESS",M=jr(null),V=jr(!1),C=gs(()=>{M.current!==null&&(clearTimeout(M.current),M.current=null),V.current=!1,m(!1),s(null),T(void 0),u(k=>k.map(F=>w(_({},F),{className:void 0})))},[m,s,u]);by(()=>{let k=F=>{V.current&&F.buttons===0&&C()};return document.addEventListener("dragend",C),document.addEventListener("mousemove",k),()=>{document.removeEventListener("dragend",C),document.removeEventListener("mousemove",k)}},[C]);let G=gs((k,F)=>{V.current=!0,m(!1),s({type:F.type,variant:F.variant,attribute:F.attribute,icon:F.icon}),F.icon&&T(Se(F.icon,{})),k.dataTransfer.effectAllowed="move",k.dataTransfer.setData("sourceId",e),i.current&&k.dataTransfer.setDragImage(i.current,10,10),M.current=setTimeout(()=>{M.current=null,m(!0)},100)},[e,s,m]),K=gs(()=>{C()},[C]),$=[{component:Se(Hr,{elementId:e})}],J=()=>{if(f==="view")return[];let k=!I.some(F=>{var ee;return F.source===e&&((ee=E.find(U=>U.id===F.target))==null?void 0:ee.type)!=="ANNOTATION"});return[{component:Se(Lo,{nodeId:e,disabled:!k,tooltipMessage:k?void 0:a("editor.toolbar.start_event_limit_reached")})},At.TASK,At.ANNOTATION,...$]},Y=()=>f==="view"?[{component:Se(Bt,{elementId:e})}]:[{component:Se(Bt,{elementId:e})},...P?[]:[{component:Se(dd,{nodeId:e})}],{component:Se(Lo,{nodeId:e})},At.TASK,{type:"TASK",variant:"SUBPROCESS",icon:en,label:"bpmn.task.variant.subprocess"},At.ANNOTATION,...Object.values(Ty),...co(e,E,I)?[]:[At.END_EVENT],...$],S=()=>f==="view"?[{component:Se(Bt,{elementId:e,elementType:"gateway"})}]:[{component:Se(Bt,{elementId:e,elementType:"gateway"})},{component:Se(Lo,{nodeId:e})},At.TASK,{type:"TASK",variant:"SUBPROCESS",icon:en,label:"bpmn.task.variant.subprocess"},At.ANNOTATION,...$],R=()=>f==="view"?[]:[At.ANNOTATION,...$],D=()=>f==="view"?[]:[...n?[]:[{component:Se(Lo,{nodeId:e})}],At.ANNOTATION,...$],A=()=>f==="view"?[]:[{component:Se(Lo,{nodeId:e})},...$],L=()=>f==="view"?[]:[...$],z=(k=>{switch(k){case"START_EVENT":return J();case"TASK":return Y();case"GATEWAY":return S();case"END_EVENT":return R();case"LANE":return D();case"ANNOTATION":return A();case"UNSUPPORTED":return L();default:return[]}})(t),O=z.length>6;if(!(z.length===0||f==="readonly"))return ud(fy,{position:v,align:"start",className:O?"-top-[4.5rem]":"-top-8",isVisible:y,children:[Se("div",{ref:r,className:`${O?"grid grid-cols-6":"flex"} gap-1 px-2 py-2 bg-white rounded-sm shadow-md`,children:z.map((k,F)=>{if(k.component)return Se("div",{children:k.component},F);let ee={sourceNodeType:t,targetNodeType:k.type,sourceNodeId:e,nodes:E,edges:I},U=fc(ee),Q={gateway_limit_reached:a("editor.toolbar.gateway_limit_reached"),start_event_limit_reached:a("editor.toolbar.start_event_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")},j=U.shouldDisable&&U.reason?Q[U.reason]||a(k.label):a(k.label)||"";return ud(hy,{children:[Se(xy,{asChild:!0,children:Se(gy,{variant:"ghost",color:"grey",size:"small",iconButton:!0,draggable:!U.shouldDisable,disabled:U.shouldDisable,className:U.shouldDisable?"opacity-50 cursor-not-allowed":"",onDragStart:U.shouldDisable?void 0:oe=>G(oe,k),onDragEnd:U.shouldDisable?void 0:K,children:k.icon&&Se(k.icon,{size:16})})}),Se(yy,{color:"black",children:j})]},F)})}),Se("div",{ref:i,className:"absolute w-0 h-0 top-0 left-0 z-[-1] bg-transparent",children:N})]})};import{Fragment as pd,jsx as dt,jsxs as ys}from"react/jsx-runtime";var fd=({id:e,data:t,selected:o,dragging:n})=>{let{updateNodeData:r,setNodes:i}=vy(),{inProgress:a,fromNode:s}=Ny(),{mode:l}=Z(),c=a&&(s==null?void 0:s.id)!==e,d=hs(f=>{let y=f.split(`
40
+ `),x=y.reduce((E,I)=>Math.max(E,I.length),0),v=y.length,N=Math.max(Io.MIN_WIDTH,x*7+32),T=Math.max(Io.MIN_HEIGHT,v*20+24);i(E=>E.map(I=>I.id===e?w(_({},I),{width:N,height:T,style:w(_({},I.style),{width:N,height:T})}):I))},[e,i]),u=hs(f=>{r(e,{label:f}),d(f)},[e,r,d]),m=hs(f=>{d(f)},[d]);return ys("div",{className:H("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:[dt(Re,{value:t.label,className:"m-1 text-grey-600 text-left",onChange:u,onInput:m,skipFirstCharValidation:!0}),dt(Xe,{nodeId:e,nodeType:"ANNOTATION"}),l==="edit"&&dt(it,{nodeId:e,minWidth:Io.MIN_WIDTH,minHeight:Io.MIN_HEIGHT,isVisible:!n&&o}),!a&&ys(pd,{children:[dt(te,{type:"source",position:Wt.Left,id:"left"}),dt(te,{type:"source",position:Wt.Right,id:"right"}),dt(te,{type:"source",position:Wt.Top,id:"top"}),dt(te,{type:"source",position:Wt.Bottom,id:"bottom"})]}),(!a||c)&&ys(pd,{children:[dt(te,{type:"target",position:Wt.Left,id:"left",className:H({"annotation-handle":c})}),dt(te,{type:"target",position:Wt.Right,id:"right",className:H({"annotation-handle":c})}),dt(te,{type:"target",position:Wt.Top,id:"top",className:H({"annotation-handle":c})}),dt(te,{type:"target",position:Wt.Bottom,id:"bottom",className:H({"annotation-handle":c})})]})]})};import{Position as Ft,useConnection as wy,useReactFlow as Iy}from"@xyflow/react";import{useState as Ay}from"react";import{Fragment as md,jsx as Ze,jsxs as xs}from"react/jsx-runtime";var gd=({id:e,data:t,selected:o,dragging:n})=>{let{updateNodeData:r}=Iy(),{inProgress:i,fromNode:a}=wy(),{mode:s,reconnectingEdgeId:l}=Z(),[c,d]=Ay(!1),u=i&&(a==null?void 0:a.id)!==e||!!l,m=b=>{r(e,{label:b})},f=()=>{d(!0)},g=()=>{d(!1)};return xs("div",{className:"relative",onDoubleClick:f,children:[Ze(_o,{className:H("w-full h-full min-w-9 min-h-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})}),Ze("div",{className:"absolute mt-2 left-1/2 -translate-x-1/2 max-w-80 w-max",children:Ze(Re,{value:t.label,isEditing:c,onBlur:g,onChange:m})}),Ze(Xe,{nodeId:e,nodeType:"END_EVENT"}),s==="edit"&&Ze(it,{nodeId:e,isVisible:!n&&o,minWidth:$n.MIN_WIDTH,minHeight:$n.MIN_HEIGHT,offset:4,keepAspectRatio:!0}),(!i||u)&&xs(md,{children:[Ze(te,{type:"target",position:Ft.Left,id:"left",className:H({"event-handle":u})}),Ze(te,{type:"target",position:Ft.Right,id:"right",className:H({"event-handle":u})}),Ze(te,{type:"target",position:Ft.Top,id:"top",className:H({"event-handle":u})}),Ze(te,{type:"target",position:Ft.Bottom,id:"bottom",className:H({"event-handle":u})})]}),!i&&xs(md,{children:[Ze(te,{type:"source",position:Ft.Left,id:"left"}),Ze(te,{type:"source",position:Ft.Right,id:"right"}),Ze(te,{type:"source",position:Ft.Top,id:"top"}),Ze(te,{type:"source",position:Ft.Bottom,id:"bottom"})]})]})};import{Position as Xt,useConnection as Cy,useReactFlow as Sy}from"@xyflow/react";import{useCallback as My,useState as Py}from"react";import{Fragment as hd,jsx as Je,jsxs as Es}from"react/jsx-runtime";var yd=({id:e,data:t,width:o,height:n,selected:r,dragging:i})=>{let a=Oi[t.variant].icon,{updateNodeData:s}=Sy(),{inProgress:l,fromNode:c}=Cy(),{mode:d,reconnectingEdgeId:u}=Z(),[m,f]=Py(!1),g=l&&(c==null?void 0:c.id)!==e||!!u,b=My(y=>{s(e,{label:y})},[e,s]),p=()=>{f(!0)},h=()=>{f(!1)};return Es("div",{className:"relative",style:{width:o!=null?o:wo.MIN_WIDTH,height:n!=null?n:wo.MIN_HEIGHT},onDoubleClick:p,children:[Je(a,{className:H("w-full h-full min-w-14 min-h-14 stroke-1 stroke-grey-400 hover:stroke-grey-500 transition-colors duration-75",{"stroke-blue-500 hover:stroke-blue-600":r,"stroke-red-500 hover:stroke-red-600 drop-shadow-[0_0_3px_rgba(255,0,0,0.5)]":t.hasError})}),Je("div",{className:"absolute mt-2 left-1/2 -translate-x-1/2 max-w-80 w-max",children:Je(Re,{value:t.label,isEditing:m,onBlur:h,onChange:b})}),Je(Xe,{nodeId:e,nodeType:"GATEWAY",nodeVariant:t.variant}),d==="edit"&&Je(it,{nodeId:e,isVisible:!i&&r,minWidth:wo.MIN_WIDTH,minHeight:wo.MIN_HEIGHT,offset:2,keepAspectRatio:!0}),(!l||g)&&Es(hd,{children:[Je(te,{type:"target",position:Xt.Left,id:"left",className:H({"gateway-handle":g})}),Je(te,{type:"target",position:Xt.Right,id:"right",className:H({"gateway-handle":g})}),Je(te,{type:"target",position:Xt.Top,id:"top",className:H({"gateway-handle":g})}),Je(te,{type:"target",position:Xt.Bottom,id:"bottom",className:H({"gateway-handle":g})})]}),!l&&Es(hd,{children:[Je(He,{type:"source",position:Xt.Left,id:"left",nodeId:e,nodeType:"GATEWAY",gatewayVariant:t.variant}),Je(He,{type:"source",position:Xt.Right,id:"right",nodeId:e,nodeType:"GATEWAY",gatewayVariant:t.variant}),Je(He,{type:"source",position:Xt.Top,id:"top",nodeId:e,nodeType:"GATEWAY",gatewayVariant:t.variant}),Je(He,{type:"source",position:Xt.Bottom,id:"bottom",nodeId:e,nodeType:"GATEWAY",gatewayVariant:t.variant})]})]})};import{useNodesData as _M,useReactFlow as TM}from"@xyflow/react";import{Button as vM,DropdownMenu as wM,DropdownMenuContent as IM,DropdownMenuGroup as AM,DropdownMenuItem as CM,DropdownMenuLabel as SM,DropdownMenuTrigger as MM,Tooltip as PM,TooltipContent as LM,TooltipTrigger as kM,useTranslation as RM}from"@produto-lecom/lecom-ui";import{WrenchIcon as OM}from"lucide-react";import{jsx as BM,jsxs as zM}from"react/jsx-runtime";import{Position as Ut,useConnection as Ly,useReactFlow as ky}from"@xyflow/react";import{useState as Ry}from"react";import{Fragment as xd,jsx as Qe,jsxs as bs}from"react/jsx-runtime";var Ed=({id:e,data:t,selected:o,dragging:n})=>{let{updateNodeData:r}=ky(),{inProgress:i,fromNode:a}=Ly(),{mode:s,reconnectingEdgeId:l}=Z(),[c,d]=Ry(!1),u=i&&(a==null?void 0:a.id)!==e||!!l,m=b=>{r(e,{label:b})},f=()=>{d(!0)},g=()=>{d(!1)};return bs("div",{className:"relative",onDoubleClick:f,children:[Qe(Yn,{className:H("w-full h-full min-w-9 min-h-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})}),Qe("div",{className:"absolute mt-2 left-1/2 -translate-x-1/2 max-w-80 w-max",children:Qe(Re,{value:t.label,isEditing:c,onBlur:g,onChange:m})}),Qe(Xe,{nodeId:e,nodeType:"START_EVENT"}),s==="edit"&&Qe(it,{nodeId:e,isVisible:!n&&o,minWidth:Un.MIN_WIDTH,minHeight:Un.MIN_HEIGHT,offset:4,keepAspectRatio:!0}),(!i||u)&&bs(xd,{children:[Qe(te,{type:"target",position:Ut.Left,id:"left",className:H({"event-handle":u})}),Qe(te,{type:"target",position:Ut.Right,id:"right",className:H({"event-handle":u})}),Qe(te,{type:"target",position:Ut.Top,id:"top",className:H({"event-handle":u})}),Qe(te,{type:"target",position:Ut.Bottom,id:"bottom",className:H({"event-handle":u})})]}),!i&&bs(xd,{children:[Qe(He,{type:"source",position:Ut.Left,id:"left",nodeId:e,nodeType:"START_EVENT"}),Qe(He,{type:"source",position:Ut.Right,id:"right",nodeId:e,nodeType:"START_EVENT"}),Qe(He,{type:"source",position:Ut.Top,id:"top",nodeId:e,nodeType:"START_EVENT"}),Qe(He,{type:"source",position:Ut.Bottom,id:"bottom",nodeId:e,nodeType:"START_EVENT"})]})]})};import{useTranslation as Vy}from"@produto-lecom/lecom-ui";import{Position as $t,useConnection as Hy,useReactFlow as Gy}from"@xyflow/react";import{useCallback as ti}from"react";var An=60,ei=(e,t)=>{var a;let o=[],n=`${t} `;for(let s of e){if(!(s.type==="TASK"))continue;let c=(a=s.data)==null?void 0:a.label;if(c&&c.startsWith(n)){let d=c.substring(n.length);/^\d{1,15}$/.test(d)&&o.push(parseInt(d,10))}}let r=o.length>0?Math.max(...o)+1:1,i=`${t} ${r}`;return i.length<=An?i:i.substring(0,An).trim()},Fo=(e,t)=>{var s;let o=new Set;for(let l of t)l.type==="TASK"&&((s=l.data)!=null&&s.label)&&o.add(l.data.label);let n=e;if(n.length>An&&(n=n.substring(0,An).trim()),!o.has(n))return n;let r=n.replace(/\s+\(\d+\)$/,""),i=2,a=o.size+2;for(;i<=a;){let l=` (${i})`,c=An-l.length,u=`${r.substring(0,c).trim()}${l}`;if(!o.has(u))return u;i++}return n};import{jsx as bd,jsxs as Dy}from"react/jsx-runtime";var _d=e=>Dy("svg",w(_({width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",xmlns:"http://www.w3.org/2000/svg"},e),{children:[bd("circle",{cx:"12",cy:"12",r:"10",fill:"#10B981"}),bd("path",{d:"M7 12L10 15L17 8",stroke:"white",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"})]}));import{jsx as Td}from"react/jsx-runtime";var Nd=e=>Td("svg",w(_({width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",xmlns:"http://www.w3.org/2000/svg"},e),{children:Td("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 vd,jsxs as Oy}from"react/jsx-runtime";var wd=e=>Oy("svg",w(_({width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",xmlns:"http://www.w3.org/2000/svg"},e),{children:[vd("circle",{cx:"12",cy:"12",r:"10",fill:"#EF4444"}),vd("path",{d:"M8 8L16 16M8 16L16 8",stroke:"white",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"})]}));import{Fragment as oi,jsx as Te,jsxs as Cn}from"react/jsx-runtime";var By={APROVADO:_d,EM_ANDAMENTO:Nd,REJEITADO:wd},_s={APROVADO:"border-green-500 hover:border-green-500 border-[3px] border-solid",EM_ANDAMENTO:"border-turquoise-400 hover:border-turquoise-400 border-[3px] border-solid",REJEITADO:"border-red-500 hover:border-red-500 border-[3px] border-solid",default:"border-grey-400 border-2 border-solid",error:"border-red-500 border-[3px] shadow-[0_0_5px_rgba(255,0,0,0.5)]"},zy={APROVADO:"bg-green-50",EM_ANDAMENTO:"bg-turquoise-50",REJEITADO:"bg-red-50"},Id=({id:e,data:t,width:o,height:n,selected:r,dragging:i})=>{let{t:a}=Vy(),{toast:s}=Fe(),{updateNodeData:l,getNodes:c,setNodes:d}=Gy(),{inProgress:u,fromNode:m}=Hy(),{mode:f,onSubprocessValidationClick:g,reconnectingEdgeId:b}=Z(),{getTaskStatus:p}=no(),h=u&&(m==null?void 0:m.id)!==e||!!b,y=p(e),x=t.variant==="SUBPROCESS",v=!!t.variant&&!x||!!y,N=!!t.attribute||x,T=ti(J=>{let D=v||N?80:40,A=J.split(`
41
+ `),L=A.reduce((k,F)=>Math.max(k,F.length),0),B=A.length,z=Math.max(kt.MIN_WIDTH,L*7+64),O=Math.max(kt.MIN_HEIGHT,B*24+D);d(k=>k.map(F=>F.id===e?w(_({},F),{width:z,height:O,style:w(_({},F.style),{width:z,height:O})}):F))},[e,d,v,N]),E=ti(J=>{let Y=J.trim(),S=t.label||"";if(Y===S)return;let R=Y,D=c();if(!(Y&&Y!=="")){R=ei(D,a("bpmn.task.label.prefix")),l(e,{label:R}),T(R),s({variant:"warning",content:Cn(oi,{children:[a("bpmn.task.feedback.label_empty.prefix")," ",Te("strong",{children:R})]})});return}let L=Fo(R,D);L===S||(l(e,{label:L}),T(L),L!==R&&s({variant:"warning",content:Cn(oi,{children:[a("bpmn.task.feedback.label_already_exists.prefix")," ",Te("strong",{children:Y})," ",a("bpmn.task.feedback.label_already_exists.middle")," ",Te("strong",{children:L})]})}))},[t.label,c,e,a,l,T,s]),I=ti(J=>{T(J)},[T]),P=ti(()=>{s({variant:"error",content:a("bpmn.task.feedback.invalid_first_character")})},[a,s]),M=y?By[y]:null,V=t.variant?Fn[t.variant].icon:null,C=t.attribute?Xn[t.attribute].icon:null,G=()=>t.hasError?_s.error:y?_s[y]:_s.default,K=()=>{var J;return r&&(J=zy[y])!=null?J:""},$=()=>{g==null||g({id:e,type:"sub_process",label:t.label})};return Cn("div",{className:H("relative w-full h-full min-w-44 min-h-24 flex flex-col items-stretch justify-stretch bg-blue-400 border-2 border-grey-400 hover:border-grey-500 rounded-md hover:shadow-md transition-colors duration-75",G(),{"border-blue-500 hover:border-blue-600 shadow-md":r&&!y,"border-red-500 hover:border-red-600 shadow-[0_0_5px_rgba(255,0,0,0.5)]":t.hasError}),style:{width:o!=null?o:kt.MIN_WIDTH,height:n!=null?n:kt.MIN_HEIGHT},children:[Te("div",{className:"flex-1 flex items-stretch justify-stretch overflow-hidden",children:Te(Re,{value:t.label,maxLength:60,className:H(K(),{"py-10 px-8":v||N}),onChange:E,onInput:I,onInvalidFirstCharacter:P})}),V&&Te("div",{className:H("absolute flex items-center p-1",x?"bottom-0 left-1/2 -translate-x-1/2":"top-0 left-0"),children:Te(V,{size:16,className:H(t.hasError?"text-red-500":"text-grey-500",x&&"cursor-pointer"),onClick:x?$:void 0})}),C&&Te("div",{className:"absolute bottom-0 left-0 w-full flex items-center justify-center",children:Te("div",{className:H("flex items-center w-16 p-1",x?"justify-between":"justify-center"),children:Te(C,{size:16,className:H(t.hasError?"text-red-500":"text-grey-500")})})}),M&&Te("div",{className:"absolute top-0 right-0 flex items-center p-1",children:Te(M,{})}),Te(Xe,{nodeId:e,nodeType:"TASK",nodeVariant:t.variant}),f==="edit"&&Te(it,{nodeId:e,isVisible:!i&&r,minWidth:kt.MIN_WIDTH,minHeight:kt.MIN_HEIGHT}),(!u||h)&&Cn(oi,{children:[Te(te,{type:"target",position:$t.Left,id:"left",className:H({"task-handle":h})}),Te(te,{type:"target",position:$t.Right,id:"right",className:H({"task-handle":h})}),Te(te,{type:"target",position:$t.Top,id:"top",className:H({"task-handle":h})}),Te(te,{type:"target",position:$t.Bottom,id:"bottom",className:H({"task-handle":h})})]}),!u&&Cn(oi,{children:[Te(He,{type:"source",position:$t.Left,id:"left",nodeId:e,nodeType:"TASK"}),Te(He,{type:"source",position:$t.Right,id:"right",nodeId:e,nodeType:"TASK"}),Te(He,{type:"source",position:$t.Top,id:"top",nodeId:e,nodeType:"TASK"}),Te(He,{type:"source",position:$t.Bottom,id:"bottom",nodeId:e,nodeType:"TASK"})]})]})};import{Position as Ad}from"@xyflow/react";import{Fragment as Yy,jsx as ni,jsxs as Wy}from"react/jsx-runtime";var Cd=({id:e,data:t})=>Wy(Yy,{children:[ni("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}),ni(Xe,{nodeId:e,nodeType:"UNSUPPORTED"}),ni(te,{type:"source",position:Ad.Right}),ni(te,{type:"target",position:Ad.Left})]});import{BaseEdge as Fy,EdgeLabelRenderer as Xy,getSmoothStepPath as Uy,MarkerType as $y,useInternalNode as Sd,useReactFlow as Ky,useViewport as qy,Position as Xo}from"@xyflow/react";import{useState as Zy,useMemo as Jy}from"react";import{Fragment as Md,jsx as Ue,jsxs as mo}from"react/jsx-runtime";var w5={type:"MESSAGE_EDGE",reconnectable:!0,markerEnd:{type:$y.Arrow},data:{label:""}},Pd=({id:e,source:t,target:o,data:n,selected:r,sourcePosition:i,targetPosition:a,sourceHandleId:s,targetHandleId:l})=>{var B;let{zoom:c}=qy(),{updateEdgeData:d}=Ky(),{isMultipleSelection:u,mode:m,instanceId:f}=Z(),g=m!=="edit",[b,p]=Zy(!1),{reconnectingHandle:h,cursorPosition:y,hoveredNodeId:x,reconnectingSide:v,isValidReconnection:N,handleReconnectStart:T}=$r({edgeId:e,source:t,target:o,instanceId:f,isReadOnly:g}),E=Sd(t),I=Sd(o),{sx:P,sy:M,tx:V,ty:C,sourcePos:G,targetPos:K}=Jy(()=>{var ce,ne;if(!E||!I)return{sx:0,sy:0,tx:0,ty:0,sourcePos:Xo.Left,targetPos:Xo.Right};let z=Ao(E,I),O=s?i:z.sourcePos,k=l?a:z.targetPos,F=(q,xe,W)=>{var pe,he,Ne,ke,Ge,Ke;let{x:ae,y:re}=q.internals.positionAbsolute,ie=(Ne=(he=(pe=q.measured)==null?void 0:pe.width)!=null?he:q.width)!=null?Ne:0,ue=(Ke=(Ge=(ke=q.measured)==null?void 0:ke.height)!=null?Ge:q.height)!=null?Ke:0;switch(xe){case Xo.Top:return{x:ae+ie*W,y:re};case Xo.Bottom:return{x:ae+ie*W,y:re+ue};case Xo.Left:return{x:ae,y:re+ue*W};case Xo.Right:return{x:ae+ie,y:re+ue*W};default:return{x:ae+ie/2,y:re+ue/2}}},ee=(ce=n==null?void 0:n.sourceOffset)!=null?ce:.5,U=(ne=n==null?void 0:n.targetOffset)!=null?ne:.5,Q=E?F(E,O,ee).x:z.sx,j=E?F(E,O,ee).y:z.sy,oe=I?F(I,k,U).x:z.tx,X=I?F(I,k,U).y:z.ty;return h==="source"&&y?(Q=y.x,j=y.y,v&&(O=v)):h==="target"&&y&&(oe=y.x,X=y.y,v&&(k=v)),{sx:Q,sy:j,tx:oe,ty:X,sourcePos:O,targetPos:k}},[E,I,s,l,i,a,h,y,v,n==null?void 0:n.sourceOffset,n==null?void 0:n.targetOffset]);if(!E||!I)return null;let[$,J,Y]=Uy({sourceX:P,sourceY:M,targetX:V,targetY:C,sourcePosition:G,targetPosition:K}),S=r||(E==null?void 0:E.selected)||(I==null?void 0:I.selected),R=S?"sequence-edge-marker-highlighted":"sequence-edge-marker",D=b||(n==null?void 0:n.label.trim().length)>0,A=()=>{p(!1)},L=z=>{d(e,{label:z.trim()})};return Ue(Md,{children:mo("g",{className:H("group bpmn-arrow-edge",{"is-highlighted":S}),onDoubleClick:()=>!g&&p(!0),children:[Ue("path",{d:$,fill:"none",stroke:"transparent",strokeWidth:Math.max(12,12/c),style:{pointerEvents:"stroke",cursor:"pointer"}}),mo("g",{className:H("text-grey-500 transition-colors duration-75 group-hover:text-grey-800",{"text-blue-500 group-hover:text-blue-600":S}),children:[Ue(Fy,{id:e,path:$,interactionWidth:0,markerEnd:`url(#${R})`,strokeDasharray:4,className:H("stroke-2 stroke-current transition-[stroke,filter] duration-75 group-hover:drop-shadow-[0_0_3px_rgba(0,0,0,0.2)]",{"stroke-red-500 hover:stroke-red-600":(n==null?void 0:n.hasError)||h&&x&&!N,"stroke-green-500":h&&x&&N,"stroke-blue-500 hover:stroke-blue-600 drop-shadow-[0_0_3px_rgba(59,130,246,0.5)]":S&&!(n!=null&&n.hasError)&&!h})}),mo(Xy,{children:[mo("div",{className:"absolute z-[3000] pointer-events-auto flex flex-col items-center gap-1",style:{transform:`translate(-50%, -50%) translate(${J}px, ${Y}px)`},children:[r&&!u&&Ue(Ro,{sx:P,sy:M,tx:V,ty:C,hasLabel:!!((B=n==null?void 0:n.label)!=null&&B.trim()),children:Ue(ko,{edgeId:e,edgeType:"MESSAGE_EDGE"})}),D&&Ue(Re,{value:n==null?void 0:n.label,className:"min-w-8 max-w-56 bg-white rounded-md px-2 py-1 text-xs",isEditing:b,onBlur:A,onChange:L})]}),r&&!u&&!g&&mo(Md,{children:[Ue("div",{className:"absolute z-[1000] pointer-events-none",style:{transform:`translate(-50%, -50%) translate(${P}px, ${M}px)`},children:mo("svg",{width:12/c,height:12/c,style:{overflow:"visible",position:"absolute",left:"50%",top:"50%",transform:"translate(-50%, -50%)"},children:[Ue("circle",{cx:6/c,cy:6/c,r:4/c,fill:h==="source"?"#3b82f6":"#fff",stroke:"#3b82f6",strokeWidth:2/c,className:"pointer-events-none"}),Ue("circle",{cx:6/c,cy:6/c,r:6/c,fill:"none",stroke:"#3b82f6",strokeWidth:1/c,opacity:h==="source"?.6:.3,className:"pointer-events-none"}),Ue("circle",{cx:6/c,cy:6/c,r:8/c,fill:"transparent",className:H("pointer-events-auto",{"cursor-move":!h||h!=="source","cursor-not-allowed":h==="source"&&x&&!N,"cursor-grabbing":h==="source"&&(!x||N)}),onMouseDown:z=>T("source",z.nativeEvent)})]})}),Ue("div",{className:"absolute z-[1000] pointer-events-none",style:{transform:`translate(-50%, -50%) translate(${V}px, ${C}px)`},children:mo("svg",{width:12/c,height:12/c,style:{overflow:"visible",position:"absolute",left:"50%",top:"50%",transform:"translate(-50%, -50%)"},children:[Ue("circle",{cx:6/c,cy:6/c,r:4/c,fill:h==="target"?"#3b82f6":"#fff",stroke:"#3b82f6",strokeWidth:2/c,className:"pointer-events-none"}),Ue("circle",{cx:6/c,cy:6/c,r:6/c,fill:"none",stroke:"#3b82f6",strokeWidth:1/c,opacity:h==="target"?.6:.3,className:"pointer-events-none"}),Ue("circle",{cx:6/c,cy:6/c,r:8/c,fill:"transparent",className:H("pointer-events-auto",{"cursor-move":!h||h!=="target","cursor-not-allowed":h==="target"&&x&&!N,"cursor-grabbing":h==="target"&&(!x||N)}),onMouseDown:z=>T("target",z.nativeEvent)})]})})]})]})]})]})})};import{getStraightPath as Qy,Position as ri}from"@xyflow/react";import{jsx as Ld,jsxs as jy}from"react/jsx-runtime";var kd=({toX:e,toY:t,fromNode:o})=>{var u,m;if(!o)return null;let{internals:{positionAbsolute:{x:n,y:r}},measured:i}=o,a=(u=i.width)!=null?u:0,s=(m=i.height)!=null?m:0,c=[{x:n,y:r+s/2,pos:ri.Left},{x:n+a,y:r+s/2,pos:ri.Right},{x:n+a/2,y:r,pos:ri.Top},{x:n+a/2,y:r+s,pos:ri.Bottom}].reduce((f,g)=>{let b=Math.hypot(e-f.x,t-f.y);return Math.hypot(e-g.x,t-g.y)<b?g:f}),[d]=Qy({sourceX:c.x,sourceY:c.y,targetX:e,targetY:t});return jy("g",{className:"group",children:[Ld("path",{fill:"none",className:"stroke-2 stroke-grey-500 animated transition-[stroke,filter] duration-75",d}),Ld("circle",{cx:e,cy:t,fill:"none",r:4,className:"stroke-2 stroke-grey-600"})]})};import{Position as Kt,useConnection as e0,useReactFlow as t0}from"@xyflow/react";import{orderBy as o0}from"lodash";import{useMemo as Rd,useState as n0}from"react";import{Fragment as Ts,jsx as $e,jsxs as ii}from"react/jsx-runtime";var Dd=({id:e,data:t,selected:o,dragging:n,parentId:r})=>{var T;let{updateNodeData:i,getNodes:a}=t0(),{mode:s}=Z(),{inProgress:l,fromNode:c}=e0(),d=l&&(c==null?void 0:c.id)!==e,[u,m]=n0(!1),f=a(),g=!r,b=!g&&((T=f.find(E=>E.id===r))==null?void 0:T.selected),p=Rd(()=>o0([...f.filter(E=>E.parentId===e&&E.type==="LANE")],"position.y","asc"),[f,e]),h=g?js.MIN_WIDTH:se.MIN_WIDTH,y=Rd(()=>{if(g&&p.length>1){let E=[...p];return E.pop(),E.reduce((P,M)=>{var V,C;return P+((C=(V=M.measured)==null?void 0:V.height)!=null?C:0)},0)+se.MIN_HEIGHT}return se.MIN_HEIGHT},[g,p]),x=E=>{i(e,{label:E})},v=()=>{m(!0)},N=()=>{m(!1)};return ii(Ts,{children:[ii("div",{className:H("flex h-full min-h-64 w-full min-w-[50rem] hover:shadow-md bg-white outline outline-2 outline-grey-400",{"outline-offset-0 outline-blue-500 shadow-sm":o||b}),children:[$e("div",{className:H("flex align-items justify-center w-10 border-r-2 border-grey-400",{"border-blue-500":o||b}),onDoubleClick:v,children:$e("div",{className:"relative flex-1 [writing-mode:vertical-rl] [text-orientation:sideways] transform rotate-180",children:$e(Re,{value:t.label,className:"w-full h-full self-auto",contentClassName:H({"whitespace-nowrap":u}),isEditing:u,onBlur:N,onChange:x})})}),$e("div",{className:"flex-1"})]}),$e(Xe,{nodeId:e,nodeType:"LANE",isChild:!g}),s==="edit"&&$e(it,{nodeId:e,isVisible:!n&&o,minWidth:h,minHeight:y,offset:10}),!l&&ii(Ts,{children:[$e(te,{type:"source",position:Kt.Left,id:"left"}),$e(te,{type:"source",position:Kt.Right,id:"right"}),$e(te,{type:"source",position:Kt.Top,id:"top"}),$e(te,{type:"source",position:Kt.Bottom,id:"bottom"})]}),(!l||d)&&ii(Ts,{children:[$e(te,{type:"target",position:Kt.Left,id:"left",className:H({"annotation-handle":d})}),$e(te,{type:"target",position:Kt.Right,id:"right",className:H({"annotation-handle":d})}),$e(te,{type:"target",position:Kt.Top,id:"top",className:H({"annotation-handle":d})}),$e(te,{type:"target",position:Kt.Bottom,id:"bottom",className:H({"annotation-handle":d})})]})]})};var Od={START_EVENT:Ed,END_EVENT:gd,TASK:Id,GATEWAY:yd,ANNOTATION:fd,LANE:Dd,UNSUPPORTED:Cd},Vd={SEQUENCE_EDGE:kc,MESSAGE_EDGE:Pd,ANNOTATION_EDGE:yc},Hd="#fafafa",Gd="#bebebe",Bd=1,zd=10,Yd="bottom-left",Ns=.05,Wd=5,Uo=.5,$o=Ns,Ko=1,Fd={x:0,y:0,zoom:.75},Xd=1,Ud=2,r0={[Xd]:4,[Ud]:2},Sn=[Xd,Ud],vs=Sn.reduce((e,t)=>e|r0[t],0);import{useReactFlow as i0}from"@xyflow/react";var st=()=>{let{getEdges:e,getNodes:t}=i0(),{lastElementId:o}=Z(),n=()=>{let i=t(),a=e(),s=jc(i,a);return Math.max(s,o)};return{getLastId:n,getNextId:()=>n()+1}};var qo=()=>{let{getNodes:e,getEdges:t,setNodes:o,setEdges:n,setViewport:r}=a0(),{getLastId:i}=st(),a=l0(),{setLastElementId:s}=Z(),l=$d(async(d="")=>{let{nodes:u,edges:m,lastElementId:f}=await td(d),{width:g,height:b}=a.getState();if(g>0&&b>0){let p=aa(u);p&&r(s0(p,g,b,$o,Ko,Uo))}o(u),n(m),s(f)},[o,n,s,a,r]),c=$d(()=>{let d=e(),u=t(),m=i();return ed(d,u,m)},[e,t,i]);return{importFromMxGraph:l,exportToMxGraph:c}};import{useCallback as Kd}from"react";var d0=500,si=()=>{let{isInitialized:e,onElementChanges:t}=Z(),{exportToMxGraph:o}=qo(),n=c0(()=>{if(!e)return;let a=o();t==null||t(a)},d0),r=Kd(a=>{a.every(c=>c.type==="select")||a.some(c=>c.type==="position"&&c.dragging)||n()},[n]),i=Kd(a=>{a.some(l=>l.type==="select")||n()},[n]);return{emitElementChanges:n,handleNodeChanges:r,handleEdgeChanges:i}};var qd=({setEdges:e,saveHistory:t})=>{let{getNode:o,getEdges:n,getNodes:r,getInternalNode:i}=p0(),{emitElementChanges:a}=si(),s=f0(null),{getNextId:l}=st(),c=go(p=>{var N;let h=o(p.source),y=o(p.target);if(!h||!y)return!1;let x={sourceNodeId:h.id,targetNodeId:y.id,sourceNodeType:h.type,targetNodeType:y.type,nodes:r(),edges:n(),reconnectingEdgeId:(N=s.current)!=null?N:void 0};return ns(x).isValid},[o,n,r]),d=go(p=>{var x,v;let h=l(),y=i(p.source);if(y){let N=i(p.target),T=N?N.internals.positionAbsolute.x+((x=N.measured.width)!=null?x:0)/2:0,E=N?N.internals.positionAbsolute.y+((v=N.measured.height)!=null?v:0)/2:0,I=Rc(y,T,E),P=(N==null?void 0:N.type)==="ANNOTATION"||(y==null?void 0:y.type)==="ANNOTATION",M=P?Do:rt,V;if(!P&&N&&p.targetHandle){let K=qr(I),$=qr(p.targetHandle),{x:J,y:Y}=ls(y,I),{x:S,y:R}=ls(N,p.targetHandle),A=Xr(J,Y,S,R,K,$).slice(1,-1);A.length>0&&(V=A)}let C=w(_(_({},p),M),{id:String(h),sourceHandle:I,data:_(_({},P?{}:rt.data),V?{points:V}:{})}),G=n().concat(C);e(G),t("forceSave",{nodes:r(),edges:G}),a()}},[l,e,a,i,n,r,t]),u=go((p,h)=>{s.current=h.id},[]),m=go(()=>{s.current=null},[]),f=go((p,h)=>{let y=o(h.source),x=o(h.target);if(!y||!x){s.current=null;return}let v={sourceNodeId:y.id,targetNodeId:x.id,sourceNodeType:y.type,targetNodeType:x.type,nodes:r(),edges:n(),reconnectingEdgeId:p.id};if(!ns(v).isValid){s.current=null;return}let T=u0(p,h,n()).map(E=>E.id===p.id?w(_({},E),{data:w(_({},E.data),{points:void 0})}):E);e(T),t("forceSave",{nodes:r(),edges:T}),s.current=null,a()},[o,r,n,e,a,t]),g=go(p=>{s.current=p},[]),b=go(()=>{s.current=null},[]);return{isValidConnection:c,onConnect:d,onReconnect:f,onReconnectStart:u,onReconnectEnd:m,setReconnectingEdge:g,clearReconnectingEdge:b}};import{useTranslation as m0}from"@produto-lecom/lecom-ui";import{useReactFlow as g0}from"@xyflow/react";import{useCallback as kn,useRef as ru,useState as h0}from"react";var Mn=(e=[])=>e.filter(t=>t.type==="START_EVENT"),ho=(e=[])=>e.filter(t=>t.type==="END_EVENT"),qt=(e=[])=>e.filter(t=>t.type==="TASK")||[],Zd=(e=[])=>e.filter(t=>{var o;return t.type==="TASK"&&((o=t.properties)==null?void 0:o.variant)==="SCRIPT"});var ai=(e=[])=>e.filter(t=>t.type==="GATEWAY"),Jd=(e=[])=>e.filter(t=>{var o;return t.type==="GATEWAY"&&((o=t.properties)==null?void 0:o.variant)==="EXCLUSIVE"}),je=(e,t=[])=>t.filter(o=>o.source===e),Pn=(e,t=[])=>t.filter(o=>o.target===e),Qd=(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"},jd=(e,t)=>{let o=je(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},eu=e=>e?/[^\s]/.test(e.trim()):!1,Ee=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:[]}},Ct=(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)}},tu=(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 Ln=[{id:"start_event_not_found",validate:e=>{let t=Mn(e.nodes);return Ee({isValid:t.length>=1})}},{id:"end_event_not_found",validate:e=>{let t=ho(e.nodes);return Ee({isValid:t.length>=1})}},{id:"multiple_start_event_not_allowed",validate:e=>{let t=Mn(e.nodes),o=t.length===1;if(t.length===0)return Ee({isValid:!0});if(!o)return Ee({isValid:!1,nodeIds:t.map(i=>i.id)});let n=je(t[0].id,e.edges);if(!(n.length<=1)){let i=[...t.map(a=>a.id),...n.map(a=>a.target)];return Ee({isValid:!1,nodeIds:[...new Set(i)]})}return Ee({isValid:!0})}},{id:"task_flows_limit_exceeds",validate:e=>{let t=qt(e.nodes),o=Ct(t,n=>je(n.id,e.edges).length<=2);return Ee({isValid:o.isValid,nodeIds:o.invalidIds})}},{id:"task_label_empty",highlightRelatedEdges:!1,validate:e=>{let t=qt(e.nodes),o=Ct(t,n=>!!n.label&&n.label.trim()!=="");return Ee({isValid:o.isValid,nodeIds:o.invalidIds})}},{id:"task_label_length",highlightRelatedEdges:!1,validate:e=>{let o=qt(e.nodes),n=Ct(o,r=>!r.label||r.label.length<=60);return Ee({isValid:n.isValid,nodeIds:n.invalidIds})}},{id:"duplicate_task_name",highlightRelatedEdges:!1,validate:e=>{let t=qt(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 Ee({isValid:n.length===0,nodeIds:n})}},{id:"nested_gateway",validate:e=>{let t=ai(e.nodes),o=[],n=[];for(let r of t){let i=je(r.id,e.edges);for(let a of i){let s=e.nodes.find(l=>l.id===a.target);s&&s.type==="GATEWAY"&&(o.push(r.id,s.id),n.push(a.id))}}return Ee({isValid:o.length===0,nodeIds:o.length>0?[...new Set(o)]:[],edgeIds:n})}},{id:"events_nested",validate:e=>{let t=[...Mn(e.nodes),...ho(e.nodes)],o=[],n=[];for(let r of t){let i=je(r.id,e.edges);for(let a of i){let s=e.nodes.find(l=>l.id===a.target);s&&(s.type==="START_EVENT"||s.type==="END_EVENT")&&(o.push(r.id,s.id),n.push(a.id))}}return Ee({isValid:o.length===0,nodeIds:o.length>0?[...new Set(o)]:[],edgeIds:n})}},{id:"flows_on_end_tasks_not_allowed",validate:e=>{let t=ho(e.nodes),o=[],n=[];for(let r of t){let i=Pn(r.id,e.edges);for(let a of i){let s=e.nodes.find(l=>l.id===a.source);if(s&&s.type==="TASK"){let l=je(s.id,e.edges);l.length>1&&(o.push(s.id),l.forEach(c=>n.push(c.id)))}}}return Ee({isValid:o.length===0,nodeIds:o,edgeIds:n})}},{id:"conditions_flows_limit_exceeds",validate:e=>{let t=Jd(e.nodes),o=Ct(t,r=>je(r.id,e.edges).length<=2),n=o.invalidIds.flatMap(r=>je(r,e.edges).map(i=>i.id));return Ee({isValid:o.isValid,nodeIds:o.invalidIds,edgeIds:n})}},{id:"activity_name_invalid",validate:e=>{let t=qt(e.nodes),o=Ct(t,n=>!n.label||eu(n.label));return Ee({isValid:o.isValid,nodeIds:o.invalidIds})}},{id:"final_activity_has_loop",validate:e=>{var a,s;if(!((a=e==null?void 0:e.nodes)!=null&&a.length)||!((s=e==null?void 0:e.edges)!=null&&s.length))return Ee({isValid:!0});let t=ho(e.nodes)[0];if(!t)return Ee({isValid:!0});let o=Pn(t.id,e.edges);if(!o.length)return Ee({isValid:!0});let r=qt(e.nodes).filter(l=>o.some(c=>c.source===l.id)),i=Ct(r,l=>!Qd(l.id,e));return Ee({isValid:i.isValid,nodeIds:i.isValid?[]:[t.id,...i.invalidIds]})}},{id:"concurrent_initial_and_final_event",validate:e=>{let t=qt(e.nodes),o=ho(e.nodes)[0];if(!o)return Ee({isValid:!0});let n=t.filter(l=>{let c=Pn(l.id,e.edges),d=je(l.id,e.edges),u=c.some(f=>{var g;return((g=e.nodes.find(b=>b.id===f.source))==null?void 0:g.type)==="START_EVENT"}),m=d.some(f=>{var g;return((g=e.nodes.find(b=>b.id===f.target))==null?void 0:g.type)==="END_EVENT"});return u&&m}),r=Pn(o.id,e.edges),i=r.length>1,a=r.map(l=>l.source),s={isValid:n.length===0&&!i,nodeIds:[...n.map(l=>l.id),...i?a:[]]};return Ee(s)}},{id:"gateway_flow_to_event",validate:e=>{let t=ai(e.nodes),o=[],n=[];for(let r of t){let i=je(r.id,e.edges);for(let a of i){let s=e.nodes.find(l=>l.id===a.target);s&&s.type==="END_EVENT"&&(o.push(r.id,s.id),n.push(a.id))}}return Ee({isValid:o.length===0,nodeIds:o.length>0?[...new Set(o)]:[],edgeIds:n})}},{id:"gateway_missing_output_streams",validate:e=>{let t=ai(e.nodes),o=Ct(t,n=>je(n.id,e.edges).length>=1);return Ee({isValid:o.isValid,nodeIds:o.invalidIds})}},{id:"event_to_condition",validate:e=>{let t=[...Mn(e.nodes),...ho(e.nodes)],o=[],n=[];for(let r of t){let i=je(r.id,e.edges);for(let a of i){let s=e.nodes.find(l=>l.id===a.target);s&&s.type==="GATEWAY"&&(o.push(r.id,s.id),n.push(a.id))}}return Ee({isValid:o.length===0,nodeIds:o.length>0?[...new Set(o)]:[],edgeIds:n})}},{id:"script_in_final_activity",validate:e=>{let t=Zd(e.nodes),o=Ct(t,n=>!jd(n.id,e));return Ee({isValid:o.isValid,nodeIds:o.invalidIds})}}];var ou=e=>{e=e||{nodes:[],edges:[]},e.nodes=e.nodes||[],e.edges=e.edges||[];let t=[];for(let n of Ln){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}},nu=async(e,t)=>{var n;let o=[];try{let r=await e(),i=(n=r==null?void 0:r.filter(a=>a.area==="DIAGRAM"))!=null?n:[];return i.length===0?{isValid:!0,errors:[]}:(i.forEach(a=>{var l,c;let s=(c=(l=a==null?void 0:a.detail)==null?void 0:l.phases)==null?void 0:c.map(d=>d.diagramCellId);o.push({id:a.code,message:a.code,nodeIds:s,edgeIds:[]})}),{isValid:!1,errors:o})}catch(r){return{isValid:!1,errors:[{id:"cannot_validate_subprocess_reference",message:"cannot_validate_subprocess_reference",nodeIds:t.map(i=>i.id)||[],edgeIds:[]}]}}};import{jsx as li,jsxs as y0}from"react/jsx-runtime";var iu=()=>{let{t:e}=m0(),{toast:t}=Fe(),{setNodes:o,setEdges:n,getNodes:r,getEdges:i}=g0(),{validateCustomDiagram:a}=Z(),[s,l]=h0(!1),c=ru(!1),d=ru(!1),u=kn(async p=>{let h=tu(p.nodes,p.edges),y=ou(h),x=p.nodes.filter(({type:N,data:T})=>N==="TASK"&&(T==null?void 0:T.variant)==="SUBPROCESS");if(a&&x.length>0){let N=await nu(a,x);y={isValid:y.isValid&&N.isValid,errors:[...y.errors,...N.errors]}}let v=y.errors.map(N=>w(_({},N),{message:e(`validation.errors.${N.id}`)}));return s||l(!0),{isValid:y.isValid,errors:v}},[s,e,a]),m=kn((p,h=!0)=>{if(h&&p&&t({variant:p.isValid?"success":"error",duration:5e3,title:p.isValid?e("validation.success.title"):e("validation.errors.title"),content:y0("div",{className:"flex flex-col gap-1",children:[!p.isValid&&li("span",{className:"body-small-500",children:e("validation.errors.subtitle")}),li("ul",{className:"list-disc list-inside max-h-40 overflow-y-auto",children:p.isValid?li("li",{children:e("validation.success.message")}):p.errors.map(C=>li("li",{className:"text-xs",children:C.message},C.id))})]})}),!p)return;c.current=!0,d.current=!0;let y=[],x=[];p.errors.forEach(C=>{C.nodeIds&&C.nodeIds.length>0&&C.nodeIds.forEach(G=>y.push(G)),C.edgeIds&&C.edgeIds.length>0&&C.edgeIds.forEach(G=>x.push(G))});let v=[...new Set(y)];o(C=>C.map(G=>w(_({},G),{data:w(_({},G.data),{hasError:!1})}))),n(C=>C.map(G=>w(_({},G),{data:w(_({},G.data),{hasError:!1})})));let N=r(),T=i(),E=new Set(v),I=new Set;p.errors.forEach(C=>{var $,J;let G=Ln.find(Y=>Y.id===C.id);(G==null?void 0:G.highlightRelatedEdges)!==!1&&(($=C.edgeIds)==null||$.forEach(Y=>I.add(Y)),(J=C.nodeIds)==null||J.forEach(Y=>{T.forEach(S=>{(S.source===Y||S.target===Y)&&I.add(S.id)})}))});let P=new Set,M=new Set,V=new Set;N.forEach(C=>{C.type==="START_EVENT"?P.add(C.id):C.type==="END_EVENT"&&M.add(C.id)}),T.forEach(C=>{P.has(C.source)&&V.add(C.target),M.has(C.target)&&V.add(C.source)}),V.forEach(C=>{var G,K;if(E.has(C)){let $=(G=p.errors.find(Y=>{var S;return(S=Y.nodeIds)==null?void 0:S.includes(C)}))==null?void 0:G.id;((K=Ln.find(Y=>Y.id===$))==null?void 0:K.highlightRelatedEdges)!==!1&&T.forEach(Y=>{Y.source===C&&M.has(Y.target)&&(E.add(Y.target),I.add(Y.id)),Y.target===C&&P.has(Y.source)&&(E.add(Y.source),I.add(Y.id))})}}),E.size>0&&o(C=>C.map(G=>w(_({},G),{data:w(_({},G.data),{hasError:E.has(G.id)})}))),I.size>0&&n(C=>C.map(G=>w(_({},G),{data:w(_({},G.data),{hasError:I.has(G.id)})}))),setTimeout(()=>{c.current=!1},0)},[e,i,r,n,o,t]),f=kn(()=>{l(!1),d.current=!1,o(p=>p.map(h=>w(_({},h),{data:w(_({},h.data),{hasError:!1})}))),n(p=>p.map(h=>w(_({},h),{data:w(_({},h.data),{hasError:!1})})))},[n,o]),g=kn(()=>{d.current&&(c.current=!0,d.current=!1,o(p=>p.map(h=>w(_({},h),{data:w(_({},h.data),{hasError:!1})}))),n(p=>p.map(h=>w(_({},h),{data:w(_({},h.data),{hasError:!1})}))),setTimeout(()=>{c.current=!1},0))},[n,o]),b=kn(()=>c.current,[]);return{validateDiagram:u,handleValidationComplete:m,clearValidation:f,dismissValidationPanel:g,isAutoValidationEnabled:s,getIsClearingValidation:b}};import{useReactFlow as x0}from"@xyflow/react";import{useTranslation as E0}from"@produto-lecom/lecom-ui";import{useEffect as b0}from"react";var _0=15,su="bpmn:selection",T0=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},au=e=>{if(!T0(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},lu=({offset:e=_0,saveHistory:t})=>{let{t:o}=E0(),{getNodes:n,setNodes:r,getEdges:i,setEdges:a}=x0(),{getNextId:s}=st(),{mode:l}=Z();b0(()=>{if(l!=="edit")return;let c=u=>{var y,x;if(!au(u))return;let m=n(),f=i(),g=m.filter(v=>v.selected);if(!g.length)return;u.preventDefault(),u.stopPropagation();let b=f.filter(v=>g.some(N=>N.id===v.source)&&g.some(N=>N.id===v.target)),h=JSON.stringify({nodes:g,edges:b});(y=u.clipboardData)==null||y.setData(su,h),(x=u.clipboardData)==null||x.setData("text/plain",`BPMN Selection: ${g.length} nodes`)},d=u=>{var I,P;if(!au(u))return;let m=(I=u.clipboardData)==null?void 0:I.getData(su);if(!m)return;u.preventDefault(),u.stopPropagation();let f;try{f=JSON.parse(m)}catch(M){return}if(!((P=f.nodes)!=null&&P.length))return;let g=new Map,b=n(),p=[],h=f.nodes.filter(M=>Ht(M.type,b));if(h.length===0)return;let y=s(),x=h.map(M=>{var G;let V=String(y++);g.set(M.id,V);let C=w(_({},M),{id:V,selected:!0,position:{x:M.position.x+e,y:M.position.y+e}});if(M.type==="TASK"){let K=(G=M.data)==null?void 0:G.label,$=Fo(K||o("bpmn.task.label.prefix"),[...b,...p]);C.data=w(_({},M.data),{label:$})}return p.push(C),C}),v=f.edges.map(M=>w(_({},M),{id:String(y++),selected:!0,source:g.get(M.source)||M.source,target:g.get(M.target)||M.target})),N=[...b.map(M=>w(_({},M),{selected:!1})),...x],E=[...i().map(M=>w(_({},M),{selected:!1})),...v];r(N),a(E),t("forceSave",{nodes:N,edges:E})};return document.addEventListener("copy",c,!0),document.addEventListener("paste",d,!0),()=>{document.removeEventListener("copy",c,!0),document.removeEventListener("paste",d,!0)}},[n,r,i,a,s,e,o,t,l])};import{useTranslation as N0}from"@produto-lecom/lecom-ui";import{useReactFlow as v0}from"@xyflow/react";import{useState as w0}from"react";var I0=50,cu=({nodes:e,setNodes:t,setEdges:o,saveHistory:n})=>{let{draggableNode:r,setDraggableNode:i}=Wo(),{t:a}=N0(),{getInternalNode:s,getNodes:l,getEdges:c,screenToFlowPosition:d}=v0(),{getNextId:u}=st(),{setIsDragging:m}=Z(),{getInternalNodes:f}=Qr(),{rebuildIndex:g,forceRebuildIndex:b}=Ar(),[p,h]=w0(null),y=(S,R,D)=>{var z;if(S.parentId!==R)return null;let A=D.filter(O=>O.id!==S.id&&O.parentId===R&&O.type==="LANE").sort((O,k)=>O.position.y-k.position.y);if(A.length===0)return null;let L=(z=D.find(O=>O.id===S.id))!=null?z:S,B=A.find(O=>L.position.y<O.position.y);return B?{draggedLaneId:S.id,beforeLaneId:B.id}:{draggedLaneId:S.id,afterLaneId:A[A.length-1].id}},x=(S,R=!1,D)=>{let A=R?"node-drop-target-error":"node-drop-target",L=R?"node-drop-target-lane-error":"node-drop-target-lane";t(B=>{var O;let z=(O=D==null?void 0:D(B))!=null?O:null;return B.map(k=>{let F=[];return k.id===S&&F.push(A),S!==void 0&&k.parentId===S&&k.type==="LANE"&&k.id!==(z==null?void 0:z.draggedLaneId)&&F.push(L),k.id===(z==null?void 0:z.draggedLaneId)&&F.push("lane-reorder-dragging"),k.id===(z==null?void 0:z.beforeLaneId)&&F.push("lane-reorder-before"),k.id===(z==null?void 0:z.afterLaneId)&&F.push("lane-reorder-after"),w(_({},k),{className:F.join(" ")})})})},v=(S,R)=>{let D=f();if(S.type==="LANE"){if(R){x();return}let O=D.filter(ee=>ee.id!==S.id&&ee.type==="LANE"&&!ee.parentId),k=on(S,O);if(!k){x();return}if(eo({parentId:k.id,nodes:e,excludeTypes:["LANE"]})){x(k.id,!0);return}x(k.id,!1,ee=>y(S,k.id,ee));return}let L=D.filter(O=>O.id!==S.id&&O.type==="LANE"),B=on(S,L);if(!B){x();return}if(eo({parentId:B.id,nodes:e,includeTypes:["LANE"]})){x();return}x(B.id)},N=S=>{let R=s(S.id),D=S.type==="LANE"&&eo({parentId:S.id,nodes:e,includeTypes:["LANE"]});v(R,D)},T=S=>S.map(R=>w(_({},R),{className:void 0})),E=S=>S.some(D=>D.dragging)?S.map(D=>D.dragging?w(_({},D),{dragging:!1}):D):S,I=(S,R)=>{let D=0;for(let A of R){if(A.id===S||A.parentId||A.type==="LANE")continue;let L=ot(A),B=L.y+L.h;D=Math.max(D,B)}return D+I0},P=(S,R)=>{if(!Vi(S,R))return R;let D=I(S,R);return R.map(A=>A.id===S?w(_({},A),{position:w(_({},A.position),{y:D})}):A)},M=S=>{if(S.preventDefault(),S.dataTransfer.dropEffect="move",!(r!=null&&r.type))return;let R=d({x:S.clientX,y:S.clientY}),D={id:"__sidebar_drag__",type:r.type,position:R,measured:{width:1,height:1},internals:{positionAbsolute:R}};v(D,!1)},V=S=>{let R=S.relatedTarget;(!R||!S.currentTarget.contains(R))&&x()},C=(S,R)=>{S.preventDefault(),N(R)},G=(S,R,D)=>{var F,ee;let A=[...D],L=R.parentId?R.parentId:R.id;if(S.parentId===R.id)return A=Gi(S,R,A),A=It(A),A=to(L,A),T(A);if(S.type==="LANE"){if(eo({parentId:R.id,nodes:A,excludeTypes:["LANE"]})){let X=vr(R),ce=50,ne=50;return A.map(q=>{var xe,W;return q.id===S.id?w(_({},q),{position:{x:(xe=p==null?void 0:p.x)!=null?xe:X.x+ce,y:(W=p==null?void 0:p.y)!=null?W:X.y2+ne}}):q})}let j=A.filter(X=>X.parentId===R.id).reduce((X,ce)=>{var ne,q;return X+((q=(ne=ce.measured)==null?void 0:ne.height)!=null?q:0)},0),oe={x:se.HEADER_WIDTH,y:j};return A=A.map(X=>X.id===S.id?w(_({},X),{parentId:R.id,position:oe,className:void 0}):w(_({},X),{className:void 0})),A=It(A),A=P(L,A),A}if(eo({parentId:R.id,nodes:A,includeTypes:["LANE"]})){let U;if(S.parentId){let Q=s(S.parentId),{x:j,y:oe}=ot(Q);U={x:j+((F=S.position.x)!=null?F:0),y:oe+((ee=S.position.y)!=null?ee:0)}}return A=A.map(Q=>Q.id===S.id?w(_({},Q),{position:U!=null?U:Q.position,parentId:void 0,className:void 0}):w(_({},Q),{className:void 0})),A=to(L,A),A}let O=ra(S,R);A=A.map(U=>U.id===S.id?w(_({},U),{parentId:R.id,position:O,className:void 0}):w(_({},U),{className:void 0}));let k=A.find(U=>U.id===S.id);return A=Gi(k,R,A),A=It(A),A=to(L,A),A},K=S=>{if(S.preventDefault(),!(r!=null&&r.type))return;if(!Ht(r.type,l())){m(!1),i(null);return}let R=d({x:S.clientX,y:S.clientY}),D={width:fe[r.type].MIN_WIDTH,height:fe[r.type].MIN_HEIGHT},A=u(),L={id:String(A),type:r.type,position:R,measured:D,data:{label:r.type==="TASK"?ei(e,a("bpmn.task.label.prefix")):"",variant:r.variant,attribute:r.attribute},selected:!0},B=w(_({},L),{internals:{positionAbsolute:R}}),z=w(_({},B),{measured:{width:1,height:1}}),O=f(),k=r.type==="LANE",F=O.filter(X=>k?X.type==="LANE"&&!X.parentId:X.type==="LANE"),ee=on(z,F),U=[...O.map(X=>w(_({},X),{selected:!1})),B];ee&&(U=G(B,ee,U)),U=jt(U),k&&!ee&&(U=P(B.id,U)),U=T(U),t(U),b();let Q=S.dataTransfer.getData("sourceId"),j=c(),oe=j;if(Q){let X={id:String(A+1),source:Q,target:L.id},ce=r.type==="ANNOTATION"?_(_({},X),Do):_(_({},X),rt);oe=j.concat(ce),o(oe)}n("forceSave",{nodes:U,edges:oe}),m(!1),i(null)},$=async(S,R,D)=>{let A=[...f()],L=new Set;D.forEach(O=>{let k=s(O.id),F=O.type==="LANE",ee=A.filter(Q=>Q.id!==O.id&&(F?Q.type==="LANE"&&!Q.parentId:Q.type==="LANE")),U=on(k,ee);if(U){if(F&&eo({parentId:O.id,nodes:A,includeTypes:["LANE"]})){O.parentId&&(A=Y(O,A),L.add(O.id));return}A=G(k,U,A);return}O.parentId&&(A=Y(O,A),O.type==="LANE"&&L.add(O.id))}),A=E(A);let B=D.filter(O=>O.type==="LANE"&&!O.parentId).map(O=>O.id);for(let O of B)Vi(O,A)&&p&&(A=A.map(k=>k.id===O?w(_({},k),{position:_({},p)}):k));for(let O of L)A=P(O,A);if(D.some(O=>O.type!=="LANE"&&!O.parentId)){let O=A.filter(k=>k.type==="LANE"&&!k.parentId).map(k=>k.id);for(let k of O)A=to(k,A)}A=jt(A),A=T(A),t(A),g(A),h(null)},J=(S,R)=>{h({x:R.position.x,y:R.position.y})},Y=(S,R)=>{var ee,U,Q,j,oe,X,ce,ne;let D=s(S.parentId);if(!D)return R;let A=S.type==="LANE",L=R.filter(q=>q.parentId===D.id&&q.id!==S.id),B=L.filter(q=>q.type==="LANE"),z;if(A&&B.length===0)z=se.MIN_HEIGHT;else if(A){let q=(U=(ee=S.measured)==null?void 0:ee.height)!=null?U:se.MIN_HEIGHT;z=((j=(Q=D.measured)==null?void 0:Q.height)!=null?j:se.MIN_HEIGHT)-q,z=Math.max(se.MIN_HEIGHT,z)}else z=L.length>0?L.reduce((q,xe)=>{var W,ae;return q+((ae=(W=xe.measured)==null?void 0:W.height)!=null?ae:0)},0)+_e:Math.max(se.MIN_HEIGHT,(X=(oe=D.measured)==null?void 0:oe.height)!=null?X:0);let{x:O,y:k}=ot(D),F={x:O+((ce=S.position.x)!=null?ce:0),y:k+((ne=S.position.y)!=null?ne:0)};return R=R.map(q=>q.id===S.id?w(_({},q),{position:F,parentId:void 0}):q.id===D.id?w(_({},q),{height:z,measured:w(_({},q.measured),{height:z})}):q),R=It(R),R};return{onDragOver:M,onDragLeave:V,onDrop:K,onNodeDrag:C,onNodeDragStart:J,onNodeDragStop:$}};import{useReactFlow as A0}from"@xyflow/react";import{useTranslation as C0}from"@produto-lecom/lecom-ui";import{useEffect as S0}from"react";var M0=30,P0=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},L0=e=>!P0(e.target),du=({offset:e=M0,saveHistory:t})=>{let{t:o}=C0(),{getNodes:n,setNodes:r,getEdges:i,setEdges:a}=A0(),{getNextId:s}=st(),{mode:l}=Z();S0(()=>{if(l!=="edit")return;let c=d=>{if(d.ctrlKey&&d.key.toLowerCase()==="d"&&L0(d)){d.preventDefault(),d.stopPropagation();let u=n(),m=i(),f=u.filter(E=>E.selected);if(!f.length)return;let g=new Map,b=[],p=f.filter(E=>Ht(E.type,u));if(p.length===0)return;let h=m.filter(E=>p.some(I=>I.id===E.source)&&p.some(I=>I.id===E.target)),y=s(),x=p.map(E=>{var M;let I=String(y++);g.set(E.id,I);let P=w(_({},E),{id:I,selected:!0,position:{x:E.position.x+e,y:E.position.y+e}});if(E.type==="TASK"){let V=(M=E.data)==null?void 0:M.label,C=Fo(V||o("bpmn.task.label.prefix"),[...u,...b]);P.data=w(_({},E.data),{label:C})}return b.push(P),P}),v=h.map(E=>w(_({},E),{id:String(y++),selected:!0,source:g.get(E.source)||E.source,target:g.get(E.target)||E.target})),N=[...u.map(E=>w(_({},E),{selected:!1})),...x],T=[...m.map(E=>w(_({},E),{selected:!1})),...v];r(N),a(T),t("forceSave",{nodes:N,edges:T})}};return document.addEventListener("keydown",c,!0),()=>{document.removeEventListener("keydown",c,!0)}},[n,r,i,a,s,e,o,t,l])};import{useEffect as k0,useRef as uu}from"react";import{useReactFlow as R0}from"@xyflow/react";var D0=20,O0=50,Rn={UP:"ArrowUp",DOWN:"ArrowDown",LEFT:"ArrowLeft",RIGHT:"ArrowRight"},V0=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},pu=e=>{let{getNodes:t}=R0(),{mode:o,isMoveTool:n}=Z(),r=uu(0),i=uu(new Map);k0(()=>{let a=s=>{if(o!=="edit"||!n||V0(s.target)||!Object.values(Rn).includes(s.key))return;let u=t().filter(y=>y.selected);if(u.length===0){i.current.clear();return}s.preventDefault();let m=Date.now(),f=m-r.current<500;r.current=m;let g=s.shiftKey?O0:D0,b=0,p=0;switch(s.key){case Rn.UP:p=-g;break;case Rn.DOWN:p=g;break;case Rn.LEFT:b=-g;break;case Rn.RIGHT:b=g;break}let h=u.map(y=>{let x=i.current.get(y.id);(!f||!x)&&(x={x:y.position.x,y:y.position.y});let v={x:x.x+b,y:x.y+p};return i.current.set(y.id,v),{id:y.id,dragging:!0,type:"position",position:v}});e&&e(h)};return window.addEventListener("keydown",a),()=>{window.removeEventListener("keydown",a)}},[t,e,o,n])};import{useReactFlow as G0}from"@xyflow/react";var mu={"start-event":"START_EVENT","end-event":"END_EVENT",task:"TASK","gateway-exclusive":"GATEWAY"},gu={"start-event":"","end-event":"",task:"","gateway-exclusive":"EXCLUSIVE"},fu=(e,t)=>{if(!e){console.warn("Step not found");return}e=e.trim();let o=e.match(/(\<.*?\>)/)||[],n=e.match(/(\[.*?\])/)||[],r=e.match(/(\{.*?\})/)||[],i=e.match(/(--.*|\|.*?\|)/i)||[],a="",s="",l="";if(o.length){switch(o[1]){case"<start>":a="start-event";break;case"<end>":a="end-event";break}e=e.replace(o[1],"")}return n.length&&(a="task",s=n[1].replace(/\[|\]/g,""),e=e.replace(n[1],"")),r.length&&(a="gateway-exclusive",s=r[1].replace(/\{|\}/g,""),e=e.replace(r[1],"")),a||(a="task",s=e),i.length&&(l=i[1].replace(/(\||--)/g,""),e=e.replace(i[1],"")),e=e.trim(),t[e]||(t[e]={type:a,label:s}),{step:e,type:a,label:s,edgeLabel:l}},H0=e=>{e=e||"";let t=e.trim().split(`
42
+ `),o={},n=[];return t.forEach(r=>{r=r||"";let i=r.trim().split("-->");if(i.length!==2){console.warn("Invalid number of steps");return}let a=fu(i[0],o),s=fu(i[1],o);a&&s&&n.push({sourceId:a.step,targetId:s.step,label:a.edgeLabel||s.edgeLabel||""})}),{components:o,connections:n}},hu=e=>{let{components:t,connections:o}=H0(e);return{nodes:t,edges:o}};var yu=()=>{let{setNodes:e,setEdges:t,fitView:o}=G0(),{getNextId:n}=st();return{importFromLia:i=>{let a=typeof i=="string"?i:i.diagramXml||"",{nodes:s,edges:l}=hu(a),c=[],d=new Map,u=!1,m=n();for(let[p,h]of Object.entries(s)){let y=String(m++),x=mu[h.type],v=gu[h.type];x==="START_EVENT"&&(u=!0),d.set(p,y);let N=fe[x].MIN_WIDTH,T=fe[x].MIN_HEIGHT;c.push({id:y,type:x,data:{label:h.label||"",variant:v,attribute:""},position:{x:0,y:0},width:N,height:T,measured:{width:N,height:T}})}let f=[];for(let p of l){let h=w(_({},rt),{id:String(m++),source:d.get(p.sourceId)||p.sourceId,target:d.get(p.targetId)||p.targetId});f.push(h)}if(!u&&c.length>0){let p=String(m++),h={id:p,type:"START_EVENT",data:{label:"",variant:"",attribute:""},position:{x:0,y:0},width:fe.START_EVENT.MIN_WIDTH,height:fe.START_EVENT.MIN_HEIGHT,measured:{width:fe.START_EVENT.MIN_WIDTH,height:fe.START_EVENT.MIN_HEIGHT}};c.unshift(h);let y=c[1];if(y){let x=w(_({},rt),{id:String(m++),source:p,target:y.id});f.unshift(x)}}let{nodes:g,edges:b}=qc(c,f);e(g),t(b),o({padding:Uo,minZoom:$o,maxZoom:Ko})}}};import{useEffect as B0,useCallback as z0}from"react";var Y0={origin:"*",debug:!1};function ci(e,t=Y0){let{origin:o,debug:n}=t,r=z0((i,a)=>{let s={event:i,data:[i,{event:i,data:a}]};window.parent.postMessage(s,o||"*")},[o]);return B0(()=>{if(!e)return;let i=a=>{let s=a.data;if(!(s!=null&&s.event)||(s==null?void 0:s.data)===void 0)return;let{event:l,data:c}=s,d;if(Array.isArray(c)){let[,u]=c;d=u.data}else d=c;n&&(console.debug("[postMessage] received:",s),console.debug("[postMessage] eventData:",d)),l&&e[l]&&e[l](d)};return window.addEventListener("message",i),()=>window.removeEventListener("message",i)},[e,n]),{sendMessage:r}}import{useNodesInitialized as F0}from"@xyflow/react";import{useEffect as xu}from"react";var Eu=()=>{let e=F0(),{initialDiagram:t,setIsInitialized:o}=Z(),{importFromMxGraph:n}=qo(),{sendMessage:r}=ci();xu(()=>{t&&n(t)},[t,n]),xu(()=>{if(!e)return;(async()=>{await zn(),o(!0),r("INIT_MODELER",t)})()},[t,e,o,r])};import{useCallback as bu}from"react";import{useReactFlow as X0}from"@xyflow/react";function _u(){let{setTaskStatuses:e,clearTaskStatuses:t,calculateFlowPath:o}=no(),{getEdges:n}=X0(),r=qn(),i=bu(s=>{if(!(s!=null&&s.activities))return;e(s.activities);let l=s.activities.map(d=>d.diagramId),c=n();o(c,l),setTimeout(()=>{r()},0)},[e,o,n,r]),a=bu(()=>{t(),setTimeout(()=>{r()},0)},[t,r]);return{handleTasksStatus:i,handleClearTaskStatus:a}}import{useReactFlow as U0}from"@xyflow/react";import{useCallback as St,useState as $0,useEffect as Tu}from"react";import{useDebouncedCallback as K0}from"use-debounce";var q0=500,Nu=100,vu=(e=!1)=>{let{getNodes:t,getEdges:o,setNodes:n,setEdges:r}=U0(),{mode:i}=Z(),[a,s]=$0({history:[],currentStep:0}),{history:l,currentStep:c}=a,d=c>0,u=c<l.length-1,m=St((T,E)=>{n(T[E].nodes),r(T[E].edges)},[n,r]),f=St(()=>{if(c>0){let T=c-1;s(E=>w(_({},E),{currentStep:T})),m(l,T)}},[c,l,m]),g=St(()=>{if(c<l.length-1){let T=c+1;s(E=>w(_({},E),{currentStep:T})),m(l,T)}},[l,c,m]),b=St(T=>{s(E=>{let I=E.history[E.currentStep];if(I&&JSON.stringify(I)===JSON.stringify(T))return E;let V=[...E.history.slice(0,E.currentStep+1),T],C=V.length>Nu?V.slice(V.length-Nu):V;return{history:C,currentStep:C.length-1}})},[]),p=St((T,E)=>{let I=T.map(M=>w(_({},M),{selected:!1,className:"",data:w(_({},M.data),{hasError:!1})})),P=E.map(M=>w(_({},M),{data:w(_({},M.data),{hasError:!1})}));return{nodes:jt(I),edges:P}},[]),h=St(()=>p(t(),o()),[t,o,p]),y=K0(()=>{let T=h();b(T)},q0),x=St((T,E)=>{if(!e)return;if(l.length===0){let M=h();s({history:[M],currentStep:0})}if(T==="forceSave"){if(E){b(p(E.nodes,E.edges));return}y();return}T.some(M=>M.type==="select")||T.some(M=>M.type==="position"&&M.dragging)||y()},[e,y,l.length,h,b,p]);Tu(()=>{if(e&&l.length===0){let T=h();s({history:[T],currentStep:0})}},[e,l.length,h]);let v=St(T=>{s({history:T||[],currentStep:0})},[]),N=St(()=>{s({history:[],currentStep:0})},[]);return Tu(()=>{if(i!=="edit")return;let T=E=>{(E.ctrlKey||E.metaKey)&&(E.shiftKey&&E.key.toLowerCase()==="z"?(E.preventDefault(),g()):E.key.toLowerCase()==="z"&&(E.preventDefault(),f()))};return document.addEventListener("keydown",T),()=>{document.removeEventListener("keydown",T)}},[f,g,i]),{history:l,undo:f,redo:g,canUndo:d,canRedo:u,saveHistory:x,resetHistory:v,clearHistory:N}};var wu=()=>{let{t:e}=Z0(),[t,o,n]=Q0([]),[r,i,a]=J0([]),{getNodes:s,getNode:l}=ex(),{toast:c}=Fe(),d=tx(),{instanceId:u,isInitialized:m,setIsConnecting:f,setIsMultipleSelection:g,onElementClick:b}=Z(),{updateHelperLines:p,HelperLines:h}=Ar(),{undo:y,redo:x,canUndo:v,canRedo:N,saveHistory:T}=vu(m),{onNodeDrag:E,onDrop:I,onDragOver:P,onDragLeave:M,onNodeDragStop:V,onNodeDragStart:C}=cu({nodes:t,setNodes:o,setEdges:i,saveHistory:T}),{isValidConnection:G,onConnect:K,onReconnect:$,onReconnectStart:J,onReconnectEnd:Y,setReconnectingEdge:S,clearReconnectingEdge:R}=qd({setEdges:i,saveHistory:T}),{handleValidationComplete:D,clearValidation:A,dismissValidationPanel:L,validateDiagram:B,getIsClearingValidation:z}=iu(),{importFromLia:O}=yu(),{handleTasksStatus:k,handleClearTaskStatus:F}=_u(),{getTaskStatus:ee,clearPathEdges:U}=no(),{emitElementChanges:Q,handleNodeChanges:j,handleEdgeChanges:oe}=si(),X=qn();lu({saveHistory:T}),du({saveHistory:T}),Eu();let ce=bt(()=>{o([]),i([]),U(),setTimeout(X,0)},[o,i,U,X]),{selectElements:ne,clearSelection:q}=Gt(),{importFromMxGraph:xe,exportToMxGraph:W}=qo(),{configureElement:ae,getConfigureElement:re}=Dr(),ie=bt(me=>{me!=null&&me.id&&ne([me.id])},[ne]),{sendMessage:ue}=ci({LIA_CREATE_DIAGRAM:O,CLEAR_DIAGRAM:ce,TASKS_STATUS:k,CLEAR_TASKS_STATUS:F,EXTERNAL_TASK_SELECT:ie}),pe=bt(()=>t.length+r.length,[t,r]);ox(()=>(Et.set(u,{importFromMxGraph:xe,exportToMxGraph:W,selectElements:ne,clearSelection:q,configureElement:ae,getConfigureElement:re,getElementsCount:pe,setReconnectingEdge:S,clearReconnectingEdge:R}),()=>{Et.delete(u)}),[u,xe,W,ne,q,ae,re,pe,S,R]);let he=bt((me,ye)=>{if(ye.type!=="TASK"&&ye.type!=="GATEWAY")return;let be=re(ye.id);be&&(b==null||b(be)),ee(ye.id)&&ue("SELECT_TASK",{id:ye.id})},[re,ee,b,ue]),Ne=bt((me,ye)=>{if(ye.type!=="SEQUENCE_EDGE")return;let be=l(ye.source),et=l(ye.target),{isFromStartEvent:Jt,isGatewayToGateway:Qt,isActiviyToAndGateway:ze,isToEndEvent:mt}=Kn(be,et);if(!(!Jt&&!Qt&&!ze&&!mt))return;let Eo=re(ye.id);Eo&&(b==null||b(Eo))},[re,l,b]),ke=bt(me=>{let ye=p(me,t);n(ye),T(me),z()||L(),j(me)},[t,n,T,z,L,p,j]),Ge=bt(me=>{a(me),T(me),z()||L(),oe(me)},[a,T,z,L,oe]);pu(ke);let Ke=bt(({nodes:me,edges:ye})=>{g(me.length+ye.length>=2)},[g]);j0({onChange:Ke});let ft=bt(async({nodes:me})=>me.some(be=>be.type==="LANE"&&t.some(et=>et.parentId===be.id))?(c({variant:"error",title:e("validation.errors.title"),content:e("editor.toolbar.delete_pool_lane_error")}),!1):!0,[t,e,c]),qe=()=>{T("forceSave"),Q(),L()},at=()=>{f(!0)},Be=()=>{f(!1),L()},ve=bt(me=>{let ye=new Set(me.filter(be=>be.type==="LANE"&&!!be.parentId).map(be=>be.parentId));ye.size!==0&&setTimeout(()=>{var Jt,Qt;let be=s(),et=new Map(be.map(ze=>[ze.id,ze]));for(let ze of ye){let mt=oo(be.filter(bo=>bo.type==="LANE"&&bo.parentId===ze));if(mt.length===0)continue;let Pt=0;for(let bo of mt)et.set(bo.id,w(_({},bo),{position:{x:se.HEADER_WIDTH,y:Pt}})),Pt+=(Qt=(Jt=bo.measured)==null?void 0:Jt.height)!=null?Qt:0;let Eo=et.get(ze);Eo&&et.set(ze,w(_({},Eo),{height:Pt,measured:w(_({},Eo.measured),{height:Pt})}))}o(be.map(ze=>{var mt;return(mt=et.get(ze.id))!=null?mt:ze}))},0)},[s,o]);return{nodes:t,setNodes:o,edges:r,setEdges:i,events:{isValidConnection:G,onConnect:K,onReconnect:$,onReconnectStart:J,onReconnectEnd:Y,onDrop:I,onDragOver:P,onDragLeave:M,onNodeDrag:E,onNodeDragStop:V,onNodeDragStart:C,onNodeClick:he,onEdgeClick:Ne,onDropCapture:qe,onConnectStart:at,onConnectEnd:Be,onSelectionEnd:()=>setTimeout(()=>d.setState({nodesSelectionActive:!1}),0),onNodesChange:ke,onEdgesChange:Ge,onBeforeDelete:ft,onNodesDelete:ve},ui:{handleCloseValidationPanel:A},controls:{undo:y,redo:x,canUndo:v,canRedo:N},components:{HelperLines:h},actions:{saveHistory:T,selectElements:ne,clearSelection:q,exportToMxGraph:W,validateDiagram:B,handleValidationComplete:D,setReconnectingEdge:S,clearReconnectingEdge:R}}};import{useReactFlow as nx}from"@xyflow/react";import{useCallback as rx,useEffect as ix,useRef as sx,useState as ax}from"react";var lx=".react-flow__node, .react-flow__edge, .react-flow__node-toolbar";function Iu(e,t,o){let[n,r]=ax(!1),i=sx(null),{getViewport:a,setViewport:s}=nx(),l=rx(()=>{i.current=null,r(!1)},[]);return ix(()=>{let c=e.current;if(!c)return;let d=f=>{if(!Sn.some(b=>b===f.button)||t.current||o.current||(r(!0),!(f.target instanceof Element))||!f.target.closest(lx))return;f.preventDefault(),f.stopPropagation();let g=a();i.current={pointerX:f.clientX,pointerY:f.clientY,viewportX:g.x,viewportY:g.y,zoom:g.zoom}},u=f=>{let g=i.current;if(g){if((f.buttons&vs)===0){l();return}s({x:g.viewportX+(f.clientX-g.pointerX),y:g.viewportY+(f.clientY-g.pointerY),zoom:g.zoom})}},m=f=>{(f.buttons&vs)===0&&l()};return c.addEventListener("pointerdown",d,!0),window.addEventListener("pointermove",u),window.addEventListener("pointerup",m),window.addEventListener("pointercancel",l),window.addEventListener("blur",l),()=>{c.removeEventListener("pointerdown",d,!0),window.removeEventListener("pointermove",u),window.removeEventListener("pointerup",m),window.removeEventListener("pointercancel",l),window.removeEventListener("blur",l)}},[e,t,o,a,s,l]),n}import{jsx as Au}from"react/jsx-runtime";var di=({id:e,className:t})=>Au("marker",{id:e,className:H("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:Au("path",{d:"M 0 0 L 10 5 L 0 10 Z"})});import{jsx as ui,jsxs as cx}from"react/jsx-runtime";var Cu=()=>ui("svg",{style:{position:"absolute",top:0,left:0},children:cx("defs",{children:[ui(di,{id:"sequence-edge-marker",className:"text-grey-500"}),ui(di,{id:"sequence-edge-marker-hovered",className:"text-grey-800"}),ui(di,{id:"sequence-edge-marker-highlighted",className:"text-blue-500"})]})});import{Tooltip as kE,TooltipContent as RE,TooltipTrigger as DE,useTranslation as OE}from"@produto-lecom/lecom-ui";import{useKeyPress as $u,useReactFlow as eE}from"@xyflow/react";import{Button as xi,Tooltip as Ei,TooltipContent as bi,TooltipTrigger as _i,useTranslation as tE}from"@produto-lecom/lecom-ui";import{HandIcon as oE,ListCheckIcon as nE,Loader2Icon as rE,MapIcon as iE,MousePointerIcon as sE}from"lucide-react";import{useCallback as Cs,useEffect as Ku,useState as aE}from"react";import{Tooltip as Sx,TooltipContent as Mx,TooltipTrigger as Px,useTranslation as Lx}from"@produto-lecom/lecom-ui";var Dn=(x=>(x.START_EVENT="START_EVENT",x.END_EVENT="END_EVENT",x.TASK="TASK",x.SUBPROCESS="SUBPROCESS",x.GATEWAY="GATEWAY",x.LANE="LANE",x.ANNOTATION="ANNOTATION",x.CONNECTION="CONNECTION",x.INTERMEDIATE_EVENT="INTERMEDIATE_EVENT",x.ACTIVITY="ACTIVITY",x.PROCESS_INTERFACE="PROCESS_INTERFACE",x.WORKFLOW_INTERFACE="WORKFLOW_INTERFACE",x.VARIANT_ACTIVITY="VARIANT_ACTIVITY",x.AUTO_ACTIVITY="AUTO_ACTIVITY",x.DATA_STORE="DATA_STORE",x.DATA_OBJECT="DATA_OBJECT",x.DATA_OUTPUT="DATA_OUTPUT",x.DATA_INPUT="DATA_INPUT",x.MARKER="MARKER",x))(Dn||{});import{Button as _x,useTranslation as Tx}from"@produto-lecom/lecom-ui";import{useReactFlow as Nx}from"@xyflow/react";var Su=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 Mu({columns:e=[],rows:t=[],fileName:o="report"}){if(!e.length||!t.length)return;let r="data:text/csv;charset=utf-8,"+[e,...t].map(a=>a.join(",")).join(`
43
+ `),i=encodeURI(r);pi(i,`${o}.csv`)}var pi=(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 Pu(e){return e==null?void 0:e.replaceAll("&#xA;"," ")}var YR={START_EVENT:"START_EVENT",END_EVENT:"END_EVENT",TASK:"TASK",GATEWAY:"GATEWAY",ANNOTATION:"ANNOTATION"},Lu={script:"SCRIPT",subprocess:"SUBPROCESS"},ku={"marker-loop":"LOOP"},Ru={complex:"COMPLEX",none:"EXCLUSIVE",exclusive:"EXCLUSIVE",parallel:"PARALLEL",inclusive:"EXCLUSIVE"};var yo=({cell:e,type:t,variant:o="",attribute:n=""})=>{let{_attributes:r,mxGeometry:i}=e,{value:a,parent:s}=r,l=Number(i._attributes.width),c=Number(i._attributes.height),d=s==="1"?void 0:s;return{id:r.id,parentId:d,type:t,data:{label:a||"",variant:o,attribute:n},position:{x:Number(i._attributes.x)||0,y:Number(i._attributes.y)||0},width:l,height:c,measured:{width:l,height:c}}},ux=e=>{let{subType:t,style:o}=e._attributes,n="imported";return["none"].includes(t)||(n="adapted"),e.mxGeometry._attributes.width=fe.START_EVENT.MIN_WIDTH,e.mxGeometry._attributes.height=fe.START_EVENT.MIN_HEIGHT,{node:yo({cell:e,type:"START_EVENT"}),status:n,originalType:o}},px=e=>{let{subType:t,style:o}=e==null?void 0:e._attributes,n="imported";return["none"].includes(t)||(n="adapted"),e.mxGeometry._attributes.width=fe.END_EVENT.MIN_WIDTH,e.mxGeometry._attributes.height=fe.END_EVENT.MIN_HEIGHT,{node:yo({cell:e,type:"END_EVENT"}),status:n,originalType:o}},fx=(e,t)=>{let{id:o,subType:n,style:r}=e==null?void 0:e._attributes,i=Lu[n],a=t.get(o)||"",s=ku[a]||"",l=s==="LOOP",c="imported";return!["script","none"].includes(n)&&!l&&(c="adapted"),e.mxGeometry._attributes.width=Lt(e.mxGeometry._attributes.width||0,fe.TASK.MIN_WIDTH),e.mxGeometry._attributes.height=Lt(e.mxGeometry._attributes.height||0,fe.TASK.MIN_HEIGHT),{node:yo({cell:e,type:"TASK",variant:i,attribute:s}),status:c,originalType:r}},mx=e=>{let{style:t,subType:o}=e==null?void 0:e._attributes,n=Ru[o],r=["none","inclusive","event-based"],i="imported";return r.includes(o)&&(i="adapted"),e.mxGeometry._attributes.width=fe.GATEWAY.MIN_WIDTH,e.mxGeometry._attributes.height=fe.GATEWAY.MIN_HEIGHT,{node:yo({cell:e,type:"GATEWAY",variant:n}),status:i,originalType:t}},gx=e=>{let{style:t}=e==null?void 0:e._attributes;return{node:yo({cell:e,type:"LANE"}),status:"imported",originalType:t}},hx=e=>{let{style:t}=e==null?void 0:e._attributes;return e.mxGeometry._attributes.width=Lt(e.mxGeometry._attributes.width||0,fe.ANNOTATION.MIN_WIDTH),e.mxGeometry._attributes.height=Lt(e.mxGeometry._attributes.height||0,fe.ANNOTATION.MIN_HEIGHT),{node:yo({cell:e,type:"ANNOTATION"}),status:"imported",originalType:t}},Du=e=>{let{style:t}=e==null?void 0:e._attributes;return e.mxGeometry._attributes.width=fe.UNSUPPORTED.MIN_WIDTH,e.mxGeometry._attributes.height=fe.UNSUPPORTED.MIN_HEIGHT,{node:yo({cell:e,type:"UNSUPPORTED"}),status:"unsupported",originalType:t}},Ou=(e,t)=>{let{id:o,source:n,target:r,value:i}=e._attributes;return w(_({},rt),{id:o,source:t.get(n)||n,target:t.get(r)||r,data:{label:i||""}})},Vu={TASK:fx,GATEWAY:mx,START_EVENT:ux,END_EVENT:px,LANE:gx,ANNOTATION:hx};var yx=e=>{let t=new Map,o=Object.values(Dn),n=[],r=new Map;e.forEach(s=>{var c;let l=(c=s._attributes)==null?void 0:c.type;if(l==="MARKER"){r.set(s._attributes.parent,s._attributes.style);return}if(o.includes(l)){n.push(s);return}});let i=[],a=[];for(let s of n){let{type:l}=s._attributes,c=Vu[l]||Du,{node:d,status:u,originalType:m}=c(s,r);a.push(d),i.push({originalType:m,type:d.type,variant:d.data.variant,value:Pu(d.data.label),status:u})}return{nodes:a,governanceIdToNodeIdMap:t,summary:i}},xx=(e,t)=>e.filter(r=>{var i;return(i=r._attributes)==null?void 0:i.edge}).map(r=>Ou(r,t)),Ex=e=>{let{mxGraphModel:t}=e,{nodes:o,governanceIdToNodeIdMap:n,summary:r}=yx(t.root.mxCell),i=xx(t.root.mxCell,n);return{nodes:o,edges:i,summary:r}},bx=async e=>{let t=await Su(e),o=Zr(t);if(!o)throw new Error("EMPTY_FILE");let{metadata:n,mxGraphModel:r}=o.modeler||{},i=(n==null?void 0:n.app)&&(n==null?void 0:n.diagramType)&&(n==null?void 0:n.version),a=r==null?void 0:r.root;if(!i||!a)throw new Error("INVALID_FILE");if(!Object.keys(r.root.mxCell||{}).length)throw new Error("CONTAIN_NO_CELLS");return{metadata:n,mxGraphModel:r}},Hu=async e=>{try{let t=await bx(e),{nodes:o,edges:n,summary:r}=Ex(t)||{};return{nodes:o,edges:n,summary:r}}catch(t){throw t}};import{jsx as vx}from"react/jsx-runtime";var Gu=()=>{let{t:e}=Tx(),{toast:t}=Fe(),{setNodes:o,setEdges:n,fitView:r}=Nx(),i=s=>{let l=[e("adapter.governance.report.columns.type"),e("adapter.governance.report.columns.value"),e("adapter.governance.report.columns.status")],c=s.map(d=>[d.originalType,d.value,e(`adapter.governance.report.status.${d.status.toLowerCase()}`)]);t({variant:"warning",content:e("adapter.governance.success.incompatible_cells"),duration:1e3*60*1,action:vx(_x,{size:"small",variant:"ghost",onClick:()=>Mu({columns:l,rows:c,fileName:"governance-imported-cells"}),children:e("adapter.governance.action.download")})})};return{importFromGovernance:async s=>{try{let{nodes:l,edges:c,summary:d}=await Hu(s);if(o(m=>m.concat(l)),n(m=>m.concat(c)),r({padding:Uo,minZoom:$o,maxZoom:Ko}),d.some(m=>m.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 wx}from"@produto-lecom/lecom-ui";import{useRef as Ix}from"react";import{Fragment as Ax,jsx as Bu,jsxs as Cx}from"react/jsx-runtime";var zu=s=>{var l=s,{children:e,accept:t="*",multiple:o=!1,disabled:n=!1,onClick:r,onFilesSelected:i}=l,a=gt(l,["children","accept","multiple","disabled","onClick","onFilesSelected"]);let c=Ix(null),d=m=>{let f=m.target.files;f!=null&&f.length&&i(f),c.current&&(c.current.value="")};return Cx(Ax,{children:[Bu(wx,w(_({disabled:n,onClick:m=>{var f;(f=c.current)==null||f.click(),r==null||r(m)}},a),{children:e})),Bu("input",{type:"file",ref:c,className:"sr-only",accept:t,multiple:o,disabled:n,onChange:d})]})};import{jsx as fi,jsxs as kx}from"react/jsx-runtime";var Yu=({disabled:e=!1})=>{let{t}=Lx(),{toast:o}=Fe(),{importFromGovernance:n}=Gu(),r=()=>{if(e){o({variant:"error",content:t("adapter.governance.error.ALREADY_INITIALIZED")});return}},i=a=>{let s=a[0];if(!s){o({variant:"error",content:t("adapter.governance.error.NO_FILE")});return}n(s)};return kx(Sx,{children:[fi(Px,{asChild:!0,children:fi(zu,{className:"[&>svg]:size-7 p-0",variant:"ghost",size:"small",color:"grey",iconButton:!0,accept:".mdr",disabled:e,onClick:r,onFilesSelected:i,children:fi(Xs,{})})}),fi(Mx,{color:"black",children:t("editor.controls.actions.import_governance")})]})};import{jsx as Rx}from"react/jsx-runtime";var ws=({shortcut:e})=>Rx("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 Fx,DropdownMenu as Xx,DropdownMenuContent as Ux,DropdownMenuItem as As,DropdownMenuTrigger as $x,Tooltip as gi,TooltipContent as hi,TooltipTrigger as yi,useTranslation as Kx}from"@produto-lecom/lecom-ui";import{FileCodeIcon as qx,FileImageIcon as Zx,FolderOutputIcon as Jx,PrinterIcon as Qx}from"lucide-react";import{useState as jx}from"react";import{useTranslation as Dx}from"@produto-lecom/lecom-ui";import{useReactFlow as Ox}from"@xyflow/react";import{toPng as Wu,toSvg as Vx}from"html-to-image";import{useState as Hx}from"react";var Gx=3,Is="diagram",mi=50,Bx=96,zx=25.4,Yx="sequence-edge-marker",Fu=e=>e*zx/Bx,Wx=e=>{let t=document.getElementById(Yx);if(!(t instanceof SVGElement)||!t.ownerSVGElement)return null;let n=t.ownerSVGElement.cloneNode(!0);return n.style.position="absolute",n.style.width="0",n.style.height="0",n.style.overflow="hidden",n.setAttribute("aria-hidden","true"),n.setAttribute("data-export-marker-defs","true"),e.prepend(n),n},Xu=()=>{let{t:e}=Dx(),{toast:t}=Fe(),{getEdges:o,getNodes:n,getNodesBounds:r}=Ox(),{clearSelection:i}=Gt(),[a,s]=Hx({png:!1,html:!1,print:!1}),l=()=>{let f=us(n(),o()),g=r(f),b=g.width+mi*2,p=g.height+mi*2,h=mi-g.x,y=mi-g.y;return{width:b,height:p,style:{width:`${b}px`,height:`${p}px`,transform:`translate(${h}px, ${y}px)`,transformOrigin:"top left"}}},c=async(f,g)=>{s(b=>w(_({},b),{[g]:!0})),await i();try{if(us(n(),o()).length===0){t({content:e("editor.controls.actions.export.feedback.empty"),variant:"warning"});return}let p=Jc();if(!p)throw new Error("Flow element not found");let h=l(),y=Wx(p);try{return await f(p,h)}finally{y==null||y.remove()}}catch(b){console.error("Diagram export failed",b),t({content:e("editor.controls.actions.export.feedback.error"),variant:"error"})}finally{s(b=>w(_({},b),{[g]:!1}))}};return{exportAsPng:async(f=Is)=>{await c(async(g,b)=>{let p=await Wu(g,w(_({},b),{backgroundColor:"#fcfcfc",skipFonts:!0}));pi(p,`${f}.png`)},"png")},exportAsHtml:async(f=Is)=>{await c(async(g,b)=>{let p=await Vx(g,w(_({},b),{backgroundColor:"#fcfcfc",skipFonts:!0})),h=`
44
44
  <!DOCTYPE html>
45
45
  <html>
46
46
  <head>
47
47
  <meta charset="utf-8" />
48
- <title>${m}</title>
48
+ <title>${f}</title>
49
49
  <style>
50
50
  html, body {
51
51
  margin: 0;
@@ -65,11 +65,11 @@ var sp=Object.defineProperty,ap=Object.defineProperties;var lp=Object.getOwnProp
65
65
  </style>
66
66
  </head>
67
67
  <body>
68
- <img src="${E}" alt="${m}" />
68
+ <img src="${p}" alt="${f}" />
69
69
  </body>
70
- </html>`,h=new Blob([f],{type:"text/html"}),y=URL.createObjectURL(h);ai(y,`${m}.html`),window.setTimeout(()=>URL.revokeObjectURL(y),1e4)},"html")},printDiagram:async(m=Ns)=>{await l(async(u,g)=>{var I;let E=await zu(u,w(b({},g),{backgroundColor:"#fcfcfc",pixelRatio:Lx,skipFonts:!0})),f=document.createElement("iframe");f.style.position="fixed",f.style.right="0",f.style.bottom="0",f.style.width="0",f.style.height="0",f.style.border="0",document.body.appendChild(f);let h=(I=f.contentWindow)==null?void 0:I.document;if(!h)throw document.body.removeChild(f),new Error("Unable to access print iframe document");let y=Yu(g.width).toFixed(2),x=Yu(g.height).toFixed(2),v=h.createElement("style");v.textContent=`
70
+ </html>`,y=new Blob([h],{type:"text/html"}),x=URL.createObjectURL(y);pi(x,`${f}.html`),window.setTimeout(()=>URL.revokeObjectURL(x),1e4)},"html")},printDiagram:async(f=Is)=>{await c(async(g,b)=>{var P;let p=await Wu(g,w(_({},b),{backgroundColor:"#fcfcfc",pixelRatio:Gx,skipFonts:!0})),h=document.createElement("iframe");h.style.position="fixed",h.style.right="0",h.style.bottom="0",h.style.width="0",h.style.height="0",h.style.border="0",document.body.appendChild(h);let y=(P=h.contentWindow)==null?void 0:P.document;if(!y)throw document.body.removeChild(h),new Error("Unable to access print iframe document");let x=Fu(b.width).toFixed(2),v=Fu(b.height).toFixed(2),N=y.createElement("style");N.textContent=`
71
71
  @page {
72
- size: ${y}mm ${x}mm;
72
+ size: ${x}mm ${v}mm;
73
73
  margin: 0;
74
74
  }
75
75
  html, body {
@@ -83,4 +83,4 @@ var sp=Object.defineProperty,ap=Object.defineProperties;var lp=Object.getOwnProp
83
83
  height: 100%;
84
84
  object-fit: contain;
85
85
  }
86
- `,h.head.appendChild(v),h.title=m;let N=h.createElement("img");N.alt="Diagram",h.body.appendChild(N),await new Promise((S,P)=>{let R=!1,M=B=>{R||(R=!0,B?P(B):S())};N.onload=()=>M(),N.onerror=()=>M(new Error("Failed to load print image")),N.src=E,N.complete&&N.naturalWidth>0&&M()});let T=f.contentWindow;if(!T)throw document.body.removeChild(f),new Error("Unable to access print iframe window");let _=()=>{f.parentNode&&document.body.removeChild(f)};T.addEventListener("afterprint",_,{once:!0}),window.setTimeout(_,6e4),T.focus(),T.print()},"print")},isPrintingPng:i.png,isPrintingHtml:i.html,isPrinting:i.print}};import{jsx as Pe,jsxs as $o}from"react/jsx-runtime";function Fu(){let{t:e}=Gx(),{exportAsPng:t,exportAsHtml:o,printDiagram:n,isPrinting:r,isPrintingPng:i,isPrintingHtml:a}=Wu(),[s,l]=Fx(!1);return $o(Ox,{modal:!1,open:s,onOpenChange:l,children:[Pe(Hx,{asChild:!0,children:Pe("div",{children:$o(di,{children:[Pe(pi,{asChild:!0,children:Pe(Dx,{size:"small",variant:"ghost",color:"grey",iconButton:!0,children:Pe(Yx,{})})}),!s&&Pe(ui,{color:"black",children:e("editor.controls.actions.export.title")})]})})}),$o(Vx,{align:"center",side:"top",sideOffset:16,className:"min-w-0 flex flex-col gap-2 p-2 shadow-sm",children:[$o(di,{children:[Pe(pi,{asChild:!0,children:Pe(Ts,{className:"p-1.5",disabled:i,onClick:()=>t(),children:Pe(zx,{})})}),Pe(ui,{side:"right",color:"black",children:e("editor.controls.actions.export.png")})]}),$o(di,{children:[Pe(pi,{asChild:!0,children:Pe(Ts,{className:"p-1.5",disabled:a,onClick:()=>o(),children:Pe(Bx,{})})}),Pe(ui,{side:"right",color:"black",children:e("editor.controls.actions.export.html")})]}),$o(di,{children:[Pe(pi,{asChild:!0,children:Pe(Ts,{className:"p-1.5",disabled:r,onClick:()=>n(),children:Pe(Wx,{})})}),Pe(ui,{side:"right",color:"black",children:e("editor.controls.actions.export.print")})]})]})]})}import{Fragment as $u,jsx as Me,jsxs as Pt}from"react/jsx-runtime";var Ku=({nodes:e,edges:t,validateDiagram:o,handleValidationComplete:n})=>{let{t:r}=Ux(),{clearSelection:i}=Bt(),{mode:a,isMinimapOpen:s,setIsMinimapOpen:l,isMoveTool:c,isHandTool:d,setIsMoveTool:p,setIsHandTool:m}=$(),{getNodes:u,getEdges:g}=Xx(),E=Xu(["v","V"]),f=Xu(["h","H"]),h=vs(()=>{i(),m(!0),p(!1)},[i,m,p]),y=vs(()=>{p(!0),m(!1)},[p,m]),[x,v]=Qx(!1),N=vs(async()=>{v(!0);try{let T=u(),_=g(),I=await o({nodes:T,edges:_});n(I)}finally{v(!1)}},[u,g,o,n]);return Uu(()=>{E&&!c&&a==="edit"&&y()},[E,y,c,a]),Uu(()=>{f&&!d&&a==="edit"&&h()},[f,h,d,a]),Pt("div",{className:"flex items-center gap-2 px-3 py-2 bg-white rounded-sm shadow-md",children:[a==="edit"&&Pt($u,{children:[Pt(mi,{children:[Me(hi,{asChild:!0,children:Me(fi,{size:"small",variant:"ghost",color:"grey",className:H(c&&"bg-grey-400"),iconButton:!0,onClick:y,children:Me(Jx,{})})}),Pt(gi,{color:"black",className:"flex items-center gap-2",children:[r("editor.controls.actions.move_tool"),Me(_s,{shortcut:"V"})]})]}),Pt(mi,{children:[Me(hi,{asChild:!0,children:Me(fi,{size:"small",variant:"ghost",color:"grey",className:H(d&&"bg-grey-400"),iconButton:!0,onClick:h,children:Me($x,{})})}),Pt(gi,{color:"black",className:"flex items-center gap-2",children:[r("editor.controls.actions.hand_tool")," ",Me(_s,{shortcut:"H"})]})]})]}),Me(Fu,{}),a==="edit"&&Pt($u,{children:[Pt(mi,{children:[Me(hi,{asChild:!0,children:Me(fi,{size:"small",variant:"ghost",color:"grey",iconButton:!0,disabled:x,onClick:N,children:x?Me(qx,{className:"animate-spin"}):Me(Kx,{})})}),Me(gi,{color:"black",children:r(x?"editor.controls.actions.check_loading":"editor.controls.actions.check")})]}),Me(Bu,{disabled:e.length>0||t.length>0})]}),Pt(mi,{children:[Me(hi,{asChild:!0,children:Me(fi,{size:"small",variant:"ghost",color:"grey",className:H(s&&"bg-grey-400"),iconButton:!0,onClick:()=>l(!s),children:Me(Zx,{})})}),Me(gi,{color:"black",children:r(s?"editor.controls.actions.minimap.close":"editor.controls.actions.minimap.open")})]})]})};import{Button as qu,Tooltip as Zu,TooltipContent as Ju,TooltipTrigger as Qu,useTranslation as jx}from"@produto-lecom/lecom-ui";import{RedoIcon as eE,UndoIcon as tE}from"lucide-react";import{jsx as Jt,jsxs as ws}from"react/jsx-runtime";var ju=({undo:e,redo:t,canUndo:o,canRedo:n})=>{let{t:r}=jx();return ws("div",{className:"flex items-center gap-2 px-3 py-2 bg-white rounded-sm shadow-md",children:[ws(Zu,{children:[Jt(Qu,{asChild:!0,children:Jt(qu,{size:"small",variant:"ghost",color:"grey",iconButton:!0,disabled:!o,onClick:e,children:Jt(tE,{})})}),Jt(Ju,{color:"black",children:r("editor.controls.history.undo")})]}),ws(Zu,{children:[Jt(Qu,{asChild:!0,children:Jt(qu,{size:"small",variant:"ghost",color:"grey",iconButton:!0,disabled:!n,onClick:t,children:Jt(eE,{})})}),Jt(Ju,{color:"black",children:r("editor.controls.history.redo")})]})]})};import{useEdges as oE,useNodes as nE,useReactFlow as rE}from"@xyflow/react";import{Button as yi,Tooltip as xi,TooltipContent as Ei,TooltipTrigger as bi,useTranslation as iE}from"@produto-lecom/lecom-ui";import{ScanIcon as sE,ZoomIn as aE,ZoomOut as lE}from"lucide-react";import{jsx as De,jsxs as kn}from"react/jsx-runtime";var ep=()=>{let{t:e}=iE(),t=nE(),o=oE(),{zoomIn:n,zoomOut:r,zoomTo:i,fitView:a}=rE(),s=t.length===0&&o.length===0;return kn("div",{className:"flex items-center gap-2 px-3 py-2 bg-white rounded-sm shadow-md",children:[kn(xi,{children:[De(bi,{asChild:!0,children:De(yi,{iconButton:!0,size:"small",color:"grey",variant:"ghost",disabled:s,onClick:()=>a(),children:De(sE,{})})}),De(Ei,{color:"black",children:e("editor.controls.zoom.fit")})]}),kn(xi,{children:[De(bi,{asChild:!0,children:De(yi,{iconButton:!0,size:"small",color:"grey",variant:"ghost",disabled:s,onClick:()=>r(),children:De(lE,{})})}),De(Ei,{color:"black",children:e("editor.controls.zoom.out")})]}),kn(xi,{children:[De(bi,{asChild:!0,children:De(yi,{iconButton:!0,size:"small",color:"grey",variant:"ghost",disabled:s,onClick:()=>i(1),children:De(Xs,{})})}),De(Ei,{color:"black",children:e("editor.controls.zoom.reset")})]}),kn(xi,{children:[De(bi,{asChild:!0,children:De(yi,{iconButton:!0,size:"small",color:"grey",variant:"ghost",disabled:s,onClick:()=>n(),children:De(aE,{})})}),De(Ei,{color:"black",children:e("editor.controls.zoom.in")})]})]})};import{useNodes as cE}from"@xyflow/react";import{Button as dE,Tooltip as uE,TooltipContent as pE,TooltipTrigger as fE,useTranslation as mE}from"@produto-lecom/lecom-ui";import{useRef as gE,useState as hE}from"react";import{jsx as yo,jsxs as tp}from"react/jsx-runtime";var op=()=>{let e=gE(null),{t}=mE(),{setDraggableNode:o}=Bo(),n=cE(),{setIsDragging:r}=$(),[i,a]=hE(void 0),s=[{type:"START_EVENT",icon:Gn,label:t("bpmn.start_event.variant.default")},{type:"END_EVENT",icon:xo,label:t("bpmn.end_event.variant.default")},{type:"TASK",icon:qo,label:t("bpmn.task.variant.default")},{type:"TASK",variant:"SUBPROCESS",icon:Jo,label:t("bpmn.task.variant.subprocess")},{type:"TASK",variant:"SCRIPT",icon:qs,label:t("bpmn.task.variant.script")},{type:"TASK",attribute:"LOOP",icon:Ks,label:t("bpmn.task.attribute.loop")},{type:"GATEWAY",variant:"EXCLUSIVE",icon:bo,label:t("bpmn.gateway.variant.exclusive")},{type:"GATEWAY",variant:"PARALLEL",icon:_o,label:t("bpmn.gateway.variant.parallel")},{type:"GATEWAY",variant:"COMPLEX",icon:Eo,label:t("bpmn.gateway.variant.complex")},{type:"LANE",icon:Fs,label:t("bpmn.lane.variant.default")},{type:"ANNOTATION",icon:Vn,label:t("bpmn.annotation.variant.default")}],l=(c,d)=>{o({type:d.type,variant:d.variant,attribute:d.attribute,icon:d.icon}),a(yo(d.icon,{})),c.dataTransfer.effectAllowed="move",e.current&&c.dataTransfer.setDragImage(e.current,10,10),setTimeout(()=>{r(!0)},100)};return tp("aside",{className:"sidebar absolute z-[1] top-4 left-4",children:[yo("div",{className:"grid grid-cols-1 gap-2 p-2 bg-white rounded-md shadow-md",children:s.map((c,d)=>{let p=!Gt(c.type,n),m=p?t("editor.toolbar.start_event_already_exists"):c.label;return tp(uE,{children:[yo(fE,{asChild:!0,children:yo(dE,{className:H("[&>svg]:size-6",{"opacity-50 cursor-not-allowed":p}),size:"small",variant:"ghost",color:"grey",draggable:!p,disabled:p,iconButton:!0,onDragStart:p?void 0:u=>l(u,c),children:yo(c.icon,{})},d)}),yo(pE,{color:"black",side:"right",children:m})]},d)})}),yo("div",{ref:e,className:"absolute w-0 h-0 top-0 left-0 z-[-1] bg-transparent",children:i})]})};import{jsx as dt,jsxs as _i}from"react/jsx-runtime";var As=e=>e.preventDefault(),Cs=NE((e,t)=>{let o=_E("Space"),{instanceId:n,mode:r,isMinimapOpen:i,isMoveTool:a,isHandTool:s}=$(),l=Is(null),c=Is(s),d=Is(o),{nodes:p,edges:m,actions:u,events:g,components:E,controls:f}=Tu(),{t:h}=AE();c.current=s,d.current=o;let y=vu(l,c,d);TE(t,()=>({selectElements:u.selectElements,clearSelection:u.clearSelection}));let x=s||o||r!=="edit",v=x?[0,1,2]:In,N=s||o||y,T=a&&!o&&!y,_=r==="edit"&&T,I=!x&&!y,S=r==="view"||T;return _i("div",{ref:l,className:"w-full h-full",children:[r==="edit"&&dt(op,{}),dt(Iu,{}),_i(EE,w(b({},g),{id:`modeler-${n}`,className:H({"is-hand-tool":N,"is-pan-tool-active":N}),edges:m,nodes:p,nodeTypes:kd,edgeTypes:Rd,minZoom:Es,maxZoom:Bd,panOnDrag:v,panOnScroll:!0,selectionOnDrag:I,elevateEdgesOnSelect:!0,elevateNodesOnSelect:!0,elementsSelectable:S,nodesConnectable:_,nodesDraggable:_,connectionLineComponent:Md,selectionMode:bE.Partial,multiSelectionKeyCode:["Control","Meta"],deleteKeyCode:_?"Delete":null,selectionKeyCode:null,defaultViewport:zd,connectOnClick:!1,connectionRadius:50,onPaneContextMenu:As,onNodeContextMenu:As,onEdgeContextMenu:As,proOptions:{hideAttribution:!0},children:[dt(yE,{gap:Hd,size:Vd,color:Od,bgColor:Dd}),i&&_i(vE,{children:[dt(IE,{asChild:!0,children:dt("div",{className:"absolute bottom-[0px] left-[0px] z-[5]",children:dt(xE,{pannable:!0,zoomable:!0,position:Gd,className:"shadow-md rounded-md",ariaLabel:"",style:{pointerEvents:"all",position:"relative"}})})}),dt(wE,{color:"black",children:h("editor.controls.actions.minimap.label")})]}),_i("div",{className:"absolute z-10 bottom-4 left-1/2 -translate-x-1/2 flex gap-4",children:[r==="edit"&&dt(ju,b({},f)),dt(Ku,{nodes:p,edges:m,validateDiagram:u.validateDiagram,handleValidationComplete:u.handleValidationComplete}),dt(ep,{})]}),dt(E.HelperLines,{})]}))]})});Cs.displayName="Editor";import{useStore as CE}from"@xyflow/react";import{useEffect as SE,useRef as ME}from"react";import{jsx as LE}from"react/jsx-runtime";var PE=e=>({width:e.width,height:e.height,transform:e.transform}),Ss="rgba(51, 103, 217, 0.4)",oc=({horizontal:e,vertical:t})=>{let{width:o,height:n,transform:r}=CE(PE),i=ME(null);return SE(()=>{let a=i.current,s=a==null?void 0:a.getContext("2d");if(!s||!a)return;let l=window.devicePixelRatio;a.width=o*l,a.height=n*l,s.clearRect(0,0,o,n),s.scale(l,l),s.strokeStyle=Ss,t&&(s.beginPath(),s.strokeStyle=t.color||Ss,s.moveTo(t.position*r[2]+r[0],0),s.lineTo(t.position*r[2]+r[0],n),s.stroke()),e&&(s.beginPath(),s.strokeStyle=e.color||Ss,s.moveTo(0,e.position*r[2]+r[1]),s.lineTo(o,e.position*r[2]+r[1]),s.stroke())},[o,n,r,e,t]),LE("canvas",{ref:i,className:"w-full h-full absolute z-10 pointer-events-none"})};import{i18n as kE,Notification as RE,TooltipProvider as DE}from"@produto-lecom/lecom-ui";import{createContext as OE,useContext as VE,useEffect as HE,useState as GE}from"react";import{jsx as np,jsxs as zE}from"react/jsx-runtime";var xt=new Map,rp=OE(null),xn=()=>{let e=VE(rp);if(!e)throw new Error("useModeler must be used within an <ModelerProvider />");return e},BE=({locale:e,defaultMode:t="view",toast:o,children:n})=>{let[r,i]=GE(e||"pt_BR");HE(()=>{e&&(i(e),kE.changeLanguage(e))},[e]);let a=g=>{let E=xt.size;if(E===0)throw new Error("No modeler instances found");if(E===1||!g){let[h]=xt.values();return h}let f=xt.get(g);if(!f)throw new Error(`Modeler instance with ID "${g}" not found`);return f},s=(g,E)=>{let f=a(E);return f==null?void 0:f.selectElements(g)},l=async g=>{let E=a(g);return E==null?void 0:E.clearSelection()},c=(g,E)=>{let f=a(E);return f==null?void 0:f.configureElement(g)},d=(g,E)=>{let f=a(E);return f==null?void 0:f.getConfigureElement(g)},p=async(g,E)=>{let f=a(E);await(f==null?void 0:f.importFromMxGraph(g))},m=g=>{let E=a(g);return E==null?void 0:E.exportToMxGraph()},u=g=>{let E=a(g);return(E==null?void 0:E.getElementsCount())||0};return np(rp.Provider,{value:{defaultMode:t,locale:r,selectElements:s,clearSelection:l,configureElement:c,getConfigureElement:d,importDiagram:p,exportDiagram:m,getElementsCount:u,toast:o},children:zE(DE,{children:[!o&&np(RE,{type:"toast",placement:"topRight",enableClose:!0,showProgress:!0,pauseOnHover:!0}),n]})})};import{jsx as Ms}from"react/jsx-runtime";var ip=FE(null),$=()=>{let e=XE(ip);if(!e)throw new Error("useModelerInstance must be used within an <Modeler />");return e},qE=({selectorRef:e,initialDiagram:t,instanceId:o,mode:n,validateCustomDiagram:r,onElementChanges:i,onConfigureElement:a,onElementClick:s,onSubprocessValidationClick:l})=>{let{t:c}=YE(),{defaultMode:d}=xn(),p=$E(),[m]=ut(o||p),[u,g]=ut(n||d||"edit"),[E,f]=ut(Nn),[h,y]=ut(!1),[x,v]=ut(!0),[N,T]=ut(!1),[_,I]=ut(!1),[S,P]=ut(!1),[R,M]=ut(!1),[B,X]=ut(!1),[U,Q]=ut(null);UE(()=>{n&&g(n)},[n]);let Y=KE(()=>t||qc(c),[t,c]),C={instanceId:m,initialDiagram:Y,mode:u,lastElementId:E,isInitialized:h,isMinimapOpen:_,isMoveTool:x,isHandTool:N,isDragging:S,isMultipleSelection:B,isConnecting:R,setLastElementId:f,setIsInitialized:y,reconnectingEdgeId:U,setIsMinimapOpen:I,setIsMoveTool:v,setIsHandTool:T,setIsDragging:P,setIsConnecting:M,setIsMultipleSelection:X,setReconnectingEdgeId:Q,validateCustomDiagram:r,onElementChanges:i,onConfigureElement:a,onElementClick:s,onSubprocessValidationClick:l};return Ms(WE,{children:Ms(ip.Provider,{value:C,children:Ms(Cs,{ref:e})})})};export{we as EditorMode,Ti as ElementPosition,Dn as ElementType,vi as GatewayElementVariant,at as GatewayVariant,qE as Modeler,BE as ModelerProvider,gt as NodeAttribute,se as NodeType,tt as NodeVariant,wi as RoutingVariant,xn as useModeler};
86
+ `,y.head.appendChild(N),y.title=f;let T=y.createElement("img");T.alt="Diagram",y.body.appendChild(T),await new Promise((M,V)=>{let C=!1,G=K=>{C||(C=!0,K?V(K):M())};T.onload=()=>G(),T.onerror=()=>G(new Error("Failed to load print image")),T.src=p,T.complete&&T.naturalWidth>0&&G()});let E=h.contentWindow;if(!E)throw document.body.removeChild(h),new Error("Unable to access print iframe window");let I=()=>{h.parentNode&&document.body.removeChild(h)};E.addEventListener("afterprint",I,{once:!0}),window.setTimeout(I,6e4),E.focus(),E.print()},"print")},isPrintingPng:a.png,isPrintingHtml:a.html,isPrinting:a.print}};import{jsx as Pe,jsxs as Zo}from"react/jsx-runtime";function Uu(){let{t:e}=Kx(),{exportAsPng:t,exportAsHtml:o,printDiagram:n,isPrinting:r,isPrintingPng:i,isPrintingHtml:a}=Xu(),[s,l]=jx(!1);return Zo(Xx,{modal:!1,open:s,onOpenChange:l,children:[Pe($x,{asChild:!0,children:Pe("div",{children:Zo(gi,{children:[Pe(yi,{asChild:!0,children:Pe(Fx,{size:"small",variant:"ghost",color:"grey",iconButton:!0,children:Pe(Jx,{})})}),!s&&Pe(hi,{color:"black",children:e("editor.controls.actions.export.title")})]})})}),Zo(Ux,{align:"center",side:"top",sideOffset:16,className:"min-w-0 flex flex-col gap-2 p-2 shadow-sm",children:[Zo(gi,{children:[Pe(yi,{asChild:!0,children:Pe(As,{className:"p-1.5",disabled:i,onClick:()=>t(),children:Pe(Zx,{})})}),Pe(hi,{side:"right",color:"black",children:e("editor.controls.actions.export.png")})]}),Zo(gi,{children:[Pe(yi,{asChild:!0,children:Pe(As,{className:"p-1.5",disabled:a,onClick:()=>o(),children:Pe(qx,{})})}),Pe(hi,{side:"right",color:"black",children:e("editor.controls.actions.export.html")})]}),Zo(gi,{children:[Pe(yi,{asChild:!0,children:Pe(As,{className:"p-1.5",disabled:r,onClick:()=>n(),children:Pe(Qx,{})})}),Pe(hi,{side:"right",color:"black",children:e("editor.controls.actions.export.print")})]})]})]})}import{Fragment as qu,jsx as Me,jsxs as Mt}from"react/jsx-runtime";var Zu=({nodes:e,edges:t,validateDiagram:o,handleValidationComplete:n})=>{let{t:r}=tE(),{clearSelection:i}=Gt(),{mode:a,isMinimapOpen:s,setIsMinimapOpen:l,isMoveTool:c,isHandTool:d,setIsMoveTool:u,setIsHandTool:m}=Z(),{getNodes:f,getEdges:g}=eE(),b=$u(["v","V"]),p=$u(["h","H"]),h=Cs(()=>{i(),m(!0),u(!1)},[i,m,u]),y=Cs(()=>{u(!0),m(!1)},[u,m]),[x,v]=aE(!1),N=Cs(async()=>{v(!0);try{let T=f(),E=g(),I=await o({nodes:T,edges:E});n(I)}finally{v(!1)}},[f,g,o,n]);return Ku(()=>{b&&!c&&a==="edit"&&y()},[b,y,c,a]),Ku(()=>{p&&!d&&a==="edit"&&h()},[p,h,d,a]),Mt("div",{className:"flex items-center gap-2 px-3 py-2 bg-white rounded-sm shadow-md",children:[a==="edit"&&Mt(qu,{children:[Mt(Ei,{children:[Me(_i,{asChild:!0,children:Me(xi,{size:"small",variant:"ghost",color:"grey",className:H(c&&"bg-grey-400"),iconButton:!0,onClick:y,children:Me(sE,{})})}),Mt(bi,{color:"black",className:"flex items-center gap-2",children:[r("editor.controls.actions.move_tool"),Me(ws,{shortcut:"V"})]})]}),Mt(Ei,{children:[Me(_i,{asChild:!0,children:Me(xi,{size:"small",variant:"ghost",color:"grey",className:H(d&&"bg-grey-400"),iconButton:!0,onClick:h,children:Me(oE,{})})}),Mt(bi,{color:"black",className:"flex items-center gap-2",children:[r("editor.controls.actions.hand_tool")," ",Me(ws,{shortcut:"H"})]})]})]}),Me(Uu,{}),a==="edit"&&Mt(qu,{children:[Mt(Ei,{children:[Me(_i,{asChild:!0,children:Me(xi,{size:"small",variant:"ghost",color:"grey",iconButton:!0,disabled:x,onClick:N,children:x?Me(rE,{className:"animate-spin"}):Me(nE,{})})}),Me(bi,{color:"black",children:r(x?"editor.controls.actions.check_loading":"editor.controls.actions.check")})]}),Me(Yu,{disabled:e.length>0||t.length>0})]}),Mt(Ei,{children:[Me(_i,{asChild:!0,children:Me(xi,{size:"small",variant:"ghost",color:"grey",className:H(s&&"bg-grey-400"),iconButton:!0,onClick:()=>l(!s),children:Me(iE,{})})}),Me(bi,{color:"black",children:r(s?"editor.controls.actions.minimap.close":"editor.controls.actions.minimap.open")})]})]})};import{Button as Ju,Tooltip as Qu,TooltipContent as ju,TooltipTrigger as ep,useTranslation as lE}from"@produto-lecom/lecom-ui";import{RedoIcon as cE,UndoIcon as dE}from"lucide-react";import{jsx as Zt,jsxs as Ss}from"react/jsx-runtime";var tp=({undo:e,redo:t,canUndo:o,canRedo:n})=>{let{t:r}=lE();return Ss("div",{className:"flex items-center gap-2 px-3 py-2 bg-white rounded-sm shadow-md",children:[Ss(Qu,{children:[Zt(ep,{asChild:!0,children:Zt(Ju,{size:"small",variant:"ghost",color:"grey",iconButton:!0,disabled:!o,onClick:e,children:Zt(dE,{})})}),Zt(ju,{color:"black",children:r("editor.controls.history.undo")})]}),Ss(Qu,{children:[Zt(ep,{asChild:!0,children:Zt(Ju,{size:"small",variant:"ghost",color:"grey",iconButton:!0,disabled:!n,onClick:t,children:Zt(cE,{})})}),Zt(ju,{color:"black",children:r("editor.controls.history.redo")})]})]})};import{useEdges as uE,useNodes as pE,useReactFlow as fE}from"@xyflow/react";import{Button as Ti,Tooltip as Ni,TooltipContent as vi,TooltipTrigger as wi,useTranslation as mE}from"@produto-lecom/lecom-ui";import{ScanIcon as gE,ZoomIn as hE,ZoomOut as yE}from"lucide-react";import{jsx as Oe,jsxs as On}from"react/jsx-runtime";var op=()=>{let{t:e}=mE(),t=pE(),o=uE(),{zoomIn:n,zoomOut:r,zoomTo:i,fitView:a}=fE(),s=t.length===0&&o.length===0;return On("div",{className:"flex items-center gap-2 px-3 py-2 bg-white rounded-sm shadow-md",children:[On(Ni,{children:[Oe(wi,{asChild:!0,children:Oe(Ti,{iconButton:!0,size:"small",color:"grey",variant:"ghost",disabled:s,onClick:()=>a(),children:Oe(gE,{})})}),Oe(vi,{color:"black",children:e("editor.controls.zoom.fit")})]}),On(Ni,{children:[Oe(wi,{asChild:!0,children:Oe(Ti,{iconButton:!0,size:"small",color:"grey",variant:"ghost",disabled:s,onClick:()=>r(),children:Oe(yE,{})})}),Oe(vi,{color:"black",children:e("editor.controls.zoom.out")})]}),On(Ni,{children:[Oe(wi,{asChild:!0,children:Oe(Ti,{iconButton:!0,size:"small",color:"grey",variant:"ghost",disabled:s,onClick:()=>i(1),children:Oe(Ks,{})})}),Oe(vi,{color:"black",children:e("editor.controls.zoom.reset")})]}),On(Ni,{children:[Oe(wi,{asChild:!0,children:Oe(Ti,{iconButton:!0,size:"small",color:"grey",variant:"ghost",disabled:s,onClick:()=>n(),children:Oe(hE,{})})}),Oe(vi,{color:"black",children:e("editor.controls.zoom.in")})]})]})};import{useNodes as xE}from"@xyflow/react";import{Button as EE,Tooltip as bE,TooltipContent as _E,TooltipTrigger as TE,useTranslation as NE}from"@produto-lecom/lecom-ui";import{useRef as vE,useState as wE}from"react";import{jsx as xo,jsxs as np}from"react/jsx-runtime";var rp=()=>{let e=vE(null),{t}=NE(),{setDraggableNode:o}=Wo(),n=xE(),{setIsDragging:r}=Z(),[i,a]=wE(void 0),s=[{type:"START_EVENT",icon:Yn,label:t("bpmn.start_event.variant.default")},{type:"END_EVENT",icon:_o,label:t("bpmn.end_event.variant.default")},{type:"TASK",icon:Qo,label:t("bpmn.task.variant.default")},{type:"TASK",variant:"SUBPROCESS",icon:en,label:t("bpmn.task.variant.subprocess")},{type:"TASK",variant:"SCRIPT",icon:Qs,label:t("bpmn.task.variant.script")},{type:"TASK",attribute:"LOOP",icon:Js,label:t("bpmn.task.attribute.loop")},{type:"GATEWAY",variant:"EXCLUSIVE",icon:No,label:t("bpmn.gateway.variant.exclusive")},{type:"GATEWAY",variant:"PARALLEL",icon:vo,label:t("bpmn.gateway.variant.parallel")},{type:"GATEWAY",variant:"COMPLEX",icon:To,label:t("bpmn.gateway.variant.complex")},{type:"LANE",icon:$s,label:t("bpmn.lane.variant.default")},{type:"ANNOTATION",icon:Bn,label:t("bpmn.annotation.variant.default")}],l=(c,d)=>{o({type:d.type,variant:d.variant,attribute:d.attribute,icon:d.icon}),a(xo(d.icon,{})),c.dataTransfer.effectAllowed="move",e.current&&c.dataTransfer.setDragImage(e.current,10,10),setTimeout(()=>{r(!0)},100)};return np("aside",{className:"sidebar absolute z-[1] top-4 left-4",children:[xo("div",{className:"grid grid-cols-1 gap-2 p-2 bg-white rounded-md shadow-md",children:s.map((c,d)=>{let u=!Ht(c.type,n),m=u?t("editor.toolbar.start_event_already_exists"):c.label;return np(bE,{children:[xo(TE,{asChild:!0,children:xo(EE,{className:H("[&>svg]:size-6",{"opacity-50 cursor-not-allowed":u}),size:"small",variant:"ghost",color:"grey",draggable:!u,disabled:u,iconButton:!0,onDragStart:u?void 0:f=>l(f,c),children:xo(c.icon,{})},d)}),xo(_E,{color:"black",side:"right",children:m})]},d)})}),xo("div",{ref:e,className:"absolute w-0 h-0 top-0 left-0 z-[-1] bg-transparent",children:i})]})};import{jsx as ut,jsxs as Ii}from"react/jsx-runtime";var Ps=e=>e.preventDefault(),Ls=PE((e,t)=>{let o=ME("Space"),{instanceId:n,mode:r,isMinimapOpen:i,isMoveTool:a,isHandTool:s}=Z(),l=Ms(null),c=Ms(s),d=Ms(o),{nodes:u,edges:m,actions:f,events:g,components:b,controls:p}=wu(),{t:h}=OE();c.current=s,d.current=o;let y=Iu(l,c,d);LE(t,()=>({selectElements:f.selectElements,clearSelection:f.clearSelection}));let x=s||o||r!=="edit",v=x?[0,1,2]:Sn,N=s||o||y,T=a&&!o&&!y,E=r==="edit"&&T,I=!x&&!y,P=r==="view"||T;return Ii("div",{ref:l,className:"w-full h-full",children:[r==="edit"&&ut(rp,{}),ut(Cu,{}),Ii(CE,w(_({},g),{id:`modeler-${n}`,className:H({"is-hand-tool":N,"is-pan-tool-active":N}),edges:m,nodes:u,nodeTypes:Od,edgeTypes:Vd,minZoom:Ns,maxZoom:Wd,panOnDrag:v,panOnScroll:!0,selectionOnDrag:I,elevateEdgesOnSelect:!0,elevateNodesOnSelect:!0,elementsSelectable:P,nodesConnectable:E,nodesDraggable:E,connectionLineComponent:kd,selectionMode:SE.Partial,multiSelectionKeyCode:["Control","Meta"],deleteKeyCode:E?"Delete":null,selectionKeyCode:null,defaultViewport:Fd,connectOnClick:!1,connectionRadius:50,onPaneContextMenu:Ps,onNodeContextMenu:Ps,onEdgeContextMenu:Ps,proOptions:{hideAttribution:!0},children:[ut(IE,{gap:zd,size:Bd,color:Gd,bgColor:Hd}),i&&Ii(kE,{children:[ut(DE,{asChild:!0,children:ut("div",{className:"absolute bottom-[0px] left-[0px] z-[5]",children:ut(AE,{pannable:!0,zoomable:!0,position:Yd,className:"shadow-md rounded-md",ariaLabel:"",style:{pointerEvents:"all",position:"relative"}})})}),ut(RE,{color:"black",children:h("editor.controls.actions.minimap.label")})]}),Ii("div",{className:"absolute z-10 bottom-4 left-1/2 -translate-x-1/2 flex gap-4",children:[r==="edit"&&ut(tp,_({},p)),r!=="readonly"&&ut(Zu,{nodes:u,edges:m,validateDiagram:f.validateDiagram,handleValidationComplete:f.handleValidationComplete}),ut(op,{})]}),ut(b.HelperLines,{})]}))]})});Ls.displayName="Editor";import{useStore as VE}from"@xyflow/react";import{useEffect as HE,useRef as GE}from"react";import{jsx as zE}from"react/jsx-runtime";var BE=e=>({width:e.width,height:e.height,transform:e.transform}),ks="rgba(51, 103, 217, 0.4)",ic=({horizontal:e,vertical:t})=>{let{width:o,height:n,transform:r}=VE(BE),i=GE(null);return HE(()=>{let a=i.current,s=a==null?void 0:a.getContext("2d");if(!s||!a)return;let l=window.devicePixelRatio;a.width=o*l,a.height=n*l,s.clearRect(0,0,o,n),s.scale(l,l),s.strokeStyle=ks,t&&(s.beginPath(),s.strokeStyle=t.color||ks,s.moveTo(t.position*r[2]+r[0],0),s.lineTo(t.position*r[2]+r[0],n),s.stroke()),e&&(s.beginPath(),s.strokeStyle=e.color||ks,s.moveTo(0,e.position*r[2]+r[1]),s.lineTo(o,e.position*r[2]+r[1]),s.stroke())},[o,n,r,e,t]),zE("canvas",{ref:i,className:"w-full h-full absolute z-10 pointer-events-none"})};import{i18n as YE,Notification as WE,TooltipProvider as FE}from"@produto-lecom/lecom-ui";import{createContext as XE,useContext as UE,useEffect as $E,useState as KE}from"react";import{jsx as ip,jsxs as ZE}from"react/jsx-runtime";var Et=new Map,sp=XE(null),_n=()=>{let e=UE(sp);if(!e)throw new Error("useModeler must be used within an <ModelerProvider />");return e},qE=({locale:e,defaultMode:t="view",toast:o,children:n})=>{let[r,i]=KE(e||"pt_BR");$E(()=>{e&&(i(e),YE.changeLanguage(e))},[e]);let a=g=>{let b=Et.size;if(b===0)throw new Error("No modeler instances found");if(b===1||!g){let[h]=Et.values();return h}let p=Et.get(g);if(!p)throw new Error(`Modeler instance with ID "${g}" not found`);return p},s=(g,b)=>{let p=a(b);return p==null?void 0:p.selectElements(g)},l=async g=>{let b=a(g);return b==null?void 0:b.clearSelection()},c=(g,b)=>{let p=a(b);return p==null?void 0:p.configureElement(g)},d=(g,b)=>{let p=a(b);return p==null?void 0:p.getConfigureElement(g)},u=async(g,b)=>{let p=a(b);await(p==null?void 0:p.importFromMxGraph(g))},m=g=>{let b=a(g);return b==null?void 0:b.exportToMxGraph()},f=g=>{let b=a(g);return(b==null?void 0:b.getElementsCount())||0};return ip(sp.Provider,{value:{defaultMode:t,locale:r,selectElements:s,clearSelection:l,configureElement:c,getConfigureElement:d,importDiagram:u,exportDiagram:m,getElementsCount:f,toast:o},children:ZE(FE,{children:[!o&&ip(WE,{type:"toast",placement:"topRight",enableClose:!0,showProgress:!0,pauseOnHover:!0}),n]})})};import{jsx as Rs}from"react/jsx-runtime";var ap=jE(null),Z=()=>{let e=e1(ap);if(!e)throw new Error("useModelerInstance must be used within an <Modeler />");return e},r1=({selectorRef:e,initialDiagram:t,instanceId:o,mode:n,validateCustomDiagram:r,onElementChanges:i,onConfigureElement:a,onElementClick:s,onSubprocessValidationClick:l})=>{let{t:c}=JE(),{defaultMode:d}=_n(),u=o1(),[m]=pt(o||u),[f,g]=pt(n||d||"edit"),[b,p]=pt(wn),[h,y]=pt(!1),[x,v]=pt(!0),[N,T]=pt(!1),[E,I]=pt(!1),[P,M]=pt(!1),[V,C]=pt(!1),[G,K]=pt(!1),[$,J]=pt(null);t1(()=>{n&&g(n)},[n]);let Y=n1(()=>t||Qc(c),[t,c]),S={instanceId:m,initialDiagram:Y,mode:f,lastElementId:b,isInitialized:h,isMinimapOpen:E,isMoveTool:x,isHandTool:N,isDragging:P,isMultipleSelection:G,isConnecting:V,setLastElementId:p,setIsInitialized:y,reconnectingEdgeId:$,setIsMinimapOpen:I,setIsMoveTool:v,setIsHandTool:T,setIsDragging:M,setIsConnecting:C,setIsMultipleSelection:K,setReconnectingEdgeId:J,validateCustomDiagram:r,onElementChanges:i,onConfigureElement:a,onElementClick:s,onSubprocessValidationClick:l};return Rs(QE,{children:Rs(ap.Provider,{value:S,children:Rs(Ls,{ref:e})})})};export{we as EditorMode,Ci as ElementPosition,Hn as ElementType,Si as GatewayElementVariant,lt as GatewayVariant,r1 as Modeler,qE as ModelerProvider,ht as NodeAttribute,le as NodeType,tt as NodeVariant,Mi as RoutingVariant,_n as useModeler};