lecom-modeler 0.27.0 → 0.29.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 ju=Object.defineProperty,ep=Object.defineProperties;var tp=Object.getOwnPropertyDescriptors;var Sn=Object.getOwnPropertySymbols;var Is=Object.prototype.hasOwnProperty,As=Object.prototype.propertyIsEnumerable;var ws=(e,t,o)=>t in e?ju(e,t,{enumerable:!0,configurable:!0,writable:!0,value:o}):e[t]=o,_=(e,t)=>{for(var o in t||(t={}))Is.call(t,o)&&ws(e,o,t[o]);if(Sn)for(var o of Sn(t))As.call(t,o)&&ws(e,o,t[o]);return e},v=(e,t)=>ep(e,tp(t));var st=(e,t)=>{var o={};for(var n in e)Is.call(e,n)&&t.indexOf(n)<0&&(o[n]=e[n]);if(e!=null&&Sn)for(var n of Sn(e))t.indexOf(n)<0&&As.call(e,n)&&(o[n]=e[n]);return o};var _i=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 op,Translations as np}from"@produto-lecom/lecom-ui";var Cs={translations:{general:{layout:{title:"Modeler"}},editor:{toolbar:{delete:"Delete",configure_node:"Configure activity",configure_edge:"Configure routing",initial_task:"Initial Activity",gateway_limit_reached:"Exclusive gateway cannot have more than 2 outgoing connections",task_limit_reached:"Task cannot have more than 2 outgoing connections",start_event_limit_reached:"Start event can only connect to a single element",gateway_to_gateway_not_allowed:"Gateways cannot connect directly to other gateways",start_event_already_exists:"A start event already exists. Delete the current event to add another",script_to_end_not_allowed:"Script activities cannot connect directly to the end event",loop_to_end_not_allowed:"Loop activities cannot connect directly to the end event",initial_activity_to_end_not_allowed:"Initial activity cannot connect directly to the end event",final_activity_cannot_connect:"Final activity cannot connect to other elements",activity_has_outgoing_connections:"Activity with outgoing connections cannot connect to end event",end_event_cannot_connect_to_initial_activity:"End event cannot connect to an initial activity",initial_activity_cannot_connect_to_start_event:"Initial activity cannot connect to start event",concurrent_initial_and_final_activity:"An activity cannot be connected to both start and end events",duplicate_connection_not_allowed:"A connection already exists between these elements",connect_node:"Connect element",connecting:"Connecting...",delete_pool_lane_error:"Cannot delete the pool or lane while there are elements inside it."},controls:{zoom:{fit:"Fit zoom",in:"Zoom in",out:"Zoom out",reset:"Reset zoom"},actions:{move_tool:"Select elements",hand_tool:"Navigate the diagram",check:"Check diagram",export:{title:"Export diagram",print:"Print",html:"Export as HTML",png:"Export as PNG",feedback:{empty:"Cannot export an empty diagram",error:"Error exporting diagram"}},import_governance:"Import diagram from Governance platform",minimap:{label:"Minimap",open:"Open minimap",close:"Hide minimap"}},history:{undo:"Undo",redo:"Redo"}},modals:{delete_elements:{title:"Delete elements",callout:"When deleting, the activity and routing settings will be deleted.",content:"Are you sure you want to delete?",confirm:"Delete",cancel:"Cancel"}},task_menu:{loop_not_allowed_when_connected_to_end:"Cannot create loop on activity connected to end event",script_not_allowed_when_connected_to_end:"Cannot transform to Script activity connected to end event",loop_not_allowed_when_subprocess:"Cannot create loop on subprocess",loop:"Activity with loop"}},validation:{success:{title:"Validation Successful",message:"The diagram was validated successfully with no errors."},errors:{title:"The diagram contains errors",subtitle:"Please review the following:",task_label_length:"Task name exceeds the maximum character limit",multiple_start_event_not_allowed:"Multiple start events are not allowed",task_flows_limit_exceeds:"The number of output connections exceeds the limit of two",duplicate_task_name:"There are multiple activities with the same name",flows_on_end_tasks_not_allowed:"Activities connected to end events cannot have other connections",conditions_flows_limit_exceeds:"Exclusive gateway has too many output connections (maximum of two)",task_label_empty:"One or more activities have no name",activity_name_invalid:"Activity name is invalid",final_activity_has_loop:"Final activities cannot have loops",nested_gateway:"Connecting gateways directly is not allowed",concurrent_initial_and_final_event:"The same activity cannot have both initial and final events",gateway_flow_to_event:"Connecting a gateway to an output event is not allowed",gateway_missing_output_streams:"The gateway does not have the correct number of outputs",events_nested:"Connecting events directly is not allowed",event_to_condition:"Connecting an event directly to a gateway is not allowed",script_in_final_activity:"Final activity cannot be a script type",subprocess_referenced_not_configured:"The subprocess reference is not properly configured",start_event_not_found:"At least one start event is required",end_event_not_found:"At least one end event is required"}},bpmn:{start_event:{variant:{default:"Start event"}},end_event:{variant:{default:"End event"}},annotation:{variant:{default:"Annotation"}},gateway:{menu:{title:"Change gateway type"},variant:{default:"Gateway",exclusive:"Exclusive gateway",parallel:"Parallel gateway",complex:"Complex gateway"}},task:{menu:{title:"Change task type"},variant:{default:"Task",script:"Script task",subprocess:"Subprocess"},attribute:{loop:"Task with loop"},label:{prefix:"Activity"},feedback:{label_empty:{prefix:"Activity name was automatically set to"},label_already_exists:{prefix:"The name",middle:"already exists. The name was changed to"},invalid_first_character:"Activity name must start with a letter or number"}},lane:{variant:{default:"Pool / Lane"}},unsupported:{variant:{default:"Unsupported element"}}},adapter:{governance:{error:{DEFAULT:"Error importing diagram",NO_FILE:"No file selected",EMPTY_FILE:"Empty file",INVALID_FILE:"Invalid file",CONTAIN_NO_CELLS:"No cells found to be imported",ALREADY_INITIALIZED:"It is not possible to import the diagram from the Governance platform, since the diagram has already been initialized"},success:{default:"The diagram was imported from the Governance platform successfully and without any incompatibility detected.",incompatible_cells:"The diagram was imported from the Governance platform with incompatibilities. To know more details, click on the button below."},report:{columns:{type:"Type",value:"Value",status:"Status"},status:{imported:"Imported",adapted:"Adapted",unsupported:"Unsupported"}},action:{download:"Download report"}}}}};var Ss={translations:{general:{layout:{title:"Modeler"}},editor:{toolbar:{delete:"Eliminar",configure_node:"Configurar actividad",configure_edge:"Configurar enrutamiento",initial_task:"Actividad Inicial",gateway_limit_reached:"Compuerta exclusiva no puede tener m\xE1s de 2 conexiones de salida",task_limit_reached:"Actividad no puede tener m\xE1s de 2 conexiones de salida",start_event_limit_reached:"Evento inicial solo puede conectarse a un \xFAnico elemento",gateway_to_gateway_not_allowed:"Las compuertas no pueden conectarse directamente con otras compuertas",start_event_already_exists:"Ya existe un evento de inicio. Elimine el evento actual para agregar otro",script_to_end_not_allowed:"Las actividades Script no pueden conectarse directamente al evento final",loop_to_end_not_allowed:"Las actividades Loop no pueden conectarse directamente al evento final",initial_activity_to_end_not_allowed:"Actividad inicial no puede conectarse directamente al evento final",final_activity_cannot_connect:"Actividad final no puede conectarse a otros elementos",activity_has_outgoing_connections:"Actividad con conexiones de salida no puede conectarse al evento final",end_event_cannot_connect_to_initial_activity:"El evento final no puede conectarse a una actividad inicial",initial_activity_cannot_connect_to_start_event:"Actividad inicial no puede conectarse a evento de inicio",concurrent_initial_and_final_activity:"Una actividad no puede estar conectada al evento inicial y final al mismo tiempo",duplicate_connection_not_allowed:"Ya existe una conexi\xF3n entre estos elementos",connect_node:"Conectar elemento",connecting:"Conectando...",delete_pool_lane_error:"No se puede eliminar la piscina o carril mientras haya elementos dentro."},controls:{zoom:{fit:"Ajustar zoom",in:"Acercar",out:"Alejar",reset:"Restablecer zoom"},actions:{move_tool:"Seleccionar elementos",hand_tool:"Navegar por el diagrama",check:"Validar diagrama",export:{title:"Exportar diagrama",print:"Imprimir",html:"Exportar como HTML",png:"Exportar como PNG",feedback:{empty:"No es posible exportar un diagrama vac\xEDo",error:"Error al exportar diagrama"}},import_governance:"Importar diagrama de la plataforma Governance",minimap:{label:"Minimapa",open:"Abrir minimapa",close:"Ocultar minimapa"}},history:{undo:"Deshacer",redo:"Rehacer"}},modals:{delete_elements:{title:"Eliminar elementos",callout:"Al eliminar, las configuraciones de actividades y enrutamiento ser\xE1n eliminadas.",content:"\xBFEst\xE1s seguro de querer eliminar?",confirm:"Eliminar",cancel:"Cancelar"}},task_menu:{loop_not_allowed_when_connected_to_end:"No se puede crear bucle en actividad conectada al evento final",script_not_allowed_when_connected_to_end:"No se puede transformar a Script actividad conectada al evento final",loop_not_allowed_when_subprocess:"No se puede crear bucle en subproceso",loop:"Actividad con loop"}},validation:{success:{title:"Validaci\xF3n exitosa",message:"El diagrama ha sido validado correctamente sin errores."},errors:{title:"El diagrama contiene errores",subtitle:"Revise lo siguiente:",task_label_length:"El nombre de la actividad excede el l\xEDmite m\xE1ximo de caracteres",multiple_start_event_not_allowed:"No se permite tener m\xE1s de un evento de inicio",task_flows_limit_exceeds:"El n\xFAmero de conexiones de salida supera el l\xEDmite de dos",duplicate_task_name:"Hay varias actividades con el mismo nombre",flows_on_end_tasks_not_allowed:"Las actividades conectadas a eventos finales no pueden tener otras conexiones",conditions_flows_limit_exceeds:"Compuerta exclusiva con exceso de conexiones de salida (m\xE1ximo de dos)",task_label_empty:"El nombre de una o m\xE1s actividades no ha sido completado",activity_name_invalid:"El nombre de la actividad no es v\xE1lido",final_activity_has_loop:"Las actividades finales no pueden tener bucles",nested_gateway:"No se permite conectar compuertas directamente",concurrent_initial_and_final_event:"Una misma actividad no puede tener eventos iniciales y finales",gateway_flow_to_event:"No se permite conectar una compuerta a un evento de salida",gateway_missing_output_streams:"La compuerta no tiene el n\xFAmero correcto de salidas",events_nested:"No se permite conectar eventos directamente",event_to_condition:"No se permite conectar un evento directamente a una compuerta",script_in_final_activity:"La actividad final no puede ser de tipo script",subprocess_referenced_not_configured:"La referencia al subproceso no est\xE1 configurada correctamente",start_event_not_found:"Es necesario tener al menos un evento de inicio",end_event_not_found:"Es necesario tener al menos un evento final"}},bpmn:{start_event:{variant:{default:"Evento de inicio"}},end_event:{variant:{default:"Evento final"}},annotation:{variant:{default:"Anotaci\xF3n"}},gateway:{menu:{title:"Cambiar tipo de compuerta"},variant:{default:"Compuerta",exclusive:"Compuerta exclusiva",parallel:"Compuerta paralela",complex:"Compuerta compleja"}},task:{menu:{title:"Cambiar tipo de tarea"},variant:{default:"Tarea",script:"Tarea de script",subprocess:"Subproceso"},attribute:{loop:"Tarea con bucle"},label:{prefix:"Actividad"},feedback:{label_empty:{prefix:"El nombre de la actividad se estableci\xF3 autom\xE1ticamente como"},label_already_exists:{prefix:"El nombre",middle:"ya existe. El nombre fue cambiado a"},invalid_first_character:"El nombre de la actividad debe comenzar con una letra o n\xFAmero"}},lane:{variant:{default:"Piscina / Raia"}},unsupported:{variant:{default:"Elemento no soportado"}}},adapter:{governance:{error:{DEFAULT:"Error al importar diagrama",NO_FILE:"No se ha seleccionado ning\xFAn archivo",EMPTY_FILE:"Archivo vac\xEDo",INVALID_FILE:"Archivo inv\xE1lido",CONTAIN_NO_CELLS:"No se encontraron c\xE9lulas para importar",ALREADY_INITIALIZED:"No es posible importar el diagrama de la plataforma Governance, ya que el diagrama ya ha sido iniciado"},success:{default:"El diagrama se ha importado de la plataforma Governance correctamente y sin ninguna incompatibilidad detectada.",incompatible_cells:"El diagrama se ha importado de la plataforma Governance con incompatibilidades. Para saber m\xE1s detalles, haz click en el bot\xF3n de abajo."},report:{columns:{type:"Tipo",value:"Valor",status:"Estado"},status:{imported:"Importado",adapted:"Adaptado",unsupported:"No soportado"}},action:{download:"Descargar informe"}}}}};var Ms={translations:{general:{layout:{title:"Modeler"}},editor:{toolbar:{delete:"Excluir",configure_node:"Configurar atividade",configure_edge:"Configurar roteamento",initial_task:"Atividade Inicial",gateway_limit_reached:"Gateway exclusivo n\xE3o pode ter mais de 2 conex\xF5es de sa\xEDda",task_limit_reached:"Atividade n\xE3o pode ter mais de 2 conex\xF5es de sa\xEDda",start_event_limit_reached:"Evento inicial s\xF3 pode se conectar a um \xFAnico elemento",gateway_to_gateway_not_allowed:"Gateways n\xE3o podem se conectar diretamente com outros gateways",start_event_already_exists:"J\xE1 existe um evento de in\xEDcio. Exclua o evento atual para adicionar outro",script_to_end_not_allowed:"Atividades Script n\xE3o podem se conectar diretamente ao evento final",loop_to_end_not_allowed:"Atividades Loop n\xE3o podem se conectar diretamente ao evento final",initial_activity_to_end_not_allowed:"Atividade inicial n\xE3o pode se conectar diretamente ao evento final",final_activity_cannot_connect:"Atividade final n\xE3o pode se conectar a outros elementos",activity_has_outgoing_connections:"Atividade com conex\xF5es de sa\xEDda n\xE3o pode se conectar a um evento final",end_event_cannot_connect_to_initial_activity:"O evento final n\xE3o pode ser conectado a uma atividade inicial",initial_activity_cannot_connect_to_start_event:"Atividade inicial n\xE3o pode se conectar a evento de in\xEDcio",concurrent_initial_and_final_activity:"Uma atividade n\xE3o pode estar conectada ao evento inicial e final ao mesmo tempo",duplicate_connection_not_allowed:"J\xE1 existe uma conex\xE3o entre esses elementos",start_event_to_subprocess_not_allowed:"Evento inicial n\xE3o pode se conectar a um subprocesso",connect_node:"Conectar elemento",connecting:"Conectando...",delete_pool_lane_error:"N\xE3o \xE9 poss\xEDvel excluir a piscina ou raia enquanto houver elementos dentro dela."},controls:{zoom:{fit:"Ajustar o zoom",in:"Aumentar o zoom",out:"Diminuir o zoom",reset:"Resetar o zoom"},actions:{move_tool:"Selecionar elementos",hand_tool:"Navegar pelo diagrama",check:"Validar diagrama",export:{title:"Exportar diagrama",print:"Imprimir",html:"Exportar como HTML",png:"Exportar como PNG",feedback:{empty:"N\xE3o \xE9 poss\xEDvel exportar um diagrama vazio",error:"Erro ao exportar o diagrama"}},import_governance:"Importar diagrama da plataforma Governance",minimap:{label:"Minimapa",open:"Abrir minimapa",close:"Ocultar minimapa"}},history:{undo:"Desfazer",redo:"Refazer"}},modals:{delete_elements:{title:"Excluir elementos",callout:"Ao excluir, as configura\xE7\xF5es de atividades e roteamento ser\xE3o exclu\xEDdas.",content:"Deseja realmente excluir?",confirm:"Excluir",cancel:"Cancelar"}},task_menu:{loop_not_allowed_when_connected_to_end:"N\xE3o \xE9 poss\xEDvel criar loop em atividade conectada ao evento final",script_not_allowed_when_connected_to_end:"N\xE3o \xE9 poss\xEDvel transformar em Script atividade conectada ao evento final",loop_not_allowed_when_subprocess:"N\xE3o \xE9 poss\xEDvel criar loop em subprocesso",loop:"Atividade com loop"}},validation:{success:{title:"Diagrama v\xE1lidado com sucesso!",message:"Nenhum erro encontrado."},errors:{title:"O diagrama cont\xE9m erros",subtitle:"Veja abaixo o que precisa ser corrigido:",task_label_length:"O nome da atividade excede o limite m\xE1ximo de caracteres",multiple_start_event_not_allowed:"N\xE3o \xE9 permitido ter mais de um evento de in\xEDcio",task_flows_limit_exceeds:"O n\xFAmero de conex\xF5es de sa\xEDda ultrapassa o limite de dois",duplicate_task_name:"H\xE1 v\xE1rias atividades com o mesmo nome",flows_on_end_tasks_not_allowed:"Atividades conectadas a eventos finais n\xE3o podem ter outras conex\xF5es",conditions_flows_limit_exceeds:"Gateway exclusivo com excesso de conex\xF5es de sa\xEDda (m\xE1ximo de dois)",task_label_empty:"O nome de uma ou mais atividades n\xE3o foi preenchido",activity_name_invalid:"O nome da atividade n\xE3o \xE9 v\xE1lido",final_activity_has_loop:"Atividades finais n\xE3o podem ter loops",nested_gateway:"N\xE3o \xE9 permitido conectar gateways",concurrent_initial_and_final_event:"Uma mesma atividade n\xE3o pode ter eventos iniciais e finais",gateway_flow_to_event:"N\xE3o \xE9 permitido conectar um gateway a um evento de sa\xEDda",gateway_missing_output_streams:"O gateway n\xE3o possui o n\xFAmero correto de sa\xEDdas",events_nested:"N\xE3o \xE9 permitido conectar eventos",event_to_condition:"N\xE3o \xE9 permitido conectar um evento diretamente em um gateway",script_in_final_activity:"Atividade final n\xE3o pode ser do tipo script",subprocess_referenced_not_configured:"A refer\xEAncia ao subprocesso n\xE3o est\xE1 configurada corretamente",start_event_not_found:"\xC9 necess\xE1rio ter ao menos um evento inicial",end_event_not_found:"\xC9 necess\xE1rio ter ao menos um evento final"}},bpmn:{start_event:{variant:{default:"Evento inicial"}},end_event:{variant:{default:"Evento final"}},annotation:{variant:{default:"Anota\xE7\xE3o"}},gateway:{menu:{title:"Alterar tipo de gateway"},variant:{default:"Gateway",exclusive:"Gateway exclusivo",parallel:"Gateway paralelo",complex:"Gateway complexo"}},task:{menu:{title:"Alterar tipo de Atividade"},variant:{default:"Atividade",script:"Atividade de script",subprocess:"Subprocesso"},attribute:{loop:"Atividade com loop"},label:{prefix:"Atividade"},feedback:{label_empty:{prefix:"O nome da atividade foi definido automaticamente como"},label_already_exists:{prefix:"O nome",middle:"j\xE1 existe. O nome foi alterado para"},invalid_first_character:"O nome da atividade deve come\xE7ar com uma letra ou n\xFAmero"}},lane:{variant:{default:"Piscina / Raia"}},unsupported:{variant:{default:"Elemento n\xE3o suportado"}}},adapter:{governance:{error:{DEFAULT:"Erro ao importar diagrama",NO_FILE:"Nenhum arquivo selecionado",EMPTY_FILE:"Arquivo vazio",INVALID_FILE:"Arquivo inv\xE1lido",CONTAIN_NO_CELLS:"N\xE3o foram encontradas c\xE9lulas para serem importadas",ALREADY_INITIALIZED:"N\xE3o \xE9 poss\xEDvel importar o diagrama da plataforma Governance, pois o diagrama j\xE1 foi iniciado"},success:{default:"O diagrama foi importado da plataforma Governance com sucesso e sem nenhuma incompatibilidade detectada.",incompatible_cells:"O diagrama foi importado da plataforma Governance com incompatibilidades. Para saber mais detalhes, clique no bot\xE3o abaixo."},report:{columns:{type:"Tipo do elemento",value:"Valor",status:"Status"},status:{imported:"Importado",adapted:"Adaptado",unsupported:"N\xE3o suportado"}},action:{download:"Baixar relat\xF3rio"}}}}};var Ps={pt_BR:Ms,en_US:Cs,es_ES:Ss};var Ls,ks,rp=(ks=(Ls=_i("LecomUserLanguage"))!=null?Ls:_i("org.springframework.web.servlet.i18n.CookieLocaleResolver.LOCALE"))!=null?ks:np.PT_BR;op({lng:rp,resources:Ps});var Ie=(n=>(n.EDIT="edit",n.VIEW="view",n.READONLY="readonly",n))(Ie||{});var Mn=(r=>(r.ACTIVITY="activity",r.ROUTING="routing",r.GATEWAY="gateway",r.SUB_PROCESS="sub_process",r))(Mn||{}),Ti=(n=>(n.START="start",n.END="end",n.BETWEEN="between",n))(Ti||{}),Ni=(n=>(n.SCRIPT="script",n.LOOP="loop",n.SCRIPT_LOOP="script_loop",n))(Ni||{}),vi=(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))(vi||{});import{RotateCcw as hp,ScrollText as yp,SquarePlus as xp}from"lucide-react";import{jsx as Pn,jsxs as ip}from"react/jsx-runtime";var Ln=({size:e=24,className:t})=>ip("svg",{width:e,height:e,viewBox:"0 0 24 24",xmlns:"http://www.w3.org/2000/svg",fill:"#6b7280",className:t,children:[Pn("path",{strokeWidth:"2",d:"M16 3V3.5085V11.9998V20.4915V21H16.5411H21.4592H22V19.123H21.4592H17.9974V11.9998V4.8773H21.4592H22V3H21.4592H16.5411H16Z"}),Pn("path",{d:"M4.41026 16.9999L2 18.7861L3.89693 21.1103L6.3072 19.324L4.41026 16.9999Z"}),Pn("path",{d:"M8.41026 13.9999L6 15.7861L7.89693 18.1103L10.3072 16.324L8.41026 13.9999Z"}),Pn("path",{d:"M12.4313 10.954L10.021 12.7402L11.9179 15.0644L14.3282 13.2781L12.4313 10.954Z"})]});import{jsx as Rs}from"react/jsx-runtime";var uo=({size:e=24,className:t})=>Rs("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:Rs("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 zo,jsxs as sp}from"react/jsx-runtime";var po=({size:e=24,className:t})=>sp("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:"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"}),zo("path",{d:"M12 8V16",strokeLinecap:"round",strokeLinejoin:"round"}),zo("path",{d:"M8 12H16",strokeLinecap:"round",strokeLinejoin:"round"}),zo("path",{d:"M9.17139 9.17188L14.8282 14.8287",strokeLinecap:"round",strokeLinejoin:"round"}),zo("path",{d:"M14.8281 9.17188L9.17127 14.8287",strokeLinecap:"round",strokeLinejoin:"round"})]});import{jsx as wi,jsxs as ap}from"react/jsx-runtime";var fo=({size:e=24,className:t})=>ap("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:[wi("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"}),wi("path",{d:"M14.8286 9.17188L9.17176 14.8287",strokeLinecap:"round",strokeLinejoin:"round"}),wi("path",{d:"M9.17139 9.17188L14.8282 14.8287",strokeLinecap:"round",strokeLinejoin:"round"})]});import{jsx as Ii,jsxs as lp}from"react/jsx-runtime";var mo=({size:e=24,className:t})=>lp("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:[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:"M12 8V16",strokeLinecap:"round",strokeLinejoin:"round"}),Ii("path",{d:"M8 12H16",strokeLinecap:"round",strokeLinejoin:"round"})]});import{jsx as Ai,jsxs as cp}from"react/jsx-runtime";var Ds=({size:e=24,className:t})=>Ai("svg",{width:e,height:e,viewBox:"0 0 34 24",xmlns:"http://www.w3.org/2000/svg",fill:"currentColor",className:t,children:cp("g",{children:[Ai("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"}),Ai("path",{d:"M24.5 4.5L28 1M28 1L31.5 4.5M28 1V8",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round"})]})});import{clsx as dp}from"clsx";import{twMerge as up}from"tailwind-merge";function V(...e){return up(dp(e))}var vt=(e=0,t=0)=>e<t?t:e,kn=(e=1e3)=>new Promise(t=>{setTimeout(t,e)});import{jsx as Os,jsxs as pp}from"react/jsx-runtime";var Hs=({size:e=24,className:t})=>pp("svg",{width:e,height:e,viewBox:"0 0 24 24",fill:"none",stroke:"#6b7280",strokeWidth:2,xmlns:"http://www.w3.org/2000/svg",className:V("stroke-2",t),children:[Os("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"}),Os("path",{d:"M9 3V21",strokeLinecap:"round",strokeLinejoin:"round"})]});import{jsx as Ci}from"react/jsx-runtime";var Vs=({size:e=24,className:t})=>Ci("svg",{width:e,height:e,viewBox:"0 0 24 24",xmlns:"http://www.w3.org/2000/svg",stroke:"currentColor",className:t,children:Ci("g",{children:Ci("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 Gs}from"react/jsx-runtime";var Rn=({size:e=24,className:t})=>Gs("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:Gs("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 Bs}from"react/jsx-runtime";var Yo=({size:e=24,className:t})=>Bs("svg",{width:e,height:e,viewBox:"0 0 24 24",xmlns:"http://www.w3.org/2000/svg",fill:"white",stroke:"#6b7280",className:V("stroke-2",t),children:Bs("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 Si,jsxs as fp}from"react/jsx-runtime";var zs=({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:"#6b7280",strokeWidth:"2",className:t,children:[Si("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"}),Si("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"}),Si("path",{d:"M7.5 7.5V10H10",strokeWidth:"1.5",fill:"none",strokeLinecap:"round",strokeLinejoin:"round"})]});import{jsx as Wo,jsxs as mp}from"react/jsx-runtime";var Ys=({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:"#6b7280",strokeWidth:"2",className:t,children:[Wo("path",{d:"M20 3H4C2.89543 3 2 4.34315 2 6V18C2 19.6569 2.89543 21 4 21H20C21.1046 21 22 19.6569 22 18V6C22 4.34315 21.1046 3 20 3Z",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"}),Wo("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"}),Wo("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"}),Wo("path",{d:"M13.5 12H11",strokeWidth:"1",strokeLinecap:"round",strokeLinejoin:"round"}),Wo("path",{d:"M13.5 10H11",strokeWidth:"1",strokeLinecap:"round",strokeLinejoin:"round"})]});import{jsx as Dn,jsxs as gp}from"react/jsx-runtime";var Ws=({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:"#6b7280",strokeWidth:2,className:t,children:[Dn("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"}),Dn("path",{d:"M8 21V14C8 13.4477 8.44772 13 9 13H15C15.5523 13 16 13.4477 16 14V21",strokeWidth:"1",fill:"none"}),Dn("path",{d:"M10.2222 17H13.7777",strokeWidth:"1",strokeLinecap:"round",strokeLinejoin:"round"}),Dn("path",{d:"M12 15.2227V18.7782",strokeWidth:"1",strokeLinecap:"round",strokeLinejoin:"round"})]});var ie=(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))(ie||{}),je=(o=>(o.SCRIPT="SCRIPT",o.SUBPROCESS="SUBPROCESS",o))(je||{}),On={SCRIPT:{icon:yp},SUBPROCESS:{icon:xp}},at=(t=>(t.LOOP="LOOP",t))(at||{}),Hn={LOOP:{icon:hp}},et=(n=>(n.EXCLUSIVE="EXCLUSIVE",n.PARALLEL="PARALLEL",n.COMPLEX="COMPLEX",n))(et||{}),Mi={EXCLUSIVE:{icon:fo},PARALLEL:{icon:mo},COMPLEX:{icon:po}};import{ReactFlowProvider as vE}from"@xyflow/react";import{createContext as wE,useContext as IE,useEffect as AE,useId as CE,useMemo as SE,useState as rt}from"react";import{Background as Jx,MiniMap as Qx,ReactFlow as jx,SelectionMode as eE,useKeyPress as tE}from"@xyflow/react";import{forwardRef as oE,useEffect as qu,useImperativeHandle as nE,useRef as rE,useState as iE}from"react";import{useTranslation as P0}from"@produto-lecom/lecom-ui";import{useEdgesState as L0,useNodesState as k0,useOnSelectionChange as R0,useReactFlow as D0,useStoreApi as O0}from"@xyflow/react";import{useCallback as _t,useEffect as H0}from"react";import{Position as Fo}from"@xyflow/react";function Fs(e,t){var E,N,b,g;let{width:o=0,height:n=0}=e.measured||{width:0,height:0},r=e.internals.positionAbsolute,i=t.internals.positionAbsolute,a=o/2,s=n/2,l=r.x+a,c=r.y+s,d=i.x+((N=(E=t==null?void 0:t.measured)==null?void 0:E.width)!=null?N:0)/2,u=i.y+((g=(b=t==null?void 0:t.measured)==null?void 0:b.height)!=null?g:0)/2,f=(d-l)/(2*a)-(u-c)/(2*s),p=(d-l)/(2*a)+(u-c)/(2*s),h=1/(Math.abs(f)+Math.abs(p)||1),y=h*f,m=h*p,x=a*(y+m)+l,T=s*(-y+m)+c;return{x,y:T}}function Xs(e,t){var c,d,u,f;let{positionAbsolute:o}=e.internals,n=(d=(c=e.measured)==null?void 0:c.width)!=null?d:0,r=(f=(u=e.measured)==null?void 0:u.height)!=null?f:0,i=Math.round(o.x),a=Math.round(o.y),s=Math.round(t.x),l=Math.round(t.y);return s<=i+1?Fo.Left:s>=i+n-1?Fo.Right:l<=a+1?Fo.Top:l>=a+r-1?Fo.Bottom:Fo.Top}function go(e,t){let o=Fs(e,t),n=Fs(t,e),r=Xs(e,o),i=Xs(t,n);return{sx:o.x,sy:o.y,tx:n.x,ty:n.y,sourcePos:r,targetPos:i}}function Vn(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 Gn={MIN_WIDTH:36,MIN_HEIGHT:36},Bn={MIN_WIDTH:36,MIN_HEIGHT:36},zn={MIN_WIDTH:56,MIN_HEIGHT:56},ho={MIN_WIDTH:176,MIN_HEIGHT:96},Us={HEADER_WIDTH:40,MIN_WIDTH:840,MIN_HEIGHT:256},re={HEADER_WIDTH:40,MIN_WIDTH:800,MIN_HEIGHT:256},yo={MIN_WIDTH:176,MIN_HEIGHT:64},Ep={MIN_WIDTH:128,MIN_HEIGHT:64},ae={START_EVENT:Gn,END_EVENT:Bn,GATEWAY:zn,TASK:ho,LANE:re,ANNOTATION:yo,UNSUPPORTED:Ep};import{orderBy as bp}from"lodash";var $s=e=>new Map(e.map(t=>[t.id,t])),Ks=(e,t)=>e.map(o=>{var n;return(n=t.get(o.id))!=null?n:o}),$e=e=>{var t,o,n,r,i,a,s,l;return{x:(o=(t=e.internals)==null?void 0:t.positionAbsolute.x)!=null?o:0,y:(r=(n=e.internals)==null?void 0:n.positionAbsolute.y)!=null?r:0,w:(a=(i=e.measured)==null?void 0:i.width)!=null?a:0,h:(l=(s=e.measured)==null?void 0:s.height)!=null?l:0}},Ft=e=>bp(e,[o=>{let n=o.type==="LANE";return n&&!o.parentId?0:n?1:2}],["asc"]),qs=(e,t)=>{let{x:o,y:n}=$e(e),{x:r,y:i}=$e(t);return{x:o-r,y:n-i}};var Xt=({parentId:e,nodes:t,includeTypes:o=[...Object.values(ie)],excludeTypes:n=[]})=>t.some(r=>r.parentId===e&&(!o.length||o.includes(r.type))&&!n.includes(r.type)),_p=(e,t)=>{let{x:o,y:n}=$e(e),{x:r,y:i}=$e(t),a=o-r,s=n-i;return Math.sqrt(a*a+s*s)},Tp=(e,t)=>{let{x:o,y:n,w:r,h:i}=$e(e),{x:a,y:s,w:l,h:c}=$e(t),d=o+r/2,u=n+i/2;return d>=a&&d<=a+l&&u>=s&&u<=s+c},Xo=(e,t)=>{let o=null,n=1/0;for(let r of t)if(r.id!==e.id&&Tp(e,r)){let i=_p(e,r);i<n&&(n=i,o=r)}return o},Zs=(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),Js=(e,t)=>{let o=e.filter(c=>!c.parentId);if(o.length===0)return{nodes:e,edges:t};let n=o.filter(c=>c.type==="LANE"),r=n.length>0?n:o,i=Math.min(...r.map(c=>c.position.x||0)),a=Math.min(...r.map(c=>c.position.y||0)),s=e.map(c=>c.parentId?c:v(_({},c),{position:{x:c.position.x-i,y:c.position.y-a}})),l=t.map(c=>{let d=c.data;return d!=null&&d.points?v(_({},c),{data:v(_({},d),{points:d.points.map(u=>({x:u.x-i,y:u.y-a}))})}):c});return{nodes:s,edges:l}},Qs=e=>{var l,c;let t=e.filter(d=>!d.parentId),o=t.filter(d=>d.type==="LANE"),n=o.length>0?o:t;if(n.length===0)return null;let r=1/0,i=1/0,a=-1/0,s=-1/0;for(let d of n){let u=d.position.x+((l=d.width)!=null?l:0),f=d.position.y+((c=d.height)!=null?c:0);d.position.x<r&&(r=d.position.x),d.position.y<i&&(i=d.position.y),u>a&&(a=u),f>s&&(s=f)}return{x:r,y:i,width:a-r,height:s-i}};var Pi=(e,t)=>{let o=t.find(a=>a.id===e);if(!o||o.type!=="LANE"||o.parentId)return!1;let n=$e(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=$e(a);return s.x<r&&s.x+s.w>n.x&&s.y<i&&s.y+s.h>n.y})};var Np=50,Ut=(e,t)=>{var f,p,h,y,m,x,T,E,N,b,g,w,A,I,D,S;let o=t.find(L=>L.id===e);if(!o)return t;let n=(p=(f=o.position)==null?void 0:f.x)!=null?p:0,r=(y=(h=o.position)==null?void 0:h.y)!=null?y:0,i=(x=(m=o.measured)==null?void 0:m.width)!=null?x:0,a=(E=(T=o.measured)==null?void 0:T.height)!=null?E:0,s=r+a,l=n+i,c=new Set,d=1/0;for(let L of t){if(L.id===e||L.parentId)continue;let z=(b=(N=L.position)==null?void 0:N.y)!=null?b:0,q=(w=(g=L.position)==null?void 0:g.x)!=null?w:0,Q=(I=(A=L.measured)==null?void 0:A.width)!=null?I:0,U=(S=(D=L.measured)==null?void 0:D.height)!=null?S:0;q<l&&q+Q>n&&z<s&&z+U>r&&(c.add(L.id),d=Math.min(d,z))}if(c.size===0)return t;let u=s+Np-d;return t.map(L=>{var q,Q,U;if(!c.has(L.id))return L;let z=(Q=(q=L.position)==null?void 0:q.y)!=null?Q:0;return v(_({},L),{position:v(_({},(U=L.position)!=null?U:{x:0,y:0}),{y:z+u})})})},he=15,$t=e=>[...e].sort((t,o)=>t.position.y-o.position.y),vp=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)},wp=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)},Li=(e,t,o)=>{var d,u,f,p,h,y,m,x,T,E,N,b,g,w,A;if(t.length===0)return e;let n=(f=(u=e.width)!=null?u:(d=e.measured)==null?void 0:d.width)!=null?f:0,r=(y=(h=e.height)!=null?h:(p=e.measured)==null?void 0:p.height)!=null?y:0,i=0,a=0;for(let I of t){let D=vp(I),S=wp(I);if(((x=(m=I.position)==null?void 0:m.y)!=null?x:0)<he&&(o.set(I.id,v(_({},I),{position:v(_({},I.position),{y:he})})),S=he+((E=(T=I.measured)==null?void 0:T.height)!=null?E:0)),((b=(N=I.position)==null?void 0:N.x)!=null?b:0)<re.HEADER_WIDTH+he){let L=(g=o.get(I.id))!=null?g:I;o.set(I.id,v(_({},L),{position:v(_({},L.position),{x:re.HEADER_WIDTH+he})})),D=re.HEADER_WIDTH+he+((A=(w=I.measured)==null?void 0:w.width)!=null?A:0)}i=Math.max(i,D),a=Math.max(a,S)}let s=Math.max(n,re.MIN_WIDTH),l=Math.max(r,re.MIN_HEIGHT);i+he>s&&(s=i+he),a+he>l&&(l=a+he);let c=v(_({},e),{width:s,height:l,measured:v(_({},e.measured),{width:s,height:l})});return o.set(e.id,c),c},js=(e,t,o)=>{var a,s;let n=$t(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=Li(l,c,t);t.set(d.id,v(_({},d),{position:{x:re.HEADER_WIDTH,y:i}})),i+=(s=d.height)!=null?s:0}},ea=(e,t)=>{var h,y,m,x;let o=[];for(let T of t.values())T.parentId===e.id&&o.push(T);let n=$t(o),r=((y=(h=e.measured)==null?void 0:h.width)!=null?y:0)-re.HEADER_WIDTH,i=Zs(e.id,o)||re.MIN_WIDTH,a=o.reduce((T,E)=>{var N;return T+((N=E.height)!=null?N:re.MIN_HEIGHT)},0),s=Math.max(r,i),l=a,c=r>i,d=c?s:s+re.HEADER_WIDTH,u=c?s-re.HEADER_WIDTH:s,f=0;for(let T=0;T<n.length;T++){let E=n[T],N=Math.max(re.MIN_HEIGHT,(m=E.height)!=null?m:re.MIN_HEIGHT),b=v(_({},E),{width:u,height:N,measured:v(_({},E.measured),{width:u,height:N}),position:{x:re.HEADER_WIDTH,y:f}});if(T===o.length-1){let g=Math.max(re.MIN_HEIGHT,l-f);b=v(_({},b),{height:g,measured:v(_({},E.measured),{width:u,height:g})})}t.set(E.id,b),f+=(x=b.height)!=null?x:0}let p=Math.max(l,f);t.set(e.id,v(_({},e),{width:d,height:p,measured:v(_({},e.measured),{width:d,height:p})}))},ta=(e,t,o,n,r)=>{var h,y;let i=!e.parentId,a=i?e.id:e.parentId,s=n.filter(m=>m.type==="LANE"&&m.parentId===a);if(!s.length)return n;let l=$t(s),c=l.findIndex(m=>m.id===e.id),d=(y=(h=e.position)==null?void 0:h.y)!=null?y:0,u=!i&&r!==void 0&&c>0&&Math.abs(r-d)>.5,f=0,p=[...n];return l.forEach((m,x)=>{var g,w;let T=x===l.length-1,E=m.id===e.id,b=(w=(g=m.measured)==null?void 0:g.height)!=null?w:0;E?b=o:u&&x===c-1&&(b=Math.max(re.MIN_HEIGHT,r-f)),T&&i&&(b=Math.max(re.MIN_HEIGHT,o-f)),p=p.map(A=>{if(A.id===m.id){let I=i?t-re.HEADER_WIDTH:t;return v(_({},A),{width:I,height:b,measured:v(_({},A.measured),{width:I,height:b}),position:{x:re.HEADER_WIDTH,y:f}})}return A}),E&&u?f=r+o:f+=b}),p=p.map(m=>{if(m.id===a){let x=i?t:t+re.HEADER_WIDTH;return v(_({},m),{width:x,height:i?o:f,measured:{width:x,height:i?o:f}})}return m}),p};var ki=(e,t,o)=>{var s,l,c,d,u,f,p,h;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<he&&(e.position.y=he),e.position.x<re.HEADER_WIDTH+he&&(e.position.x=re.HEADER_WIDTH+he);let i=e.position.x+((f=(u=e.measured)==null?void 0:u.width)!=null?f:0),a=e.position.y+((h=(p=e.measured)==null?void 0:p.height)!=null?h:0);return i+he>n&&(t.width=i+he,t.measured.width=i+he),a+he>r&&(t.height=a+he,t.measured.height=a+he),o=o.map(y=>y.id===t.id?v(_({},y),{height:t.height,width:t.width,measured:t.measured}):y.id===e.id?v(_({},y),{position:e.position}):y),o};import{create as Ip}from"zustand";import{useReactFlow as Ap}from"@xyflow/react";import{useCallback as Cp}from"react";var Yn=()=>{let{setEdges:e}=Ap();return Cp(()=>{let o=Kt.getState().pathEdgeIds;e(n=>n.map(r=>v(_({},r),{selected:o.includes(r.id)})))},[e])},Kt=Ip((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 f=[],p=new Set;for(f.push({node:d,path:[]}),p.add(d);f.length>0;){let{node:h,path:y}=f.shift();if(h===u)return y;let m=a[h]||[];for(let{targetId:x,edgeId:T}of m)p.has(x)||(p.add(x),f.push({node:x,path:[...y,T]}))}return[]};for(let d=0;d<r.length-1;d++){let u=r[d],f=r[d+1],p=c(u,f);p.length>0&&i.push(...p)}i.length>0&&e({pathEdgeIds:i})}}));import{useNodesInitialized as Fm,useReactFlow as Xm,useStore as Um}from"@xyflow/react";import{useCallback as an,useEffect as $m,useRef as Km,useState as ql}from"react";import{shallow as qm}from"zustand/shallow";var Sp={value:()=>{}};function na(){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 Wn(o)}function Wn(e){this._=e}function Mp(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}})}Wn.prototype=na.prototype={constructor:Wn,on:function(e,t){var o=this._,n=Mp(e+"",o),r,i=-1,a=n.length;if(arguments.length<2){for(;++i<a;)if((r=(e=n[i]).type)&&(r=Pp(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]=oa(o[r],e.name,t);else if(t==null)for(r in o)o[r]=oa(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 Wn(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 Pp(e,t){for(var o=0,n=e.length,r;o<n;++o)if((r=e[o]).name===t)return r.value}function oa(e,t,o){for(var n=0,r=e.length;n<r;++n)if(e[n].name===t){e[n]=Sp,e=e.slice(0,n).concat(e.slice(n+1));break}return o!=null&&e.push({name:t,value:o}),e}var Ri=na;var Fn="http://www.w3.org/1999/xhtml",Di={svg:"http://www.w3.org/2000/svg",xhtml:Fn,xlink:"http://www.w3.org/1999/xlink",xml:"http://www.w3.org/XML/1998/namespace",xmlns:"http://www.w3.org/2000/xmlns/"};function ft(e){var t=e+="",o=t.indexOf(":");return o>=0&&(t=e.slice(0,o))!=="xmlns"&&(e=e.slice(o+1)),Di.hasOwnProperty(t)?{space:Di[t],local:e}:e}function Lp(e){return function(){var t=this.ownerDocument,o=this.namespaceURI;return o===Fn&&t.documentElement.namespaceURI===Fn?t.createElement(e):t.createElementNS(o,e)}}function kp(e){return function(){return this.ownerDocument.createElementNS(e.space,e.local)}}function Xn(e){var t=ft(e);return(t.local?kp:Lp)(t)}function Rp(){}function qt(e){return e==null?Rp:function(){return this.querySelector(e)}}function ra(e){typeof e!="function"&&(e=qt(e));for(var t=this._groups,o=t.length,n=new Array(o),r=0;r<o;++r)for(var i=t[r],a=i.length,s=n[r]=new Array(a),l,c,d=0;d<a;++d)(l=i[d])&&(c=e.call(l,l.__data__,d,i))&&("__data__"in l&&(c.__data__=l.__data__),s[d]=c);return new Ee(n,this._parents)}function Oi(e){return e==null?[]:Array.isArray(e)?e:Array.from(e)}function Dp(){return[]}function Uo(e){return e==null?Dp:function(){return this.querySelectorAll(e)}}function Op(e){return function(){return Oi(e.apply(this,arguments))}}function ia(e){typeof e=="function"?e=Op(e):e=Uo(e);for(var t=this._groups,o=t.length,n=[],r=[],i=0;i<o;++i)for(var a=t[i],s=a.length,l,c=0;c<s;++c)(l=a[c])&&(n.push(e.call(l,l.__data__,c,a)),r.push(l));return new Ee(n,r)}function $o(e){return function(){return this.matches(e)}}function Un(e){return function(t){return t.matches(e)}}var Hp=Array.prototype.find;function Vp(e){return function(){return Hp.call(this.children,e)}}function Gp(){return this.firstElementChild}function sa(e){return this.select(e==null?Gp:Vp(typeof e=="function"?e:Un(e)))}var Bp=Array.prototype.filter;function zp(){return Array.from(this.children)}function Yp(e){return function(){return Bp.call(this.children,e)}}function aa(e){return this.selectAll(e==null?zp:Yp(typeof e=="function"?e:Un(e)))}function la(e){typeof e!="function"&&(e=$o(e));for(var t=this._groups,o=t.length,n=new Array(o),r=0;r<o;++r)for(var i=t[r],a=i.length,s=n[r]=[],l,c=0;c<a;++c)(l=i[c])&&e.call(l,l.__data__,c,i)&&s.push(l);return new Ee(n,this._parents)}function $n(e){return new Array(e.length)}function ca(){return new Ee(this._enter||this._groups.map($n),this._parents)}function Ko(e,t){this.ownerDocument=e.ownerDocument,this.namespaceURI=e.namespaceURI,this._next=null,this._parent=e,this.__data__=t}Ko.prototype={constructor:Ko,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 da(e){return function(){return e}}function Wp(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 Ko(e,i[a]);for(;a<l;++a)(s=t[a])&&(r[a]=s)}function Fp(e,t,o,n,r,i,a){var s,l,c=new Map,d=t.length,u=i.length,f=new Array(d),p;for(s=0;s<d;++s)(l=t[s])&&(f[s]=p=a.call(l,l.__data__,s,t)+"",c.has(p)?r[s]=l:c.set(p,l));for(s=0;s<u;++s)p=a.call(e,i[s],s,i)+"",(l=c.get(p))?(n[s]=l,l.__data__=i[s],c.delete(p)):o[s]=new Ko(e,i[s]);for(s=0;s<d;++s)(l=t[s])&&c.get(f[s])===l&&(r[s]=l)}function Xp(e){return e.__data__}function ua(e,t){if(!arguments.length)return Array.from(this,Xp);var o=t?Fp:Wp,n=this._parents,r=this._groups;typeof e!="function"&&(e=da(e));for(var i=r.length,a=new Array(i),s=new Array(i),l=new Array(i),c=0;c<i;++c){var d=n[c],u=r[c],f=u.length,p=Up(e.call(d,d&&d.__data__,c,n)),h=p.length,y=s[c]=new Array(h),m=a[c]=new Array(h),x=l[c]=new Array(f);o(d,u,y,m,x,p,t);for(var T=0,E=0,N,b;T<h;++T)if(N=y[T]){for(T>=E&&(E=T+1);!(b=m[E])&&++E<h;);N._next=b||null}}return a=new Ee(a,n),a._enter=s,a._exit=l,a}function Up(e){return typeof e=="object"&&"length"in e?e:Array.from(e)}function pa(){return new Ee(this._exit||this._groups.map($n),this._parents)}function fa(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 ma(e){for(var t=e.selection?e.selection():e,o=this._groups,n=t._groups,r=o.length,i=n.length,a=Math.min(r,i),s=new Array(r),l=0;l<a;++l)for(var c=o[l],d=n[l],u=c.length,f=s[l]=new Array(u),p,h=0;h<u;++h)(p=c[h]||d[h])&&(f[h]=p);for(;l<r;++l)s[l]=o[l];return new Ee(s,this._parents)}function ga(){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 ha(e){e||(e=$p);function t(u,f){return u&&f?e(u.__data__,f.__data__):!u-!f}for(var o=this._groups,n=o.length,r=new Array(n),i=0;i<n;++i){for(var a=o[i],s=a.length,l=r[i]=new Array(s),c,d=0;d<s;++d)(c=a[d])&&(l[d]=c);l.sort(t)}return new Ee(r,this._parents).order()}function $p(e,t){return e<t?-1:e>t?1:e>=t?0:NaN}function ya(){var e=arguments[0];return arguments[0]=this,e.apply(null,arguments),this}function xa(){return Array.from(this)}function Ea(){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 ba(){let e=0;for(let t of this)++e;return e}function _a(){return!this.node()}function Ta(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 Kp(e){return function(){this.removeAttribute(e)}}function qp(e){return function(){this.removeAttributeNS(e.space,e.local)}}function Zp(e,t){return function(){this.setAttribute(e,t)}}function Jp(e,t){return function(){this.setAttributeNS(e.space,e.local,t)}}function Qp(e,t){return function(){var o=t.apply(this,arguments);o==null?this.removeAttribute(e):this.setAttribute(e,o)}}function jp(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 Na(e,t){var o=ft(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?qp:Kp:typeof t=="function"?o.local?jp:Qp:o.local?Jp:Zp)(o,t))}function Kn(e){return e.ownerDocument&&e.ownerDocument.defaultView||e.document&&e||e.defaultView}function ef(e){return function(){this.style.removeProperty(e)}}function tf(e,t,o){return function(){this.style.setProperty(e,t,o)}}function of(e,t,o){return function(){var n=t.apply(this,arguments);n==null?this.style.removeProperty(e):this.style.setProperty(e,n,o)}}function va(e,t,o){return arguments.length>1?this.each((t==null?ef:typeof t=="function"?of:tf)(e,t,o==null?"":o)):wt(this.node(),e)}function wt(e,t){return e.style.getPropertyValue(t)||Kn(e).getComputedStyle(e,null).getPropertyValue(t)}function nf(e){return function(){delete this[e]}}function rf(e,t){return function(){this[e]=t}}function sf(e,t){return function(){var o=t.apply(this,arguments);o==null?delete this[e]:this[e]=o}}function wa(e,t){return arguments.length>1?this.each((t==null?nf:typeof t=="function"?sf:rf)(e,t)):this.node()[e]}function Ia(e){return e.trim().split(/^|\s+/)}function Hi(e){return e.classList||new Aa(e)}function Aa(e){this._node=e,this._names=Ia(e.getAttribute("class")||"")}Aa.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 Ca(e,t){for(var o=Hi(e),n=-1,r=t.length;++n<r;)o.add(t[n])}function Sa(e,t){for(var o=Hi(e),n=-1,r=t.length;++n<r;)o.remove(t[n])}function af(e){return function(){Ca(this,e)}}function lf(e){return function(){Sa(this,e)}}function cf(e,t){return function(){(t.apply(this,arguments)?Ca:Sa)(this,e)}}function Ma(e,t){var o=Ia(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"?cf:t?af:lf)(o,t))}function df(){this.textContent=""}function uf(e){return function(){this.textContent=e}}function pf(e){return function(){var t=e.apply(this,arguments);this.textContent=t==null?"":t}}function Pa(e){return arguments.length?this.each(e==null?df:(typeof e=="function"?pf:uf)(e)):this.node().textContent}function ff(){this.innerHTML=""}function mf(e){return function(){this.innerHTML=e}}function gf(e){return function(){var t=e.apply(this,arguments);this.innerHTML=t==null?"":t}}function La(e){return arguments.length?this.each(e==null?ff:(typeof e=="function"?gf:mf)(e)):this.node().innerHTML}function hf(){this.nextSibling&&this.parentNode.appendChild(this)}function ka(){return this.each(hf)}function yf(){this.previousSibling&&this.parentNode.insertBefore(this,this.parentNode.firstChild)}function Ra(){return this.each(yf)}function Da(e){var t=typeof e=="function"?e:Xn(e);return this.select(function(){return this.appendChild(t.apply(this,arguments))})}function xf(){return null}function Oa(e,t){var o=typeof e=="function"?e:Xn(e),n=t==null?xf:typeof t=="function"?t:qt(t);return this.select(function(){return this.insertBefore(o.apply(this,arguments),n.apply(this,arguments)||null)})}function Ef(){var e=this.parentNode;e&&e.removeChild(this)}function Ha(){return this.each(Ef)}function bf(){var e=this.cloneNode(!1),t=this.parentNode;return t?t.insertBefore(e,this.nextSibling):e}function _f(){var e=this.cloneNode(!0),t=this.parentNode;return t?t.insertBefore(e,this.nextSibling):e}function Va(e){return this.select(e?_f:bf)}function Ga(e){return arguments.length?this.property("__data__",e):this.node().__data__}function Tf(e){return function(t){e.call(this,t,this.__data__)}}function Nf(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 vf(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 wf(e,t,o){return function(){var n=this.__on,r,i=Tf(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 Ba(e,t,o){var n=Nf(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?wf:vf,r=0;r<i;++r)this.each(s(n[r],t,o));return this}function za(e,t,o){var n=Kn(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 If(e,t){return function(){return za(this,e,t)}}function Af(e,t){return function(){return za(this,e,t.apply(this,arguments))}}function Ya(e,t){return this.each((typeof t=="function"?Af:If)(e,t))}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,a;r<i;++r)(a=n[r])&&(yield a)}var Cf=[null];function Ee(e,t){this._groups=e,this._parents=t}function Fa(){return new Ee([[document.documentElement]],Cf)}function Sf(){return this}Ee.prototype=Fa.prototype={constructor:Ee,select:ra,selectAll:ia,selectChild:sa,selectChildren:aa,filter:la,data:ua,enter:ca,exit:pa,join:fa,merge:ma,selection:Sf,order:ga,sort:ha,call:ya,nodes:xa,node:Ea,size:ba,empty:_a,each:Ta,attr:Na,style:va,property:wa,classed:Ma,text:Pa,html:La,raise:ka,lower:Ra,append:Da,insert:Oa,remove:Ha,clone:Va,datum:Ga,on:Ba,dispatch:Ya,[Symbol.iterator]:Wa};var mt=Fa;function qn(e,t,o){e.prototype=t.prototype=o,o.constructor=e}function Vi(e,t){var o=Object.create(e.prototype);for(var n in t)o[n]=t[n];return o}function Jo(){}var qo=.7,Qn=1/qo,xo="\\s*([+-]?\\d+)\\s*",Zo="\\s*([+-]?(?:\\d*\\.)?\\d+(?:[eE][+-]?\\d+)?)\\s*",lt="\\s*([+-]?(?:\\d*\\.)?\\d+(?:[eE][+-]?\\d+)?)%\\s*",Mf=/^#([0-9a-f]{3,8})$/,Pf=new RegExp(`^rgb\\(${xo},${xo},${xo}\\)$`),Lf=new RegExp(`^rgb\\(${lt},${lt},${lt}\\)$`),kf=new RegExp(`^rgba\\(${xo},${xo},${xo},${Zo}\\)$`),Rf=new RegExp(`^rgba\\(${lt},${lt},${lt},${Zo}\\)$`),Df=new RegExp(`^hsl\\(${Zo},${lt},${lt}\\)$`),Of=new RegExp(`^hsla\\(${Zo},${lt},${lt},${Zo}\\)$`),Xa={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};qn(Jo,It,{copy(e){return Object.assign(new this.constructor,this,e)},displayable(){return this.rgb().displayable()},hex:Ua,formatHex:Ua,formatHex8:Hf,formatHsl:Vf,formatRgb:$a,toString:$a});function Ua(){return this.rgb().formatHex()}function Hf(){return this.rgb().formatHex8()}function Vf(){return ja(this).formatHsl()}function $a(){return this.rgb().formatRgb()}function It(e){var t,o;return e=(e+"").trim().toLowerCase(),(t=Mf.exec(e))?(o=t[1].length,t=parseInt(t[1],16),o===6?Ka(t):o===3?new He(t>>8&15|t>>4&240,t>>4&15|t&240,(t&15)<<4|t&15,1):o===8?Zn(t>>24&255,t>>16&255,t>>8&255,(t&255)/255):o===4?Zn(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=Pf.exec(e))?new He(t[1],t[2],t[3],1):(t=Lf.exec(e))?new He(t[1]*255/100,t[2]*255/100,t[3]*255/100,1):(t=kf.exec(e))?Zn(t[1],t[2],t[3],t[4]):(t=Rf.exec(e))?Zn(t[1]*255/100,t[2]*255/100,t[3]*255/100,t[4]):(t=Df.exec(e))?Ja(t[1],t[2]/100,t[3]/100,1):(t=Of.exec(e))?Ja(t[1],t[2]/100,t[3]/100,t[4]):Xa.hasOwnProperty(e)?Ka(Xa[e]):e==="transparent"?new He(NaN,NaN,NaN,0):null}function Ka(e){return new He(e>>16&255,e>>8&255,e&255,1)}function Zn(e,t,o,n){return n<=0&&(e=t=o=NaN),new He(e,t,o,n)}function Gf(e){return e instanceof Jo||(e=It(e)),e?(e=e.rgb(),new He(e.r,e.g,e.b,e.opacity)):new He}function Eo(e,t,o,n){return arguments.length===1?Gf(e):new He(e,t,o,n==null?1:n)}function He(e,t,o,n){this.r=+e,this.g=+t,this.b=+o,this.opacity=+n}qn(He,Eo,Vi(Jo,{brighter(e){return e=e==null?Qn:Math.pow(Qn,e),new He(this.r*e,this.g*e,this.b*e,this.opacity)},darker(e){return e=e==null?qo:Math.pow(qo,e),new He(this.r*e,this.g*e,this.b*e,this.opacity)},rgb(){return this},clamp(){return new He(Jt(this.r),Jt(this.g),Jt(this.b),jn(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:qa,formatHex:qa,formatHex8:Bf,formatRgb:Za,toString:Za}));function qa(){return`#${Zt(this.r)}${Zt(this.g)}${Zt(this.b)}`}function Bf(){return`#${Zt(this.r)}${Zt(this.g)}${Zt(this.b)}${Zt((isNaN(this.opacity)?1:this.opacity)*255)}`}function Za(){let e=jn(this.opacity);return`${e===1?"rgb(":"rgba("}${Jt(this.r)}, ${Jt(this.g)}, ${Jt(this.b)}${e===1?")":`, ${e})`}`}function jn(e){return isNaN(e)?1:Math.max(0,Math.min(1,e))}function Jt(e){return Math.max(0,Math.min(255,Math.round(e)||0))}function Zt(e){return e=Jt(e),(e<16?"0":"")+e.toString(16)}function Ja(e,t,o,n){return n<=0?e=t=o=NaN:o<=0||o>=1?e=t=NaN:t<=0&&(e=NaN),new tt(e,t,o,n)}function ja(e){if(e instanceof tt)return new tt(e.h,e.s,e.l,e.opacity);if(e instanceof Jo||(e=It(e)),!e)return new tt;if(e instanceof tt)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 tt(a,s,l,e.opacity)}function el(e,t,o,n){return arguments.length===1?ja(e):new tt(e,t,o,n==null?1:n)}function tt(e,t,o,n){this.h=+e,this.s=+t,this.l=+o,this.opacity=+n}qn(tt,el,Vi(Jo,{brighter(e){return e=e==null?Qn:Math.pow(Qn,e),new tt(this.h,this.s,this.l*e,this.opacity)},darker(e){return e=e==null?qo:Math.pow(qo,e),new tt(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 He(Gi(e>=240?e-240:e+120,r,n),Gi(e,r,n),Gi(e<120?e+240:e-120,r,n),this.opacity)},clamp(){return new tt(Qa(this.h),Jn(this.s),Jn(this.l),jn(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=jn(this.opacity);return`${e===1?"hsl(":"hsla("}${Qa(this.h)}, ${Jn(this.s)*100}%, ${Jn(this.l)*100}%${e===1?")":`, ${e})`}`}}));function Qa(e){return e=(e||0)%360,e<0?e+360:e}function Jn(e){return Math.max(0,Math.min(1,e||0))}function Gi(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 Bi(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 tl(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 Bi((o-n/t)*t,a,r,i,s)}}function ol(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 Bi((o-n/t)*t,r,i,a,s)}}var zi=e=>()=>e;function zf(e,t){return function(o){return e+o*t}}function Yf(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 nl(e){return(e=+e)==1?er:function(t,o){return o-t?Yf(t,o,e):zi(isNaN(t)?o:t)}}function er(e,t){var o=t-e;return o?zf(e,o):zi(isNaN(e)?t:e)}var tr=function e(t){var o=nl(t);function n(r,i){var a=o((r=Eo(r)).r,(i=Eo(i)).r),s=o(r.g,i.g),l=o(r.b,i.b),c=er(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 rl(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=Eo(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 Wf=rl(tl),Ff=rl(ol);function Ke(e,t){return e=+e,t=+t,function(o){return e*(1-o)+t*o}}var Wi=/[-+]?(?:\d+\.?\d*|\.?\d+)(?:[eE][-+]?\d+)?/g,Yi=new RegExp(Wi.source,"g");function Xf(e){return function(){return e}}function Uf(e){return function(t){return e(t)+""}}function Fi(e,t){var o=Wi.lastIndex=Yi.lastIndex=0,n,r,i,a=-1,s=[],l=[];for(e=e+"",t=t+"";(n=Wi.exec(e))&&(r=Yi.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:Ke(n,r)})),o=Yi.lastIndex;return o<t.length&&(i=t.slice(o),s[a]?s[a]+=i:s[++a]=i),s.length<2?l[0]?Uf(l[0].x):Xf(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 il=180/Math.PI,or={translateX:0,translateY:0,rotate:0,skewX:0,scaleX:1,scaleY:1};function Xi(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)*il,skewX:Math.atan(l)*il,scaleX:a,scaleY:s}}var nr;function sl(e){let t=new(typeof DOMMatrix=="function"?DOMMatrix:WebKitCSSMatrix)(e+"");return t.isIdentity?or:Xi(t.a,t.b,t.c,t.d,t.e,t.f)}function al(e){return e==null?or:(nr||(nr=document.createElementNS("http://www.w3.org/2000/svg","g")),nr.setAttribute("transform",e),(e=nr.transform.baseVal.consolidate())?(e=e.matrix,Xi(e.a,e.b,e.c,e.d,e.e,e.f)):or)}function ll(e,t,o,n){function r(c){return c.length?c.pop()+" ":""}function i(c,d,u,f,p,h){if(c!==u||d!==f){var y=p.push("translate(",null,t,null,o);h.push({i:y-4,x:Ke(c,u)},{i:y-2,x:Ke(d,f)})}else(u||f)&&p.push("translate("+u+t+f+o)}function a(c,d,u,f){c!==d?(c-d>180?d+=360:d-c>180&&(c+=360),f.push({i:u.push(r(u)+"rotate(",null,n)-2,x:Ke(c,d)})):d&&u.push(r(u)+"rotate("+d+n)}function s(c,d,u,f){c!==d?f.push({i:u.push(r(u)+"skewX(",null,n)-2,x:Ke(c,d)}):d&&u.push(r(u)+"skewX("+d+n)}function l(c,d,u,f,p,h){if(c!==u||d!==f){var y=p.push(r(p)+"scale(",null,",",null,")");h.push({i:y-4,x:Ke(c,u)},{i:y-2,x:Ke(d,f)})}else(u!==1||f!==1)&&p.push(r(p)+"scale("+u+","+f+")")}return function(c,d){var u=[],f=[];return c=e(c),d=e(d),i(c.translateX,c.translateY,d.translateX,d.translateY,u,f),a(c.rotate,d.rotate,u,f),s(c.skewX,d.skewX,u,f),l(c.scaleX,c.scaleY,d.scaleX,d.scaleY,u,f),c=d=null,function(p){for(var h=-1,y=f.length,m;++h<y;)u[(m=f[h]).i]=m.x(p);return u.join("")}}}var Ui=ll(sl,"px, ","px)","deg)"),$i=ll(al,", ",")",")");var bo=0,jo=0,Qo=0,dl=1e3,rr,en,ir=0,Qt=0,sr=0,tn=typeof performance=="object"&&performance.now?performance:Date,ul=typeof window=="object"&&window.requestAnimationFrame?window.requestAnimationFrame.bind(window):function(e){setTimeout(e,17)};function nn(){return Qt||(ul($f),Qt=tn.now()+sr)}function $f(){Qt=0}function on(){this._call=this._time=this._next=null}on.prototype=ar.prototype={constructor:on,restart:function(e,t,o){if(typeof e!="function")throw new TypeError("callback is not a function");o=(o==null?nn():+o)+(t==null?0:+t),!this._next&&en!==this&&(en?en._next=this:rr=this,en=this),this._call=e,this._time=o,Ki()},stop:function(){this._call&&(this._call=null,this._time=1/0,Ki())}};function ar(e,t,o){var n=new on;return n.restart(e,t,o),n}function pl(){nn(),++bo;for(var e=rr,t;e;)(t=Qt-e._time)>=0&&e._call.call(void 0,t),e=e._next;--bo}function cl(){Qt=(ir=tn.now())+sr,bo=jo=0;try{pl()}finally{bo=0,qf(),Qt=0}}function Kf(){var e=tn.now(),t=e-ir;t>dl&&(sr-=t,ir=e)}function qf(){for(var e,t=rr,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:rr=o);en=e,Ki(n)}function Ki(e){if(!bo){jo&&(jo=clearTimeout(jo));var t=e-Qt;t>24?(e<1/0&&(jo=setTimeout(cl,e-tn.now()-sr)),Qo&&(Qo=clearInterval(Qo))):(Qo||(ir=tn.now(),Qo=setInterval(Kf,dl)),bo=1,ul(cl))}}function lr(e,t,o){var n=new on;return t=t==null?0:+t,n.restart(r=>{n.stop(),e(r+t)},t,o),n}var Zf=Ri("start","end","cancel","interrupt"),Jf=[],gl=0,fl=1,dr=2,cr=3,ml=4,ur=5,rn=6;function At(e,t,o,n,r,i){var a=e.__transition;if(!a)e.__transition={};else if(o in a)return;Qf(e,o,{name:t,index:n,group:r,on:Zf,tween:Jf,time:i.time,delay:i.delay,duration:i.duration,ease:i.ease,timer:null,state:gl})}function sn(e,t){var o=be(e,t);if(o.state>gl)throw new Error("too late; already scheduled");return o}function Ae(e,t){var o=be(e,t);if(o.state>cr)throw new Error("too late; already running");return o}function be(e,t){var o=e.__transition;if(!o||!(o=o[t]))throw new Error("transition not found");return o}function Qf(e,t,o){var n=e.__transition,r;n[t]=o,o.timer=ar(i,0,o.time);function i(c){o.state=fl,o.timer.restart(a,o.delay,o.time),o.delay<=c&&a(c-o.delay)}function a(c){var d,u,f,p;if(o.state!==fl)return l();for(d in n)if(p=n[d],p.name===o.name){if(p.state===cr)return lr(a);p.state===ml?(p.state=rn,p.timer.stop(),p.on.call("interrupt",e,e.__data__,p.index,p.group),delete n[d]):+d<t&&(p.state=rn,p.timer.stop(),p.on.call("cancel",e,e.__data__,p.index,p.group),delete n[d])}if(lr(function(){o.state===cr&&(o.state=ml,o.timer.restart(s,o.delay,o.time),s(c))}),o.state=dr,o.on.call("start",e,e.__data__,o.index,o.group),o.state===dr){for(o.state=cr,r=new Array(f=o.tween.length),d=0,u=-1;d<f;++d)(p=o.tween[d].value.call(e,e.__data__,o.index,o.group))&&(r[++u]=p);r.length=u+1}}function s(c){for(var d=c<o.duration?o.ease.call(null,c/o.duration):(o.timer.restart(l),o.state=ur,1),u=-1,f=r.length;++u<f;)r[u].call(e,d);o.state===ur&&(o.on.call("end",e,e.__data__,o.index,o.group),l())}function l(){o.state=rn,o.timer.stop(),delete n[t];for(var c in n)return;delete e.__transition}}function qi(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>dr&&n.state<ur,n.state=rn,n.timer.stop(),n.on.call(r?"interrupt":"cancel",e,e.__data__,n.index,n.group),delete o[a]}i&&delete e.__transition}}function hl(e){return this.each(function(){qi(this,e)})}function jf(e,t){var o,n;return function(){var r=Ae(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 em(e,t,o){var n,r;if(typeof o!="function")throw new Error;return function(){var i=Ae(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 yl(e,t){var o=this._id;if(e+="",arguments.length<2){for(var n=be(this.node(),o).tween,r=0,i=n.length,a;r<i;++r)if((a=n[r]).name===e)return a.value;return null}return this.each((t==null?jf:em)(o,e,t))}function _o(e,t,o){var n=e._id;return e.each(function(){var r=Ae(this,n);(r.value||(r.value={}))[t]=o.apply(this,arguments)}),function(r){return be(r,n).value[t]}}function pr(e,t){var o;return(typeof t=="number"?Ke:t instanceof It?tr:(o=It(t))?(t=o,tr):Fi)(e,t)}function tm(e){return function(){this.removeAttribute(e)}}function om(e){return function(){this.removeAttributeNS(e.space,e.local)}}function nm(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 rm(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 im(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 sm(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 xl(e,t){var o=ft(e),n=o==="transform"?$i:pr;return this.attrTween(e,typeof t=="function"?(o.local?sm:im)(o,n,_o(this,"attr."+e,t)):t==null?(o.local?om:tm)(o):(o.local?rm:nm)(o,n,t))}function am(e,t){return function(o){this.setAttribute(e,t.call(this,o))}}function lm(e,t){return function(o){this.setAttributeNS(e.space,e.local,t.call(this,o))}}function cm(e,t){var o,n;function r(){var i=t.apply(this,arguments);return i!==n&&(o=(n=i)&&lm(e,i)),o}return r._value=t,r}function dm(e,t){var o,n;function r(){var i=t.apply(this,arguments);return i!==n&&(o=(n=i)&&am(e,i)),o}return r._value=t,r}function El(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=ft(e);return this.tween(o,(n.local?cm:dm)(n,t))}function um(e,t){return function(){sn(this,e).delay=+t.apply(this,arguments)}}function pm(e,t){return t=+t,function(){sn(this,e).delay=t}}function bl(e){var t=this._id;return arguments.length?this.each((typeof e=="function"?um:pm)(t,e)):be(this.node(),t).delay}function fm(e,t){return function(){Ae(this,e).duration=+t.apply(this,arguments)}}function mm(e,t){return t=+t,function(){Ae(this,e).duration=t}}function _l(e){var t=this._id;return arguments.length?this.each((typeof e=="function"?fm:mm)(t,e)):be(this.node(),t).duration}function gm(e,t){if(typeof t!="function")throw new Error;return function(){Ae(this,e).ease=t}}function Tl(e){var t=this._id;return arguments.length?this.each(gm(t,e)):be(this.node(),t).ease}function hm(e,t){return function(){var o=t.apply(this,arguments);if(typeof o!="function")throw new Error;Ae(this,e).ease=o}}function Nl(e){if(typeof e!="function")throw new Error;return this.each(hm(this._id,e))}function vl(e){typeof e!="function"&&(e=$o(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 Re(n,this._parents,this._name,this._id)}function wl(e){if(e._id!==this._id)throw new Error;for(var t=this._groups,o=e._groups,n=t.length,r=o.length,i=Math.min(n,r),a=new Array(n),s=0;s<i;++s)for(var l=t[s],c=o[s],d=l.length,u=a[s]=new Array(d),f,p=0;p<d;++p)(f=l[p]||c[p])&&(u[p]=f);for(;s<n;++s)a[s]=t[s];return new Re(a,this._parents,this._name,this._id)}function ym(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 xm(e,t,o){var n,r,i=ym(t)?sn:Ae;return function(){var a=i(this,e),s=a.on;s!==n&&(r=(n=s).copy()).on(t,o),a.on=r}}function Il(e,t){var o=this._id;return arguments.length<2?be(this.node(),o).on.on(e):this.each(xm(o,e,t))}function Em(e){return function(){var t=this.parentNode;for(var o in this.__transition)if(+o!==e)return;t&&t.removeChild(this)}}function Al(){return this.on("end.remove",Em(this._id))}function Cl(e){var t=this._name,o=this._id;typeof e!="function"&&(e=qt(e));for(var n=this._groups,r=n.length,i=new Array(r),a=0;a<r;++a)for(var s=n[a],l=s.length,c=i[a]=new Array(l),d,u,f=0;f<l;++f)(d=s[f])&&(u=e.call(d,d.__data__,f,s))&&("__data__"in d&&(u.__data__=d.__data__),c[f]=u,At(c[f],t,o,f,c,be(d,o)));return new Re(i,this._parents,t,o)}function Sl(e){var t=this._name,o=this._id;typeof e!="function"&&(e=Uo(e));for(var n=this._groups,r=n.length,i=[],a=[],s=0;s<r;++s)for(var l=n[s],c=l.length,d,u=0;u<c;++u)if(d=l[u]){for(var f=e.call(d,d.__data__,u,l),p,h=be(d,o),y=0,m=f.length;y<m;++y)(p=f[y])&&At(p,t,o,y,f,h);i.push(f),a.push(d)}return new Re(i,a,t,o)}var bm=mt.prototype.constructor;function Ml(){return new bm(this._groups,this._parents)}function _m(e,t){var o,n,r;return function(){var i=wt(this,e),a=(this.style.removeProperty(e),wt(this,e));return i===a?null:i===o&&a===n?r:r=t(o=i,n=a)}}function Pl(e){return function(){this.style.removeProperty(e)}}function Tm(e,t,o){var n,r=o+"",i;return function(){var a=wt(this,e);return a===r?null:a===n?i:i=t(n=a,o)}}function Nm(e,t,o){var n,r,i;return function(){var a=wt(this,e),s=o(this),l=s+"";return s==null&&(l=s=(this.style.removeProperty(e),wt(this,e))),a===l?null:a===n&&l===r?i:(r=l,i=t(n=a,s))}}function vm(e,t){var o,n,r,i="style."+t,a="end."+i,s;return function(){var l=Ae(this,e),c=l.on,d=l.value[i]==null?s||(s=Pl(t)):void 0;(c!==o||r!==d)&&(n=(o=c).copy()).on(a,r=d),l.on=n}}function Ll(e,t,o){var n=(e+="")=="transform"?Ui:pr;return t==null?this.styleTween(e,_m(e,n)).on("end.style."+e,Pl(e)):typeof t=="function"?this.styleTween(e,Nm(e,n,_o(this,"style."+e,t))).each(vm(this._id,e)):this.styleTween(e,Tm(e,n,t),o).on("end.style."+e,null)}function wm(e,t,o){return function(n){this.style.setProperty(e,t.call(this,n),o)}}function Im(e,t,o){var n,r;function i(){var a=t.apply(this,arguments);return a!==r&&(n=(r=a)&&wm(e,a,o)),n}return i._value=t,i}function kl(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,Im(e,t,o==null?"":o))}function Am(e){return function(){this.textContent=e}}function Cm(e){return function(){var t=e(this);this.textContent=t==null?"":t}}function Rl(e){return this.tween("text",typeof e=="function"?Cm(_o(this,"text",e)):Am(e==null?"":e+""))}function Sm(e){return function(t){this.textContent=e.call(this,t)}}function Mm(e){var t,o;function n(){var r=e.apply(this,arguments);return r!==o&&(t=(o=r)&&Sm(r)),t}return n._value=e,n}function Dl(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,Mm(e))}function Ol(){for(var e=this._name,t=this._id,o=fr(),n=this._groups,r=n.length,i=0;i<r;++i)for(var a=n[i],s=a.length,l,c=0;c<s;++c)if(l=a[c]){var d=be(l,t);At(l,e,o,c,a,{time:d.time+d.delay+d.duration,delay:0,duration:d.duration,ease:d.ease})}return new Re(n,this._parents,e,o)}function Hl(){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=Ae(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 Pm=0;function Re(e,t,o,n){this._groups=e,this._parents=t,this._name=o,this._id=n}function Vl(e){return mt().transition(e)}function fr(){return++Pm}var gt=mt.prototype;Re.prototype=Vl.prototype={constructor:Re,select:Cl,selectAll:Sl,selectChild:gt.selectChild,selectChildren:gt.selectChildren,filter:vl,merge:wl,selection:Ml,transition:Ol,call:gt.call,nodes:gt.nodes,node:gt.node,size:gt.size,empty:gt.empty,each:gt.each,on:Il,attr:xl,attrTween:El,style:Ll,styleTween:kl,text:Rl,textTween:Dl,remove:Al,tween:yl,delay:bl,duration:_l,ease:Tl,easeVarying:Nl,end:Hl,[Symbol.iterator]:gt[Symbol.iterator]};function mr(e){return((e*=2)<=1?e*e*e:(e-=2)*e*e+2)/2}var Lm={time:null,delay:0,duration:250,ease:mr};function km(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 Gl(e){var t,o;e instanceof Re?(t=e._id,e=e._name):(t=fr(),(o=Lm).time=nn(),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])&&At(l,e,t,c,a,o||km(l,t));return new Re(n,this._parents,e,t)}mt.prototype.interrupt=hl;mt.prototype.transition=Gl;function Ct(e,t,o){this.k=e,this.x=t,this.y=o}Ct.prototype={constructor:Ct,scale:function(e){return e===1?this:new Ct(this.k*e,this.x,this.y)},translate:function(e,t){return e===0&t===0?this:new Ct(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 gr=new Ct(1,0,0);hr.prototype=Ct.prototype;function hr(e){for(;!e.__zoom;)if(!(e=e.parentNode))return gr;return e.__zoom}var Dm=[[Number.NEGATIVE_INFINITY,Number.NEGATIVE_INFINITY],[Number.POSITIVE_INFINITY,Number.POSITIVE_INFINITY]];var Bl;(function(e){e.Strict="strict",e.Loose="loose"})(Bl||(Bl={}));var zl;(function(e){e.Free="free",e.Vertical="vertical",e.Horizontal="horizontal"})(zl||(zl={}));var Yl;(function(e){e.Partial="partial",e.Full="full"})(Yl||(Yl={}));var Wl;(function(e){e.Bezier="default",e.Straight="straight",e.Step="step",e.SmoothStep="smoothstep",e.SimpleBezier="simplebezier"})(Wl||(Wl={}));var Fl;(function(e){e.Arrow="arrow",e.ArrowClosed="arrowclosed"})(Fl||(Fl={}));var Ve;(function(e){e.Left="left",e.Top="top",e.Right="right",e.Bottom="bottom"})(Ve||(Ve={}));var xw={[Ve.Left]:Ve.Right,[Ve.Right]:Ve.Left,[Ve.Top]:Ve.Bottom,[Ve.Bottom]:Ve.Top};var Om=e=>"id"in e&&"internals"in e&&!("source"in e)&&!("target"in e);var Hm=(e,t=[0,0])=>{var s;let{width:o,height:n}=Vm(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 yr=(e,t=[0,0])=>{var r,i,a,s,l,c,d,u;let{x:o,y:n}=Om(e)?e.internals.positionAbsolute:Hm(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 Vm(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 Ew={[Ve.Left]:{x:-1,y:0},[Ve.Right]:{x:1,y:0},[Ve.Top]:{x:0,y:-1},[Ve.Bottom]:{x:0,y:1}};var Gm={nodeOrigin:[0,0],nodeExtent:Dm,elevateNodesOnSelect:!0,defaults:{}},bw=v(_({},Gm),{checkEquality:!0});var Xl;(function(e){e.Line="line",e.Handle="handle"})(Xl||(Xl={}));var Bm={width:0,height:0,x:0,y:0},_w=v(_({},Bm),{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 Ym(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 Wm(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 xr=class{constructor(){this.xLines=[];this.yLines=[]}initialize(t){this.xLines=t.filter(o=>o.orientation==="vertical"),this.yLines=t.filter(o=>o.orientation==="horizontal"),this.xLines.sort((o,n)=>o.position-n.position),this.yLines.sort((o,n)=>o.position-n.position),this.lastHorizontalLine=void 0,this.lastVerticalLine=void 0}search(t,o,n,r,i){let a=t==="horizontal"?this.yLines:this.xLines,[s,l]=t==="horizontal"?[r.y,r.y2]:[r.x,r.x2],c=[];for(let p of a){if(p.position<s)continue;if(p.position>l)break;if(i.has(p.node.id)||p.node.parentId&&i.has(p.node.parentId)||!zm(p.nodeBox,r))continue;let h=Math.abs(p.position-o);if(h>Er)continue;let m=Ym(p.nodeBox,n)>0?0:Wm(p.nodeBox,n);c.push({line:p,lineDist:h,nodeDist:m})}let d=.5,u=t==="horizontal"?this.lastHorizontalLine:this.lastVerticalLine;c.sort((p,h)=>{if(u){if(p.line===u&&h.line!==u)return-1;if(h.line===u&&p.line!==u)return 1}return Math.abs(p.lineDist-h.lineDist)<=d?p.nodeDist-h.nodeDist:p.lineDist-h.lineDist});let f=c.length>0?c[0].line:void 0;return f&&(t==="horizontal"?this.lastHorizontalLine=f:this.lastVerticalLine=f),f}};function Ul(e,t=jt,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=yr(i);Object.entries(t).forEach(([s,l])=>{var c;n.push({position:l.resolve(r,a),color:(c=r.style)==null?void 0:c.backgroundColor,orientation:l.orientation,anchorName:s,nodeBox:a,node:r})})}),n}function $l(e,t,o,n,r=Object.keys(jt)){let i=[];for(let s of r){let l=jt[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 Kl(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)<=Er&&(r=l,a=!0)}if(o){let l=o.anchor.resolve(null,e)-o.line.position;Math.abs(l)<=Er&&(n=l,i=!0)}return{deltaX:n,deltaY:r,snappedX:i,snappedY:a}}var Er=10,jt={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 Jm}from"react/jsx-runtime";var Zm=new xr;function br(){let[e,t]=ql(void 0),[o,n]=ql(void 0),{width:r,height:i}=Um(m=>({width:m.width,height:m.height}),qm),a=Fm(),s=Km(Zm),{screenToFlowPosition:l,getInternalNode:c,getNodes:d}=Xm(),u=an(()=>{t(void 0),n(void 0)},[]),f=an(m=>{let x=m!=null?m:d();u();let T=Ul(x,jt,c);s.current.initialize(T)},[c,u,d]),p=an(()=>{setTimeout(()=>{f()},100)},[f]);$m(()=>{a&&f(d())},[a,f,d]);let h=an((m,x)=>{var R,H,k,G,B,K,W,X,Z,j;if(!s.current||m.length===0||m.filter(Y=>Y.type==="dimensions").length>1)return m;u();let E=m.filter(Y=>Y.type==="position"&&!!Y.position),N=m.find(Y=>Y.type==="dimensions");if(E.length===0&&!N)return m;let b=Object.keys(jt),g=new Set,w=1/0,A=1/0,I=-1/0,D=-1/0;if(E.length>0)E.forEach(Y=>{var ge,fe,ce,we,Oe,it;let te=x.find(pt=>pt.id===Y.id);if(!te)return;g.add(te.id);let ne=c(te.id);if(!ne)return;let J=ne.parentId?c(ne.parentId):void 0,le=Y.position.x+((ge=J==null?void 0:J.internals.positionAbsolute.x)!=null?ge:0),de=Y.position.y+((fe=J==null?void 0:J.internals.positionAbsolute.y)!=null?fe:0),ue=(we=(ce=te.measured)==null?void 0:ce.width)!=null?we:0,xe=(it=(Oe=te.measured)==null?void 0:Oe.height)!=null?it:0;w=Math.min(w,le),A=Math.min(A,de),I=Math.max(I,le+ue),D=Math.max(D,de+xe)}),N&&(b=["top","left"]);else if(N){let Y=x.find(ue=>ue.id===N.id);if(!Y)return m;g.add(Y.id);let te=c(Y.id);if(!te)return m;let ne=te.internals.positionAbsolute.x,J=te.internals.positionAbsolute.y,le=(G=(k=(R=N.dimensions)==null?void 0:R.width)!=null?k:(H=Y.measured)==null?void 0:H.width)!=null?G:0,de=(X=(W=(B=N.dimensions)==null?void 0:B.height)!=null?W:(K=Y.measured)==null?void 0:K.height)!=null?X:0;w=ne,A=J,I=ne+le,D=J+de,b=["right","bottom"]}if(w===1/0)return m;let S={x:w,y:A,x2:I,y2:D},{x:L,y:z}=l({x:0,y:0}),{x:q,y:Q}=l({x:r,y:i}),U={x:L,y:z,x2:q,y2:Q},{horizontal:$,vertical:M}=$l(s.current,U,S,g,b),{deltaX:O,deltaY:P,snappedX:C,snappedY:F}=Kl(S,$,M);if(C||F){let Y=E.some(ne=>ne.dragging),te=!!(N!=null&&N.resizing);(Y||te)&&(C&&n(M==null?void 0:M.line),F&&t($==null?void 0:$.line)),C&&(E.forEach(ne=>{ne.position&&(ne.position.x-=O)}),(N==null?void 0:N.id)===((Z=E[0])==null?void 0:Z.id)?N.dimensions&&(N.dimensions.width+=O):N&&!E.length&&N.dimensions&&(N.dimensions.width-=O)),F&&(E.forEach(ne=>{ne.position&&(ne.position.y-=P)}),(N==null?void 0:N.id)===((j=E[0])==null?void 0:j.id)?N.dimensions&&(N.dimensions.height+=P):N&&!E.length&&N.dimensions&&(N.dimensions.height-=P))}return m},[l,c,r,i,t,n,u]),y=an(()=>Jm(Zl,{horizontal:e,vertical:o}),[e,o]);return{rebuildIndex:f,forceRebuildIndex:p,updateHelperLines:h,helperLineHorizontal:e,helperLineVertical:o,HelperLines:y}}import{reconnectEdge as $y,useReactFlow as Ky}from"@xyflow/react";import{useCallback as ro,useRef as qy}from"react";var ht=e=>new Map(e.map(t=>[t.id,t])),ln=(e,t,o)=>t.filter(n=>!(n.source!==e||o&&n.id===o)),Jl=(e,t,o)=>t.filter(n=>!(n.target!==e||o&&n.id===o)),Zi=e=>e.some(t=>t.type==="START_EVENT"),St=(e,t)=>e==="START_EVENT"?!Zi(t):!0,Ql=(e,t,o,n,r)=>{let i=ht(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:ln(e,n,r).filter(c=>{let d=i.get(c.target);return(d==null?void 0:d.type)!=="ANNOTATION"}).length>=1},jl=(e,t,o,n,r)=>{let i=ht(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:Jl(t,n,r).filter(c=>{let d=i.get(c.source);return(d==null?void 0:d.type)!=="ANNOTATION"}).length>=1},_r=(e,t,o,n,r)=>{var c;let i=ht(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:ln(e,n,r).filter(d=>{let u=i.get(d.target);return(u==null?void 0:u.type)!=="ANNOTATION"}).length>=2},ec=(e,t,o)=>{var a,s,l,c;let n=ht(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"},Tr=(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"},tc=(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"},Nr=(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"},cn=(e,t,o,n)=>{let r=ht(t),i=r.get(e);return!i||i.type!=="TASK"?!1:Jl(e,o,n).some(s=>{let l=r.get(s.source);return(l==null?void 0:l.type)==="START_EVENT"})},dn=(e,t,o,n)=>{let r=ht(t),i=r.get(e);return!i||i.type!=="TASK"?!1:ln(e,o,n).some(s=>{let l=r.get(s.target);return(l==null?void 0:l.type)==="END_EVENT"})},oc=(e,t,o,n,r)=>{let i=ht(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"?dn(t,o,n,r):(s==null?void 0:s.type)==="END_EVENT"&&(a==null?void 0:a.type)==="TASK"?cn(e,o,n,r):!1},vr=(e,t,o)=>ln(e,t,o).length>0,wr=(e,t,o,n,r)=>{let i=ht(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:ln(e,n,r).filter(c=>{let d=i.get(c.target);return(d==null?void 0:d.type)!=="ANNOTATION"}).length>=2};var nc=(e,t,o,n,r)=>{var s,l;let i=ht(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 Qm=[e=>({isValid:e.sourceNodeId!==e.targetNodeId,reason:"self_connection_not_allowed"}),e=>({isValid:!nc(e.sourceNodeId,e.targetNodeId,e.edges,e.nodes,e.reconnectingEdgeId),reason:"duplicate_connection_not_allowed"}),e=>({isValid:!Ql(e.sourceNodeId,e.targetNodeId,e.nodes,e.edges,e.reconnectingEdgeId),reason:"start_event_limit_reached"}),e=>({isValid:!jl(e.sourceNodeId,e.targetNodeId,e.nodes,e.edges,e.reconnectingEdgeId),reason:"end_event_limit_reached"}),e=>({isValid:!_r(e.sourceNodeId,e.targetNodeId,e.nodes,e.edges,e.reconnectingEdgeId),reason:"gateway_limit_reached"}),e=>({isValid:!wr(e.sourceNodeId,e.targetNodeId,e.nodes,e.edges,e.reconnectingEdgeId),reason:"task_limit_reached"}),e=>({isValid:ec(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"&&tc(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:!(Tr(e.sourceNodeId,e.nodes)&&e.targetNodeType==="END_EVENT"),reason:"script_to_end_not_allowed"}),e=>({isValid:!(Nr(e.sourceNodeId,e.nodes)&&e.targetNodeType==="END_EVENT"),reason:"loop_to_end_not_allowed"}),e=>({isValid:!(cn(e.sourceNodeId,e.nodes,e.edges,e.reconnectingEdgeId)&&e.targetNodeType==="END_EVENT"),reason:"initial_activity_to_end_not_allowed"}),e=>({isValid:!oc(e.sourceNodeId,e.targetNodeId,e.nodes,e.edges,e.reconnectingEdgeId),reason:"concurrent_initial_and_final_activity"}),e=>({isValid:!(dn(e.sourceNodeId,e.nodes,e.edges,e.reconnectingEdgeId)&&e.targetNodeType!=="ANNOTATION"),reason:"final_activity_cannot_connect"}),e=>({isValid:!(vr(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"})],Ji=e=>{for(let t of Qm){let o=t(e);if(!o.isValid)return o}return{isValid:!0}};var jm=[{sourceTypes:["GATEWAY"],targetTypes:["TASK","GATEWAY"],validate:e=>({shouldDisable:_r(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:Zi(e.nodes),reason:"start_event_already_exists"})},{sourceTypes:["TASK"],targetTypes:["END_EVENT"],validate:e=>({shouldDisable:Tr(e.sourceNodeId,e.nodes),reason:"script_to_end_not_allowed"})},{sourceTypes:["TASK"],targetTypes:["END_EVENT"],validate:e=>({shouldDisable:Nr(e.sourceNodeId,e.nodes),reason:"loop_to_end_not_allowed"})},{sourceTypes:["TASK"],targetTypes:["END_EVENT"],validate:e=>({shouldDisable:cn(e.sourceNodeId,e.nodes,e.edges),reason:"initial_activity_to_end_not_allowed"})},{sourceTypes:["TASK"],validate:e=>({shouldDisable:dn(e.sourceNodeId,e.nodes,e.edges)&&e.targetNodeType!=="ANNOTATION",reason:"final_activity_cannot_connect"})},{targetTypes:["END_EVENT"],validate:e=>({shouldDisable:vr(e.sourceNodeId,e.edges),reason:"activity_has_outgoing_connections"})},{sourceTypes:["TASK"],validate:e=>({shouldDisable:wr(e.sourceNodeId,null,e.nodes,e.edges)&&e.targetNodeType!=="ANNOTATION",reason:"task_limit_reached"})}],rc=e=>{let t=jm.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 Cg,EdgeLabelRenderer as Sg,getStraightPath as Mg,useInternalNode as sc,useViewport as Pg}from"@xyflow/react";import{Button as og,Tooltip as ng,TooltipContent as rg,TooltipTrigger as ig,useTranslation as sg}from"@produto-lecom/lecom-ui";import{Settings as ag}from"lucide-react";import{getIncomers as Ir,getOutgoers as Ar,useReactFlow as tg}from"@xyflow/react";import{useStoreApi as eg}from"@xyflow/react";var Mt=()=>{let e=eg();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 kn(),!0}}};var Cr=()=>{let{getNode:e,getEdge:t,getNodes:o,getEdges:n}=tg(),{selectElements:r}=Mt(),i=m=>{let x=o(),T=n(),E=Ir(m,x,T),N=Ar(m,x,T),b=E.some(w=>w.type==="START_EVENT"),g=N.some(w=>w.type==="END_EVENT");return b?"start":g?"end":"between"},a=(m,x,T)=>{var b,g,w,A;if(!m)return;let E={type:m.type,variant:(b=m.data)==null?void 0:b.variant,attribute:(g=m.data)==null?void 0:g.attribute},N={id:m.id,position:i(m),label:(w=m.data)==null?void 0:w.label,node:E};return m.type==="TASK"&&((A=m.data)==null?void 0:A.variant)==="SUBPROCESS"?v(_({},N),{type:"sub_process"}):m.type==="GATEWAY"?v(_({},N),{type:"gateway",variant:s(m,x,T)}):v(_({},N),{type:"activity"})},s=(m,x,T)=>{if(m.type!=="GATEWAY")return;let E=Ir(m,x,T),N=!1,b=!1;if(E.forEach(g=>{var w,A;g.type==="TASK"&&(((w=g.data)==null?void 0:w.variant)==="SCRIPT"&&(N=!0),((A=g.data)==null?void 0:A.attribute)==="LOOP"&&(b=!0))}),N&&b)return"script_loop";if(N)return"script";if(b)return"loop"},l=(m,x,T)=>{var w,A,I,D;let E=e(m.source),N=e(m.target);if(!E||!N)return"simple";if(Ar(E,x,T).some(S=>S.type==="END_EVENT"))return"final";if(E.type==="GATEWAY")switch((w=E.data)==null?void 0:w.variant){case"PARALLEL":return"parallel";case"EXCLUSIVE":return"exclusive";case"COMPLEX":return"complex";default:return"simple"}if(E.type==="TASK"){let S=(A=E.data)==null?void 0:A.variant,L=(I=E.data)==null?void 0:I.attribute;if(S==="SUBPROCESS")return"from_sub_process";if(N.type==="TASK"&&((D=N.data)==null?void 0:D.variant)==="SUBPROCESS")return"to_sub_process";let z=S==="SCRIPT",q=L==="LOOP";return z&&q?"script_loop":z?"script":q?"loop":"simple"}return"simple"},c=(m,x,T)=>{let E=[];function N(g,w,A=0){let I=a(g,x,T);if(I.depth=A,w.push(I),g.type==="TASK"){E.push([...w]),w.pop();return}let D=Ir(g,x,T);if(D.length)for(let S of D)N(S,w,A+1);w.pop()}let b=Ir(m,x,T);for(let g of b)N(g,[]);return E},d=(m,x,T)=>{let E=[];function N(g,w,A=0){let I=a(g,x,T);if(I.depth=A,w.push(I),g.type==="TASK"){E.push([...w]),w.pop();return}let D=Ar(g,x,T);if(D.length)for(let S of D)N(S,w,A+1);w.pop()}let b=Ar(m,x,T);for(let g of b)N(g,[]);return E},u=(m,x,T)=>(T=T.filter(N=>N.source===m.id),T.map(N=>{var w;let b=e(N.target),g;return b&&(g=a(b,x,T)),{id:N.id,type:"routing",variant:l(N,x,T),label:(w=N.data)==null?void 0:w.label,target:g}})),f=m=>{let x=e(m);if(!x)return;let T=o(),E=n(),N=a(x,T,E);return N.sources=c(x,T,E),N.targets=d(x,T,E),N.edgeTargets=u(x,T,E),x.type==="GATEWAY"&&(N.variant=s(x,T,E)),N},p=m=>{let x=t(m);if(!x)return;let T=o(),E=n(),N=l(x,T,E),g={id:x.id,type:"routing",variant:N,gatewayVariant:void 0},w=e(x.source);if(w){let I=a(w,T,E);g.source=I;let D=s(w,T,E);if(g.gatewayVariant=D,w.type==="TASK")g.sources=[[I]];else{let S=c(w,T,E);g.sources=S.length?S:[[I]]}}let A=e(x.target);if(A){let I=a(A,T,E);if(g.target=I,A.type==="TASK")g.targets=[[I]];else{let D=d(A,T,E);g.targets=D.length?D:[[I]]}}return g},h=m=>{let x=e(m);if(x)return f(x.id);let T=t(m);if(T)return p(T.id)};return{configureElement:m=>{let x=h(m);if(x)return r([m]),x},getConfigureElement:h,getNodeConfigure:f,getEdgeConfigure:p}};import{jsx as Sr,jsxs as lg}from"react/jsx-runtime";var Pt=({elementId:e,elementType:t="node"})=>{let{t:o}=sg(),{onConfigureElement:n}=ee(),{getConfigureElement:r}=Cr();return lg(ng,{children:[Sr(ig,{asChild:!0,children:Sr(og,{variant:"ghost",color:"grey",size:"small",iconButton:!0,onClick:()=>{let a=r(e);a&&(n==null||n(a))},children:Sr(ag,{size:16})})}),Sr(rg,{color:"black",children:o(t==="node"?"editor.toolbar.configure_node":"editor.toolbar.configure_edge")})]})};import{Button as dg,Tooltip as ug,TooltipContent as pg,TooltipTrigger as fg,useTranslation as mg}from"@produto-lecom/lecom-ui";import{useReactFlow as gg}from"@xyflow/react";import{TrashIcon as hg}from"lucide-react";import{useNotificationToast as cg}from"@produto-lecom/lecom-ui";function Ge(){let{toast:e}=un(),{toast:t}=cg();return{toast:e||t}}import{jsx as Mr,jsxs as yg}from"react/jsx-runtime";var Pr=({elementId:e,elementType:t="node"})=>{let{t:o}=mg(),{toast:n}=Ge(),{deleteElements:r,getNodes:i}=gg();return yg(ug,{children:[Mr(fg,{asChild:!0,children:Mr(dg,{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:Mr(hg,{size:16})})}),Mr(pg,{color:"black",children:o("editor.toolbar.delete")})]})};import{Button as xg,Tooltip as Eg,TooltipContent as bg,TooltipTrigger as _g,useTranslation as Tg}from"@produto-lecom/lecom-ui";import{MoveUpRightIcon as Ng}from"lucide-react";import{useCallback as vg}from"react";import{jsx as Lr,jsxs as wg}from"react/jsx-runtime";var To=({nodeId:e,disabled:t=!1,tooltipMessage:o})=>{let{t:n}=Tg(),r=vg(i=>{i.stopPropagation();let a=document.querySelectorAll(`.react-flow__handle.source[data-nodeid="${e}"]`);if(a.length===0)return;let s=Array.from(a).reduce((f,p)=>{let h=f.getBoundingClientRect(),y=p.getBoundingClientRect(),m=Math.hypot(i.clientX-(h.left+h.width/2),i.clientY-(h.top+h.height/2));return Math.hypot(i.clientX-(y.left+y.width/2),i.clientY-(y.top+y.height/2))<m?p:f}),l=s.getBoundingClientRect(),c=l.left+l.width/2,d=l.top+l.height/2,u=new MouseEvent("mousedown",{clientX:c,clientY:d,bubbles:!0,cancelable:!0});s.dispatchEvent(u)},[e]);return wg(Eg,{children:[Lr(_g,{asChild:!0,children:Lr(xg,{variant:"ghost",color:"grey",size:"small",iconButton:!0,disabled:t,className:t?"opacity-50 cursor-not-allowed":"",onMouseDown:t?void 0:r,children:Lr(Ng,{size:16})})}),Lr(bg,{color:"black",children:o||n("editor.toolbar.connect_node")})]})};import{jsx as pn}from"react/jsx-runtime";var vo=i=>{var a=i,{edgeId:e,edgeType:t,sourceNode:o,targetNode:n}=a,r=st(a,["edgeId","edgeType","sourceNode","targetNode"]);let{mode:s}=ee(),{isFromStartEvent:l,isGatewayToGateway:c,isActiviyToAndGateway:d,isToEndEvent:u}=Vn(o,n),f=!l&&!c&&!d&&!u,p=[{component:pn(Pr,{elementId:e,elementType:"edge"})}],h=()=>s==="view"?f?[{component:pn(Pt,{elementId:e,elementType:"edge"})}]:[]:f?[{component:pn(Pt,{elementId:e,elementType:"edge"})},...p]:p,m=(x=>{switch(x){case"SEQUENCE_EDGE":return h();case"MESSAGE_EDGE":return s==="view"?[]:[...p];case"ANNOTATION_EDGE":return s==="view"?[]:[...p];default:return[]}})(t);if(!(m.length===0||s==="view"))return pn("div",v(_({className:"flex items-center gap-1 w-fit px-3 py-2 bg-white rounded-sm shadow-md"},r),{children:m.map((x,T)=>pn("div",{children:x.component},T))}))};import{useViewport as Ig}from"@xyflow/react";import{useMemo as Ag}from"react";import{jsx as ic}from"react/jsx-runtime";var ct=12,wo=({sx:e,sy:t,tx:o,ty:n,hasLabel:r=!1,children:i})=>{let{zoom:a}=Ig(),s=1/a,l=Ag(()=>t===n?{bottom:`${ct}px`,transform:"translateX(-50%)"}:e===o?{left:`${ct}px`,transform:r?"translateY(-100%)":"translateY(-50%)"}:n>t&&o>e?{left:`${ct}px`,bottom:`${ct}px`}:n>t&&o<e?{right:`${ct}px`,bottom:`${ct}px`}:t>n&&o>e?{right:`${ct}px`,bottom:`${ct}px`}:{left:`${ct}px`,bottom:`${ct}px`},[e,t,o,n,r]);return ic("div",{style:{transform:`scale(${s})`},children:ic("div",{className:"absolute pointer-events-auto",style:_({},l),children:i})})};import{Fragment as Lg,jsx as eo,jsxs as ac}from"react/jsx-runtime";var Io={type:"ANNOTATION_EDGE",reconnectable:!0},lc=({id:e,source:t,target:o,selected:n,data:r})=>{let{isMultipleSelection:i}=ee(),{zoom:a}=Pg(),s=sc(t),l=sc(o);if(!s||!l)return null;let{sx:c,sy:d,tx:u,ty:f}=go(s,l),[p,h,y]=Mg({sourceX:c,sourceY:d,targetX:u,targetY:f}),m=n||(s==null?void 0:s.selected)||(l==null?void 0:l.selected);return eo(Lg,{children:ac("g",{className:V("group bpmn-edge",{"is-highlighted":m}),children:[eo("path",{d:p,fill:"none",stroke:"transparent",strokeWidth:Math.max(12,12/a),style:{pointerEvents:"stroke",cursor:"pointer"}}),ac("g",{className:V("text-grey-500 transition-colors duration-75 group-hover:text-grey-800",{"text-blue-500 group-hover:text-blue-600":m}),children:[eo(Cg,{id:e,path:p,interactionWidth:0,strokeDasharray:4,className:V("stroke-2 stroke-current transition-[stroke,filter] duration-75 group-hover:drop-shadow-[0_0_3px_rgba(0,0,0,0.2)]",{"stroke-red-500 hover:stroke-red-600":r==null?void 0:r.hasError,"stroke-blue-500 hover:stroke-blue-600 drop-shadow-[0_0_3px_rgba(59,130,246,0.5)]":m&&!(r!=null&&r.hasError)})}),eo(Sg,{children:eo("div",{className:"absolute z-[3000] pointer-events-auto flex flex-col items-center gap-1",style:{transform:`translate(-50%, -50%) translate(${h}px, ${y}px)`},children:n&&!i&&eo(wo,{sx:c,sy:d,tx:u,ty:f,children:eo(vo,{edgeId:e,edgeType:"ANNOTATION_EDGE"})})})})]})]})})};import{useState as yc,useCallback as Kg,useMemo as es,useEffect as qg,useRef as xc}from"react";import{BaseEdge as Zg,EdgeLabelRenderer as Jg,MarkerType as Ec,useInternalNode as bc,useReactFlow as Qg,useViewport as jg,useEdges as eh,Position as So}from"@xyflow/react";import{useCallback as kg,useEffect as Qi,useRef as cc,useState as Rg}from"react";import{jsx as uc}from"react/jsx-runtime";var ji=/[a-zA-Z0-9À-ÖØ-öø-ÿ]/,dc=["Backspace","Delete","ArrowLeft","ArrowRight","ArrowUp","ArrowDown","Home","End","Tab","Escape","Shift"],Pe=({value:e,maxLength:t,style:o,className:n,contentClassName:r,isEditing:i,onChange:a,onBlur:s,onInput:l,onInvalidFirstCharacter:c,skipFirstCharValidation:d})=>{let u=cc(null),f=cc(null),[p,h]=Rg(!1);Qi(()=>()=>{f.current&&clearTimeout(f.current)},[]),Qi(()=>{h(i!=null?i:!1)},[i]),Qi(()=>{if(p&&u.current){u.current.focus();let b=document.createRange();b.selectNodeContents(u.current);let g=window.getSelection();g&&(g.removeAllRanges(),g.addRange(b))}},[p]);let y=kg(()=>{f.current||(c==null||c(),f.current=setTimeout(()=>{f.current=null},500))},[c]),m=b=>{b.stopPropagation(),p||h(!0)},x=b=>{let g=b.currentTarget.innerText.replace(/\n$/,""),w=t&&g.length>=t,A=window.getSelection(),I=(A==null?void 0:A.toString())||"",D=I.length>0,S=(b.ctrlKey||b.metaKey)&&!b.altKey,L=S&&b.key==="a",z=S&&b.key==="c",q=S&&b.key==="x",Q=S&&b.key==="v",U=g.length===0||D&&I.length===g.length;if(!d&&U&&!ji.test(b.key)&&!dc.includes(b.key)&&!S){b.preventDefault(),y();return}w&&!D&&(dc.includes(b.key)||L||z||q||Q||b.preventDefault())},T=b=>{b.preventDefault();let g=b.clipboardData.getData("text/plain").replace(/\r\n/g,`
1
+ var ip=Object.defineProperty,sp=Object.defineProperties;var ap=Object.getOwnPropertyDescriptors;var Ln=Object.getOwnPropertySymbols;var Ls=Object.prototype.hasOwnProperty,ks=Object.prototype.propertyIsEnumerable;var Ps=(e,t,o)=>t in e?ip(e,t,{enumerable:!0,configurable:!0,writable:!0,value:o}):e[t]=o,_=(e,t)=>{for(var o in t||(t={}))Ls.call(t,o)&&Ps(e,o,t[o]);if(Ln)for(var o of Ln(t))ks.call(t,o)&&Ps(e,o,t[o]);return e},v=(e,t)=>sp(e,ap(t));var mt=(e,t)=>{var o={};for(var n in e)Ls.call(e,n)&&t.indexOf(n)<0&&(o[n]=e[n]);if(e!=null&&Ln)for(var n of Ln(e))t.indexOf(n)<0&&ks.call(e,n)&&(o[n]=e[n]);return o};var _i=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 lp,Translations as cp}from"@produto-lecom/lecom-ui";var Rs={translations:{general:{layout:{title:"Modeler"}},editor:{toolbar:{delete:"Delete",configure_node:"Configure activity",configure_edge:"Configure routing",initial_task:"Initial Activity",gateway_limit_reached:"Exclusive gateway cannot have more than 2 outgoing connections",task_limit_reached:"Task cannot have more than 2 outgoing connections",start_event_limit_reached:"Start event can only connect to a single element",gateway_to_gateway_not_allowed:"Gateways cannot connect directly to other gateways",start_event_already_exists:"A start event already exists. Delete the current event to add another",script_to_end_not_allowed:"Script activities cannot connect directly to the end event",loop_to_end_not_allowed:"Loop activities cannot connect directly to the end event",initial_activity_to_end_not_allowed:"Initial activity cannot connect directly to the end event",final_activity_cannot_connect:"Final activity cannot connect to other elements",activity_has_outgoing_connections:"Activity with outgoing connections cannot connect to end event",end_event_cannot_connect_to_initial_activity:"End event cannot connect to an initial activity",initial_activity_cannot_connect_to_start_event:"Initial activity cannot connect to start event",concurrent_initial_and_final_activity:"An activity cannot be connected to both start and end events",duplicate_connection_not_allowed:"A connection already exists between these elements",connect_node:"Connect element",connecting:"Connecting...",delete_pool_lane_error:"Cannot delete the pool or lane while there are elements inside it."},controls:{zoom:{fit:"Fit zoom",in:"Zoom in",out:"Zoom out",reset:"Reset zoom"},actions:{move_tool:"Select elements",hand_tool:"Navigate the diagram",check:"Check diagram",export:{title:"Export diagram",print:"Print",html:"Export as HTML",png:"Export as PNG",feedback:{empty:"Cannot export an empty diagram",error:"Error exporting diagram"}},import_governance:"Import diagram from Governance platform",minimap:{label:"Minimap",open:"Open minimap",close:"Hide minimap"}},history:{undo:"Undo",redo:"Redo"}},modals:{delete_elements:{title:"Delete elements",callout:"When deleting, the activity and routing settings will be deleted.",content:"Are you sure you want to delete?",confirm:"Delete",cancel:"Cancel"}},task_menu:{loop_not_allowed_when_connected_to_end:"Cannot create loop on activity connected to end event",script_not_allowed_when_connected_to_end:"Cannot transform to Script activity connected to end event",loop_not_allowed_when_subprocess:"Cannot create loop on subprocess",loop:"Activity with loop"}},validation:{success:{title:"Validation Successful",message:"The diagram was validated successfully with no errors."},errors:{title:"The diagram contains errors",subtitle:"Please review the following:",task_label_length:"Task name exceeds the maximum character limit",multiple_start_event_not_allowed:"Multiple start events are not allowed",task_flows_limit_exceeds:"The number of output connections exceeds the limit of two",duplicate_task_name:"There are multiple activities with the same name",flows_on_end_tasks_not_allowed:"Activities connected to end events cannot have other connections",conditions_flows_limit_exceeds:"Exclusive gateway has too many output connections (maximum of two)",task_label_empty:"One or more activities have no name",activity_name_invalid:"Activity name is invalid",final_activity_has_loop:"Final activities cannot have loops",nested_gateway:"Connecting gateways directly is not allowed",concurrent_initial_and_final_event:"The same activity cannot have both initial and final events",gateway_flow_to_event:"Connecting a gateway to an output event is not allowed",gateway_missing_output_streams:"The gateway does not have the correct number of outputs",events_nested:"Connecting events directly is not allowed",event_to_condition:"Connecting an event directly to a gateway is not allowed",script_in_final_activity:"Final activity cannot be a script type",subprocess_referenced_not_configured:"The subprocess reference is not properly configured",start_event_not_found:"At least one start event is required",end_event_not_found:"At least one end event is required"}},bpmn:{start_event:{variant:{default:"Start event"}},end_event:{variant:{default:"End event"}},annotation:{variant:{default:"Annotation"}},gateway:{menu:{title:"Change gateway type"},variant:{default:"Gateway",exclusive:"Exclusive gateway",parallel:"Parallel gateway",complex:"Complex gateway"}},task:{menu:{title:"Change task type"},variant:{default:"Task",script:"Script task",subprocess:"Subprocess"},attribute:{loop:"Task with loop"},label:{prefix:"Activity"},feedback:{label_empty:{prefix:"Activity name was automatically set to"},label_already_exists:{prefix:"The name",middle:"already exists. The name was changed to"},invalid_first_character:"Activity name must start with a letter or number"}},lane:{variant:{default:"Pool / Lane"}},unsupported:{variant:{default:"Unsupported element"}}},adapter:{governance:{error:{DEFAULT:"Error importing diagram",NO_FILE:"No file selected",EMPTY_FILE:"Empty file",INVALID_FILE:"Invalid file",CONTAIN_NO_CELLS:"No cells found to be imported",ALREADY_INITIALIZED:"It is not possible to import the diagram from the Governance platform, since the diagram has already been initialized"},success:{default:"The diagram was imported from the Governance platform successfully and without any incompatibility detected.",incompatible_cells:"The diagram was imported from the Governance platform with incompatibilities. To know more details, click on the button below."},report:{columns:{type:"Type",value:"Value",status:"Status"},status:{imported:"Imported",adapted:"Adapted",unsupported:"Unsupported"}},action:{download:"Download report"}}}}};var Ds={translations:{general:{layout:{title:"Modeler"}},editor:{toolbar:{delete:"Eliminar",configure_node:"Configurar actividad",configure_edge:"Configurar enrutamiento",initial_task:"Actividad Inicial",gateway_limit_reached:"Compuerta exclusiva no puede tener m\xE1s de 2 conexiones de salida",task_limit_reached:"Actividad no puede tener m\xE1s de 2 conexiones de salida",start_event_limit_reached:"Evento inicial solo puede conectarse a un \xFAnico elemento",gateway_to_gateway_not_allowed:"Las compuertas no pueden conectarse directamente con otras compuertas",start_event_already_exists:"Ya existe un evento de inicio. Elimine el evento actual para agregar otro",script_to_end_not_allowed:"Las actividades Script no pueden conectarse directamente al evento final",loop_to_end_not_allowed:"Las actividades Loop no pueden conectarse directamente al evento final",initial_activity_to_end_not_allowed:"Actividad inicial no puede conectarse directamente al evento final",final_activity_cannot_connect:"Actividad final no puede conectarse a otros elementos",activity_has_outgoing_connections:"Actividad con conexiones de salida no puede conectarse al evento final",end_event_cannot_connect_to_initial_activity:"El evento final no puede conectarse a una actividad inicial",initial_activity_cannot_connect_to_start_event:"Actividad inicial no puede conectarse a evento de inicio",concurrent_initial_and_final_activity:"Una actividad no puede estar conectada al evento inicial y final al mismo tiempo",duplicate_connection_not_allowed:"Ya existe una conexi\xF3n entre estos elementos",connect_node:"Conectar elemento",connecting:"Conectando...",delete_pool_lane_error:"No se puede eliminar la piscina o carril mientras haya elementos dentro."},controls:{zoom:{fit:"Ajustar zoom",in:"Acercar",out:"Alejar",reset:"Restablecer zoom"},actions:{move_tool:"Seleccionar elementos",hand_tool:"Navegar por el diagrama",check:"Validar diagrama",export:{title:"Exportar diagrama",print:"Imprimir",html:"Exportar como HTML",png:"Exportar como PNG",feedback:{empty:"No es posible exportar un diagrama vac\xEDo",error:"Error al exportar diagrama"}},import_governance:"Importar diagrama de la plataforma Governance",minimap:{label:"Minimapa",open:"Abrir minimapa",close:"Ocultar minimapa"}},history:{undo:"Deshacer",redo:"Rehacer"}},modals:{delete_elements:{title:"Eliminar elementos",callout:"Al eliminar, las configuraciones de actividades y enrutamiento ser\xE1n eliminadas.",content:"\xBFEst\xE1s seguro de querer eliminar?",confirm:"Eliminar",cancel:"Cancelar"}},task_menu:{loop_not_allowed_when_connected_to_end:"No se puede crear bucle en actividad conectada al evento final",script_not_allowed_when_connected_to_end:"No se puede transformar a Script actividad conectada al evento final",loop_not_allowed_when_subprocess:"No se puede crear bucle en subproceso",loop:"Actividad con loop"}},validation:{success:{title:"Validaci\xF3n exitosa",message:"El diagrama ha sido validado correctamente sin errores."},errors:{title:"El diagrama contiene errores",subtitle:"Revise lo siguiente:",task_label_length:"El nombre de la actividad excede el l\xEDmite m\xE1ximo de caracteres",multiple_start_event_not_allowed:"No se permite tener m\xE1s de un evento de inicio",task_flows_limit_exceeds:"El n\xFAmero de conexiones de salida supera el l\xEDmite de dos",duplicate_task_name:"Hay varias actividades con el mismo nombre",flows_on_end_tasks_not_allowed:"Las actividades conectadas a eventos finales no pueden tener otras conexiones",conditions_flows_limit_exceeds:"Compuerta exclusiva con exceso de conexiones de salida (m\xE1ximo de dos)",task_label_empty:"El nombre de una o m\xE1s actividades no ha sido completado",activity_name_invalid:"El nombre de la actividad no es v\xE1lido",final_activity_has_loop:"Las actividades finales no pueden tener bucles",nested_gateway:"No se permite conectar compuertas directamente",concurrent_initial_and_final_event:"Una misma actividad no puede tener eventos iniciales y finales",gateway_flow_to_event:"No se permite conectar una compuerta a un evento de salida",gateway_missing_output_streams:"La compuerta no tiene el n\xFAmero correcto de salidas",events_nested:"No se permite conectar eventos directamente",event_to_condition:"No se permite conectar un evento directamente a una compuerta",script_in_final_activity:"La actividad final no puede ser de tipo script",subprocess_referenced_not_configured:"La referencia al subproceso no est\xE1 configurada correctamente",start_event_not_found:"Es necesario tener al menos un evento de inicio",end_event_not_found:"Es necesario tener al menos un evento final"}},bpmn:{start_event:{variant:{default:"Evento de inicio"}},end_event:{variant:{default:"Evento final"}},annotation:{variant:{default:"Anotaci\xF3n"}},gateway:{menu:{title:"Cambiar tipo de compuerta"},variant:{default:"Compuerta",exclusive:"Compuerta exclusiva",parallel:"Compuerta paralela",complex:"Compuerta compleja"}},task:{menu:{title:"Cambiar tipo de tarea"},variant:{default:"Tarea",script:"Tarea de script",subprocess:"Subproceso"},attribute:{loop:"Tarea con bucle"},label:{prefix:"Actividad"},feedback:{label_empty:{prefix:"El nombre de la actividad se estableci\xF3 autom\xE1ticamente como"},label_already_exists:{prefix:"El nombre",middle:"ya existe. El nombre fue cambiado a"},invalid_first_character:"El nombre de la actividad debe comenzar con una letra o n\xFAmero"}},lane:{variant:{default:"Piscina / Raia"}},unsupported:{variant:{default:"Elemento no soportado"}}},adapter:{governance:{error:{DEFAULT:"Error al importar diagrama",NO_FILE:"No se ha seleccionado ning\xFAn archivo",EMPTY_FILE:"Archivo vac\xEDo",INVALID_FILE:"Archivo inv\xE1lido",CONTAIN_NO_CELLS:"No se encontraron c\xE9lulas para importar",ALREADY_INITIALIZED:"No es posible importar el diagrama de la plataforma Governance, ya que el diagrama ya ha sido iniciado"},success:{default:"El diagrama se ha importado de la plataforma Governance correctamente y sin ninguna incompatibilidad detectada.",incompatible_cells:"El diagrama se ha importado de la plataforma Governance con incompatibilidades. Para saber m\xE1s detalles, haz click en el bot\xF3n de abajo."},report:{columns:{type:"Tipo",value:"Valor",status:"Estado"},status:{imported:"Importado",adapted:"Adaptado",unsupported:"No soportado"}},action:{download:"Descargar informe"}}}}};var Os={translations:{general:{layout:{title:"Modeler"}},editor:{toolbar:{delete:"Excluir",configure_node:"Configurar atividade",configure_edge:"Configurar roteamento",initial_task:"Atividade Inicial",gateway_limit_reached:"Gateway exclusivo n\xE3o pode ter mais de 2 conex\xF5es de sa\xEDda",task_limit_reached:"Atividade n\xE3o pode ter mais de 2 conex\xF5es de sa\xEDda",start_event_limit_reached:"Evento inicial s\xF3 pode se conectar a um \xFAnico elemento",gateway_to_gateway_not_allowed:"Gateways n\xE3o podem se conectar diretamente com outros gateways",start_event_already_exists:"J\xE1 existe um evento de in\xEDcio. Exclua o evento atual para adicionar outro",script_to_end_not_allowed:"Atividades Script n\xE3o podem se conectar diretamente ao evento final",loop_to_end_not_allowed:"Atividades Loop n\xE3o podem se conectar diretamente ao evento final",initial_activity_to_end_not_allowed:"Atividade inicial n\xE3o pode se conectar diretamente ao evento final",final_activity_cannot_connect:"Atividade final n\xE3o pode se conectar a outros elementos",activity_has_outgoing_connections:"Atividade com conex\xF5es de sa\xEDda n\xE3o pode se conectar a um evento final",end_event_cannot_connect_to_initial_activity:"O evento final n\xE3o pode ser conectado a uma atividade inicial",initial_activity_cannot_connect_to_start_event:"Atividade inicial n\xE3o pode se conectar a evento de in\xEDcio",concurrent_initial_and_final_activity:"Uma atividade n\xE3o pode estar conectada ao evento inicial e final ao mesmo tempo",duplicate_connection_not_allowed:"J\xE1 existe uma conex\xE3o entre esses elementos",start_event_to_subprocess_not_allowed:"Evento inicial n\xE3o pode se conectar a um subprocesso",connect_node:"Conectar elemento",connecting:"Conectando...",delete_pool_lane_error:"N\xE3o \xE9 poss\xEDvel excluir a piscina ou raia enquanto houver elementos dentro dela."},controls:{zoom:{fit:"Ajustar o zoom",in:"Aumentar o zoom",out:"Diminuir o zoom",reset:"Resetar o zoom"},actions:{move_tool:"Selecionar elementos",hand_tool:"Navegar pelo diagrama",check:"Validar diagrama",export:{title:"Exportar diagrama",print:"Imprimir",html:"Exportar como HTML",png:"Exportar como PNG",feedback:{empty:"N\xE3o \xE9 poss\xEDvel exportar um diagrama vazio",error:"Erro ao exportar o diagrama"}},import_governance:"Importar diagrama da plataforma Governance",minimap:{label:"Minimapa",open:"Abrir minimapa",close:"Ocultar minimapa"}},history:{undo:"Desfazer",redo:"Refazer"}},modals:{delete_elements:{title:"Excluir elementos",callout:"Ao excluir, as configura\xE7\xF5es de atividades e roteamento ser\xE3o exclu\xEDdas.",content:"Deseja realmente excluir?",confirm:"Excluir",cancel:"Cancelar"}},task_menu:{loop_not_allowed_when_connected_to_end:"N\xE3o \xE9 poss\xEDvel criar loop em atividade conectada ao evento final",script_not_allowed_when_connected_to_end:"N\xE3o \xE9 poss\xEDvel transformar em Script atividade conectada ao evento final",loop_not_allowed_when_subprocess:"N\xE3o \xE9 poss\xEDvel criar loop em subprocesso",loop:"Atividade com loop"}},validation:{success:{title:"Diagrama v\xE1lidado com sucesso!",message:"Nenhum erro encontrado."},errors:{title:"O diagrama cont\xE9m erros",subtitle:"Veja abaixo o que precisa ser corrigido:",task_label_length:"O nome da atividade excede o limite m\xE1ximo de caracteres",multiple_start_event_not_allowed:"N\xE3o \xE9 permitido ter mais de um evento de in\xEDcio",task_flows_limit_exceeds:"O n\xFAmero de conex\xF5es de sa\xEDda ultrapassa o limite de dois",duplicate_task_name:"H\xE1 v\xE1rias atividades com o mesmo nome",flows_on_end_tasks_not_allowed:"Atividades conectadas a eventos finais n\xE3o podem ter outras conex\xF5es",conditions_flows_limit_exceeds:"Gateway exclusivo com excesso de conex\xF5es de sa\xEDda (m\xE1ximo de dois)",task_label_empty:"O nome de uma ou mais atividades n\xE3o foi preenchido",activity_name_invalid:"O nome da atividade n\xE3o \xE9 v\xE1lido",final_activity_has_loop:"Atividades finais n\xE3o podem ter loops",nested_gateway:"N\xE3o \xE9 permitido conectar gateways",concurrent_initial_and_final_event:"Uma mesma atividade n\xE3o pode ter eventos iniciais e finais",gateway_flow_to_event:"N\xE3o \xE9 permitido conectar um gateway a um evento de sa\xEDda",gateway_missing_output_streams:"O gateway n\xE3o possui o n\xFAmero correto de sa\xEDdas",events_nested:"N\xE3o \xE9 permitido conectar eventos",event_to_condition:"N\xE3o \xE9 permitido conectar um evento diretamente em um gateway",script_in_final_activity:"Atividade final n\xE3o pode ser do tipo script",subprocess_referenced_not_configured:"A refer\xEAncia ao subprocesso n\xE3o est\xE1 configurada corretamente",start_event_not_found:"\xC9 necess\xE1rio ter ao menos um evento inicial",end_event_not_found:"\xC9 necess\xE1rio ter ao menos um evento final"}},bpmn:{start_event:{variant:{default:"Evento inicial"}},end_event:{variant:{default:"Evento final"}},annotation:{variant:{default:"Anota\xE7\xE3o"}},gateway:{menu:{title:"Alterar tipo de gateway"},variant:{default:"Gateway",exclusive:"Gateway exclusivo",parallel:"Gateway paralelo",complex:"Gateway complexo"}},task:{menu:{title:"Alterar tipo de Atividade"},variant:{default:"Atividade",script:"Atividade de script",subprocess:"Subprocesso"},attribute:{loop:"Atividade com loop"},label:{prefix:"Atividade"},feedback:{label_empty:{prefix:"O nome da atividade foi definido automaticamente como"},label_already_exists:{prefix:"O nome",middle:"j\xE1 existe. O nome foi alterado para"},invalid_first_character:"O nome da atividade deve come\xE7ar com uma letra ou n\xFAmero"}},lane:{variant:{default:"Piscina / Raia"}},unsupported:{variant:{default:"Elemento n\xE3o suportado"}}},adapter:{governance:{error:{DEFAULT:"Erro ao importar diagrama",NO_FILE:"Nenhum arquivo selecionado",EMPTY_FILE:"Arquivo vazio",INVALID_FILE:"Arquivo inv\xE1lido",CONTAIN_NO_CELLS:"N\xE3o foram encontradas c\xE9lulas para serem importadas",ALREADY_INITIALIZED:"N\xE3o \xE9 poss\xEDvel importar o diagrama da plataforma Governance, pois o diagrama j\xE1 foi iniciado"},success:{default:"O diagrama foi importado da plataforma Governance com sucesso e sem nenhuma incompatibilidade detectada.",incompatible_cells:"O diagrama foi importado da plataforma Governance com incompatibilidades. Para saber mais detalhes, clique no bot\xE3o abaixo."},report:{columns:{type:"Tipo do elemento",value:"Valor",status:"Status"},status:{imported:"Importado",adapted:"Adaptado",unsupported:"N\xE3o suportado"}},action:{download:"Baixar relat\xF3rio"}}}}};var Hs={pt_BR:Os,en_US:Rs,es_ES:Ds};var Vs,Gs,dp=(Gs=(Vs=_i("LecomUserLanguage"))!=null?Vs:_i("org.springframework.web.servlet.i18n.CookieLocaleResolver.LOCALE"))!=null?Gs:cp.PT_BR;lp({lng:dp,resources:Hs});var Re=(n=>(n.EDIT="edit",n.VIEW="view",n.READONLY="readonly",n))(Re||{});var kn=(r=>(r.ACTIVITY="activity",r.ROUTING="routing",r.GATEWAY="gateway",r.SUB_PROCESS="sub_process",r))(kn||{}),Ni=(n=>(n.START="start",n.END="end",n.BETWEEN="between",n))(Ni||{}),Ti=(n=>(n.SCRIPT="script",n.LOOP="loop",n.SCRIPT_LOOP="script_loop",n))(Ti||{}),vi=(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))(vi||{});import{RotateCcw as Np,ScrollText as Tp,SquarePlus as vp}from"lucide-react";import{jsx as Rn,jsxs as up}from"react/jsx-runtime";var Dn=({size:e=24,className:t})=>up("svg",{width:e,height:e,viewBox:"0 0 24 24",xmlns:"http://www.w3.org/2000/svg",fill:"#6b7280",className:t,children:[Rn("path",{strokeWidth:"2",d:"M16 3V3.5085V11.9998V20.4915V21H16.5411H21.4592H22V19.123H21.4592H17.9974V11.9998V4.8773H21.4592H22V3H21.4592H16.5411H16Z"}),Rn("path",{d:"M4.41026 16.9999L2 18.7861L3.89693 21.1103L6.3072 19.324L4.41026 16.9999Z"}),Rn("path",{d:"M8.41026 13.9999L6 15.7861L7.89693 18.1103L10.3072 16.324L8.41026 13.9999Z"}),Rn("path",{d:"M12.4313 10.954L10.021 12.7402L11.9179 15.0644L14.3282 13.2781L12.4313 10.954Z"})]});import{jsx as Bs}from"react/jsx-runtime";var ho=({size:e=24,className:t})=>Bs("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:Bs("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 Uo,jsxs as pp}from"react/jsx-runtime";var yo=({size:e=24,className:t})=>pp("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:[Uo("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"}),Uo("path",{d:"M12 8V16",strokeLinecap:"round",strokeLinejoin:"round"}),Uo("path",{d:"M8 12H16",strokeLinecap:"round",strokeLinejoin:"round"}),Uo("path",{d:"M9.17139 9.17188L14.8282 14.8287",strokeLinecap:"round",strokeLinejoin:"round"}),Uo("path",{d:"M14.8281 9.17188L9.17127 14.8287",strokeLinecap:"round",strokeLinejoin:"round"})]});import{jsx as wi,jsxs as fp}from"react/jsx-runtime";var xo=({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:"#6b7280",strokeWidth:2,className:t,children:[wi("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"}),wi("path",{d:"M14.8286 9.17188L9.17176 14.8287",strokeLinecap:"round",strokeLinejoin:"round"}),wi("path",{d:"M9.17139 9.17188L14.8282 14.8287",strokeLinecap:"round",strokeLinejoin:"round"})]});import{jsx as Ii,jsxs as mp}from"react/jsx-runtime";var Eo=({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:"#6b7280",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:"M12 8V16",strokeLinecap:"round",strokeLinejoin:"round"}),Ii("path",{d:"M8 12H16",strokeLinecap:"round",strokeLinejoin:"round"})]});import{jsx as Ai,jsxs as gp}from"react/jsx-runtime";var zs=({size:e=24,className:t})=>Ai("svg",{width:e,height:e,viewBox:"0 0 34 24",xmlns:"http://www.w3.org/2000/svg",fill:"currentColor",className:t,children:gp("g",{children:[Ai("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"}),Ai("path",{d:"M24.5 4.5L28 1M28 1L31.5 4.5M28 1V8",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round"})]})});import{clsx as hp}from"clsx";import{twMerge as yp}from"tailwind-merge";function G(...e){return yp(hp(e))}var Lt=(e=0,t=0)=>e<t?t:e,On=(e=1e3)=>new Promise(t=>{setTimeout(t,e)});import{jsx as Ys,jsxs as xp}from"react/jsx-runtime";var Ws=({size:e=24,className:t})=>xp("svg",{width:e,height:e,viewBox:"0 0 24 24",fill:"none",stroke:"#6b7280",strokeWidth:2,xmlns:"http://www.w3.org/2000/svg",className:G("stroke-2",t),children:[Ys("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"}),Ys("path",{d:"M9 3V21",strokeLinecap:"round",strokeLinejoin:"round"})]});import{jsx as Ci}from"react/jsx-runtime";var Fs=({size:e=24,className:t})=>Ci("svg",{width:e,height:e,viewBox:"0 0 24 24",xmlns:"http://www.w3.org/2000/svg",stroke:"currentColor",className:t,children:Ci("g",{children:Ci("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 Xs}from"react/jsx-runtime";var Hn=({size:e=24,className:t})=>Xs("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:Xs("path",{d:"M12 22C17.5228 22 22 17.5228 22 12C22 6.47715 17.5228 2 12 2C6.47715 2 2 6.47715 2 12C2 17.5228 6.47715 22 12 22Z",strokeLinecap:"round",strokeLinejoin:"round"})});import{jsx as Us}from"react/jsx-runtime";var $o=({size:e=24,className:t})=>Us("svg",{width:e,height:e,viewBox:"0 0 24 24",xmlns:"http://www.w3.org/2000/svg",fill:"white",stroke:"#6b7280",className:G("stroke-2",t),children:Us("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 Si,jsxs as Ep}from"react/jsx-runtime";var $s=({size:e=24,className:t})=>Ep("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:[Si("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"}),Si("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"}),Si("path",{d:"M7.5 7.5V10H10",strokeWidth:"1.5",fill:"none",strokeLinecap:"round",strokeLinejoin:"round"})]});import{jsx as Ko,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:[Ko("path",{d:"M20 3H4C2.89543 3 2 4.34315 2 6V18C2 19.6569 2.89543 21 4 21H20C21.1046 21 22 19.6569 22 18V6C22 4.34315 21.1046 3 20 3Z",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"}),Ko("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"}),Ko("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"}),Ko("path",{d:"M13.5 12H11",strokeWidth:"1",strokeLinecap:"round",strokeLinejoin:"round"}),Ko("path",{d:"M13.5 10H11",strokeWidth:"1",strokeLinecap:"round",strokeLinejoin:"round"})]});import{jsx as Vn,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:[Vn("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"}),Vn("path",{d:"M8 21V14C8 13.4477 8.44772 13 9 13H15C15.5523 13 16 13.4477 16 14V21",strokeWidth:"1",fill:"none"}),Vn("path",{d:"M10.2222 17H13.7777",strokeWidth:"1",strokeLinecap:"round",strokeLinejoin:"round"}),Vn("path",{d:"M12 15.2227V18.7782",strokeWidth:"1",strokeLinecap:"round",strokeLinejoin:"round"})]});var ie=(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))(ie||{}),it=(o=>(o.SCRIPT="SCRIPT",o.SUBPROCESS="SUBPROCESS",o))(it||{}),Gn={SCRIPT:{icon:Tp},SUBPROCESS:{icon:vp}},gt=(t=>(t.LOOP="LOOP",t))(gt||{}),Bn={LOOP:{icon:Np}},st=(n=>(n.EXCLUSIVE="EXCLUSIVE",n.PARALLEL="PARALLEL",n.COMPLEX="COMPLEX",n))(st||{}),Mi={EXCLUSIVE:{icon:xo},PARALLEL:{icon:Eo},COMPLEX:{icon:yo}};import{ReactFlowProvider as HE}from"@xyflow/react";import{createContext as VE,useContext as GE,useEffect as BE,useId as zE,useMemo as YE,useState as dt}from"react";import{Background as pE,MiniMap as fE,ReactFlow as mE,SelectionMode as gE,useKeyPress as hE}from"@xyflow/react";import{forwardRef as yE,useImperativeHandle as xE,useRef as vs}from"react";import{useTranslation as B0}from"@produto-lecom/lecom-ui";import{useEdgesState as z0,useNodesState as Y0,useOnSelectionChange as W0,useReactFlow as F0,useStoreApi as X0}from"@xyflow/react";import{useCallback as St,useEffect as U0}from"react";import{Position as qo}from"@xyflow/react";function Zs(e,t){var E,T,b,x;let{width:o=0,height:n=0}=e.measured||{width:0,height:0},r=e.internals.positionAbsolute,i=t.internals.positionAbsolute,a=o/2,s=n/2,l=r.x+a,c=r.y+s,d=i.x+((T=(E=t==null?void 0:t.measured)==null?void 0:E.width)!=null?T:0)/2,u=i.y+((x=(b=t==null?void 0:t.measured)==null?void 0:b.height)!=null?x:0)/2,m=(d-l)/(2*a)-(u-c)/(2*s),p=(d-l)/(2*a)+(u-c)/(2*s),g=1/(Math.abs(m)+Math.abs(p)||1),h=g*m,f=g*p,y=a*(h+f)+l,N=s*(-h+f)+c;return{x:y,y:N}}function Js(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?qo.Left:s>=i+n-1?qo.Right:l<=a+1?qo.Top:l>=a+r-1?qo.Bottom:qo.Top}function bo(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 zn(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 Yn={MIN_WIDTH:36,MIN_HEIGHT:36},Wn={MIN_WIDTH:36,MIN_HEIGHT:36},Fn={MIN_WIDTH:56,MIN_HEIGHT:56},_o={MIN_WIDTH:176,MIN_HEIGHT:96},Qs={HEADER_WIDTH:40,MIN_WIDTH:840,MIN_HEIGHT:256},re={HEADER_WIDTH:40,MIN_WIDTH:800,MIN_HEIGHT:256},No={MIN_WIDTH:176,MIN_HEIGHT:64},wp={MIN_WIDTH:128,MIN_HEIGHT:64},pe={START_EVENT:Yn,END_EVENT:Wn,GATEWAY:Fn,TASK:_o,LANE:re,ANNOTATION:No,UNSUPPORTED:wp};import{orderBy as Ip}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}),et=e=>{var t,o,n,r,i,a,s,l;return{x:(o=(t=e.internals)==null?void 0:t.positionAbsolute.x)!=null?o:0,y:(r=(n=e.internals)==null?void 0:n.positionAbsolute.y)!=null?r:0,w:(a=(i=e.measured)==null?void 0:i.width)!=null?a:0,h:(l=(s=e.measured)==null?void 0:s.height)!=null?l:0}},Zt=e=>Ip(e,[o=>{let n=o.type==="LANE";return n&&!o.parentId?0:n?1:2}],["asc"]),ta=(e,t)=>{let{x:o,y:n}=et(e),{x:r,y:i}=et(t);return{x:o-r,y:n-i}};var Jt=({parentId:e,nodes:t,includeTypes:o=[...Object.values(ie)],excludeTypes:n=[]})=>t.some(r=>r.parentId===e&&(!o.length||o.includes(r.type))&&!n.includes(r.type)),Ap=(e,t)=>{let{x:o,y:n}=et(e),{x:r,y:i}=et(t),a=o-r,s=n-i;return Math.sqrt(a*a+s*s)},Cp=(e,t)=>{let{x:o,y:n,w:r,h:i}=et(e),{x:a,y:s,w:l,h:c}=et(t),d=o+r/2,u=n+i/2;return d>=a&&d<=a+l&&u>=s&&u<=s+c},Zo=(e,t)=>{let o=null,n=1/0;for(let r of t)if(r.id!==e.id&&Cp(e,r)){let i=Ap(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:v(_({},c),{position:{x:c.position.x-i,y:c.position.y-a}})),l=t.map(c=>{let d=c.data;return d!=null&&d.points?v(_({},c),{data:v(_({},d),{points:d.points.map(u=>({x:u.x-i,y:u.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 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 Pi=(e,t)=>{let o=t.find(a=>a.id===e);if(!o||o.type!=="LANE"||o.parentId)return!1;let n=et(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=et(a);return s.x<r&&s.x+s.w>n.x&&s.y<i&&s.y+s.h>n.y})};var Sp=50,Qt=(e,t)=>{var m,p,g,h,f,y,N,E,T,b,x,w,A,I,D,S;let o=t.find(L=>L.id===e);if(!o)return t;let n=(p=(m=o.position)==null?void 0:m.x)!=null?p:0,r=(h=(g=o.position)==null?void 0:g.y)!=null?h:0,i=(y=(f=o.measured)==null?void 0:f.width)!=null?y:0,a=(E=(N=o.measured)==null?void 0:N.height)!=null?E:0,s=r+a,l=n+i,c=new Set,d=1/0;for(let L of t){if(L.id===e||L.parentId)continue;let z=(b=(T=L.position)==null?void 0:T.y)!=null?b:0,U=(w=(x=L.position)==null?void 0:x.x)!=null?w:0,K=(I=(A=L.measured)==null?void 0:A.width)!=null?I:0,Y=(S=(D=L.measured)==null?void 0:D.height)!=null?S:0;U<l&&U+K>n&&z<s&&z+Y>r&&(c.add(L.id),d=Math.min(d,z))}if(c.size===0)return t;let u=s+Sp-d;return t.map(L=>{var U,K,Y;if(!c.has(L.id))return L;let z=(K=(U=L.position)==null?void 0:U.y)!=null?K:0;return v(_({},L),{position:v(_({},(Y=L.position)!=null?Y:{x:0,y:0}),{y:z+u})})})},Te=15,jt=e=>[...e].sort((t,o)=>t.position.y-o.position.y),Mp=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)},Pp=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)},Li=(e,t,o)=>{var d,u,m,p,g,h,f,y,N,E,T,b,x,w,A;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=(h=(g=e.height)!=null?g:(p=e.measured)==null?void 0:p.height)!=null?h:0,i=0,a=0;for(let I of t){let D=Mp(I),S=Pp(I);if(((y=(f=I.position)==null?void 0:f.y)!=null?y:0)<Te&&(o.set(I.id,v(_({},I),{position:v(_({},I.position),{y:Te})})),S=Te+((E=(N=I.measured)==null?void 0:N.height)!=null?E:0)),((b=(T=I.position)==null?void 0:T.x)!=null?b:0)<re.HEADER_WIDTH+Te){let L=(x=o.get(I.id))!=null?x:I;o.set(I.id,v(_({},L),{position:v(_({},L.position),{x:re.HEADER_WIDTH+Te})})),D=re.HEADER_WIDTH+Te+((A=(w=I.measured)==null?void 0:w.width)!=null?A:0)}i=Math.max(i,D),a=Math.max(a,S)}let s=Math.max(n,re.MIN_WIDTH),l=Math.max(r,re.MIN_HEIGHT);i+Te>s&&(s=i+Te),a+Te>l&&(l=a+Te);let c=v(_({},e),{width:s,height:l,measured:v(_({},e.measured),{width:s,height:l})});return o.set(e.id,c),c},ia=(e,t,o)=>{var a,s;let n=jt(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=Li(l,c,t);t.set(d.id,v(_({},d),{position:{x:re.HEADER_WIDTH,y:i}})),i+=(s=d.height)!=null?s:0}},sa=(e,t)=>{var g,h,f,y;let o=[];for(let N of t.values())N.parentId===e.id&&o.push(N);let n=jt(o),r=((h=(g=e.measured)==null?void 0:g.width)!=null?h:0)-re.HEADER_WIDTH,i=oa(e.id,o)||re.MIN_WIDTH,a=o.reduce((N,E)=>{var T;return N+((T=E.height)!=null?T:re.MIN_HEIGHT)},0),s=Math.max(r,i),l=a,c=r>i,d=c?s:s+re.HEADER_WIDTH,u=c?s-re.HEADER_WIDTH:s,m=0;for(let N=0;N<n.length;N++){let E=n[N],T=Math.max(re.MIN_HEIGHT,(f=E.height)!=null?f:re.MIN_HEIGHT),b=v(_({},E),{width:u,height:T,measured:v(_({},E.measured),{width:u,height:T}),position:{x:re.HEADER_WIDTH,y:m}});if(N===o.length-1){let x=Math.max(re.MIN_HEIGHT,l-m);b=v(_({},b),{height:x,measured:v(_({},E.measured),{width:u,height:x})})}t.set(E.id,b),m+=(y=b.height)!=null?y:0}let p=Math.max(l,m);t.set(e.id,v(_({},e),{width:d,height:p,measured:v(_({},e.measured),{width:d,height:p})}))},aa=(e,t,o,n,r)=>{var g,h;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=jt(s),c=l.findIndex(f=>f.id===e.id),d=(h=(g=e.position)==null?void 0:g.y)!=null?h:0,u=!i&&r!==void 0&&c>0&&Math.abs(r-d)>.5,m=0,p=[...n];return l.forEach((f,y)=>{var x,w;let N=y===l.length-1,E=f.id===e.id,b=(w=(x=f.measured)==null?void 0:x.height)!=null?w:0;E?b=o:u&&y===c-1&&(b=Math.max(re.MIN_HEIGHT,r-m)),N&&i&&(b=Math.max(re.MIN_HEIGHT,o-m)),p=p.map(A=>{if(A.id===f.id){let I=i?t-re.HEADER_WIDTH:t;return v(_({},A),{width:I,height:b,measured:v(_({},A.measured),{width:I,height:b}),position:{x:re.HEADER_WIDTH,y:m}})}return A}),E&&u?m=r+o:m+=b}),p=p.map(f=>{if(f.id===a){let y=i?t:t+re.HEADER_WIDTH;return v(_({},f),{width:y,height:i?o:m,measured:{width:y,height:i?o:m}})}return f}),p};var ki=(e,t,o)=>{var s,l,c,d,u,m,p,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<Te&&(e.position.y=Te),e.position.x<re.HEADER_WIDTH+Te&&(e.position.x=re.HEADER_WIDTH+Te);let i=e.position.x+((m=(u=e.measured)==null?void 0:u.width)!=null?m:0),a=e.position.y+((g=(p=e.measured)==null?void 0:p.height)!=null?g:0);return i+Te>n&&(t.width=i+Te,t.measured.width=i+Te),a+Te>r&&(t.height=a+Te,t.measured.height=a+Te),o=o.map(h=>h.id===t.id?v(_({},h),{height:t.height,width:t.width,measured:t.measured}):h.id===e.id?v(_({},h),{position:e.position}):h),o};import{create as Lp}from"zustand";import{useReactFlow as kp}from"@xyflow/react";import{useCallback as Rp}from"react";var Xn=()=>{let{setEdges:e}=kp();return Rp(()=>{let o=eo.getState().pathEdgeIds;e(n=>n.map(r=>v(_({},r),{selected:o.includes(r.id)})))},[e])},eo=Lp((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=[],p=new Set;for(m.push({node:d,path:[]}),p.add(d);m.length>0;){let{node:g,path:h}=m.shift();if(g===u)return h;let f=a[g]||[];for(let{targetId:y,edgeId:N}of f)p.has(y)||(p.add(y),m.push({node:y,path:[...h,N]}))}return[]};for(let d=0;d<r.length-1;d++){let u=r[d],m=r[d+1],p=c(u,m);p.length>0&&i.push(...p)}i.length>0&&e({pathEdgeIds:i})}}));import{useNodesInitialized as Zm,useReactFlow as Jm,useStore as Qm}from"@xyflow/react";import{useCallback as pn,useEffect as jm,useRef as eg,useState as tc}from"react";import{shallow as tg}from"zustand/shallow";var Dp={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 Un(o)}function Un(e){this._=e}function Op(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}})}Un.prototype=ca.prototype={constructor:Un,on:function(e,t){var o=this._,n=Op(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 Un(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]=Dp,e=e.slice(0,n).concat(e.slice(n+1));break}return o!=null&&e.push({name:t,value:o}),e}var Ri=ca;var $n="http://www.w3.org/1999/xhtml",Di={svg:"http://www.w3.org/2000/svg",xhtml:$n,xlink:"http://www.w3.org/1999/xlink",xml:"http://www.w3.org/XML/1998/namespace",xmlns:"http://www.w3.org/2000/xmlns/"};function Nt(e){var t=e+="",o=t.indexOf(":");return o>=0&&(t=e.slice(0,o))!=="xmlns"&&(e=e.slice(o+1)),Di.hasOwnProperty(t)?{space:Di[t],local:e}:e}function Vp(e){return function(){var t=this.ownerDocument,o=this.namespaceURI;return o===$n&&t.documentElement.namespaceURI===$n?t.createElement(e):t.createElementNS(o,e)}}function Gp(e){return function(){return this.ownerDocument.createElementNS(e.space,e.local)}}function Kn(e){var t=Nt(e);return(t.local?Gp:Vp)(t)}function Bp(){}function to(e){return e==null?Bp:function(){return this.querySelector(e)}}function da(e){typeof e!="function"&&(e=to(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 Ae(n,this._parents)}function Oi(e){return e==null?[]:Array.isArray(e)?e:Array.from(e)}function zp(){return[]}function Jo(e){return e==null?zp:function(){return this.querySelectorAll(e)}}function Yp(e){return function(){return Oi(e.apply(this,arguments))}}function ua(e){typeof e=="function"?e=Yp(e):e=Jo(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 Ae(n,r)}function Qo(e){return function(){return this.matches(e)}}function qn(e){return function(t){return t.matches(e)}}var Wp=Array.prototype.find;function Fp(e){return function(){return Wp.call(this.children,e)}}function Xp(){return this.firstElementChild}function pa(e){return this.select(e==null?Xp:Fp(typeof e=="function"?e:qn(e)))}var Up=Array.prototype.filter;function $p(){return Array.from(this.children)}function Kp(e){return function(){return Up.call(this.children,e)}}function fa(e){return this.selectAll(e==null?$p:Kp(typeof e=="function"?e:qn(e)))}function ma(e){typeof e!="function"&&(e=Qo(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 Ae(n,this._parents)}function Zn(e){return new Array(e.length)}function ga(){return new Ae(this._enter||this._groups.map(Zn),this._parents)}function jo(e,t){this.ownerDocument=e.ownerDocument,this.namespaceURI=e.namespaceURI,this._next=null,this._parent=e,this.__data__=t}jo.prototype={constructor:jo,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 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 jo(e,i[a]);for(;a<l;++a)(s=t[a])&&(r[a]=s)}function Zp(e,t,o,n,r,i,a){var s,l,c=new Map,d=t.length,u=i.length,m=new Array(d),p;for(s=0;s<d;++s)(l=t[s])&&(m[s]=p=a.call(l,l.__data__,s,t)+"",c.has(p)?r[s]=l:c.set(p,l));for(s=0;s<u;++s)p=a.call(e,i[s],s,i)+"",(l=c.get(p))?(n[s]=l,l.__data__=i[s],c.delete(p)):o[s]=new jo(e,i[s]);for(s=0;s<d;++s)(l=t[s])&&c.get(m[s])===l&&(r[s]=l)}function Jp(e){return e.__data__}function ya(e,t){if(!arguments.length)return Array.from(this,Jp);var o=t?Zp:qp,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],u=r[c],m=u.length,p=Qp(e.call(d,d&&d.__data__,c,n)),g=p.length,h=s[c]=new Array(g),f=a[c]=new Array(g),y=l[c]=new Array(m);o(d,u,h,f,y,p,t);for(var N=0,E=0,T,b;N<g;++N)if(T=h[N]){for(N>=E&&(E=N+1);!(b=f[E])&&++E<g;);T._next=b||null}}return a=new Ae(a,n),a._enter=s,a._exit=l,a}function Qp(e){return typeof e=="object"&&"length"in e?e:Array.from(e)}function xa(){return new Ae(this._exit||this._groups.map(Zn),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],u=c.length,m=s[l]=new Array(u),p,g=0;g<u;++g)(p=c[g]||d[g])&&(m[g]=p);for(;l<r;++l)s[l]=o[l];return new Ae(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=jp);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 Ae(r,this._parents).order()}function jp(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 ef(e){return function(){this.removeAttribute(e)}}function tf(e){return function(){this.removeAttributeNS(e.space,e.local)}}function of(e,t){return function(){this.setAttribute(e,t)}}function nf(e,t){return function(){this.setAttributeNS(e.space,e.local,t)}}function rf(e,t){return function(){var o=t.apply(this,arguments);o==null?this.removeAttribute(e):this.setAttribute(e,o)}}function sf(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=Nt(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?tf:ef:typeof t=="function"?o.local?sf:rf:o.local?nf:of)(o,t))}function Jn(e){return e.ownerDocument&&e.ownerDocument.defaultView||e.document&&e||e.defaultView}function af(e){return function(){this.style.removeProperty(e)}}function lf(e,t,o){return function(){this.style.setProperty(e,t,o)}}function cf(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?af:typeof t=="function"?cf:lf)(e,t,o==null?"":o)):kt(this.node(),e)}function kt(e,t){return e.style.getPropertyValue(t)||Jn(e).getComputedStyle(e,null).getPropertyValue(t)}function df(e){return function(){delete this[e]}}function uf(e,t){return function(){this[e]=t}}function pf(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?df:typeof t=="function"?pf:uf)(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 ff(e){return function(){Ra(this,e)}}function mf(e){return function(){Da(this,e)}}function gf(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"?gf:t?ff:mf)(o,t))}function hf(){this.textContent=""}function yf(e){return function(){this.textContent=e}}function xf(e){return function(){var t=e.apply(this,arguments);this.textContent=t==null?"":t}}function Ha(e){return arguments.length?this.each(e==null?hf:(typeof e=="function"?xf:yf)(e)):this.node().textContent}function Ef(){this.innerHTML=""}function bf(e){return function(){this.innerHTML=e}}function _f(e){return function(){var t=e.apply(this,arguments);this.innerHTML=t==null?"":t}}function Va(e){return arguments.length?this.each(e==null?Ef:(typeof e=="function"?_f:bf)(e)):this.node().innerHTML}function Nf(){this.nextSibling&&this.parentNode.appendChild(this)}function Ga(){return this.each(Nf)}function Tf(){this.previousSibling&&this.parentNode.insertBefore(this,this.parentNode.firstChild)}function Ba(){return this.each(Tf)}function za(e){var t=typeof e=="function"?e:Kn(e);return this.select(function(){return this.appendChild(t.apply(this,arguments))})}function vf(){return null}function Ya(e,t){var o=typeof e=="function"?e:Kn(e),n=t==null?vf:typeof t=="function"?t:to(t);return this.select(function(){return this.insertBefore(o.apply(this,arguments),n.apply(this,arguments)||null)})}function wf(){var e=this.parentNode;e&&e.removeChild(this)}function Wa(){return this.each(wf)}function If(){var e=this.cloneNode(!1),t=this.parentNode;return t?t.insertBefore(e,this.nextSibling):e}function Af(){var e=this.cloneNode(!0),t=this.parentNode;return t?t.insertBefore(e,this.nextSibling):e}function Fa(e){return this.select(e?Af:If)}function Xa(e){return arguments.length?this.property("__data__",e):this.node().__data__}function Cf(e){return function(t){e.call(this,t,this.__data__)}}function Sf(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 Mf(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 Pf(e,t,o){return function(){var n=this.__on,r,i=Cf(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=Sf(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?Pf:Mf,r=0;r<i;++r)this.each(s(n[r],t,o));return this}function $a(e,t,o){var n=Jn(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 Lf(e,t){return function(){return $a(this,e,t)}}function kf(e,t){return function(){return $a(this,e,t.apply(this,arguments))}}function Ka(e,t){return this.each((typeof t=="function"?kf:Lf)(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 Rf=[null];function Ae(e,t){this._groups=e,this._parents=t}function Za(){return new Ae([[document.documentElement]],Rf)}function Df(){return this}Ae.prototype=Za.prototype={constructor:Ae,select:da,selectAll:ua,selectChild:pa,selectChildren:fa,filter:ma,data:ya,enter:ga,exit:xa,join:Ea,merge:ba,selection:Df,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:Ha,html:Va,raise:Ga,lower:Ba,append:za,insert:Ya,remove:Wa,clone:Fa,datum:Xa,on:Ua,dispatch:Ka,[Symbol.iterator]:qa};var Tt=Za;function Qn(e,t,o){e.prototype=t.prototype=o,o.constructor=e}function Vi(e,t){var o=Object.create(e.prototype);for(var n in t)o[n]=t[n];return o}function on(){}var en=.7,tr=1/en,To="\\s*([+-]?\\d+)\\s*",tn="\\s*([+-]?(?:\\d*\\.)?\\d+(?:[eE][+-]?\\d+)?)\\s*",ht="\\s*([+-]?(?:\\d*\\.)?\\d+(?:[eE][+-]?\\d+)?)%\\s*",Of=/^#([0-9a-f]{3,8})$/,Hf=new RegExp(`^rgb\\(${To},${To},${To}\\)$`),Vf=new RegExp(`^rgb\\(${ht},${ht},${ht}\\)$`),Gf=new RegExp(`^rgba\\(${To},${To},${To},${tn}\\)$`),Bf=new RegExp(`^rgba\\(${ht},${ht},${ht},${tn}\\)$`),zf=new RegExp(`^hsl\\(${tn},${ht},${ht}\\)$`),Yf=new RegExp(`^hsla\\(${tn},${ht},${ht},${tn}\\)$`),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};Qn(on,Rt,{copy(e){return Object.assign(new this.constructor,this,e)},displayable(){return this.rgb().displayable()},hex:Qa,formatHex:Qa,formatHex8:Wf,formatHsl:Ff,formatRgb:ja,toString:ja});function Qa(){return this.rgb().formatHex()}function Wf(){return this.rgb().formatHex8()}function Ff(){return il(this).formatHsl()}function ja(){return this.rgb().formatRgb()}function Rt(e){var t,o;return e=(e+"").trim().toLowerCase(),(t=Of.exec(e))?(o=t[1].length,t=parseInt(t[1],16),o===6?el(t):o===3?new Ye(t>>8&15|t>>4&240,t>>4&15|t&240,(t&15)<<4|t&15,1):o===8?jn(t>>24&255,t>>16&255,t>>8&255,(t&255)/255):o===4?jn(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 Ye(t[1],t[2],t[3],1):(t=Vf.exec(e))?new Ye(t[1]*255/100,t[2]*255/100,t[3]*255/100,1):(t=Gf.exec(e))?jn(t[1],t[2],t[3],t[4]):(t=Bf.exec(e))?jn(t[1]*255/100,t[2]*255/100,t[3]*255/100,t[4]):(t=zf.exec(e))?nl(t[1],t[2]/100,t[3]/100,1):(t=Yf.exec(e))?nl(t[1],t[2]/100,t[3]/100,t[4]):Ja.hasOwnProperty(e)?el(Ja[e]):e==="transparent"?new Ye(NaN,NaN,NaN,0):null}function el(e){return new Ye(e>>16&255,e>>8&255,e&255,1)}function jn(e,t,o,n){return n<=0&&(e=t=o=NaN),new Ye(e,t,o,n)}function Xf(e){return e instanceof on||(e=Rt(e)),e?(e=e.rgb(),new Ye(e.r,e.g,e.b,e.opacity)):new Ye}function vo(e,t,o,n){return arguments.length===1?Xf(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}Qn(Ye,vo,Vi(on,{brighter(e){return e=e==null?tr:Math.pow(tr,e),new Ye(this.r*e,this.g*e,this.b*e,this.opacity)},darker(e){return e=e==null?en:Math.pow(en,e),new Ye(this.r*e,this.g*e,this.b*e,this.opacity)},rgb(){return this},clamp(){return new Ye(no(this.r),no(this.g),no(this.b),or(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:Uf,formatRgb:ol,toString:ol}));function tl(){return`#${oo(this.r)}${oo(this.g)}${oo(this.b)}`}function Uf(){return`#${oo(this.r)}${oo(this.g)}${oo(this.b)}${oo((isNaN(this.opacity)?1:this.opacity)*255)}`}function ol(){let e=or(this.opacity);return`${e===1?"rgb(":"rgba("}${no(this.r)}, ${no(this.g)}, ${no(this.b)}${e===1?")":`, ${e})`}`}function or(e){return isNaN(e)?1:Math.max(0,Math.min(1,e))}function no(e){return Math.max(0,Math.min(255,Math.round(e)||0))}function oo(e){return e=no(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 at(e,t,o,n)}function il(e){if(e instanceof at)return new at(e.h,e.s,e.l,e.opacity);if(e instanceof on||(e=Rt(e)),!e)return new at;if(e instanceof at)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 at(a,s,l,e.opacity)}function sl(e,t,o,n){return arguments.length===1?il(e):new at(e,t,o,n==null?1:n)}function at(e,t,o,n){this.h=+e,this.s=+t,this.l=+o,this.opacity=+n}Qn(at,sl,Vi(on,{brighter(e){return e=e==null?tr:Math.pow(tr,e),new at(this.h,this.s,this.l*e,this.opacity)},darker(e){return e=e==null?en:Math.pow(en,e),new at(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(Gi(e>=240?e-240:e+120,r,n),Gi(e,r,n),Gi(e<120?e+240:e-120,r,n),this.opacity)},clamp(){return new at(rl(this.h),er(this.s),er(this.l),or(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=or(this.opacity);return`${e===1?"hsl(":"hsla("}${rl(this.h)}, ${er(this.s)*100}%, ${er(this.l)*100}%${e===1?")":`, ${e})`}`}}));function rl(e){return e=(e||0)%360,e<0?e+360:e}function er(e){return Math.max(0,Math.min(1,e||0))}function Gi(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 Bi(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 Bi((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 Bi((o-n/t)*t,r,i,a,s)}}var zi=e=>()=>e;function $f(e,t){return function(o){return e+o*t}}function Kf(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?nr:function(t,o){return o-t?Kf(t,o,e):zi(isNaN(t)?o:t)}}function nr(e,t){var o=t-e;return o?$f(e,o):zi(isNaN(e)?t:e)}var rr=function e(t){var o=cl(t);function n(r,i){var a=o((r=vo(r)).r,(i=vo(i)).r),s=o(r.g,i.g),l=o(r.b,i.b),c=nr(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=vo(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=dl(al),Zf=dl(ll);function tt(e,t){return e=+e,t=+t,function(o){return e*(1-o)+t*o}}var Wi=/[-+]?(?:\d+\.?\d*|\.?\d+)(?:[eE][-+]?\d+)?/g,Yi=new RegExp(Wi.source,"g");function Jf(e){return function(){return e}}function Qf(e){return function(t){return e(t)+""}}function Fi(e,t){var o=Wi.lastIndex=Yi.lastIndex=0,n,r,i,a=-1,s=[],l=[];for(e=e+"",t=t+"";(n=Wi.exec(e))&&(r=Yi.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:tt(n,r)})),o=Yi.lastIndex;return o<t.length&&(i=t.slice(o),s[a]?s[a]+=i:s[++a]=i),s.length<2?l[0]?Qf(l[0].x):Jf(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 ul=180/Math.PI,ir={translateX:0,translateY:0,rotate:0,skewX:0,scaleX:1,scaleY:1};function Xi(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 sr;function pl(e){let t=new(typeof DOMMatrix=="function"?DOMMatrix:WebKitCSSMatrix)(e+"");return t.isIdentity?ir:Xi(t.a,t.b,t.c,t.d,t.e,t.f)}function fl(e){return e==null?ir:(sr||(sr=document.createElementNS("http://www.w3.org/2000/svg","g")),sr.setAttribute("transform",e),(e=sr.transform.baseVal.consolidate())?(e=e.matrix,Xi(e.a,e.b,e.c,e.d,e.e,e.f)):ir)}function ml(e,t,o,n){function r(c){return c.length?c.pop()+" ":""}function i(c,d,u,m,p,g){if(c!==u||d!==m){var h=p.push("translate(",null,t,null,o);g.push({i:h-4,x:tt(c,u)},{i:h-2,x:tt(d,m)})}else(u||m)&&p.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:tt(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:tt(c,d)}):d&&u.push(r(u)+"skewX("+d+n)}function l(c,d,u,m,p,g){if(c!==u||d!==m){var h=p.push(r(p)+"scale(",null,",",null,")");g.push({i:h-4,x:tt(c,u)},{i:h-2,x:tt(d,m)})}else(u!==1||m!==1)&&p.push(r(p)+"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(p){for(var g=-1,h=m.length,f;++g<h;)u[(f=m[g]).i]=f.x(p);return u.join("")}}}var Ui=ml(pl,"px, ","px)","deg)"),$i=ml(fl,", ",")",")");var wo=0,rn=0,nn=0,hl=1e3,ar,sn,lr=0,ro=0,cr=0,an=typeof performance=="object"&&performance.now?performance:Date,yl=typeof window=="object"&&window.requestAnimationFrame?window.requestAnimationFrame.bind(window):function(e){setTimeout(e,17)};function cn(){return ro||(yl(jf),ro=an.now()+cr)}function jf(){ro=0}function ln(){this._call=this._time=this._next=null}ln.prototype=dr.prototype={constructor:ln,restart:function(e,t,o){if(typeof e!="function")throw new TypeError("callback is not a function");o=(o==null?cn():+o)+(t==null?0:+t),!this._next&&sn!==this&&(sn?sn._next=this:ar=this,sn=this),this._call=e,this._time=o,Ki()},stop:function(){this._call&&(this._call=null,this._time=1/0,Ki())}};function dr(e,t,o){var n=new ln;return n.restart(e,t,o),n}function xl(){cn(),++wo;for(var e=ar,t;e;)(t=ro-e._time)>=0&&e._call.call(void 0,t),e=e._next;--wo}function gl(){ro=(lr=an.now())+cr,wo=rn=0;try{xl()}finally{wo=0,tm(),ro=0}}function em(){var e=an.now(),t=e-lr;t>hl&&(cr-=t,lr=e)}function tm(){for(var e,t=ar,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:ar=o);sn=e,Ki(n)}function Ki(e){if(!wo){rn&&(rn=clearTimeout(rn));var t=e-ro;t>24?(e<1/0&&(rn=setTimeout(gl,e-an.now()-cr)),nn&&(nn=clearInterval(nn))):(nn||(lr=an.now(),nn=setInterval(em,hl)),wo=1,yl(gl))}}function ur(e,t,o){var n=new ln;return t=t==null?0:+t,n.restart(r=>{n.stop(),e(r+t)},t,o),n}var om=Ri("start","end","cancel","interrupt"),nm=[],_l=0,El=1,fr=2,pr=3,bl=4,mr=5,dn=6;function Dt(e,t,o,n,r,i){var a=e.__transition;if(!a)e.__transition={};else if(o in a)return;rm(e,o,{name:t,index:n,group:r,on:om,tween:nm,time:i.time,delay:i.delay,duration:i.duration,ease:i.ease,timer:null,state:_l})}function un(e,t){var o=Ce(e,t);if(o.state>_l)throw new Error("too late; already scheduled");return o}function De(e,t){var o=Ce(e,t);if(o.state>pr)throw new Error("too late; already running");return o}function Ce(e,t){var o=e.__transition;if(!o||!(o=o[t]))throw new Error("transition not found");return o}function rm(e,t,o){var n=e.__transition,r;n[t]=o,o.timer=dr(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,u,m,p;if(o.state!==El)return l();for(d in n)if(p=n[d],p.name===o.name){if(p.state===pr)return ur(a);p.state===bl?(p.state=dn,p.timer.stop(),p.on.call("interrupt",e,e.__data__,p.index,p.group),delete n[d]):+d<t&&(p.state=dn,p.timer.stop(),p.on.call("cancel",e,e.__data__,p.index,p.group),delete n[d])}if(ur(function(){o.state===pr&&(o.state=bl,o.timer.restart(s,o.delay,o.time),s(c))}),o.state=fr,o.on.call("start",e,e.__data__,o.index,o.group),o.state===fr){for(o.state=pr,r=new Array(m=o.tween.length),d=0,u=-1;d<m;++d)(p=o.tween[d].value.call(e,e.__data__,o.index,o.group))&&(r[++u]=p);r.length=u+1}}function s(c){for(var d=c<o.duration?o.ease.call(null,c/o.duration):(o.timer.restart(l),o.state=mr,1),u=-1,m=r.length;++u<m;)r[u].call(e,d);o.state===mr&&(o.on.call("end",e,e.__data__,o.index,o.group),l())}function l(){o.state=dn,o.timer.stop(),delete n[t];for(var c in n)return;delete e.__transition}}function qi(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>fr&&n.state<mr,n.state=dn,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(){qi(this,e)})}function im(e,t){var o,n;return function(){var r=De(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 sm(e,t,o){var n,r;if(typeof o!="function")throw new Error;return function(){var i=De(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=Ce(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?im:sm)(o,e,t))}function Io(e,t,o){var n=e._id;return e.each(function(){var r=De(this,n);(r.value||(r.value={}))[t]=o.apply(this,arguments)}),function(r){return Ce(r,n).value[t]}}function gr(e,t){var o;return(typeof t=="number"?tt:t instanceof Rt?rr:(o=Rt(t))?(t=o,rr):Fi)(e,t)}function am(e){return function(){this.removeAttribute(e)}}function lm(e){return function(){this.removeAttributeNS(e.space,e.local)}}function cm(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 dm(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 um(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 pm(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=Nt(e),n=o==="transform"?$i:gr;return this.attrTween(e,typeof t=="function"?(o.local?pm:um)(o,n,Io(this,"attr."+e,t)):t==null?(o.local?lm:am)(o):(o.local?dm:cm)(o,n,t))}function fm(e,t){return function(o){this.setAttribute(e,t.call(this,o))}}function mm(e,t){return function(o){this.setAttributeNS(e.space,e.local,t.call(this,o))}}function gm(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 hm(e,t){var o,n;function r(){var i=t.apply(this,arguments);return i!==n&&(o=(n=i)&&fm(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=Nt(e);return this.tween(o,(n.local?gm:hm)(n,t))}function ym(e,t){return function(){un(this,e).delay=+t.apply(this,arguments)}}function xm(e,t){return t=+t,function(){un(this,e).delay=t}}function Il(e){var t=this._id;return arguments.length?this.each((typeof e=="function"?ym:xm)(t,e)):Ce(this.node(),t).delay}function Em(e,t){return function(){De(this,e).duration=+t.apply(this,arguments)}}function bm(e,t){return t=+t,function(){De(this,e).duration=t}}function Al(e){var t=this._id;return arguments.length?this.each((typeof e=="function"?Em:bm)(t,e)):Ce(this.node(),t).duration}function _m(e,t){if(typeof t!="function")throw new Error;return function(){De(this,e).ease=t}}function Cl(e){var t=this._id;return arguments.length?this.each(_m(t,e)):Ce(this.node(),t).ease}function Nm(e,t){return function(){var o=t.apply(this,arguments);if(typeof o!="function")throw new Error;De(this,e).ease=o}}function Sl(e){if(typeof e!="function")throw new Error;return this.each(Nm(this._id,e))}function Ml(e){typeof e!="function"&&(e=Qo(e));for(var t=this._groups,o=t.length,n=new Array(o),r=0;r<o;++r)for(var i=t[r],a=i.length,s=n[r]=[],l,c=0;c<a;++c)(l=i[c])&&e.call(l,l.__data__,c,i)&&s.push(l);return new Ge(n,this._parents,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,u=a[s]=new Array(d),m,p=0;p<d;++p)(m=l[p]||c[p])&&(u[p]=m);for(;s<n;++s)a[s]=t[s];return new Ge(a,this._parents,this._name,this._id)}function Tm(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 vm(e,t,o){var n,r,i=Tm(t)?un:De;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?Ce(this.node(),o).on.on(e):this.each(vm(o,e,t))}function wm(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",wm(this._id))}function Rl(e){var t=this._name,o=this._id;typeof e!="function"&&(e=to(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,Dt(c[m],t,o,m,c,Ce(d,o)));return new Ge(i,this._parents,t,o)}function Dl(e){var t=this._name,o=this._id;typeof e!="function"&&(e=Jo(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),p,g=Ce(d,o),h=0,f=m.length;h<f;++h)(p=m[h])&&Dt(p,t,o,h,m,g);i.push(m),a.push(d)}return new Ge(i,a,t,o)}var Im=Tt.prototype.constructor;function Ol(){return new Im(this._groups,this._parents)}function Am(e,t){var o,n,r;return function(){var i=kt(this,e),a=(this.style.removeProperty(e),kt(this,e));return i===a?null:i===o&&a===n?r:r=t(o=i,n=a)}}function Hl(e){return function(){this.style.removeProperty(e)}}function Cm(e,t,o){var n,r=o+"",i;return function(){var a=kt(this,e);return a===r?null:a===n?i:i=t(n=a,o)}}function Sm(e,t,o){var n,r,i;return function(){var a=kt(this,e),s=o(this),l=s+"";return s==null&&(l=s=(this.style.removeProperty(e),kt(this,e))),a===l?null:a===n&&l===r?i:(r=l,i=t(n=a,s))}}function Mm(e,t){var o,n,r,i="style."+t,a="end."+i,s;return function(){var l=De(this,e),c=l.on,d=l.value[i]==null?s||(s=Hl(t)):void 0;(c!==o||r!==d)&&(n=(o=c).copy()).on(a,r=d),l.on=n}}function Vl(e,t,o){var n=(e+="")=="transform"?Ui:gr;return t==null?this.styleTween(e,Am(e,n)).on("end.style."+e,Hl(e)):typeof t=="function"?this.styleTween(e,Sm(e,n,Io(this,"style."+e,t))).each(Mm(this._id,e)):this.styleTween(e,Cm(e,n,t),o).on("end.style."+e,null)}function Pm(e,t,o){return function(n){this.style.setProperty(e,t.call(this,n),o)}}function Lm(e,t,o){var n,r;function i(){var a=t.apply(this,arguments);return a!==r&&(n=(r=a)&&Pm(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,Lm(e,t,o==null?"":o))}function km(e){return function(){this.textContent=e}}function Rm(e){return function(){var t=e(this);this.textContent=t==null?"":t}}function Bl(e){return this.tween("text",typeof e=="function"?Rm(Io(this,"text",e)):km(e==null?"":e+""))}function Dm(e){return function(t){this.textContent=e.call(this,t)}}function Om(e){var t,o;function n(){var r=e.apply(this,arguments);return r!==o&&(t=(o=r)&&Dm(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,Om(e))}function Yl(){for(var e=this._name,t=this._id,o=hr(),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=Ce(l,t);Dt(l,e,o,c,a,{time:d.time+d.delay+d.duration,delay:0,duration:d.duration,ease:d.ease})}return new Ge(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=De(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 Ge(e,t,o,n){this._groups=e,this._parents=t,this._name=o,this._id=n}function Fl(e){return Tt().transition(e)}function hr(){return++Hm}var vt=Tt.prototype;Ge.prototype=Fl.prototype={constructor:Ge,select:Rl,selectAll:Dl,selectChild:vt.selectChild,selectChildren:vt.selectChildren,filter:Ml,merge:Pl,selection:Ol,transition:Yl,call:vt.call,nodes:vt.nodes,node:vt.node,size:vt.size,empty:vt.empty,each:vt.each,on:Ll,attr:vl,attrTween:wl,style:Vl,styleTween:Gl,text:Bl,textTween:zl,remove:kl,tween:Tl,delay:Il,duration:Al,ease:Cl,easeVarying:Sl,end:Wl,[Symbol.iterator]:vt[Symbol.iterator]};function yr(e){return((e*=2)<=1?e*e*e:(e-=2)*e*e+2)/2}var Vm={time:null,delay:0,duration:250,ease:yr};function Gm(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 Ge?(t=e._id,e=e._name):(t=hr(),(o=Vm).time=cn(),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])&&Dt(l,e,t,c,a,o||Gm(l,t));return new Ge(n,this._parents,e,t)}Tt.prototype.interrupt=Nl;Tt.prototype.transition=Xl;function Ot(e,t,o){this.k=e,this.x=t,this.y=o}Ot.prototype={constructor:Ot,scale:function(e){return e===1?this:new Ot(this.k*e,this.x,this.y)},translate:function(e,t){return e===0&t===0?this:new Ot(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 xr=new Ot(1,0,0);Er.prototype=Ot.prototype;function Er(e){for(;!e.__zoom;)if(!(e=e.parentNode))return xr;return e.__zoom}var zm=[[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 We;(function(e){e.Left="left",e.Top="top",e.Right="right",e.Bottom="bottom"})(We||(We={}));var Pw={[We.Left]:We.Right,[We.Right]:We.Left,[We.Top]:We.Bottom,[We.Bottom]:We.Top};var Ym=e=>"id"in e&&"internals"in e&&!("source"in e)&&!("target"in e);var Wm=(e,t=[0,0])=>{var s;let{width:o,height:n}=Fm(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 br=(e,t=[0,0])=>{var r,i,a,s,l,c,d,u;let{x:o,y:n}=Ym(e)?e.internals.positionAbsolute:Wm(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 Fm(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 Lw={[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 Xm={nodeOrigin:[0,0],nodeExtent:zm,elevateNodesOnSelect:!0,defaults:{}},kw=v(_({},Xm),{checkEquality:!0});var Jl;(function(e){e.Line="line",e.Handle="handle"})(Jl||(Jl={}));var Um={width:0,height:0,x:0,y:0},Rw=v(_({},Um),{pointerX:0,pointerY:0,aspectRatio:1});var $m=(e,t)=>e.x<t.x2&&e.x2>t.x&&e.y<t.y2&&e.y2>t.y;function Km(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 _r=class{constructor(){this.xLines=[];this.yLines=[]}initialize(t){this.xLines=t.filter(o=>o.orientation==="vertical"),this.yLines=t.filter(o=>o.orientation==="horizontal"),this.xLines.sort((o,n)=>o.position-n.position),this.yLines.sort((o,n)=>o.position-n.position),this.lastHorizontalLine=void 0,this.lastVerticalLine=void 0}search(t,o,n,r,i){let a=t==="horizontal"?this.yLines:this.xLines,[s,l]=t==="horizontal"?[r.y,r.y2]:[r.x,r.x2],c=[];for(let p of a){if(p.position<s)continue;if(p.position>l)break;if(i.has(p.node.id)||p.node.parentId&&i.has(p.node.parentId)||!$m(p.nodeBox,r))continue;let g=Math.abs(p.position-o);if(g>Nr)continue;let f=Km(p.nodeBox,n)>0?0:qm(p.nodeBox,n);c.push({line:p,lineDist:g,nodeDist:f})}let d=.5,u=t==="horizontal"?this.lastHorizontalLine:this.lastVerticalLine;c.sort((p,g)=>{if(u){if(p.line===u&&g.line!==u)return-1;if(g.line===u&&p.line!==u)return 1}return Math.abs(p.lineDist-g.lineDist)<=d?p.nodeDist-g.nodeDist:p.lineDist-g.lineDist});let m=c.length>0?c[0].line:void 0;return m&&(t==="horizontal"?this.lastHorizontalLine=m:this.lastVerticalLine=m),m}};function Ql(e,t=io,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=br(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(io)){let i=[];for(let s of r){let l=io[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)<=Nr&&(r=l,a=!0)}if(o){let l=o.anchor.resolve(null,e)-o.line.position;Math.abs(l)<=Nr&&(n=l,i=!0)}return{deltaX:n,deltaY:r,snappedX:i,snappedY:a}}var Nr=10,io={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 ng}from"react/jsx-runtime";var og=new _r;function Tr(){let[e,t]=tc(void 0),[o,n]=tc(void 0),{width:r,height:i}=Qm(f=>({width:f.width,height:f.height}),tg),a=Zm(),s=eg(og),{screenToFlowPosition:l,getInternalNode:c,getNodes:d}=Jm(),u=pn(()=>{t(void 0),n(void 0)},[]),m=pn(f=>{let y=f!=null?f:d();u();let N=Ql(y,io,c);s.current.initialize(N)},[c,u,d]),p=pn(()=>{setTimeout(()=>{m()},100)},[m]);jm(()=>{a&&m(d())},[a,m,d]);let g=pn((f,y)=>{var P,R,V,B,ee,oe,q,Z,Q,se;if(!s.current||f.length===0||f.filter(W=>W.type==="dimensions").length>1)return f;u();let E=f.filter(W=>W.type==="position"&&!!W.position),T=f.find(W=>W.type==="dimensions");if(E.length===0&&!T)return f;let b=Object.keys(io),x=new Set,w=1/0,A=1/0,I=-1/0,D=-1/0;if(E.length>0)E.forEach(W=>{var ce,j,le,ye,Ne,Pe;let ne=y.find(ze=>ze.id===W.id);if(!ne)return;x.add(ne.id);let ae=c(ne.id);if(!ae)return;let $=ae.parentId?c(ae.parentId):void 0,he=W.position.x+((ce=$==null?void 0:$.internals.positionAbsolute.x)!=null?ce:0),fe=W.position.y+((j=$==null?void 0:$.internals.positionAbsolute.y)!=null?j:0),F=(ye=(le=ne.measured)==null?void 0:le.width)!=null?ye:0,ue=(Pe=(Ne=ne.measured)==null?void 0:Ne.height)!=null?Pe:0;w=Math.min(w,he),A=Math.min(A,fe),I=Math.max(I,he+F),D=Math.max(D,fe+ue)}),T&&(b=["top","left"]);else if(T){let W=y.find(F=>F.id===T.id);if(!W)return f;x.add(W.id);let ne=c(W.id);if(!ne)return f;let ae=ne.internals.positionAbsolute.x,$=ne.internals.positionAbsolute.y,he=(B=(V=(P=T.dimensions)==null?void 0:P.width)!=null?V:(R=W.measured)==null?void 0:R.width)!=null?B:0,fe=(Z=(q=(ee=T.dimensions)==null?void 0:ee.height)!=null?q:(oe=W.measured)==null?void 0:oe.height)!=null?Z:0;w=ae,A=$,I=ae+he,D=$+fe,b=["right","bottom"]}if(w===1/0)return f;let S={x:w,y:A,x2:I,y2:D},{x:L,y:z}=l({x:0,y:0}),{x:U,y:K}=l({x:r,y:i}),Y={x:L,y:z,x2:U,y2:K},{horizontal:X,vertical:M}=jl(s.current,Y,S,x,b),{deltaX:O,deltaY:H,snappedX:C,snappedY:k}=ec(S,X,M);if(C||k){let W=E.some(ae=>ae.dragging),ne=!!(T!=null&&T.resizing);(W||ne)&&(C&&n(M==null?void 0:M.line),k&&t(X==null?void 0:X.line)),C&&(E.forEach(ae=>{ae.position&&(ae.position.x-=O)}),(T==null?void 0:T.id)===((Q=E[0])==null?void 0:Q.id)?T.dimensions&&(T.dimensions.width+=O):T&&!E.length&&T.dimensions&&(T.dimensions.width-=O)),k&&(E.forEach(ae=>{ae.position&&(ae.position.y-=H)}),(T==null?void 0:T.id)===((se=E[0])==null?void 0:se.id)?T.dimensions&&(T.dimensions.height+=H):T&&!E.length&&T.dimensions&&(T.dimensions.height-=H))}return f},[l,c,r,i,t,n,u]),h=pn(()=>ng(oc,{horizontal:e,vertical:o}),[e,o]);return{rebuildIndex:m,forceRebuildIndex:p,updateHelperLines:g,helperLineHorizontal:e,helperLineVertical:o,HelperLines:h}}import{reconnectEdge as o0,useReactFlow as n0}from"@xyflow/react";import{useCallback as po,useRef as r0}from"react";var wt=e=>new Map(e.map(t=>[t.id,t])),fn=(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)),Zi=e=>e.some(t=>t.type==="START_EVENT"),Ht=(e,t)=>e==="START_EVENT"?!Zi(t):!0,rc=(e,t,o,n,r)=>{let i=wt(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:fn(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=wt(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},vr=(e,t,o,n,r)=>{var c;let i=wt(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:fn(e,n,r).filter(d=>{let u=i.get(d.target);return(u==null?void 0:u.type)!=="ANNOTATION"}).length>=2},sc=(e,t,o)=>{var a,s,l,c;let n=wt(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"},wr=(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"},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.attribute)==="LOOP"},mn=(e,t,o,n)=>{let r=wt(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"})},gn=(e,t,o,n)=>{let r=wt(t),i=r.get(e);return!i||i.type!=="TASK"?!1:fn(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=wt(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"?gn(t,o,n,r):(s==null?void 0:s.type)==="END_EVENT"&&(a==null?void 0:a.type)==="TASK"?mn(e,o,n,r):!1},Ar=(e,t,o)=>fn(e,t,o).length>0,Cr=(e,t,o,n,r)=>{let i=wt(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:fn(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=wt(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 rg=[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:!vr(e.sourceNodeId,e.targetNodeId,e.nodes,e.edges,e.reconnectingEdgeId),reason:"gateway_limit_reached"}),e=>({isValid:!Cr(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:!(wr(e.sourceNodeId,e.nodes)&&e.targetNodeType==="END_EVENT"),reason:"script_to_end_not_allowed"}),e=>({isValid:!(Ir(e.sourceNodeId,e.nodes)&&e.targetNodeType==="END_EVENT"),reason:"loop_to_end_not_allowed"}),e=>({isValid:!(mn(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:!(gn(e.sourceNodeId,e.nodes,e.edges,e.reconnectingEdgeId)&&e.targetNodeType!=="ANNOTATION"),reason:"final_activity_cannot_connect"}),e=>({isValid:!(Ar(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"})],Ji=e=>{for(let t of rg){let o=t(e);if(!o.isValid)return o}return{isValid:!0}};var ig=[{sourceTypes:["GATEWAY"],targetTypes:["TASK","GATEWAY"],validate:e=>({shouldDisable:vr(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:Zi(e.nodes),reason:"start_event_already_exists"})},{sourceTypes:["TASK"],targetTypes:["END_EVENT"],validate:e=>({shouldDisable:wr(e.sourceNodeId,e.nodes),reason:"script_to_end_not_allowed"})},{sourceTypes:["TASK"],targetTypes:["END_EVENT"],validate:e=>({shouldDisable:Ir(e.sourceNodeId,e.nodes),reason:"loop_to_end_not_allowed"})},{sourceTypes:["TASK"],targetTypes:["END_EVENT"],validate:e=>({shouldDisable:mn(e.sourceNodeId,e.nodes,e.edges),reason:"initial_activity_to_end_not_allowed"})},{sourceTypes:["TASK"],validate:e=>({shouldDisable:gn(e.sourceNodeId,e.nodes,e.edges)&&e.targetNodeType!=="ANNOTATION",reason:"final_activity_cannot_connect"})},{targetTypes:["END_EVENT"],validate:e=>({shouldDisable:Ar(e.sourceNodeId,e.edges),reason:"activity_has_outgoing_connections"})},{sourceTypes:["TASK"],validate:e=>({shouldDisable:Cr(e.sourceNodeId,null,e.nodes,e.edges)&&e.targetNodeType!=="ANNOTATION",reason:"task_limit_reached"})}],dc=e=>{let t=ig.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 Rg,EdgeLabelRenderer as Dg,getStraightPath as Og,useInternalNode as pc,useViewport as Hg}from"@xyflow/react";import{Button as lg,Tooltip as cg,TooltipContent as dg,TooltipTrigger as ug,useTranslation as pg}from"@produto-lecom/lecom-ui";import{Settings as fg}from"lucide-react";import{getIncomers as Sr,getOutgoers as Mr,useReactFlow as ag}from"@xyflow/react";import{useStoreApi as sg}from"@xyflow/react";var Vt=()=>{let e=sg();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 On(),!0}}};var Pr=()=>{let{getNode:e,getEdge:t,getNodes:o,getEdges:n}=ag(),{selectElements:r}=Vt(),i=f=>{let y=o(),N=n(),E=Sr(f,y,N),T=Mr(f,y,N),b=E.some(w=>w.type==="START_EVENT"),x=T.some(w=>w.type==="END_EVENT");return b?"start":x?"end":"between"},a=(f,y,N)=>{var b,x,w,A;if(!f)return;let E={type:f.type,variant:(b=f.data)==null?void 0:b.variant,attribute:(x=f.data)==null?void 0:x.attribute},T={id:f.id,position:i(f),label:(w=f.data)==null?void 0:w.label,node:E};return f.type==="TASK"&&((A=f.data)==null?void 0:A.variant)==="SUBPROCESS"?v(_({},T),{type:"sub_process"}):f.type==="GATEWAY"?v(_({},T),{type:"gateway",variant:s(f,y,N)}):v(_({},T),{type:"activity"})},s=(f,y,N)=>{if(f.type!=="GATEWAY")return;let E=Sr(f,y,N),T=!1,b=!1;if(E.forEach(x=>{var w,A;x.type==="TASK"&&(((w=x.data)==null?void 0:w.variant)==="SCRIPT"&&(T=!0),((A=x.data)==null?void 0:A.attribute)==="LOOP"&&(b=!0))}),T&&b)return"script_loop";if(T)return"script";if(b)return"loop"},l=(f,y,N)=>{var w,A,I,D;let E=e(f.source),T=e(f.target);if(!E||!T)return"simple";if(Mr(E,y,N).some(S=>S.type==="END_EVENT"))return"final";if(E.type==="GATEWAY")switch((w=E.data)==null?void 0:w.variant){case"PARALLEL":return"parallel";case"EXCLUSIVE":return"exclusive";case"COMPLEX":return"complex";default:return"simple"}if(E.type==="TASK"){let S=(A=E.data)==null?void 0:A.variant,L=(I=E.data)==null?void 0:I.attribute;if(S==="SUBPROCESS")return"from_sub_process";if(T.type==="TASK"&&((D=T.data)==null?void 0:D.variant)==="SUBPROCESS")return"to_sub_process";let z=S==="SCRIPT",U=L==="LOOP";return z&&U?"script_loop":z?"script":U?"loop":"simple"}return"simple"},c=(f,y,N)=>{let E=[];function T(x,w,A=0){let I=a(x,y,N);if(I.depth=A,w.push(I),x.type==="TASK"){E.push([...w]),w.pop();return}let D=Sr(x,y,N);if(D.length)for(let S of D)T(S,w,A+1);w.pop()}let b=Sr(f,y,N);for(let x of b)T(x,[]);return E},d=(f,y,N)=>{let E=[];function T(x,w,A=0){let I=a(x,y,N);if(I.depth=A,w.push(I),x.type==="TASK"){E.push([...w]),w.pop();return}let D=Mr(x,y,N);if(D.length)for(let S of D)T(S,w,A+1);w.pop()}let b=Mr(f,y,N);for(let x of b)T(x,[]);return E},u=(f,y,N)=>(N=N.filter(T=>T.source===f.id),N.map(T=>{var w;let b=e(T.target),x;return b&&(x=a(b,y,N)),{id:T.id,type:"routing",variant:l(T,y,N),label:(w=T.data)==null?void 0:w.label,target:x}})),m=f=>{let y=e(f);if(!y)return;let N=o(),E=n(),T=a(y,N,E);return T.sources=c(y,N,E),T.targets=d(y,N,E),T.edgeTargets=u(y,N,E),y.type==="GATEWAY"&&(T.variant=s(y,N,E)),T},p=f=>{let y=t(f);if(!y)return;let N=o(),E=n(),T=l(y,N,E),x={id:y.id,type:"routing",variant:T,gatewayVariant:void 0},w=e(y.source);if(w){let I=a(w,N,E);x.source=I;let D=s(w,N,E);if(x.gatewayVariant=D,w.type==="TASK")x.sources=[[I]];else{let S=c(w,N,E);x.sources=S.length?S:[[I]]}}let A=e(y.target);if(A){let I=a(A,N,E);if(x.target=I,A.type==="TASK")x.targets=[[I]];else{let D=d(A,N,E);x.targets=D.length?D:[[I]]}}return x},g=f=>{let y=e(f);if(y)return m(y.id);let N=t(f);if(N)return p(N.id)};return{configureElement:f=>{let y=g(f);if(y)return r([f]),y},getConfigureElement:g,getNodeConfigure:m,getEdgeConfigure:p}};import{jsx as Lr,jsxs as mg}from"react/jsx-runtime";var Gt=({elementId:e,elementType:t="node"})=>{let{t:o}=pg(),{onConfigureElement:n}=J(),{getConfigureElement:r}=Pr();return mg(cg,{children:[Lr(ug,{asChild:!0,children:Lr(lg,{variant:"ghost",color:"grey",size:"small",iconButton:!0,onClick:()=>{let a=r(e);a&&(n==null||n(a))},children:Lr(fg,{size:16})})}),Lr(dg,{color:"black",children:o(t==="node"?"editor.toolbar.configure_node":"editor.toolbar.configure_edge")})]})};import{Button as hg,Tooltip as yg,TooltipContent as xg,TooltipTrigger as Eg,useTranslation as bg}from"@produto-lecom/lecom-ui";import{useReactFlow as _g}from"@xyflow/react";import{TrashIcon as Ng}from"lucide-react";import{useNotificationToast as gg}from"@produto-lecom/lecom-ui";function Fe(){let{toast:e}=hn(),{toast:t}=gg();return{toast:e||t}}import{jsx as kr,jsxs as Tg}from"react/jsx-runtime";var Rr=({elementId:e,elementType:t="node"})=>{let{t:o}=bg(),{toast:n}=Fe(),{deleteElements:r,getNodes:i}=_g();return Tg(yg,{children:[kr(Eg,{asChild:!0,children:kr(hg,{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:kr(Ng,{size:16})})}),kr(xg,{color:"black",children:o("editor.toolbar.delete")})]})};import{Button as vg,Tooltip as wg,TooltipContent as Ig,TooltipTrigger as Ag,useTranslation as Cg}from"@produto-lecom/lecom-ui";import{MoveUpRightIcon as Sg}from"lucide-react";import{useCallback as Mg}from"react";import{jsx as Dr,jsxs as Pg}from"react/jsx-runtime";var Ao=({nodeId:e,disabled:t=!1,tooltipMessage:o})=>{let{t:n}=Cg(),r=Mg(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,p)=>{let g=m.getBoundingClientRect(),h=p.getBoundingClientRect(),f=Math.hypot(i.clientX-(g.left+g.width/2),i.clientY-(g.top+g.height/2));return Math.hypot(i.clientX-(h.left+h.width/2),i.clientY-(h.top+h.height/2))<f?p: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 Pg(wg,{children:[Dr(Ag,{asChild:!0,children:Dr(vg,{variant:"ghost",color:"grey",size:"small",iconButton:!0,disabled:t,className:t?"opacity-50 cursor-not-allowed":"",onMouseDown:t?void 0:r,children:Dr(Sg,{size:16})})}),Dr(Ig,{color:"black",children:o||n("editor.toolbar.connect_node")})]})};import{jsx as yn}from"react/jsx-runtime";var Co=i=>{var a=i,{edgeId:e,edgeType:t,sourceNode:o,targetNode:n}=a,r=mt(a,["edgeId","edgeType","sourceNode","targetNode"]);let{mode:s}=J(),{isFromStartEvent:l,isGatewayToGateway:c,isActiviyToAndGateway:d,isToEndEvent:u}=zn(o,n),m=!l&&!c&&!d&&!u,p=[{component:yn(Rr,{elementId:e,elementType:"edge"})}],g=()=>s==="view"?m?[{component:yn(Gt,{elementId:e,elementType:"edge"})}]:[]:m?[{component:yn(Gt,{elementId:e,elementType:"edge"})},...p]:p,f=(y=>{switch(y){case"SEQUENCE_EDGE":return g();case"MESSAGE_EDGE":return s==="view"?[]:[...p];case"ANNOTATION_EDGE":return s==="view"?[]:[...p];default:return[]}})(t);if(!(f.length===0||s==="readonly"))return yn("div",v(_({className:"flex items-center gap-1 w-fit px-3 py-2 bg-white rounded-sm shadow-md"},r),{children:f.map((y,N)=>yn("div",{children:y.component},N))}))};import{useViewport as Lg}from"@xyflow/react";import{useMemo as kg}from"react";import{jsx as uc}from"react/jsx-runtime";var yt=12,So=({sx:e,sy:t,tx:o,ty:n,hasLabel:r=!1,children:i})=>{let{zoom:a}=Lg(),s=1/a,l=kg(()=>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:_({},l),children:i})})};import{Fragment as Vg,jsx as ao,jsxs as fc}from"react/jsx-runtime";var Mo={type:"ANNOTATION_EDGE",reconnectable:!0},mc=({id:e,source:t,target:o,selected:n,data:r})=>{let{isMultipleSelection:i}=J(),{zoom:a}=Hg(),s=pc(t),l=pc(o);if(!s||!l)return null;let{sx:c,sy:d,tx:u,ty:m}=bo(s,l),[p,g,h]=Og({sourceX:c,sourceY:d,targetX:u,targetY:m}),f=n||(s==null?void 0:s.selected)||(l==null?void 0:l.selected);return ao(Vg,{children:fc("g",{className:G("group bpmn-edge",{"is-highlighted":f}),children:[ao("path",{d:p,fill:"none",stroke:"transparent",strokeWidth:Math.max(12,12/a),style:{pointerEvents:"stroke",cursor:"pointer"}}),fc("g",{className:G("text-grey-500 transition-colors duration-75 group-hover:text-grey-800",{"text-blue-500 group-hover:text-blue-600":f}),children:[ao(Rg,{id:e,path:p,interactionWidth:0,strokeDasharray:4,className:G("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)})}),ao(Dg,{children:ao("div",{className:"absolute z-[3000] pointer-events-auto flex flex-col items-center gap-1",style:{transform:`translate(-50%, -50%) translate(${g}px, ${h}px)`},children:n&&!i&&ao(So,{sx:c,sy:d,tx:u,ty:m,children:ao(Co,{edgeId:e,edgeType:"ANNOTATION_EDGE"})})})})]})]})})};import{useState as vc,useCallback as wc,useMemo as es,useEffect as th,useRef as ts}from"react";import{BaseEdge as oh,EdgeLabelRenderer as nh,MarkerType as Ic,useInternalNode as Ac,useReactFlow as rh,useViewport as ih,useEdges as sh,useNodes as ah,Position as Ro}from"@xyflow/react";import{useCallback as Gg,useEffect as Qi,useRef as gc,useState as Bg}from"react";import{jsx as yc}from"react/jsx-runtime";var ji=/[a-zA-Z0-9À-ÖØ-öø-ÿ]/,hc=["Backspace","Delete","ArrowLeft","ArrowRight","ArrowUp","ArrowDown","Home","End","Tab","Escape","Shift"],Oe=({value:e,maxLength:t,style:o,className:n,contentClassName:r,isEditing:i,onChange:a,onBlur:s,onInput:l,onInvalidFirstCharacter:c,skipFirstCharValidation:d})=>{let u=gc(null),m=gc(null),[p,g]=Bg(!1);Qi(()=>()=>{m.current&&clearTimeout(m.current)},[]),Qi(()=>{g(i!=null?i:!1)},[i]),Qi(()=>{if(p&&u.current){u.current.focus();let b=document.createRange();b.selectNodeContents(u.current);let x=window.getSelection();x&&(x.removeAllRanges(),x.addRange(b))}},[p]);let h=Gg(()=>{m.current||(c==null||c(),m.current=setTimeout(()=>{m.current=null},500))},[c]),f=b=>{b.stopPropagation(),p||g(!0)},y=b=>{let x=b.currentTarget.innerText.replace(/\n$/,""),w=t&&x.length>=t,A=window.getSelection(),I=(A==null?void 0:A.toString())||"",D=I.length>0,S=(b.ctrlKey||b.metaKey)&&!b.altKey,L=S&&b.key==="a",z=S&&b.key==="c",U=S&&b.key==="x",K=S&&b.key==="v",Y=x.length===0||D&&I.length===x.length;if(!d&&Y&&!ji.test(b.key)&&!hc.includes(b.key)&&!S){b.preventDefault(),h();return}w&&!D&&(hc.includes(b.key)||L||z||U||K||b.preventDefault())},N=b=>{b.preventDefault();let x=b.clipboardData.getData("text/plain").replace(/\r\n/g,`
2
2
  `).replace(/\r/g,`
3
- `),w=b.currentTarget.innerText.replace(/\n$/,""),A=window.getSelection();if(!A||A.rangeCount===0)return;let I=A.toString(),D=w.length-I.length,S=t?Math.max(0,t-D):1/0;if(S<=0&&I.length===0)return;let L=g;if(L.length>S&&(L=L.substring(0,S)),!L&&I.length===0)return;let z=A.getRangeAt(0),q=z.startOffset===0&&(z.startContainer===b.currentTarget||z.startContainer.parentNode===b.currentTarget);if(!d&&q&&L.length>0&&!ji.test(L[0])){y();return}z.deleteContents();let Q=document.createTextNode(L);z.insertNode(Q),z.setStartAfter(Q),z.collapse(!0),A.removeAllRanges(),A.addRange(z),l==null||l(b.currentTarget.innerText.replace(/\n$/,""))},E=b=>{let g=b.currentTarget,w=g.innerText.replace(/\n$/,"");if(!d&&w.length>0&&!ji.test(w[0])){let A=w.slice(1);if(g.innerText=A,A.length>0&&g.firstChild){let I=document.createRange(),D=window.getSelection();I.setStart(g.firstChild,0),I.collapse(!0),D==null||D.removeAllRanges(),D==null||D.addRange(I)}y(),l==null||l(A);return}l==null||l(w)},N=b=>{h(!1);let g=b.currentTarget.innerText.replace(/\r\n/g,`
3
+ `),w=b.currentTarget.innerText.replace(/\n$/,""),A=window.getSelection();if(!A||A.rangeCount===0)return;let I=A.toString(),D=w.length-I.length,S=t?Math.max(0,t-D):1/0;if(S<=0&&I.length===0)return;let L=x;if(L.length>S&&(L=L.substring(0,S)),!L&&I.length===0)return;let z=A.getRangeAt(0),U=z.startOffset===0&&(z.startContainer===b.currentTarget||z.startContainer.parentNode===b.currentTarget);if(!d&&U&&L.length>0&&!ji.test(L[0])){h();return}z.deleteContents();let K=document.createTextNode(L);z.insertNode(K),z.setStartAfter(K),z.collapse(!0),A.removeAllRanges(),A.addRange(z),l==null||l(b.currentTarget.innerText.replace(/\n$/,""))},E=b=>{let x=b.currentTarget,w=x.innerText.replace(/\n$/,"");if(!d&&w.length>0&&!ji.test(w[0])){let A=w.slice(1);if(x.innerText=A,A.length>0&&x.firstChild){let I=document.createRange(),D=window.getSelection();I.setStart(x.firstChild,0),I.collapse(!0),D==null||D.removeAllRanges(),D==null||D.addRange(I)}h(),l==null||l(A);return}l==null||l(w)},T=b=>{g(!1);let x=b.currentTarget.innerText.replace(/\r\n/g,`
4
4
  `).replace(/\r/g,`
5
- `).trim();t&&g.length>t&&(g=g.substring(0,t)),b.currentTarget.innerText=g,s==null||s(),g!==e&&(a==null||a(g))};return uc("div",{className:V("flex-1 p-2 self-stretch flex items-center justify-center border border-transparent overflow-hidden text-ellipsis body-medium-400 text-center rounded-sm",{"border border-dashed border-grey-400 bg-white shadow-md":p,"bg-white":e.length>0},n),style:o,onDoubleClick:m,children:uc("div",{ref:u,className:V("outline-none whitespace-pre-wrap overflow-hidden",r,{"nodrag nopan cursor-text":p}),contentEditable:p,suppressContentEditableWarning:!0,onKeyDown:x,onPaste:T,onInput:E,onBlur:N,children:e})})};import{Position as fI}from"@xyflow/react";var pe=(e,t,o,n=1)=>Math.abs(e[o]-t[o])<n,kr=(e,t)=>Math.sqrt((t.x-e.x)**2+(t.y-e.y)**2),Rr=(e,t)=>({x:(e.x+t.x)/2,y:(e.y+t.y)/2});import{Position as Dr}from"@xyflow/react";var Lt={OFFSET:30,TOLERANCE:1,MOVE_THRESHOLD:5,MIN_SEGMENT_LENGTH:15,PARALLEL_OFFSET:15};var{TOLERANCE:se}=Lt;function Dg(e,t,o){return pe(e,t,"x",se)&&pe(t,o,"x",se)&&pe(e,o,"x",se)}function Og(e,t,o){return pe(e,t,"y",se)&&pe(t,o,"y",se)&&pe(e,o,"y",se)}function Hg(e,t,o){if(!Dg(e,t,o))return!1;let n=t.y-e.y,r=o.y-t.y;return Math.abs(n)<se||Math.abs(r)<se?!1:n*r<0}function Vg(e,t,o){if(!Og(e,t,o))return!1;let n=t.x-e.x,r=o.x-t.x;return Math.abs(n)<se||Math.abs(r)<se?!1:n*r<0}function Gg(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 pc(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];pe(n,r,"x",se)&&pe(r,i,"x",se)||pe(n,r,"y",se)&&pe(r,i,"y",se)||t.push(r)}return t.push(e[e.length-1]),t}function Or(e){let t=[];for(let o of e){let n=t[t.length-1];(!n||Math.abs(n.x-o.x)>=se||Math.abs(n.y-o.y)>=se)&&t.push(o)}return t}function Bg(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(Hg(r,i,a)||Vg(r,i,a)){t.splice(n,1),o=!0;break}}}return t}function fc(e){let t=Or(pc([...e]));return t=Bg(t),Or(pc(t))}function Hr(e){switch(e){case Dr.Left:return{x:-1,y:0};case Dr.Right:return{x:1,y:0};case Dr.Top:return{x:0,y:-1};case Dr.Bottom:return{x:0,y:1};default:return{x:0,y:0}}}function mc(e,t,o,n){let r=Lt.OFFSET,i=Lt.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*Lt.OFFSET&&(r=a/2,i=a/2)}else{let a=(o.y-e.y)*t.y;a>0&&a<2*Lt.OFFSET&&(r=a/2,i=a/2)}return{sourceOffset:r,targetOffset:i}}function zg(e,t,o,n,r,i,a=0){let s=Hr(r),l=Hr(i),c=s.x===0?a:0,d=s.y===0?a:0,u=l.x===0?a:0,f=l.y===0?a:0,p={x:e+c,y:t+d},h={x:o+u,y:n+f},{sourceOffset:y,targetOffset:m}=mc(p,s,h,l),x={x:p.x+s.x*y,y:p.y+s.y*y},T={x:h.x+l.x*m,y:h.y+l.y*m},E=Gg(x,s,T,l),N=[p,x,...E,T,h],b=fc(N);if(b.length===2&&Vr(p,h)>se){let g=pe(p,x,"x",se)&&pe(x,T,"x",se)&&pe(T,h,"x",se),w=pe(p,x,"y",se)&&pe(x,T,"y",se)&&pe(T,h,"y",se);if(g||w){let A=w&&(T.x-x.x)*s.x<0,I=g&&(T.y-x.y)*s.y<0;if(!A&&!I)return Or([p,x,T,h])}}return b}function Gr(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=Hr(r),c=Hr(i),d=l.x===0?s:0,u=l.y===0?s:0,f=c.x===0?s:0,p=c.y===0?s:0,h={x:e+d,y:t+u},y={x:o+f,y:n+p},{sourceOffset:m,targetOffset:x}=mc(h,l,y,c),T={x:h.x+l.x*m,y:h.y+l.y*m},E={x:y.x+c.x*x,y:y.y+c.y*x},N=[...a],b=N[0],g=l.y===0;g&&Math.abs(h.y-b.y)>se?N.unshift({x:b.x,y:h.y}):!g&&Math.abs(h.x-b.x)>se&&N.unshift({x:h.x,y:b.y});let w=N[N.length-1],A=c.y===0,I=[];(Math.abs(w.x-E.x)>se||Math.abs(w.y-E.y)>se)&&(A?I.push({x:E.x,y:w.y}):I.push({x:w.x,y:E.y})),I.push(E);let D=[h,...N,...I,y],S=fc(D);if(S.length===2&&Vr(h,y)>se){let L=pe(h,T,"x",se)&&pe(T,E,"x",se)&&pe(E,y,"x",se),z=pe(h,T,"y",se)&&pe(T,E,"y",se)&&pe(E,y,"y",se);if(L||z){let q=z&&(E.x-T.x)*l.x<0,Q=L&&(E.y-T.y)*l.y<0;if(!q&&!Q)return Or([h,T,E,y])}}return S}var Vr=(e,t)=>Math.sqrt(Math.pow(t.x-e.x,2)+Math.pow(t.y-e.y,2));function Yg(e,t,o){return pe(e,t,"x",se)&&pe(t,o,"x",se)||pe(e,t,"y",se)&&pe(t,o,"y",se)}function Wg(e,t,o,n){if(Yg(e,t,o))return`L${t.x} ${t.y}`;let r=Vr(e,t),i=Vr(t,o),a=Math.min(r/2,i/2,n);if(a<1)return`L${t.x} ${t.y}`;let s=e.x-t.x,l=e.y-t.y,c=o.x-t.x,d=o.y-t.y,u={x:s/r,y:l/r},f={x:c/i,y:d/i},p={x:t.x+u.x*a,y:t.y+u.y*a},h={x:t.x+f.x*a,y:t.y+f.y*a},y=-u.x,m=-u.y,x=f.x,T=f.y,N=y*T-m*x>0?1:0;return`L${p.x} ${p.y}A${a} ${a} 0 0 ${N} ${h.x} ${h.y}`}var gc=(e,t=5)=>e.length<2?"":e.reduce((o,n,r)=>{let i="";return r>0&&r<e.length-1?i=Wg(e[r-1],n,e[r+1],t):i=`${r===0?"M":"L"}${n.x} ${n.y}`,o+=i,o},"");import{useCallback as Ao,useEffect as Br,useRef as fn,useState as Co}from"react";import{useReactFlow as Fg,useStore as Xg}from"@xyflow/react";var Ug=50,hc=.1,$g=.6,zr=({edgeId:e,source:t,target:o,instanceId:n,isReadOnly:r})=>{let{setEdges:i,getNode:a,getNodes:s,getEdge:l,screenToFlowPosition:c}=Fg(),{setIsDragging:d,setReconnectingEdgeId:u}=ee(),f=Xg(P=>P.isValidConnection),[p,h]=Co(null),[y,m]=Co(null),[x,T]=Co(null),[E,N]=Co(null),[b,g]=Co(null),[w,A]=Co(!1),I=fn(null),D=fn(null),S=fn(null),L=fn(t),z=fn(o);Br(()=>{L.current=t,z.current=o},[t,o]),Br(()=>{I.current=p},[p]),Br(()=>{D.current=b},[b]);let q=Ao(P=>{let C=s(),F=C.find(G=>G.id===P);if(!F)return{x:0,y:0};let R=F.position.x,H=F.position.y,k=F.parentId;for(;k;){let G=C.find(B=>B.id===k);if(!G)break;R+=G.position.x,H+=G.position.y,k=G.parentId}return{x:R,y:H}},[s]),Q=Ao(P=>{var k,G,B,K,W,X;let C=s(),F=null,R=Ug,H=C.filter(Z=>Z.type!=="LANE"&&Z.type!=="ANNOTATION");for(let Z of H){if(Z.id===e)continue;let j=q(Z.id),Y=(B=(G=(k=Z.measured)==null?void 0:k.width)!=null?G:Z.width)!=null?B:0,te=(X=(W=(K=Z.measured)==null?void 0:K.height)!=null?W:Z.height)!=null?X:0;if(P.x>=j.x&&P.x<=j.x+Y&&P.y>=j.y&&P.y<=j.y+te)return Z.id;let J=Math.max(j.x-P.x,0,P.x-(j.x+Y)),le=Math.max(j.y-P.y,0,P.y-(j.y+te)),de=Math.sqrt(J*J+le*le);de<R&&(R=de,F=Z.id)}return F},[s,q,e]),U=Ao((P,C)=>{var J,le,de,ue,xe,ge;let F=a(P);if(!F)return null;let R=q(P),H=(de=(le=(J=F.measured)==null?void 0:J.width)!=null?le:F.width)!=null?de:0,k=(ge=(xe=(ue=F.measured)==null?void 0:ue.height)!=null?xe:F.height)!=null?ge:0,G=Math.abs(R.x+H-C.x),B=Math.abs(C.x-R.x),K=Math.abs(R.y+k-C.y),W=Math.abs(C.y-R.y),X={right:G,left:B,bottom:K,top:W},Z=Object.entries(X).reduce((fe,[ce,we])=>we<fe[1]?[ce,we]:fe,["right",X.right])[0],j=S.current;if(j&&j!==Z){let fe=X[Z],ce=X[j],we=Math.abs(ce-fe),Oe=Math.min(Math.abs(ce),Math.abs(fe));we<Oe*$g&&(Z=j)}let Y=Z,te,ne;if(Y==="right"||Y==="left"){let ce=(Math.max(R.y,Math.min(R.y+k,C.y))-R.y)/(k||1);Math.abs(ce-.5)<hc&&(ce=.5),ne=ce,te={x:Y==="right"?R.x+H:R.x,y:R.y+ne*k}}else{let ce=(Math.max(R.x,Math.min(R.x+H,C.x))-R.x)/(H||1);Math.abs(ce-.5)<hc&&(ce=.5),ne=ce,te={x:R.x+ne*H,y:Y==="bottom"?R.y+k:R.y}}return{side:Y,snapPosition:te,offset:ne}},[a,q]),$=Ao(P=>{var B,K,W;let C=I.current;if(!C)return;let F=c({x:P.clientX,y:P.clientY}),R=Q(F);T(R);let H=F,k=null,G=null;if(R){let X=U(R,F);X&&(k=X.side,H=X.snapPosition,G=X.offset,S.current=k);let Z=l(e),j={source:C==="source"?R:L.current,target:C==="target"?R:z.current,sourceHandle:C==="source"?k:(B=Z==null?void 0:Z.sourceHandle)!=null?B:null,targetHandle:C==="target"?k:(K=Z==null?void 0:Z.targetHandle)!=null?K:null},Y=(W=f==null?void 0:f(j))!=null?W:!0;A(Y)}else S.current=null,A(!1);N(k),g(G),m(H)},[Q,U,l,e,c,f]),M=Ao(P=>{var k,G,B,K,W;let C=I.current;if(!C)return;let F=c({x:P.clientX,y:P.clientY}),R=Q(F);if(R){let X=U(R,F),Z=(k=X==null?void 0:X.side)!=null?k:null,j=(G=X==null?void 0:X.offset)!=null?G:.5,Y=l(e),te={source:C==="source"?R:L.current,target:C==="target"?R:z.current,sourceHandle:C==="source"?Z:(B=Y==null?void 0:Y.sourceHandle)!=null?B:null,targetHandle:C==="target"?Z:(K=Y==null?void 0:Y.targetHandle)!=null?K:null};((W=f==null?void 0:f(te))==null||W)&&i(ne=>ne.map(J=>{var le,de;return J.id===e?v(_({},J),{source:te.source,target:te.target,sourceHandle:te.sourceHandle,targetHandle:te.targetHandle,data:v(_({},J.data),{points:void 0,sourceOffset:C==="source"?j:(le=J.data)==null?void 0:le.sourceOffset,targetOffset:C==="target"?j:(de=J.data)==null?void 0:de.targetOffset})}):J}))}h(null),m(null),T(null),N(null),g(null),d(!1),A(!1),u(null),S.current=null,document.removeEventListener("mouseup",M),document.removeEventListener("mousemove",$);let H=dt.get(n);H==null||H.clearReconnectingEdge()},[e,Q,U,l,i,n,$,f,c,d,u]),O=Ao((P,C)=>{if(r||C.button!==0)return;C.stopPropagation(),C.preventDefault(),i(R=>R.map(H=>H.id===e?v(_({},H),{data:v(_({},H.data),{points:void 0})}):H)),h(P),u(e);let F=dt.get(n);F==null||F.setReconnectingEdge(e),document.addEventListener("mousemove",$),document.addEventListener("mouseup",M)},[r,e,n,$,M,u,i]);return Br(()=>()=>{if(I.current){document.removeEventListener("mousemove",$),document.removeEventListener("mouseup",M),u(null);let P=dt.get(n);P==null||P.clearReconnectingEdge()}},[n,$,M,u]),{reconnectingHandle:p,cursorPosition:y,hoveredNodeId:x,reconnectingSide:E,reconnectingOffset:b,isValidReconnection:w,handleReconnectStart:O}};import{Fragment as Tc,jsx as Ce,jsxs as yt}from"react/jsx-runtime";var qe={type:"SEQUENCE_EDGE",reconnectable:!0,markerStart:{type:Ec.ArrowClosed},markerEnd:{type:Ec.Arrow},data:{label:""}},{MOVE_THRESHOLD:Yr,MIN_SEGMENT_LENGTH:th,PARALLEL_OFFSET:_c}=Lt;function oh(e,t,o,n){let r=n.filter(s=>s.source===t&&s.target===o||s.source===o&&s.target===t);if(r.length<=1){let s=n.filter(d=>d.source===t);if(s.length<=1)return 0;let l=s.findIndex(d=>d.id===e);if(l<=0)return 0;let c=(s.length-1)/2;return(l-c)*_c}let i=r.findIndex(s=>s.id===e),a=(r.length-1)/2;return(i-a)*_c}var Nc=({id:e,source:t,target:o,data:n,selected:r,sourcePosition:i,targetPosition:a,sourceHandleId:s,targetHandleId:l})=>{var k,G;let{zoom:c}=jg(),{updateEdgeData:d}=Qg(),u=eh(),{isMultipleSelection:f,mode:p,instanceId:h}=ee(),[y,m]=yc(!1),[x,T]=yc(null),E=xc(null),N=xc(null),b=p!=="edit",{reconnectingHandle:g,cursorPosition:w,hoveredNodeId:A,reconnectingSide:I,isValidReconnection:D,handleReconnectStart:S}=zr({edgeId:e,source:t,target:o,instanceId:h,isReadOnly:b}),L=bc(t),z=bc(o),{sx:q,sy:Q,tx:U,ty:$,sourcePos:M,targetPos:O}=es(()=>{var le,de;let B=L&&z?go(L,z):{sx:0,sy:0,tx:0,ty:0,sourcePos:So.Right,targetPos:So.Left},K=s?i:B.sourcePos,W=l?a:B.targetPos,X=(ue,xe,ge)=>{var it,pt,zt,Yt,In,Te;let{x:fe,y:ce}=ue.internals.positionAbsolute,we=(zt=(pt=(it=ue.measured)==null?void 0:it.width)!=null?pt:ue.width)!=null?zt:0,Oe=(Te=(In=(Yt=ue.measured)==null?void 0:Yt.height)!=null?In:ue.height)!=null?Te:0;switch(xe){case So.Top:return{x:fe+we*ge,y:ce};case So.Bottom:return{x:fe+we*ge,y:ce+Oe};case So.Left:return{x:fe,y:ce+Oe*ge};case So.Right:return{x:fe+we,y:ce+Oe*ge};default:return{x:fe+we/2,y:ce+Oe/2}}},Z=(le=n==null?void 0:n.sourceOffset)!=null?le:.5,j=(de=n==null?void 0:n.targetOffset)!=null?de:.5,Y=L?X(L,K,Z).x:B.sx,te=L?X(L,K,Z).y:B.sy,ne=z?X(z,W,j).x:B.tx,J=z?X(z,W,j).y:B.ty;return g==="source"&&w?(Y=w.x,te=w.y,I&&(K=I)):g==="target"&&w&&(ne=w.x,J=w.y,I&&(W=I)),{sx:Y,sy:te,tx:ne,ty:J,sourcePos:K,targetPos:W}},[L,z,s,l,i,a,g,w,I,n==null?void 0:n.sourceOffset,n==null?void 0:n.targetOffset]);qg(()=>{var W;if(!N.current){N.current={sx:q,sy:Q,tx:U,ty:$,sourcePos:M,targetPos:O};return}let B=N.current;(Math.abs(q-B.sx)>Yr||Math.abs(Q-B.sy)>Yr||Math.abs(U-B.tx)>Yr||Math.abs($-B.ty)>Yr||B.sourcePos!==M||B.targetPos!==O)&&((W=n==null?void 0:n.points)!=null&&W.length)&&d(e,v(_({},n),{points:void 0})),N.current={sx:q,sy:Q,tx:U,ty:$,sourcePos:M,targetPos:O}},[q,Q,U,$,M,O,n,e,d,g]);let P=es(()=>{let B=oh(e,t,o,u);return Gr(q,Q,U,$,M,O,n==null?void 0:n.points,B)},[q,Q,U,$,M,O,n==null?void 0:n.points,u,e,t,o]),C=es(()=>{if(P.length<2)return Rr({x:q,y:Q},{x:U,y:$});let B=0;for(let X=0;X<P.length-1;X++)B+=kr(P[X],P[X+1]);let K=B/2,W=0;for(let X=0;X<P.length-1;X++){let Z=kr(P[X],P[X+1]);if(W+Z>=K){let j=(K-W)/Z,Y=P[X],te=P[X+1];return{x:Y.x+(te.x-Y.x)*j,y:Y.y+(te.y-Y.y)*j}}W+=Z}return Rr({x:q,y:Q},{x:U,y:$})},[P,q,Q,U,$]),F=Kg((B,K)=>{if(p!=="edit"||K.button!==0)return;K.stopPropagation(),K.preventDefault();let W=P[B],X=P[B+1],Z=pe(W,X,"y"),j=Z?W.y:W.x,Y=[...P],te=Y.length,ne=B,J=B+1;T(B);let le=ue=>{let xe=j+(Z?ue.clientY-K.clientY:ue.clientX-K.clientX)/c;E.current=Z?{x:(W.x+X.x)/2,y:xe}:{x:xe,y:(W.y+X.y)/2};let ge=[];for(let fe=1;fe<te-1;fe++){let ce=Y[fe];fe===ne||fe===J?Z?ge.push({x:ce.x,y:xe}):ge.push({x:xe,y:ce.y}):ge.push(_({},ce))}d(e,v(_({},n),{points:ge}))},de=()=>{T(null),E.current=null,document.removeEventListener("mousemove",le),document.removeEventListener("mouseup",de)};document.addEventListener("mousemove",le),document.addEventListener("mouseup",de)},[p,P,c,n,e,d]);if(!L||!z)return null;let R=gc(P),H=r||L.selected||z.selected;return yt(Tc,{children:[yt("g",{className:V("group bpmn-arrow-edge",{"is-highlighted":H}),onDoubleClick:()=>m(!0),children:[Ce("path",{d:R,fill:"none",stroke:"transparent",strokeWidth:Math.max(12,12/c),style:{pointerEvents:"stroke",cursor:"pointer"}}),yt("g",{className:V("text-grey-500 transition-colors duration-75 group-hover:text-grey-800",{"text-blue-500 group-hover:text-blue-600":H}),children:[Ce(Zg,{id:e,path:R,interactionWidth:0,markerEnd:`url(#${H?"sequence-edge-marker-highlighted":"sequence-edge-marker"})`,className:V("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)||g&&A&&!D,"stroke-green-500":g&&A&&D,"stroke-blue-500 hover:stroke-blue-600 drop-shadow-[0_0_3px_rgba(59,130,246,0.5)]":H&&!(n!=null&&n.hasError)&&!g})}),r&&!f&&!b&&Ce("g",{children:P.slice(0,-1).map((B,K)=>{let W=P[K+1];if(K===0||K===P.length-2||kr(B,W)<th)return null;let X=pe(B,W,"y"),Z=x===K,j=Z&&E.current?E.current:Rr(B,W);return yt("g",{children:[Ce("line",{x1:B.x,y1:B.y,x2:W.x,y2:W.y,stroke:"transparent",strokeWidth:20/c,className:V("cursor-pointer",{"cursor-ns-resize":X,"cursor-ew-resize":!X}),onMouseDown:Y=>F(K,Y)}),Ce("circle",{cx:j.x,cy:j.y,r:4/c,fill:Z?"#3b82f6":"#fff",stroke:"#3b82f6",strokeWidth:2/c,className:"pointer-events-none"}),Ce("circle",{cx:j.x,cy:j.y,r:6/c,fill:"none",stroke:"#3b82f6",strokeWidth:1/c,opacity:Z?.6:.3,className:"pointer-events-none"})]},K)})})]})]}),yt(Jg,{children:[yt("div",{className:"absolute z-[3000] pointer-events-none flex flex-col items-center gap-1",style:{transform:`translate(-50%, -50%) translate(${C.x}px, ${C.y}px)`},children:[r&&!f&&Ce(wo,{sx:q,sy:Q,tx:U,ty:$,hasLabel:!!((k=n==null?void 0:n.label)!=null&&k.trim()),children:Ce(vo,{edgeId:e,edgeType:"SEQUENCE_EDGE",sourceNode:L,targetNode:z})}),(y||((G=n==null?void 0:n.label)==null?void 0:G.trim()))&&Ce(Pe,{value:n==null?void 0:n.label,className:V("min-w-8 max-w-56 px-2 py-1 body-small-400",{"pointer-events-auto":y,"pointer-events-none":!y}),isEditing:y,onBlur:()=>m(!1),onChange:B=>d(e,{label:B.trim()})})]}),r&&!f&&!b&&yt(Tc,{children:[Ce("div",{className:"absolute z-[10000] pointer-events-none",style:{transform:`translate(-50%, -50%) translate(${P[0].x}px, ${P[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:g==="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:g==="source"?.6:.3,className:"pointer-events-none"}),Ce("circle",{cx:6/c,cy:6/c,r:8/c,fill:"transparent",className:V("pointer-events-auto",{"cursor-move":!g||g!=="source","cursor-not-allowed":g==="source"&&A&&!D,"cursor-grabbing":g==="source"&&(!A||D)}),onMouseDown:B=>S("source",B.nativeEvent)})]})}),Ce("div",{className:"absolute z-[10000] pointer-events-none",style:{transform:`translate(-50%, -50%) translate(${P[P.length-1].x}px, ${P[P.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:g==="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:g==="target"?.6:.3,className:"pointer-events-none"}),Ce("circle",{cx:6/c,cy:6/c,r:8/c,fill:"transparent",className:V("pointer-events-auto",{"cursor-move":!g||g!=="target","cursor-not-allowed":g==="target"&&A&&!D,"cursor-grabbing":g==="target"&&(!A||D)}),onMouseDown:B=>S("target",B.nativeEvent)})]})})]})]})]})};import{Position as xt}from"@xyflow/react";var nh={right:xt.Right,left:xt.Left,top:xt.Top,bottom:xt.Bottom},Wr=e=>{var t;return(t=nh[e!=null?e:""])!=null?t:xt.Right},ts=(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(Wr(t)){case xt.Right:return{x:n+i,y:r+a*o};case xt.Left:return{x:n,y:r+a*o};case xt.Top:return{x:n+i*o,y:r};case xt.Bottom:return{x:n+i*o,y:r+a};default:return{x:n+i/2,y:r+a/2}}},vc=(e,t,o)=>{var d,u;let{position:{x:n,y:r},measured:i}=e,a=(d=i.width)!=null?d:0,s=(u=i.height)!=null?u:0;return[{id:"left",x:n,y:r+s/2},{id:"right",x:n+a,y:r+s/2},{id:"top",x:n+a/2,y:r},{id:"bottom",x:n+a/2,y:r+s}].reduce((f,p)=>{let h=Math.hypot(t-f.x,o-f.y);return Math.hypot(t-p.x,o-p.y)<h?p:f}).id};import{useDebouncedCallback as Xy}from"use-debounce";import{getViewportForBounds as Yy,useReactFlow as Wy,useStoreApi as Fy}from"@xyflow/react";import{useCallback as Hd}from"react";var mn=(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))(mn||{});import{xml2json as rh,json2xml as ih}from"xml-js";var wc={compact:!0,spaces:4},sh=e=>e.replace(/\n/g,"&#xA;");function Fr(e,t=wc){if(e)return JSON.parse(rh(e,t))}function Ic(e,t=wc){return e?ih(e,v(_({},t),{attributeValueFn:sh})):""}var Ac={"attribute-loop":"LOOP"},Cc={"task-script":"SCRIPT","subprocess-collapsed":"SUBPROCESS"},Sc={"gateway-exclusive":"EXCLUSIVE","gateway-parallel":"PARALLEL","gateway-complex":"COMPLEX"},Mc={SCRIPT:"task-script",SUBPROCESS:"subprocess-collapsed"},Pc={EXCLUSIVE:"gateway-exclusive",PARALLEL:"gateway-parallel",COMPLEX:"gateway-complex"};var Mo=(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 h=n.split(`
6
- `),y=h.length;l=h.reduce((x,T)=>Math.max(x,T.length),0)*7+r,c=y*20+i}let d=Math.max(vt(Number(a),t),l),u=Math.max(vt(Number(s),o),c);return{width:d,height:u,measured:{width:d,height:u}}},Po=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},lh=e=>{let{mxGeometry:t}=e,o=Po(e),n=Mo(t,ae.START_EVENT.MIN_WIDTH,ae.START_EVENT.MIN_HEIGHT);return v(_(_({},o),n),{type:"START_EVENT"})},ch=e=>{let{mxGeometry:t}=e,o=Po(e),n=Mo(t,ae.END_EVENT.MIN_WIDTH,ae.END_EVENT.MIN_HEIGHT);return v(_(_({},o),n),{type:"END_EVENT"})},os=(e,t)=>{let{_attributes:o,mxGeometry:n}=e,r=Po(e),s=Mo(n,ae.TASK.MIN_WIDTH,ae.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=Ac[d];u&&(r.data.attribute=u)}let c=Cc[o.style];return c&&(r.data.variant=c),v(_(_({},r),s),{type:"TASK"})},ns=e=>{let{_attributes:t,mxGeometry:o}=e,{style:n}=t,r=Po(e),i=Mo(o,ae.GATEWAY.MIN_WIDTH,ae.GATEWAY.MIN_HEIGHT);return r.data.variant=Sc[n],v(_(_({},r),i),{type:"GATEWAY"})},dh=e=>{let{mxGeometry:t}=e,o=Po(e),i=Mo(t,ae.ANNOTATION.MIN_WIDTH,ae.ANNOTATION.MIN_HEIGHT,o.data.label,32,24);return v(_(_({},o),i),{type:"ANNOTATION"})},uh=e=>{let{mxGeometry:t}=e,o=Po(e),n=Mo(t,ae.LANE.MIN_WIDTH,ae.LANE.MIN_HEIGHT);return v(_(_({},o),n),{type:"LANE"})},Lc={task:os,"task-script":os,"subprocess-collapsed":os,"start-event":lh,"end-event-terminate":ch,"gateway-parallel":ns,"gateway-exclusive":ns,"gateway-complex":ns,annotation:dh,lane:uh},ph=e=>{if(e&&Array.isArray(e))return e.map(t=>({x:Number(t._attributes.x),y:Number(t._attributes.y)}))},kc=e=>{let{_attributes:t,mxGeometry:o}=e,{id:n,source:r,target:i,value:a,style:s,sourceHandle:l,targetHandle:c,sourceOffset:d,targetOffset:u}=t,f=ph(o==null?void 0:o.Array),p=d!==void 0?Number(d):void 0,h=u!==void 0?Number(u):void 0,y=v(_(_({id:n,source:r,target:i},l?{sourceHandle:l}:{}),c?{targetHandle:c}:{}),{data:_(_(_({label:a||""},f&&f.length>0?{points:f}:{}),p!==void 0?{sourceOffset:p}:{}),h!==void 0?{targetOffset:h}:{})});return s.includes("association")&&s.includes('endArrow=""')?_(_({},Io),y):_(_({},qe),y)},Rc=(e,t)=>{let{id:o,type:n,source:r,target:i,sourceHandle:a,targetHandle:s,data:l}=e,c=t==null?void 0:t.find(p=>p.id===r),d="";n==="ANNOTATION_EDGE"&&(d='association;endArrow=""');let u={_attributes:{as:"geometry",relative:"1"}};return l!=null&&l.points&&Array.isArray(l.points)&&l.points.length>0&&(u.Array=l.points.map(p=>({_attributes:{as:"mxPoint",x:p.x,y:p.y}}))),{_attributes:{id:o,parent:(c==null?void 0:c.parentId)||"1",edge:"1",style:d,source:r,target:i,value:(l==null?void 0:l.label)||"",sourceHandle:a!=null?a:void 0,targetHandle:s!=null?s:void 0,sourceOffset:(l==null?void 0:l.sourceOffset)!==void 0?String(l.sourceOffset):void 0,targetOffset:(l==null?void 0:l.targetOffset)!==void 0?String(l.targetOffset):void 0},mxGeometry:u}},Lo=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}}}},fh=e=>{let{variant:t}=e.data,o=Lo(e);return v(_({},o),{_attributes:v(_({},o._attributes),{style:Mc[t]||"task"})})},mh=e=>{let t=Lo(e);return v(_({},t),{_attributes:v(_({},t._attributes),{style:"start-event"})})},gh=e=>{let t=Lo(e);return v(_({},t),{_attributes:v(_({},t._attributes),{style:"end-event-terminate"})})},hh=e=>{let{variant:t}=e.data,o=Lo(e);return v(_({},o),{_attributes:v(_({},o._attributes),{style:Pc[t]})})},yh=e=>{let t=Lo(e);return v(_({},t),{_attributes:v(_({},t._attributes),{style:"lane"})})},xh=e=>{let t=Lo(e);return v(_({},t),{_attributes:v(_({},t._attributes),{style:"annotation"})})},Dc={TASK:fh,START_EVENT:mh,END_EVENT:gh,GATEWAY:hh,ANNOTATION:xh,LANE:yh},Oc=(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 Hc from"@dagrejs/dagre";import{getNodesBounds as xA}from"@xyflow/react";var Vc=(e=[],t=[],o="LR")=>{let n=new Hc.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)),Hc.layout(n),{nodes:e.map(i=>{let a=n.node(i.id);return v(_({},i),{position:{x:a.x-i.width/2,y:a.y-i.height/2}})}),edges:t}},Et=e=>{let t=e.filter(n=>n.type==="LANE"&&!n.parentId);if(t.length===0)return e;let o=$s(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){js(a,o,r),ea(n,o);continue}Li(n,i,o)}return Ks(e,o)},Gc=Et,Bc=()=>{let e=document.querySelector(".react-flow__viewport");return e||(console.error("Flow element (.react-flow__viewport) not found."),null)};var Eh=e=>e.type==="LANE"&&!e.parentId,rs=e=>{var i;let t=e.filter(Eh);if(t.length===0)return e;let o=new Map;for(let a of e){if(!a.parentId)continue;let s=(i=o.get(a.parentId))!=null?i:[];s.push(a.id),o.set(a.parentId,s)}let n=new Set,r=t.map(a=>a.id);for(;r.length>0;){let a=r.pop();if(!a||n.has(a))continue;n.add(a);let s=o.get(a);if(s)for(let l of s)n.has(l)||r.push(l)}return e.filter(a=>n.has(a.id))};var gn=1,zc=e=>`<mxGraphModel>
5
+ `).trim();t&&x.length>t&&(x=x.substring(0,t)),b.currentTarget.innerText=x,s==null||s(),x!==e&&(a==null||a(x))};return yc("div",{className:G("flex-1 p-2 self-stretch flex items-center justify-center border border-transparent overflow-hidden text-ellipsis body-medium-400 text-center rounded-sm",{"border border-dashed border-grey-400 bg-white shadow-md":p,"bg-white":e.length>0},n),style:o,onDoubleClick:f,children:yc("div",{ref:u,className:G("outline-none whitespace-pre-wrap overflow-hidden",r,{"nodrag nopan cursor-text":p}),contentEditable:p,suppressContentEditableWarning:!0,onKeyDown:y,onPaste:N,onInput:E,onBlur:T,children:e})})};import{Position as II}from"@xyflow/react";var me=(e,t,o,n=1)=>Math.abs(e[o]-t[o])<n,Po=(e,t)=>Math.sqrt((t.x-e.x)**2+(t.y-e.y)**2),Or=(e,t)=>({x:(e.x+t.x)/2,y:(e.y+t.y)/2}),zg=(e,t,o)=>{let n=o.x-t.x,r=o.y-t.y,i=n*n+r*r;if(i===0)return Po(e,t);let a=Math.max(0,Math.min(1,((e.x-t.x)*n+(e.y-t.y)*r)/i));return Po(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,zg(e,t[n],t[n+1]));return o};import{Position as Hr}from"@xyflow/react";var Bt={OFFSET:30,TOLERANCE:1,MOVE_THRESHOLD:5,MIN_SEGMENT_LENGTH:15,PARALLEL_OFFSET:15,MAX_LABEL_DISTANCE:80};var{TOLERANCE:de}=Bt;function Yg(e,t,o){return me(e,t,"x",de)&&me(t,o,"x",de)&&me(e,o,"x",de)}function Wg(e,t,o){return me(e,t,"y",de)&&me(t,o,"y",de)&&me(e,o,"y",de)}function Fg(e,t,o){if(!Yg(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 Xg(e,t,o){if(!Wg(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 Ug(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 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];me(n,r,"x",de)&&me(r,i,"x",de)||me(n,r,"y",de)&&me(r,i,"y",de)||t.push(r)}return t.push(e[e.length-1]),t}function Vr(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 $g(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(Fg(r,i,a)||Xg(r,i,a)){t.splice(n,1),o=!0;break}}}return t}function bc(e){let t=Vr(Ec([...e]));return t=$g(t),Vr(Ec(t))}function Gr(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=Bt.OFFSET,i=Bt.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*Bt.OFFSET&&(r=a/2,i=a/2)}else{let a=(o.y-e.y)*t.y;a>0&&a<2*Bt.OFFSET&&(r=a/2,i=a/2)}return{sourceOffset:r,targetOffset:i}}function Kg(e,t,o,n,r,i,a=0){let s=Gr(r),l=Gr(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,p={x:e+c,y:t+d},g={x:o+u,y:n+m},{sourceOffset:h,targetOffset:f}=_c(p,s,g,l),y={x:p.x+s.x*h,y:p.y+s.y*h},N={x:g.x+l.x*f,y:g.y+l.y*f},E=Ug(y,s,N,l),T=[p,y,...E,N,g],b=bc(T);if(b.length===2&&Br(p,g)>de){let x=me(p,y,"x",de)&&me(y,N,"x",de)&&me(N,g,"x",de),w=me(p,y,"y",de)&&me(y,N,"y",de)&&me(N,g,"y",de);if(x||w){let A=w&&(N.x-y.x)*s.x<0,I=x&&(N.y-y.y)*s.y<0;if(!A&&!I)return Vr([p,y,N,g])}}return b}function zr(e,t,o,n,r,i,a,s=0){if(!(a!=null&&a.length))return Kg(e,t,o,n,r,i,s);let l=Gr(r),c=Gr(i),d=l.x===0?s:0,u=l.y===0?s:0,m=c.x===0?s:0,p=c.y===0?s:0,g={x:e+d,y:t+u},h={x:o+m,y:n+p},{sourceOffset:f,targetOffset:y}=_c(g,l,h,c),N={x:g.x+l.x*f,y:g.y+l.y*f},E={x:h.x+c.x*y,y:h.y+c.y*y},T=[...a],b=T[0],x=l.y===0;x&&Math.abs(g.y-b.y)>de?T.unshift({x:b.x,y:g.y}):!x&&Math.abs(g.x-b.x)>de&&T.unshift({x:g.x,y:b.y});let w=T[T.length-1],A=c.y===0,I=[];(Math.abs(w.x-E.x)>de||Math.abs(w.y-E.y)>de)&&(A?I.push({x:E.x,y:w.y}):I.push({x:w.x,y:E.y})),I.push(E);let D=[g,...T,...I,h],S=bc(D);if(S.length===2&&Br(g,h)>de){let L=me(g,N,"x",de)&&me(N,E,"x",de)&&me(E,h,"x",de),z=me(g,N,"y",de)&&me(N,E,"y",de)&&me(E,h,"y",de);if(L||z){let U=z&&(E.x-N.x)*l.x<0,K=L&&(E.y-N.y)*l.y<0;if(!U&&!K)return Vr([g,N,E,h])}}return S}var Br=(e,t)=>Math.sqrt(Math.pow(t.x-e.x,2)+Math.pow(t.y-e.y,2));function qg(e,t,o){return me(e,t,"x",de)&&me(t,o,"x",de)||me(e,t,"y",de)&&me(t,o,"y",de)}function Zg(e,t,o,n){if(qg(e,t,o))return`L${t.x} ${t.y}`;let r=Br(e,t),i=Br(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},p={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},h=-u.x,f=-u.y,y=m.x,N=m.y,T=h*N-f*y>0?1:0;return`L${p.x} ${p.y}A${a} ${a} 0 0 ${T} ${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=Zg(e[r-1],n,e[r+1],t):i=`${r===0?"M":"L"}${n.x} ${n.y}`,o+=i,o},"");import{useCallback as Lo,useEffect as Yr,useRef as xn,useState as ko}from"react";import{useReactFlow as Jg,useStore as Qg}from"@xyflow/react";var jg=50,Tc=.1,eh=.6,Wr=({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:u}=J(),m=Qg(H=>H.isValidConnection),[p,g]=ko(null),[h,f]=ko(null),[y,N]=ko(null),[E,T]=ko(null),[b,x]=ko(null),[w,A]=ko(!1),I=xn(null),D=xn(null),S=xn(null),L=xn(t),z=xn(o);Yr(()=>{L.current=t,z.current=o},[t,o]),Yr(()=>{I.current=p},[p]),Yr(()=>{D.current=b},[b]);let U=Lo(H=>{let C=s(),k=C.find(B=>B.id===H);if(!k)return{x:0,y:0};let P=k.position.x,R=k.position.y,V=k.parentId;for(;V;){let B=C.find(ee=>ee.id===V);if(!B)break;P+=B.position.x,R+=B.position.y,V=B.parentId}return{x:P,y:R}},[s]),K=Lo(H=>{var V,B,ee,oe,q,Z;let C=s(),k=null,P=jg,R=C.filter(Q=>Q.type!=="LANE"&&Q.type!=="ANNOTATION");for(let Q of R){if(Q.id===e)continue;let se=U(Q.id),W=(ee=(B=(V=Q.measured)==null?void 0:V.width)!=null?B:Q.width)!=null?ee:0,ne=(Z=(q=(oe=Q.measured)==null?void 0:oe.height)!=null?q:Q.height)!=null?Z:0;if(H.x>=se.x&&H.x<=se.x+W&&H.y>=se.y&&H.y<=se.y+ne)return Q.id;let $=Math.max(se.x-H.x,0,H.x-(se.x+W)),he=Math.max(se.y-H.y,0,H.y-(se.y+ne)),fe=Math.sqrt($*$+he*he);fe<P&&(P=fe,k=Q.id)}return k},[s,U,e]),Y=Lo((H,C)=>{var $,he,fe,F,ue,ce;let k=a(H);if(!k)return null;let P=U(H),R=(fe=(he=($=k.measured)==null?void 0:$.width)!=null?he:k.width)!=null?fe:0,V=(ce=(ue=(F=k.measured)==null?void 0:F.height)!=null?ue:k.height)!=null?ce:0,B=Math.abs(P.x+R-C.x),ee=Math.abs(C.x-P.x),oe=Math.abs(P.y+V-C.y),q=Math.abs(C.y-P.y),Z={right:B,left:ee,bottom:oe,top:q},Q=Object.entries(Z).reduce((j,[le,ye])=>ye<j[1]?[le,ye]:j,["right",Z.right])[0],se=S.current;if(se&&se!==Q){let j=Z[Q],le=Z[se],ye=Math.abs(le-j),Ne=Math.min(Math.abs(le),Math.abs(j));ye<Ne*eh&&(Q=se)}let W=Q,ne,ae;if(W==="right"||W==="left"){let le=(Math.max(P.y,Math.min(P.y+V,C.y))-P.y)/(V||1);Math.abs(le-.5)<Tc&&(le=.5),ae=le,ne={x:W==="right"?P.x+R:P.x,y:P.y+ae*V}}else{let le=(Math.max(P.x,Math.min(P.x+R,C.x))-P.x)/(R||1);Math.abs(le-.5)<Tc&&(le=.5),ae=le,ne={x:P.x+ae*R,y:W==="bottom"?P.y+V:P.y}}return{side:W,snapPosition:ne,offset:ae}},[a,U]),X=Lo(H=>{var ee,oe,q;let C=I.current;if(!C)return;let k=c({x:H.clientX,y:H.clientY}),P=K(k);N(P);let R=k,V=null,B=null;if(P){let Z=Y(P,k);Z&&(V=Z.side,R=Z.snapPosition,B=Z.offset,S.current=V);let Q=l(e),se={source:C==="source"?P:L.current,target:C==="target"?P:z.current,sourceHandle:C==="source"?V:(ee=Q==null?void 0:Q.sourceHandle)!=null?ee:null,targetHandle:C==="target"?V:(oe=Q==null?void 0:Q.targetHandle)!=null?oe:null},W=(q=m==null?void 0:m(se))!=null?q:!0;A(W)}else S.current=null,A(!1);T(V),x(B),f(R)},[K,Y,l,e,c,m]),M=Lo(H=>{var V,B,ee,oe,q;let C=I.current;if(!C)return;let k=c({x:H.clientX,y:H.clientY}),P=K(k);if(P){let Z=Y(P,k),Q=(V=Z==null?void 0:Z.side)!=null?V:null,se=(B=Z==null?void 0:Z.offset)!=null?B:.5,W=l(e),ne={source:C==="source"?P:L.current,target:C==="target"?P:z.current,sourceHandle:C==="source"?Q:(ee=W==null?void 0:W.sourceHandle)!=null?ee:null,targetHandle:C==="target"?Q:(oe=W==null?void 0:W.targetHandle)!=null?oe:null};((q=m==null?void 0:m(ne))==null||q)&&i(ae=>ae.map($=>{var he,fe;return $.id===e?v(_({},$),{source:ne.source,target:ne.target,sourceHandle:ne.sourceHandle,targetHandle:ne.targetHandle,data:v(_({},$.data),{points:void 0,sourceOffset:C==="source"?se:(he=$.data)==null?void 0:he.sourceOffset,targetOffset:C==="target"?se:(fe=$.data)==null?void 0:fe.targetOffset})}):$}))}g(null),f(null),N(null),T(null),x(null),d(!1),A(!1),u(null),S.current=null,document.removeEventListener("mouseup",M),document.removeEventListener("mousemove",X);let R=xt.get(n);R==null||R.clearReconnectingEdge()},[e,K,Y,l,i,n,X,m,c,d,u]),O=Lo((H,C)=>{if(r||C.button!==0)return;C.stopPropagation(),C.preventDefault(),i(P=>P.map(R=>R.id===e?v(_({},R),{data:v(_({},R.data),{points:void 0})}):R)),g(H),u(e);let k=xt.get(n);k==null||k.setReconnectingEdge(e),document.addEventListener("mousemove",X),document.addEventListener("mouseup",M)},[r,e,n,X,M,u,i]);return Yr(()=>()=>{if(I.current){document.removeEventListener("mousemove",X),document.removeEventListener("mouseup",M),u(null);let H=xt.get(n);H==null||H.clearReconnectingEdge()}},[n,X,M,u]),{reconnectingHandle:p,cursorPosition:h,hoveredNodeId:y,reconnectingSide:E,reconnectingOffset:b,isValidReconnection:w,handleReconnectStart:O}};import{Fragment as Sc,jsx as Se,jsxs as zt}from"react/jsx-runtime";var ot={type:"SEQUENCE_EDGE",reconnectable:!0,markerStart:{type:Ic.ArrowClosed},markerEnd:{type:Ic.Arrow},data:{label:""}},{MOVE_THRESHOLD:Fr,MIN_SEGMENT_LENGTH:lh,PARALLEL_OFFSET:Cc,MAX_LABEL_DISTANCE:ch}=Bt;function dh(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(p=>p.source===t);if(d.length<=1)return 0;let u=d.findIndex(p=>p.id===e);if(u<=0)return 0;let m=(d.length-1)/2;return(u-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 oe,q,Z,Q,se,W,ne,ae,$,he,fe;let{zoom:c}=ih(),{updateEdgeData:d}=rh(),u=sh(),m=ah(),{isMultipleSelection:p,mode:g,instanceId:h}=J(),[f,y]=vc(!1),[N,E]=vc(null),T=ts(null),b=ts(n==null?void 0:n.labelOffset),x=ts(null),w=g!=="edit",{reconnectingHandle:A,cursorPosition:I,hoveredNodeId:D,reconnectingSide:S,isValidReconnection:L,handleReconnectStart:z}=Wr({edgeId:e,source:t,target:o,instanceId:h,isReadOnly:w}),U=Ac(t),K=Ac(o),{sx:Y,sy:X,tx:M,ty:O,sourcePos:H,targetPos:C}=es(()=>{var ut,pt;let F=U&&K?bo(U,K):{sx:0,sy:0,tx:0,ty:0,sourcePos:Ro.Right,targetPos:Ro.Left},ue=s?i:F.sourcePos,ce=l?a:F.targetPos,j=(xe,_e,ge)=>{var ft,Pt,bt,_t,Ss,Ms;let{x:Ee,y:we}=xe.internals.positionAbsolute,Ke=(bt=(Pt=(ft=xe.measured)==null?void 0:ft.width)!=null?Pt:xe.width)!=null?bt:0,Ie=(Ms=(Ss=(_t=xe.measured)==null?void 0:_t.height)!=null?Ss:xe.height)!=null?Ms:0;switch(_e){case Ro.Top:return{x:Ee+Ke*ge,y:we};case Ro.Bottom:return{x:Ee+Ke*ge,y:we+Ie};case Ro.Left:return{x:Ee,y:we+Ie*ge};case Ro.Right:return{x:Ee+Ke,y:we+Ie*ge};default:return{x:Ee+Ke/2,y:we+Ie/2}}},le=(ut=n==null?void 0:n.sourceOffset)!=null?ut:.5,ye=(pt=n==null?void 0:n.targetOffset)!=null?pt:.5,Ne=U?j(U,ue,le).x:F.sx,Pe=U?j(U,ue,le).y:F.sy,ze=K?j(K,ce,ye).x:F.tx,je=K?j(K,ce,ye).y:F.ty;return A==="source"&&I?(Ne=I.x,Pe=I.y,S&&(ue=S)):A==="target"&&I&&(ze=I.x,je=I.y,S&&(ce=S)),{sx:Ne,sy:Pe,tx:ze,ty:je,sourcePos:ue,targetPos:ce}},[U,K,s,l,i,a,A,I,S,n==null?void 0:n.sourceOffset,n==null?void 0:n.targetOffset]);th(()=>{var ce;if(!x.current){x.current={sx:Y,sy:X,tx:M,ty:O,sourcePos:H,targetPos:C};return}let F=x.current;if(Math.abs(Y-F.sx)>Fr||Math.abs(X-F.sy)>Fr||Math.abs(M-F.tx)>Fr||Math.abs(O-F.ty)>Fr||F.sourcePos!==H||F.targetPos!==C){let j={};(ce=n==null?void 0:n.points)!=null&&ce.length&&(j.points=void 0),n!=null&&n.labelOffset&&(j.labelOffset=void 0),Object.keys(j).length>0&&d(e,_(_({},n),j))}x.current={sx:Y,sy:X,tx:M,ty:O,sourcePos:H,targetPos:C}},[Y,X,M,O,H,C,n,e,d,A]);let k=es(()=>{let F=dh(e,t,o,u,m);return zr(Y,X,M,O,H,C,n==null?void 0:n.points,F)},[Y,X,M,O,H,C,n==null?void 0:n.points,u,m,e,t,o]),P=es(()=>{if(k.length<2)return Or({x:Y,y:X},{x:M,y:O});let F=0;for(let j=0;j<k.length-1;j++)F+=Po(k[j],k[j+1]);let ue=F/2,ce=0;for(let j=0;j<k.length-1;j++){let le=Po(k[j],k[j+1]);if(ce+le>=ue){let ye=(ue-ce)/le,Ne=k[j],Pe=k[j+1];return{x:Ne.x+(Pe.x-Ne.x)*ye,y:Ne.y+(Pe.y-Ne.y)*ye}}ce+=le}return Or({x:Y,y:X},{x:M,y:O})},[k,Y,X,M,O]),R=wc((F,ue)=>{if(g!=="edit"||ue.button!==0)return;ue.stopPropagation(),ue.preventDefault();let ce=k[F],j=k[F+1],le=me(ce,j,"y"),ye=le?ce.y:ce.x,Ne=[...k],Pe=Ne.length,ze=F,je=F+1;E(F);let ut=xe=>{let _e=ye+(le?xe.clientY-ue.clientY:xe.clientX-ue.clientX)/c;T.current=le?{x:(ce.x+j.x)/2,y:_e}:{x:_e,y:(ce.y+j.y)/2};let ge=[];for(let Ee=1;Ee<Pe-1;Ee++){let we=Ne[Ee];Ee===ze||Ee===je?le?ge.push({x:we.x,y:_e}):ge.push({x:_e,y:we.y}):ge.push(_({},we))}d(e,v(_({},n),{points:ge}))},pt=()=>{E(null),T.current=null,document.removeEventListener("mousemove",ut),document.removeEventListener("mouseup",pt)};document.addEventListener("mousemove",ut),document.addEventListener("mouseup",pt)},[g,k,c,n,e,d]),V=wc(F=>{var ut,pt,xe,_e,ge;if(f||w||F.button!==0||!((ut=n==null?void 0:n.label)!=null&&ut.trim()))return;F.stopPropagation(),F.preventDefault();let ue=F.clientX,ce=F.clientY,j=(xe=(pt=n==null?void 0:n.labelOffset)==null?void 0:pt.x)!=null?xe:0,le=(ge=(_e=n==null?void 0:n.labelOffset)==null?void 0:_e.y)!=null?ge:0,ye=[...k],Ne={x:P.x,y:P.y},Pe=!1,ze=Ee=>{let we=(Ee.clientX-ue)/c,Ke=(Ee.clientY-ce)/c;if(!Pe&&Math.abs(we)<3&&Math.abs(Ke)<3)return;Pe=!0;let Ie={x:j+we,y:le+Ke};b.current=Ie,d(e,v(_({},n),{labelOffset:Ie}))},je=()=>{document.removeEventListener("mousemove",ze),document.removeEventListener("mouseup",je);let Ee=b.current;if(!Ee)return;let we={x:Ne.x+Ee.x,y:Ne.y+Ee.y};xc(we,ye)>ch&&(b.current=void 0,d(e,v(_({},n),{labelOffset:void 0})))};document.addEventListener("mousemove",ze),document.addEventListener("mouseup",je)},[f,w,c,n,e,d,k,P]);if(!U||!K)return null;let B=Nc(k),ee=r||U.selected||K.selected;return zt(Sc,{children:[zt("g",{className:G("group bpmn-arrow-edge",{"is-highlighted":ee}),onDoubleClick:()=>!w&&y(!0),children:[Se("path",{d:B,fill:"none",stroke:"transparent",strokeWidth:Math.max(12,12/c),className:G({"nopan nodrag":!f&&!w&&!!((oe=n==null?void 0:n.label)!=null&&oe.trim())}),style:{pointerEvents:"stroke",cursor:!f&&!w&&((q=n==null?void 0:n.label)!=null&&q.trim())?"move":"pointer"},onMouseDown:V}),zt("g",{className:G("text-grey-500 transition-colors duration-75 group-hover:text-grey-800",{"text-blue-500 group-hover:text-blue-600":ee}),children:[Se(oh,{id:e,path:B,interactionWidth:0,markerEnd:`url(#${ee?"sequence-edge-marker-highlighted":"sequence-edge-marker"})`,className:G("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)||A&&D&&!L,"stroke-green-500":A&&D&&L,"stroke-blue-500 hover:stroke-blue-600 drop-shadow-[0_0_3px_rgba(59,130,246,0.5)]":ee&&!(n!=null&&n.hasError)&&!A})}),r&&!p&&!w&&Se("g",{children:k.slice(0,-1).map((F,ue)=>{let ce=k[ue+1];if(ue===0||ue===k.length-2||Po(F,ce)<lh)return null;let j=me(F,ce,"y"),le=N===ue,ye=le&&T.current?T.current:Or(F,ce);return zt("g",{children:[Se("line",{x1:F.x,y1:F.y,x2:ce.x,y2:ce.y,stroke:"transparent",strokeWidth:20/c,className:G("cursor-pointer",{"cursor-ns-resize":j,"cursor-ew-resize":!j}),onMouseDown:Ne=>R(ue,Ne)}),Se("circle",{cx:ye.x,cy:ye.y,r:4/c,fill:le?"#3b82f6":"#fff",stroke:"#3b82f6",strokeWidth:2/c,className:"pointer-events-none"}),Se("circle",{cx:ye.x,cy:ye.y,r:6/c,fill:"none",stroke:"#3b82f6",strokeWidth:1/c,opacity:le?.6:.3,className:"pointer-events-none"})]},ue)})})]})]}),zt(nh,{children:[Se("div",{className:"absolute z-[3000] pointer-events-none flex flex-col items-center gap-1",style:{transform:`translate(-50%, -50%) translate(${P.x}px, ${P.y}px)`},children:r&&!p&&Se(So,{sx:Y,sy:X,tx:M,ty:O,hasLabel:!!((Z=n==null?void 0:n.label)!=null&&Z.trim()),children:Se(Co,{edgeId:e,edgeType:"SEQUENCE_EDGE",sourceNode:U,targetNode:K})})}),(f||((Q=n==null?void 0:n.label)==null?void 0:Q.trim()))&&Se("div",{className:G("absolute nodrag nopan",{"z-[10001] pointer-events-auto":!f&&!w&&!!((se=n==null?void 0:n.label)!=null&&se.trim()),"z-[3000] pointer-events-none":f||!((W=n==null?void 0:n.label)!=null&&W.trim())}),style:{transform:`translate(-50%, -50%) translate(${P.x+((ae=(ne=n==null?void 0:n.labelOffset)==null?void 0:ne.x)!=null?ae:0)}px, ${P.y+((he=($=n==null?void 0:n.labelOffset)==null?void 0:$.y)!=null?he:0)}px)`,cursor:!f&&!w&&((fe=n==null?void 0:n.label)!=null&&fe.trim())?"move":void 0},onMouseDown:!f&&!w?V:void 0,onDoubleClick:F=>{w||(F.stopPropagation(),y(!0))},children:Se(Oe,{value:n==null?void 0:n.label,className:G("min-w-8 max-w-56 px-2 py-1 body-small-400",{"pointer-events-auto":f,"pointer-events-none":!f}),isEditing:f,onBlur:()=>y(!1),onChange:F=>d(e,{label:F.trim()})})}),r&&!p&&!w&&zt(Sc,{children:[Se("div",{className:"absolute z-[10000] pointer-events-none",style:{transform:`translate(-50%, -50%) translate(${k[0].x}px, ${k[0].y}px)`},children:zt("svg",{width:12/c,height:12/c,style:{overflow:"visible",position:"absolute",left:"50%",top:"50%",transform:"translate(-50%, -50%)"},children:[Se("circle",{cx:6/c,cy:6/c,r:4/c,fill:A==="source"?"#3b82f6":"#fff",stroke:"#3b82f6",strokeWidth:2/c,className:"pointer-events-none"}),Se("circle",{cx:6/c,cy:6/c,r:6/c,fill:"none",stroke:"#3b82f6",strokeWidth:1/c,opacity:A==="source"?.6:.3,className:"pointer-events-none"}),Se("circle",{cx:6/c,cy:6/c,r:8/c,fill:"transparent",className:G("pointer-events-auto",{"cursor-move":!A||A!=="source","cursor-not-allowed":A==="source"&&D&&!L,"cursor-grabbing":A==="source"&&(!D||L)}),onMouseDown:F=>z("source",F.nativeEvent)})]})}),Se("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:zt("svg",{width:12/c,height:12/c,style:{overflow:"visible",position:"absolute",left:"50%",top:"50%",transform:"translate(-50%, -50%)"},children:[Se("circle",{cx:6/c,cy:6/c,r:4/c,fill:A==="target"?"#3b82f6":"#fff",stroke:"#3b82f6",strokeWidth:2/c,className:"pointer-events-none"}),Se("circle",{cx:6/c,cy:6/c,r:6/c,fill:"none",stroke:"#3b82f6",strokeWidth:1/c,opacity:A==="target"?.6:.3,className:"pointer-events-none"}),Se("circle",{cx:6/c,cy:6/c,r:8/c,fill:"transparent",className:G("pointer-events-auto",{"cursor-move":!A||A!=="target","cursor-not-allowed":A==="target"&&D&&!L,"cursor-grabbing":A==="target"&&(!D||L)}),onMouseDown:F=>z("target",F.nativeEvent)})]})})]})]})]})};import{Position as It}from"@xyflow/react";var uh={right:It.Right,left:It.Left,top:It.Top,bottom:It.Bottom},Xr=e=>{var t;return(t=uh[e!=null?e:""])!=null?t:It.Right},os=(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(Xr(t)){case It.Right:return{x:n+i,y:r+a*o};case It.Left:return{x:n,y:r+a*o};case It.Top:return{x:n+i*o,y:r};case It.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,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,p)=>{let g=Math.hypot(t-m.x,o-m.y);return Math.hypot(t-p.x,o-p.y)<g?p:m}).id};import{useDebouncedCallback as e0}from"use-debounce";import{getViewportForBounds as Jy,useReactFlow as Qy,useStoreApi as jy}from"@xyflow/react";import{useCallback as Wd}from"react";var En=(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))(En||{});import{xml2json as ph,json2xml as fh}from"xml-js";var Lc={compact:!0,spaces:4},mh=e=>e.replace(/\n/g,"&#xA;");function Ur(e,t=Lc){if(e)return JSON.parse(ph(e,t))}function kc(e,t=Lc){return e?fh(e,v(_({},t),{attributeValueFn:mh})):""}var Rc={"attribute-loop":"LOOP"},Dc={"task-script":"SCRIPT","subprocess-collapsed":"SUBPROCESS"},Oc={"gateway-exclusive":"EXCLUSIVE","gateway-parallel":"PARALLEL","gateway-complex":"COMPLEX"},Hc={SCRIPT:"task-script",SUBPROCESS:"subprocess-collapsed"},Vc={EXCLUSIVE:"gateway-exclusive",PARALLEL:"gateway-parallel",COMPLEX:"gateway-complex"};var Do=(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
+ `),h=g.length;l=g.reduce((y,N)=>Math.max(y,N.length),0)*7+r,c=h*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}}},Oo=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},hh=e=>{let{mxGeometry:t}=e,o=Oo(e),n=Do(t,pe.START_EVENT.MIN_WIDTH,pe.START_EVENT.MIN_HEIGHT);return v(_(_({},o),n),{type:"START_EVENT"})},yh=e=>{let{mxGeometry:t}=e,o=Oo(e),n=Do(t,pe.END_EVENT.MIN_WIDTH,pe.END_EVENT.MIN_HEIGHT);return v(_(_({},o),n),{type:"END_EVENT"})},ns=(e,t)=>{let{_attributes:o,mxGeometry:n}=e,r=Oo(e),s=Do(n,pe.TASK.MIN_WIDTH,pe.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=Rc[d];u&&(r.data.attribute=u)}let c=Dc[o.style];return c&&(r.data.variant=c),v(_(_({},r),s),{type:"TASK"})},rs=e=>{let{_attributes:t,mxGeometry:o}=e,{style:n}=t,r=Oo(e),i=Do(o,pe.GATEWAY.MIN_WIDTH,pe.GATEWAY.MIN_HEIGHT);return r.data.variant=Oc[n],v(_(_({},r),i),{type:"GATEWAY"})},xh=e=>{let{mxGeometry:t}=e,o=Oo(e),i=Do(t,pe.ANNOTATION.MIN_WIDTH,pe.ANNOTATION.MIN_HEIGHT,o.data.label,32,24);return v(_(_({},o),i),{type:"ANNOTATION"})},Eh=e=>{let{mxGeometry:t}=e,o=Oo(e),n=Do(t,pe.LANE.MIN_WIDTH,pe.LANE.MIN_HEIGHT);return v(_(_({},o),n),{type:"LANE"})},Gc={task:ns,"task-script":ns,"subprocess-collapsed":ns,"start-event":hh,"end-event-terminate":yh,"gateway-parallel":rs,"gateway-exclusive":rs,"gateway-complex":rs,annotation:xh,lane:Eh},bh=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:u,labelOffsetX:m,labelOffsetY:p}=t,g=bh(o==null?void 0:o.Array),h=d!==void 0?Number(d):void 0,f=u!==void 0?Number(u):void 0,y=m!==void 0?Number(m):void 0,N=p!==void 0?Number(p):void 0,E=v(_(_({id:n,source:r,target:i},l?{sourceHandle:l}:{}),c?{targetHandle:c}:{}),{data:_(_(_(_({label:a||""},g&&g.length>0?{points:g}:{}),h!==void 0?{sourceOffset:h}:{}),f!==void 0?{targetOffset:f}:{}),y!==void 0&&N!==void 0?{labelOffset:{x:y,y:N}}:{})});return s.includes("association")&&s.includes('endArrow=""')?_(_({},Mo),E):_(_({},ot),E)},zc=(e,t)=>{var p,g;let{id:o,type:n,source:r,target:i,sourceHandle:a,targetHandle:s,data:l}=e,c=t==null?void 0:t.find(h=>h.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(h=>({_attributes:{as:"mxPoint",x:h.x,y:h.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:((p=l==null?void 0:l.labelOffset)==null?void 0:p.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}},Ho=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}}}},_h=e=>{let{variant:t}=e.data,o=Ho(e);return v(_({},o),{_attributes:v(_({},o._attributes),{style:Hc[t]||"task"})})},Nh=e=>{let t=Ho(e);return v(_({},t),{_attributes:v(_({},t._attributes),{style:"start-event"})})},Th=e=>{let t=Ho(e);return v(_({},t),{_attributes:v(_({},t._attributes),{style:"end-event-terminate"})})},vh=e=>{let{variant:t}=e.data,o=Ho(e);return v(_({},o),{_attributes:v(_({},o._attributes),{style:Vc[t]})})},wh=e=>{let t=Ho(e);return v(_({},t),{_attributes:v(_({},t._attributes),{style:"lane"})})},Ih=e=>{let t=Ho(e);return v(_({},t),{_attributes:v(_({},t._attributes),{style:"annotation"})})},Yc={TASK:_h,START_EVENT:Nh,END_EVENT:Th,GATEWAY:vh,ANNOTATION:Ih,LANE:wh},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 LA}from"@xyflow/react";var Xc=(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 v(_({},i),{position:{x:a.x-i.width/2,y:a.y-i.height/2}})}),edges:t}},At=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}Li(n,i,o)}return ea(e,o)},Uc=At,$c=()=>{let e=document.querySelector(".react-flow__viewport");return e||(console.error("Flow element (.react-flow__viewport) not found."),null)};var Ah=e=>e.type==="LANE"&&!e.parentId,is=e=>{var i;let t=e.filter(Ah);if(t.length===0)return e;let o=new Map;for(let a of e){if(!a.parentId)continue;let s=(i=o.get(a.parentId))!=null?i:[];s.push(a.id),o.set(a.parentId,s)}let n=new Set,r=t.map(a=>a.id);for(;r.length>0;){let a=r.pop();if(!a||n.has(a))continue;n.add(a);let s=o.get(a);if(s)for(let l of s)n.has(l)||r.push(l)}return e.filter(a=>n.has(a.id))};var bn=1,Kc=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 ju=Object.defineProperty,ep=Object.defineProperties;var tp=Object.getOwnProp
36
36
  <mxGeometry as="geometry" relative="1" />
37
37
  </mxCell>
38
38
  </root>
39
- </mxGraphModel>`,Yc=(e,t)=>{if(!e.length&&!t.length)return gn;let o=[...e.map(r=>r.id),...t.map(r=>r.id)];return Math.max(...o.map(r=>Number(r)))};var bh=e=>{let t=Object.values(mn),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=Lc[a],l=s==null?void 0:s(i,n);if(!l){console.warn(`Node ${a} not supported`);continue}r.push(l)}return r},_h=(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=kc(r),a=t.find(l=>l.id===i.source),s=t.find(l=>l.id===i.target);(a==null?void 0:a.type)==="LANE"||(s==null?void 0:s.type)==="LANE"||n.push(i)}return n},Th=(e,t)=>{let o=[];return e.forEach(n=>{var a,s;let r=(s=(a=Dc)[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=Oc(n,t);o.push(l)}}),o},Nh=(e,t)=>{let o=[];return e.forEach(n=>{let r=Rc(n,t);o.push(r)}),o},Wc=(e=[],t=[],o)=>{let n=Th(e,o),r=Nh(t,e),i={mxGraphModel:{root:{_attributes:{version:"1.1",lastId:o},mxCell:[{_attributes:{id:"0"}},{_attributes:{id:"1",parent:"0"}},...n,...r]}}};return Ic(JSON.stringify(i),{compact:!0,spaces:0})},Fc=async e=>{var c,d,u,f,p;let t=await Fr(e),o=((d=(c=t==null?void 0:t.mxGraphModel)==null?void 0:c.root)==null?void 0:d.mxCell)||[],n=Number(((p=(f=(u=t==null?void 0:t.mxGraphModel)==null?void 0:u.root)==null?void 0:f._attributes)==null?void 0:p.lastId)||gn),r=bh(o),i=_h(o,r),a=Gc(r),{nodes:s,edges:l}=Js(a,i);return{lastElementId:n,edges:l,nodes:Ft(s)}};import{Position as kt,useConnection as sy,useReactFlow as ay}from"@xyflow/react";import{useCallback as cs}from"react";import{Handle as Xc,useReactFlow as vh}from"@xyflow/react";import{jsx as Uc}from"react/jsx-runtime";var oe=i=>{var a=i,{type:e,position:t,className:o,nodeType:n}=a,r=st(a,["type","position","className","nodeType"]);let s=n==="TASK";return Uc(Xc,_({type:e,position:t,className:V("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))},De=s=>{var l=s,{nodeId:e,nodeType:t,gatewayVariant:o,type:n,position:r,className:i}=l,a=st(l,["nodeId","nodeType","gatewayVariant","type","position","className"]);let{getEdges:c,getNodes:d}=vh(),f=(()=>{if(n!=="source")return!1;let p=c();if(t==="TASK")return p.filter(y=>y.source===e).length>=2;if(t==="GATEWAY"&&o==="EXCLUSIVE")return p.filter(y=>y.source===e).length>=2;if(t==="START_EVENT"){let h=d();return p.filter(m=>{if(m.source!==e)return!1;let x=h.find(T=>T.id===m.target);return(x==null?void 0:x.type)!=="ANNOTATION"}).length>=1}return!1})();return Uc(Xc,_({type:n,position:r,className:V("size-2.5 border border-grey-400 bg-white transition-all duration-200 relative",{"before:content-[''] before:absolute before:inset-[-16px] before:bg-transparent before:pointer-events-none":t==="TASK","before:content-[''] before:absolute before:inset-[-4px] before:bg-transparent before:pointer-events-none":t!=="TASK","opacity-50 cursor-not-allowed pointer-events-none":f,"hover:border-grey-500":!f},i),style:{pointerEvents:f?"none":"auto"}},a))};import{useRef as $c}from"react";import{NodeResizeControl as Kc,ResizeControlVariant as Ih,useReactFlow as Ah,useStoreApi as Ch}from"@xyflow/react";import{useStoreApi as wh}from"@xyflow/react";var Xr=()=>{let e=wh();return{getInternalNodes:()=>{let{nodeLookup:o}=e.getState();return Array.from(o.values())}}};import{Fragment as Ph,jsxs as Lh}from"react/jsx-runtime";import{createElement as qc}from"react";var Sh=["top","right","bottom","left"],Mh=["top-left","top-middle","top-right","right-middle","bottom-left","left-middle","bottom-right","bottom-middle"],Ze=r=>{var i=r,{nodeId:e,isVisible:t,offset:o=8}=i,n=st(i,["nodeId","isVisible","offset"]);let{getInternalNode:a,setNodes:s}=Ah(),{getInternalNodes:l}=Xr(),{isMultipleSelection:c}=ee(),d=Ch(),u=$c(0),f=$c([]),p=({y:x,width:T,height:E})=>{cancelAnimationFrame(u.current),u.current=requestAnimationFrame(()=>{var Q,U;if(!e)return;let{nodeLookup:N,onNodesChange:b}=d.getState(),g=N.get(e);if(!g||g.type!=="LANE")return;let w=!g.parentId,A=w?g.id:g.parentId;if(!A)return;let I=Array.from(N.values()).filter($=>$.type==="LANE"&&$.parentId===A);if(!I.length)return;f.current.length===0&&(f.current=$t(I).map($=>$.id));let D=f.current.map($=>I.find(M=>M.id===$)).filter(Boolean),S=[],L=0,z=D.findIndex($=>$.id===g.id),q=!w&&z>0&&Math.abs(x-g.position.y)>.5;for(let $=0;$<D.length;$++){let M=D[$],O=M.id===g.id,P=$===D.length-1;if(O){L=q?x+E:L+E;continue}let C=(U=(Q=M.measured)==null?void 0:Q.height)!=null?U:0,F=w?T-re.HEADER_WIDTH:T,R=C;w&&P&&(R=Math.max(re.MIN_HEIGHT,E-L)),q&&$===z-1&&(R=Math.max(re.MIN_HEIGHT,x-L)),S.push({id:M.id,type:"dimensions",dimensions:{width:F,height:R},setAttributes:!0}),S.push({id:M.id,type:"position",position:{x:re.HEADER_WIDTH,y:L}}),L+=R}w?S.push({id:A,type:"dimensions",dimensions:{width:T,height:E},setAttributes:!0}):S.push({id:A,type:"dimensions",dimensions:{width:T+re.HEADER_WIDTH,height:L},setAttributes:!0}),b==null||b(S)})},h=({y:x,width:T,height:E})=>{var g;if(cancelAnimationFrame(u.current),f.current=[],!e)return;let N=a(e);if(!N||N.type!=="LANE"&&!N.parentId)return;let b=[...l()];if(N.type!=="LANE"){b=b.map(w=>w.id===e?v(_({},w),{width:T,height:E,measured:{width:T,height:E}}):w),b=Et(b),s(b);return}b=ta(N,T,E,b,x),b=Et(b),b=Ut((g=N.parentId)!=null?g:N.id,b),s(b)};if(!(!c&&t))return null;let m={"--resize-offset":`${o}px`};return Lh(Ph,{children:[Sh.map(x=>qc(Kc,v(_({},n),{key:x,nodeId:e,position:x,variant:Ih.Line,className:"border-blue-400/90 border-dashed",style:m,onResize:(T,E)=>p(E),onResizeEnd:(T,E)=>h(E)}))),Mh.map(x=>qc(Kc,v(_({},n),{key:x,nodeId:e,position:x,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:m,onResize:(T,E)=>p(E),onResizeEnd:(T,E)=>h(E)})))]})};import{NodeToolbar as Zh,useReactFlow as Jh}from"@xyflow/react";import{Button as Qh,Tooltip as jh,TooltipContent as ey,TooltipTrigger as ty,useTranslation as oy}from"@produto-lecom/lecom-ui";import{useCallback as ls,useEffect as ny,useRef as Ur,useState as ry}from"react";import{create as kh}from"zustand";var ko=kh(e=>({draggableNode:null,setDraggableNode:t=>{e({draggableNode:t})}}));import{useEffect as Rh,useState as Dh}from"react";var Zc=(e,t=!1)=>{let[o,n]=Dh({width:0,height:0});return Rh(()=>{if(e.current&&t){let r=e.current.getBoundingClientRect();n({width:r.width,height:r.height})}},[t,e]),{dimensions:o}};import{Position as hn,useReactFlow as Oh}from"@xyflow/react";import{useMemo as Hh}from"react";var Vh=120,Gh=12,Jc=(e,t=!1,o)=>{let{getNode:n,getViewport:r}=Oh(),{instanceId:i}=ee();return Hh(()=>{var p,h;if(!t)return{position:hn.Right,align:"start"};let a=n(e);if(!a)return{position:hn.Right,align:"start"};let s=r(),l=a.position.x*s.zoom+s.x,c=(((p=a.measured)==null?void 0:p.width)||a.width||100)*s.zoom,d=(h=document.getElementById(`modeler-${i}`))==null?void 0:h.clientWidth;if(!d)return{position:hn.Right,align:"start"};let u=(o==null?void 0:o.width)||Vh;return{position:l+c+u+Gh>d?hn.Left:hn.Right}},[i,e,t,o,n,r])};import{useNodesData as Bh,useReactFlow as zh}from"@xyflow/react";import{Button as Qc,DropdownMenu as Yh,DropdownMenuContent as Wh,DropdownMenuGroup as Fh,DropdownMenuItem as Xh,DropdownMenuLabel as Uh,DropdownMenuTrigger as $h,Tooltip as is,TooltipContent as ss,TooltipTrigger as as,useTranslation as Kh}from"@produto-lecom/lecom-ui";import{WrenchIcon as qh}from"lucide-react";import{jsx as Le,jsxs as to}from"react/jsx-runtime";var jc=({nodeId:e})=>{let{t}=Kh(),{updateNodeData:o,getEdges:n,getNode:r}=zh(),i=Bh(e),s=n().filter(p=>p.source===e).some(p=>{let h=r(p.target);return(h==null?void 0:h.type)==="END_EVENT"}),l=(i==null?void 0:i.data.variant)==="SUBPROCESS",c=u=>{o(e,{variant:(i==null?void 0:i.data.variant)===u?"":u})},d=u=>{o(e,{attribute:(i==null?void 0:i.data.attribute)===u?"":u})};return to(Yh,{children:[to(is,{children:[Le(as,{asChild:!0,children:Le($h,{asChild:!0,children:Le(Qc,{variant:"ghost",color:"grey",size:"small",iconButton:!0,children:Le(qh,{})})})}),Le(ss,{color:"black",children:t("bpmn.task.menu.title")})]}),to(Wh,{align:"start",className:"w-60 bg-white text-grey-600",children:[to(Uh,{className:"flex items-center gap-1",children:[Le("div",{className:"flex-1 body-medium-500",children:t("bpmn.task.menu.title")}),Le("div",{className:"flex items-center gap-1",children:Object.entries(Hn).map(([u,f])=>{let p=u==="LOOP"&&(s||l),y=(()=>{if(u==="LOOP"&&s)return t("editor.task_menu.loop_not_allowed_when_connected_to_end");if(u==="LOOP"&&l)return t("editor.task_menu.loop_not_allowed_when_subprocess");if(u==="LOOP")return t("editor.task_menu.loop")})();return to(is,{children:[Le(as,{asChild:!0,children:Le(Qc,{variant:"ghost",color:"grey",size:"small",iconButton:!0,disabled:p,className:V({"bg-grey-100 text-blue-500":(i==null?void 0:i.data.attribute)===u,"opacity-50 cursor-not-allowed":p}),onClick:p?void 0:()=>d(u),children:Le(f.icon,{className:"stroke-inherit"})})}),y&&Le(ss,{color:"black",children:y})]},u)})})]}),Le(Fh,{children:to(is,{children:[Le(as,{asChild:!0,children:Le("div",{className:V({"cursor-not-allowed":s}),children:to(Xh,{className:V({"bg-grey-100 text-blue-500":(i==null?void 0:i.data.variant)==="SCRIPT","opacity-50":s}),disabled:s,onClick:()=>c("SCRIPT"),children:[Le(On.SCRIPT.icon,{className:"stroke-current"}),t(`bpmn.task.variant.${"SCRIPT".toLowerCase()}`)]})})}),s&&Le(ss,{color:"black",children:t("editor.task_menu.script_not_allowed_when_connected_to_end")})]})})]})]})};import{jsx as _e,jsxs as ed}from"react/jsx-runtime";var oo={START_EVENT:{type:"START_EVENT",icon:Yo,label:"bpmn.start_event.variant.default"},END_EVENT:{type:"END_EVENT",icon:uo,label:"bpmn.end_event.variant.default"},TASK:{type:"TASK",icon:Yo,label:"bpmn.task.variant.default"},ANNOTATION:{type:"ANNOTATION",icon:Ln,label:"bpmn.annotation.variant.default"}},iy={EXCLUSIVE:{type:"GATEWAY",variant:"EXCLUSIVE",icon:fo,label:"bpmn.gateway.variant.exclusive"},PARALLEL:{type:"GATEWAY",variant:"PARALLEL",icon:mo,label:"bpmn.gateway.variant.parallel"},COMPLEX:{type:"GATEWAY",variant:"COMPLEX",icon:po,label:"bpmn.gateway.variant.complex"}},Be=({nodeId:e,nodeType:t,nodeVariant:o})=>{let n=Ur(null),r=Ur(null),{t:i}=oy(),{setDraggableNode:a}=ko(),{getEdges:s,getNodes:l,getNode:c}=Jh(),{setIsDragging:d,mode:u,isConnecting:f,isDragging:p,isMultipleSelection:h}=ee(),y=c(e),m=!!(y!=null&&y.selected)&&!y.dragging&&!f&&!p&&!h,{dimensions:x}=Zc(n,m),{position:T}=Jc(e,m,x),[E,N]=ry(void 0),b=l(),g=s(),w=o==="SUBPROCESS",A=Ur(null),I=Ur(!1),D=ls(()=>{A.current!==null&&(clearTimeout(A.current),A.current=null),I.current=!1,d(!1),a(null),N(void 0)},[d,a]);ny(()=>{let R=H=>{I.current&&H.buttons===0&&D()};return document.addEventListener("dragend",D),document.addEventListener("mousemove",R),()=>{document.removeEventListener("dragend",D),document.removeEventListener("mousemove",R)}},[D]);let S=ls((R,H)=>{I.current=!0,d(!1),a({type:H.type,variant:H.variant,attribute:H.attribute,icon:H.icon}),H.icon&&N(_e(H.icon,{})),R.dataTransfer.effectAllowed="move",R.dataTransfer.setData("sourceId",e),r.current&&R.dataTransfer.setDragImage(r.current,10,10),A.current=setTimeout(()=>{A.current=null,d(!0)},100)},[e,a,d]),L=ls(()=>{D()},[D]),z=[{component:_e(Pr,{elementId:e})}],q=()=>{if(u==="view")return[];let R=!g.some(H=>{var k;return H.source===e&&((k=b.find(G=>G.id===H.target))==null?void 0:k.type)!=="ANNOTATION"});return[{component:_e(To,{nodeId:e,disabled:!R,tooltipMessage:R?void 0:i("editor.toolbar.start_event_limit_reached")})},oo.TASK,oo.ANNOTATION,...z]},Q=()=>u==="view"?[{component:_e(Pt,{elementId:e})}]:[{component:_e(Pt,{elementId:e})},...w?[]:[{component:_e(jc,{nodeId:e})}],{component:_e(To,{nodeId:e})},oo.TASK,...Object.values(iy),...z],U=()=>u==="view"?[{component:_e(Pt,{elementId:e})}]:[{component:_e(Pt,{elementId:e})},{component:_e(To,{nodeId:e})},oo.TASK,oo.ANNOTATION,...z],$=()=>u==="view"?[]:[oo.ANNOTATION,...z],M=()=>u==="view"?[]:[{component:_e(To,{nodeId:e})},oo.ANNOTATION,...z],O=()=>u==="view"?[]:[{component:_e(To,{nodeId:e})},...z],P=()=>u==="view"?[]:[...z],F=(R=>{switch(R){case"START_EVENT":return q();case"TASK":return Q();case"GATEWAY":return U();case"END_EVENT":return $();case"LANE":return M();case"ANNOTATION":return O();case"UNSUPPORTED":return P();default:return[]}})(t);if(!(F.length===0||u==="readonly"))return ed(Zh,{position:T,align:"start",className:"-top-8",isVisible:m,children:[_e("div",{ref:n,className:"flex items-center gap-1 px-3 py-2 bg-white rounded-sm shadow-md",children:F.map((R,H)=>{if(R.component)return _e("div",{children:R.component},H);let k={sourceNodeType:t,targetNodeType:R.type,sourceNodeId:e,nodes:b,edges:g},G=rc(k),B={gateway_limit_reached:i("editor.toolbar.gateway_limit_reached"),start_event_limit_reached:i("editor.toolbar.start_event_limit_reached"),start_event_already_exists:i("editor.toolbar.start_event_already_exists"),script_to_end_not_allowed:i("editor.toolbar.script_to_end_not_allowed"),loop_to_end_not_allowed:i("editor.toolbar.loop_to_end_not_allowed"),initial_activity_to_end_not_allowed:i("editor.toolbar.initial_activity_to_end_not_allowed"),final_activity_cannot_connect:i("editor.toolbar.final_activity_cannot_connect"),activity_has_outgoing_connections:i("editor.toolbar.activity_has_outgoing_connections"),task_limit_reached:i("editor.toolbar.task_limit_reached")},K=G.shouldDisable&&G.reason?B[G.reason]||i(R.label):i(R.label)||"";return ed(jh,{children:[_e(ty,{asChild:!0,children:_e(Qh,{variant:"ghost",color:"grey",size:"small",iconButton:!0,draggable:!G.shouldDisable,disabled:G.shouldDisable,className:G.shouldDisable?"opacity-50 cursor-not-allowed":"",onDragStart:G.shouldDisable?void 0:W=>S(W,R),onDragEnd:G.shouldDisable?void 0:L,children:R.icon&&_e(R.icon,{size:16})})}),_e(ey,{color:"black",children:K})]},H)})}),_e("div",{ref:r,className:"absolute w-0 h-0 top-0 left-0 z-[-1] bg-transparent",children:E})]})};import{Fragment as td,jsx as ot,jsxs as ds}from"react/jsx-runtime";var od=({id:e,data:t,selected:o,dragging:n})=>{let{updateNodeData:r,setNodes:i}=ay(),{inProgress:a,fromNode:s}=sy(),{mode:l}=ee(),c=a&&(s==null?void 0:s.id)!==e,d=cs(p=>{let T=p.split(`
40
- `),E=T.reduce((w,A)=>Math.max(w,A.length),0),N=T.length,b=Math.max(yo.MIN_WIDTH,E*7+32),g=Math.max(yo.MIN_HEIGHT,N*20+24);i(w=>w.map(A=>A.id===e?v(_({},A),{width:b,height:g,style:v(_({},A.style),{width:b,height:g})}):A))},[e,i]),u=cs(p=>{r(e,{label:p}),d(p)},[e,r,d]),f=cs(p=>{d(p)},[d]);return ds("div",{className:V("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:[ot(Pe,{value:t.label,className:"m-1 text-grey-600 text-left",onChange:u,onInput:f,skipFirstCharValidation:!0}),ot(Be,{nodeId:e,nodeType:"ANNOTATION"}),l==="edit"&&ot(Ze,{nodeId:e,minWidth:yo.MIN_WIDTH,minHeight:yo.MIN_HEIGHT,isVisible:!n&&o}),!a&&ds(td,{children:[ot(oe,{type:"source",position:kt.Left,id:"left"}),ot(oe,{type:"source",position:kt.Right,id:"right"}),ot(oe,{type:"source",position:kt.Top,id:"top"}),ot(oe,{type:"source",position:kt.Bottom,id:"bottom"})]}),(!a||c)&&ds(td,{children:[ot(oe,{type:"target",position:kt.Left,id:"left",className:V({"annotation-handle":c})}),ot(oe,{type:"target",position:kt.Right,id:"right",className:V({"annotation-handle":c})}),ot(oe,{type:"target",position:kt.Top,id:"top",className:V({"annotation-handle":c})}),ot(oe,{type:"target",position:kt.Bottom,id:"bottom",className:V({"annotation-handle":c})})]})]})};import{Position as Rt,useConnection as ly,useReactFlow as cy}from"@xyflow/react";import{useState as dy}from"react";import{Fragment as nd,jsx as We,jsxs as us}from"react/jsx-runtime";var rd=({id:e,data:t,selected:o,dragging:n})=>{let{updateNodeData:r}=cy(),{inProgress:i,fromNode:a}=ly(),{mode:s,reconnectingEdgeId:l}=ee(),[c,d]=dy(!1),u=i&&(a==null?void 0:a.id)!==e||!!l,f=y=>{r(e,{label:y})},p=()=>{d(!0)},h=()=>{d(!1)};return us("div",{className:"relative",onDoubleClick:p,children:[We(uo,{className:V("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})}),We("div",{className:"absolute mt-2 left-1/2 -translate-x-1/2 max-w-80 w-max",children:We(Pe,{value:t.label,isEditing:c,onBlur:h,onChange:f})}),We(Be,{nodeId:e,nodeType:"END_EVENT"}),s==="edit"&&We(Ze,{nodeId:e,isVisible:!n&&o,minWidth:Bn.MIN_WIDTH,minHeight:Bn.MIN_HEIGHT,offset:4,keepAspectRatio:!0}),(!i||u)&&us(nd,{children:[We(oe,{type:"target",position:Rt.Left,id:"left",className:V({"event-handle":u})}),We(oe,{type:"target",position:Rt.Right,id:"right",className:V({"event-handle":u})}),We(oe,{type:"target",position:Rt.Top,id:"top",className:V({"event-handle":u})}),We(oe,{type:"target",position:Rt.Bottom,id:"bottom",className:V({"event-handle":u})})]}),!i&&us(nd,{children:[We(oe,{type:"source",position:Rt.Left,id:"left"}),We(oe,{type:"source",position:Rt.Right,id:"right"}),We(oe,{type:"source",position:Rt.Top,id:"top"}),We(oe,{type:"source",position:Rt.Bottom,id:"bottom"})]})]})};import{Position as Dt,useConnection as uy,useReactFlow as py}from"@xyflow/react";import{useCallback as fy,useState as my}from"react";import{Fragment as id,jsx as Fe,jsxs as ps}from"react/jsx-runtime";var sd=({id:e,data:t,selected:o,dragging:n})=>{let r=Mi[t.variant].icon,{updateNodeData:i}=py(),{inProgress:a,fromNode:s}=uy(),{mode:l,reconnectingEdgeId:c}=ee(),[d,u]=my(!1),f=a&&(s==null?void 0:s.id)!==e||!!c,p=fy(m=>{i(e,{label:m})},[e,i]),h=()=>{u(!0)},y=()=>{u(!1)};return ps("div",{className:"relative",onDoubleClick:h,children:[Fe(r,{className:V("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":o,"stroke-red-500 hover:stroke-red-600 drop-shadow-[0_0_3px_rgba(255,0,0,0.5)]":t.hasError})}),Fe("div",{className:"absolute mt-2 left-1/2 -translate-x-1/2 max-w-80 w-max",children:Fe(Pe,{value:t.label,isEditing:d,onBlur:y,onChange:p})}),Fe(Be,{nodeId:e,nodeType:"GATEWAY"}),l==="edit"&&Fe(Ze,{nodeId:e,isVisible:!n&&o,minWidth:zn.MIN_WIDTH,minHeight:zn.MIN_HEIGHT,offset:2,keepAspectRatio:!0}),(!a||f)&&ps(id,{children:[Fe(oe,{type:"target",position:Dt.Left,id:"left",className:V({"gateway-handle":f})}),Fe(oe,{type:"target",position:Dt.Right,id:"right",className:V({"gateway-handle":f})}),Fe(oe,{type:"target",position:Dt.Top,id:"top",className:V({"gateway-handle":f})}),Fe(oe,{type:"target",position:Dt.Bottom,id:"bottom",className:V({"gateway-handle":f})})]}),!a&&ps(id,{children:[Fe(De,{type:"source",position:Dt.Left,id:"left",nodeId:e,nodeType:"GATEWAY",gatewayVariant:t.variant}),Fe(De,{type:"source",position:Dt.Right,id:"right",nodeId:e,nodeType:"GATEWAY",gatewayVariant:t.variant}),Fe(De,{type:"source",position:Dt.Top,id:"top",nodeId:e,nodeType:"GATEWAY",gatewayVariant:t.variant}),Fe(De,{type:"source",position:Dt.Bottom,id:"bottom",nodeId:e,nodeType:"GATEWAY",gatewayVariant:t.variant})]})]})};import{useNodesData as US,useReactFlow as $S}from"@xyflow/react";import{Button as qS,DropdownMenu as ZS,DropdownMenuContent as JS,DropdownMenuGroup as QS,DropdownMenuItem as jS,DropdownMenuLabel as eM,DropdownMenuTrigger as tM,Tooltip as oM,TooltipContent as nM,TooltipTrigger as rM,useTranslation as iM}from"@produto-lecom/lecom-ui";import{WrenchIcon as aM}from"lucide-react";import{jsx as uM,jsxs as pM}from"react/jsx-runtime";import{Position as Ot,useConnection as gy,useReactFlow as hy}from"@xyflow/react";import{useState as yy}from"react";import{Fragment as ad,jsx as Xe,jsxs as fs}from"react/jsx-runtime";var ld=({id:e,data:t,selected:o,dragging:n})=>{let{updateNodeData:r}=hy(),{inProgress:i,fromNode:a}=gy(),{mode:s,reconnectingEdgeId:l}=ee(),[c,d]=yy(!1),u=i&&(a==null?void 0:a.id)!==e||!!l,f=y=>{r(e,{label:y})},p=()=>{d(!0)},h=()=>{d(!1)};return fs("div",{className:"relative",onDoubleClick:p,children:[Xe(Rn,{className:V("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})}),Xe("div",{className:"absolute mt-2 left-1/2 -translate-x-1/2 max-w-80 w-max",children:Xe(Pe,{value:t.label,isEditing:c,onBlur:h,onChange:f})}),Xe(Be,{nodeId:e,nodeType:"START_EVENT"}),s==="edit"&&Xe(Ze,{nodeId:e,isVisible:!n&&o,minWidth:Gn.MIN_WIDTH,minHeight:Gn.MIN_HEIGHT,offset:4,keepAspectRatio:!0}),(!i||u)&&fs(ad,{children:[Xe(oe,{type:"target",position:Ot.Left,id:"left",className:V({"event-handle":u})}),Xe(oe,{type:"target",position:Ot.Right,id:"right",className:V({"event-handle":u})}),Xe(oe,{type:"target",position:Ot.Top,id:"top",className:V({"event-handle":u})}),Xe(oe,{type:"target",position:Ot.Bottom,id:"bottom",className:V({"event-handle":u})})]}),!i&&fs(ad,{children:[Xe(De,{type:"source",position:Ot.Left,id:"left",nodeId:e,nodeType:"START_EVENT"}),Xe(De,{type:"source",position:Ot.Right,id:"right",nodeId:e,nodeType:"START_EVENT"}),Xe(De,{type:"source",position:Ot.Top,id:"top",nodeId:e,nodeType:"START_EVENT"}),Xe(De,{type:"source",position:Ot.Bottom,id:"bottom",nodeId:e,nodeType:"START_EVENT"})]})]})};import{useTranslation as by}from"@produto-lecom/lecom-ui";import{Position as Ht,useConnection as _y,useReactFlow as Ty}from"@xyflow/react";import{useCallback as Kr}from"react";var yn=60,$r=(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<=yn?i:i.substring(0,yn).trim()},Ro=(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>yn&&(n=n.substring(0,yn).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=yn-l.length,u=`${r.substring(0,c).trim()}${l}`;if(!o.has(u))return u;i++}return n};import{jsx as cd,jsxs as xy}from"react/jsx-runtime";var dd=e=>xy("svg",v(_({width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",xmlns:"http://www.w3.org/2000/svg"},e),{children:[cd("circle",{cx:"12",cy:"12",r:"10",fill:"#10B981"}),cd("path",{d:"M7 12L10 15L17 8",stroke:"white",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"})]}));import{jsx as ud}from"react/jsx-runtime";var pd=e=>ud("svg",v(_({width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",xmlns:"http://www.w3.org/2000/svg"},e),{children:ud("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 fd,jsxs as Ey}from"react/jsx-runtime";var md=e=>Ey("svg",v(_({width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",xmlns:"http://www.w3.org/2000/svg"},e),{children:[fd("circle",{cx:"12",cy:"12",r:"10",fill:"#EF4444"}),fd("path",{d:"M8 8L16 16M8 16L16 8",stroke:"white",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"})]}));import{Fragment as qr,jsx as ye,jsxs as xn}from"react/jsx-runtime";var Ny={APROVADO:dd,EM_ANDAMENTO:pd,REJEITADO:md},ms={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)]"},gd=({id:e,data:t,selected:o,dragging:n})=>{let{t:r}=by(),{toast:i}=Ge(),{updateNodeData:a,getNodes:s,setNodes:l}=Ty(),{inProgress:c,fromNode:d}=_y(),{mode:u,onSubprocessValidationClick:f,reconnectingEdgeId:p}=ee(),{getTaskStatus:h}=Kt(),y=c&&(d==null?void 0:d.id)!==e||!!p,m=h(e),x=t.variant==="SUBPROCESS",T=!!t.variant&&!x||!!m,E=!!t.attribute||x,N=Kr(z=>{let $=T||E?80:40,M=z.split(`
41
- `),O=M.reduce((R,H)=>Math.max(R,H.length),0),P=M.length,C=Math.max(ho.MIN_WIDTH,O*7+64),F=Math.max(ho.MIN_HEIGHT,P*24+$);l(R=>R.map(H=>H.id===e?v(_({},H),{width:C,height:F,style:v(_({},H.style),{width:C,height:F})}):H))},[e,l,T,E]),b=Kr(z=>{let q=z.trim(),Q=t.label||"";if(q===Q)return;let U=q,$=s();if(!(q&&q!=="")){U=$r($,r("bpmn.task.label.prefix")),a(e,{label:U}),N(U),i({variant:"warning",content:xn(qr,{children:[r("bpmn.task.feedback.label_empty.prefix")," ",ye("strong",{children:U})]})});return}let O=Ro(U,$);O===Q||(a(e,{label:O}),N(O),O!==U&&i({variant:"warning",content:xn(qr,{children:[r("bpmn.task.feedback.label_already_exists.prefix")," ",ye("strong",{children:q})," ",r("bpmn.task.feedback.label_already_exists.middle")," ",ye("strong",{children:O})]})}))},[t.label,s,e,r,a,N,i]),g=Kr(z=>{N(z)},[N]),w=Kr(()=>{i({variant:"error",content:r("bpmn.task.feedback.invalid_first_character")})},[r,i]),A=m?Ny[m]:null,I=t.variant?On[t.variant].icon:null,D=t.attribute?Hn[t.attribute].icon:null,S=()=>t.hasError?ms.error:m?ms[m]:ms.default,L=()=>{f==null||f({id:e,type:"sub_process",label:t.label})};return xn("div",{className:V("relative w-full h-full min-w-44 min-h-24 flex flex-col items-stretch justify-stretch bg-white border-2 border-grey-400 hover:border-grey-500 rounded-md hover:shadow-md transition-colors duration-75",S(),{"border-blue-500 hover:border-blue-600 shadow-md":o,"border-red-500 hover:border-red-600 shadow-[0_0_5px_rgba(255,0,0,0.5)]":t.hasError}),children:[ye("div",{className:"flex-1 flex items-stretch justify-stretch overflow-hidden",children:ye(Pe,{value:t.label,maxLength:60,className:V({"py-10 px-8":T||E}),onChange:b,onInput:g,onInvalidFirstCharacter:w})}),I&&ye("div",{className:V("absolute flex items-center p-1",x?"bottom-0 left-1/2 -translate-x-1/2":"top-0 left-0"),children:ye(I,{size:16,className:V(t.hasError?"text-red-500":"text-grey-500",x&&"cursor-pointer"),onClick:x?L:void 0})}),D&&ye("div",{className:"absolute bottom-0 left-0 w-full flex items-center justify-center",children:ye("div",{className:V("flex items-center w-16 p-1",x?"justify-between":"justify-center"),children:ye(D,{size:16,className:V(t.hasError?"text-red-500":"text-grey-500")})})}),A&&ye("div",{className:"absolute top-0 right-0 flex items-center p-1",children:ye(A,{})}),ye(Be,{nodeId:e,nodeType:"TASK",nodeVariant:t.variant}),u==="edit"&&ye(Ze,{nodeId:e,isVisible:!n&&o,minWidth:ho.MIN_WIDTH,minHeight:ho.MIN_HEIGHT}),(!c||y)&&xn(qr,{children:[ye(oe,{type:"target",position:Ht.Left,id:"left",className:V({"task-handle":y})}),ye(oe,{type:"target",position:Ht.Right,id:"right",className:V({"task-handle":y})}),ye(oe,{type:"target",position:Ht.Top,id:"top",className:V({"task-handle":y})}),ye(oe,{type:"target",position:Ht.Bottom,id:"bottom",className:V({"task-handle":y})})]}),!c&&xn(qr,{children:[ye(De,{type:"source",position:Ht.Left,id:"left",nodeId:e,nodeType:"TASK"}),ye(De,{type:"source",position:Ht.Right,id:"right",nodeId:e,nodeType:"TASK"}),ye(De,{type:"source",position:Ht.Top,id:"top",nodeId:e,nodeType:"TASK"}),ye(De,{type:"source",position:Ht.Bottom,id:"bottom",nodeId:e,nodeType:"TASK"})]})]})};import{Position as hd}from"@xyflow/react";import{Fragment as vy,jsx as Zr,jsxs as wy}from"react/jsx-runtime";var yd=({id:e,data:t})=>wy(vy,{children:[Zr("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}),Zr(Be,{nodeId:e,nodeType:"UNSUPPORTED"}),Zr(oe,{type:"source",position:hd.Right}),Zr(oe,{type:"target",position:hd.Left})]});import{BaseEdge as Iy,EdgeLabelRenderer as Ay,getSmoothStepPath as Cy,MarkerType as Sy,useInternalNode as xd,useReactFlow as My,useViewport as Py,Position as Do}from"@xyflow/react";import{useState as Ly,useMemo as ky}from"react";import{Fragment as Ed,jsx as ze,jsxs as no}from"react/jsx-runtime";var Z5={type:"MESSAGE_EDGE",reconnectable:!0,markerEnd:{type:Sy.Arrow},data:{label:""}},bd=({id:e,source:t,target:o,data:n,selected:r,sourcePosition:i,targetPosition:a,sourceHandleId:s,targetHandleId:l})=>{var H;let{zoom:c}=Py(),{updateEdgeData:d}=My(),{isMultipleSelection:u,mode:f,instanceId:p}=ee(),h=f!=="edit",[y,m]=Ly(!1),{reconnectingHandle:x,cursorPosition:T,hoveredNodeId:E,reconnectingSide:N,isValidReconnection:b,handleReconnectStart:g}=zr({edgeId:e,source:t,target:o,instanceId:p,isReadOnly:h}),w=xd(t),A=xd(o),{sx:I,sy:D,tx:S,ty:L,sourcePos:z,targetPos:q}=ky(()=>{var ne,J;if(!w||!A)return{sx:0,sy:0,tx:0,ty:0,sourcePos:Do.Left,targetPos:Do.Right};let k=go(w,A),G=s?i:k.sourcePos,B=l?a:k.targetPos,K=(le,de,ue)=>{var we,Oe,it,pt,zt,Yt;let{x:xe,y:ge}=le.internals.positionAbsolute,fe=(it=(Oe=(we=le.measured)==null?void 0:we.width)!=null?Oe:le.width)!=null?it:0,ce=(Yt=(zt=(pt=le.measured)==null?void 0:pt.height)!=null?zt:le.height)!=null?Yt:0;switch(de){case Do.Top:return{x:xe+fe*ue,y:ge};case Do.Bottom:return{x:xe+fe*ue,y:ge+ce};case Do.Left:return{x:xe,y:ge+ce*ue};case Do.Right:return{x:xe+fe,y:ge+ce*ue};default:return{x:xe+fe/2,y:ge+ce/2}}},W=(ne=n==null?void 0:n.sourceOffset)!=null?ne:.5,X=(J=n==null?void 0:n.targetOffset)!=null?J:.5,Z=w?K(w,G,W).x:k.sx,j=w?K(w,G,W).y:k.sy,Y=A?K(A,B,X).x:k.tx,te=A?K(A,B,X).y:k.ty;return x==="source"&&T?(Z=T.x,j=T.y,N&&(G=N)):x==="target"&&T&&(Y=T.x,te=T.y,N&&(B=N)),{sx:Z,sy:j,tx:Y,ty:te,sourcePos:G,targetPos:B}},[w,A,s,l,i,a,x,T,N,n==null?void 0:n.sourceOffset,n==null?void 0:n.targetOffset]);if(!w||!A)return null;let[Q,U,$]=Cy({sourceX:I,sourceY:D,targetX:S,targetY:L,sourcePosition:z,targetPosition:q}),M=r||(w==null?void 0:w.selected)||(A==null?void 0:A.selected),O=M?"sequence-edge-marker-highlighted":"sequence-edge-marker",P=y||(n==null?void 0:n.label.trim().length)>0,C=()=>{m(!0)},F=()=>{m(!1)},R=k=>{d(e,{label:k.trim()})};return ze(Ed,{children:no("g",{className:V("group bpmn-arrow-edge",{"is-highlighted":M}),onDoubleClick:C,children:[ze("path",{d:Q,fill:"none",stroke:"transparent",strokeWidth:Math.max(12,12/c),style:{pointerEvents:"stroke",cursor:"pointer"}}),no("g",{className:V("text-grey-500 transition-colors duration-75 group-hover:text-grey-800",{"text-blue-500 group-hover:text-blue-600":M}),children:[ze(Iy,{id:e,path:Q,interactionWidth:0,markerEnd:`url(#${O})`,strokeDasharray:4,className:V("stroke-2 stroke-current transition-[stroke,filter] duration-75 group-hover:drop-shadow-[0_0_3px_rgba(0,0,0,0.2)]",{"stroke-red-500 hover:stroke-red-600":(n==null?void 0:n.hasError)||x&&E&&!b,"stroke-green-500":x&&E&&b,"stroke-blue-500 hover:stroke-blue-600 drop-shadow-[0_0_3px_rgba(59,130,246,0.5)]":M&&!(n!=null&&n.hasError)&&!x})}),no(Ay,{children:[no("div",{className:"absolute z-[3000] pointer-events-auto flex flex-col items-center gap-1",style:{transform:`translate(-50%, -50%) translate(${U}px, ${$}px)`},children:[r&&!u&&ze(wo,{sx:I,sy:D,tx:S,ty:L,hasLabel:!!((H=n==null?void 0:n.label)!=null&&H.trim()),children:ze(vo,{edgeId:e,edgeType:"MESSAGE_EDGE"})}),P&&ze(Pe,{value:n==null?void 0:n.label,className:"min-w-8 max-w-56 bg-white rounded-md px-2 py-1 text-xs",isEditing:y,onBlur:F,onChange:R})]}),r&&!u&&!h&&no(Ed,{children:[ze("div",{className:"absolute z-[1000] pointer-events-none",style:{transform:`translate(-50%, -50%) translate(${I}px, ${D}px)`},children:no("svg",{width:12/c,height:12/c,style:{overflow:"visible",position:"absolute",left:"50%",top:"50%",transform:"translate(-50%, -50%)"},children:[ze("circle",{cx:6/c,cy:6/c,r:4/c,fill:x==="source"?"#3b82f6":"#fff",stroke:"#3b82f6",strokeWidth:2/c,className:"pointer-events-none"}),ze("circle",{cx:6/c,cy:6/c,r:6/c,fill:"none",stroke:"#3b82f6",strokeWidth:1/c,opacity:x==="source"?.6:.3,className:"pointer-events-none"}),ze("circle",{cx:6/c,cy:6/c,r:8/c,fill:"transparent",className:V("pointer-events-auto",{"cursor-move":!x||x!=="source","cursor-not-allowed":x==="source"&&E&&!b,"cursor-grabbing":x==="source"&&(!E||b)}),onMouseDown:k=>g("source",k.nativeEvent)})]})}),ze("div",{className:"absolute z-[1000] pointer-events-none",style:{transform:`translate(-50%, -50%) translate(${S}px, ${L}px)`},children:no("svg",{width:12/c,height:12/c,style:{overflow:"visible",position:"absolute",left:"50%",top:"50%",transform:"translate(-50%, -50%)"},children:[ze("circle",{cx:6/c,cy:6/c,r:4/c,fill:x==="target"?"#3b82f6":"#fff",stroke:"#3b82f6",strokeWidth:2/c,className:"pointer-events-none"}),ze("circle",{cx:6/c,cy:6/c,r:6/c,fill:"none",stroke:"#3b82f6",strokeWidth:1/c,opacity:x==="target"?.6:.3,className:"pointer-events-none"}),ze("circle",{cx:6/c,cy:6/c,r:8/c,fill:"transparent",className:V("pointer-events-auto",{"cursor-move":!x||x!=="target","cursor-not-allowed":x==="target"&&E&&!b,"cursor-grabbing":x==="target"&&(!E||b)}),onMouseDown:k=>g("target",k.nativeEvent)})]})})]})]})]})]})})};import{getStraightPath as Ry,Position as Jr}from"@xyflow/react";import{jsx as _d,jsxs as Dy}from"react/jsx-runtime";var Td=({toX:e,toY:t,fromNode:o})=>{var u,f;if(!o)return null;let{internals:{positionAbsolute:{x:n,y:r}},measured:i}=o,a=(u=i.width)!=null?u:0,s=(f=i.height)!=null?f:0,c=[{x:n,y:r+s/2,pos:Jr.Left},{x:n+a,y:r+s/2,pos:Jr.Right},{x:n+a/2,y:r,pos:Jr.Top},{x:n+a/2,y:r+s,pos:Jr.Bottom}].reduce((p,h)=>{let y=Math.hypot(e-p.x,t-p.y);return Math.hypot(e-h.x,t-h.y)<y?h:p}),[d]=Ry({sourceX:c.x,sourceY:c.y,targetX:e,targetY:t});return Dy("g",{className:"group",children:[_d("path",{fill:"none",className:"stroke-2 stroke-grey-500 animated transition-[stroke,filter] duration-75",d}),_d("circle",{cx:e,cy:t,fill:"none",r:4,className:"stroke-2 stroke-grey-600"})]})};import{Position as Vt,useConnection as Oy,useReactFlow as Hy}from"@xyflow/react";import{orderBy as Vy}from"lodash";import{useMemo as Nd,useState as Gy}from"react";import{Fragment as gs,jsx as Ye,jsxs as Qr}from"react/jsx-runtime";var vd=({id:e,data:t,selected:o,dragging:n,parentId:r})=>{let{updateNodeData:i,getNodes:a}=Hy(),{mode:s}=ee(),{inProgress:l,fromNode:c}=Oy(),d=l&&(c==null?void 0:c.id)!==e,[u,f]=Gy(!1),p=a(),h=!r,y=Nd(()=>Vy([...p.filter(b=>b.parentId===e&&b.type==="LANE")],"position.y","asc"),[p,e]),m=h?Us.MIN_WIDTH:re.MIN_WIDTH,x=Nd(()=>{if(h&&y.length>1){let b=[...y];return b.pop(),b.reduce((w,A)=>{var I,D;return w+((D=(I=A.measured)==null?void 0:I.height)!=null?D:0)},0)+re.MIN_HEIGHT}return re.MIN_HEIGHT},[h,y]),T=b=>{i(e,{label:b})},E=()=>{f(!0)},N=()=>{f(!1)};return Qr(gs,{children:[Qr("div",{className:V("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:[Ye("div",{className:"flex align-items justify-center w-10 border-r border-grey-300",onDoubleClick:E,children:Ye("div",{className:"relative flex-1 [writing-mode:vertical-rl] [text-orientation:sideways] transform rotate-180",children:Ye(Pe,{value:t.label,className:"w-full h-full self-auto",contentClassName:V({"whitespace-nowrap":u}),isEditing:u,onBlur:N,onChange:T})})}),Ye("div",{className:"flex-1"})]}),Ye(Be,{nodeId:e,nodeType:"LANE",isChild:!h}),s==="edit"&&Ye(Ze,{nodeId:e,isVisible:!n&&o,minWidth:m,minHeight:x,offset:10}),!l&&Qr(gs,{children:[Ye(oe,{type:"source",position:Vt.Left,id:"left"}),Ye(oe,{type:"source",position:Vt.Right,id:"right"}),Ye(oe,{type:"source",position:Vt.Top,id:"top"}),Ye(oe,{type:"source",position:Vt.Bottom,id:"bottom"})]}),(!l||d)&&Qr(gs,{children:[Ye(oe,{type:"target",position:Vt.Left,id:"left",className:V({"annotation-handle":d})}),Ye(oe,{type:"target",position:Vt.Right,id:"right",className:V({"annotation-handle":d})}),Ye(oe,{type:"target",position:Vt.Top,id:"top",className:V({"annotation-handle":d})}),Ye(oe,{type:"target",position:Vt.Bottom,id:"bottom",className:V({"annotation-handle":d})})]})]})};var wd={START_EVENT:ld,END_EVENT:rd,TASK:gd,GATEWAY:sd,ANNOTATION:od,LANE:vd,UNSUPPORTED:yd},Id={SEQUENCE_EDGE:Nc,MESSAGE_EDGE:bd,ANNOTATION_EDGE:lc},Ad="#fafafa",Cd="#bebebe",Sd=1,Md=10,Pd="bottom-left",hs=.05,Ld=5,Oo=.5,Ho=hs,Vo=1,kd={x:0,y:0,zoom:.75},Rd=1,Dd=2,By={[Rd]:4,[Dd]:2},jr=[Rd,Dd],Od=jr.reduce((e,t)=>e|By[t],0);import{useReactFlow as zy}from"@xyflow/react";var Je=()=>{let{getEdges:e,getNodes:t}=zy(),{lastElementId:o}=ee(),n=()=>{let i=t(),a=e(),s=Yc(i,a);return Math.max(s,o)};return{getLastId:n,getNextId:()=>n()+1}};var Go=()=>{let{getNodes:e,getEdges:t,setNodes:o,setEdges:n,setViewport:r}=Wy(),{getLastId:i}=Je(),a=Fy(),{setLastElementId:s}=ee(),l=Hd(async(d="")=>{let{nodes:u,edges:f,lastElementId:p}=await Fc(d),{width:h,height:y}=a.getState();if(h>0&&y>0){let m=Qs(u);m&&r(Yy(m,h,y,Ho,Vo,Oo))}o(u),n(f),s(p)},[o,n,s,a,r]),c=Hd(()=>{let d=e(),u=t(),f=i();return Wc(d,u,f)},[e,t,i]);return{importFromMxGraph:l,exportToMxGraph:c}};import{useCallback as Vd}from"react";var Uy=500,ei=()=>{let{isInitialized:e,onElementChanges:t}=ee(),{exportToMxGraph:o}=Go(),n=Xy(()=>{if(!e)return;let a=o();t==null||t(a)},Uy),r=Vd(a=>{a.every(c=>c.type==="select")||a.some(c=>c.type==="position"&&c.dragging)||n()},[n]),i=Vd(a=>{a.some(l=>l.type==="select")||n()},[n]);return{emitElementChanges:n,handleNodeChanges:r,handleEdgeChanges:i}};var Gd=({setEdges:e,saveHistory:t})=>{let{getNode:o,getEdges:n,getNodes:r,getInternalNode:i}=Ky(),{emitElementChanges:a}=ei(),s=qy(null),{getNextId:l}=Je(),c=ro(m=>{var b;let x=o(m.source),T=o(m.target);if(!x||!T)return!1;let E={sourceNodeId:x.id,targetNodeId:T.id,sourceNodeType:x.type,targetNodeType:T.type,nodes:r(),edges:n(),reconnectingEdgeId:(b=s.current)!=null?b:void 0};return Ji(E).isValid},[o,n,r]),d=ro(m=>{var E,N;let x=l(),T=i(m.source);if(T){let b=i(m.target),g=b?b.internals.positionAbsolute.x+((E=b.measured.width)!=null?E:0)/2:0,w=b?b.internals.positionAbsolute.y+((N=b.measured.height)!=null?N:0)/2:0,A=vc(T,g,w),I=(b==null?void 0:b.type)==="ANNOTATION"||(T==null?void 0:T.type)==="ANNOTATION",D=I?Io:qe,S;if(!I&&b&&m.targetHandle){let q=Wr(A),Q=Wr(m.targetHandle),{x:U,y:$}=ts(T,A),{x:M,y:O}=ts(b,m.targetHandle),C=Gr(U,$,M,O,q,Q).slice(1,-1);C.length>0&&(S=C)}let L=v(_(_({},m),D),{id:String(x),sourceHandle:A,data:_(_({},I?{}:qe.data),S?{points:S}:{})}),z=n().concat(L);e(z),t("forceSave",{nodes:r(),edges:z}),a()}},[l,e,a,i,n,r,t]),u=ro((m,x)=>{s.current=x.id},[]),f=ro(()=>{s.current=null},[]),p=ro((m,x)=>{let T=o(x.source),E=o(x.target);if(!T||!E){s.current=null;return}let N={sourceNodeId:T.id,targetNodeId:E.id,sourceNodeType:T.type,targetNodeType:E.type,nodes:r(),edges:n(),reconnectingEdgeId:m.id};if(!Ji(N).isValid){s.current=null;return}let g=$y(m,x,n()).map(w=>w.id===m.id?v(_({},w),{data:v(_({},w.data),{points:void 0})}):w);e(g),t("forceSave",{nodes:r(),edges:g}),s.current=null,a()},[o,r,n,e,a,t]),h=ro(m=>{s.current=m},[]),y=ro(()=>{s.current=null},[]);return{isValidConnection:c,onConnect:d,onReconnect:p,onReconnectStart:u,onReconnectEnd:f,setReconnectingEdge:h,clearReconnectingEdge:y}};import{useTranslation as Zy}from"@produto-lecom/lecom-ui";import{useReactFlow as Jy}from"@xyflow/react";import{useCallback as Tn,useRef as Kd,useState as Qy}from"react";var En=(e=[])=>e.filter(t=>t.type==="START_EVENT"),io=(e=[])=>e.filter(t=>t.type==="END_EVENT"),Gt=(e=[])=>e.filter(t=>t.type==="TASK")||[],Bd=(e=[])=>e.filter(t=>{var o;return t.type==="TASK"&&((o=t.properties)==null?void 0:o.variant)==="SCRIPT"}),zd=(e=[])=>e.filter(t=>{var o;return t.type==="TASK"&&((o=t.properties)==null?void 0:o.variant)==="SUBPROCESS"}),ti=(e=[])=>e.filter(t=>t.type==="GATEWAY"),Yd=(e=[])=>e.filter(t=>{var o;return t.type==="GATEWAY"&&((o=t.properties)==null?void 0:o.variant)==="EXCLUSIVE"}),Ue=(e,t=[])=>t.filter(o=>o.source===e),bn=(e,t=[])=>t.filter(o=>o.target===e),Wd=(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"},Fd=(e,t)=>{let o=Ue(e,t.edges||[]);for(let n of o){let r=(t.nodes||[]).find(i=>i.id===n.target);if(r&&r.type==="END_EVENT")return!0}return!1},Xd=e=>e?/[^\s]/.test(e.trim()):!1,me=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:[]}},ut=(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)}},Ud=(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 _n=[{id:"start_event_not_found",validate:e=>{let t=En(e.nodes);return me({isValid:t.length>=1})}},{id:"end_event_not_found",validate:e=>{let t=io(e.nodes);return me({isValid:t.length>=1})}},{id:"multiple_start_event_not_allowed",validate:e=>{let t=En(e.nodes),o=t.length===1;if(t.length===0)return me({isValid:!0});if(!o)return me({isValid:!1,nodeIds:t.map(i=>i.id)});let n=Ue(t[0].id,e.edges);if(!(n.length<=1)){let i=[...t.map(a=>a.id),...n.map(a=>a.target)];return me({isValid:!1,nodeIds:[...new Set(i)]})}return me({isValid:!0})}},{id:"task_flows_limit_exceeds",validate:e=>{let t=Gt(e.nodes),o=ut(t,n=>Ue(n.id,e.edges).length<=2);return me({isValid:o.isValid,nodeIds:o.invalidIds})}},{id:"task_label_empty",highlightRelatedEdges:!1,validate:e=>{let t=Gt(e.nodes),o=ut(t,n=>!!n.label&&n.label.trim()!=="");return me({isValid:o.isValid,nodeIds:o.invalidIds})}},{id:"task_label_length",highlightRelatedEdges:!1,validate:e=>{let o=Gt(e.nodes),n=ut(o,r=>!r.label||r.label.length<=60);return me({isValid:n.isValid,nodeIds:n.invalidIds})}},{id:"duplicate_task_name",highlightRelatedEdges:!1,validate:e=>{let t=Gt(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 me({isValid:n.length===0,nodeIds:n})}},{id:"nested_gateway",validate:e=>{let t=ti(e.nodes),o=[],n=[];for(let r of t){let i=Ue(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 me({isValid:o.length===0,nodeIds:o.length>0?[...new Set(o)]:[],edgeIds:n})}},{id:"events_nested",validate:e=>{let t=[...En(e.nodes),...io(e.nodes)],o=[],n=[];for(let r of t){let i=Ue(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 me({isValid:o.length===0,nodeIds:o.length>0?[...new Set(o)]:[],edgeIds:n})}},{id:"flows_on_end_tasks_not_allowed",validate:e=>{let t=io(e.nodes),o=[],n=[];for(let r of t){let i=bn(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=Ue(s.id,e.edges);l.length>1&&(o.push(s.id),l.forEach(c=>n.push(c.id)))}}}return me({isValid:o.length===0,nodeIds:o,edgeIds:n})}},{id:"conditions_flows_limit_exceeds",validate:e=>{let t=Yd(e.nodes),o=ut(t,r=>Ue(r.id,e.edges).length<=2),n=o.invalidIds.flatMap(r=>Ue(r,e.edges).map(i=>i.id));return me({isValid:o.isValid,nodeIds:o.invalidIds,edgeIds:n})}},{id:"activity_name_invalid",validate:e=>{let t=Gt(e.nodes),o=ut(t,n=>!n.label||Xd(n.label));return me({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 me({isValid:!0});let t=io(e.nodes)[0];if(!t)return me({isValid:!0});let o=bn(t.id,e.edges);if(!o.length)return me({isValid:!0});let r=Gt(e.nodes).filter(l=>o.some(c=>c.source===l.id)),i=ut(r,l=>!Wd(l.id,e));return me({isValid:i.isValid,nodeIds:i.isValid?[]:[t.id,...i.invalidIds]})}},{id:"concurrent_initial_and_final_event",validate:e=>{let t=Gt(e.nodes),o=io(e.nodes)[0];if(!o)return me({isValid:!0});let n=t.filter(l=>{let c=bn(l.id,e.edges),d=Ue(l.id,e.edges),u=c.some(p=>{var h;return((h=e.nodes.find(y=>y.id===p.source))==null?void 0:h.type)==="START_EVENT"}),f=d.some(p=>{var h;return((h=e.nodes.find(y=>y.id===p.target))==null?void 0:h.type)==="END_EVENT"});return u&&f}),r=bn(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 me(s)}},{id:"gateway_flow_to_event",validate:e=>{let t=ti(e.nodes),o=[],n=[];for(let r of t){let i=Ue(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 me({isValid:o.length===0,nodeIds:o.length>0?[...new Set(o)]:[],edgeIds:n})}},{id:"gateway_missing_output_streams",validate:e=>{let t=ti(e.nodes),o=ut(t,n=>Ue(n.id,e.edges).length>=1);return me({isValid:o.isValid,nodeIds:o.invalidIds})}},{id:"event_to_condition",validate:e=>{let t=[...En(e.nodes),...io(e.nodes)],o=[],n=[];for(let r of t){let i=Ue(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 me({isValid:o.length===0,nodeIds:o.length>0?[...new Set(o)]:[],edgeIds:n})}},{id:"script_in_final_activity",validate:e=>{let t=Bd(e.nodes),o=ut(t,n=>!Fd(n.id,e));return me({isValid:o.isValid,nodeIds:o.invalidIds})}},{id:"subprocess_referenced_not_configured",validate:e=>{let t=zd(e.nodes),o=ut(t,n=>{var r,i;return((r=n.properties)==null?void 0:r.subprocessRef)!==void 0&&((i=n.properties)==null?void 0:i.subprocessRef)!==""});return me({isValid:o.isValid,nodeIds:o.invalidIds})}}];var $d=e=>{e=e||{nodes:[],edges:[]},e.nodes=e.nodes||[],e.edges=e.edges||[];let t=[];for(let n of _n){let r=n.validate(e);r.isValid||t.push({id:n.id,message:n.id,nodeIds:r.nodeIds||[],edgeIds:r.edgeIds||[]})}return{isValid:t.length===0,errors:t}};import{jsx as oi,jsxs as jy}from"react/jsx-runtime";var qd=()=>{let{t:e}=Zy(),{toast:t}=Ge(),{setNodes:o,setEdges:n,getNodes:r,getEdges:i}=Jy(),[a,s]=Qy(!1),l=Kd(!1),c=Kd(!1),d=Tn(y=>{let m=Ud(y.nodes,y.edges),x=$d(m),T=x.errors.map(E=>v(_({},E),{message:e(`validation.errors.${E.id}`)}));return a||s(!0),{isValid:x.isValid,errors:T}},[a,e]),u=Tn((y,m=!0)=>{if(m&&y&&t({variant:y.isValid?"success":"error",duration:5e3,title:y.isValid?e("validation.success.title"):e("validation.errors.title"),content:jy("div",{className:"flex flex-col gap-1",children:[!y.isValid&&oi("span",{className:"body-small-500",children:e("validation.errors.subtitle")}),oi("ul",{className:"list-disc list-inside max-h-40 overflow-y-auto",children:y.isValid?oi("li",{children:e("validation.success.message")}):y.errors.map(S=>oi("li",{className:"text-xs",children:S.message},S.id))})]})}),!y)return;l.current=!0,c.current=!0;let x=[],T=[];y.errors.forEach(S=>{S.nodeIds&&S.nodeIds.length>0&&S.nodeIds.forEach(L=>x.push(L)),S.edgeIds&&S.edgeIds.length>0&&S.edgeIds.forEach(L=>T.push(L))});let E=[...new Set(x)];o(S=>S.map(L=>v(_({},L),{data:v(_({},L.data),{hasError:!1})}))),n(S=>S.map(L=>v(_({},L),{data:v(_({},L.data),{hasError:!1})})));let N=r(),b=i(),g=new Set(E),w=new Set;y.errors.forEach(S=>{var q,Q;let L=_n.find(U=>U.id===S.id);(L==null?void 0:L.highlightRelatedEdges)!==!1&&((q=S.edgeIds)==null||q.forEach(U=>w.add(U)),(Q=S.nodeIds)==null||Q.forEach(U=>{b.forEach($=>{($.source===U||$.target===U)&&w.add($.id)})}))});let A=new Set,I=new Set,D=new Set;N.forEach(S=>{S.type==="START_EVENT"?A.add(S.id):S.type==="END_EVENT"&&I.add(S.id)}),b.forEach(S=>{A.has(S.source)&&D.add(S.target),I.has(S.target)&&D.add(S.source)}),D.forEach(S=>{var L,z;if(g.has(S)){let q=(L=y.errors.find(U=>{var $;return($=U.nodeIds)==null?void 0:$.includes(S)}))==null?void 0:L.id;((z=_n.find(U=>U.id===q))==null?void 0:z.highlightRelatedEdges)!==!1&&b.forEach(U=>{U.source===S&&I.has(U.target)&&(g.add(U.target),w.add(U.id)),U.target===S&&A.has(U.source)&&(g.add(U.source),w.add(U.id))})}}),g.size>0&&o(S=>S.map(L=>v(_({},L),{data:v(_({},L.data),{hasError:g.has(L.id)})}))),w.size>0&&n(S=>S.map(L=>v(_({},L),{data:v(_({},L.data),{hasError:w.has(L.id)})}))),setTimeout(()=>{l.current=!1},0)},[e,i,r,n,o,t]),f=Tn(()=>{s(!1),c.current=!1,o(y=>y.map(m=>v(_({},m),{data:v(_({},m.data),{hasError:!1})}))),n(y=>y.map(m=>v(_({},m),{data:v(_({},m.data),{hasError:!1})})))},[n,o]),p=Tn(()=>{c.current&&(l.current=!0,c.current=!1,o(y=>y.map(m=>v(_({},m),{data:v(_({},m.data),{hasError:!1})}))),n(y=>y.map(m=>v(_({},m),{data:v(_({},m.data),{hasError:!1})}))),setTimeout(()=>{l.current=!1},0))},[n,o]),h=Tn(()=>l.current,[]);return{validateDiagram:d,handleValidationComplete:u,clearValidation:f,dismissValidationPanel:p,isAutoValidationEnabled:a,getIsClearingValidation:h}};import{useReactFlow as e0}from"@xyflow/react";import{useTranslation as t0}from"@produto-lecom/lecom-ui";import{useEffect as o0}from"react";var n0=15,Zd="bpmn:selection",r0=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},Jd=e=>{if(!r0(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},Qd=({offset:e=n0,saveHistory:t})=>{let{t:o}=t0(),{getNodes:n,setNodes:r,getEdges:i,setEdges:a}=e0(),{getNextId:s}=Je();o0(()=>{let l=d=>{var x,T;if(!Jd(d))return;let u=n(),f=i(),p=u.filter(E=>E.selected);if(!p.length)return;d.preventDefault(),d.stopPropagation();let h=f.filter(E=>p.some(N=>N.id===E.source)&&p.some(N=>N.id===E.target)),m=JSON.stringify({nodes:p,edges:h});(x=d.clipboardData)==null||x.setData(Zd,m),(T=d.clipboardData)==null||T.setData("text/plain",`BPMN Selection: ${p.length} nodes`)},c=d=>{var w,A;if(!Jd(d))return;let u=(w=d.clipboardData)==null?void 0:w.getData(Zd);if(!u)return;d.preventDefault(),d.stopPropagation();let f;try{f=JSON.parse(u)}catch(I){return}if(!((A=f.nodes)!=null&&A.length))return;let p=new Map,h=n(),y=[],m=f.nodes.filter(I=>St(I.type,h));if(m.length===0)return;let x=s(),T=m.map(I=>{var L;let D=String(x++);p.set(I.id,D);let S=v(_({},I),{id:D,selected:!0,position:{x:I.position.x+e,y:I.position.y+e}});if(I.type==="TASK"){let z=(L=I.data)==null?void 0:L.label,q=Ro(z||o("bpmn.task.label.prefix"),[...h,...y]);S.data=v(_({},I.data),{label:q})}return y.push(S),S}),E=f.edges.map(I=>v(_({},I),{id:String(x++),selected:!0,source:p.get(I.source)||I.source,target:p.get(I.target)||I.target})),N=[...h.map(I=>v(_({},I),{selected:!1})),...T],g=[...i().map(I=>v(_({},I),{selected:!1})),...E];r(N),a(g),t("forceSave",{nodes:N,edges:g})};return document.addEventListener("copy",l,!0),document.addEventListener("paste",c,!0),()=>{document.removeEventListener("copy",l,!0),document.removeEventListener("paste",c,!0)}},[n,r,i,a,s,e,o,t])};import{useTranslation as i0}from"@produto-lecom/lecom-ui";import{useReactFlow as s0}from"@xyflow/react";import{useState as a0}from"react";var l0=50,jd=({nodes:e,setNodes:t,setEdges:o,saveHistory:n})=>{let{draggableNode:r,setDraggableNode:i}=ko(),{t:a}=i0(),{getInternalNode:s,getNodes:l,getEdges:c,screenToFlowPosition:d}=s0(),{getNextId:u}=Je(),{setIsDragging:f}=ee(),{getInternalNodes:p}=Xr(),{rebuildIndex:h,forceRebuildIndex:y}=br(),[m,x]=a0(null),T=(M,O,P)=>{var H;if(M.parentId!==O)return null;let C=P.filter(k=>k.id!==M.id&&k.parentId===O&&k.type==="LANE").sort((k,G)=>k.position.y-G.position.y);if(C.length===0)return null;let F=(H=P.find(k=>k.id===M.id))!=null?H:M,R=C.find(k=>F.position.y<k.position.y);return R?{draggedLaneId:M.id,beforeLaneId:R.id}:{draggedLaneId:M.id,afterLaneId:C[C.length-1].id}},E=(M,O=!1,P)=>{let C=O?"node-drop-target-error":"node-drop-target",F=O?"node-drop-target-lane-error":"node-drop-target-lane";t(R=>{var k;let H=(k=P==null?void 0:P(R))!=null?k:null;return R.map(G=>{let B=[];return G.id===M&&B.push(C),M!==void 0&&G.parentId===M&&G.type==="LANE"&&G.id!==(H==null?void 0:H.draggedLaneId)&&B.push(F),G.id===(H==null?void 0:H.draggedLaneId)&&B.push("lane-reorder-dragging"),G.id===(H==null?void 0:H.beforeLaneId)&&B.push("lane-reorder-before"),G.id===(H==null?void 0:H.afterLaneId)&&B.push("lane-reorder-after"),v(_({},G),{className:B.join(" ")})})})},N=(M,O)=>{let P=p();if(M.type==="LANE"){if(O){E();return}let k=P.filter(K=>K.id!==M.id&&K.type==="LANE"&&!K.parentId),G=Xo(M,k);if(!G){E();return}if(Xt({parentId:G.id,nodes:e,excludeTypes:["LANE"]})){E(G.id,!0);return}E(G.id,!1,K=>T(M,G.id,K));return}let F=P.filter(k=>k.id!==M.id&&k.type==="LANE"),R=Xo(M,F);if(!R){E();return}if(Xt({parentId:R.id,nodes:e,includeTypes:["LANE"]})){E();return}E(R.id)},b=M=>{let O=s(M.id),P=M.type==="LANE"&&Xt({parentId:M.id,nodes:e,includeTypes:["LANE"]});N(O,P)},g=M=>M.map(O=>v(_({},O),{className:void 0})),w=M=>M.some(P=>P.dragging)?M.map(P=>P.dragging?v(_({},P),{dragging:!1}):P):M,A=(M,O)=>{let P=0;for(let C of O){if(C.id===M||C.parentId||C.type==="LANE")continue;let F=$e(C),R=F.y+F.h;P=Math.max(P,R)}return P+l0},I=(M,O)=>{if(!Pi(M,O))return O;let P=A(M,O);return O.map(C=>C.id===M?v(_({},C),{position:v(_({},C.position),{y:P})}):C)},D=M=>{if(M.preventDefault(),M.dataTransfer.dropEffect="move",!(r!=null&&r.type))return;let O=d({x:M.clientX,y:M.clientY}),P={id:"__sidebar_drag__",type:r.type,position:O,measured:{width:1,height:1},internals:{positionAbsolute:O}};N(P,!1)},S=M=>{let O=M.relatedTarget;(!O||!M.currentTarget.contains(O))&&E()},L=(M,O)=>{M.preventDefault(),b(O)},z=(M,O,P)=>{var B,K;let C=[...P],F=O.parentId?O.parentId:O.id;if(M.parentId===O.id)return C=ki(M,O,C),C=Et(C),C=Ut(F,C),g(C);if(M.type==="LANE"){if(Xt({parentId:O.id,nodes:C,excludeTypes:["LANE"]})){let Y=yr(O),te=50,ne=50;return C.map(J=>{var le,de;return J.id===M.id?v(_({},J),{position:{x:(le=m==null?void 0:m.x)!=null?le:Y.x+te,y:(de=m==null?void 0:m.y)!=null?de:Y.y2+ne}}):J})}let Z=C.filter(Y=>Y.parentId===O.id).reduce((Y,te)=>{var ne,J;return Y+((J=(ne=te.measured)==null?void 0:ne.height)!=null?J:0)},0),j={x:re.HEADER_WIDTH,y:Z};return C=C.map(Y=>Y.id===M.id?v(_({},Y),{parentId:O.id,position:j,className:void 0}):v(_({},Y),{className:void 0})),C=Et(C),C=I(F,C),C}if(Xt({parentId:O.id,nodes:C,includeTypes:["LANE"]})){let W;if(M.parentId){let X=s(M.parentId),{x:Z,y:j}=$e(X);W={x:Z+((B=M.position.x)!=null?B:0),y:j+((K=M.position.y)!=null?K:0)}}return C=C.map(X=>X.id===M.id?v(_({},X),{position:W!=null?W:X.position,parentId:void 0,className:void 0}):v(_({},X),{className:void 0})),C=Ut(F,C),C}let k=qs(M,O);C=C.map(W=>W.id===M.id?v(_({},W),{parentId:O.id,position:k,className:void 0}):v(_({},W),{className:void 0}));let G=C.find(W=>W.id===M.id);return C=ki(G,O,C),C=Et(C),C=Ut(F,C),C},q=M=>{if(M.preventDefault(),!(r!=null&&r.type))return;if(!St(r.type,l())){f(!1),i(null);return}let O=d({x:M.clientX,y:M.clientY}),P={width:ae[r.type].MIN_WIDTH,height:ae[r.type].MIN_HEIGHT},C=u(),F={id:String(C),type:r.type,position:O,measured:P,data:{label:r.type==="TASK"?$r(e,a("bpmn.task.label.prefix")):"",variant:r.variant,attribute:r.attribute},selected:!0},R=v(_({},F),{internals:{positionAbsolute:O}}),H=v(_({},R),{measured:{width:1,height:1}}),k=p(),G=r.type==="LANE",B=k.filter(Y=>G?Y.type==="LANE"&&!Y.parentId:Y.type==="LANE"),K=Xo(H,B),W=[...k.map(Y=>v(_({},Y),{selected:!1})),R];K&&(W=z(R,K,W)),W=Ft(W),G&&!K&&(W=I(R.id,W)),W=g(W),t(W),y();let X=M.dataTransfer.getData("sourceId"),Z=c(),j=Z;if(X){let Y={id:String(C+1),source:X,target:F.id},te=r.type==="ANNOTATION"?_(_({},Y),Io):_(_({},Y),qe);j=Z.concat(te),o(j)}n("forceSave",{nodes:W,edges:j}),f(!1),i(null)},Q=async(M,O,P)=>{let C=[...p()],F=new Set;P.forEach(k=>{let G=s(k.id),B=k.type==="LANE",K=C.filter(X=>X.id!==k.id&&(B?X.type==="LANE"&&!X.parentId:X.type==="LANE")),W=Xo(G,K);if(W){if(B&&Xt({parentId:k.id,nodes:C,includeTypes:["LANE"]})){k.parentId&&(C=$(k,C),F.add(k.id));return}C=z(G,W,C);return}k.parentId&&(C=$(k,C),k.type==="LANE"&&F.add(k.id))}),C=w(C);let R=P.filter(k=>k.type==="LANE"&&!k.parentId).map(k=>k.id);for(let k of R)Pi(k,C)&&m&&(C=C.map(G=>G.id===k?v(_({},G),{position:_({},m)}):G));for(let k of F)C=I(k,C);if(P.some(k=>k.type!=="LANE"&&!k.parentId)){let k=C.filter(G=>G.type==="LANE"&&!G.parentId).map(G=>G.id);for(let G of k)C=Ut(G,C)}C=Ft(C),C=g(C),t(C),h(C),x(null)},U=(M,O)=>{x({x:O.position.x,y:O.position.y})},$=(M,O)=>{var K,W,X,Z,j,Y,te,ne;let P=s(M.parentId);if(!P)return O;let C=M.type==="LANE",F=O.filter(J=>J.parentId===P.id&&J.id!==M.id),R=F.filter(J=>J.type==="LANE"),H;if(C&&R.length===0)H=re.MIN_HEIGHT;else if(C){let J=(W=(K=M.measured)==null?void 0:K.height)!=null?W:re.MIN_HEIGHT;H=((Z=(X=P.measured)==null?void 0:X.height)!=null?Z:re.MIN_HEIGHT)-J,H=Math.max(re.MIN_HEIGHT,H)}else H=F.length>0?F.reduce((J,le)=>{var de,ue;return J+((ue=(de=le.measured)==null?void 0:de.height)!=null?ue:0)},0)+he:Math.max(re.MIN_HEIGHT,(Y=(j=P.measured)==null?void 0:j.height)!=null?Y:0);let{x:k,y:G}=$e(P),B={x:k+((te=M.position.x)!=null?te:0),y:G+((ne=M.position.y)!=null?ne:0)};return O=O.map(J=>J.id===M.id?v(_({},J),{position:B,parentId:void 0}):J.id===P.id?v(_({},J),{height:H,measured:v(_({},J.measured),{height:H})}):J),O=Et(O),O};return{onDragOver:D,onDragLeave:S,onDrop:q,onNodeDrag:L,onNodeDragStart:U,onNodeDragStop:Q}};import{useReactFlow as c0}from"@xyflow/react";import{useTranslation as d0}from"@produto-lecom/lecom-ui";import{useEffect as u0}from"react";var p0=30,f0=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},m0=e=>!f0(e.target),eu=({offset:e=p0,saveHistory:t})=>{let{t:o}=d0(),{getNodes:n,setNodes:r,getEdges:i,setEdges:a}=c0(),{getNextId:s}=Je();u0(()=>{let l=c=>{if(c.ctrlKey&&c.key.toLowerCase()==="d"&&m0(c)){c.preventDefault(),c.stopPropagation();let d=n(),u=i(),f=d.filter(g=>g.selected);if(!f.length)return;let p=new Map,h=[],y=f.filter(g=>St(g.type,d));if(y.length===0)return;let m=u.filter(g=>y.some(w=>w.id===g.source)&&y.some(w=>w.id===g.target)),x=s(),T=y.map(g=>{var I;let w=String(x++);p.set(g.id,w);let A=v(_({},g),{id:w,selected:!0,position:{x:g.position.x+e,y:g.position.y+e}});if(g.type==="TASK"){let D=(I=g.data)==null?void 0:I.label,S=Ro(D||o("bpmn.task.label.prefix"),[...d,...h]);A.data=v(_({},g.data),{label:S})}return h.push(A),A}),E=m.map(g=>v(_({},g),{id:String(x++),selected:!0,source:p.get(g.source)||g.source,target:p.get(g.target)||g.target})),N=[...d.map(g=>v(_({},g),{selected:!1})),...T],b=[...u.map(g=>v(_({},g),{selected:!1})),...E];r(N),a(b),t("forceSave",{nodes:N,edges:b})}};return document.addEventListener("keydown",l,!0),()=>{document.removeEventListener("keydown",l,!0)}},[n,r,i,a,s,e,o,t])};import{useEffect as g0,useRef as tu}from"react";import{useReactFlow as h0}from"@xyflow/react";var y0=20,x0=50,Nn={UP:"ArrowUp",DOWN:"ArrowDown",LEFT:"ArrowLeft",RIGHT:"ArrowRight"},E0=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},ou=e=>{let{getNodes:t}=h0(),{mode:o,isMoveTool:n}=ee(),r=tu(0),i=tu(new Map);g0(()=>{let a=s=>{if(o!=="edit"||!n||E0(s.target)||!Object.values(Nn).includes(s.key))return;let u=t().filter(T=>T.selected);if(u.length===0){i.current.clear();return}s.preventDefault();let f=Date.now(),p=f-r.current<500;r.current=f;let h=s.shiftKey?x0:y0,y=0,m=0;switch(s.key){case Nn.UP:m=-h;break;case Nn.DOWN:m=h;break;case Nn.LEFT:y=-h;break;case Nn.RIGHT:y=h;break}let x=u.map(T=>{let E=i.current.get(T.id);(!p||!E)&&(E={x:T.position.x,y:T.position.y});let N={x:E.x+y,y:E.y+m};return i.current.set(T.id,N),{id:T.id,dragging:!0,type:"position",position:N}});e&&e(x)};return window.addEventListener("keydown",a),()=>{window.removeEventListener("keydown",a)}},[t,e,o,n])};import{useReactFlow as _0}from"@xyflow/react";var ru={"start-event":"START_EVENT","end-event":"END_EVENT",task:"TASK","gateway-exclusive":"GATEWAY"},iu={"start-event":"","end-event":"",task:"","gateway-exclusive":"EXCLUSIVE"},nu=(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}},b0=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=nu(i[0],o),s=nu(i[1],o);a&&s&&n.push({sourceId:a.step,targetId:s.step,label:a.edgeLabel||s.edgeLabel||""})}),{components:o,connections:n}},su=e=>{let{components:t,connections:o}=b0(e);return{nodes:t,edges:o}};var au=()=>{let{setNodes:e,setEdges:t,fitView:o}=_0(),{getNextId:n}=Je();return{importFromLia:i=>{let a=typeof i=="string"?i:i.diagramXml||"",{nodes:s,edges:l}=su(a),c=[],d=new Map,u=!1,f=n();for(let[m,x]of Object.entries(s)){let T=String(f++),E=ru[x.type],N=iu[x.type];E==="START_EVENT"&&(u=!0),d.set(m,T);let b=ae[E].MIN_WIDTH,g=ae[E].MIN_HEIGHT;c.push({id:T,type:E,data:{label:x.label||"",variant:N,attribute:""},position:{x:0,y:0},width:b,height:g,measured:{width:b,height:g}})}let p=[];for(let m of l){let x=v(_({},qe),{id:String(f++),source:d.get(m.sourceId)||m.sourceId,target:d.get(m.targetId)||m.targetId});p.push(x)}if(!u&&c.length>0){let m=String(f++),x={id:m,type:"START_EVENT",data:{label:"",variant:"",attribute:""},position:{x:0,y:0},width:ae.START_EVENT.MIN_WIDTH,height:ae.START_EVENT.MIN_HEIGHT,measured:{width:ae.START_EVENT.MIN_WIDTH,height:ae.START_EVENT.MIN_HEIGHT}};c.unshift(x);let T=c[1];if(T){let E=v(_({},qe),{id:String(f++),source:m,target:T.id});p.unshift(E)}}let{nodes:h,edges:y}=Vc(c,p);e(h),t(y),o({padding:Oo,minZoom:Ho,maxZoom:Vo})}}};import{useEffect as T0,useCallback as N0}from"react";var v0={origin:"*",debug:!1};function lu(e,t=v0){let{origin:o,debug:n}=t,r=N0((i,a)=>{let s={event:i,data:[i,{event:i,data:a}]};window.parent.postMessage(s,o||"*")},[o]);return T0(()=>{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 w0}from"@xyflow/react";import{useEffect as cu}from"react";var du=()=>{let e=w0(),{initialDiagram:t,setIsInitialized:o}=ee(),{importFromMxGraph:n}=Go();cu(()=>{t&&n(t)},[t,n,o]),cu(()=>{if(!e)return;(async()=>{await kn(),o(!0)})()},[e,o])};import{useCallback as uu}from"react";import{useReactFlow as I0}from"@xyflow/react";function pu(){let{setTaskStatuses:e,clearTaskStatuses:t,calculateFlowPath:o}=Kt(),{getEdges:n}=I0(),r=Yn(),i=uu(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=uu(()=>{t(),setTimeout(()=>{r()},0)},[t,r]);return{handleTasksStatus:i,handleClearTaskStatus:a}}import{useReactFlow as A0}from"@xyflow/react";import{useCallback as bt,useState as C0,useEffect as fu}from"react";import{useDebouncedCallback as S0}from"use-debounce";var M0=500,mu=100,gu=(e=!1)=>{let{getNodes:t,getEdges:o,setNodes:n,setEdges:r}=A0(),[i,a]=C0({history:[],currentStep:0}),{history:s,currentStep:l}=i,c=l>0,d=l<s.length-1,u=bt((b,g)=>{n(b[g].nodes),r(b[g].edges)},[n,r]),f=bt(()=>{if(l>0){let b=l-1;a(g=>v(_({},g),{currentStep:b})),u(s,b)}},[l,s,u]),p=bt(()=>{if(l<s.length-1){let b=l+1;a(g=>v(_({},g),{currentStep:b})),u(s,b)}},[s,l,u]),h=bt(b=>{a(g=>{let w=g.history[g.currentStep];if(w&&JSON.stringify(w)===JSON.stringify(b))return g;let D=[...g.history.slice(0,g.currentStep+1),b],S=D.length>mu?D.slice(D.length-mu):D;return{history:S,currentStep:S.length-1}})},[]),y=bt((b,g)=>{let w=b.map(I=>v(_({},I),{selected:!1,className:"",data:v(_({},I.data),{hasError:!1})})),A=g.map(I=>v(_({},I),{data:v(_({},I.data),{hasError:!1})}));return{nodes:Ft(w),edges:A}},[]),m=bt(()=>y(t(),o()),[t,o,y]),x=S0(()=>{let b=m();h(b)},M0),T=bt((b,g)=>{if(!e)return;if(s.length===0){let I=m();a({history:[I],currentStep:0})}if(b==="forceSave"){if(g){h(y(g.nodes,g.edges));return}x();return}b.some(I=>I.type==="select")||b.some(I=>I.type==="position"&&I.dragging)||x()},[e,x,s.length,m,h,y]);fu(()=>{if(e&&s.length===0){let b=m();a({history:[b],currentStep:0})}},[e,s.length,m]);let E=bt(b=>{a({history:b||[],currentStep:0})},[]),N=bt(()=>{a({history:[],currentStep:0})},[]);return fu(()=>{let b=g=>{(g.ctrlKey||g.metaKey)&&(g.shiftKey&&g.key.toLowerCase()==="z"?(g.preventDefault(),p()):g.key.toLowerCase()==="z"&&(g.preventDefault(),f()))};return document.addEventListener("keydown",b),()=>{document.removeEventListener("keydown",b)}},[f,p]),{history:s,undo:f,redo:p,canUndo:c,canRedo:d,saveHistory:T,resetHistory:E,clearHistory:N}};var hu=()=>{let{t:e}=P0(),[t,o,n]=k0([]),[r,i,a]=L0([]),{getNodes:s,getNode:l}=D0(),{toast:c}=Ge(),d=O0(),{instanceId:u,isInitialized:f,setIsConnecting:p,setIsMultipleSelection:h,onElementClick:y}=ee(),{updateHelperLines:m,HelperLines:x}=br(),{undo:T,redo:E,canUndo:N,canRedo:b,saveHistory:g}=gu(f),{onNodeDrag:w,onDrop:A,onDragOver:I,onDragLeave:D,onNodeDragStop:S,onNodeDragStart:L}=jd({nodes:t,setNodes:o,setEdges:i,saveHistory:g}),{isValidConnection:z,onConnect:q,onReconnect:Q,onReconnectStart:U,onReconnectEnd:$,setReconnectingEdge:M,clearReconnectingEdge:O}=Gd({setEdges:i,saveHistory:g}),{handleValidationComplete:P,clearValidation:C,dismissValidationPanel:F,validateDiagram:R,getIsClearingValidation:H}=qd(),{importFromLia:k}=au(),{handleTasksStatus:G,handleClearTaskStatus:B}=pu(),{clearPathEdges:K}=Kt(),{emitElementChanges:W,handleNodeChanges:X,handleEdgeChanges:Z}=ei(),j=Yn();Qd({saveHistory:g}),eu({saveHistory:g}),du();let Y=_t(()=>{o([]),i([]),K(),setTimeout(j,0)},[o,i,K,j]);lu({LIA_CREATE_DIAGRAM:k,CLEAR_DIAGRAM:Y,TASKS_STATUS:G,CLEAR_TASKS_STATUS:B});let{selectElements:te,clearSelection:ne}=Mt(),{importFromMxGraph:J,exportToMxGraph:le}=Go(),{configureElement:de,getConfigureElement:ue}=Cr(),xe=_t(()=>t.length+r.length,[t,r]);H0(()=>(dt.set(u,{importFromMxGraph:J,exportToMxGraph:le,selectElements:te,clearSelection:ne,configureElement:de,getConfigureElement:ue,getElementsCount:xe,setReconnectingEdge:M,clearReconnectingEdge:O}),()=>{dt.delete(u)}),[u,J,le,te,ne,de,ue,xe,M,O]);let ge=_t((Te,Se)=>{if(Se.type!=="TASK"&&Se.type!=="GATEWAY")return;let Me=ue(Se.id);Me&&(y==null||y(Me))},[ue,y]),fe=_t((Te,Se)=>{if(Se.type!=="SEQUENCE_EDGE")return;let Me=l(Se.source),Nt=l(Se.target),{isFromStartEvent:An,isGatewayToGateway:Cn,isActiviyToAndGateway:Qe}=Vn(Me,Nt);if(!(!An&&!Cn&&!Qe))return;let Wt=ue(Se.id);Wt&&(y==null||y(Wt))},[ue,l,y]),ce=_t(Te=>{let Se=m(Te,t);n(Se),g(Te),H()||F(),X(Te)},[t,n,g,H,F,m,X]),we=_t(Te=>{a(Te),g(Te),H()||F(),Z(Te)},[a,g,H,F,Z]);ou(ce);let Oe=_t(({nodes:Te,edges:Se})=>{h(Te.length+Se.length>=2)},[h]);R0({onChange:Oe});let it=_t(async({nodes:Te})=>Te.some(Me=>Me.type==="LANE"&&t.some(Nt=>Nt.parentId===Me.id))?(c({variant:"error",title:e("validation.errors.title"),content:e("editor.toolbar.delete_pool_lane_error")}),!1):!0,[t,e,c]),pt=()=>{g("forceSave"),W(),F()},zt=()=>{p(!0)},Yt=()=>{p(!1),F()},In=_t(Te=>{let Se=new Set(Te.filter(Me=>Me.type==="LANE"&&!!Me.parentId).map(Me=>Me.parentId));Se.size!==0&&setTimeout(()=>{var An,Cn;let Me=s(),Nt=new Map(Me.map(Qe=>[Qe.id,Qe]));for(let Qe of Se){let lo=$t(Me.filter(co=>co.type==="LANE"&&co.parentId===Qe));if(lo.length===0)continue;let Wt=0;for(let co of lo)Nt.set(co.id,v(_({},co),{position:{x:re.HEADER_WIDTH,y:Wt}})),Wt+=(Cn=(An=co.measured)==null?void 0:An.height)!=null?Cn:0;let bi=Nt.get(Qe);bi&&Nt.set(Qe,v(_({},bi),{height:Wt,measured:v(_({},bi.measured),{height:Wt})}))}o(Me.map(Qe=>{var lo;return(lo=Nt.get(Qe.id))!=null?lo:Qe}))},0)},[s,o]);return{nodes:t,setNodes:o,edges:r,setEdges:i,events:{isValidConnection:z,onConnect:q,onReconnect:Q,onReconnectStart:U,onReconnectEnd:$,onDrop:A,onDragOver:I,onDragLeave:D,onNodeDrag:w,onNodeDragStop:S,onNodeDragStart:L,onNodeClick:ge,onEdgeClick:fe,onDropCapture:pt,onConnectStart:zt,onConnectEnd:Yt,onSelectionEnd:()=>setTimeout(()=>d.setState({nodesSelectionActive:!1}),0),onNodesChange:ce,onEdgesChange:we,onBeforeDelete:it,onNodesDelete:In},ui:{handleCloseValidationPanel:C},controls:{undo:T,redo:E,canUndo:N,canRedo:b},components:{HelperLines:x},actions:{saveHistory:g,selectElements:te,clearSelection:ne,exportToMxGraph:le,validateDiagram:R,handleValidationComplete:P,setReconnectingEdge:M,clearReconnectingEdge:O}}};import{jsx as yu}from"react/jsx-runtime";var ni=({id:e,className:t})=>yu("marker",{id:e,className:V("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:yu("path",{d:"M 0 0 L 10 5 L 0 10 Z"})});import{jsx as ri,jsxs as V0}from"react/jsx-runtime";var xu=()=>ri("svg",{style:{position:"absolute",top:0,left:0},children:V0("defs",{children:[ri(ni,{id:"sequence-edge-marker",className:"text-grey-500"}),ri(ni,{id:"sequence-edge-marker-hovered",className:"text-grey-800"}),ri(ni,{id:"sequence-edge-marker-highlighted",className:"text-blue-500"})]})});import{Tooltip as sE,TooltipContent as aE,TooltipTrigger as lE,useTranslation as cE}from"@produto-lecom/lecom-ui";import{useKeyPress as Hu,useReactFlow as Ax}from"@xyflow/react";import{Button as ui,Tooltip as pi,TooltipContent as fi,TooltipTrigger as mi,useTranslation as Cx}from"@produto-lecom/lecom-ui";import{HandIcon as Sx,ListCheckIcon as Mx,MapIcon as Px,MousePointerIcon as Lx}from"lucide-react";import{useCallback as bs,useEffect as Vu}from"react";import{Tooltip as rx,TooltipContent as ix,TooltipTrigger as sx,useTranslation as ax}from"@produto-lecom/lecom-ui";var vn=(E=>(E.START_EVENT="START_EVENT",E.END_EVENT="END_EVENT",E.TASK="TASK",E.SUBPROCESS="SUBPROCESS",E.GATEWAY="GATEWAY",E.LANE="LANE",E.ANNOTATION="ANNOTATION",E.CONNECTION="CONNECTION",E.INTERMEDIATE_EVENT="INTERMEDIATE_EVENT",E.ACTIVITY="ACTIVITY",E.PROCESS_INTERFACE="PROCESS_INTERFACE",E.WORKFLOW_INTERFACE="WORKFLOW_INTERFACE",E.VARIANT_ACTIVITY="VARIANT_ACTIVITY",E.AUTO_ACTIVITY="AUTO_ACTIVITY",E.DATA_STORE="DATA_STORE",E.DATA_OBJECT="DATA_OBJECT",E.DATA_OUTPUT="DATA_OUTPUT",E.DATA_INPUT="DATA_INPUT",E.MARKER="MARKER",E))(vn||{});import{Button as Z0,useTranslation as J0}from"@produto-lecom/lecom-ui";import{useReactFlow as Q0}from"@xyflow/react";var Eu=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 bu({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);ii(i,`${o}.csv`)}var ii=(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 _u(e){return e==null?void 0:e.replaceAll("&#xA;"," ")}var e3={START_EVENT:"START_EVENT",END_EVENT:"END_EVENT",TASK:"TASK",GATEWAY:"GATEWAY",ANNOTATION:"ANNOTATION"},Tu={script:"SCRIPT",subprocess:"SUBPROCESS"},Nu={"marker-loop":"LOOP"},vu={complex:"COMPLEX",none:"EXCLUSIVE",exclusive:"EXCLUSIVE",parallel:"PARALLEL",inclusive:"EXCLUSIVE"};var so=({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}}},B0=e=>{let{subType:t,style:o}=e._attributes,n="imported";return["none"].includes(t)||(n="adapted"),e.mxGeometry._attributes.width=ae.START_EVENT.MIN_WIDTH,e.mxGeometry._attributes.height=ae.START_EVENT.MIN_HEIGHT,{node:so({cell:e,type:"START_EVENT"}),status:n,originalType:o}},z0=e=>{let{subType:t,style:o}=e==null?void 0:e._attributes,n="imported";return["none"].includes(t)||(n="adapted"),e.mxGeometry._attributes.width=ae.END_EVENT.MIN_WIDTH,e.mxGeometry._attributes.height=ae.END_EVENT.MIN_HEIGHT,{node:so({cell:e,type:"END_EVENT"}),status:n,originalType:o}},Y0=(e,t)=>{let{id:o,subType:n,style:r}=e==null?void 0:e._attributes,i=Tu[n],a=t.get(o)||"",s=Nu[a]||"",l=s==="LOOP",c="imported";return!["script","none"].includes(n)&&!l&&(c="adapted"),e.mxGeometry._attributes.width=vt(e.mxGeometry._attributes.width||0,ae.TASK.MIN_WIDTH),e.mxGeometry._attributes.height=vt(e.mxGeometry._attributes.height||0,ae.TASK.MIN_HEIGHT),{node:so({cell:e,type:"TASK",variant:i,attribute:s}),status:c,originalType:r}},W0=e=>{let{style:t,subType:o}=e==null?void 0:e._attributes,n=vu[o],r=["none","inclusive","event-based"],i="imported";return r.includes(o)&&(i="adapted"),e.mxGeometry._attributes.width=ae.GATEWAY.MIN_WIDTH,e.mxGeometry._attributes.height=ae.GATEWAY.MIN_HEIGHT,{node:so({cell:e,type:"GATEWAY",variant:n}),status:i,originalType:t}},F0=e=>{let{style:t}=e==null?void 0:e._attributes;return{node:so({cell:e,type:"LANE"}),status:"imported",originalType:t}},X0=e=>{let{style:t}=e==null?void 0:e._attributes;return e.mxGeometry._attributes.width=vt(e.mxGeometry._attributes.width||0,ae.ANNOTATION.MIN_WIDTH),e.mxGeometry._attributes.height=vt(e.mxGeometry._attributes.height||0,ae.ANNOTATION.MIN_HEIGHT),{node:so({cell:e,type:"ANNOTATION"}),status:"imported",originalType:t}},wu=e=>{let{style:t}=e==null?void 0:e._attributes;return e.mxGeometry._attributes.width=ae.UNSUPPORTED.MIN_WIDTH,e.mxGeometry._attributes.height=ae.UNSUPPORTED.MIN_HEIGHT,{node:so({cell:e,type:"UNSUPPORTED"}),status:"unsupported",originalType:t}},Iu=(e,t)=>{let{id:o,source:n,target:r,value:i}=e._attributes;return v(_({},qe),{id:o,source:t.get(n)||n,target:t.get(r)||r,data:{label:i||""}})},Au={TASK:Y0,GATEWAY:W0,START_EVENT:B0,END_EVENT:z0,LANE:F0,ANNOTATION:X0};var U0=e=>{let t=new Map,o=Object.values(vn),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=Au[l]||wu,{node:d,status:u,originalType:f}=c(s,r);a.push(d),i.push({originalType:f,type:d.type,variant:d.data.variant,value:_u(d.data.label),status:u})}return{nodes:a,governanceIdToNodeIdMap:t,summary:i}},$0=(e,t)=>e.filter(r=>{var i;return(i=r._attributes)==null?void 0:i.edge}).map(r=>Iu(r,t)),K0=e=>{let{mxGraphModel:t}=e,{nodes:o,governanceIdToNodeIdMap:n,summary:r}=U0(t.root.mxCell),i=$0(t.root.mxCell,n);return{nodes:o,edges:i,summary:r}},q0=async e=>{let t=await Eu(e),o=Fr(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}},Cu=async e=>{try{let t=await q0(e),{nodes:o,edges:n,summary:r}=K0(t)||{};return{nodes:o,edges:n,summary:r}}catch(t){throw t}};import{jsx as j0}from"react/jsx-runtime";var Su=()=>{let{t:e}=J0(),{toast:t}=Ge(),{setNodes:o,setEdges:n,fitView:r}=Q0(),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:j0(Z0,{size:"small",variant:"ghost",onClick:()=>bu({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 Cu(s);if(o(f=>f.concat(l)),n(f=>f.concat(c)),r({padding:Oo,minZoom:Ho,maxZoom:Vo}),d.some(f=>f.status==="unsupported")){i(d);return}t({variant:"success",content:e("adapter.governance.success.default")})}catch(l){let c=l instanceof Error?l.message:"DEFAULT";t({variant:"error",content:e(`adapter.governance.error.${c}`)})}}}};import{Button as ex}from"@produto-lecom/lecom-ui";import{useRef as tx}from"react";import{Fragment as ox,jsx as Mu,jsxs as nx}from"react/jsx-runtime";var Pu=s=>{var l=s,{children:e,accept:t="*",multiple:o=!1,disabled:n=!1,onClick:r,onFilesSelected:i}=l,a=st(l,["children","accept","multiple","disabled","onClick","onFilesSelected"]);let c=tx(null),d=f=>{let p=f.target.files;p!=null&&p.length&&i(p),c.current&&(c.current.value="")};return nx(ox,{children:[Mu(ex,v(_({disabled:n,onClick:f=>{var p;(p=c.current)==null||p.click(),r==null||r(f)}},a),{children:e})),Mu("input",{type:"file",ref:c,className:"sr-only",accept:t,multiple:o,disabled:n,onChange:d})]})};import{jsx as si,jsxs as lx}from"react/jsx-runtime";var Lu=({disabled:e=!1})=>{let{t}=ax(),{toast:o}=Ge(),{importFromGovernance:n}=Su(),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 lx(rx,{children:[si(sx,{asChild:!0,children:si(Pu,{className:"[&>svg]:size-7 p-0",variant:"ghost",size:"small",color:"grey",iconButton:!0,accept:".mdr",disabled:e,onClick:r,onFilesSelected:i,children:si(Ds,{})})}),si(ix,{color:"black",children:t("editor.controls.actions.import_governance")})]})};import{jsx as cx}from"react/jsx-runtime";var ys=({shortcut:e})=>cx("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 yx,DropdownMenu as xx,DropdownMenuContent as Ex,DropdownMenuItem as Es,DropdownMenuTrigger as bx,Tooltip as li,TooltipContent as ci,TooltipTrigger as di,useTranslation as _x}from"@produto-lecom/lecom-ui";import{FileCodeIcon as Tx,FileImageIcon as Nx,FolderOutputIcon as vx,PrinterIcon as wx}from"lucide-react";import{useState as Ix}from"react";import{useTranslation as dx}from"@produto-lecom/lecom-ui";import{useReactFlow as ux}from"@xyflow/react";import{toPng as ku,toSvg as px}from"html-to-image";import{useState as fx}from"react";var mx=3,xs="diagram",ai=50,gx=96,hx=25.4,Ru=e=>e*hx/gx,Du=()=>{let{t:e}=dx(),{toast:t}=Ge(),{getNodes:o,getNodesBounds:n}=ux(),{clearSelection:r}=Mt(),[i,a]=fx({png:!1,html:!1,print:!1}),s=()=>{let f=rs(o()),p=n(f),h=p.width+ai*2,y=p.height+ai*2,m=ai-p.x,x=ai-p.y;return{width:h,height:y,style:{width:`${h}px`,height:`${y}px`,transform:`translate(${m}px, ${x}px)`,transformOrigin:"top left"}}},l=async(f,p)=>{a(h=>v(_({},h),{[p]:!0})),await r();try{if(rs(o()).length===0){t({content:e("editor.controls.actions.export.feedback.empty"),variant:"warning"});return}let y=Bc();if(!y)throw new Error("Flow element not found");let m=s();return await f(y,m)}catch(h){console.error("Diagram export failed",h),t({content:e("editor.controls.actions.export.feedback.error"),variant:"error"})}finally{a(h=>v(_({},h),{[p]:!1}))}};return{exportAsPng:async(f=xs)=>{await l(async(p,h)=>{let y=await ku(p,v(_({},h),{backgroundColor:"#fcfcfc",skipFonts:!0}));ii(y,`${f}.png`)},"png")},exportAsHtml:async(f=xs)=>{await l(async(p,h)=>{let y=await px(p,v(_({},h),{backgroundColor:"#fcfcfc",skipFonts:!0})),m=`
39
+ </mxGraphModel>`,qc=(e,t)=>{if(!e.length&&!t.length)return bn;let o=[...e.map(r=>r.id),...t.map(r=>r.id)];return Math.max(...o.map(r=>Number(r)))};var Ch=e=>{let t=Object.values(En),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},Sh=(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},Mh=(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},Ph=(e,t)=>{let o=[];return e.forEach(n=>{let r=zc(n,t);o.push(r)}),o},Lh=(e=[],t=[],o)=>{let n=Mh(e,o),r=Ph(t,e);return{mxGraphModel:{root:{_attributes:{version:"1.1",lastId:o},mxCell:[{_attributes:{id:"0"}},{_attributes:{id:"1",parent:"0"}},...n,...r]}}}},Zc=(e=[],t=[],o)=>{let n=Lh(e,t,o);return kc(JSON.stringify(n),{compact:!0,spaces:0})},Jc=async e=>{var c,d,u,m,p;let t=await Ur(e),o=((d=(c=t==null?void 0:t.mxGraphModel)==null?void 0:c.root)==null?void 0:d.mxCell)||[],n=Number(((p=(m=(u=t==null?void 0:t.mxGraphModel)==null?void 0:u.root)==null?void 0:m._attributes)==null?void 0:p.lastId)||bn),r=Ch(o),i=Sh(o,r),a=Uc(r),{nodes:s,edges:l}=na(a,i);return{lastElementId:n,edges:l,nodes:Zt(s)}};import{Position as Yt,useConnection as gy,useReactFlow as hy}from"@xyflow/react";import{useCallback as ds}from"react";import{Handle as Qc,useReactFlow as kh}from"@xyflow/react";import{jsx as jc}from"react/jsx-runtime";var te=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 jc(Qc,_({type:e,position:t,className:G("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))},Be=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}=kh(),m=(()=>{if(n!=="source")return!1;let p=c();if(t==="TASK")return p.filter(h=>h.source===e).length>=2;if(t==="GATEWAY"&&o==="EXCLUSIVE")return p.filter(h=>h.source===e).length>=2;if(t==="START_EVENT"){let g=d();return p.filter(f=>{if(f.source!==e)return!1;let y=g.find(N=>N.id===f.target);return(y==null?void 0:y.type)!=="ANNOTATION"}).length>=1}return!1})();return jc(Qc,_({type:n,position:r,className:G("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 ed}from"react";import{NodeResizeControl as td,ResizeControlVariant as Dh,useReactFlow as Oh,useStoreApi as Hh}from"@xyflow/react";import{useStoreApi as Rh}from"@xyflow/react";var $r=()=>{let e=Rh();return{getInternalNodes:()=>{let{nodeLookup:o}=e.getState();return Array.from(o.values())}}};import{Fragment as Bh,jsxs as zh}from"react/jsx-runtime";import{createElement as od}from"react";var Vh=["top","right","bottom","left"],Gh=["top-left","top-middle","top-right","right-middle","bottom-left","left-middle","bottom-right","bottom-middle"],nt=r=>{var i=r,{nodeId:e,isVisible:t,offset:o=8}=i,n=mt(i,["nodeId","isVisible","offset"]);let{getInternalNode:a,setNodes:s}=Oh(),{getInternalNodes:l}=$r(),{isMultipleSelection:c}=J(),d=Hh(),u=ed(0),m=ed([]),p=({y,width:N,height:E})=>{cancelAnimationFrame(u.current),u.current=requestAnimationFrame(()=>{var K,Y;if(!e)return;let{nodeLookup:T,onNodesChange:b}=d.getState(),x=T.get(e);if(!x||x.type!=="LANE")return;let w=!x.parentId,A=w?x.id:x.parentId;if(!A)return;let I=Array.from(T.values()).filter(X=>X.type==="LANE"&&X.parentId===A);if(!I.length)return;m.current.length===0&&(m.current=jt(I).map(X=>X.id));let D=m.current.map(X=>I.find(M=>M.id===X)).filter(Boolean),S=[],L=0,z=D.findIndex(X=>X.id===x.id),U=!w&&z>0&&Math.abs(y-x.position.y)>.5;for(let X=0;X<D.length;X++){let M=D[X],O=M.id===x.id,H=X===D.length-1;if(O){L=U?y+E:L+E;continue}let C=(Y=(K=M.measured)==null?void 0:K.height)!=null?Y:0,k=w?N-re.HEADER_WIDTH:N,P=C;w&&H&&(P=Math.max(re.MIN_HEIGHT,E-L)),U&&X===z-1&&(P=Math.max(re.MIN_HEIGHT,y-L)),S.push({id:M.id,type:"dimensions",dimensions:{width:k,height:P},setAttributes:!0}),S.push({id:M.id,type:"position",position:{x:re.HEADER_WIDTH,y:L}}),L+=P}w?S.push({id:A,type:"dimensions",dimensions:{width:N,height:E},setAttributes:!0}):S.push({id:A,type:"dimensions",dimensions:{width:N+re.HEADER_WIDTH,height:L},setAttributes:!0}),b==null||b(S)})},g=({y,width:N,height:E})=>{var x;if(cancelAnimationFrame(u.current),m.current=[],!e)return;let T=a(e);if(!T||T.type!=="LANE"&&!T.parentId)return;let b=[...l()];if(T.type!=="LANE"){b=b.map(w=>w.id===e?v(_({},w),{width:N,height:E,measured:{width:N,height:E}}):w),b=At(b),s(b);return}b=aa(T,N,E,b,y),b=At(b),b=Qt((x=T.parentId)!=null?x:T.id,b),s(b)};if(!(!c&&t))return null;let f={"--resize-offset":`${o}px`};return zh(Bh,{children:[Vh.map(y=>od(td,v(_({},n),{key:y,nodeId:e,position:y,variant:Dh.Line,className:"border-blue-400/90 border-dashed",style:f,onResize:(N,E)=>p(E),onResizeEnd:(N,E)=>g(E)}))),Gh.map(y=>od(td,v(_({},n),{key:y,nodeId:e,position:y,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:(N,E)=>p(E),onResizeEnd:(N,E)=>g(E)})))]})};import{NodeToolbar as iy,useReactFlow as sy}from"@xyflow/react";import{Button as ay,Tooltip as ly,TooltipContent as cy,TooltipTrigger as dy,useTranslation as uy}from"@produto-lecom/lecom-ui";import{useCallback as cs,useEffect as py,useRef as Kr,useState as fy}from"react";import{create as Yh}from"zustand";var Vo=Yh(e=>({draggableNode:null,setDraggableNode:t=>{e({draggableNode:t})}}));import{useEffect as Wh,useState as Fh}from"react";var nd=(e,t=!1)=>{let[o,n]=Fh({width:0,height:0});return Wh(()=>{if(e.current&&t){let r=e.current.getBoundingClientRect();n({width:r.width,height:r.height})}},[t,e]),{dimensions:o}};import{Position as _n,useReactFlow as Xh}from"@xyflow/react";import{useMemo as Uh}from"react";var $h=120,Kh=12,rd=(e,t=!1,o)=>{let{getNode:n,getViewport:r}=Xh(),{instanceId:i}=J();return Uh(()=>{var p,g;if(!t)return{position:_n.Right,align:"start"};let a=n(e);if(!a)return{position:_n.Right,align:"start"};let s=r(),l=a.position.x*s.zoom+s.x,c=(((p=a.measured)==null?void 0:p.width)||a.width||100)*s.zoom,d=(g=document.getElementById(`modeler-${i}`))==null?void 0:g.clientWidth;if(!d)return{position:_n.Right,align:"start"};let u=(o==null?void 0:o.width)||$h;return{position:l+c+u+Kh>d?_n.Left:_n.Right}},[i,e,t,o,n,r])};import{useNodesData as qh,useReactFlow as Zh}from"@xyflow/react";import{Button as id,DropdownMenu as Jh,DropdownMenuContent as Qh,DropdownMenuGroup as jh,DropdownMenuItem as ey,DropdownMenuLabel as ty,DropdownMenuTrigger as oy,Tooltip as ss,TooltipContent as as,TooltipTrigger as ls,useTranslation as ny}from"@produto-lecom/lecom-ui";import{WrenchIcon as ry}from"lucide-react";import{jsx as He,jsxs as lo}from"react/jsx-runtime";var sd=({nodeId:e})=>{let{t}=ny(),{updateNodeData:o,getEdges:n,getNode:r}=Zh(),i=qh(e),s=n().filter(p=>p.source===e).some(p=>{let g=r(p.target);return(g==null?void 0:g.type)==="END_EVENT"}),l=(i==null?void 0:i.data.variant)==="SUBPROCESS",c=u=>{o(e,{variant:(i==null?void 0:i.data.variant)===u?"":u})},d=u=>{o(e,{attribute:(i==null?void 0:i.data.attribute)===u?"":u})};return lo(Jh,{children:[lo(ss,{children:[He(ls,{asChild:!0,children:He(oy,{asChild:!0,children:He(id,{variant:"ghost",color:"grey",size:"small",iconButton:!0,children:He(ry,{})})})}),He(as,{color:"black",children:t("bpmn.task.menu.title")})]}),lo(Qh,{align:"start",className:"w-60 bg-white text-grey-600",children:[lo(ty,{className:"flex items-center gap-1",children:[He("div",{className:"flex-1 body-medium-500",children:t("bpmn.task.menu.title")}),He("div",{className:"flex items-center gap-1",children:Object.entries(Bn).map(([u,m])=>{let p=u==="LOOP"&&(s||l),h=(()=>{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 lo(ss,{children:[He(ls,{asChild:!0,children:He(id,{variant:"ghost",color:"grey",size:"small",iconButton:!0,disabled:p,className:G({"bg-grey-100 text-blue-500":(i==null?void 0:i.data.attribute)===u,"opacity-50 cursor-not-allowed":p}),onClick:p?void 0:()=>d(u),children:He(m.icon,{className:"stroke-inherit"})})}),h&&He(as,{color:"black",children:h})]},u)})})]}),He(jh,{children:lo(ss,{children:[He(ls,{asChild:!0,children:He("div",{className:G({"cursor-not-allowed":s}),children:lo(ey,{className:G({"bg-grey-100 text-blue-500":(i==null?void 0:i.data.variant)==="SCRIPT","opacity-50":s}),disabled:s,onClick:()=>c("SCRIPT"),children:[He(Gn.SCRIPT.icon,{className:"stroke-current"}),t(`bpmn.task.variant.${"SCRIPT".toLowerCase()}`)]})})}),s&&He(as,{color:"black",children:t("editor.task_menu.script_not_allowed_when_connected_to_end")})]})})]})]})};import{jsx as Me,jsxs as ad}from"react/jsx-runtime";var co={START_EVENT:{type:"START_EVENT",icon:$o,label:"bpmn.start_event.variant.default"},END_EVENT:{type:"END_EVENT",icon:ho,label:"bpmn.end_event.variant.default"},TASK:{type:"TASK",icon:$o,label:"bpmn.task.variant.default"},ANNOTATION:{type:"ANNOTATION",icon:Dn,label:"bpmn.annotation.variant.default"}},my={EXCLUSIVE:{type:"GATEWAY",variant:"EXCLUSIVE",icon:xo,label:"bpmn.gateway.variant.exclusive"},PARALLEL:{type:"GATEWAY",variant:"PARALLEL",icon:Eo,label:"bpmn.gateway.variant.parallel"},COMPLEX:{type:"GATEWAY",variant:"COMPLEX",icon:yo,label:"bpmn.gateway.variant.complex"}},Xe=({nodeId:e,nodeType:t,nodeVariant:o})=>{let n=Kr(null),r=Kr(null),{t:i}=uy(),{setDraggableNode:a}=Vo(),{getEdges:s,getNodes:l,getNode:c}=sy(),{setIsDragging:d,mode:u,isConnecting:m,isDragging:p,isMultipleSelection:g}=J(),h=c(e),f=!!(h!=null&&h.selected)&&!h.dragging&&!m&&!p&&!g,{dimensions:y}=nd(n,f),{position:N}=rd(e,f,y),[E,T]=fy(void 0),b=l(),x=s(),w=o==="SUBPROCESS",A=Kr(null),I=Kr(!1),D=cs(()=>{A.current!==null&&(clearTimeout(A.current),A.current=null),I.current=!1,d(!1),a(null),T(void 0)},[d,a]);py(()=>{let P=R=>{I.current&&R.buttons===0&&D()};return document.addEventListener("dragend",D),document.addEventListener("mousemove",P),()=>{document.removeEventListener("dragend",D),document.removeEventListener("mousemove",P)}},[D]);let S=cs((P,R)=>{I.current=!0,d(!1),a({type:R.type,variant:R.variant,attribute:R.attribute,icon:R.icon}),R.icon&&T(Me(R.icon,{})),P.dataTransfer.effectAllowed="move",P.dataTransfer.setData("sourceId",e),r.current&&P.dataTransfer.setDragImage(r.current,10,10),A.current=setTimeout(()=>{A.current=null,d(!0)},100)},[e,a,d]),L=cs(()=>{D()},[D]),z=[{component:Me(Rr,{elementId:e})}],U=()=>{if(u==="view")return[];let P=!x.some(R=>{var V;return R.source===e&&((V=b.find(B=>B.id===R.target))==null?void 0:V.type)!=="ANNOTATION"});return[{component:Me(Ao,{nodeId:e,disabled:!P,tooltipMessage:P?void 0:i("editor.toolbar.start_event_limit_reached")})},co.TASK,co.ANNOTATION,...z]},K=()=>u==="view"?[{component:Me(Gt,{elementId:e})}]:[{component:Me(Gt,{elementId:e})},...w?[]:[{component:Me(sd,{nodeId:e})}],{component:Me(Ao,{nodeId:e})},co.TASK,...Object.values(my),...z],Y=()=>u==="view"?[{component:Me(Gt,{elementId:e})}]:[{component:Me(Gt,{elementId:e})},{component:Me(Ao,{nodeId:e})},co.TASK,co.ANNOTATION,...z],X=()=>u==="view"?[]:[co.ANNOTATION,...z],M=()=>u==="view"?[]:[{component:Me(Ao,{nodeId:e})},co.ANNOTATION,...z],O=()=>u==="view"?[]:[{component:Me(Ao,{nodeId:e})},...z],H=()=>u==="view"?[]:[...z],k=(P=>{switch(P){case"START_EVENT":return U();case"TASK":return K();case"GATEWAY":return Y();case"END_EVENT":return X();case"LANE":return M();case"ANNOTATION":return O();case"UNSUPPORTED":return H();default:return[]}})(t);if(!(k.length===0||u==="readonly"))return ad(iy,{position:N,align:"start",className:"-top-8",isVisible:f,children:[Me("div",{ref:n,className:"flex items-center gap-1 px-3 py-2 bg-white rounded-sm shadow-md",children:k.map((P,R)=>{if(P.component)return Me("div",{children:P.component},R);let V={sourceNodeType:t,targetNodeType:P.type,sourceNodeId:e,nodes:b,edges:x},B=dc(V),ee={gateway_limit_reached:i("editor.toolbar.gateway_limit_reached"),start_event_limit_reached:i("editor.toolbar.start_event_limit_reached"),start_event_already_exists:i("editor.toolbar.start_event_already_exists"),script_to_end_not_allowed:i("editor.toolbar.script_to_end_not_allowed"),loop_to_end_not_allowed:i("editor.toolbar.loop_to_end_not_allowed"),initial_activity_to_end_not_allowed:i("editor.toolbar.initial_activity_to_end_not_allowed"),final_activity_cannot_connect:i("editor.toolbar.final_activity_cannot_connect"),activity_has_outgoing_connections:i("editor.toolbar.activity_has_outgoing_connections"),task_limit_reached:i("editor.toolbar.task_limit_reached")},oe=B.shouldDisable&&B.reason?ee[B.reason]||i(P.label):i(P.label)||"";return ad(ly,{children:[Me(dy,{asChild:!0,children:Me(ay,{variant:"ghost",color:"grey",size:"small",iconButton:!0,draggable:!B.shouldDisable,disabled:B.shouldDisable,className:B.shouldDisable?"opacity-50 cursor-not-allowed":"",onDragStart:B.shouldDisable?void 0:q=>S(q,P),onDragEnd:B.shouldDisable?void 0:L,children:P.icon&&Me(P.icon,{size:16})})}),Me(cy,{color:"black",children:oe})]},R)})}),Me("div",{ref:r,className:"absolute w-0 h-0 top-0 left-0 z-[-1] bg-transparent",children:E})]})};import{Fragment as ld,jsx as lt,jsxs as us}from"react/jsx-runtime";var cd=({id:e,data:t,selected:o,dragging:n})=>{let{updateNodeData:r,setNodes:i}=hy(),{inProgress:a,fromNode:s}=gy(),{mode:l}=J(),c=a&&(s==null?void 0:s.id)!==e,d=ds(p=>{let N=p.split(`
40
+ `),E=N.reduce((w,A)=>Math.max(w,A.length),0),T=N.length,b=Math.max(No.MIN_WIDTH,E*7+32),x=Math.max(No.MIN_HEIGHT,T*20+24);i(w=>w.map(A=>A.id===e?v(_({},A),{width:b,height:x,style:v(_({},A.style),{width:b,height:x})}):A))},[e,i]),u=ds(p=>{r(e,{label:p}),d(p)},[e,r,d]),m=ds(p=>{d(p)},[d]);return us("div",{className:G("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:[lt(Oe,{value:t.label,className:"m-1 text-grey-600 text-left",onChange:u,onInput:m,skipFirstCharValidation:!0}),lt(Xe,{nodeId:e,nodeType:"ANNOTATION"}),l==="edit"&&lt(nt,{nodeId:e,minWidth:No.MIN_WIDTH,minHeight:No.MIN_HEIGHT,isVisible:!n&&o}),!a&&us(ld,{children:[lt(te,{type:"source",position:Yt.Left,id:"left"}),lt(te,{type:"source",position:Yt.Right,id:"right"}),lt(te,{type:"source",position:Yt.Top,id:"top"}),lt(te,{type:"source",position:Yt.Bottom,id:"bottom"})]}),(!a||c)&&us(ld,{children:[lt(te,{type:"target",position:Yt.Left,id:"left",className:G({"annotation-handle":c})}),lt(te,{type:"target",position:Yt.Right,id:"right",className:G({"annotation-handle":c})}),lt(te,{type:"target",position:Yt.Top,id:"top",className:G({"annotation-handle":c})}),lt(te,{type:"target",position:Yt.Bottom,id:"bottom",className:G({"annotation-handle":c})})]})]})};import{Position as Wt,useConnection as yy,useReactFlow as xy}from"@xyflow/react";import{useState as Ey}from"react";import{Fragment as dd,jsx as qe,jsxs as ps}from"react/jsx-runtime";var ud=({id:e,data:t,selected:o,dragging:n})=>{let{updateNodeData:r}=xy(),{inProgress:i,fromNode:a}=yy(),{mode:s,reconnectingEdgeId:l}=J(),[c,d]=Ey(!1),u=i&&(a==null?void 0:a.id)!==e||!!l,m=h=>{r(e,{label:h})},p=()=>{d(!0)},g=()=>{d(!1)};return ps("div",{className:"relative",onDoubleClick:p,children:[qe(ho,{className:G("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})}),qe("div",{className:"absolute mt-2 left-1/2 -translate-x-1/2 max-w-80 w-max",children:qe(Oe,{value:t.label,isEditing:c,onBlur:g,onChange:m})}),qe(Xe,{nodeId:e,nodeType:"END_EVENT"}),s==="edit"&&qe(nt,{nodeId:e,isVisible:!n&&o,minWidth:Wn.MIN_WIDTH,minHeight:Wn.MIN_HEIGHT,offset:4,keepAspectRatio:!0}),(!i||u)&&ps(dd,{children:[qe(te,{type:"target",position:Wt.Left,id:"left",className:G({"event-handle":u})}),qe(te,{type:"target",position:Wt.Right,id:"right",className:G({"event-handle":u})}),qe(te,{type:"target",position:Wt.Top,id:"top",className:G({"event-handle":u})}),qe(te,{type:"target",position:Wt.Bottom,id:"bottom",className:G({"event-handle":u})})]}),!i&&ps(dd,{children:[qe(te,{type:"source",position:Wt.Left,id:"left"}),qe(te,{type:"source",position:Wt.Right,id:"right"}),qe(te,{type:"source",position:Wt.Top,id:"top"}),qe(te,{type:"source",position:Wt.Bottom,id:"bottom"})]})]})};import{Position as Ft,useConnection as by,useReactFlow as _y}from"@xyflow/react";import{useCallback as Ny,useState as Ty}from"react";import{Fragment as pd,jsx as Ze,jsxs as fs}from"react/jsx-runtime";var fd=({id:e,data:t,selected:o,dragging:n})=>{let r=Mi[t.variant].icon,{updateNodeData:i}=_y(),{inProgress:a,fromNode:s}=by(),{mode:l,reconnectingEdgeId:c}=J(),[d,u]=Ty(!1),m=a&&(s==null?void 0:s.id)!==e||!!c,p=Ny(f=>{i(e,{label:f})},[e,i]),g=()=>{u(!0)},h=()=>{u(!1)};return fs("div",{className:"relative",onDoubleClick:g,children:[Ze(r,{className:G("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":o,"stroke-red-500 hover:stroke-red-600 drop-shadow-[0_0_3px_rgba(255,0,0,0.5)]":t.hasError})}),Ze("div",{className:"absolute mt-2 left-1/2 -translate-x-1/2 max-w-80 w-max",children:Ze(Oe,{value:t.label,isEditing:d,onBlur:h,onChange:p})}),Ze(Xe,{nodeId:e,nodeType:"GATEWAY"}),l==="edit"&&Ze(nt,{nodeId:e,isVisible:!n&&o,minWidth:Fn.MIN_WIDTH,minHeight:Fn.MIN_HEIGHT,offset:2,keepAspectRatio:!0}),(!a||m)&&fs(pd,{children:[Ze(te,{type:"target",position:Ft.Left,id:"left",className:G({"gateway-handle":m})}),Ze(te,{type:"target",position:Ft.Right,id:"right",className:G({"gateway-handle":m})}),Ze(te,{type:"target",position:Ft.Top,id:"top",className:G({"gateway-handle":m})}),Ze(te,{type:"target",position:Ft.Bottom,id:"bottom",className:G({"gateway-handle":m})})]}),!a&&fs(pd,{children:[Ze(Be,{type:"source",position:Ft.Left,id:"left",nodeId:e,nodeType:"GATEWAY",gatewayVariant:t.variant}),Ze(Be,{type:"source",position:Ft.Right,id:"right",nodeId:e,nodeType:"GATEWAY",gatewayVariant:t.variant}),Ze(Be,{type:"source",position:Ft.Top,id:"top",nodeId:e,nodeType:"GATEWAY",gatewayVariant:t.variant}),Ze(Be,{type:"source",position:Ft.Bottom,id:"bottom",nodeId:e,nodeType:"GATEWAY",gatewayVariant:t.variant})]})]})};import{useNodesData as sM,useReactFlow as aM}from"@xyflow/react";import{Button as cM,DropdownMenu as dM,DropdownMenuContent as uM,DropdownMenuGroup as pM,DropdownMenuItem as fM,DropdownMenuLabel as mM,DropdownMenuTrigger as gM,Tooltip as hM,TooltipContent as yM,TooltipTrigger as xM,useTranslation as EM}from"@produto-lecom/lecom-ui";import{WrenchIcon as _M}from"lucide-react";import{jsx as wM,jsxs as IM}from"react/jsx-runtime";import{Position as Xt,useConnection as vy,useReactFlow as wy}from"@xyflow/react";import{useState as Iy}from"react";import{Fragment as md,jsx as Je,jsxs as ms}from"react/jsx-runtime";var gd=({id:e,data:t,selected:o,dragging:n})=>{let{updateNodeData:r}=wy(),{inProgress:i,fromNode:a}=vy(),{mode:s,reconnectingEdgeId:l}=J(),[c,d]=Iy(!1),u=i&&(a==null?void 0:a.id)!==e||!!l,m=h=>{r(e,{label:h})},p=()=>{d(!0)},g=()=>{d(!1)};return ms("div",{className:"relative",onDoubleClick:p,children:[Je(Hn,{className:G("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})}),Je("div",{className:"absolute mt-2 left-1/2 -translate-x-1/2 max-w-80 w-max",children:Je(Oe,{value:t.label,isEditing:c,onBlur:g,onChange:m})}),Je(Xe,{nodeId:e,nodeType:"START_EVENT"}),s==="edit"&&Je(nt,{nodeId:e,isVisible:!n&&o,minWidth:Yn.MIN_WIDTH,minHeight:Yn.MIN_HEIGHT,offset:4,keepAspectRatio:!0}),(!i||u)&&ms(md,{children:[Je(te,{type:"target",position:Xt.Left,id:"left",className:G({"event-handle":u})}),Je(te,{type:"target",position:Xt.Right,id:"right",className:G({"event-handle":u})}),Je(te,{type:"target",position:Xt.Top,id:"top",className:G({"event-handle":u})}),Je(te,{type:"target",position:Xt.Bottom,id:"bottom",className:G({"event-handle":u})})]}),!i&&ms(md,{children:[Je(Be,{type:"source",position:Xt.Left,id:"left",nodeId:e,nodeType:"START_EVENT"}),Je(Be,{type:"source",position:Xt.Right,id:"right",nodeId:e,nodeType:"START_EVENT"}),Je(Be,{type:"source",position:Xt.Top,id:"top",nodeId:e,nodeType:"START_EVENT"}),Je(Be,{type:"source",position:Xt.Bottom,id:"bottom",nodeId:e,nodeType:"START_EVENT"})]})]})};import{useTranslation as Sy}from"@produto-lecom/lecom-ui";import{Position as Ut,useConnection as My,useReactFlow as Py}from"@xyflow/react";import{useCallback as Zr}from"react";var Nn=60,qr=(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<=Nn?i:i.substring(0,Nn).trim()},Go=(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>Nn&&(n=n.substring(0,Nn).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=Nn-l.length,u=`${r.substring(0,c).trim()}${l}`;if(!o.has(u))return u;i++}return n};import{jsx as hd,jsxs as Ay}from"react/jsx-runtime";var yd=e=>Ay("svg",v(_({width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",xmlns:"http://www.w3.org/2000/svg"},e),{children:[hd("circle",{cx:"12",cy:"12",r:"10",fill:"#10B981"}),hd("path",{d:"M7 12L10 15L17 8",stroke:"white",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"})]}));import{jsx as xd}from"react/jsx-runtime";var Ed=e=>xd("svg",v(_({width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",xmlns:"http://www.w3.org/2000/svg"},e),{children:xd("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 bd,jsxs as Cy}from"react/jsx-runtime";var _d=e=>Cy("svg",v(_({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:"#EF4444"}),bd("path",{d:"M8 8L16 16M8 16L16 8",stroke:"white",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"})]}));import{Fragment as Jr,jsx as ve,jsxs as Tn}from"react/jsx-runtime";var Ly={APROVADO:yd,EM_ANDAMENTO:Ed,REJEITADO:_d},gs={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)]"},Nd=({id:e,data:t,selected:o,dragging:n})=>{let{t:r}=Sy(),{toast:i}=Fe(),{updateNodeData:a,getNodes:s,setNodes:l}=Py(),{inProgress:c,fromNode:d}=My(),{mode:u,onSubprocessValidationClick:m,reconnectingEdgeId:p}=J(),{getTaskStatus:g}=eo(),h=c&&(d==null?void 0:d.id)!==e||!!p,f=g(e),y=t.variant==="SUBPROCESS",N=!!t.variant&&!y||!!f,E=!!t.attribute||y,T=Zr(z=>{let X=N||E?80:40,M=z.split(`
41
+ `),O=M.reduce((P,R)=>Math.max(P,R.length),0),H=M.length,C=Math.max(_o.MIN_WIDTH,O*7+64),k=Math.max(_o.MIN_HEIGHT,H*24+X);l(P=>P.map(R=>R.id===e?v(_({},R),{width:C,height:k,style:v(_({},R.style),{width:C,height:k})}):R))},[e,l,N,E]),b=Zr(z=>{let U=z.trim(),K=t.label||"";if(U===K)return;let Y=U,X=s();if(!(U&&U!=="")){Y=qr(X,r("bpmn.task.label.prefix")),a(e,{label:Y}),T(Y),i({variant:"warning",content:Tn(Jr,{children:[r("bpmn.task.feedback.label_empty.prefix")," ",ve("strong",{children:Y})]})});return}let O=Go(Y,X);O===K||(a(e,{label:O}),T(O),O!==Y&&i({variant:"warning",content:Tn(Jr,{children:[r("bpmn.task.feedback.label_already_exists.prefix")," ",ve("strong",{children:U})," ",r("bpmn.task.feedback.label_already_exists.middle")," ",ve("strong",{children:O})]})}))},[t.label,s,e,r,a,T,i]),x=Zr(z=>{T(z)},[T]),w=Zr(()=>{i({variant:"error",content:r("bpmn.task.feedback.invalid_first_character")})},[r,i]),A=f?Ly[f]:null,I=t.variant?Gn[t.variant].icon:null,D=t.attribute?Bn[t.attribute].icon:null,S=()=>t.hasError?gs.error:f?gs[f]:gs.default,L=()=>{m==null||m({id:e,type:"sub_process",label:t.label})};return Tn("div",{className:G("relative w-full h-full min-w-44 min-h-24 flex flex-col items-stretch justify-stretch bg-white border-2 border-grey-400 hover:border-grey-500 rounded-md hover:shadow-md transition-colors duration-75",S(),{"border-blue-500 hover:border-blue-600 shadow-md":o,"border-red-500 hover:border-red-600 shadow-[0_0_5px_rgba(255,0,0,0.5)]":t.hasError}),children:[ve("div",{className:"flex-1 flex items-stretch justify-stretch overflow-hidden",children:ve(Oe,{value:t.label,maxLength:60,className:G({"py-10 px-8":N||E}),onChange:b,onInput:x,onInvalidFirstCharacter:w})}),I&&ve("div",{className:G("absolute flex items-center p-1",y?"bottom-0 left-1/2 -translate-x-1/2":"top-0 left-0"),children:ve(I,{size:16,className:G(t.hasError?"text-red-500":"text-grey-500",y&&"cursor-pointer"),onClick:y?L:void 0})}),D&&ve("div",{className:"absolute bottom-0 left-0 w-full flex items-center justify-center",children:ve("div",{className:G("flex items-center w-16 p-1",y?"justify-between":"justify-center"),children:ve(D,{size:16,className:G(t.hasError?"text-red-500":"text-grey-500")})})}),A&&ve("div",{className:"absolute top-0 right-0 flex items-center p-1",children:ve(A,{})}),ve(Xe,{nodeId:e,nodeType:"TASK",nodeVariant:t.variant}),u==="edit"&&ve(nt,{nodeId:e,isVisible:!n&&o,minWidth:_o.MIN_WIDTH,minHeight:_o.MIN_HEIGHT}),(!c||h)&&Tn(Jr,{children:[ve(te,{type:"target",position:Ut.Left,id:"left",className:G({"task-handle":h})}),ve(te,{type:"target",position:Ut.Right,id:"right",className:G({"task-handle":h})}),ve(te,{type:"target",position:Ut.Top,id:"top",className:G({"task-handle":h})}),ve(te,{type:"target",position:Ut.Bottom,id:"bottom",className:G({"task-handle":h})})]}),!c&&Tn(Jr,{children:[ve(Be,{type:"source",position:Ut.Left,id:"left",nodeId:e,nodeType:"TASK"}),ve(Be,{type:"source",position:Ut.Right,id:"right",nodeId:e,nodeType:"TASK"}),ve(Be,{type:"source",position:Ut.Top,id:"top",nodeId:e,nodeType:"TASK"}),ve(Be,{type:"source",position:Ut.Bottom,id:"bottom",nodeId:e,nodeType:"TASK"})]})]})};import{Position as Td}from"@xyflow/react";import{Fragment as ky,jsx as Qr,jsxs as Ry}from"react/jsx-runtime";var vd=({id:e,data:t})=>Ry(ky,{children:[Qr("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}),Qr(Xe,{nodeId:e,nodeType:"UNSUPPORTED"}),Qr(te,{type:"source",position:Td.Right}),Qr(te,{type:"target",position:Td.Left})]});import{BaseEdge as Dy,EdgeLabelRenderer as Oy,getSmoothStepPath as Hy,MarkerType as Vy,useInternalNode as wd,useReactFlow as Gy,useViewport as By,Position as Bo}from"@xyflow/react";import{useState as zy,useMemo as Yy}from"react";import{Fragment as Id,jsx as Ue,jsxs as uo}from"react/jsx-runtime";var dP={type:"MESSAGE_EDGE",reconnectable:!0,markerEnd:{type:Vy.Arrow},data:{label:""}},Ad=({id:e,source:t,target:o,data:n,selected:r,sourcePosition:i,targetPosition:a,sourceHandleId:s,targetHandleId:l})=>{var P;let{zoom:c}=By(),{updateEdgeData:d}=Gy(),{isMultipleSelection:u,mode:m,instanceId:p}=J(),g=m!=="edit",[h,f]=zy(!1),{reconnectingHandle:y,cursorPosition:N,hoveredNodeId:E,reconnectingSide:T,isValidReconnection:b,handleReconnectStart:x}=Wr({edgeId:e,source:t,target:o,instanceId:p,isReadOnly:g}),w=wd(t),A=wd(o),{sx:I,sy:D,tx:S,ty:L,sourcePos:z,targetPos:U}=Yy(()=>{var ne,ae;if(!w||!A)return{sx:0,sy:0,tx:0,ty:0,sourcePos:Bo.Left,targetPos:Bo.Right};let R=bo(w,A),V=s?i:R.sourcePos,B=l?a:R.targetPos,ee=($,he,fe)=>{var le,ye,Ne,Pe,ze,je;let{x:F,y:ue}=$.internals.positionAbsolute,ce=(Ne=(ye=(le=$.measured)==null?void 0:le.width)!=null?ye:$.width)!=null?Ne:0,j=(je=(ze=(Pe=$.measured)==null?void 0:Pe.height)!=null?ze:$.height)!=null?je:0;switch(he){case Bo.Top:return{x:F+ce*fe,y:ue};case Bo.Bottom:return{x:F+ce*fe,y:ue+j};case Bo.Left:return{x:F,y:ue+j*fe};case Bo.Right:return{x:F+ce,y:ue+j*fe};default:return{x:F+ce/2,y:ue+j/2}}},oe=(ne=n==null?void 0:n.sourceOffset)!=null?ne:.5,q=(ae=n==null?void 0:n.targetOffset)!=null?ae:.5,Z=w?ee(w,V,oe).x:R.sx,Q=w?ee(w,V,oe).y:R.sy,se=A?ee(A,B,q).x:R.tx,W=A?ee(A,B,q).y:R.ty;return y==="source"&&N?(Z=N.x,Q=N.y,T&&(V=T)):y==="target"&&N&&(se=N.x,W=N.y,T&&(B=T)),{sx:Z,sy:Q,tx:se,ty:W,sourcePos:V,targetPos:B}},[w,A,s,l,i,a,y,N,T,n==null?void 0:n.sourceOffset,n==null?void 0:n.targetOffset]);if(!w||!A)return null;let[K,Y,X]=Hy({sourceX:I,sourceY:D,targetX:S,targetY:L,sourcePosition:z,targetPosition:U}),M=r||(w==null?void 0:w.selected)||(A==null?void 0:A.selected),O=M?"sequence-edge-marker-highlighted":"sequence-edge-marker",H=h||(n==null?void 0:n.label.trim().length)>0,C=()=>{f(!1)},k=R=>{d(e,{label:R.trim()})};return Ue(Id,{children:uo("g",{className:G("group bpmn-arrow-edge",{"is-highlighted":M}),onDoubleClick:()=>!g&&f(!0),children:[Ue("path",{d:K,fill:"none",stroke:"transparent",strokeWidth:Math.max(12,12/c),style:{pointerEvents:"stroke",cursor:"pointer"}}),uo("g",{className:G("text-grey-500 transition-colors duration-75 group-hover:text-grey-800",{"text-blue-500 group-hover:text-blue-600":M}),children:[Ue(Dy,{id:e,path:K,interactionWidth:0,markerEnd:`url(#${O})`,strokeDasharray:4,className:G("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)||y&&E&&!b,"stroke-green-500":y&&E&&b,"stroke-blue-500 hover:stroke-blue-600 drop-shadow-[0_0_3px_rgba(59,130,246,0.5)]":M&&!(n!=null&&n.hasError)&&!y})}),uo(Oy,{children:[uo("div",{className:"absolute z-[3000] pointer-events-auto flex flex-col items-center gap-1",style:{transform:`translate(-50%, -50%) translate(${Y}px, ${X}px)`},children:[r&&!u&&Ue(So,{sx:I,sy:D,tx:S,ty:L,hasLabel:!!((P=n==null?void 0:n.label)!=null&&P.trim()),children:Ue(Co,{edgeId:e,edgeType:"MESSAGE_EDGE"})}),H&&Ue(Oe,{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:h,onBlur:C,onChange:k})]}),r&&!u&&!g&&uo(Id,{children:[Ue("div",{className:"absolute z-[1000] pointer-events-none",style:{transform:`translate(-50%, -50%) translate(${I}px, ${D}px)`},children:uo("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:y==="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:y==="source"?.6:.3,className:"pointer-events-none"}),Ue("circle",{cx:6/c,cy:6/c,r:8/c,fill:"transparent",className:G("pointer-events-auto",{"cursor-move":!y||y!=="source","cursor-not-allowed":y==="source"&&E&&!b,"cursor-grabbing":y==="source"&&(!E||b)}),onMouseDown:R=>x("source",R.nativeEvent)})]})}),Ue("div",{className:"absolute z-[1000] pointer-events-none",style:{transform:`translate(-50%, -50%) translate(${S}px, ${L}px)`},children:uo("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:y==="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:y==="target"?.6:.3,className:"pointer-events-none"}),Ue("circle",{cx:6/c,cy:6/c,r:8/c,fill:"transparent",className:G("pointer-events-auto",{"cursor-move":!y||y!=="target","cursor-not-allowed":y==="target"&&E&&!b,"cursor-grabbing":y==="target"&&(!E||b)}),onMouseDown:R=>x("target",R.nativeEvent)})]})})]})]})]})]})})};import{getStraightPath as Wy,Position as jr}from"@xyflow/react";import{jsx as Cd,jsxs as Fy}from"react/jsx-runtime";var Sd=({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:jr.Left},{x:n+a,y:r+s/2,pos:jr.Right},{x:n+a/2,y:r,pos:jr.Top},{x:n+a/2,y:r+s,pos:jr.Bottom}].reduce((p,g)=>{let h=Math.hypot(e-p.x,t-p.y);return Math.hypot(e-g.x,t-g.y)<h?g:p}),[d]=Wy({sourceX:c.x,sourceY:c.y,targetX:e,targetY:t});return Fy("g",{className:"group",children:[Cd("path",{fill:"none",className:"stroke-2 stroke-grey-500 animated transition-[stroke,filter] duration-75",d}),Cd("circle",{cx:e,cy:t,fill:"none",r:4,className:"stroke-2 stroke-grey-600"})]})};import{Position as $t,useConnection as Xy,useReactFlow as Uy}from"@xyflow/react";import{orderBy as $y}from"lodash";import{useMemo as Md,useState as Ky}from"react";import{Fragment as hs,jsx as $e,jsxs as ei}from"react/jsx-runtime";var Pd=({id:e,data:t,selected:o,dragging:n,parentId:r})=>{let{updateNodeData:i,getNodes:a}=Uy(),{mode:s}=J(),{inProgress:l,fromNode:c}=Xy(),d=l&&(c==null?void 0:c.id)!==e,[u,m]=Ky(!1),p=a(),g=!r,h=Md(()=>$y([...p.filter(b=>b.parentId===e&&b.type==="LANE")],"position.y","asc"),[p,e]),f=g?Qs.MIN_WIDTH:re.MIN_WIDTH,y=Md(()=>{if(g&&h.length>1){let b=[...h];return b.pop(),b.reduce((w,A)=>{var I,D;return w+((D=(I=A.measured)==null?void 0:I.height)!=null?D:0)},0)+re.MIN_HEIGHT}return re.MIN_HEIGHT},[g,h]),N=b=>{i(e,{label:b})},E=()=>{m(!0)},T=()=>{m(!1)};return ei(hs,{children:[ei("div",{className:G("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:[$e("div",{className:"flex align-items justify-center w-10 border-r border-grey-300",onDoubleClick:E,children:$e("div",{className:"relative flex-1 [writing-mode:vertical-rl] [text-orientation:sideways] transform rotate-180",children:$e(Oe,{value:t.label,className:"w-full h-full self-auto",contentClassName:G({"whitespace-nowrap":u}),isEditing:u,onBlur:T,onChange:N})})}),$e("div",{className:"flex-1"})]}),$e(Xe,{nodeId:e,nodeType:"LANE",isChild:!g}),s==="edit"&&$e(nt,{nodeId:e,isVisible:!n&&o,minWidth:f,minHeight:y,offset:10}),!l&&ei(hs,{children:[$e(te,{type:"source",position:$t.Left,id:"left"}),$e(te,{type:"source",position:$t.Right,id:"right"}),$e(te,{type:"source",position:$t.Top,id:"top"}),$e(te,{type:"source",position:$t.Bottom,id:"bottom"})]}),(!l||d)&&ei(hs,{children:[$e(te,{type:"target",position:$t.Left,id:"left",className:G({"annotation-handle":d})}),$e(te,{type:"target",position:$t.Right,id:"right",className:G({"annotation-handle":d})}),$e(te,{type:"target",position:$t.Top,id:"top",className:G({"annotation-handle":d})}),$e(te,{type:"target",position:$t.Bottom,id:"bottom",className:G({"annotation-handle":d})})]})]})};var Ld={START_EVENT:gd,END_EVENT:ud,TASK:Nd,GATEWAY:fd,ANNOTATION:cd,LANE:Pd,UNSUPPORTED:vd},kd={SEQUENCE_EDGE:Mc,MESSAGE_EDGE:Ad,ANNOTATION_EDGE:mc},Rd="#fafafa",Dd="#bebebe",Od=1,Hd=10,Vd="bottom-left",ys=.05,Gd=5,zo=.5,Yo=ys,Wo=1,Bd={x:0,y:0,zoom:.75},zd=1,Yd=2,qy={[zd]:4,[Yd]:2},vn=[zd,Yd],xs=vn.reduce((e,t)=>e|qy[t],0);import{useReactFlow as Zy}from"@xyflow/react";var rt=()=>{let{getEdges:e,getNodes:t}=Zy(),{lastElementId:o}=J(),n=()=>{let i=t(),a=e(),s=qc(i,a);return Math.max(s,o)};return{getLastId:n,getNextId:()=>n()+1}};var Fo=()=>{let{getNodes:e,getEdges:t,setNodes:o,setEdges:n,setViewport:r}=Qy(),{getLastId:i}=rt(),a=jy(),{setLastElementId:s}=J(),l=Wd(async(d="")=>{let{nodes:u,edges:m,lastElementId:p}=await Jc(d),{width:g,height:h}=a.getState();if(g>0&&h>0){let f=ra(u);f&&r(Jy(f,g,h,Yo,Wo,zo))}o(u),n(m),s(p)},[o,n,s,a,r]),c=Wd(()=>{let d=e(),u=t(),m=i();return Zc(d,u,m)},[e,t,i]);return{importFromMxGraph:l,exportToMxGraph:c}};import{useCallback as Fd}from"react";var t0=500,ti=()=>{let{isInitialized:e,onElementChanges:t}=J(),{exportToMxGraph:o}=Fo(),n=e0(()=>{if(!e)return;let a=o();t==null||t(a)},t0),r=Fd(a=>{a.every(c=>c.type==="select")||a.some(c=>c.type==="position"&&c.dragging)||n()},[n]),i=Fd(a=>{a.some(l=>l.type==="select")||n()},[n]);return{emitElementChanges:n,handleNodeChanges:r,handleEdgeChanges:i}};var Xd=({setEdges:e,saveHistory:t})=>{let{getNode:o,getEdges:n,getNodes:r,getInternalNode:i}=n0(),{emitElementChanges:a}=ti(),s=r0(null),{getNextId:l}=rt(),c=po(f=>{var b;let y=o(f.source),N=o(f.target);if(!y||!N)return!1;let E={sourceNodeId:y.id,targetNodeId:N.id,sourceNodeType:y.type,targetNodeType:N.type,nodes:r(),edges:n(),reconnectingEdgeId:(b=s.current)!=null?b:void 0};return Ji(E).isValid},[o,n,r]),d=po(f=>{var E,T;let y=l(),N=i(f.source);if(N){let b=i(f.target),x=b?b.internals.positionAbsolute.x+((E=b.measured.width)!=null?E:0)/2:0,w=b?b.internals.positionAbsolute.y+((T=b.measured.height)!=null?T:0)/2:0,A=Pc(N,x,w),I=(b==null?void 0:b.type)==="ANNOTATION"||(N==null?void 0:N.type)==="ANNOTATION",D=I?Mo:ot,S;if(!I&&b&&f.targetHandle){let U=Xr(A),K=Xr(f.targetHandle),{x:Y,y:X}=os(N,A),{x:M,y:O}=os(b,f.targetHandle),C=zr(Y,X,M,O,U,K).slice(1,-1);C.length>0&&(S=C)}let L=v(_(_({},f),D),{id:String(y),sourceHandle:A,data:_(_({},I?{}:ot.data),S?{points:S}:{})}),z=n().concat(L);e(z),t("forceSave",{nodes:r(),edges:z}),a()}},[l,e,a,i,n,r,t]),u=po((f,y)=>{s.current=y.id},[]),m=po(()=>{s.current=null},[]),p=po((f,y)=>{let N=o(y.source),E=o(y.target);if(!N||!E){s.current=null;return}let T={sourceNodeId:N.id,targetNodeId:E.id,sourceNodeType:N.type,targetNodeType:E.type,nodes:r(),edges:n(),reconnectingEdgeId:f.id};if(!Ji(T).isValid){s.current=null;return}let x=o0(f,y,n()).map(w=>w.id===f.id?v(_({},w),{data:v(_({},w.data),{points:void 0})}):w);e(x),t("forceSave",{nodes:r(),edges:x}),s.current=null,a()},[o,r,n,e,a,t]),g=po(f=>{s.current=f},[]),h=po(()=>{s.current=null},[]);return{isValidConnection:c,onConnect:d,onReconnect:p,onReconnectStart:u,onReconnectEnd:m,setReconnectingEdge:g,clearReconnectingEdge:h}};import{useTranslation as i0}from"@produto-lecom/lecom-ui";import{useReactFlow as s0}from"@xyflow/react";import{useCallback as Cn,useRef as eu,useState as a0}from"react";var wn=(e=[])=>e.filter(t=>t.type==="START_EVENT"),fo=(e=[])=>e.filter(t=>t.type==="END_EVENT"),Kt=(e=[])=>e.filter(t=>t.type==="TASK")||[],Ud=(e=[])=>e.filter(t=>{var o;return t.type==="TASK"&&((o=t.properties)==null?void 0:o.variant)==="SCRIPT"}),$d=(e=[])=>e.filter(t=>{var o;return t.type==="TASK"&&((o=t.properties)==null?void 0:o.variant)==="SUBPROCESS"}),oi=(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"}),Qe=(e,t=[])=>t.filter(o=>o.source===e),In=(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=Qe(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,be=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:[]}},Et=(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 An=[{id:"start_event_not_found",validate:e=>{let t=wn(e.nodes);return be({isValid:t.length>=1})}},{id:"end_event_not_found",validate:e=>{let t=fo(e.nodes);return be({isValid:t.length>=1})}},{id:"multiple_start_event_not_allowed",validate:e=>{let t=wn(e.nodes),o=t.length===1;if(t.length===0)return be({isValid:!0});if(!o)return be({isValid:!1,nodeIds:t.map(i=>i.id)});let n=Qe(t[0].id,e.edges);if(!(n.length<=1)){let i=[...t.map(a=>a.id),...n.map(a=>a.target)];return be({isValid:!1,nodeIds:[...new Set(i)]})}return be({isValid:!0})}},{id:"task_flows_limit_exceeds",validate:e=>{let t=Kt(e.nodes),o=Et(t,n=>Qe(n.id,e.edges).length<=2);return be({isValid:o.isValid,nodeIds:o.invalidIds})}},{id:"task_label_empty",highlightRelatedEdges:!1,validate:e=>{let t=Kt(e.nodes),o=Et(t,n=>!!n.label&&n.label.trim()!=="");return be({isValid:o.isValid,nodeIds:o.invalidIds})}},{id:"task_label_length",highlightRelatedEdges:!1,validate:e=>{let o=Kt(e.nodes),n=Et(o,r=>!r.label||r.label.length<=60);return be({isValid:n.isValid,nodeIds:n.invalidIds})}},{id:"duplicate_task_name",highlightRelatedEdges:!1,validate:e=>{let t=Kt(e.nodes),o=new Map;for(let r of t){if(!r.label)continue;let i=r.label.trim();i&&(o.has(i)||o.set(i,[]),o.get(i).push(r))}let n=[];for(let[,r]of o.entries())r.length>1&&r.forEach(i=>n.push(i.id));return be({isValid:n.length===0,nodeIds:n})}},{id:"nested_gateway",validate:e=>{let t=oi(e.nodes),o=[],n=[];for(let r of t){let i=Qe(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 be({isValid:o.length===0,nodeIds:o.length>0?[...new Set(o)]:[],edgeIds:n})}},{id:"events_nested",validate:e=>{let t=[...wn(e.nodes),...fo(e.nodes)],o=[],n=[];for(let r of t){let i=Qe(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 be({isValid:o.length===0,nodeIds:o.length>0?[...new Set(o)]:[],edgeIds:n})}},{id:"flows_on_end_tasks_not_allowed",validate:e=>{let t=fo(e.nodes),o=[],n=[];for(let r of t){let i=In(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=Qe(s.id,e.edges);l.length>1&&(o.push(s.id),l.forEach(c=>n.push(c.id)))}}}return be({isValid:o.length===0,nodeIds:o,edgeIds:n})}},{id:"conditions_flows_limit_exceeds",validate:e=>{let t=Kd(e.nodes),o=Et(t,r=>Qe(r.id,e.edges).length<=2),n=o.invalidIds.flatMap(r=>Qe(r,e.edges).map(i=>i.id));return be({isValid:o.isValid,nodeIds:o.invalidIds,edgeIds:n})}},{id:"activity_name_invalid",validate:e=>{let t=Kt(e.nodes),o=Et(t,n=>!n.label||Jd(n.label));return be({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 be({isValid:!0});let t=fo(e.nodes)[0];if(!t)return be({isValid:!0});let o=In(t.id,e.edges);if(!o.length)return be({isValid:!0});let r=Kt(e.nodes).filter(l=>o.some(c=>c.source===l.id)),i=Et(r,l=>!qd(l.id,e));return be({isValid:i.isValid,nodeIds:i.isValid?[]:[t.id,...i.invalidIds]})}},{id:"concurrent_initial_and_final_event",validate:e=>{let t=Kt(e.nodes),o=fo(e.nodes)[0];if(!o)return be({isValid:!0});let n=t.filter(l=>{let c=In(l.id,e.edges),d=Qe(l.id,e.edges),u=c.some(p=>{var g;return((g=e.nodes.find(h=>h.id===p.source))==null?void 0:g.type)==="START_EVENT"}),m=d.some(p=>{var g;return((g=e.nodes.find(h=>h.id===p.target))==null?void 0:g.type)==="END_EVENT"});return u&&m}),r=In(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 be(s)}},{id:"gateway_flow_to_event",validate:e=>{let t=oi(e.nodes),o=[],n=[];for(let r of t){let i=Qe(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 be({isValid:o.length===0,nodeIds:o.length>0?[...new Set(o)]:[],edgeIds:n})}},{id:"gateway_missing_output_streams",validate:e=>{let t=oi(e.nodes),o=Et(t,n=>Qe(n.id,e.edges).length>=1);return be({isValid:o.isValid,nodeIds:o.invalidIds})}},{id:"event_to_condition",validate:e=>{let t=[...wn(e.nodes),...fo(e.nodes)],o=[],n=[];for(let r of t){let i=Qe(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 be({isValid:o.length===0,nodeIds:o.length>0?[...new Set(o)]:[],edgeIds:n})}},{id:"script_in_final_activity",validate:e=>{let t=Ud(e.nodes),o=Et(t,n=>!Zd(n.id,e));return be({isValid:o.isValid,nodeIds:o.invalidIds})}},{id:"subprocess_referenced_not_configured",validate:e=>{let t=$d(e.nodes),o=Et(t,n=>{var r,i;return((r=n.properties)==null?void 0:r.subprocessRef)!==void 0&&((i=n.properties)==null?void 0:i.subprocessRef)!==""});return be({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 An){let r=n.validate(e);r.isValid||t.push({id:n.id,message:n.id,nodeIds:r.nodeIds||[],edgeIds:r.edgeIds||[]})}return{isValid:t.length===0,errors:t}};import{jsx as ni,jsxs as l0}from"react/jsx-runtime";var tu=()=>{let{t:e}=i0(),{toast:t}=Fe(),{setNodes:o,setEdges:n,getNodes:r,getEdges:i}=s0(),[a,s]=a0(!1),l=eu(!1),c=eu(!1),d=Cn(h=>{let f=Qd(h.nodes,h.edges),y=jd(f),N=y.errors.map(E=>v(_({},E),{message:e(`validation.errors.${E.id}`)}));return a||s(!0),{isValid:y.isValid,errors:N}},[a,e]),u=Cn((h,f=!0)=>{if(f&&h&&t({variant:h.isValid?"success":"error",duration:5e3,title:h.isValid?e("validation.success.title"):e("validation.errors.title"),content:l0("div",{className:"flex flex-col gap-1",children:[!h.isValid&&ni("span",{className:"body-small-500",children:e("validation.errors.subtitle")}),ni("ul",{className:"list-disc list-inside max-h-40 overflow-y-auto",children:h.isValid?ni("li",{children:e("validation.success.message")}):h.errors.map(S=>ni("li",{className:"text-xs",children:S.message},S.id))})]})}),!h)return;l.current=!0,c.current=!0;let y=[],N=[];h.errors.forEach(S=>{S.nodeIds&&S.nodeIds.length>0&&S.nodeIds.forEach(L=>y.push(L)),S.edgeIds&&S.edgeIds.length>0&&S.edgeIds.forEach(L=>N.push(L))});let E=[...new Set(y)];o(S=>S.map(L=>v(_({},L),{data:v(_({},L.data),{hasError:!1})}))),n(S=>S.map(L=>v(_({},L),{data:v(_({},L.data),{hasError:!1})})));let T=r(),b=i(),x=new Set(E),w=new Set;h.errors.forEach(S=>{var U,K;let L=An.find(Y=>Y.id===S.id);(L==null?void 0:L.highlightRelatedEdges)!==!1&&((U=S.edgeIds)==null||U.forEach(Y=>w.add(Y)),(K=S.nodeIds)==null||K.forEach(Y=>{b.forEach(X=>{(X.source===Y||X.target===Y)&&w.add(X.id)})}))});let A=new Set,I=new Set,D=new Set;T.forEach(S=>{S.type==="START_EVENT"?A.add(S.id):S.type==="END_EVENT"&&I.add(S.id)}),b.forEach(S=>{A.has(S.source)&&D.add(S.target),I.has(S.target)&&D.add(S.source)}),D.forEach(S=>{var L,z;if(x.has(S)){let U=(L=h.errors.find(Y=>{var X;return(X=Y.nodeIds)==null?void 0:X.includes(S)}))==null?void 0:L.id;((z=An.find(Y=>Y.id===U))==null?void 0:z.highlightRelatedEdges)!==!1&&b.forEach(Y=>{Y.source===S&&I.has(Y.target)&&(x.add(Y.target),w.add(Y.id)),Y.target===S&&A.has(Y.source)&&(x.add(Y.source),w.add(Y.id))})}}),x.size>0&&o(S=>S.map(L=>v(_({},L),{data:v(_({},L.data),{hasError:x.has(L.id)})}))),w.size>0&&n(S=>S.map(L=>v(_({},L),{data:v(_({},L.data),{hasError:w.has(L.id)})}))),setTimeout(()=>{l.current=!1},0)},[e,i,r,n,o,t]),m=Cn(()=>{s(!1),c.current=!1,o(h=>h.map(f=>v(_({},f),{data:v(_({},f.data),{hasError:!1})}))),n(h=>h.map(f=>v(_({},f),{data:v(_({},f.data),{hasError:!1})})))},[n,o]),p=Cn(()=>{c.current&&(l.current=!0,c.current=!1,o(h=>h.map(f=>v(_({},f),{data:v(_({},f.data),{hasError:!1})}))),n(h=>h.map(f=>v(_({},f),{data:v(_({},f.data),{hasError:!1})}))),setTimeout(()=>{l.current=!1},0))},[n,o]),g=Cn(()=>l.current,[]);return{validateDiagram:d,handleValidationComplete:u,clearValidation:m,dismissValidationPanel:p,isAutoValidationEnabled:a,getIsClearingValidation:g}};import{useReactFlow as c0}from"@xyflow/react";import{useTranslation as d0}from"@produto-lecom/lecom-ui";import{useEffect as u0}from"react";var p0=15,ou="bpmn:selection",f0=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},nu=e=>{if(!f0(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},ru=({offset:e=p0,saveHistory:t})=>{let{t:o}=d0(),{getNodes:n,setNodes:r,getEdges:i,setEdges:a}=c0(),{getNextId:s}=rt();u0(()=>{let l=d=>{var y,N;if(!nu(d))return;let u=n(),m=i(),p=u.filter(E=>E.selected);if(!p.length)return;d.preventDefault(),d.stopPropagation();let g=m.filter(E=>p.some(T=>T.id===E.source)&&p.some(T=>T.id===E.target)),f=JSON.stringify({nodes:p,edges:g});(y=d.clipboardData)==null||y.setData(ou,f),(N=d.clipboardData)==null||N.setData("text/plain",`BPMN Selection: ${p.length} nodes`)},c=d=>{var w,A;if(!nu(d))return;let u=(w=d.clipboardData)==null?void 0:w.getData(ou);if(!u)return;d.preventDefault(),d.stopPropagation();let m;try{m=JSON.parse(u)}catch(I){return}if(!((A=m.nodes)!=null&&A.length))return;let p=new Map,g=n(),h=[],f=m.nodes.filter(I=>Ht(I.type,g));if(f.length===0)return;let y=s(),N=f.map(I=>{var L;let D=String(y++);p.set(I.id,D);let S=v(_({},I),{id:D,selected:!0,position:{x:I.position.x+e,y:I.position.y+e}});if(I.type==="TASK"){let z=(L=I.data)==null?void 0:L.label,U=Go(z||o("bpmn.task.label.prefix"),[...g,...h]);S.data=v(_({},I.data),{label:U})}return h.push(S),S}),E=m.edges.map(I=>v(_({},I),{id:String(y++),selected:!0,source:p.get(I.source)||I.source,target:p.get(I.target)||I.target})),T=[...g.map(I=>v(_({},I),{selected:!1})),...N],x=[...i().map(I=>v(_({},I),{selected:!1})),...E];r(T),a(x),t("forceSave",{nodes:T,edges:x})};return document.addEventListener("copy",l,!0),document.addEventListener("paste",c,!0),()=>{document.removeEventListener("copy",l,!0),document.removeEventListener("paste",c,!0)}},[n,r,i,a,s,e,o,t])};import{useTranslation as m0}from"@produto-lecom/lecom-ui";import{useReactFlow as g0}from"@xyflow/react";import{useState as h0}from"react";var y0=50,iu=({nodes:e,setNodes:t,setEdges:o,saveHistory:n})=>{let{draggableNode:r,setDraggableNode:i}=Vo(),{t:a}=m0(),{getInternalNode:s,getNodes:l,getEdges:c,screenToFlowPosition:d}=g0(),{getNextId:u}=rt(),{setIsDragging:m}=J(),{getInternalNodes:p}=$r(),{rebuildIndex:g,forceRebuildIndex:h}=Tr(),[f,y]=h0(null),N=(M,O,H)=>{var R;if(M.parentId!==O)return null;let C=H.filter(V=>V.id!==M.id&&V.parentId===O&&V.type==="LANE").sort((V,B)=>V.position.y-B.position.y);if(C.length===0)return null;let k=(R=H.find(V=>V.id===M.id))!=null?R:M,P=C.find(V=>k.position.y<V.position.y);return P?{draggedLaneId:M.id,beforeLaneId:P.id}:{draggedLaneId:M.id,afterLaneId:C[C.length-1].id}},E=(M,O=!1,H)=>{let C=O?"node-drop-target-error":"node-drop-target",k=O?"node-drop-target-lane-error":"node-drop-target-lane";t(P=>{var V;let R=(V=H==null?void 0:H(P))!=null?V:null;return P.map(B=>{let ee=[];return B.id===M&&ee.push(C),M!==void 0&&B.parentId===M&&B.type==="LANE"&&B.id!==(R==null?void 0:R.draggedLaneId)&&ee.push(k),B.id===(R==null?void 0:R.draggedLaneId)&&ee.push("lane-reorder-dragging"),B.id===(R==null?void 0:R.beforeLaneId)&&ee.push("lane-reorder-before"),B.id===(R==null?void 0:R.afterLaneId)&&ee.push("lane-reorder-after"),v(_({},B),{className:ee.join(" ")})})})},T=(M,O)=>{let H=p();if(M.type==="LANE"){if(O){E();return}let V=H.filter(oe=>oe.id!==M.id&&oe.type==="LANE"&&!oe.parentId),B=Zo(M,V);if(!B){E();return}if(Jt({parentId:B.id,nodes:e,excludeTypes:["LANE"]})){E(B.id,!0);return}E(B.id,!1,oe=>N(M,B.id,oe));return}let k=H.filter(V=>V.id!==M.id&&V.type==="LANE"),P=Zo(M,k);if(!P){E();return}if(Jt({parentId:P.id,nodes:e,includeTypes:["LANE"]})){E();return}E(P.id)},b=M=>{let O=s(M.id),H=M.type==="LANE"&&Jt({parentId:M.id,nodes:e,includeTypes:["LANE"]});T(O,H)},x=M=>M.map(O=>v(_({},O),{className:void 0})),w=M=>M.some(H=>H.dragging)?M.map(H=>H.dragging?v(_({},H),{dragging:!1}):H):M,A=(M,O)=>{let H=0;for(let C of O){if(C.id===M||C.parentId||C.type==="LANE")continue;let k=et(C),P=k.y+k.h;H=Math.max(H,P)}return H+y0},I=(M,O)=>{if(!Pi(M,O))return O;let H=A(M,O);return O.map(C=>C.id===M?v(_({},C),{position:v(_({},C.position),{y:H})}):C)},D=M=>{if(M.preventDefault(),M.dataTransfer.dropEffect="move",!(r!=null&&r.type))return;let O=d({x:M.clientX,y:M.clientY}),H={id:"__sidebar_drag__",type:r.type,position:O,measured:{width:1,height:1},internals:{positionAbsolute:O}};T(H,!1)},S=M=>{let O=M.relatedTarget;(!O||!M.currentTarget.contains(O))&&E()},L=(M,O)=>{M.preventDefault(),b(O)},z=(M,O,H)=>{var ee,oe;let C=[...H],k=O.parentId?O.parentId:O.id;if(M.parentId===O.id)return C=ki(M,O,C),C=At(C),C=Qt(k,C),x(C);if(M.type==="LANE"){if(Jt({parentId:O.id,nodes:C,excludeTypes:["LANE"]})){let W=br(O),ne=50,ae=50;return C.map($=>{var he,fe;return $.id===M.id?v(_({},$),{position:{x:(he=f==null?void 0:f.x)!=null?he:W.x+ne,y:(fe=f==null?void 0:f.y)!=null?fe:W.y2+ae}}):$})}let Q=C.filter(W=>W.parentId===O.id).reduce((W,ne)=>{var ae,$;return W+(($=(ae=ne.measured)==null?void 0:ae.height)!=null?$:0)},0),se={x:re.HEADER_WIDTH,y:Q};return C=C.map(W=>W.id===M.id?v(_({},W),{parentId:O.id,position:se,className:void 0}):v(_({},W),{className:void 0})),C=At(C),C=I(k,C),C}if(Jt({parentId:O.id,nodes:C,includeTypes:["LANE"]})){let q;if(M.parentId){let Z=s(M.parentId),{x:Q,y:se}=et(Z);q={x:Q+((ee=M.position.x)!=null?ee:0),y:se+((oe=M.position.y)!=null?oe:0)}}return C=C.map(Z=>Z.id===M.id?v(_({},Z),{position:q!=null?q:Z.position,parentId:void 0,className:void 0}):v(_({},Z),{className:void 0})),C=Qt(k,C),C}let V=ta(M,O);C=C.map(q=>q.id===M.id?v(_({},q),{parentId:O.id,position:V,className:void 0}):v(_({},q),{className:void 0}));let B=C.find(q=>q.id===M.id);return C=ki(B,O,C),C=At(C),C=Qt(k,C),C},U=M=>{if(M.preventDefault(),!(r!=null&&r.type))return;if(!Ht(r.type,l())){m(!1),i(null);return}let O=d({x:M.clientX,y:M.clientY}),H={width:pe[r.type].MIN_WIDTH,height:pe[r.type].MIN_HEIGHT},C=u(),k={id:String(C),type:r.type,position:O,measured:H,data:{label:r.type==="TASK"?qr(e,a("bpmn.task.label.prefix")):"",variant:r.variant,attribute:r.attribute},selected:!0},P=v(_({},k),{internals:{positionAbsolute:O}}),R=v(_({},P),{measured:{width:1,height:1}}),V=p(),B=r.type==="LANE",ee=V.filter(W=>B?W.type==="LANE"&&!W.parentId:W.type==="LANE"),oe=Zo(R,ee),q=[...V.map(W=>v(_({},W),{selected:!1})),P];oe&&(q=z(P,oe,q)),q=Zt(q),B&&!oe&&(q=I(P.id,q)),q=x(q),t(q),h();let Z=M.dataTransfer.getData("sourceId"),Q=c(),se=Q;if(Z){let W={id:String(C+1),source:Z,target:k.id},ne=r.type==="ANNOTATION"?_(_({},W),Mo):_(_({},W),ot);se=Q.concat(ne),o(se)}n("forceSave",{nodes:q,edges:se}),m(!1),i(null)},K=async(M,O,H)=>{let C=[...p()],k=new Set;H.forEach(V=>{let B=s(V.id),ee=V.type==="LANE",oe=C.filter(Z=>Z.id!==V.id&&(ee?Z.type==="LANE"&&!Z.parentId:Z.type==="LANE")),q=Zo(B,oe);if(q){if(ee&&Jt({parentId:V.id,nodes:C,includeTypes:["LANE"]})){V.parentId&&(C=X(V,C),k.add(V.id));return}C=z(B,q,C);return}V.parentId&&(C=X(V,C),V.type==="LANE"&&k.add(V.id))}),C=w(C);let P=H.filter(V=>V.type==="LANE"&&!V.parentId).map(V=>V.id);for(let V of P)Pi(V,C)&&f&&(C=C.map(B=>B.id===V?v(_({},B),{position:_({},f)}):B));for(let V of k)C=I(V,C);if(H.some(V=>V.type!=="LANE"&&!V.parentId)){let V=C.filter(B=>B.type==="LANE"&&!B.parentId).map(B=>B.id);for(let B of V)C=Qt(B,C)}C=Zt(C),C=x(C),t(C),g(C),y(null)},Y=(M,O)=>{y({x:O.position.x,y:O.position.y})},X=(M,O)=>{var oe,q,Z,Q,se,W,ne,ae;let H=s(M.parentId);if(!H)return O;let C=M.type==="LANE",k=O.filter($=>$.parentId===H.id&&$.id!==M.id),P=k.filter($=>$.type==="LANE"),R;if(C&&P.length===0)R=re.MIN_HEIGHT;else if(C){let $=(q=(oe=M.measured)==null?void 0:oe.height)!=null?q:re.MIN_HEIGHT;R=((Q=(Z=H.measured)==null?void 0:Z.height)!=null?Q:re.MIN_HEIGHT)-$,R=Math.max(re.MIN_HEIGHT,R)}else R=k.length>0?k.reduce(($,he)=>{var fe,F;return $+((F=(fe=he.measured)==null?void 0:fe.height)!=null?F:0)},0)+Te:Math.max(re.MIN_HEIGHT,(W=(se=H.measured)==null?void 0:se.height)!=null?W:0);let{x:V,y:B}=et(H),ee={x:V+((ne=M.position.x)!=null?ne:0),y:B+((ae=M.position.y)!=null?ae:0)};return O=O.map($=>$.id===M.id?v(_({},$),{position:ee,parentId:void 0}):$.id===H.id?v(_({},$),{height:R,measured:v(_({},$.measured),{height:R})}):$),O=At(O),O};return{onDragOver:D,onDragLeave:S,onDrop:U,onNodeDrag:L,onNodeDragStart:Y,onNodeDragStop:K}};import{useReactFlow as x0}from"@xyflow/react";import{useTranslation as E0}from"@produto-lecom/lecom-ui";import{useEffect as b0}from"react";var _0=30,N0=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},T0=e=>!N0(e.target),su=({offset:e=_0,saveHistory:t})=>{let{t:o}=E0(),{getNodes:n,setNodes:r,getEdges:i,setEdges:a}=x0(),{getNextId:s}=rt();b0(()=>{let l=c=>{if(c.ctrlKey&&c.key.toLowerCase()==="d"&&T0(c)){c.preventDefault(),c.stopPropagation();let d=n(),u=i(),m=d.filter(x=>x.selected);if(!m.length)return;let p=new Map,g=[],h=m.filter(x=>Ht(x.type,d));if(h.length===0)return;let f=u.filter(x=>h.some(w=>w.id===x.source)&&h.some(w=>w.id===x.target)),y=s(),N=h.map(x=>{var I;let w=String(y++);p.set(x.id,w);let A=v(_({},x),{id:w,selected:!0,position:{x:x.position.x+e,y:x.position.y+e}});if(x.type==="TASK"){let D=(I=x.data)==null?void 0:I.label,S=Go(D||o("bpmn.task.label.prefix"),[...d,...g]);A.data=v(_({},x.data),{label:S})}return g.push(A),A}),E=f.map(x=>v(_({},x),{id:String(y++),selected:!0,source:p.get(x.source)||x.source,target:p.get(x.target)||x.target})),T=[...d.map(x=>v(_({},x),{selected:!1})),...N],b=[...u.map(x=>v(_({},x),{selected:!1})),...E];r(T),a(b),t("forceSave",{nodes:T,edges:b})}};return document.addEventListener("keydown",l,!0),()=>{document.removeEventListener("keydown",l,!0)}},[n,r,i,a,s,e,o,t])};import{useEffect as v0,useRef as au}from"react";import{useReactFlow as w0}from"@xyflow/react";var I0=20,A0=50,Sn={UP:"ArrowUp",DOWN:"ArrowDown",LEFT:"ArrowLeft",RIGHT:"ArrowRight"},C0=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},lu=e=>{let{getNodes:t}=w0(),{mode:o,isMoveTool:n}=J(),r=au(0),i=au(new Map);v0(()=>{let a=s=>{if(o!=="edit"||!n||C0(s.target)||!Object.values(Sn).includes(s.key))return;let u=t().filter(N=>N.selected);if(u.length===0){i.current.clear();return}s.preventDefault();let m=Date.now(),p=m-r.current<500;r.current=m;let g=s.shiftKey?A0:I0,h=0,f=0;switch(s.key){case Sn.UP:f=-g;break;case Sn.DOWN:f=g;break;case Sn.LEFT:h=-g;break;case Sn.RIGHT:h=g;break}let y=u.map(N=>{let E=i.current.get(N.id);(!p||!E)&&(E={x:N.position.x,y:N.position.y});let T={x:E.x+h,y:E.y+f};return i.current.set(N.id,T),{id:N.id,dragging:!0,type:"position",position:T}});e&&e(y)};return window.addEventListener("keydown",a),()=>{window.removeEventListener("keydown",a)}},[t,e,o,n])};import{useReactFlow as M0}from"@xyflow/react";var du={"start-event":"START_EVENT","end-event":"END_EVENT",task:"TASK","gateway-exclusive":"GATEWAY"},uu={"start-event":"","end-event":"",task:"","gateway-exclusive":"EXCLUSIVE"},cu=(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}},S0=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=cu(i[0],o),s=cu(i[1],o);a&&s&&n.push({sourceId:a.step,targetId:s.step,label:a.edgeLabel||s.edgeLabel||""})}),{components:o,connections:n}},pu=e=>{let{components:t,connections:o}=S0(e);return{nodes:t,edges:o}};var fu=()=>{let{setNodes:e,setEdges:t,fitView:o}=M0(),{getNextId:n}=rt();return{importFromLia:i=>{let a=typeof i=="string"?i:i.diagramXml||"",{nodes:s,edges:l}=pu(a),c=[],d=new Map,u=!1,m=n();for(let[f,y]of Object.entries(s)){let N=String(m++),E=du[y.type],T=uu[y.type];E==="START_EVENT"&&(u=!0),d.set(f,N);let b=pe[E].MIN_WIDTH,x=pe[E].MIN_HEIGHT;c.push({id:N,type:E,data:{label:y.label||"",variant:T,attribute:""},position:{x:0,y:0},width:b,height:x,measured:{width:b,height:x}})}let p=[];for(let f of l){let y=v(_({},ot),{id:String(m++),source:d.get(f.sourceId)||f.sourceId,target:d.get(f.targetId)||f.targetId});p.push(y)}if(!u&&c.length>0){let f=String(m++),y={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(y);let N=c[1];if(N){let E=v(_({},ot),{id:String(m++),source:f,target:N.id});p.unshift(E)}}let{nodes:g,edges:h}=Xc(c,p);e(g),t(h),o({padding:zo,minZoom:Yo,maxZoom:Wo})}}};import{useEffect as P0,useCallback as L0}from"react";var k0={origin:"*",debug:!1};function mu(e,t=k0){let{origin:o,debug:n}=t,r=L0((i,a)=>{let s={event:i,data:[i,{event:i,data:a}]};window.parent.postMessage(s,o||"*")},[o]);return P0(()=>{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 R0}from"@xyflow/react";import{useEffect as gu}from"react";var hu=()=>{let e=R0(),{initialDiagram:t,setIsInitialized:o}=J(),{importFromMxGraph:n}=Fo();gu(()=>{t&&n(t)},[t,n,o]),gu(()=>{if(!e)return;(async()=>{await On(),o(!0)})()},[e,o])};import{useCallback as yu}from"react";import{useReactFlow as D0}from"@xyflow/react";function xu(){let{setTaskStatuses:e,clearTaskStatuses:t,calculateFlowPath:o}=eo(),{getEdges:n}=D0(),r=Xn(),i=yu(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=yu(()=>{t(),setTimeout(()=>{r()},0)},[t,r]);return{handleTasksStatus:i,handleClearTaskStatus:a}}import{useReactFlow as O0}from"@xyflow/react";import{useCallback as Ct,useState as H0,useEffect as Eu}from"react";import{useDebouncedCallback as V0}from"use-debounce";var G0=500,bu=100,_u=(e=!1)=>{let{getNodes:t,getEdges:o,setNodes:n,setEdges:r}=O0(),[i,a]=H0({history:[],currentStep:0}),{history:s,currentStep:l}=i,c=l>0,d=l<s.length-1,u=Ct((b,x)=>{n(b[x].nodes),r(b[x].edges)},[n,r]),m=Ct(()=>{if(l>0){let b=l-1;a(x=>v(_({},x),{currentStep:b})),u(s,b)}},[l,s,u]),p=Ct(()=>{if(l<s.length-1){let b=l+1;a(x=>v(_({},x),{currentStep:b})),u(s,b)}},[s,l,u]),g=Ct(b=>{a(x=>{let w=x.history[x.currentStep];if(w&&JSON.stringify(w)===JSON.stringify(b))return x;let D=[...x.history.slice(0,x.currentStep+1),b],S=D.length>bu?D.slice(D.length-bu):D;return{history:S,currentStep:S.length-1}})},[]),h=Ct((b,x)=>{let w=b.map(I=>v(_({},I),{selected:!1,className:"",data:v(_({},I.data),{hasError:!1})})),A=x.map(I=>v(_({},I),{data:v(_({},I.data),{hasError:!1})}));return{nodes:Zt(w),edges:A}},[]),f=Ct(()=>h(t(),o()),[t,o,h]),y=V0(()=>{let b=f();g(b)},G0),N=Ct((b,x)=>{if(!e)return;if(s.length===0){let I=f();a({history:[I],currentStep:0})}if(b==="forceSave"){if(x){g(h(x.nodes,x.edges));return}y();return}b.some(I=>I.type==="select")||b.some(I=>I.type==="position"&&I.dragging)||y()},[e,y,s.length,f,g,h]);Eu(()=>{if(e&&s.length===0){let b=f();a({history:[b],currentStep:0})}},[e,s.length,f]);let E=Ct(b=>{a({history:b||[],currentStep:0})},[]),T=Ct(()=>{a({history:[],currentStep:0})},[]);return Eu(()=>{let b=x=>{(x.ctrlKey||x.metaKey)&&(x.shiftKey&&x.key.toLowerCase()==="z"?(x.preventDefault(),p()):x.key.toLowerCase()==="z"&&(x.preventDefault(),m()))};return document.addEventListener("keydown",b),()=>{document.removeEventListener("keydown",b)}},[m,p]),{history:s,undo:m,redo:p,canUndo:c,canRedo:d,saveHistory:N,resetHistory:E,clearHistory:T}};var Nu=()=>{let{t:e}=B0(),[t,o,n]=Y0([]),[r,i,a]=z0([]),{getNodes:s,getNode:l}=F0(),{toast:c}=Fe(),d=X0(),{instanceId:u,isInitialized:m,setIsConnecting:p,setIsMultipleSelection:g,onElementClick:h}=J(),{updateHelperLines:f,HelperLines:y}=Tr(),{undo:N,redo:E,canUndo:T,canRedo:b,saveHistory:x}=_u(m),{onNodeDrag:w,onDrop:A,onDragOver:I,onDragLeave:D,onNodeDragStop:S,onNodeDragStart:L}=iu({nodes:t,setNodes:o,setEdges:i,saveHistory:x}),{isValidConnection:z,onConnect:U,onReconnect:K,onReconnectStart:Y,onReconnectEnd:X,setReconnectingEdge:M,clearReconnectingEdge:O}=Xd({setEdges:i,saveHistory:x}),{handleValidationComplete:H,clearValidation:C,dismissValidationPanel:k,validateDiagram:P,getIsClearingValidation:R}=tu(),{importFromLia:V}=fu(),{handleTasksStatus:B,handleClearTaskStatus:ee}=xu(),{clearPathEdges:oe}=eo(),{emitElementChanges:q,handleNodeChanges:Z,handleEdgeChanges:Q}=ti(),se=Xn();ru({saveHistory:x}),su({saveHistory:x}),hu();let W=St(()=>{o([]),i([]),oe(),setTimeout(se,0)},[o,i,oe,se]);mu({LIA_CREATE_DIAGRAM:V,CLEAR_DIAGRAM:W,TASKS_STATUS:B,CLEAR_TASKS_STATUS:ee});let{selectElements:ne,clearSelection:ae}=Vt(),{importFromMxGraph:$,exportToMxGraph:he}=Fo(),{configureElement:fe,getConfigureElement:F}=Pr(),ue=St(()=>t.length+r.length,[t,r]);U0(()=>(xt.set(u,{importFromMxGraph:$,exportToMxGraph:he,selectElements:ne,clearSelection:ae,configureElement:fe,getConfigureElement:F,getElementsCount:ue,setReconnectingEdge:M,clearReconnectingEdge:O}),()=>{xt.delete(u)}),[u,$,he,ne,ae,fe,F,ue,M,O]);let ce=St((xe,_e)=>{if(_e.type!=="TASK"&&_e.type!=="GATEWAY")return;let ge=F(_e.id);ge&&(h==null||h(ge))},[F,h]),j=St((xe,_e)=>{if(_e.type!=="SEQUENCE_EDGE")return;let ge=l(_e.source),Ee=l(_e.target),{isFromStartEvent:we,isGatewayToGateway:Ke,isActiviyToAndGateway:Ie,isToEndEvent:ft}=zn(ge,Ee);if(!(!we&&!Ke&&!Ie&&!ft))return;let bt=F(_e.id);bt&&(h==null||h(bt))},[F,l,h]),le=St(xe=>{let _e=f(xe,t);n(_e),x(xe),R()||k(),Z(xe)},[t,n,x,R,k,f,Z]),ye=St(xe=>{a(xe),x(xe),R()||k(),Q(xe)},[a,x,R,k,Q]);lu(le);let Ne=St(({nodes:xe,edges:_e})=>{g(xe.length+_e.length>=2)},[g]);W0({onChange:Ne});let Pe=St(async({nodes:xe})=>xe.some(ge=>ge.type==="LANE"&&t.some(Ee=>Ee.parentId===ge.id))?(c({variant:"error",title:e("validation.errors.title"),content:e("editor.toolbar.delete_pool_lane_error")}),!1):!0,[t,e,c]),ze=()=>{x("forceSave"),q(),k()},je=()=>{p(!0)},ut=()=>{p(!1),k()},pt=St(xe=>{let _e=new Set(xe.filter(ge=>ge.type==="LANE"&&!!ge.parentId).map(ge=>ge.parentId));_e.size!==0&&setTimeout(()=>{var we,Ke;let ge=s(),Ee=new Map(ge.map(Ie=>[Ie.id,Ie]));for(let Ie of _e){let ft=jt(ge.filter(_t=>_t.type==="LANE"&&_t.parentId===Ie));if(ft.length===0)continue;let Pt=0;for(let _t of ft)Ee.set(_t.id,v(_({},_t),{position:{x:re.HEADER_WIDTH,y:Pt}})),Pt+=(Ke=(we=_t.measured)==null?void 0:we.height)!=null?Ke:0;let bt=Ee.get(Ie);bt&&Ee.set(Ie,v(_({},bt),{height:Pt,measured:v(_({},bt.measured),{height:Pt})}))}o(ge.map(Ie=>{var ft;return(ft=Ee.get(Ie.id))!=null?ft:Ie}))},0)},[s,o]);return{nodes:t,setNodes:o,edges:r,setEdges:i,events:{isValidConnection:z,onConnect:U,onReconnect:K,onReconnectStart:Y,onReconnectEnd:X,onDrop:A,onDragOver:I,onDragLeave:D,onNodeDrag:w,onNodeDragStop:S,onNodeDragStart:L,onNodeClick:ce,onEdgeClick:j,onDropCapture:ze,onConnectStart:je,onConnectEnd:ut,onSelectionEnd:()=>setTimeout(()=>d.setState({nodesSelectionActive:!1}),0),onNodesChange:le,onEdgesChange:ye,onBeforeDelete:Pe,onNodesDelete:pt},ui:{handleCloseValidationPanel:C},controls:{undo:N,redo:E,canUndo:T,canRedo:b},components:{HelperLines:y},actions:{saveHistory:x,selectElements:ne,clearSelection:ae,exportToMxGraph:he,validateDiagram:P,handleValidationComplete:H,setReconnectingEdge:M,clearReconnectingEdge:O}}};import{useReactFlow as $0}from"@xyflow/react";import{useCallback as K0,useEffect as q0,useRef as Z0,useState as J0}from"react";var Q0=".react-flow__node, .react-flow__edge, .react-flow__node-toolbar";function Tu(e,t,o){let[n,r]=J0(!1),i=Z0(null),{getViewport:a,setViewport:s}=$0(),l=K0(()=>{i.current=null,r(!1)},[]);return q0(()=>{let c=e.current;if(!c)return;let d=p=>{if(!vn.some(h=>h===p.button)||t.current||o.current||(r(!0),!(p.target instanceof Element))||!p.target.closest(Q0))return;p.preventDefault(),p.stopPropagation();let g=a();i.current={pointerX:p.clientX,pointerY:p.clientY,viewportX:g.x,viewportY:g.y,zoom:g.zoom}},u=p=>{let g=i.current;if(g){if((p.buttons&xs)===0){l();return}s({x:g.viewportX+(p.clientX-g.pointerX),y:g.viewportY+(p.clientY-g.pointerY),zoom:g.zoom})}},m=p=>{(p.buttons&xs)===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 vu}from"react/jsx-runtime";var ri=({id:e,className:t})=>vu("marker",{id:e,className:G("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:vu("path",{d:"M 0 0 L 10 5 L 0 10 Z"})});import{jsx as ii,jsxs as j0}from"react/jsx-runtime";var wu=()=>ii("svg",{style:{position:"absolute",top:0,left:0},children:j0("defs",{children:[ii(ri,{id:"sequence-edge-marker",className:"text-grey-500"}),ii(ri,{id:"sequence-edge-marker-hovered",className:"text-grey-800"}),ii(ri,{id:"sequence-edge-marker-highlighted",className:"text-blue-500"})]})});import{Tooltip as EE,TooltipContent as bE,TooltipTrigger as _E,useTranslation as NE}from"@produto-lecom/lecom-ui";import{useKeyPress as Fu,useReactFlow as Yx}from"@xyflow/react";import{Button as pi,Tooltip as fi,TooltipContent as mi,TooltipTrigger as gi,useTranslation as Wx}from"@produto-lecom/lecom-ui";import{HandIcon as Fx,ListCheckIcon as Xx,MapIcon as Ux,MousePointerIcon as $x}from"lucide-react";import{useCallback as Ns,useEffect as Xu}from"react";import{Tooltip as Ex,TooltipContent as bx,TooltipTrigger as _x,useTranslation as Nx}from"@produto-lecom/lecom-ui";var Mn=(E=>(E.START_EVENT="START_EVENT",E.END_EVENT="END_EVENT",E.TASK="TASK",E.SUBPROCESS="SUBPROCESS",E.GATEWAY="GATEWAY",E.LANE="LANE",E.ANNOTATION="ANNOTATION",E.CONNECTION="CONNECTION",E.INTERMEDIATE_EVENT="INTERMEDIATE_EVENT",E.ACTIVITY="ACTIVITY",E.PROCESS_INTERFACE="PROCESS_INTERFACE",E.WORKFLOW_INTERFACE="WORKFLOW_INTERFACE",E.VARIANT_ACTIVITY="VARIANT_ACTIVITY",E.AUTO_ACTIVITY="AUTO_ACTIVITY",E.DATA_STORE="DATA_STORE",E.DATA_OBJECT="DATA_OBJECT",E.DATA_OUTPUT="DATA_OUTPUT",E.DATA_INPUT="DATA_INPUT",E.MARKER="MARKER",E))(Mn||{});import{Button as ux,useTranslation as px}from"@produto-lecom/lecom-ui";import{useReactFlow as fx}from"@xyflow/react";var Iu=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 Au({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);si(i,`${o}.csv`)}var si=(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 Cu(e){return e==null?void 0:e.replaceAll("&#xA;"," ")}var x3={START_EVENT:"START_EVENT",END_EVENT:"END_EVENT",TASK:"TASK",GATEWAY:"GATEWAY",ANNOTATION:"ANNOTATION"},Su={script:"SCRIPT",subprocess:"SUBPROCESS"},Mu={"marker-loop":"LOOP"},Pu={complex:"COMPLEX",none:"EXCLUSIVE",exclusive:"EXCLUSIVE",parallel:"PARALLEL",inclusive:"EXCLUSIVE"};var mo=({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}}},tx=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:mo({cell:e,type:"START_EVENT"}),status:n,originalType:o}},ox=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:mo({cell:e,type:"END_EVENT"}),status:n,originalType:o}},nx=(e,t)=>{let{id:o,subType:n,style:r}=e==null?void 0:e._attributes,i=Su[n],a=t.get(o)||"",s=Mu[a]||"",l=s==="LOOP",c="imported";return!["script","none"].includes(n)&&!l&&(c="adapted"),e.mxGeometry._attributes.width=Lt(e.mxGeometry._attributes.width||0,pe.TASK.MIN_WIDTH),e.mxGeometry._attributes.height=Lt(e.mxGeometry._attributes.height||0,pe.TASK.MIN_HEIGHT),{node:mo({cell:e,type:"TASK",variant:i,attribute:s}),status:c,originalType:r}},rx=e=>{let{style:t,subType:o}=e==null?void 0:e._attributes,n=Pu[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:mo({cell:e,type:"GATEWAY",variant:n}),status:i,originalType:t}},ix=e=>{let{style:t}=e==null?void 0:e._attributes;return{node:mo({cell:e,type:"LANE"}),status:"imported",originalType:t}},sx=e=>{let{style:t}=e==null?void 0:e._attributes;return e.mxGeometry._attributes.width=Lt(e.mxGeometry._attributes.width||0,pe.ANNOTATION.MIN_WIDTH),e.mxGeometry._attributes.height=Lt(e.mxGeometry._attributes.height||0,pe.ANNOTATION.MIN_HEIGHT),{node:mo({cell:e,type:"ANNOTATION"}),status:"imported",originalType:t}},Lu=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:mo({cell:e,type:"UNSUPPORTED"}),status:"unsupported",originalType:t}},ku=(e,t)=>{let{id:o,source:n,target:r,value:i}=e._attributes;return v(_({},ot),{id:o,source:t.get(n)||n,target:t.get(r)||r,data:{label:i||""}})},Ru={TASK:nx,GATEWAY:rx,START_EVENT:tx,END_EVENT:ox,LANE:ix,ANNOTATION:sx};var ax=e=>{let t=new Map,o=Object.values(Mn),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=Ru[l]||Lu,{node:d,status:u,originalType:m}=c(s,r);a.push(d),i.push({originalType:m,type:d.type,variant:d.data.variant,value:Cu(d.data.label),status:u})}return{nodes:a,governanceIdToNodeIdMap:t,summary:i}},lx=(e,t)=>e.filter(r=>{var i;return(i=r._attributes)==null?void 0:i.edge}).map(r=>ku(r,t)),cx=e=>{let{mxGraphModel:t}=e,{nodes:o,governanceIdToNodeIdMap:n,summary:r}=ax(t.root.mxCell),i=lx(t.root.mxCell,n);return{nodes:o,edges:i,summary:r}},dx=async e=>{let t=await Iu(e),o=Ur(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}},Du=async e=>{try{let t=await dx(e),{nodes:o,edges:n,summary:r}=cx(t)||{};return{nodes:o,edges:n,summary:r}}catch(t){throw t}};import{jsx as mx}from"react/jsx-runtime";var Ou=()=>{let{t:e}=px(),{toast:t}=Fe(),{setNodes:o,setEdges:n,fitView:r}=fx(),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:mx(ux,{size:"small",variant:"ghost",onClick:()=>Au({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 Du(s);if(o(m=>m.concat(l)),n(m=>m.concat(c)),r({padding:zo,minZoom:Yo,maxZoom:Wo}),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 gx}from"@produto-lecom/lecom-ui";import{useRef as hx}from"react";import{Fragment as yx,jsx as Hu,jsxs as xx}from"react/jsx-runtime";var Vu=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=hx(null),d=m=>{let p=m.target.files;p!=null&&p.length&&i(p),c.current&&(c.current.value="")};return xx(yx,{children:[Hu(gx,v(_({disabled:n,onClick:m=>{var p;(p=c.current)==null||p.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 ai,jsxs as Tx}from"react/jsx-runtime";var Gu=({disabled:e=!1})=>{let{t}=Nx(),{toast:o}=Fe(),{importFromGovernance:n}=Ou(),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 Tx(Ex,{children:[ai(_x,{asChild:!0,children:ai(Vu,{className:"[&>svg]:size-7 p-0",variant:"ghost",size:"small",color:"grey",iconButton:!0,accept:".mdr",disabled:e,onClick:r,onFilesSelected:i,children:ai(zs,{})})}),ai(bx,{color:"black",children:t("editor.controls.actions.import_governance")})]})};import{jsx as vx}from"react/jsx-runtime";var Es=({shortcut:e})=>vx("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 Lx,DropdownMenu as kx,DropdownMenuContent as Rx,DropdownMenuItem as _s,DropdownMenuTrigger as Dx,Tooltip as ci,TooltipContent as di,TooltipTrigger as ui,useTranslation as Ox}from"@produto-lecom/lecom-ui";import{FileCodeIcon as Hx,FileImageIcon as Vx,FolderOutputIcon as Gx,PrinterIcon as Bx}from"lucide-react";import{useState as zx}from"react";import{useTranslation as wx}from"@produto-lecom/lecom-ui";import{useReactFlow as Ix}from"@xyflow/react";import{toPng as Bu,toSvg as Ax}from"html-to-image";import{useState as Cx}from"react";var Sx=3,bs="diagram",li=50,Mx=96,Px=25.4,zu=e=>e*Px/Mx,Yu=()=>{let{t:e}=wx(),{toast:t}=Fe(),{getNodes:o,getNodesBounds:n}=Ix(),{clearSelection:r}=Vt(),[i,a]=Cx({png:!1,html:!1,print:!1}),s=()=>{let m=is(o()),p=n(m),g=p.width+li*2,h=p.height+li*2,f=li-p.x,y=li-p.y;return{width:g,height:h,style:{width:`${g}px`,height:`${h}px`,transform:`translate(${f}px, ${y}px)`,transformOrigin:"top left"}}},l=async(m,p)=>{a(g=>v(_({},g),{[p]:!0})),await r();try{if(is(o()).length===0){t({content:e("editor.controls.actions.export.feedback.empty"),variant:"warning"});return}let h=$c();if(!h)throw new Error("Flow element not found");let f=s();return await m(h,f)}catch(g){console.error("Diagram export failed",g),t({content:e("editor.controls.actions.export.feedback.error"),variant:"error"})}finally{a(g=>v(_({},g),{[p]:!1}))}};return{exportAsPng:async(m=bs)=>{await l(async(p,g)=>{let h=await Bu(p,v(_({},g),{backgroundColor:"#fcfcfc",skipFonts:!0}));si(h,`${m}.png`)},"png")},exportAsHtml:async(m=bs)=>{await l(async(p,g)=>{let h=await Ax(p,v(_({},g),{backgroundColor:"#fcfcfc",skipFonts:!0})),f=`
44
44
  <!DOCTYPE html>
45
45
  <html>
46
46
  <head>
47
47
  <meta charset="utf-8" />
48
- <title>${f}</title>
48
+ <title>${m}</title>
49
49
  <style>
50
50
  html, body {
51
51
  margin: 0;
@@ -65,11 +65,11 @@ var ju=Object.defineProperty,ep=Object.defineProperties;var tp=Object.getOwnProp
65
65
  </style>
66
66
  </head>
67
67
  <body>
68
- <img src="${y}" alt="${f}" />
68
+ <img src="${h}" alt="${m}" />
69
69
  </body>
70
- </html>`,x=new Blob([m],{type:"text/html"}),T=URL.createObjectURL(x);ii(T,`${f}.html`),window.setTimeout(()=>URL.revokeObjectURL(T),1e4)},"html")},printDiagram:async(f=xs)=>{await l(async(p,h)=>{var A;let y=await ku(p,v(_({},h),{backgroundColor:"#fcfcfc",pixelRatio:mx,skipFonts:!0})),m=document.createElement("iframe");m.style.position="fixed",m.style.right="0",m.style.bottom="0",m.style.width="0",m.style.height="0",m.style.border="0",document.body.appendChild(m);let x=(A=m.contentWindow)==null?void 0:A.document;if(!x)throw document.body.removeChild(m),new Error("Unable to access print iframe document");let T=Ru(h.width).toFixed(2),E=Ru(h.height).toFixed(2),N=x.createElement("style");N.textContent=`
70
+ </html>`,y=new Blob([f],{type:"text/html"}),N=URL.createObjectURL(y);si(N,`${m}.html`),window.setTimeout(()=>URL.revokeObjectURL(N),1e4)},"html")},printDiagram:async(m=bs)=>{await l(async(p,g)=>{var A;let h=await Bu(p,v(_({},g),{backgroundColor:"#fcfcfc",pixelRatio:Sx,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 y=(A=f.contentWindow)==null?void 0:A.document;if(!y)throw document.body.removeChild(f),new Error("Unable to access print iframe document");let N=zu(g.width).toFixed(2),E=zu(g.height).toFixed(2),T=y.createElement("style");T.textContent=`
71
71
  @page {
72
- size: ${T}mm ${E}mm;
72
+ size: ${N}mm ${E}mm;
73
73
  margin: 0;
74
74
  }
75
75
  html, body {
@@ -83,4 +83,4 @@ var ju=Object.defineProperty,ep=Object.defineProperties;var tp=Object.getOwnProp
83
83
  height: 100%;
84
84
  object-fit: contain;
85
85
  }
86
- `,x.head.appendChild(N),x.title=f;let b=x.createElement("img");b.alt="Diagram",x.body.appendChild(b),await new Promise((I,D)=>{let S=!1,L=z=>{S||(S=!0,z?D(z):I())};b.onload=()=>L(),b.onerror=()=>L(new Error("Failed to load print image")),b.src=y,b.complete&&b.naturalWidth>0&&L()});let g=m.contentWindow;if(!g)throw document.body.removeChild(m),new Error("Unable to access print iframe window");let w=()=>{m.parentNode&&document.body.removeChild(m)};g.addEventListener("afterprint",w,{once:!0}),window.setTimeout(w,6e4),g.focus(),g.print()},"print")},isPrintingPng:i.png,isPrintingHtml:i.html,isPrinting:i.print}};import{jsx as Ne,jsxs as Bo}from"react/jsx-runtime";function Ou(){let{t:e}=_x(),{exportAsPng:t,exportAsHtml:o,printDiagram:n,isPrinting:r,isPrintingPng:i,isPrintingHtml:a}=Du(),[s,l]=Ix(!1);return Bo(xx,{modal:!1,open:s,onOpenChange:l,children:[Ne(bx,{asChild:!0,children:Ne("div",{children:Bo(li,{children:[Ne(di,{asChild:!0,children:Ne(yx,{size:"small",variant:"ghost",color:"grey",iconButton:!0,children:Ne(vx,{})})}),!s&&Ne(ci,{color:"black",children:e("editor.controls.actions.export.title")})]})})}),Bo(Ex,{align:"center",side:"top",sideOffset:16,className:"min-w-0 flex flex-col gap-2 p-2 shadow-sm",children:[Bo(li,{children:[Ne(di,{asChild:!0,children:Ne(Es,{className:"p-1.5",disabled:i,onClick:()=>t(),children:Ne(Nx,{})})}),Ne(ci,{side:"right",color:"black",children:e("editor.controls.actions.export.png")})]}),Bo(li,{children:[Ne(di,{asChild:!0,children:Ne(Es,{className:"p-1.5",disabled:a,onClick:()=>o(),children:Ne(Tx,{})})}),Ne(ci,{side:"right",color:"black",children:e("editor.controls.actions.export.html")})]}),Bo(li,{children:[Ne(di,{asChild:!0,children:Ne(Es,{className:"p-1.5",disabled:r,onClick:()=>n(),children:Ne(wx,{})})}),Ne(ci,{side:"right",color:"black",children:e("editor.controls.actions.export.print")})]})]})]})}import{Fragment as Gu,jsx as ve,jsxs as Tt}from"react/jsx-runtime";var Bu=({nodes:e,edges:t,validateDiagram:o,handleValidationComplete:n})=>{let{t:r}=Cx(),{clearSelection:i}=Mt(),{mode:a,isMinimapOpen:s,setIsMinimapOpen:l,isMoveTool:c,isHandTool:d,setIsMoveTool:u,setIsHandTool:f}=ee(),{getNodes:p,getEdges:h}=Ax(),y=Hu(["v","V"]),m=Hu(["h","H"]),x=bs(()=>{i(),f(!0),u(!1)},[i,f,u]),T=bs(()=>{u(!0),f(!1)},[u,f]),E=bs(()=>{let N=p(),b=h(),g=o({nodes:N,edges:b});n(g)},[p,h,o,n]);return Vu(()=>{y&&!c&&a==="edit"&&T()},[y,T,c,a]),Vu(()=>{m&&!d&&a==="edit"&&x()},[m,x,d,a]),Tt("div",{className:"flex items-center gap-2 px-3 py-2 bg-white rounded-sm shadow-md",children:[a==="edit"&&Tt(Gu,{children:[Tt(pi,{children:[ve(mi,{asChild:!0,children:ve(ui,{size:"small",variant:"ghost",color:"grey",className:V(c&&"bg-grey-400"),iconButton:!0,onClick:T,children:ve(Lx,{})})}),Tt(fi,{color:"black",className:"flex items-center gap-2",children:[r("editor.controls.actions.move_tool"),ve(ys,{shortcut:"V"})]})]}),Tt(pi,{children:[ve(mi,{asChild:!0,children:ve(ui,{size:"small",variant:"ghost",color:"grey",className:V(d&&"bg-grey-400"),iconButton:!0,onClick:x,children:ve(Sx,{})})}),Tt(fi,{color:"black",className:"flex items-center gap-2",children:[r("editor.controls.actions.hand_tool")," ",ve(ys,{shortcut:"H"})]})]})]}),ve(Ou,{}),a==="edit"&&Tt(Gu,{children:[Tt(pi,{children:[ve(mi,{asChild:!0,children:ve(ui,{size:"small",variant:"ghost",color:"grey",iconButton:!0,onClick:E,children:ve(Mx,{})})}),ve(fi,{color:"black",children:r("editor.controls.actions.check")})]}),ve(Lu,{disabled:e.length>0||t.length>0})]}),Tt(pi,{children:[ve(mi,{asChild:!0,children:ve(ui,{size:"small",variant:"ghost",color:"grey",className:V(s&&"bg-grey-400"),iconButton:!0,onClick:()=>l(!s),children:ve(Px,{})})}),ve(fi,{color:"black",children:r(s?"editor.controls.actions.minimap.close":"editor.controls.actions.minimap.open")})]})]})};import{Button as zu,Tooltip as Yu,TooltipContent as Wu,TooltipTrigger as Fu,useTranslation as kx}from"@produto-lecom/lecom-ui";import{RedoIcon as Rx,UndoIcon as Dx}from"lucide-react";import{jsx as Bt,jsxs as _s}from"react/jsx-runtime";var Xu=({undo:e,redo:t,canUndo:o,canRedo:n})=>{let{t:r}=kx();return _s("div",{className:"flex items-center gap-2 px-3 py-2 bg-white rounded-sm shadow-md",children:[_s(Yu,{children:[Bt(Fu,{asChild:!0,children:Bt(zu,{size:"small",variant:"ghost",color:"grey",iconButton:!0,disabled:!o,onClick:e,children:Bt(Dx,{})})}),Bt(Wu,{color:"black",children:r("editor.controls.history.undo")})]}),_s(Yu,{children:[Bt(Fu,{asChild:!0,children:Bt(zu,{size:"small",variant:"ghost",color:"grey",iconButton:!0,disabled:!n,onClick:t,children:Bt(Rx,{})})}),Bt(Wu,{color:"black",children:r("editor.controls.history.redo")})]})]})};import{useEdges as Ox,useNodes as Hx,useReactFlow as Vx}from"@xyflow/react";import{Button as gi,Tooltip as hi,TooltipContent as yi,TooltipTrigger as xi,useTranslation as Gx}from"@produto-lecom/lecom-ui";import{ScanIcon as Bx,ZoomIn as zx,ZoomOut as Yx}from"lucide-react";import{jsx as ke,jsxs as wn}from"react/jsx-runtime";var Uu=()=>{let{t:e}=Gx(),t=Hx(),o=Ox(),{zoomIn:n,zoomOut:r,zoomTo:i,fitView:a}=Vx(),s=t.length===0&&o.length===0;return wn("div",{className:"flex items-center gap-2 px-3 py-2 bg-white rounded-sm shadow-md",children:[wn(hi,{children:[ke(xi,{asChild:!0,children:ke(gi,{iconButton:!0,size:"small",color:"grey",variant:"ghost",disabled:s,onClick:()=>a(),children:ke(Bx,{})})}),ke(yi,{color:"black",children:e("editor.controls.zoom.fit")})]}),wn(hi,{children:[ke(xi,{asChild:!0,children:ke(gi,{iconButton:!0,size:"small",color:"grey",variant:"ghost",disabled:s,onClick:()=>r(),children:ke(Yx,{})})}),ke(yi,{color:"black",children:e("editor.controls.zoom.out")})]}),wn(hi,{children:[ke(xi,{asChild:!0,children:ke(gi,{iconButton:!0,size:"small",color:"grey",variant:"ghost",disabled:s,onClick:()=>i(1),children:ke(Vs,{})})}),ke(yi,{color:"black",children:e("editor.controls.zoom.reset")})]}),wn(hi,{children:[ke(xi,{asChild:!0,children:ke(gi,{iconButton:!0,size:"small",color:"grey",variant:"ghost",disabled:s,onClick:()=>n(),children:ke(zx,{})})}),ke(yi,{color:"black",children:e("editor.controls.zoom.in")})]})]})};import{useNodes as Wx}from"@xyflow/react";import{Button as Fx,Tooltip as Xx,TooltipContent as Ux,TooltipTrigger as $x,useTranslation as Kx}from"@produto-lecom/lecom-ui";import{useRef as qx,useState as Zx}from"react";import{jsx as ao,jsxs as $u}from"react/jsx-runtime";var Ku=()=>{let e=qx(null),{t}=Kx(),{setDraggableNode:o}=ko(),n=Wx(),{setIsDragging:r}=ee(),[i,a]=Zx(void 0),s=[{type:"START_EVENT",icon:Rn,label:t("bpmn.start_event.variant.default")},{type:"END_EVENT",icon:uo,label:t("bpmn.end_event.variant.default")},{type:"TASK",icon:Yo,label:t("bpmn.task.variant.default")},{type:"TASK",variant:"SUBPROCESS",icon:Ws,label:t("bpmn.task.variant.subprocess")},{type:"TASK",variant:"SCRIPT",icon:Ys,label:t("bpmn.task.variant.script")},{type:"TASK",attribute:"LOOP",icon:zs,label:t("bpmn.task.attribute.loop")},{type:"GATEWAY",variant:"EXCLUSIVE",icon:fo,label:t("bpmn.gateway.variant.exclusive")},{type:"GATEWAY",variant:"PARALLEL",icon:mo,label:t("bpmn.gateway.variant.parallel")},{type:"GATEWAY",variant:"COMPLEX",icon:po,label:t("bpmn.gateway.variant.complex")},{type:"LANE",icon:Hs,label:t("bpmn.lane.variant.default")},{type:"ANNOTATION",icon:Ln,label:t("bpmn.annotation.variant.default")}],l=(c,d)=>{o({type:d.type,variant:d.variant,attribute:d.attribute,icon:d.icon}),a(ao(d.icon,{})),c.dataTransfer.effectAllowed="move",e.current&&c.dataTransfer.setDragImage(e.current,10,10),setTimeout(()=>{r(!0)},100)};return $u("aside",{className:"sidebar absolute z-[1] top-4 left-4",children:[ao("div",{className:"grid grid-cols-1 gap-2 p-2 bg-white rounded-md shadow-md",children:s.map((c,d)=>{let u=!St(c.type,n),f=u?t("editor.toolbar.start_event_already_exists"):c.label;return $u(Xx,{children:[ao($x,{asChild:!0,children:ao(Fx,{className:V("[&>svg]:size-6",{"opacity-50 cursor-not-allowed":u}),size:"small",variant:"ghost",color:"grey",draggable:!u,disabled:u,iconButton:!0,onDragStart:u?void 0:p=>l(p,c),children:ao(c.icon,{})},d)}),ao(Ux,{color:"black",side:"right",children:f})]},d)})}),ao("div",{ref:e,className:"absolute w-0 h-0 top-0 left-0 z-[-1] bg-transparent",children:i})]})};import{jsx as nt,jsxs as Ei}from"react/jsx-runtime";var Ts=oE((e,t)=>{let o=tE("Space"),{instanceId:n,mode:r,isMinimapOpen:i,isMoveTool:a,isHandTool:s}=ee(),[l,c]=iE(!1),d=rE(null),{nodes:u,edges:f,actions:p,events:h,components:y,controls:m}=hu(),{t:x}=cE();nE(t,()=>({selectElements:p.selectElements,clearSelection:p.clearSelection})),qu(()=>{let g=d.current;if(!g)return;let w=I=>{s||o||r==="edit"&&jr.some(D=>D===I.button)&&c(!0)},A=I=>{(I.buttons&Od)===0&&c(!1)};return g.addEventListener("pointerdown",w),window.addEventListener("pointerup",A),()=>{g.removeEventListener("pointerdown",w),window.removeEventListener("pointerup",A)}},[s,o,r]),qu(()=>{let g=d.current;if(!g)return;let w=g.querySelector(".react-flow__pane");if(!w)return;let A=I=>I.preventDefault();return w.addEventListener("contextmenu",A),()=>w.removeEventListener("contextmenu",A)},[]);let T=s||o||r!=="edit"?!0:jr,E=r!=="readonly"&&a&&!o,N=r==="edit"&&a&&!o,b=r==="edit"&&a&&!o;return Ei("div",{ref:d,className:"w-full h-full",children:[r==="edit"&&nt(Ku,{}),nt(xu,{}),Ei(jx,v(_({},h),{id:`modeler-${n}`,className:V({"is-hand-tool":s||o||l}),edges:f,nodes:u,nodeTypes:wd,edgeTypes:Id,minZoom:hs,maxZoom:Ld,panOnDrag:T,panOnScroll:!0,selectionOnDrag:!0,elevateEdgesOnSelect:!0,elevateNodesOnSelect:!0,elementsSelectable:E,nodesConnectable:N,nodesDraggable:b,connectionLineComponent:Td,selectionMode:eE.Partial,multiSelectionKeyCode:["Control","Meta"],deleteKeyCode:"Delete",selectionKeyCode:null,defaultViewport:kd,connectOnClick:!1,connectionRadius:50,proOptions:{hideAttribution:!0},children:[nt(Jx,{gap:Md,size:Sd,color:Cd,bgColor:Ad}),i&&Ei(sE,{children:[nt(lE,{asChild:!0,children:nt("div",{className:"absolute bottom-[0px] left-[0px] z-[5]",children:nt(Qx,{pannable:!0,zoomable:!0,position:Pd,className:"shadow-md rounded-md",ariaLabel:"",style:{pointerEvents:"all",position:"relative"}})})}),nt(aE,{color:"black",children:x("editor.controls.actions.minimap.label")})]}),Ei("div",{className:"absolute z-10 bottom-4 left-1/2 -translate-x-1/2 flex gap-4",children:[r==="edit"&&nt(Xu,_({},m)),nt(Bu,{nodes:u,edges:f,validateDiagram:p.validateDiagram,handleValidationComplete:p.handleValidationComplete}),nt(Uu,{})]}),nt(y.HelperLines,{})]}))]})});Ts.displayName="Editor";import{useStore as dE}from"@xyflow/react";import{useEffect as uE,useRef as pE}from"react";import{jsx as mE}from"react/jsx-runtime";var fE=e=>({width:e.width,height:e.height,transform:e.transform}),Ns="rgba(51, 103, 217, 0.4)",Zl=({horizontal:e,vertical:t})=>{let{width:o,height:n,transform:r}=dE(fE),i=pE(null);return uE(()=>{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=Ns,t&&(s.beginPath(),s.strokeStyle=t.color||Ns,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||Ns,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]),mE("canvas",{ref:i,className:"w-full h-full absolute z-10 pointer-events-none"})};import{i18n as gE,Notification as hE,TooltipProvider as yE}from"@produto-lecom/lecom-ui";import{createContext as xE,useContext as EE,useEffect as bE,useState as _E}from"react";import{jsx as Zu,jsxs as NE}from"react/jsx-runtime";var dt=new Map,Ju=xE(null),un=()=>{let e=EE(Ju);if(!e)throw new Error("useModeler must be used within an <ModelerProvider />");return e},TE=({locale:e,defaultMode:t="view",toast:o,children:n})=>{let[r,i]=_E(e||"pt_BR");bE(()=>{e&&(i(e),gE.changeLanguage(e))},[e]);let a=h=>{let y=dt.size;if(y===0)throw new Error("No modeler instances found");if(y===1||!h){let[x]=dt.values();return x}let m=dt.get(h);if(!m)throw new Error(`Modeler instance with ID "${h}" not found`);return m},s=(h,y)=>{let m=a(y);return m==null?void 0:m.selectElements(h)},l=async h=>{let y=a(h);return y==null?void 0:y.clearSelection()},c=(h,y)=>{let m=a(y);return m==null?void 0:m.configureElement(h)},d=(h,y)=>{let m=a(y);return m==null?void 0:m.getConfigureElement(h)},u=async(h,y)=>{let m=a(y);await(m==null?void 0:m.importFromMxGraph(h))},f=h=>{let y=a(h);return y==null?void 0:y.exportToMxGraph()},p=h=>{let y=a(h);return(y==null?void 0:y.getElementsCount())||0};return Zu(Ju.Provider,{value:{defaultMode:t,locale:r,selectElements:s,clearSelection:l,configureElement:c,getConfigureElement:d,importDiagram:u,exportDiagram:f,getElementsCount:p,toast:o},children:NE(yE,{children:[!o&&Zu(hE,{type:"toast",placement:"topRight",enableClose:!0,showProgress:!0,pauseOnHover:!0}),n]})})};import{useTranslation as ME}from"@produto-lecom/lecom-ui";import{jsx as vs}from"react/jsx-runtime";var Qu=wE(null),ee=()=>{let e=IE(Qu);if(!e)throw new Error("useModelerInstance must be used within an <Modeler />");return e},PE=({selectorRef:e,initialDiagram:t,instanceId:o,mode:n,onElementChanges:r,onConfigureElement:i,onElementClick:a,onSubprocessValidationClick:s})=>{let{t:l}=ME(),{defaultMode:c}=un(),d=CE(),[u]=rt(o||d),[f,p]=rt(n||c||"edit"),[h,y]=rt(gn),[m,x]=rt(!1),[T,E]=rt(!0),[N,b]=rt(!1),[g,w]=rt(!1),[A,I]=rt(!1),[D,S]=rt(!1),[L,z]=rt(!1),[q,Q]=rt(null);AE(()=>{n&&p(n)},[n]);let U=SE(()=>t||zc(l),[t,l]),$={instanceId:u,initialDiagram:U,mode:f,lastElementId:h,isInitialized:m,isMinimapOpen:g,isMoveTool:T,isHandTool:N,isDragging:A,isMultipleSelection:L,isConnecting:D,setLastElementId:y,setIsInitialized:x,reconnectingEdgeId:q,setIsMinimapOpen:w,setIsMoveTool:E,setIsHandTool:b,setIsDragging:I,setIsConnecting:S,setIsMultipleSelection:z,setReconnectingEdgeId:Q,onElementChanges:r,onConfigureElement:i,onElementClick:a,onSubprocessValidationClick:s};return vs(vE,{children:vs(Qu.Provider,{value:$,children:vs(Ts,{ref:e})})})};export{Ie as EditorMode,Ti as ElementPosition,Mn as ElementType,Ni as GatewayElementVariant,et as GatewayVariant,PE as Modeler,TE as ModelerProvider,at as NodeAttribute,ie as NodeType,je as NodeVariant,vi as RoutingVariant,un as useModeler};
86
+ `,y.head.appendChild(T),y.title=m;let b=y.createElement("img");b.alt="Diagram",y.body.appendChild(b),await new Promise((I,D)=>{let S=!1,L=z=>{S||(S=!0,z?D(z):I())};b.onload=()=>L(),b.onerror=()=>L(new Error("Failed to load print image")),b.src=h,b.complete&&b.naturalWidth>0&&L()});let x=f.contentWindow;if(!x)throw document.body.removeChild(f),new Error("Unable to access print iframe window");let w=()=>{f.parentNode&&document.body.removeChild(f)};x.addEventListener("afterprint",w,{once:!0}),window.setTimeout(w,6e4),x.focus(),x.print()},"print")},isPrintingPng:i.png,isPrintingHtml:i.html,isPrinting:i.print}};import{jsx as Le,jsxs as Xo}from"react/jsx-runtime";function Wu(){let{t:e}=Ox(),{exportAsPng:t,exportAsHtml:o,printDiagram:n,isPrinting:r,isPrintingPng:i,isPrintingHtml:a}=Yu(),[s,l]=zx(!1);return Xo(kx,{modal:!1,open:s,onOpenChange:l,children:[Le(Dx,{asChild:!0,children:Le("div",{children:Xo(ci,{children:[Le(ui,{asChild:!0,children:Le(Lx,{size:"small",variant:"ghost",color:"grey",iconButton:!0,children:Le(Gx,{})})}),!s&&Le(di,{color:"black",children:e("editor.controls.actions.export.title")})]})})}),Xo(Rx,{align:"center",side:"top",sideOffset:16,className:"min-w-0 flex flex-col gap-2 p-2 shadow-sm",children:[Xo(ci,{children:[Le(ui,{asChild:!0,children:Le(_s,{className:"p-1.5",disabled:i,onClick:()=>t(),children:Le(Vx,{})})}),Le(di,{side:"right",color:"black",children:e("editor.controls.actions.export.png")})]}),Xo(ci,{children:[Le(ui,{asChild:!0,children:Le(_s,{className:"p-1.5",disabled:a,onClick:()=>o(),children:Le(Hx,{})})}),Le(di,{side:"right",color:"black",children:e("editor.controls.actions.export.html")})]}),Xo(ci,{children:[Le(ui,{asChild:!0,children:Le(_s,{className:"p-1.5",disabled:r,onClick:()=>n(),children:Le(Bx,{})})}),Le(di,{side:"right",color:"black",children:e("editor.controls.actions.export.print")})]})]})]})}import{Fragment as Uu,jsx as ke,jsxs as Mt}from"react/jsx-runtime";var $u=({nodes:e,edges:t,validateDiagram:o,handleValidationComplete:n})=>{let{t:r}=Wx(),{clearSelection:i}=Vt(),{mode:a,isMinimapOpen:s,setIsMinimapOpen:l,isMoveTool:c,isHandTool:d,setIsMoveTool:u,setIsHandTool:m}=J(),{getNodes:p,getEdges:g}=Yx(),h=Fu(["v","V"]),f=Fu(["h","H"]),y=Ns(()=>{i(),m(!0),u(!1)},[i,m,u]),N=Ns(()=>{u(!0),m(!1)},[u,m]),E=Ns(()=>{let T=p(),b=g(),x=o({nodes:T,edges:b});n(x)},[p,g,o,n]);return Xu(()=>{h&&!c&&a==="edit"&&N()},[h,N,c,a]),Xu(()=>{f&&!d&&a==="edit"&&y()},[f,y,d,a]),Mt("div",{className:"flex items-center gap-2 px-3 py-2 bg-white rounded-sm shadow-md",children:[a==="edit"&&Mt(Uu,{children:[Mt(fi,{children:[ke(gi,{asChild:!0,children:ke(pi,{size:"small",variant:"ghost",color:"grey",className:G(c&&"bg-grey-400"),iconButton:!0,onClick:N,children:ke($x,{})})}),Mt(mi,{color:"black",className:"flex items-center gap-2",children:[r("editor.controls.actions.move_tool"),ke(Es,{shortcut:"V"})]})]}),Mt(fi,{children:[ke(gi,{asChild:!0,children:ke(pi,{size:"small",variant:"ghost",color:"grey",className:G(d&&"bg-grey-400"),iconButton:!0,onClick:y,children:ke(Fx,{})})}),Mt(mi,{color:"black",className:"flex items-center gap-2",children:[r("editor.controls.actions.hand_tool")," ",ke(Es,{shortcut:"H"})]})]})]}),ke(Wu,{}),a==="edit"&&Mt(Uu,{children:[Mt(fi,{children:[ke(gi,{asChild:!0,children:ke(pi,{size:"small",variant:"ghost",color:"grey",iconButton:!0,onClick:E,children:ke(Xx,{})})}),ke(mi,{color:"black",children:r("editor.controls.actions.check")})]}),ke(Gu,{disabled:e.length>0||t.length>0})]}),Mt(fi,{children:[ke(gi,{asChild:!0,children:ke(pi,{size:"small",variant:"ghost",color:"grey",className:G(s&&"bg-grey-400"),iconButton:!0,onClick:()=>l(!s),children:ke(Ux,{})})}),ke(mi,{color:"black",children:r(s?"editor.controls.actions.minimap.close":"editor.controls.actions.minimap.open")})]})]})};import{Button as Ku,Tooltip as qu,TooltipContent as Zu,TooltipTrigger as Ju,useTranslation as Kx}from"@produto-lecom/lecom-ui";import{RedoIcon as qx,UndoIcon as Zx}from"lucide-react";import{jsx as qt,jsxs as Ts}from"react/jsx-runtime";var Qu=({undo:e,redo:t,canUndo:o,canRedo:n})=>{let{t:r}=Kx();return Ts("div",{className:"flex items-center gap-2 px-3 py-2 bg-white rounded-sm shadow-md",children:[Ts(qu,{children:[qt(Ju,{asChild:!0,children:qt(Ku,{size:"small",variant:"ghost",color:"grey",iconButton:!0,disabled:!o,onClick:e,children:qt(Zx,{})})}),qt(Zu,{color:"black",children:r("editor.controls.history.undo")})]}),Ts(qu,{children:[qt(Ju,{asChild:!0,children:qt(Ku,{size:"small",variant:"ghost",color:"grey",iconButton:!0,disabled:!n,onClick:t,children:qt(qx,{})})}),qt(Zu,{color:"black",children:r("editor.controls.history.redo")})]})]})};import{useEdges as Jx,useNodes as Qx,useReactFlow as jx}from"@xyflow/react";import{Button as hi,Tooltip as yi,TooltipContent as xi,TooltipTrigger as Ei,useTranslation as eE}from"@produto-lecom/lecom-ui";import{ScanIcon as tE,ZoomIn as oE,ZoomOut as nE}from"lucide-react";import{jsx as Ve,jsxs as Pn}from"react/jsx-runtime";var ju=()=>{let{t:e}=eE(),t=Qx(),o=Jx(),{zoomIn:n,zoomOut:r,zoomTo:i,fitView:a}=jx(),s=t.length===0&&o.length===0;return Pn("div",{className:"flex items-center gap-2 px-3 py-2 bg-white rounded-sm shadow-md",children:[Pn(yi,{children:[Ve(Ei,{asChild:!0,children:Ve(hi,{iconButton:!0,size:"small",color:"grey",variant:"ghost",disabled:s,onClick:()=>a(),children:Ve(tE,{})})}),Ve(xi,{color:"black",children:e("editor.controls.zoom.fit")})]}),Pn(yi,{children:[Ve(Ei,{asChild:!0,children:Ve(hi,{iconButton:!0,size:"small",color:"grey",variant:"ghost",disabled:s,onClick:()=>r(),children:Ve(nE,{})})}),Ve(xi,{color:"black",children:e("editor.controls.zoom.out")})]}),Pn(yi,{children:[Ve(Ei,{asChild:!0,children:Ve(hi,{iconButton:!0,size:"small",color:"grey",variant:"ghost",disabled:s,onClick:()=>i(1),children:Ve(Fs,{})})}),Ve(xi,{color:"black",children:e("editor.controls.zoom.reset")})]}),Pn(yi,{children:[Ve(Ei,{asChild:!0,children:Ve(hi,{iconButton:!0,size:"small",color:"grey",variant:"ghost",disabled:s,onClick:()=>n(),children:Ve(oE,{})})}),Ve(xi,{color:"black",children:e("editor.controls.zoom.in")})]})]})};import{useNodes as rE}from"@xyflow/react";import{Button as iE,Tooltip as sE,TooltipContent as aE,TooltipTrigger as lE,useTranslation as cE}from"@produto-lecom/lecom-ui";import{useRef as dE,useState as uE}from"react";import{jsx as go,jsxs as ep}from"react/jsx-runtime";var tp=()=>{let e=dE(null),{t}=cE(),{setDraggableNode:o}=Vo(),n=rE(),{setIsDragging:r}=J(),[i,a]=uE(void 0),s=[{type:"START_EVENT",icon:Hn,label:t("bpmn.start_event.variant.default")},{type:"END_EVENT",icon:ho,label:t("bpmn.end_event.variant.default")},{type:"TASK",icon:$o,label:t("bpmn.task.variant.default")},{type:"TASK",variant:"SUBPROCESS",icon:qs,label:t("bpmn.task.variant.subprocess")},{type:"TASK",variant:"SCRIPT",icon:Ks,label:t("bpmn.task.variant.script")},{type:"TASK",attribute:"LOOP",icon:$s,label:t("bpmn.task.attribute.loop")},{type:"GATEWAY",variant:"EXCLUSIVE",icon:xo,label:t("bpmn.gateway.variant.exclusive")},{type:"GATEWAY",variant:"PARALLEL",icon:Eo,label:t("bpmn.gateway.variant.parallel")},{type:"GATEWAY",variant:"COMPLEX",icon:yo,label:t("bpmn.gateway.variant.complex")},{type:"LANE",icon:Ws,label:t("bpmn.lane.variant.default")},{type:"ANNOTATION",icon:Dn,label:t("bpmn.annotation.variant.default")}],l=(c,d)=>{o({type:d.type,variant:d.variant,attribute:d.attribute,icon:d.icon}),a(go(d.icon,{})),c.dataTransfer.effectAllowed="move",e.current&&c.dataTransfer.setDragImage(e.current,10,10),setTimeout(()=>{r(!0)},100)};return ep("aside",{className:"sidebar absolute z-[1] top-4 left-4",children:[go("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 ep(sE,{children:[go(lE,{asChild:!0,children:go(iE,{className:G("[&>svg]:size-6",{"opacity-50 cursor-not-allowed":u}),size:"small",variant:"ghost",color:"grey",draggable:!u,disabled:u,iconButton:!0,onDragStart:u?void 0:p=>l(p,c),children:go(c.icon,{})},d)}),go(aE,{color:"black",side:"right",children:m})]},d)})}),go("div",{ref:e,className:"absolute w-0 h-0 top-0 left-0 z-[-1] bg-transparent",children:i})]})};import{jsx as ct,jsxs as bi}from"react/jsx-runtime";var ws=e=>e.preventDefault(),Is=yE((e,t)=>{let o=hE("Space"),{instanceId:n,mode:r,isMinimapOpen:i,isMoveTool:a,isHandTool:s}=J(),l=vs(null),c=vs(s),d=vs(o),{nodes:u,edges:m,actions:p,events:g,components:h,controls:f}=Nu(),{t:y}=NE();c.current=s,d.current=o;let N=Tu(l,c,d);xE(t,()=>({selectElements:p.selectElements,clearSelection:p.clearSelection}));let E=s||o||r!=="edit",T=E?[0,1,2]:vn,b=s||o||N,x=a&&!o&&!N,w=r==="edit"&&x,A=!E&&!N,I=r==="view"||x;return bi("div",{ref:l,className:"w-full h-full",children:[r==="edit"&&ct(tp,{}),ct(wu,{}),bi(mE,v(_({},g),{id:`modeler-${n}`,className:G({"is-hand-tool":b,"is-pan-tool-active":b}),edges:m,nodes:u,nodeTypes:Ld,edgeTypes:kd,minZoom:ys,maxZoom:Gd,panOnDrag:T,panOnScroll:!0,selectionOnDrag:A,elevateEdgesOnSelect:!0,elevateNodesOnSelect:!0,elementsSelectable:I,nodesConnectable:w,nodesDraggable:w,connectionLineComponent:Sd,selectionMode:gE.Partial,multiSelectionKeyCode:["Control","Meta"],deleteKeyCode:w?"Delete":null,selectionKeyCode:null,defaultViewport:Bd,connectOnClick:!1,connectionRadius:50,onPaneContextMenu:ws,onNodeContextMenu:ws,onEdgeContextMenu:ws,proOptions:{hideAttribution:!0},children:[ct(pE,{gap:Hd,size:Od,color:Dd,bgColor:Rd}),i&&bi(EE,{children:[ct(_E,{asChild:!0,children:ct("div",{className:"absolute bottom-[0px] left-[0px] z-[5]",children:ct(fE,{pannable:!0,zoomable:!0,position:Vd,className:"shadow-md rounded-md",ariaLabel:"",style:{pointerEvents:"all",position:"relative"}})})}),ct(bE,{color:"black",children:y("editor.controls.actions.minimap.label")})]}),bi("div",{className:"absolute z-10 bottom-4 left-1/2 -translate-x-1/2 flex gap-4",children:[r==="edit"&&ct(Qu,_({},f)),ct($u,{nodes:u,edges:m,validateDiagram:p.validateDiagram,handleValidationComplete:p.handleValidationComplete}),ct(ju,{})]}),ct(h.HelperLines,{})]}))]})});Is.displayName="Editor";import{useStore as TE}from"@xyflow/react";import{useEffect as vE,useRef as wE}from"react";import{jsx as AE}from"react/jsx-runtime";var IE=e=>({width:e.width,height:e.height,transform:e.transform}),As="rgba(51, 103, 217, 0.4)",oc=({horizontal:e,vertical:t})=>{let{width:o,height:n,transform:r}=TE(IE),i=wE(null);return vE(()=>{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=As,t&&(s.beginPath(),s.strokeStyle=t.color||As,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||As,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]),AE("canvas",{ref:i,className:"w-full h-full absolute z-10 pointer-events-none"})};import{i18n as CE,Notification as SE,TooltipProvider as ME}from"@produto-lecom/lecom-ui";import{createContext as PE,useContext as LE,useEffect as kE,useState as RE}from"react";import{jsx as op,jsxs as OE}from"react/jsx-runtime";var xt=new Map,np=PE(null),hn=()=>{let e=LE(np);if(!e)throw new Error("useModeler must be used within an <ModelerProvider />");return e},DE=({locale:e,defaultMode:t="view",toast:o,children:n})=>{let[r,i]=RE(e||"pt_BR");kE(()=>{e&&(i(e),CE.changeLanguage(e))},[e]);let a=g=>{let h=xt.size;if(h===0)throw new Error("No modeler instances found");if(h===1||!g){let[y]=xt.values();return y}let f=xt.get(g);if(!f)throw new Error(`Modeler instance with ID "${g}" not found`);return f},s=(g,h)=>{let f=a(h);return f==null?void 0:f.selectElements(g)},l=async g=>{let h=a(g);return h==null?void 0:h.clearSelection()},c=(g,h)=>{let f=a(h);return f==null?void 0:f.configureElement(g)},d=(g,h)=>{let f=a(h);return f==null?void 0:f.getConfigureElement(g)},u=async(g,h)=>{let f=a(h);await(f==null?void 0:f.importFromMxGraph(g))},m=g=>{let h=a(g);return h==null?void 0:h.exportToMxGraph()},p=g=>{let h=a(g);return(h==null?void 0:h.getElementsCount())||0};return op(np.Provider,{value:{defaultMode:t,locale:r,selectElements:s,clearSelection:l,configureElement:c,getConfigureElement:d,importDiagram:u,exportDiagram:m,getElementsCount:p,toast:o},children:OE(ME,{children:[!o&&op(SE,{type:"toast",placement:"topRight",enableClose:!0,showProgress:!0,pauseOnHover:!0}),n]})})};import{useTranslation as WE}from"@produto-lecom/lecom-ui";import{jsx as Cs}from"react/jsx-runtime";var rp=VE(null),J=()=>{let e=GE(rp);if(!e)throw new Error("useModelerInstance must be used within an <Modeler />");return e},FE=({selectorRef:e,initialDiagram:t,instanceId:o,mode:n,onElementChanges:r,onConfigureElement:i,onElementClick:a,onSubprocessValidationClick:s})=>{let{t:l}=WE(),{defaultMode:c}=hn(),d=zE(),[u]=dt(o||d),[m,p]=dt(n||c||"edit"),[g,h]=dt(bn),[f,y]=dt(!1),[N,E]=dt(!0),[T,b]=dt(!1),[x,w]=dt(!1),[A,I]=dt(!1),[D,S]=dt(!1),[L,z]=dt(!1),[U,K]=dt(null);BE(()=>{n&&p(n)},[n]);let Y=YE(()=>t||Kc(l),[t,l]),X={instanceId:u,initialDiagram:Y,mode:m,lastElementId:g,isInitialized:f,isMinimapOpen:x,isMoveTool:N,isHandTool:T,isDragging:A,isMultipleSelection:L,isConnecting:D,setLastElementId:h,setIsInitialized:y,reconnectingEdgeId:U,setIsMinimapOpen:w,setIsMoveTool:E,setIsHandTool:b,setIsDragging:I,setIsConnecting:S,setIsMultipleSelection:z,setReconnectingEdgeId:K,onElementChanges:r,onConfigureElement:i,onElementClick:a,onSubprocessValidationClick:s};return Cs(HE,{children:Cs(rp.Provider,{value:X,children:Cs(Is,{ref:e})})})};export{Re as EditorMode,Ni as ElementPosition,kn as ElementType,Ti as GatewayElementVariant,st as GatewayVariant,FE as Modeler,DE as ModelerProvider,gt as NodeAttribute,ie as NodeType,it as NodeVariant,vi as RoutingVariant,hn as useModeler};