lecom-modeler 0.23.0 → 0.24.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.
Files changed (3) hide show
  1. package/lib/index.cjs +13 -13
  2. package/lib/index.js +13 -13
  3. package/package.json +2 -2
package/lib/index.js CHANGED
@@ -1,9 +1,9 @@
1
- var hu=Object.defineProperty,yu=Object.defineProperties;var xu=Object.getOwnPropertyDescriptors;var hn=Object.getOwnPropertySymbols;var es=Object.prototype.hasOwnProperty,ts=Object.prototype.propertyIsEnumerable;var ji=(e,t,o)=>t in e?hu(e,t,{enumerable:!0,configurable:!0,writable:!0,value:o}):e[t]=o,y=(e,t)=>{for(var o in t||(t={}))es.call(t,o)&&ji(e,o,t[o]);if(hn)for(var o of hn(t))ts.call(t,o)&&ji(e,o,t[o]);return e},v=(e,t)=>yu(e,xu(t));var Je=(e,t)=>{var o={};for(var n in e)es.call(e,n)&&t.indexOf(n)<0&&(o[n]=e[n]);if(e!=null&&hn)for(var n of hn(e))t.indexOf(n)<0&&ts.call(e,n)&&(o[n]=e[n]);return o};var Zr=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 Eu,Translations as bu}from"@produto-lecom/lecom-ui";var os={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:{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 ns={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:{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 rs={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:{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 is={pt_BR:rs,en_US:os,es_ES:ns};var ss,as,_u=(as=(ss=Zr("LecomUserLanguage"))!=null?ss:Zr("org.springframework.web.servlet.i18n.CookieLocaleResolver.LOCALE"))!=null?as:bu.PT_BR;Eu({lng:_u,resources:is});var Le=(n=>(n.EDIT="edit",n.VIEW="view",n.READONLY="readonly",n))(Le||{});var yn=(r=>(r.ACTIVITY="activity",r.ROUTING="routing",r.GATEWAY="gateway",r.SUB_PROCESS="sub_process",r))(yn||{}),Jr=(n=>(n.START="start",n.END="end",n.BETWEEN="between",n))(Jr||{}),Qr=(n=>(n.SCRIPT="script",n.LOOP="loop",n.SCRIPT_LOOP="script_loop",n))(Qr||{}),jr=(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))(jr||{});import{RotateCcw as ku,ScrollText as Ru,SquarePlus as Du}from"lucide-react";import{jsx as xn,jsxs as Tu}from"react/jsx-runtime";var En=({size:e=24,className:t})=>Tu("svg",{width:e,height:e,viewBox:"0 0 24 24",xmlns:"http://www.w3.org/2000/svg",fill:"#6b7280",className:t,children:[xn("path",{strokeWidth:"2",d:"M16 3V3.5085V11.9998V20.4915V21H16.5411H21.4592H22V19.123H21.4592H17.9974V11.9998V4.8773H21.4592H22V3H21.4592H16.5411H16Z"}),xn("path",{d:"M4.41026 16.9999L2 18.7861L3.89693 21.1103L6.3072 19.324L4.41026 16.9999Z"}),xn("path",{d:"M8.41026 13.9999L6 15.7861L7.89693 18.1103L10.3072 16.324L8.41026 13.9999Z"}),xn("path",{d:"M12.4313 10.954L10.021 12.7402L11.9179 15.0644L14.3282 13.2781L12.4313 10.954Z"})]});import{jsx as ls}from"react/jsx-runtime";var $t=({size:e=24,className:t})=>ls("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:ls("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 wo,jsxs as Nu}from"react/jsx-runtime";var Xt=({size:e=24,className:t})=>Nu("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:"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"}),wo("path",{d:"M12 8V16",strokeLinecap:"round",strokeLinejoin:"round"}),wo("path",{d:"M8 12H16",strokeLinecap:"round",strokeLinejoin:"round"}),wo("path",{d:"M9.17139 9.17188L14.8282 14.8287",strokeLinecap:"round",strokeLinejoin:"round"}),wo("path",{d:"M14.8281 9.17188L9.17127 14.8287",strokeLinecap:"round",strokeLinejoin:"round"})]});import{jsx as ei,jsxs as vu}from"react/jsx-runtime";var Kt=({size:e=24,className:t})=>vu("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:[ei("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"}),ei("path",{d:"M14.8286 9.17188L9.17176 14.8287",strokeLinecap:"round",strokeLinejoin:"round"}),ei("path",{d:"M9.17139 9.17188L14.8282 14.8287",strokeLinecap:"round",strokeLinejoin:"round"})]});import{jsx as ti,jsxs as wu}from"react/jsx-runtime";var qt=({size:e=24,className:t})=>wu("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:[ti("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"}),ti("path",{d:"M12 8V16",strokeLinecap:"round",strokeLinejoin:"round"}),ti("path",{d:"M8 12H16",strokeLinecap:"round",strokeLinejoin:"round"})]});import{jsx as oi,jsxs as Au}from"react/jsx-runtime";var cs=({size:e=24,className:t})=>oi("svg",{width:e,height:e,viewBox:"0 0 34 24",xmlns:"http://www.w3.org/2000/svg",fill:"currentColor",className:t,children:Au("g",{children:[oi("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"}),oi("path",{d:"M24.5 4.5L28 1M28 1L31.5 4.5M28 1V8",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round"})]})});import{clsx as Iu}from"clsx";import{twMerge as Cu}from"tailwind-merge";function O(...e){return Cu(Iu(e))}var pt=(e=0,t=0)=>e<t?t:e,bn=(e=1e3)=>new Promise(t=>{setTimeout(t,e)});import{jsx as ds,jsxs as Su}from"react/jsx-runtime";var us=({size:e=24,className:t})=>Su("svg",{width:e,height:e,viewBox:"0 0 24 24",fill:"none",stroke:"#6b7280",strokeWidth:2,xmlns:"http://www.w3.org/2000/svg",className:O("stroke-2",t),children:[ds("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"}),ds("path",{d:"M9 3V21",strokeLinecap:"round",strokeLinejoin:"round"})]});import{jsx as ni}from"react/jsx-runtime";var ps=({size:e=24,className:t})=>ni("svg",{width:e,height:e,viewBox:"0 0 24 24",xmlns:"http://www.w3.org/2000/svg",stroke:"currentColor",className:t,children:ni("g",{children:ni("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 fs}from"react/jsx-runtime";var _n=({size:e=24,className:t})=>fs("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:fs("path",{d:"M12 22C17.5228 22 22 17.5228 22 12C22 6.47715 17.5228 2 12 2C6.47715 2 2 6.47715 2 12C2 17.5228 6.47715 22 12 22Z",strokeLinecap:"round",strokeLinejoin:"round"})});import{jsx as ms}from"react/jsx-runtime";var Ao=({size:e=24,className:t})=>ms("svg",{width:e,height:e,viewBox:"0 0 24 24",xmlns:"http://www.w3.org/2000/svg",fill:"white",stroke:"#6b7280",className:O("stroke-2",t),children:ms("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 ri,jsxs as Mu}from"react/jsx-runtime";var gs=({size:e=24,className:t})=>Mu("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:[ri("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"}),ri("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"}),ri("path",{d:"M7.5 7.5V10H10",strokeWidth:"1.5",fill:"none",strokeLinecap:"round",strokeLinejoin:"round"})]});import{jsx as Io,jsxs as Pu}from"react/jsx-runtime";var hs=({size:e=24,className:t})=>Pu("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:[Io("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"}),Io("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"}),Io("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"}),Io("path",{d:"M13.5 12H11",strokeWidth:"1",strokeLinecap:"round",strokeLinejoin:"round"}),Io("path",{d:"M13.5 10H11",strokeWidth:"1",strokeLinecap:"round",strokeLinejoin:"round"})]});import{jsx as Tn,jsxs as Lu}from"react/jsx-runtime";var ys=({size:e=24,className:t})=>Lu("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:[Tn("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"}),Tn("path",{d:"M8 21V14C8 13.4477 8.44772 13 9 13H15C15.5523 13 16 13.4477 16 14V21",strokeWidth:"1",fill:"none"}),Tn("path",{d:"M10.2222 17H13.7777",strokeWidth:"1",strokeLinecap:"round",strokeLinejoin:"round"}),Tn("path",{d:"M12 15.2227V18.7782",strokeWidth:"1",strokeLinecap:"round",strokeLinejoin:"round"})]});var ee=(a=>(a.START_EVENT="START_EVENT",a.END_EVENT="END_EVENT",a.TASK="TASK",a.LANE="LANE",a.GATEWAY="GATEWAY",a.ANNOTATION="ANNOTATION",a.UNSUPPORTED="UNSUPPORTED",a))(ee||{}),Ue=(o=>(o.SCRIPT="SCRIPT",o.SUBPROCESS="SUBPROCESS",o))(Ue||{}),Nn={SCRIPT:{icon:Ru},SUBPROCESS:{icon:Du}},Qe=(t=>(t.LOOP="LOOP",t))(Qe||{}),vn={LOOP:{icon:ku}},$e=(n=>(n.EXCLUSIVE="EXCLUSIVE",n.PARALLEL="PARALLEL",n.COMPLEX="COMPLEX",n))($e||{}),ii={EXCLUSIVE:{icon:Kt},PARALLEL:{icon:qt},COMPLEX:{icon:Xt}};import{ReactFlowProvider as Mx}from"@xyflow/react";import{createContext as Px,useContext as Lx,useEffect as kx,useId as Rx,useMemo as Dx,useState as qe}from"react";import{Background as ix,MiniMap as sx,ReactFlow as ax,SelectionMode as lx,useKeyPress as cx}from"@xyflow/react";import{forwardRef as dx,useImperativeHandle as ux}from"react";import{useTranslation as zy}from"@produto-lecom/lecom-ui";import{useEdgesState as Fy,useNodesState as Wy,useOnSelectionChange as Yy,useReactFlow as Uy,useStoreApi as $y}from"@xyflow/react";import{useCallback as It,useEffect as Xy}from"react";import{Position as Co}from"@xyflow/react";function xs(e,t){var b,T,N,x;let{width:o=0,height:n=0}=e.measured||{width:0,height:0},r=e.internals.positionAbsolute,i=t.internals.positionAbsolute,s=o/2,a=n/2,l=r.x+s,c=r.y+a,d=i.x+((T=(b=t==null?void 0:t.measured)==null?void 0:b.width)!=null?T:0)/2,u=i.y+((x=(N=t==null?void 0:t.measured)==null?void 0:N.height)!=null?x:0)/2,p=(d-l)/(2*s)-(u-c)/(2*a),f=(d-l)/(2*s)+(u-c)/(2*a),h=1/(Math.abs(p)+Math.abs(f)||1),g=h*p,m=h*f,E=s*(g+m)+l,_=a*(-g+m)+c;return{x:E,y:_}}function Es(e,t){var c,d,u,p;let{positionAbsolute:o}=e.internals,n=(d=(c=e.measured)==null?void 0:c.width)!=null?d:0,r=(p=(u=e.measured)==null?void 0:u.height)!=null?p:0,i=Math.round(o.x),s=Math.round(o.y),a=Math.round(t.x),l=Math.round(t.y);return a<=i+1?Co.Left:a>=i+n-1?Co.Right:l<=s+1?Co.Top:l>=s+r-1?Co.Bottom:Co.Top}function Zt(e,t){let o=xs(e,t),n=xs(t,e),r=Es(e,o),i=Es(t,n);return{sx:o.x,sy:o.y,tx:n.x,ty:n.y,sourcePos:r,targetPos:i}}function wn(e,t){return{isFromStartEvent:(e==null?void 0:e.type)==="START_EVENT",isGatewayToGateway:(e==null?void 0:e.type)==="GATEWAY"&&(t==null?void 0:t.type)==="GATEWAY",isActiviyToAndGateway:(e==null?void 0:e.type)==="TASK"&&(t==null?void 0:t.type)==="GATEWAY"}}import{create as Ou}from"zustand";import{useReactFlow as Vu}from"@xyflow/react";import{useCallback as Hu}from"react";var An=()=>{let{setEdges:e}=Vu();return Hu(()=>{let o=St.getState().pathEdgeIds;e(n=>n.map(r=>v(y({},r),{selected:o.includes(r.id)})))},[e])},St=Ou((e,t)=>({statusByNodeId:{},statusData:{},pathEdgeIds:[],setTaskStatuses:o=>{o!=null&&o.length&&e(n=>{let r=y({},n.statusByNodeId),i=y({},n.statusData),s=!1;return o.forEach(a=>{let l=`${a.diagramId}-${a.activityId}`;r[a.diagramId]!==a.status&&(r[a.diagramId]=a.status,i[l]=a,s=!0)}),s?{statusByNodeId:r,statusData:i}:n})},getTaskStatus:o=>t().statusByNodeId[o]||null,clearTaskStatuses:()=>e({statusByNodeId:{},statusData:{},pathEdgeIds:[]}),setPathEdges:o=>{e({pathEdgeIds:o})},getPathEdgeIds:()=>t().pathEdgeIds,clearPathEdges:()=>{e({pathEdgeIds:[]})},calculateFlowPath:(o,n)=>{if(!o.length||!n.length)return;t().clearPathEdges();let r=n.filter(d=>t().statusByNodeId[d]);if(r.length<=1)return;let i=[],s={};o.forEach(d=>{s[d.source]||(s[d.source]=[]),s[d.source].push({targetId:d.target,edgeId:d.id})});let a=r[0],l=r[r.length-1];o.forEach(d=>{d.target===a&&i.push(d.id)}),o.forEach(d=>{d.source===l&&i.push(d.id)});let c=(d,u)=>{let p=[],f=new Set;for(p.push({node:d,path:[]}),f.add(d);p.length>0;){let{node:h,path:g}=p.shift();if(h===u)return g;let m=s[h]||[];for(let{targetId:E,edgeId:_}of m)f.has(E)||(f.add(E),p.push({node:E,path:[...g,_]}))}return[]};for(let d=0;d<r.length-1;d++){let u=r[d],p=r[d+1],f=c(u,p);f.length>0&&i.push(...f)}i.length>0&&e({pathEdgeIds:i})}}));import{useNodesInitialized as em,useReactFlow as tm,useStore as om}from"@xyflow/react";import{useCallback as Wo,useEffect as nm,useRef as rm,useState as fl}from"react";import{shallow as im}from"zustand/shallow";var Gu={value:()=>{}};function _s(){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 In(o)}function In(e){this._=e}function Bu(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}})}In.prototype=_s.prototype={constructor:In,on:function(e,t){var o=this._,n=Bu(e+"",o),r,i=-1,s=n.length;if(arguments.length<2){for(;++i<s;)if((r=(e=n[i]).type)&&(r=zu(o[r],e.name)))return r;return}if(t!=null&&typeof t!="function")throw new Error("invalid callback: "+t);for(;++i<s;)if(r=(e=n[i]).type)o[r]=bs(o[r],e.name,t);else if(t==null)for(r in o)o[r]=bs(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 In(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 zu(e,t){for(var o=0,n=e.length,r;o<n;++o)if((r=e[o]).name===t)return r.value}function bs(e,t,o){for(var n=0,r=e.length;n<r;++n)if(e[n].name===t){e[n]=Gu,e=e.slice(0,n).concat(e.slice(n+1));break}return o!=null&&e.push({name:t,value:o}),e}var si=_s;var Cn="http://www.w3.org/1999/xhtml",ai={svg:"http://www.w3.org/2000/svg",xhtml:Cn,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)),ai.hasOwnProperty(t)?{space:ai[t],local:e}:e}function Fu(e){return function(){var t=this.ownerDocument,o=this.namespaceURI;return o===Cn&&t.documentElement.namespaceURI===Cn?t.createElement(e):t.createElementNS(o,e)}}function Wu(e){return function(){return this.ownerDocument.createElementNS(e.space,e.local)}}function Sn(e){var t=nt(e);return(t.local?Wu:Fu)(t)}function Yu(){}function Mt(e){return e==null?Yu:function(){return this.querySelector(e)}}function Ts(e){typeof e!="function"&&(e=Mt(e));for(var t=this._groups,o=t.length,n=new Array(o),r=0;r<o;++r)for(var i=t[r],s=i.length,a=n[r]=new Array(s),l,c,d=0;d<s;++d)(l=i[d])&&(c=e.call(l,l.__data__,d,i))&&("__data__"in l&&(c.__data__=l.__data__),a[d]=c);return new xe(n,this._parents)}function li(e){return e==null?[]:Array.isArray(e)?e:Array.from(e)}function Uu(){return[]}function So(e){return e==null?Uu:function(){return this.querySelectorAll(e)}}function $u(e){return function(){return li(e.apply(this,arguments))}}function Ns(e){typeof e=="function"?e=$u(e):e=So(e);for(var t=this._groups,o=t.length,n=[],r=[],i=0;i<o;++i)for(var s=t[i],a=s.length,l,c=0;c<a;++c)(l=s[c])&&(n.push(e.call(l,l.__data__,c,s)),r.push(l));return new xe(n,r)}function Mo(e){return function(){return this.matches(e)}}function Mn(e){return function(t){return t.matches(e)}}var Xu=Array.prototype.find;function Ku(e){return function(){return Xu.call(this.children,e)}}function qu(){return this.firstElementChild}function vs(e){return this.select(e==null?qu:Ku(typeof e=="function"?e:Mn(e)))}var Zu=Array.prototype.filter;function Ju(){return Array.from(this.children)}function Qu(e){return function(){return Zu.call(this.children,e)}}function ws(e){return this.selectAll(e==null?Ju:Qu(typeof e=="function"?e:Mn(e)))}function As(e){typeof e!="function"&&(e=Mo(e));for(var t=this._groups,o=t.length,n=new Array(o),r=0;r<o;++r)for(var i=t[r],s=i.length,a=n[r]=[],l,c=0;c<s;++c)(l=i[c])&&e.call(l,l.__data__,c,i)&&a.push(l);return new xe(n,this._parents)}function Pn(e){return new Array(e.length)}function Is(){return new xe(this._enter||this._groups.map(Pn),this._parents)}function Po(e,t){this.ownerDocument=e.ownerDocument,this.namespaceURI=e.namespaceURI,this._next=null,this._parent=e,this.__data__=t}Po.prototype={constructor:Po,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 Cs(e){return function(){return e}}function ju(e,t,o,n,r,i){for(var s=0,a,l=t.length,c=i.length;s<c;++s)(a=t[s])?(a.__data__=i[s],n[s]=a):o[s]=new Po(e,i[s]);for(;s<l;++s)(a=t[s])&&(r[s]=a)}function ep(e,t,o,n,r,i,s){var a,l,c=new Map,d=t.length,u=i.length,p=new Array(d),f;for(a=0;a<d;++a)(l=t[a])&&(p[a]=f=s.call(l,l.__data__,a,t)+"",c.has(f)?r[a]=l:c.set(f,l));for(a=0;a<u;++a)f=s.call(e,i[a],a,i)+"",(l=c.get(f))?(n[a]=l,l.__data__=i[a],c.delete(f)):o[a]=new Po(e,i[a]);for(a=0;a<d;++a)(l=t[a])&&c.get(p[a])===l&&(r[a]=l)}function tp(e){return e.__data__}function Ss(e,t){if(!arguments.length)return Array.from(this,tp);var o=t?ep:ju,n=this._parents,r=this._groups;typeof e!="function"&&(e=Cs(e));for(var i=r.length,s=new Array(i),a=new Array(i),l=new Array(i),c=0;c<i;++c){var d=n[c],u=r[c],p=u.length,f=op(e.call(d,d&&d.__data__,c,n)),h=f.length,g=a[c]=new Array(h),m=s[c]=new Array(h),E=l[c]=new Array(p);o(d,u,g,m,E,f,t);for(var _=0,b=0,T,N;_<h;++_)if(T=g[_]){for(_>=b&&(b=_+1);!(N=m[b])&&++b<h;);T._next=N||null}}return s=new xe(s,n),s._enter=a,s._exit=l,s}function op(e){return typeof e=="object"&&"length"in e?e:Array.from(e)}function Ms(){return new xe(this._exit||this._groups.map(Pn),this._parents)}function Ps(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 Ls(e){for(var t=e.selection?e.selection():e,o=this._groups,n=t._groups,r=o.length,i=n.length,s=Math.min(r,i),a=new Array(r),l=0;l<s;++l)for(var c=o[l],d=n[l],u=c.length,p=a[l]=new Array(u),f,h=0;h<u;++h)(f=c[h]||d[h])&&(p[h]=f);for(;l<r;++l)a[l]=o[l];return new xe(a,this._parents)}function ks(){for(var e=this._groups,t=-1,o=e.length;++t<o;)for(var n=e[t],r=n.length-1,i=n[r],s;--r>=0;)(s=n[r])&&(i&&s.compareDocumentPosition(i)^4&&i.parentNode.insertBefore(s,i),i=s);return this}function Rs(e){e||(e=np);function t(u,p){return u&&p?e(u.__data__,p.__data__):!u-!p}for(var o=this._groups,n=o.length,r=new Array(n),i=0;i<n;++i){for(var s=o[i],a=s.length,l=r[i]=new Array(a),c,d=0;d<a;++d)(c=s[d])&&(l[d]=c);l.sort(t)}return new xe(r,this._parents).order()}function np(e,t){return e<t?-1:e>t?1:e>=t?0:NaN}function Ds(){var e=arguments[0];return arguments[0]=this,e.apply(null,arguments),this}function Os(){return Array.from(this)}function Vs(){for(var e=this._groups,t=0,o=e.length;t<o;++t)for(var n=e[t],r=0,i=n.length;r<i;++r){var s=n[r];if(s)return s}return null}function Hs(){let e=0;for(let t of this)++e;return e}function Gs(){return!this.node()}function Bs(e){for(var t=this._groups,o=0,n=t.length;o<n;++o)for(var r=t[o],i=0,s=r.length,a;i<s;++i)(a=r[i])&&e.call(a,a.__data__,i,r);return this}function rp(e){return function(){this.removeAttribute(e)}}function ip(e){return function(){this.removeAttributeNS(e.space,e.local)}}function sp(e,t){return function(){this.setAttribute(e,t)}}function ap(e,t){return function(){this.setAttributeNS(e.space,e.local,t)}}function lp(e,t){return function(){var o=t.apply(this,arguments);o==null?this.removeAttribute(e):this.setAttribute(e,o)}}function cp(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 zs(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?ip:rp:typeof t=="function"?o.local?cp:lp:o.local?ap:sp)(o,t))}function Ln(e){return e.ownerDocument&&e.ownerDocument.defaultView||e.document&&e||e.defaultView}function dp(e){return function(){this.style.removeProperty(e)}}function up(e,t,o){return function(){this.style.setProperty(e,t,o)}}function pp(e,t,o){return function(){var n=t.apply(this,arguments);n==null?this.style.removeProperty(e):this.style.setProperty(e,n,o)}}function Fs(e,t,o){return arguments.length>1?this.each((t==null?dp:typeof t=="function"?pp:up)(e,t,o==null?"":o)):ft(this.node(),e)}function ft(e,t){return e.style.getPropertyValue(t)||Ln(e).getComputedStyle(e,null).getPropertyValue(t)}function fp(e){return function(){delete this[e]}}function mp(e,t){return function(){this[e]=t}}function gp(e,t){return function(){var o=t.apply(this,arguments);o==null?delete this[e]:this[e]=o}}function Ws(e,t){return arguments.length>1?this.each((t==null?fp:typeof t=="function"?gp:mp)(e,t)):this.node()[e]}function Ys(e){return e.trim().split(/^|\s+/)}function ci(e){return e.classList||new Us(e)}function Us(e){this._node=e,this._names=Ys(e.getAttribute("class")||"")}Us.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 $s(e,t){for(var o=ci(e),n=-1,r=t.length;++n<r;)o.add(t[n])}function Xs(e,t){for(var o=ci(e),n=-1,r=t.length;++n<r;)o.remove(t[n])}function hp(e){return function(){$s(this,e)}}function yp(e){return function(){Xs(this,e)}}function xp(e,t){return function(){(t.apply(this,arguments)?$s:Xs)(this,e)}}function Ks(e,t){var o=Ys(e+"");if(arguments.length<2){for(var n=ci(this.node()),r=-1,i=o.length;++r<i;)if(!n.contains(o[r]))return!1;return!0}return this.each((typeof t=="function"?xp:t?hp:yp)(o,t))}function Ep(){this.textContent=""}function bp(e){return function(){this.textContent=e}}function _p(e){return function(){var t=e.apply(this,arguments);this.textContent=t==null?"":t}}function qs(e){return arguments.length?this.each(e==null?Ep:(typeof e=="function"?_p:bp)(e)):this.node().textContent}function Tp(){this.innerHTML=""}function Np(e){return function(){this.innerHTML=e}}function vp(e){return function(){var t=e.apply(this,arguments);this.innerHTML=t==null?"":t}}function Zs(e){return arguments.length?this.each(e==null?Tp:(typeof e=="function"?vp:Np)(e)):this.node().innerHTML}function wp(){this.nextSibling&&this.parentNode.appendChild(this)}function Js(){return this.each(wp)}function Ap(){this.previousSibling&&this.parentNode.insertBefore(this,this.parentNode.firstChild)}function Qs(){return this.each(Ap)}function js(e){var t=typeof e=="function"?e:Sn(e);return this.select(function(){return this.appendChild(t.apply(this,arguments))})}function Ip(){return null}function ea(e,t){var o=typeof e=="function"?e:Sn(e),n=t==null?Ip:typeof t=="function"?t:Mt(t);return this.select(function(){return this.insertBefore(o.apply(this,arguments),n.apply(this,arguments)||null)})}function Cp(){var e=this.parentNode;e&&e.removeChild(this)}function ta(){return this.each(Cp)}function Sp(){var e=this.cloneNode(!1),t=this.parentNode;return t?t.insertBefore(e,this.nextSibling):e}function Mp(){var e=this.cloneNode(!0),t=this.parentNode;return t?t.insertBefore(e,this.nextSibling):e}function oa(e){return this.select(e?Mp:Sp)}function na(e){return arguments.length?this.property("__data__",e):this.node().__data__}function Pp(e){return function(t){e.call(this,t,this.__data__)}}function Lp(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 kp(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 Rp(e,t,o){return function(){var n=this.__on,r,i=Pp(t);if(n){for(var s=0,a=n.length;s<a;++s)if((r=n[s]).type===e.type&&r.name===e.name){this.removeEventListener(r.type,r.listener,r.options),this.addEventListener(r.type,r.listener=i,r.options=o),r.value=t;return}}this.addEventListener(e.type,i,o),r={type:e.type,name:e.name,value:t,listener:i,options:o},n?n.push(r):this.__on=[r]}}function ra(e,t,o){var n=Lp(e+""),r,i=n.length,s;if(arguments.length<2){var a=this.node().__on;if(a){for(var l=0,c=a.length,d;l<c;++l)for(r=0,d=a[l];r<i;++r)if((s=n[r]).type===d.type&&s.name===d.name)return d.value}return}for(a=t?Rp:kp,r=0;r<i;++r)this.each(a(n[r],t,o));return this}function ia(e,t,o){var n=Ln(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 Dp(e,t){return function(){return ia(this,e,t)}}function Op(e,t){return function(){return ia(this,e,t.apply(this,arguments))}}function sa(e,t){return this.each((typeof t=="function"?Op:Dp)(e,t))}function*aa(){for(var e=this._groups,t=0,o=e.length;t<o;++t)for(var n=e[t],r=0,i=n.length,s;r<i;++r)(s=n[r])&&(yield s)}var Vp=[null];function xe(e,t){this._groups=e,this._parents=t}function la(){return new xe([[document.documentElement]],Vp)}function Hp(){return this}xe.prototype=la.prototype={constructor:xe,select:Ts,selectAll:Ns,selectChild:vs,selectChildren:ws,filter:As,data:Ss,enter:Is,exit:Ms,join:Ps,merge:Ls,selection:Hp,order:ks,sort:Rs,call:Ds,nodes:Os,node:Vs,size:Hs,empty:Gs,each:Bs,attr:zs,style:Fs,property:Ws,classed:Ks,text:qs,html:Zs,raise:Js,lower:Qs,append:js,insert:ea,remove:ta,clone:oa,datum:na,on:ra,dispatch:sa,[Symbol.iterator]:aa};var rt=la;function kn(e,t,o){e.prototype=t.prototype=o,o.constructor=e}function di(e,t){var o=Object.create(e.prototype);for(var n in t)o[n]=t[n];return o}function Ro(){}var Lo=.7,On=1/Lo,Jt="\\s*([+-]?\\d+)\\s*",ko="\\s*([+-]?(?:\\d*\\.)?\\d+(?:[eE][+-]?\\d+)?)\\s*",je="\\s*([+-]?(?:\\d*\\.)?\\d+(?:[eE][+-]?\\d+)?)%\\s*",Gp=/^#([0-9a-f]{3,8})$/,Bp=new RegExp(`^rgb\\(${Jt},${Jt},${Jt}\\)$`),zp=new RegExp(`^rgb\\(${je},${je},${je}\\)$`),Fp=new RegExp(`^rgba\\(${Jt},${Jt},${Jt},${ko}\\)$`),Wp=new RegExp(`^rgba\\(${je},${je},${je},${ko}\\)$`),Yp=new RegExp(`^hsl\\(${ko},${je},${je}\\)$`),Up=new RegExp(`^hsla\\(${ko},${je},${je},${ko}\\)$`),ca={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};kn(Ro,mt,{copy(e){return Object.assign(new this.constructor,this,e)},displayable(){return this.rgb().displayable()},hex:da,formatHex:da,formatHex8:$p,formatHsl:Xp,formatRgb:ua,toString:ua});function da(){return this.rgb().formatHex()}function $p(){return this.rgb().formatHex8()}function Xp(){return ya(this).formatHsl()}function ua(){return this.rgb().formatRgb()}function mt(e){var t,o;return e=(e+"").trim().toLowerCase(),(t=Gp.exec(e))?(o=t[1].length,t=parseInt(t[1],16),o===6?pa(t):o===3?new ke(t>>8&15|t>>4&240,t>>4&15|t&240,(t&15)<<4|t&15,1):o===8?Rn(t>>24&255,t>>16&255,t>>8&255,(t&255)/255):o===4?Rn(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=Bp.exec(e))?new ke(t[1],t[2],t[3],1):(t=zp.exec(e))?new ke(t[1]*255/100,t[2]*255/100,t[3]*255/100,1):(t=Fp.exec(e))?Rn(t[1],t[2],t[3],t[4]):(t=Wp.exec(e))?Rn(t[1]*255/100,t[2]*255/100,t[3]*255/100,t[4]):(t=Yp.exec(e))?ga(t[1],t[2]/100,t[3]/100,1):(t=Up.exec(e))?ga(t[1],t[2]/100,t[3]/100,t[4]):ca.hasOwnProperty(e)?pa(ca[e]):e==="transparent"?new ke(NaN,NaN,NaN,0):null}function pa(e){return new ke(e>>16&255,e>>8&255,e&255,1)}function Rn(e,t,o,n){return n<=0&&(e=t=o=NaN),new ke(e,t,o,n)}function Kp(e){return e instanceof Ro||(e=mt(e)),e?(e=e.rgb(),new ke(e.r,e.g,e.b,e.opacity)):new ke}function Qt(e,t,o,n){return arguments.length===1?Kp(e):new ke(e,t,o,n==null?1:n)}function ke(e,t,o,n){this.r=+e,this.g=+t,this.b=+o,this.opacity=+n}kn(ke,Qt,di(Ro,{brighter(e){return e=e==null?On:Math.pow(On,e),new ke(this.r*e,this.g*e,this.b*e,this.opacity)},darker(e){return e=e==null?Lo:Math.pow(Lo,e),new ke(this.r*e,this.g*e,this.b*e,this.opacity)},rgb(){return this},clamp(){return new ke(Lt(this.r),Lt(this.g),Lt(this.b),Vn(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:fa,formatHex:fa,formatHex8:qp,formatRgb:ma,toString:ma}));function fa(){return`#${Pt(this.r)}${Pt(this.g)}${Pt(this.b)}`}function qp(){return`#${Pt(this.r)}${Pt(this.g)}${Pt(this.b)}${Pt((isNaN(this.opacity)?1:this.opacity)*255)}`}function ma(){let e=Vn(this.opacity);return`${e===1?"rgb(":"rgba("}${Lt(this.r)}, ${Lt(this.g)}, ${Lt(this.b)}${e===1?")":`, ${e})`}`}function Vn(e){return isNaN(e)?1:Math.max(0,Math.min(1,e))}function Lt(e){return Math.max(0,Math.min(255,Math.round(e)||0))}function Pt(e){return e=Lt(e),(e<16?"0":"")+e.toString(16)}function ga(e,t,o,n){return n<=0?e=t=o=NaN:o<=0||o>=1?e=t=NaN:t<=0&&(e=NaN),new Xe(e,t,o,n)}function ya(e){if(e instanceof Xe)return new Xe(e.h,e.s,e.l,e.opacity);if(e instanceof Ro||(e=mt(e)),!e)return new Xe;if(e instanceof Xe)return e;e=e.rgb();var t=e.r/255,o=e.g/255,n=e.b/255,r=Math.min(t,o,n),i=Math.max(t,o,n),s=NaN,a=i-r,l=(i+r)/2;return a?(t===i?s=(o-n)/a+(o<n)*6:o===i?s=(n-t)/a+2:s=(t-o)/a+4,a/=l<.5?i+r:2-i-r,s*=60):a=l>0&&l<1?0:s,new Xe(s,a,l,e.opacity)}function xa(e,t,o,n){return arguments.length===1?ya(e):new Xe(e,t,o,n==null?1:n)}function Xe(e,t,o,n){this.h=+e,this.s=+t,this.l=+o,this.opacity=+n}kn(Xe,xa,di(Ro,{brighter(e){return e=e==null?On:Math.pow(On,e),new Xe(this.h,this.s,this.l*e,this.opacity)},darker(e){return e=e==null?Lo:Math.pow(Lo,e),new Xe(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 ke(ui(e>=240?e-240:e+120,r,n),ui(e,r,n),ui(e<120?e+240:e-120,r,n),this.opacity)},clamp(){return new Xe(ha(this.h),Dn(this.s),Dn(this.l),Vn(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=Vn(this.opacity);return`${e===1?"hsl(":"hsla("}${ha(this.h)}, ${Dn(this.s)*100}%, ${Dn(this.l)*100}%${e===1?")":`, ${e})`}`}}));function ha(e){return e=(e||0)%360,e<0?e+360:e}function Dn(e){return Math.max(0,Math.min(1,e||0))}function ui(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 pi(e,t,o,n,r){var i=e*e,s=i*e;return((1-3*e+3*i-s)*t+(4-6*i+3*s)*o+(1+3*e+3*i-3*s)*n+s*r)/6}function Ea(e){var t=e.length-1;return function(o){var n=o<=0?o=0:o>=1?(o=1,t-1):Math.floor(o*t),r=e[n],i=e[n+1],s=n>0?e[n-1]:2*r-i,a=n<t-1?e[n+2]:2*i-r;return pi((o-n/t)*t,s,r,i,a)}}function ba(e){var t=e.length;return function(o){var n=Math.floor(((o%=1)<0?++o:o)*t),r=e[(n+t-1)%t],i=e[n%t],s=e[(n+1)%t],a=e[(n+2)%t];return pi((o-n/t)*t,r,i,s,a)}}var fi=e=>()=>e;function Zp(e,t){return function(o){return e+o*t}}function Jp(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 _a(e){return(e=+e)==1?Hn:function(t,o){return o-t?Jp(t,o,e):fi(isNaN(t)?o:t)}}function Hn(e,t){var o=t-e;return o?Zp(e,o):fi(isNaN(e)?t:e)}var Gn=function e(t){var o=_a(t);function n(r,i){var s=o((r=Qt(r)).r,(i=Qt(i)).r),a=o(r.g,i.g),l=o(r.b,i.b),c=Hn(r.opacity,i.opacity);return function(d){return r.r=s(d),r.g=a(d),r.b=l(d),r.opacity=c(d),r+""}}return n.gamma=e,n}(1);function Ta(e){return function(t){var o=t.length,n=new Array(o),r=new Array(o),i=new Array(o),s,a;for(s=0;s<o;++s)a=Qt(t[s]),n[s]=a.r||0,r[s]=a.g||0,i[s]=a.b||0;return n=e(n),r=e(r),i=e(i),a.opacity=1,function(l){return a.r=n(l),a.g=r(l),a.b=i(l),a+""}}}var Qp=Ta(Ea),jp=Ta(ba);function Ge(e,t){return e=+e,t=+t,function(o){return e*(1-o)+t*o}}var gi=/[-+]?(?:\d+\.?\d*|\.?\d+)(?:[eE][-+]?\d+)?/g,mi=new RegExp(gi.source,"g");function ef(e){return function(){return e}}function tf(e){return function(t){return e(t)+""}}function hi(e,t){var o=gi.lastIndex=mi.lastIndex=0,n,r,i,s=-1,a=[],l=[];for(e=e+"",t=t+"";(n=gi.exec(e))&&(r=mi.exec(t));)(i=r.index)>o&&(i=t.slice(o,i),a[s]?a[s]+=i:a[++s]=i),(n=n[0])===(r=r[0])?a[s]?a[s]+=r:a[++s]=r:(a[++s]=null,l.push({i:s,x:Ge(n,r)})),o=mi.lastIndex;return o<t.length&&(i=t.slice(o),a[s]?a[s]+=i:a[++s]=i),a.length<2?l[0]?tf(l[0].x):ef(t):(t=l.length,function(c){for(var d=0,u;d<t;++d)a[(u=l[d]).i]=u.x(c);return a.join("")})}var Na=180/Math.PI,Bn={translateX:0,translateY:0,rotate:0,skewX:0,scaleX:1,scaleY:1};function yi(e,t,o,n,r,i){var s,a,l;return(s=Math.sqrt(e*e+t*t))&&(e/=s,t/=s),(l=e*o+t*n)&&(o-=e*l,n-=t*l),(a=Math.sqrt(o*o+n*n))&&(o/=a,n/=a,l/=a),e*n<t*o&&(e=-e,t=-t,l=-l,s=-s),{translateX:r,translateY:i,rotate:Math.atan2(t,e)*Na,skewX:Math.atan(l)*Na,scaleX:s,scaleY:a}}var zn;function va(e){let t=new(typeof DOMMatrix=="function"?DOMMatrix:WebKitCSSMatrix)(e+"");return t.isIdentity?Bn:yi(t.a,t.b,t.c,t.d,t.e,t.f)}function wa(e){return e==null?Bn:(zn||(zn=document.createElementNS("http://www.w3.org/2000/svg","g")),zn.setAttribute("transform",e),(e=zn.transform.baseVal.consolidate())?(e=e.matrix,yi(e.a,e.b,e.c,e.d,e.e,e.f)):Bn)}function Aa(e,t,o,n){function r(c){return c.length?c.pop()+" ":""}function i(c,d,u,p,f,h){if(c!==u||d!==p){var g=f.push("translate(",null,t,null,o);h.push({i:g-4,x:Ge(c,u)},{i:g-2,x:Ge(d,p)})}else(u||p)&&f.push("translate("+u+t+p+o)}function s(c,d,u,p){c!==d?(c-d>180?d+=360:d-c>180&&(c+=360),p.push({i:u.push(r(u)+"rotate(",null,n)-2,x:Ge(c,d)})):d&&u.push(r(u)+"rotate("+d+n)}function a(c,d,u,p){c!==d?p.push({i:u.push(r(u)+"skewX(",null,n)-2,x:Ge(c,d)}):d&&u.push(r(u)+"skewX("+d+n)}function l(c,d,u,p,f,h){if(c!==u||d!==p){var g=f.push(r(f)+"scale(",null,",",null,")");h.push({i:g-4,x:Ge(c,u)},{i:g-2,x:Ge(d,p)})}else(u!==1||p!==1)&&f.push(r(f)+"scale("+u+","+p+")")}return function(c,d){var u=[],p=[];return c=e(c),d=e(d),i(c.translateX,c.translateY,d.translateX,d.translateY,u,p),s(c.rotate,d.rotate,u,p),a(c.skewX,d.skewX,u,p),l(c.scaleX,c.scaleY,d.scaleX,d.scaleY,u,p),c=d=null,function(f){for(var h=-1,g=p.length,m;++h<g;)u[(m=p[h]).i]=m.x(f);return u.join("")}}}var xi=Aa(va,"px, ","px)","deg)"),Ei=Aa(wa,", ",")",")");var jt=0,Oo=0,Do=0,Ca=1e3,Fn,Vo,Wn=0,kt=0,Yn=0,Ho=typeof performance=="object"&&performance.now?performance:Date,Sa=typeof window=="object"&&window.requestAnimationFrame?window.requestAnimationFrame.bind(window):function(e){setTimeout(e,17)};function Bo(){return kt||(Sa(of),kt=Ho.now()+Yn)}function of(){kt=0}function Go(){this._call=this._time=this._next=null}Go.prototype=Un.prototype={constructor:Go,restart:function(e,t,o){if(typeof e!="function")throw new TypeError("callback is not a function");o=(o==null?Bo():+o)+(t==null?0:+t),!this._next&&Vo!==this&&(Vo?Vo._next=this:Fn=this,Vo=this),this._call=e,this._time=o,bi()},stop:function(){this._call&&(this._call=null,this._time=1/0,bi())}};function Un(e,t,o){var n=new Go;return n.restart(e,t,o),n}function Ma(){Bo(),++jt;for(var e=Fn,t;e;)(t=kt-e._time)>=0&&e._call.call(void 0,t),e=e._next;--jt}function Ia(){kt=(Wn=Ho.now())+Yn,jt=Oo=0;try{Ma()}finally{jt=0,rf(),kt=0}}function nf(){var e=Ho.now(),t=e-Wn;t>Ca&&(Yn-=t,Wn=e)}function rf(){for(var e,t=Fn,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:Fn=o);Vo=e,bi(n)}function bi(e){if(!jt){Oo&&(Oo=clearTimeout(Oo));var t=e-kt;t>24?(e<1/0&&(Oo=setTimeout(Ia,e-Ho.now()-Yn)),Do&&(Do=clearInterval(Do))):(Do||(Wn=Ho.now(),Do=setInterval(nf,Ca)),jt=1,Sa(Ia))}}function $n(e,t,o){var n=new Go;return t=t==null?0:+t,n.restart(r=>{n.stop(),e(r+t)},t,o),n}var sf=si("start","end","cancel","interrupt"),af=[],ka=0,Pa=1,Kn=2,Xn=3,La=4,qn=5,zo=6;function gt(e,t,o,n,r,i){var s=e.__transition;if(!s)e.__transition={};else if(o in s)return;lf(e,o,{name:t,index:n,group:r,on:sf,tween:af,time:i.time,delay:i.delay,duration:i.duration,ease:i.ease,timer:null,state:ka})}function Fo(e,t){var o=Ee(e,t);if(o.state>ka)throw new Error("too late; already scheduled");return o}function Ne(e,t){var o=Ee(e,t);if(o.state>Xn)throw new Error("too late; already running");return o}function Ee(e,t){var o=e.__transition;if(!o||!(o=o[t]))throw new Error("transition not found");return o}function lf(e,t,o){var n=e.__transition,r;n[t]=o,o.timer=Un(i,0,o.time);function i(c){o.state=Pa,o.timer.restart(s,o.delay,o.time),o.delay<=c&&s(c-o.delay)}function s(c){var d,u,p,f;if(o.state!==Pa)return l();for(d in n)if(f=n[d],f.name===o.name){if(f.state===Xn)return $n(s);f.state===La?(f.state=zo,f.timer.stop(),f.on.call("interrupt",e,e.__data__,f.index,f.group),delete n[d]):+d<t&&(f.state=zo,f.timer.stop(),f.on.call("cancel",e,e.__data__,f.index,f.group),delete n[d])}if($n(function(){o.state===Xn&&(o.state=La,o.timer.restart(a,o.delay,o.time),a(c))}),o.state=Kn,o.on.call("start",e,e.__data__,o.index,o.group),o.state===Kn){for(o.state=Xn,r=new Array(p=o.tween.length),d=0,u=-1;d<p;++d)(f=o.tween[d].value.call(e,e.__data__,o.index,o.group))&&(r[++u]=f);r.length=u+1}}function a(c){for(var d=c<o.duration?o.ease.call(null,c/o.duration):(o.timer.restart(l),o.state=qn,1),u=-1,p=r.length;++u<p;)r[u].call(e,d);o.state===qn&&(o.on.call("end",e,e.__data__,o.index,o.group),l())}function l(){o.state=zo,o.timer.stop(),delete n[t];for(var c in n)return;delete e.__transition}}function _i(e,t){var o=e.__transition,n,r,i=!0,s;if(o){t=t==null?null:t+"";for(s in o){if((n=o[s]).name!==t){i=!1;continue}r=n.state>Kn&&n.state<qn,n.state=zo,n.timer.stop(),n.on.call(r?"interrupt":"cancel",e,e.__data__,n.index,n.group),delete o[s]}i&&delete e.__transition}}function Ra(e){return this.each(function(){_i(this,e)})}function cf(e,t){var o,n;return function(){var r=Ne(this,e),i=r.tween;if(i!==o){n=o=i;for(var s=0,a=n.length;s<a;++s)if(n[s].name===t){n=n.slice(),n.splice(s,1);break}}r.tween=n}}function df(e,t,o){var n,r;if(typeof o!="function")throw new Error;return function(){var i=Ne(this,e),s=i.tween;if(s!==n){r=(n=s).slice();for(var a={name:t,value:o},l=0,c=r.length;l<c;++l)if(r[l].name===t){r[l]=a;break}l===c&&r.push(a)}i.tween=r}}function Da(e,t){var o=this._id;if(e+="",arguments.length<2){for(var n=Ee(this.node(),o).tween,r=0,i=n.length,s;r<i;++r)if((s=n[r]).name===e)return s.value;return null}return this.each((t==null?cf:df)(o,e,t))}function eo(e,t,o){var n=e._id;return e.each(function(){var r=Ne(this,n);(r.value||(r.value={}))[t]=o.apply(this,arguments)}),function(r){return Ee(r,n).value[t]}}function Zn(e,t){var o;return(typeof t=="number"?Ge:t instanceof mt?Gn:(o=mt(t))?(t=o,Gn):hi)(e,t)}function uf(e){return function(){this.removeAttribute(e)}}function pf(e){return function(){this.removeAttributeNS(e.space,e.local)}}function ff(e,t,o){var n,r=o+"",i;return function(){var s=this.getAttribute(e);return s===r?null:s===n?i:i=t(n=s,o)}}function mf(e,t,o){var n,r=o+"",i;return function(){var s=this.getAttributeNS(e.space,e.local);return s===r?null:s===n?i:i=t(n=s,o)}}function gf(e,t,o){var n,r,i;return function(){var s,a=o(this),l;return a==null?void this.removeAttribute(e):(s=this.getAttribute(e),l=a+"",s===l?null:s===n&&l===r?i:(r=l,i=t(n=s,a)))}}function hf(e,t,o){var n,r,i;return function(){var s,a=o(this),l;return a==null?void this.removeAttributeNS(e.space,e.local):(s=this.getAttributeNS(e.space,e.local),l=a+"",s===l?null:s===n&&l===r?i:(r=l,i=t(n=s,a)))}}function Oa(e,t){var o=nt(e),n=o==="transform"?Ei:Zn;return this.attrTween(e,typeof t=="function"?(o.local?hf:gf)(o,n,eo(this,"attr."+e,t)):t==null?(o.local?pf:uf)(o):(o.local?mf:ff)(o,n,t))}function yf(e,t){return function(o){this.setAttribute(e,t.call(this,o))}}function xf(e,t){return function(o){this.setAttributeNS(e.space,e.local,t.call(this,o))}}function Ef(e,t){var o,n;function r(){var i=t.apply(this,arguments);return i!==n&&(o=(n=i)&&xf(e,i)),o}return r._value=t,r}function bf(e,t){var o,n;function r(){var i=t.apply(this,arguments);return i!==n&&(o=(n=i)&&yf(e,i)),o}return r._value=t,r}function Va(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?Ef:bf)(n,t))}function _f(e,t){return function(){Fo(this,e).delay=+t.apply(this,arguments)}}function Tf(e,t){return t=+t,function(){Fo(this,e).delay=t}}function Ha(e){var t=this._id;return arguments.length?this.each((typeof e=="function"?_f:Tf)(t,e)):Ee(this.node(),t).delay}function Nf(e,t){return function(){Ne(this,e).duration=+t.apply(this,arguments)}}function vf(e,t){return t=+t,function(){Ne(this,e).duration=t}}function Ga(e){var t=this._id;return arguments.length?this.each((typeof e=="function"?Nf:vf)(t,e)):Ee(this.node(),t).duration}function wf(e,t){if(typeof t!="function")throw new Error;return function(){Ne(this,e).ease=t}}function Ba(e){var t=this._id;return arguments.length?this.each(wf(t,e)):Ee(this.node(),t).ease}function Af(e,t){return function(){var o=t.apply(this,arguments);if(typeof o!="function")throw new Error;Ne(this,e).ease=o}}function za(e){if(typeof e!="function")throw new Error;return this.each(Af(this._id,e))}function Fa(e){typeof e!="function"&&(e=Mo(e));for(var t=this._groups,o=t.length,n=new Array(o),r=0;r<o;++r)for(var i=t[r],s=i.length,a=n[r]=[],l,c=0;c<s;++c)(l=i[c])&&e.call(l,l.__data__,c,i)&&a.push(l);return new Se(n,this._parents,this._name,this._id)}function Wa(e){if(e._id!==this._id)throw new Error;for(var t=this._groups,o=e._groups,n=t.length,r=o.length,i=Math.min(n,r),s=new Array(n),a=0;a<i;++a)for(var l=t[a],c=o[a],d=l.length,u=s[a]=new Array(d),p,f=0;f<d;++f)(p=l[f]||c[f])&&(u[f]=p);for(;a<n;++a)s[a]=t[a];return new Se(s,this._parents,this._name,this._id)}function If(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 Cf(e,t,o){var n,r,i=If(t)?Fo:Ne;return function(){var s=i(this,e),a=s.on;a!==n&&(r=(n=a).copy()).on(t,o),s.on=r}}function Ya(e,t){var o=this._id;return arguments.length<2?Ee(this.node(),o).on.on(e):this.each(Cf(o,e,t))}function Sf(e){return function(){var t=this.parentNode;for(var o in this.__transition)if(+o!==e)return;t&&t.removeChild(this)}}function Ua(){return this.on("end.remove",Sf(this._id))}function $a(e){var t=this._name,o=this._id;typeof e!="function"&&(e=Mt(e));for(var n=this._groups,r=n.length,i=new Array(r),s=0;s<r;++s)for(var a=n[s],l=a.length,c=i[s]=new Array(l),d,u,p=0;p<l;++p)(d=a[p])&&(u=e.call(d,d.__data__,p,a))&&("__data__"in d&&(u.__data__=d.__data__),c[p]=u,gt(c[p],t,o,p,c,Ee(d,o)));return new Se(i,this._parents,t,o)}function Xa(e){var t=this._name,o=this._id;typeof e!="function"&&(e=So(e));for(var n=this._groups,r=n.length,i=[],s=[],a=0;a<r;++a)for(var l=n[a],c=l.length,d,u=0;u<c;++u)if(d=l[u]){for(var p=e.call(d,d.__data__,u,l),f,h=Ee(d,o),g=0,m=p.length;g<m;++g)(f=p[g])&&gt(f,t,o,g,p,h);i.push(p),s.push(d)}return new Se(i,s,t,o)}var Mf=rt.prototype.constructor;function Ka(){return new Mf(this._groups,this._parents)}function Pf(e,t){var o,n,r;return function(){var i=ft(this,e),s=(this.style.removeProperty(e),ft(this,e));return i===s?null:i===o&&s===n?r:r=t(o=i,n=s)}}function qa(e){return function(){this.style.removeProperty(e)}}function Lf(e,t,o){var n,r=o+"",i;return function(){var s=ft(this,e);return s===r?null:s===n?i:i=t(n=s,o)}}function kf(e,t,o){var n,r,i;return function(){var s=ft(this,e),a=o(this),l=a+"";return a==null&&(l=a=(this.style.removeProperty(e),ft(this,e))),s===l?null:s===n&&l===r?i:(r=l,i=t(n=s,a))}}function Rf(e,t){var o,n,r,i="style."+t,s="end."+i,a;return function(){var l=Ne(this,e),c=l.on,d=l.value[i]==null?a||(a=qa(t)):void 0;(c!==o||r!==d)&&(n=(o=c).copy()).on(s,r=d),l.on=n}}function Za(e,t,o){var n=(e+="")=="transform"?xi:Zn;return t==null?this.styleTween(e,Pf(e,n)).on("end.style."+e,qa(e)):typeof t=="function"?this.styleTween(e,kf(e,n,eo(this,"style."+e,t))).each(Rf(this._id,e)):this.styleTween(e,Lf(e,n,t),o).on("end.style."+e,null)}function Df(e,t,o){return function(n){this.style.setProperty(e,t.call(this,n),o)}}function Of(e,t,o){var n,r;function i(){var s=t.apply(this,arguments);return s!==r&&(n=(r=s)&&Df(e,s,o)),n}return i._value=t,i}function Ja(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,Of(e,t,o==null?"":o))}function Vf(e){return function(){this.textContent=e}}function Hf(e){return function(){var t=e(this);this.textContent=t==null?"":t}}function Qa(e){return this.tween("text",typeof e=="function"?Hf(eo(this,"text",e)):Vf(e==null?"":e+""))}function Gf(e){return function(t){this.textContent=e.call(this,t)}}function Bf(e){var t,o;function n(){var r=e.apply(this,arguments);return r!==o&&(t=(o=r)&&Gf(r)),t}return n._value=e,n}function ja(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,Bf(e))}function el(){for(var e=this._name,t=this._id,o=Jn(),n=this._groups,r=n.length,i=0;i<r;++i)for(var s=n[i],a=s.length,l,c=0;c<a;++c)if(l=s[c]){var d=Ee(l,t);gt(l,e,o,c,s,{time:d.time+d.delay+d.duration,delay:0,duration:d.duration,ease:d.ease})}return new Se(n,this._parents,e,o)}function tl(){var e,t,o=this,n=o._id,r=o.size();return new Promise(function(i,s){var a={value:s},l={value:function(){--r===0&&i()}};o.each(function(){var c=Ne(this,n),d=c.on;d!==e&&(t=(e=d).copy(),t._.cancel.push(a),t._.interrupt.push(a),t._.end.push(l)),c.on=t}),r===0&&i()})}var zf=0;function Se(e,t,o,n){this._groups=e,this._parents=t,this._name=o,this._id=n}function ol(e){return rt().transition(e)}function Jn(){return++zf}var it=rt.prototype;Se.prototype=ol.prototype={constructor:Se,select:$a,selectAll:Xa,selectChild:it.selectChild,selectChildren:it.selectChildren,filter:Fa,merge:Wa,selection:Ka,transition:el,call:it.call,nodes:it.nodes,node:it.node,size:it.size,empty:it.empty,each:it.each,on:Ya,attr:Oa,attrTween:Va,style:Za,styleTween:Ja,text:Qa,textTween:ja,remove:Ua,tween:Da,delay:Ha,duration:Ga,ease:Ba,easeVarying:za,end:tl,[Symbol.iterator]:it[Symbol.iterator]};function Qn(e){return((e*=2)<=1?e*e*e:(e-=2)*e*e+2)/2}var Ff={time:null,delay:0,duration:250,ease:Qn};function Wf(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 nl(e){var t,o;e instanceof Se?(t=e._id,e=e._name):(t=Jn(),(o=Ff).time=Bo(),e=e==null?null:e+"");for(var n=this._groups,r=n.length,i=0;i<r;++i)for(var s=n[i],a=s.length,l,c=0;c<a;++c)(l=s[c])&&gt(l,e,t,c,s,o||Wf(l,t));return new Se(n,this._parents,e,t)}rt.prototype.interrupt=Ra;rt.prototype.transition=nl;function ht(e,t,o){this.k=e,this.x=t,this.y=o}ht.prototype={constructor:ht,scale:function(e){return e===1?this:new ht(this.k*e,this.x,this.y)},translate:function(e,t){return e===0&t===0?this:new ht(this.k,this.x+this.k*e,this.y+this.k*t)},apply:function(e){return[e[0]*this.k+this.x,e[1]*this.k+this.y]},applyX:function(e){return e*this.k+this.x},applyY:function(e){return e*this.k+this.y},invert:function(e){return[(e[0]-this.x)/this.k,(e[1]-this.y)/this.k]},invertX:function(e){return(e-this.x)/this.k},invertY:function(e){return(e-this.y)/this.k},rescaleX:function(e){return e.copy().domain(e.range().map(this.invertX,this).map(e.invert,e))},rescaleY:function(e){return e.copy().domain(e.range().map(this.invertY,this).map(e.invert,e))},toString:function(){return"translate("+this.x+","+this.y+") scale("+this.k+")"}};var jn=new ht(1,0,0);er.prototype=ht.prototype;function er(e){for(;!e.__zoom;)if(!(e=e.parentNode))return jn;return e.__zoom}var Uf=[[Number.NEGATIVE_INFINITY,Number.NEGATIVE_INFINITY],[Number.POSITIVE_INFINITY,Number.POSITIVE_INFINITY]];var rl;(function(e){e.Strict="strict",e.Loose="loose"})(rl||(rl={}));var il;(function(e){e.Free="free",e.Vertical="vertical",e.Horizontal="horizontal"})(il||(il={}));var sl;(function(e){e.Partial="partial",e.Full="full"})(sl||(sl={}));var al;(function(e){e.Bezier="default",e.Straight="straight",e.Step="step",e.SmoothStep="smoothstep",e.SimpleBezier="simplebezier"})(al||(al={}));var ll;(function(e){e.Arrow="arrow",e.ArrowClosed="arrowclosed"})(ll||(ll={}));var Re;(function(e){e.Left="left",e.Top="top",e.Right="right",e.Bottom="bottom"})(Re||(Re={}));var mv={[Re.Left]:Re.Right,[Re.Right]:Re.Left,[Re.Top]:Re.Bottom,[Re.Bottom]:Re.Top};var $f=e=>"id"in e&&"internals"in e&&!("source"in e)&&!("target"in e);var Xf=(e,t=[0,0])=>{var a;let{width:o,height:n}=Kf(e),r=(a=e.origin)!=null?a:t,i=o*r[0],s=n*r[1];return{x:e.position.x-i,y:e.position.y-s}};var st=(e,t=[0,0])=>{var r,i,s,a,l,c,d,u;let{x:o,y:n}=$f(e)?e.internals.positionAbsolute:Xf(e,t);return{x:o,y:n,x2:o+((a=(s=(i=(r=e.measured)==null?void 0:r.width)!=null?i:e.width)!=null?s:e.initialWidth)!=null?a:0),y2:n+((u=(d=(c=(l=e.measured)==null?void 0:l.height)!=null?c:e.height)!=null?d:e.initialHeight)!=null?u:0)}};function Kf(e){var t,o,n,r,i,s,a,l;return{width:(r=(n=(o=(t=e.measured)==null?void 0:t.width)!=null?o:e.width)!=null?n:e.initialWidth)!=null?r:0,height:(l=(a=(s=(i=e.measured)==null?void 0:i.height)!=null?s:e.height)!=null?a:e.initialHeight)!=null?l:0}}var gv={[Re.Left]:{x:-1,y:0},[Re.Right]:{x:1,y:0},[Re.Top]:{x:0,y:-1},[Re.Bottom]:{x:0,y:1}};var qf={nodeOrigin:[0,0],nodeExtent:Uf,elevateNodesOnSelect:!0,defaults:{}},hv=v(y({},qf),{checkEquality:!0});var cl;(function(e){e.Line="line",e.Handle="handle"})(cl||(cl={}));var Zf={width:0,height:0,x:0,y:0},yv=v(y({},Zf),{pointerX:0,pointerY:0,aspectRatio:1});var Jf=(e,t)=>e.x<t.x2&&e.x2>t.x&&e.y<t.y2&&e.y2>t.y;function Qf(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 jf(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 tr=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 s=t==="horizontal"?this.yLines:this.xLines,[a,l]=t==="horizontal"?[r.y,r.y2]:[r.x,r.x2],c=[];for(let f of s){if(f.position<a)continue;if(f.position>l)break;if(i.has(f.node.id)||f.node.parentId&&i.has(f.node.parentId)||!Jf(f.nodeBox,r))continue;let h=Math.abs(f.position-o);if(h>or)continue;let m=Qf(f.nodeBox,n)>0?0:jf(f.nodeBox,n);c.push({line:f,lineDist:h,nodeDist:m})}let d=.5,u=t==="horizontal"?this.lastHorizontalLine:this.lastVerticalLine;c.sort((f,h)=>{if(u){if(f.line===u&&h.line!==u)return-1;if(h.line===u&&f.line!==u)return 1}return Math.abs(f.lineDist-h.lineDist)<=d?f.nodeDist-h.nodeDist:f.lineDist-h.lineDist});let p=c.length>0?c[0].line:void 0;return p&&(t==="horizontal"?this.lastHorizontalLine=p:this.lastVerticalLine=p),p}};function dl(e,t=Rt,o){let n=[];return e==null||e.forEach(r=>{let i=o(r.id);if(!i)throw new Error(`Node with id ${r.id} not found in internal nodes.`);let s=st(i);Object.entries(t).forEach(([a,l])=>{var c;n.push({position:l.resolve(r,s),color:(c=r.style)==null?void 0:c.backgroundColor,orientation:l.orientation,anchorName:a,nodeBox:s,node:r})})}),n}function ul(e,t,o,n,r=Object.keys(Rt)){let i=[];for(let a of r){let l=Rt[a],c=l.resolve(null,o),d=e.search(l.orientation,c,o,t,n);d&&i.push({sourcePosition:c,anchorName:a,anchor:l,line:d})}let s={horizontal:void 0,vertical:void 0};for(let a of i){let l=s[a.anchor.orientation],c=Math.abs(a.sourcePosition-a.line.position);(!l||c<Math.abs(l.sourcePosition-l.line.position))&&(s[a.anchor.orientation]=a)}return s}function pl(e,t,o){let n=0,r=0,i=!1,s=!1;if(t){let l=t.anchor.resolve(null,e)-t.line.position;Math.abs(l)<=or&&(r=l,s=!0)}if(o){let l=o.anchor.resolve(null,e)-o.line.position;Math.abs(l)<=or&&(n=l,i=!0)}return{deltaX:n,deltaY:r,snappedX:i,snappedY:s}}var or=10,Rt={top:{orientation:"horizontal",resolve:(e,t)=>t.y},bottom:{orientation:"horizontal",resolve:(e,t)=>t.y2},left:{orientation:"vertical",resolve:(e,t)=>t.x},right:{orientation:"vertical",resolve:(e,t)=>t.x2},centerX:{orientation:"vertical",resolve:(e,t)=>(t.x+t.x2)/2},centerY:{orientation:"horizontal",resolve:(e,t)=>(t.y+t.y2)/2}};import{jsx as am}from"react/jsx-runtime";var sm=new tr;function nr(){let[e,t]=fl(void 0),[o,n]=fl(void 0),{width:r,height:i}=om(m=>({width:m.width,height:m.height}),im),s=em(),a=rm(sm),{screenToFlowPosition:l,getInternalNode:c,getNodes:d}=tm(),u=Wo(()=>{t(void 0),n(void 0)},[]),p=Wo(m=>{let E=m!=null?m:d();u();let _=dl(E,Rt,c);a.current.initialize(_)},[c,u,d]),f=Wo(()=>{setTimeout(()=>{p()},100)},[p]);nm(()=>{s&&p(d())},[s,p,d]);let h=Wo((m,E)=>{var K,P,H,F,z,k,J,U,Y,B;if(!a.current||m.length===0)return m;u();let _=m.filter(W=>W.type==="position"&&!!W.position),b=m.find(W=>W.type==="dimensions");if(_.length===0&&!b)return m;let T=Object.keys(Rt),N=new Set,x=1/0,w=1/0,C=-1/0,I=-1/0;if(_.length>0)_.forEach(W=>{var ge,ue,ie,ne,Te,Pe;let q=E.find(ut=>ut.id===W.id);if(!q)return;N.add(q.id);let j=c(q.id);if(!j)return;let se=j.parentId?c(j.parentId):void 0,ae=W.position.x+((ge=se==null?void 0:se.internals.positionAbsolute.x)!=null?ge:0),le=W.position.y+((ue=se==null?void 0:se.internals.positionAbsolute.y)!=null?ue:0),ce=(ne=(ie=q.measured)==null?void 0:ie.width)!=null?ne:0,me=(Pe=(Te=q.measured)==null?void 0:Te.height)!=null?Pe:0;x=Math.min(x,ae),w=Math.min(w,le),C=Math.max(C,ae+ce),I=Math.max(I,le+me)}),b&&(T=["top","left"]);else if(b){let W=E.find(ce=>ce.id===b.id);if(!W)return m;N.add(W.id);let q=c(W.id);if(!q)return m;let j=q.internals.positionAbsolute.x,se=q.internals.positionAbsolute.y,ae=(F=(H=(K=b.dimensions)==null?void 0:K.width)!=null?H:(P=W.measured)==null?void 0:P.width)!=null?F:0,le=(U=(J=(z=b.dimensions)==null?void 0:z.height)!=null?J:(k=W.measured)==null?void 0:k.height)!=null?U:0;x=j,w=se,C=j+ae,I=se+le,T=["right","bottom"]}if(x===1/0)return m;let R={x,y:w,x2:C,y2:I},{x:S,y:D}=l({x:0,y:0}),{x:X,y:Z}=l({x:r,y:i}),te={x:S,y:D,x2:X,y2:Z},{horizontal:A,vertical:M}=ul(a.current,te,R,N,T),{deltaX:$,deltaY:V,snappedX:L,snappedY:G}=pl(R,A,M);if(L||G){let W=_.some(j=>j.dragging),q=!!(b!=null&&b.resizing);(W||q)&&(L&&n(M==null?void 0:M.line),G&&t(A==null?void 0:A.line)),L&&(_.forEach(j=>{j.position&&(j.position.x-=$)}),(b==null?void 0:b.id)===((Y=_[0])==null?void 0:Y.id)?b.dimensions&&(b.dimensions.width+=$):b&&!_.length&&b.dimensions&&(b.dimensions.width-=$)),G&&(_.forEach(j=>{j.position&&(j.position.y-=V)}),(b==null?void 0:b.id)===((B=_[0])==null?void 0:B.id)?b.dimensions&&(b.dimensions.height+=V):b&&!_.length&&b.dimensions&&(b.dimensions.height-=V))}return m},[l,c,r,i,t,n,u]),g=Wo(()=>am(ml,{horizontal:e,vertical:o}),[e,o]);return{rebuildIndex:p,forceRebuildIndex:f,updateHelperLines:h,helperLineHorizontal:e,helperLineVertical:o,HelperLines:g}}import{reconnectEdge as ny,useReactFlow as ry}from"@xyflow/react";import{useCallback as Bt,useRef as iy}from"react";var yt=e=>new Map(e.map(t=>[t.id,t])),Yo=(e,t,o)=>t.filter(n=>!(n.source!==e||o&&n.id===o)),gl=(e,t,o)=>t.filter(n=>!(n.target!==e||o&&n.id===o)),Ti=e=>e.some(t=>t.type==="START_EVENT"),xt=(e,t)=>e==="START_EVENT"?!Ti(t):!0,hl=(e,t,o,n,r)=>{let i=yt(o),s=i.get(e);if(!s||s.type!=="START_EVENT")return!1;let a=i.get(t);return(a==null?void 0:a.type)==="ANNOTATION"?!1:Yo(e,n,r).filter(c=>{let d=i.get(c.target);return(d==null?void 0:d.type)!=="ANNOTATION"}).length>=1},yl=(e,t,o,n,r)=>{let i=yt(o),s=i.get(t);if(!s||s.type!=="END_EVENT")return!1;let a=i.get(e);return(a==null?void 0:a.type)==="ANNOTATION"?!1:gl(t,n,r).filter(c=>{let d=i.get(c.source);return(d==null?void 0:d.type)!=="ANNOTATION"}).length>=1},rr=(e,t,o,n,r)=>{var c;let i=yt(o),s=i.get(e);if(!s||s.type!=="GATEWAY"||((c=s.data)==null?void 0:c.variant)!=="EXCLUSIVE")return!1;let a=t?i.get(t):null;return(a==null?void 0:a.type)==="ANNOTATION"?!1:Yo(e,n,r).filter(d=>{let u=i.get(d.target);return(u==null?void 0:u.type)!=="ANNOTATION"}).length>=2},xl=(e,t,o)=>{var s,a,l,c;let n=yt(o),r=n.get(e),i=n.get(t);return(r==null?void 0:r.type)!=="GATEWAY"||(i==null?void 0:i.type)!=="GATEWAY"||((s=r==null?void 0:r.data)==null?void 0:s.variant)==="EXCLUSIVE"&&((a=i==null?void 0:i.data)==null?void 0:a.variant)==="PARALLEL"||((l=r==null?void 0:r.data)==null?void 0:l.variant)==="COMPLEX"&&((c=i==null?void 0:i.data)==null?void 0:c.variant)==="PARALLEL"},ir=(e,t)=>{var n;let o=t.find(r=>r.id===e);return!o||o.type!=="TASK"?!1:((n=o.data)==null?void 0:n.variant)==="SCRIPT"},El=(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"},sr=(e,t)=>{var n;let o=t.find(r=>r.id===e);return!o||o.type!=="TASK"?!1:((n=o.data)==null?void 0:n.attribute)==="LOOP"},Uo=(e,t,o,n)=>{let r=yt(t),i=r.get(e);return!i||i.type!=="TASK"?!1:gl(e,o,n).some(a=>{let l=r.get(a.source);return(l==null?void 0:l.type)==="START_EVENT"})},$o=(e,t,o,n)=>{let r=yt(t),i=r.get(e);return!i||i.type!=="TASK"?!1:Yo(e,o,n).some(a=>{let l=r.get(a.target);return(l==null?void 0:l.type)==="END_EVENT"})},bl=(e,t,o,n,r)=>{let i=yt(o),s=i.get(e),a=i.get(t);return(s==null?void 0:s.type)==="START_EVENT"&&(a==null?void 0:a.type)==="TASK"?$o(t,o,n,r):(a==null?void 0:a.type)==="END_EVENT"&&(s==null?void 0:s.type)==="TASK"?Uo(e,o,n,r):!1},ar=(e,t,o)=>Yo(e,t,o).length>0,lr=(e,t,o,n,r)=>{let i=yt(o),s=i.get(e);if(!s||s.type!=="TASK")return!1;let a=t?i.get(t):null;return(a==null?void 0:a.type)==="ANNOTATION"?!1:Yo(e,n,r).filter(c=>{let d=i.get(c.target);return(d==null?void 0:d.type)!=="ANNOTATION"}).length>=2};var _l=(e,t,o,n)=>o.some(r=>n&&r.id===n?!1:r.source===e&&r.target===t);var lm=[e=>({isValid:e.sourceNodeId!==e.targetNodeId,reason:"self_connection_not_allowed"}),e=>({isValid:!_l(e.sourceNodeId,e.targetNodeId,e.edges,e.reconnectingEdgeId),reason:"duplicate_connection_not_allowed"}),e=>({isValid:!hl(e.sourceNodeId,e.targetNodeId,e.nodes,e.edges,e.reconnectingEdgeId),reason:"start_event_limit_reached"}),e=>({isValid:!yl(e.sourceNodeId,e.targetNodeId,e.nodes,e.edges,e.reconnectingEdgeId),reason:"end_event_limit_reached"}),e=>({isValid:!rr(e.sourceNodeId,e.targetNodeId,e.nodes,e.edges,e.reconnectingEdgeId),reason:"gateway_limit_reached"}),e=>({isValid:!lr(e.sourceNodeId,e.targetNodeId,e.nodes,e.edges,e.reconnectingEdgeId),reason:"task_limit_reached"}),e=>({isValid:xl(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"&&El(e.targetNodeId,e.nodes)),reason:"start_event_to_subprocess_not_allowed"}),e=>({isValid:!(e.sourceNodeType==="GATEWAY"&&e.targetNodeType==="END_EVENT"),reason:"gateway_to_end_not_allowed"}),e=>({isValid:!(e.sourceNodeType==="START_EVENT"&&e.targetNodeType==="GATEWAY"),reason:"start_to_gateway_not_allowed"}),e=>({isValid:!(ir(e.sourceNodeId,e.nodes)&&e.targetNodeType==="END_EVENT"),reason:"script_to_end_not_allowed"}),e=>({isValid:!(sr(e.sourceNodeId,e.nodes)&&e.targetNodeType==="END_EVENT"),reason:"loop_to_end_not_allowed"}),e=>({isValid:!(Uo(e.sourceNodeId,e.nodes,e.edges,e.reconnectingEdgeId)&&e.targetNodeType==="END_EVENT"),reason:"initial_activity_to_end_not_allowed"}),e=>({isValid:!bl(e.sourceNodeId,e.targetNodeId,e.nodes,e.edges,e.reconnectingEdgeId),reason:"concurrent_initial_and_final_activity"}),e=>({isValid:!($o(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"})],Ni=e=>{for(let t of lm){let o=t(e);if(!o.isValid)return o}return{isValid:!0}};var cm=[{sourceTypes:["GATEWAY"],targetTypes:["TASK","GATEWAY"],validate:e=>({shouldDisable:rr(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:Ti(e.nodes),reason:"start_event_already_exists"})},{sourceTypes:["TASK"],targetTypes:["END_EVENT"],validate:e=>({shouldDisable:ir(e.sourceNodeId,e.nodes),reason:"script_to_end_not_allowed"})},{sourceTypes:["TASK"],targetTypes:["END_EVENT"],validate:e=>({shouldDisable:sr(e.sourceNodeId,e.nodes),reason:"loop_to_end_not_allowed"})},{sourceTypes:["TASK"],targetTypes:["END_EVENT"],validate:e=>({shouldDisable:Uo(e.sourceNodeId,e.nodes,e.edges),reason:"initial_activity_to_end_not_allowed"})},{sourceTypes:["TASK"],validate:e=>({shouldDisable:$o(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:lr(e.sourceNodeId,null,e.nodes,e.edges)&&e.targetNodeType!=="ANNOTATION",reason:"task_limit_reached"})}],Tl=e=>{let t=cm.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 Hm,EdgeLabelRenderer as Gm,getStraightPath as Bm,useInternalNode as vl}from"@xyflow/react";import{Button as pm,Tooltip as fm,TooltipContent as mm,TooltipTrigger as gm,useTranslation as hm}from"@produto-lecom/lecom-ui";import{Settings as ym}from"lucide-react";import{getIncomers as cr,getOutgoers as dr,useReactFlow as um}from"@xyflow/react";import{useStoreApi as dm}from"@xyflow/react";var Et=()=>{let e=dm();return{selectElements:n=>{let{edges:r,nodes:i,triggerEdgeChanges:s,triggerNodeChanges:a}=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 a(l),s(c),!0},clearSelection:async()=>{let{unselectNodesAndEdges:n}=e.getState();return n(),await bn(),!0}}};var ur=()=>{let{getNode:e,getEdge:t,getNodes:o,getEdges:n}=um(),{selectElements:r}=Et(),i=m=>{let E=o(),_=n(),b=cr(m,E,_),T=dr(m,E,_),N=b.some(w=>w.type==="START_EVENT"),x=T.some(w=>w.type==="END_EVENT");return N?"start":x?"end":"between"},s=(m,E,_)=>{var N,x,w,C;if(!m)return;let b={type:m.type,variant:(N=m.data)==null?void 0:N.variant,attribute:(x=m.data)==null?void 0:x.attribute},T={id:m.id,position:i(m),label:(w=m.data)==null?void 0:w.label,node:b};return m.type==="TASK"&&((C=m.data)==null?void 0:C.variant)==="SUBPROCESS"?v(y({},T),{type:"sub_process"}):m.type==="GATEWAY"?v(y({},T),{type:"gateway",variant:a(m,E,_)}):v(y({},T),{type:"activity"})},a=(m,E,_)=>{if(m.type!=="GATEWAY")return;let b=cr(m,E,_),T=!1,N=!1;if(b.forEach(x=>{var w,C;x.type==="TASK"&&(((w=x.data)==null?void 0:w.variant)==="SCRIPT"&&(T=!0),((C=x.data)==null?void 0:C.attribute)==="LOOP"&&(N=!0))}),T&&N)return"script_loop";if(T)return"script";if(N)return"loop"},l=(m,E,_)=>{var w,C,I,R;let b=e(m.source),T=e(m.target);if(!b||!T)return"simple";if(dr(b,E,_).some(S=>S.type==="END_EVENT"))return"final";if(b.type==="GATEWAY")switch((w=b.data)==null?void 0:w.variant){case"PARALLEL":return"parallel";case"EXCLUSIVE":return"exclusive";case"COMPLEX":return"complex";default:return"simple"}if(b.type==="TASK"){let S=(C=b.data)==null?void 0:C.variant,D=(I=b.data)==null?void 0:I.attribute;if(S==="SUBPROCESS")return"from_sub_process";if(T.type==="TASK"&&((R=T.data)==null?void 0:R.variant)==="SUBPROCESS")return"to_sub_process";let X=S==="SCRIPT",Z=D==="LOOP";return X&&Z?"script_loop":X?"script":Z?"loop":"simple"}return"simple"},c=(m,E,_)=>{let b=[];function T(x,w,C=0){let I=s(x,E,_);if(I.depth=C,w.push(I),x.type==="TASK"){b.push([...w]),w.pop();return}let R=cr(x,E,_);if(R.length)for(let S of R)T(S,w,C+1);w.pop()}let N=cr(m,E,_);for(let x of N)T(x,[]);return b},d=(m,E,_)=>{let b=[];function T(x,w,C=0){let I=s(x,E,_);if(I.depth=C,w.push(I),x.type==="TASK"){b.push([...w]),w.pop();return}let R=dr(x,E,_);if(R.length)for(let S of R)T(S,w,C+1);w.pop()}let N=dr(m,E,_);for(let x of N)T(x,[]);return b},u=(m,E,_)=>(_=_.filter(T=>T.source===m.id),_.map(T=>{var w;let N=e(T.target),x;return N&&(x=s(N,E,_)),{id:T.id,type:"routing",variant:l(T,E,_),label:(w=T.data)==null?void 0:w.label,target:x}})),p=m=>{let E=e(m);if(!E)return;let _=o(),b=n(),T=s(E,_,b);return T.sources=c(E,_,b),T.targets=d(E,_,b),T.edgeTargets=u(E,_,b),E.type==="GATEWAY"&&(T.variant=a(E,_,b)),T},f=m=>{let E=t(m);if(!E)return;let _=o(),b=n(),T=l(E,_,b),x={id:E.id,type:"routing",variant:T,gatewayVariant:void 0},w=e(E.source);if(w){let I=s(w,_,b);x.source=I;let R=a(w,_,b);if(x.gatewayVariant=R,w.type==="TASK")x.sources=[[I]];else{let S=c(w,_,b);x.sources=S.length?S:[[I]]}}let C=e(E.target);if(C){let I=s(C,_,b);if(x.target=I,C.type==="TASK")x.targets=[[I]];else{let R=d(C,_,b);x.targets=R.length?R:[[I]]}}return x},h=m=>{let E=e(m);if(E)return p(E.id);let _=t(m);if(_)return f(_.id)};return{configureElement:m=>{let E=h(m);if(E)return r([m]),E},getConfigureElement:h,getNodeConfigure:p,getEdgeConfigure:f}};import{jsx as pr,jsxs as xm}from"react/jsx-runtime";var bt=({elementId:e,elementType:t="node"})=>{let{t:o}=hm(),{onConfigureElement:n}=Q(),{getConfigureElement:r}=ur();return xm(fm,{children:[pr(gm,{asChild:!0,children:pr(pm,{variant:"ghost",color:"grey",size:"small",iconButton:!0,onClick:()=>{let s=r(e);s&&(n==null||n(s))},children:pr(ym,{size:16})})}),pr(mm,{color:"black",children:o(t==="node"?"editor.toolbar.configure_node":"editor.toolbar.configure_edge")})]})};import{Button as bm,Tooltip as _m,TooltipContent as Tm,TooltipTrigger as Nm,useTranslation as vm}from"@produto-lecom/lecom-ui";import{useReactFlow as wm}from"@xyflow/react";import{TrashIcon as Am}from"lucide-react";import{useNotificationToast as Em}from"@produto-lecom/lecom-ui";function De(){let{toast:e}=Xo(),{toast:t}=Em();return{toast:e||t}}import{jsx as fr,jsxs as Im}from"react/jsx-runtime";var mr=({elementId:e,elementType:t="node"})=>{let{t:o}=vm(),{toast:n}=De(),{deleteElements:r,getNodes:i}=wm();return Im(_m,{children:[fr(Nm,{asChild:!0,children:fr(bm,{variant:"ghost",color:"destructive",size:"small",iconButton:!0,onClick:()=>{if(t==="node"){let a=i(),l=a.find(c=>c.id===e);if((l==null?void 0:l.type)==="LANE"&&a.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:fr(Am,{size:16})})}),fr(Tm,{color:"black",children:o("editor.toolbar.delete")})]})};import{Button as Cm,Tooltip as Sm,TooltipContent as Mm,TooltipTrigger as Pm,useTranslation as Lm}from"@produto-lecom/lecom-ui";import{MoveUpRightIcon as km}from"lucide-react";import{useCallback as Rm}from"react";import{jsx as gr,jsxs as Dm}from"react/jsx-runtime";var Dt=({nodeId:e,disabled:t=!1,tooltipMessage:o})=>{let{t:n}=Lm(),r=Rm(i=>{i.stopPropagation();let s=document.querySelectorAll(`.react-flow__handle.source[data-nodeid="${e}"]`);if(s.length===0)return;let a=Array.from(s).reduce((p,f)=>{let h=p.getBoundingClientRect(),g=f.getBoundingClientRect(),m=Math.hypot(i.clientX-(h.left+h.width/2),i.clientY-(h.top+h.height/2));return Math.hypot(i.clientX-(g.left+g.width/2),i.clientY-(g.top+g.height/2))<m?f:p}),l=a.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});a.dispatchEvent(u)},[e]);return Dm(Sm,{children:[gr(Pm,{asChild:!0,children:gr(Cm,{variant:"ghost",color:"grey",size:"small",iconButton:!0,disabled:t,className:t?"opacity-50 cursor-not-allowed":"",onMouseDown:t?void 0:r,children:gr(km,{size:16})})}),gr(Mm,{color:"black",children:o||n("editor.toolbar.connect_node")})]})};import{jsx as Ko}from"react/jsx-runtime";var oo=i=>{var s=i,{edgeId:e,edgeType:t,sourceNode:o,targetNode:n}=s,r=Je(s,["edgeId","edgeType","sourceNode","targetNode"]);let{mode:a}=Q(),{isFromStartEvent:l,isGatewayToGateway:c,isActiviyToAndGateway:d}=wn(o,n),u=!l&&!c&&!d,p=[{component:Ko(mr,{elementId:e,elementType:"edge"})}],f=()=>a==="view"?u?[{component:Ko(bt,{elementId:e,elementType:"edge"})}]:[]:u?[{component:Ko(bt,{elementId:e,elementType:"edge"})},...p]:p,g=(m=>{switch(m){case"SEQUENCE_EDGE":return f();case"MESSAGE_EDGE":return a==="view"?[]:[...p];case"ANNOTATION_EDGE":return a==="view"?[]:[...p];default:return[]}})(t);if(!(g.length===0||a==="view"))return Ko("div",v(y({className:"flex items-center gap-1 w-fit px-3 py-2 bg-white rounded-sm shadow-md"},r),{children:g.map((m,E)=>Ko("div",{children:m.component},E))}))};import{useViewport as Om}from"@xyflow/react";import{useMemo as Vm}from"react";import{jsx as Nl}from"react/jsx-runtime";var et=12,no=({sx:e,sy:t,tx:o,ty:n,hasLabel:r=!1,children:i})=>{let{zoom:s}=Om(),a=1/s,l=Vm(()=>t===n?{bottom:`${et}px`,transform:"translateX(-50%)"}:e===o?{left:`${et}px`,transform:r?"translateY(-100%)":"translateY(-50%)"}:n>t&&o>e?{left:`${et}px`,bottom:`${et}px`}:n>t&&o<e?{right:`${et}px`,bottom:`${et}px`}:t>n&&o>e?{right:`${et}px`,bottom:`${et}px`}:{left:`${et}px`,bottom:`${et}px`},[e,t,o,n,r]);return Nl("div",{style:{transform:`scale(${a})`},children:Nl("div",{className:"absolute pointer-events-auto",style:y({},l),children:i})})};import{jsx as qo,jsxs as zm}from"react/jsx-runtime";var ro={type:"ANNOTATION_EDGE",reconnectable:!0},wl=({id:e,source:t,target:o,selected:n,data:r})=>{let{isMultipleSelection:i}=Q(),s=vl(t),a=vl(o);if(!s||!a)return null;let{sx:l,sy:c,tx:d,ty:u}=Zt(s,a),[p,f,h]=Bm({sourceX:l,sourceY:c,targetX:d,targetY:u}),g=n||(s==null?void 0:s.selected)||(a==null?void 0:a.selected);return zm("g",{className:O("text-grey-500 hover:text-grey-600",{"text-blue-500 hover:text-blue-600":g}),children:[qo(Hm,{id:e,path:p,strokeDasharray:4,className:O("stroke-2 stroke-current transition-colors duration-75",{"stroke-red-500 hover:stroke-red-600":r==null?void 0:r.hasError,"stroke-blue-500 hover:stroke-blue-600 drop-shadow-[0_0_3px_rgba(59,130,246,0.5)]":g&&!(r!=null&&r.hasError)})}),qo(Gm,{children:qo("div",{className:"absolute z-[3000] pointer-events-auto flex flex-col items-center gap-1",style:{transform:`translate(-50%, -50%) translate(${f}px, ${h}px)`},children:n&&!i&&qo(no,{sx:l,sy:c,tx:d,ty:u,children:qo(oo,{edgeId:e,edgeType:"ANNOTATION_EDGE"})})})})]})};import{useState as Ll,useCallback as Zm,useMemo as Ci,useEffect as Jm,useRef as kl}from"react";import{BaseEdge as Qm,EdgeLabelRenderer as jm,MarkerType as Rl,useInternalNode as Dl,useReactFlow as eg,useViewport as tg,useEdges as og,Position as ao}from"@xyflow/react";import{useCallback as Fm,useEffect as vi,useRef as Al,useState as Wm}from"react";import{jsx as Cl}from"react/jsx-runtime";var wi=/[a-zA-Z0-9À-ÖØ-öø-ÿ]/,Il=["Backspace","Delete","ArrowLeft","ArrowRight","ArrowUp","ArrowDown","Home","End","Tab","Escape","Shift"],we=({value:e,maxLength:t,style:o,className:n,contentClassName:r,isEditing:i,onChange:s,onBlur:a,onInput:l,onInvalidFirstCharacter:c})=>{let d=Al(null),u=Al(null),[p,f]=Wm(!1);vi(()=>()=>{u.current&&clearTimeout(u.current)},[]),vi(()=>{f(i!=null?i:!1)},[i]),vi(()=>{if(p&&d.current){d.current.focus();let T=document.createRange();T.selectNodeContents(d.current);let N=window.getSelection();N&&(N.removeAllRanges(),N.addRange(T))}},[p]);let h=Fm(()=>{u.current||(c==null||c(),u.current=setTimeout(()=>{u.current=null},500))},[c]),g=T=>{T.stopPropagation(),p||f(!0)},m=T=>{let N=T.currentTarget.innerText.replace(/\n$/,""),x=t&&N.length>=t,w=window.getSelection(),C=(w==null?void 0:w.toString())||"",I=C.length>0,R=(T.ctrlKey||T.metaKey)&&!T.altKey,S=R&&T.key==="a",D=R&&T.key==="c",X=R&&T.key==="x",Z=R&&T.key==="v";if((N.length===0||I&&C.length===N.length)&&!wi.test(T.key)&&!Il.includes(T.key)&&!R){T.preventDefault(),h();return}x&&!I&&(Il.includes(T.key)||S||D||X||Z||T.preventDefault())},E=T=>{T.preventDefault();let N=T.clipboardData.getData("text/plain").replace(/\r\n/g,`
1
+ var bu=Object.defineProperty,_u=Object.defineProperties;var Tu=Object.getOwnPropertyDescriptors;var yn=Object.getOwnPropertySymbols;var os=Object.prototype.hasOwnProperty,ns=Object.prototype.propertyIsEnumerable;var ts=(e,t,o)=>t in e?bu(e,t,{enumerable:!0,configurable:!0,writable:!0,value:o}):e[t]=o,_=(e,t)=>{for(var o in t||(t={}))os.call(t,o)&&ts(e,o,t[o]);if(yn)for(var o of yn(t))ns.call(t,o)&&ts(e,o,t[o]);return e},v=(e,t)=>_u(e,Tu(t));var je=(e,t)=>{var o={};for(var n in e)os.call(e,n)&&t.indexOf(n)<0&&(o[n]=e[n]);if(e!=null&&yn)for(var n of yn(e))t.indexOf(n)<0&&ns.call(e,n)&&(o[n]=e[n]);return o};var ei=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 Nu,Translations as vu}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:{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 is={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:{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 ss={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:{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 as={pt_BR:ss,en_US:rs,es_ES:is};var ls,cs,wu=(cs=(ls=ei("LecomUserLanguage"))!=null?ls:ei("org.springframework.web.servlet.i18n.CookieLocaleResolver.LOCALE"))!=null?cs:vu.PT_BR;Nu({lng:wu,resources:as});var Re=(n=>(n.EDIT="edit",n.VIEW="view",n.READONLY="readonly",n))(Re||{});var xn=(r=>(r.ACTIVITY="activity",r.ROUTING="routing",r.GATEWAY="gateway",r.SUB_PROCESS="sub_process",r))(xn||{}),ti=(n=>(n.START="start",n.END="end",n.BETWEEN="between",n))(ti||{}),oi=(n=>(n.SCRIPT="script",n.LOOP="loop",n.SCRIPT_LOOP="script_loop",n))(oi||{}),ni=(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))(ni||{});import{RotateCcw as Vu,ScrollText as Hu,SquarePlus as Gu}from"lucide-react";import{jsx as En,jsxs as Au}from"react/jsx-runtime";var bn=({size:e=24,className:t})=>Au("svg",{width:e,height:e,viewBox:"0 0 24 24",xmlns:"http://www.w3.org/2000/svg",fill:"#6b7280",className:t,children:[En("path",{strokeWidth:"2",d:"M16 3V3.5085V11.9998V20.4915V21H16.5411H21.4592H22V19.123H21.4592H17.9974V11.9998V4.8773H21.4592H22V3H21.4592H16.5411H16Z"}),En("path",{d:"M4.41026 16.9999L2 18.7861L3.89693 21.1103L6.3072 19.324L4.41026 16.9999Z"}),En("path",{d:"M8.41026 13.9999L6 15.7861L7.89693 18.1103L10.3072 16.324L8.41026 13.9999Z"}),En("path",{d:"M12.4313 10.954L10.021 12.7402L11.9179 15.0644L14.3282 13.2781L12.4313 10.954Z"})]});import{jsx as ds}from"react/jsx-runtime";var qt=({size:e=24,className:t})=>ds("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:ds("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 Co,jsxs as Iu}from"react/jsx-runtime";var Zt=({size:e=24,className:t})=>Iu("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:[Co("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"}),Co("path",{d:"M12 8V16",strokeLinecap:"round",strokeLinejoin:"round"}),Co("path",{d:"M8 12H16",strokeLinecap:"round",strokeLinejoin:"round"}),Co("path",{d:"M9.17139 9.17188L14.8282 14.8287",strokeLinecap:"round",strokeLinejoin:"round"}),Co("path",{d:"M14.8281 9.17188L9.17127 14.8287",strokeLinecap:"round",strokeLinejoin:"round"})]});import{jsx as ri,jsxs as Cu}from"react/jsx-runtime";var Jt=({size:e=24,className:t})=>Cu("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:[ri("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"}),ri("path",{d:"M14.8286 9.17188L9.17176 14.8287",strokeLinecap:"round",strokeLinejoin:"round"}),ri("path",{d:"M9.17139 9.17188L14.8282 14.8287",strokeLinecap:"round",strokeLinejoin:"round"})]});import{jsx as ii,jsxs as Su}from"react/jsx-runtime";var Qt=({size:e=24,className:t})=>Su("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 si,jsxs as Mu}from"react/jsx-runtime";var us=({size:e=24,className:t})=>si("svg",{width:e,height:e,viewBox:"0 0 34 24",xmlns:"http://www.w3.org/2000/svg",fill:"currentColor",className:t,children:Mu("g",{children:[si("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"}),si("path",{d:"M24.5 4.5L28 1M28 1L31.5 4.5M28 1V8",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round"})]})});import{clsx as Pu}from"clsx";import{twMerge as Lu}from"tailwind-merge";function O(...e){return Lu(Pu(e))}var mt=(e=0,t=0)=>e<t?t:e,_n=(e=1e3)=>new Promise(t=>{setTimeout(t,e)});import{jsx as ps,jsxs as ku}from"react/jsx-runtime";var fs=({size:e=24,className:t})=>ku("svg",{width:e,height:e,viewBox:"0 0 24 24",fill:"none",stroke:"#6b7280",strokeWidth:2,xmlns:"http://www.w3.org/2000/svg",className:O("stroke-2",t),children:[ps("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"}),ps("path",{d:"M9 3V21",strokeLinecap:"round",strokeLinejoin:"round"})]});import{jsx as ai}from"react/jsx-runtime";var ms=({size:e=24,className:t})=>ai("svg",{width:e,height:e,viewBox:"0 0 24 24",xmlns:"http://www.w3.org/2000/svg",stroke:"currentColor",className:t,children:ai("g",{children:ai("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 Tn=({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 hs}from"react/jsx-runtime";var So=({size:e=24,className:t})=>hs("svg",{width:e,height:e,viewBox:"0 0 24 24",xmlns:"http://www.w3.org/2000/svg",fill:"white",stroke:"#6b7280",className:O("stroke-2",t),children:hs("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 li,jsxs as Ru}from"react/jsx-runtime";var ys=({size:e=24,className:t})=>Ru("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:[li("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"}),li("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"}),li("path",{d:"M7.5 7.5V10H10",strokeWidth:"1.5",fill:"none",strokeLinecap:"round",strokeLinejoin:"round"})]});import{jsx as Mo,jsxs as Du}from"react/jsx-runtime";var xs=({size:e=24,className:t})=>Du("svg",{width:e,height:e,viewBox:"0 0 24 24",xmlns:"http://www.w3.org/2000/svg",fill:"white",stroke:"#6b7280",strokeWidth:"2",className:t,children:[Mo("path",{d:"M20 3H4C2.89543 3 2 4.34315 2 6V18C2 19.6569 2.89543 21 4 21H20C21.1046 21 22 19.6569 22 18V6C22 4.34315 21.1046 3 20 3Z",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"}),Mo("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"}),Mo("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"}),Mo("path",{d:"M13.5 12H11",strokeWidth:"1",strokeLinecap:"round",strokeLinejoin:"round"}),Mo("path",{d:"M13.5 10H11",strokeWidth:"1",strokeLinecap:"round",strokeLinejoin:"round"})]});import{jsx as Nn,jsxs as Ou}from"react/jsx-runtime";var Es=({size:e=24,className:t})=>Ou("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:[Nn("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"}),Nn("path",{d:"M8 21V14C8 13.4477 8.44772 13 9 13H15C15.5523 13 16 13.4477 16 14V21",strokeWidth:"1",fill:"none"}),Nn("path",{d:"M10.2222 17H13.7777",strokeWidth:"1",strokeLinecap:"round",strokeLinejoin:"round"}),Nn("path",{d:"M12 15.2227V18.7782",strokeWidth:"1",strokeLinecap:"round",strokeLinejoin:"round"})]});var te=(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))(te||{}),$e=(o=>(o.SCRIPT="SCRIPT",o.SUBPROCESS="SUBPROCESS",o))($e||{}),vn={SCRIPT:{icon:Hu},SUBPROCESS:{icon:Gu}},et=(t=>(t.LOOP="LOOP",t))(et||{}),wn={LOOP:{icon:Vu}},Ke=(n=>(n.EXCLUSIVE="EXCLUSIVE",n.PARALLEL="PARALLEL",n.COMPLEX="COMPLEX",n))(Ke||{}),ci={EXCLUSIVE:{icon:Jt},PARALLEL:{icon:Qt},COMPLEX:{icon:Zt}};import{ReactFlowProvider as zx}from"@xyflow/react";import{createContext as Yx,useContext as Fx,useEffect as Wx,useId as Xx,useMemo as Ux,useState as Je}from"react";import{Background as hx,MiniMap as yx,ReactFlow as xx,SelectionMode as Ex,useKeyPress as bx}from"@xyflow/react";import{forwardRef as _x,useImperativeHandle as Tx}from"react";import{useTranslation as Qy}from"@produto-lecom/lecom-ui";import{useEdgesState as jy,useNodesState as e0,useOnSelectionChange as t0,useReactFlow as o0,useStoreApi as n0}from"@xyflow/react";import{useCallback as Mt,useEffect as r0}from"react";import{Position as Po}from"@xyflow/react";function bs(e,t){var x,T,N,b;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=(x=t==null?void 0:t.measured)==null?void 0:x.width)!=null?T:0)/2,u=i.y+((b=(N=t==null?void 0:t.measured)==null?void 0:N.height)!=null?b:0)/2,f=(d-l)/(2*a)-(u-c)/(2*s),p=(d-l)/(2*a)+(u-c)/(2*s),g=1/(Math.abs(f)+Math.abs(p)||1),h=g*f,m=g*p,E=a*(h+m)+l,y=s*(-h+m)+c;return{x:E,y}}function _s(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?Po.Left:s>=i+n-1?Po.Right:l<=a+1?Po.Top:l>=a+r-1?Po.Bottom:Po.Top}function jt(e,t){let o=bs(e,t),n=bs(t,e),r=_s(e,o),i=_s(t,n);return{sx:o.x,sy:o.y,tx:n.x,ty:n.y,sourcePos:r,targetPos:i}}function An(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"}}import{create as Bu}from"zustand";import{useReactFlow as zu}from"@xyflow/react";import{useCallback as Yu}from"react";var In=()=>{let{setEdges:e}=zu();return Yu(()=>{let o=Lt.getState().pathEdgeIds;e(n=>n.map(r=>v(_({},r),{selected:o.includes(r.id)})))},[e])},Lt=Bu((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:g,path:h}=f.shift();if(g===u)return h;let m=a[g]||[];for(let{targetId:E,edgeId:y}of m)p.has(E)||(p.add(E),f.push({node:E,path:[...h,y]}))}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 rm,useReactFlow as im,useStore as sm}from"@xyflow/react";import{useCallback as Uo,useEffect as am,useRef as lm,useState as gl}from"react";import{shallow as cm}from"zustand/shallow";var Fu={value:()=>{}};function Ns(){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 Cn(o)}function Cn(e){this._=e}function Wu(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}})}Cn.prototype=Ns.prototype={constructor:Cn,on:function(e,t){var o=this._,n=Wu(e+"",o),r,i=-1,a=n.length;if(arguments.length<2){for(;++i<a;)if((r=(e=n[i]).type)&&(r=Xu(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]=Ts(o[r],e.name,t);else if(t==null)for(r in o)o[r]=Ts(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 Cn(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 Xu(e,t){for(var o=0,n=e.length,r;o<n;++o)if((r=e[o]).name===t)return r.value}function Ts(e,t,o){for(var n=0,r=e.length;n<r;++n)if(e[n].name===t){e[n]=Fu,e=e.slice(0,n).concat(e.slice(n+1));break}return o!=null&&e.push({name:t,value:o}),e}var di=Ns;var Sn="http://www.w3.org/1999/xhtml",ui={svg:"http://www.w3.org/2000/svg",xhtml:Sn,xlink:"http://www.w3.org/1999/xlink",xml:"http://www.w3.org/XML/1998/namespace",xmlns:"http://www.w3.org/2000/xmlns/"};function it(e){var t=e+="",o=t.indexOf(":");return o>=0&&(t=e.slice(0,o))!=="xmlns"&&(e=e.slice(o+1)),ui.hasOwnProperty(t)?{space:ui[t],local:e}:e}function Uu(e){return function(){var t=this.ownerDocument,o=this.namespaceURI;return o===Sn&&t.documentElement.namespaceURI===Sn?t.createElement(e):t.createElementNS(o,e)}}function $u(e){return function(){return this.ownerDocument.createElementNS(e.space,e.local)}}function Mn(e){var t=it(e);return(t.local?$u:Uu)(t)}function Ku(){}function kt(e){return e==null?Ku:function(){return this.querySelector(e)}}function vs(e){typeof e!="function"&&(e=kt(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 be(n,this._parents)}function pi(e){return e==null?[]:Array.isArray(e)?e:Array.from(e)}function qu(){return[]}function Lo(e){return e==null?qu:function(){return this.querySelectorAll(e)}}function Zu(e){return function(){return pi(e.apply(this,arguments))}}function ws(e){typeof e=="function"?e=Zu(e):e=Lo(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 be(n,r)}function ko(e){return function(){return this.matches(e)}}function Pn(e){return function(t){return t.matches(e)}}var Ju=Array.prototype.find;function Qu(e){return function(){return Ju.call(this.children,e)}}function ju(){return this.firstElementChild}function As(e){return this.select(e==null?ju:Qu(typeof e=="function"?e:Pn(e)))}var ep=Array.prototype.filter;function tp(){return Array.from(this.children)}function op(e){return function(){return ep.call(this.children,e)}}function Is(e){return this.selectAll(e==null?tp:op(typeof e=="function"?e:Pn(e)))}function Cs(e){typeof e!="function"&&(e=ko(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 be(n,this._parents)}function Ln(e){return new Array(e.length)}function Ss(){return new be(this._enter||this._groups.map(Ln),this._parents)}function Ro(e,t){this.ownerDocument=e.ownerDocument,this.namespaceURI=e.namespaceURI,this._next=null,this._parent=e,this.__data__=t}Ro.prototype={constructor:Ro,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 Ms(e){return function(){return e}}function np(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 Ro(e,i[a]);for(;a<l;++a)(s=t[a])&&(r[a]=s)}function rp(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 Ro(e,i[s]);for(s=0;s<d;++s)(l=t[s])&&c.get(f[s])===l&&(r[s]=l)}function ip(e){return e.__data__}function Ps(e,t){if(!arguments.length)return Array.from(this,ip);var o=t?rp:np,n=this._parents,r=this._groups;typeof e!="function"&&(e=Ms(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=sp(e.call(d,d&&d.__data__,c,n)),g=p.length,h=s[c]=new Array(g),m=a[c]=new Array(g),E=l[c]=new Array(f);o(d,u,h,m,E,p,t);for(var y=0,x=0,T,N;y<g;++y)if(T=h[y]){for(y>=x&&(x=y+1);!(N=m[x])&&++x<g;);T._next=N||null}}return a=new be(a,n),a._enter=s,a._exit=l,a}function sp(e){return typeof e=="object"&&"length"in e?e:Array.from(e)}function Ls(){return new be(this._exit||this._groups.map(Ln),this._parents)}function ks(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 Rs(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,g=0;g<u;++g)(p=c[g]||d[g])&&(f[g]=p);for(;l<r;++l)s[l]=o[l];return new be(s,this._parents)}function Ds(){for(var e=this._groups,t=-1,o=e.length;++t<o;)for(var n=e[t],r=n.length-1,i=n[r],a;--r>=0;)(a=n[r])&&(i&&a.compareDocumentPosition(i)^4&&i.parentNode.insertBefore(a,i),i=a);return this}function Os(e){e||(e=ap);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 be(r,this._parents).order()}function ap(e,t){return e<t?-1:e>t?1:e>=t?0:NaN}function Vs(){var e=arguments[0];return arguments[0]=this,e.apply(null,arguments),this}function Hs(){return Array.from(this)}function Gs(){for(var e=this._groups,t=0,o=e.length;t<o;++t)for(var n=e[t],r=0,i=n.length;r<i;++r){var a=n[r];if(a)return a}return null}function Bs(){let e=0;for(let t of this)++e;return e}function zs(){return!this.node()}function Ys(e){for(var t=this._groups,o=0,n=t.length;o<n;++o)for(var r=t[o],i=0,a=r.length,s;i<a;++i)(s=r[i])&&e.call(s,s.__data__,i,r);return this}function lp(e){return function(){this.removeAttribute(e)}}function cp(e){return function(){this.removeAttributeNS(e.space,e.local)}}function dp(e,t){return function(){this.setAttribute(e,t)}}function up(e,t){return function(){this.setAttributeNS(e.space,e.local,t)}}function pp(e,t){return function(){var o=t.apply(this,arguments);o==null?this.removeAttribute(e):this.setAttribute(e,o)}}function fp(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 Fs(e,t){var o=it(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?cp:lp:typeof t=="function"?o.local?fp:pp:o.local?up:dp)(o,t))}function kn(e){return e.ownerDocument&&e.ownerDocument.defaultView||e.document&&e||e.defaultView}function mp(e){return function(){this.style.removeProperty(e)}}function gp(e,t,o){return function(){this.style.setProperty(e,t,o)}}function hp(e,t,o){return function(){var n=t.apply(this,arguments);n==null?this.style.removeProperty(e):this.style.setProperty(e,n,o)}}function Ws(e,t,o){return arguments.length>1?this.each((t==null?mp:typeof t=="function"?hp:gp)(e,t,o==null?"":o)):gt(this.node(),e)}function gt(e,t){return e.style.getPropertyValue(t)||kn(e).getComputedStyle(e,null).getPropertyValue(t)}function yp(e){return function(){delete this[e]}}function xp(e,t){return function(){this[e]=t}}function Ep(e,t){return function(){var o=t.apply(this,arguments);o==null?delete this[e]:this[e]=o}}function Xs(e,t){return arguments.length>1?this.each((t==null?yp:typeof t=="function"?Ep:xp)(e,t)):this.node()[e]}function Us(e){return e.trim().split(/^|\s+/)}function fi(e){return e.classList||new $s(e)}function $s(e){this._node=e,this._names=Us(e.getAttribute("class")||"")}$s.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 Ks(e,t){for(var o=fi(e),n=-1,r=t.length;++n<r;)o.add(t[n])}function qs(e,t){for(var o=fi(e),n=-1,r=t.length;++n<r;)o.remove(t[n])}function bp(e){return function(){Ks(this,e)}}function _p(e){return function(){qs(this,e)}}function Tp(e,t){return function(){(t.apply(this,arguments)?Ks:qs)(this,e)}}function Zs(e,t){var o=Us(e+"");if(arguments.length<2){for(var n=fi(this.node()),r=-1,i=o.length;++r<i;)if(!n.contains(o[r]))return!1;return!0}return this.each((typeof t=="function"?Tp:t?bp:_p)(o,t))}function Np(){this.textContent=""}function vp(e){return function(){this.textContent=e}}function wp(e){return function(){var t=e.apply(this,arguments);this.textContent=t==null?"":t}}function Js(e){return arguments.length?this.each(e==null?Np:(typeof e=="function"?wp:vp)(e)):this.node().textContent}function Ap(){this.innerHTML=""}function Ip(e){return function(){this.innerHTML=e}}function Cp(e){return function(){var t=e.apply(this,arguments);this.innerHTML=t==null?"":t}}function Qs(e){return arguments.length?this.each(e==null?Ap:(typeof e=="function"?Cp:Ip)(e)):this.node().innerHTML}function Sp(){this.nextSibling&&this.parentNode.appendChild(this)}function js(){return this.each(Sp)}function Mp(){this.previousSibling&&this.parentNode.insertBefore(this,this.parentNode.firstChild)}function ea(){return this.each(Mp)}function ta(e){var t=typeof e=="function"?e:Mn(e);return this.select(function(){return this.appendChild(t.apply(this,arguments))})}function Pp(){return null}function oa(e,t){var o=typeof e=="function"?e:Mn(e),n=t==null?Pp:typeof t=="function"?t:kt(t);return this.select(function(){return this.insertBefore(o.apply(this,arguments),n.apply(this,arguments)||null)})}function Lp(){var e=this.parentNode;e&&e.removeChild(this)}function na(){return this.each(Lp)}function kp(){var e=this.cloneNode(!1),t=this.parentNode;return t?t.insertBefore(e,this.nextSibling):e}function Rp(){var e=this.cloneNode(!0),t=this.parentNode;return t?t.insertBefore(e,this.nextSibling):e}function ra(e){return this.select(e?Rp:kp)}function ia(e){return arguments.length?this.property("__data__",e):this.node().__data__}function Dp(e){return function(t){e.call(this,t,this.__data__)}}function Op(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 Vp(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 Hp(e,t,o){return function(){var n=this.__on,r,i=Dp(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 sa(e,t,o){var n=Op(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?Hp:Vp,r=0;r<i;++r)this.each(s(n[r],t,o));return this}function aa(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 Gp(e,t){return function(){return aa(this,e,t)}}function Bp(e,t){return function(){return aa(this,e,t.apply(this,arguments))}}function la(e,t){return this.each((typeof t=="function"?Bp:Gp)(e,t))}function*ca(){for(var e=this._groups,t=0,o=e.length;t<o;++t)for(var n=e[t],r=0,i=n.length,a;r<i;++r)(a=n[r])&&(yield a)}var zp=[null];function be(e,t){this._groups=e,this._parents=t}function da(){return new be([[document.documentElement]],zp)}function Yp(){return this}be.prototype=da.prototype={constructor:be,select:vs,selectAll:ws,selectChild:As,selectChildren:Is,filter:Cs,data:Ps,enter:Ss,exit:Ls,join:ks,merge:Rs,selection:Yp,order:Ds,sort:Os,call:Vs,nodes:Hs,node:Gs,size:Bs,empty:zs,each:Ys,attr:Fs,style:Ws,property:Xs,classed:Zs,text:Js,html:Qs,raise:js,lower:ea,append:ta,insert:oa,remove:na,clone:ra,datum:ia,on:sa,dispatch:la,[Symbol.iterator]:ca};var st=da;function Rn(e,t,o){e.prototype=t.prototype=o,o.constructor=e}function mi(e,t){var o=Object.create(e.prototype);for(var n in t)o[n]=t[n];return o}function Vo(){}var Do=.7,Vn=1/Do,eo="\\s*([+-]?\\d+)\\s*",Oo="\\s*([+-]?(?:\\d*\\.)?\\d+(?:[eE][+-]?\\d+)?)\\s*",tt="\\s*([+-]?(?:\\d*\\.)?\\d+(?:[eE][+-]?\\d+)?)%\\s*",Fp=/^#([0-9a-f]{3,8})$/,Wp=new RegExp(`^rgb\\(${eo},${eo},${eo}\\)$`),Xp=new RegExp(`^rgb\\(${tt},${tt},${tt}\\)$`),Up=new RegExp(`^rgba\\(${eo},${eo},${eo},${Oo}\\)$`),$p=new RegExp(`^rgba\\(${tt},${tt},${tt},${Oo}\\)$`),Kp=new RegExp(`^hsl\\(${Oo},${tt},${tt}\\)$`),qp=new RegExp(`^hsla\\(${Oo},${tt},${tt},${Oo}\\)$`),ua={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};Rn(Vo,ht,{copy(e){return Object.assign(new this.constructor,this,e)},displayable(){return this.rgb().displayable()},hex:pa,formatHex:pa,formatHex8:Zp,formatHsl:Jp,formatRgb:fa,toString:fa});function pa(){return this.rgb().formatHex()}function Zp(){return this.rgb().formatHex8()}function Jp(){return Ea(this).formatHsl()}function fa(){return this.rgb().formatRgb()}function ht(e){var t,o;return e=(e+"").trim().toLowerCase(),(t=Fp.exec(e))?(o=t[1].length,t=parseInt(t[1],16),o===6?ma(t):o===3?new De(t>>8&15|t>>4&240,t>>4&15|t&240,(t&15)<<4|t&15,1):o===8?Dn(t>>24&255,t>>16&255,t>>8&255,(t&255)/255):o===4?Dn(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=Wp.exec(e))?new De(t[1],t[2],t[3],1):(t=Xp.exec(e))?new De(t[1]*255/100,t[2]*255/100,t[3]*255/100,1):(t=Up.exec(e))?Dn(t[1],t[2],t[3],t[4]):(t=$p.exec(e))?Dn(t[1]*255/100,t[2]*255/100,t[3]*255/100,t[4]):(t=Kp.exec(e))?ya(t[1],t[2]/100,t[3]/100,1):(t=qp.exec(e))?ya(t[1],t[2]/100,t[3]/100,t[4]):ua.hasOwnProperty(e)?ma(ua[e]):e==="transparent"?new De(NaN,NaN,NaN,0):null}function ma(e){return new De(e>>16&255,e>>8&255,e&255,1)}function Dn(e,t,o,n){return n<=0&&(e=t=o=NaN),new De(e,t,o,n)}function Qp(e){return e instanceof Vo||(e=ht(e)),e?(e=e.rgb(),new De(e.r,e.g,e.b,e.opacity)):new De}function to(e,t,o,n){return arguments.length===1?Qp(e):new De(e,t,o,n==null?1:n)}function De(e,t,o,n){this.r=+e,this.g=+t,this.b=+o,this.opacity=+n}Rn(De,to,mi(Vo,{brighter(e){return e=e==null?Vn:Math.pow(Vn,e),new De(this.r*e,this.g*e,this.b*e,this.opacity)},darker(e){return e=e==null?Do:Math.pow(Do,e),new De(this.r*e,this.g*e,this.b*e,this.opacity)},rgb(){return this},clamp(){return new De(Dt(this.r),Dt(this.g),Dt(this.b),Hn(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:ga,formatHex:ga,formatHex8:jp,formatRgb:ha,toString:ha}));function ga(){return`#${Rt(this.r)}${Rt(this.g)}${Rt(this.b)}`}function jp(){return`#${Rt(this.r)}${Rt(this.g)}${Rt(this.b)}${Rt((isNaN(this.opacity)?1:this.opacity)*255)}`}function ha(){let e=Hn(this.opacity);return`${e===1?"rgb(":"rgba("}${Dt(this.r)}, ${Dt(this.g)}, ${Dt(this.b)}${e===1?")":`, ${e})`}`}function Hn(e){return isNaN(e)?1:Math.max(0,Math.min(1,e))}function Dt(e){return Math.max(0,Math.min(255,Math.round(e)||0))}function Rt(e){return e=Dt(e),(e<16?"0":"")+e.toString(16)}function ya(e,t,o,n){return n<=0?e=t=o=NaN:o<=0||o>=1?e=t=NaN:t<=0&&(e=NaN),new qe(e,t,o,n)}function Ea(e){if(e instanceof qe)return new qe(e.h,e.s,e.l,e.opacity);if(e instanceof Vo||(e=ht(e)),!e)return new qe;if(e instanceof qe)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 qe(a,s,l,e.opacity)}function ba(e,t,o,n){return arguments.length===1?Ea(e):new qe(e,t,o,n==null?1:n)}function qe(e,t,o,n){this.h=+e,this.s=+t,this.l=+o,this.opacity=+n}Rn(qe,ba,mi(Vo,{brighter(e){return e=e==null?Vn:Math.pow(Vn,e),new qe(this.h,this.s,this.l*e,this.opacity)},darker(e){return e=e==null?Do:Math.pow(Do,e),new qe(this.h,this.s,this.l*e,this.opacity)},rgb(){var e=this.h%360+(this.h<0)*360,t=isNaN(e)||isNaN(this.s)?0:this.s,o=this.l,n=o+(o<.5?o:1-o)*t,r=2*o-n;return new De(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 qe(xa(this.h),On(this.s),On(this.l),Hn(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=Hn(this.opacity);return`${e===1?"hsl(":"hsla("}${xa(this.h)}, ${On(this.s)*100}%, ${On(this.l)*100}%${e===1?")":`, ${e})`}`}}));function xa(e){return e=(e||0)%360,e<0?e+360:e}function On(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 hi(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 _a(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 hi((o-n/t)*t,a,r,i,s)}}function Ta(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 hi((o-n/t)*t,r,i,a,s)}}var yi=e=>()=>e;function ef(e,t){return function(o){return e+o*t}}function tf(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 Na(e){return(e=+e)==1?Gn:function(t,o){return o-t?tf(t,o,e):yi(isNaN(t)?o:t)}}function Gn(e,t){var o=t-e;return o?ef(e,o):yi(isNaN(e)?t:e)}var Bn=function e(t){var o=Na(t);function n(r,i){var a=o((r=to(r)).r,(i=to(i)).r),s=o(r.g,i.g),l=o(r.b,i.b),c=Gn(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 va(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=to(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 of=va(_a),nf=va(Ta);function ze(e,t){return e=+e,t=+t,function(o){return e*(1-o)+t*o}}var Ei=/[-+]?(?:\d+\.?\d*|\.?\d+)(?:[eE][-+]?\d+)?/g,xi=new RegExp(Ei.source,"g");function rf(e){return function(){return e}}function sf(e){return function(t){return e(t)+""}}function bi(e,t){var o=Ei.lastIndex=xi.lastIndex=0,n,r,i,a=-1,s=[],l=[];for(e=e+"",t=t+"";(n=Ei.exec(e))&&(r=xi.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:ze(n,r)})),o=xi.lastIndex;return o<t.length&&(i=t.slice(o),s[a]?s[a]+=i:s[++a]=i),s.length<2?l[0]?sf(l[0].x):rf(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 wa=180/Math.PI,zn={translateX:0,translateY:0,rotate:0,skewX:0,scaleX:1,scaleY:1};function _i(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)*wa,skewX:Math.atan(l)*wa,scaleX:a,scaleY:s}}var Yn;function Aa(e){let t=new(typeof DOMMatrix=="function"?DOMMatrix:WebKitCSSMatrix)(e+"");return t.isIdentity?zn:_i(t.a,t.b,t.c,t.d,t.e,t.f)}function Ia(e){return e==null?zn:(Yn||(Yn=document.createElementNS("http://www.w3.org/2000/svg","g")),Yn.setAttribute("transform",e),(e=Yn.transform.baseVal.consolidate())?(e=e.matrix,_i(e.a,e.b,e.c,e.d,e.e,e.f)):zn)}function Ca(e,t,o,n){function r(c){return c.length?c.pop()+" ":""}function i(c,d,u,f,p,g){if(c!==u||d!==f){var h=p.push("translate(",null,t,null,o);g.push({i:h-4,x:ze(c,u)},{i:h-2,x:ze(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:ze(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:ze(c,d)}):d&&u.push(r(u)+"skewX("+d+n)}function l(c,d,u,f,p,g){if(c!==u||d!==f){var h=p.push(r(p)+"scale(",null,",",null,")");g.push({i:h-4,x:ze(c,u)},{i:h-2,x:ze(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 g=-1,h=f.length,m;++g<h;)u[(m=f[g]).i]=m.x(p);return u.join("")}}}var Ti=Ca(Aa,"px, ","px)","deg)"),Ni=Ca(Ia,", ",")",")");var oo=0,Go=0,Ho=0,Ma=1e3,Fn,Bo,Wn=0,Ot=0,Xn=0,zo=typeof performance=="object"&&performance.now?performance:Date,Pa=typeof window=="object"&&window.requestAnimationFrame?window.requestAnimationFrame.bind(window):function(e){setTimeout(e,17)};function Fo(){return Ot||(Pa(af),Ot=zo.now()+Xn)}function af(){Ot=0}function Yo(){this._call=this._time=this._next=null}Yo.prototype=Un.prototype={constructor:Yo,restart:function(e,t,o){if(typeof e!="function")throw new TypeError("callback is not a function");o=(o==null?Fo():+o)+(t==null?0:+t),!this._next&&Bo!==this&&(Bo?Bo._next=this:Fn=this,Bo=this),this._call=e,this._time=o,vi()},stop:function(){this._call&&(this._call=null,this._time=1/0,vi())}};function Un(e,t,o){var n=new Yo;return n.restart(e,t,o),n}function La(){Fo(),++oo;for(var e=Fn,t;e;)(t=Ot-e._time)>=0&&e._call.call(void 0,t),e=e._next;--oo}function Sa(){Ot=(Wn=zo.now())+Xn,oo=Go=0;try{La()}finally{oo=0,cf(),Ot=0}}function lf(){var e=zo.now(),t=e-Wn;t>Ma&&(Xn-=t,Wn=e)}function cf(){for(var e,t=Fn,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:Fn=o);Bo=e,vi(n)}function vi(e){if(!oo){Go&&(Go=clearTimeout(Go));var t=e-Ot;t>24?(e<1/0&&(Go=setTimeout(Sa,e-zo.now()-Xn)),Ho&&(Ho=clearInterval(Ho))):(Ho||(Wn=zo.now(),Ho=setInterval(lf,Ma)),oo=1,Pa(Sa))}}function $n(e,t,o){var n=new Yo;return t=t==null?0:+t,n.restart(r=>{n.stop(),e(r+t)},t,o),n}var df=di("start","end","cancel","interrupt"),uf=[],Da=0,ka=1,qn=2,Kn=3,Ra=4,Zn=5,Wo=6;function yt(e,t,o,n,r,i){var a=e.__transition;if(!a)e.__transition={};else if(o in a)return;pf(e,o,{name:t,index:n,group:r,on:df,tween:uf,time:i.time,delay:i.delay,duration:i.duration,ease:i.ease,timer:null,state:Da})}function Xo(e,t){var o=_e(e,t);if(o.state>Da)throw new Error("too late; already scheduled");return o}function we(e,t){var o=_e(e,t);if(o.state>Kn)throw new Error("too late; already running");return o}function _e(e,t){var o=e.__transition;if(!o||!(o=o[t]))throw new Error("transition not found");return o}function pf(e,t,o){var n=e.__transition,r;n[t]=o,o.timer=Un(i,0,o.time);function i(c){o.state=ka,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!==ka)return l();for(d in n)if(p=n[d],p.name===o.name){if(p.state===Kn)return $n(a);p.state===Ra?(p.state=Wo,p.timer.stop(),p.on.call("interrupt",e,e.__data__,p.index,p.group),delete n[d]):+d<t&&(p.state=Wo,p.timer.stop(),p.on.call("cancel",e,e.__data__,p.index,p.group),delete n[d])}if($n(function(){o.state===Kn&&(o.state=Ra,o.timer.restart(s,o.delay,o.time),s(c))}),o.state=qn,o.on.call("start",e,e.__data__,o.index,o.group),o.state===qn){for(o.state=Kn,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=Zn,1),u=-1,f=r.length;++u<f;)r[u].call(e,d);o.state===Zn&&(o.on.call("end",e,e.__data__,o.index,o.group),l())}function l(){o.state=Wo,o.timer.stop(),delete n[t];for(var c in n)return;delete e.__transition}}function wi(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>qn&&n.state<Zn,n.state=Wo,n.timer.stop(),n.on.call(r?"interrupt":"cancel",e,e.__data__,n.index,n.group),delete o[a]}i&&delete e.__transition}}function Oa(e){return this.each(function(){wi(this,e)})}function ff(e,t){var o,n;return function(){var r=we(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 mf(e,t,o){var n,r;if(typeof o!="function")throw new Error;return function(){var i=we(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 Va(e,t){var o=this._id;if(e+="",arguments.length<2){for(var n=_e(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?ff:mf)(o,e,t))}function no(e,t,o){var n=e._id;return e.each(function(){var r=we(this,n);(r.value||(r.value={}))[t]=o.apply(this,arguments)}),function(r){return _e(r,n).value[t]}}function Jn(e,t){var o;return(typeof t=="number"?ze:t instanceof ht?Bn:(o=ht(t))?(t=o,Bn):bi)(e,t)}function gf(e){return function(){this.removeAttribute(e)}}function hf(e){return function(){this.removeAttributeNS(e.space,e.local)}}function yf(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 xf(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 Ef(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 bf(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 Ha(e,t){var o=it(e),n=o==="transform"?Ni:Jn;return this.attrTween(e,typeof t=="function"?(o.local?bf:Ef)(o,n,no(this,"attr."+e,t)):t==null?(o.local?hf:gf)(o):(o.local?xf:yf)(o,n,t))}function _f(e,t){return function(o){this.setAttribute(e,t.call(this,o))}}function Tf(e,t){return function(o){this.setAttributeNS(e.space,e.local,t.call(this,o))}}function Nf(e,t){var o,n;function r(){var i=t.apply(this,arguments);return i!==n&&(o=(n=i)&&Tf(e,i)),o}return r._value=t,r}function vf(e,t){var o,n;function r(){var i=t.apply(this,arguments);return i!==n&&(o=(n=i)&&_f(e,i)),o}return r._value=t,r}function Ga(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=it(e);return this.tween(o,(n.local?Nf:vf)(n,t))}function wf(e,t){return function(){Xo(this,e).delay=+t.apply(this,arguments)}}function Af(e,t){return t=+t,function(){Xo(this,e).delay=t}}function Ba(e){var t=this._id;return arguments.length?this.each((typeof e=="function"?wf:Af)(t,e)):_e(this.node(),t).delay}function If(e,t){return function(){we(this,e).duration=+t.apply(this,arguments)}}function Cf(e,t){return t=+t,function(){we(this,e).duration=t}}function za(e){var t=this._id;return arguments.length?this.each((typeof e=="function"?If:Cf)(t,e)):_e(this.node(),t).duration}function Sf(e,t){if(typeof t!="function")throw new Error;return function(){we(this,e).ease=t}}function Ya(e){var t=this._id;return arguments.length?this.each(Sf(t,e)):_e(this.node(),t).ease}function Mf(e,t){return function(){var o=t.apply(this,arguments);if(typeof o!="function")throw new Error;we(this,e).ease=o}}function Fa(e){if(typeof e!="function")throw new Error;return this.each(Mf(this._id,e))}function Wa(e){typeof e!="function"&&(e=ko(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 Pe(n,this._parents,this._name,this._id)}function Xa(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 Pe(a,this._parents,this._name,this._id)}function Pf(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 Lf(e,t,o){var n,r,i=Pf(t)?Xo:we;return function(){var a=i(this,e),s=a.on;s!==n&&(r=(n=s).copy()).on(t,o),a.on=r}}function Ua(e,t){var o=this._id;return arguments.length<2?_e(this.node(),o).on.on(e):this.each(Lf(o,e,t))}function kf(e){return function(){var t=this.parentNode;for(var o in this.__transition)if(+o!==e)return;t&&t.removeChild(this)}}function $a(){return this.on("end.remove",kf(this._id))}function Ka(e){var t=this._name,o=this._id;typeof e!="function"&&(e=kt(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,yt(c[f],t,o,f,c,_e(d,o)));return new Pe(i,this._parents,t,o)}function qa(e){var t=this._name,o=this._id;typeof e!="function"&&(e=Lo(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,g=_e(d,o),h=0,m=f.length;h<m;++h)(p=f[h])&&yt(p,t,o,h,f,g);i.push(f),a.push(d)}return new Pe(i,a,t,o)}var Rf=st.prototype.constructor;function Za(){return new Rf(this._groups,this._parents)}function Df(e,t){var o,n,r;return function(){var i=gt(this,e),a=(this.style.removeProperty(e),gt(this,e));return i===a?null:i===o&&a===n?r:r=t(o=i,n=a)}}function Ja(e){return function(){this.style.removeProperty(e)}}function Of(e,t,o){var n,r=o+"",i;return function(){var a=gt(this,e);return a===r?null:a===n?i:i=t(n=a,o)}}function Vf(e,t,o){var n,r,i;return function(){var a=gt(this,e),s=o(this),l=s+"";return s==null&&(l=s=(this.style.removeProperty(e),gt(this,e))),a===l?null:a===n&&l===r?i:(r=l,i=t(n=a,s))}}function Hf(e,t){var o,n,r,i="style."+t,a="end."+i,s;return function(){var l=we(this,e),c=l.on,d=l.value[i]==null?s||(s=Ja(t)):void 0;(c!==o||r!==d)&&(n=(o=c).copy()).on(a,r=d),l.on=n}}function Qa(e,t,o){var n=(e+="")=="transform"?Ti:Jn;return t==null?this.styleTween(e,Df(e,n)).on("end.style."+e,Ja(e)):typeof t=="function"?this.styleTween(e,Vf(e,n,no(this,"style."+e,t))).each(Hf(this._id,e)):this.styleTween(e,Of(e,n,t),o).on("end.style."+e,null)}function Gf(e,t,o){return function(n){this.style.setProperty(e,t.call(this,n),o)}}function Bf(e,t,o){var n,r;function i(){var a=t.apply(this,arguments);return a!==r&&(n=(r=a)&&Gf(e,a,o)),n}return i._value=t,i}function ja(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,Bf(e,t,o==null?"":o))}function zf(e){return function(){this.textContent=e}}function Yf(e){return function(){var t=e(this);this.textContent=t==null?"":t}}function el(e){return this.tween("text",typeof e=="function"?Yf(no(this,"text",e)):zf(e==null?"":e+""))}function Ff(e){return function(t){this.textContent=e.call(this,t)}}function Wf(e){var t,o;function n(){var r=e.apply(this,arguments);return r!==o&&(t=(o=r)&&Ff(r)),t}return n._value=e,n}function tl(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,Wf(e))}function ol(){for(var e=this._name,t=this._id,o=Qn(),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=_e(l,t);yt(l,e,o,c,a,{time:d.time+d.delay+d.duration,delay:0,duration:d.duration,ease:d.ease})}return new Pe(n,this._parents,e,o)}function nl(){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=we(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 Xf=0;function Pe(e,t,o,n){this._groups=e,this._parents=t,this._name=o,this._id=n}function rl(e){return st().transition(e)}function Qn(){return++Xf}var at=st.prototype;Pe.prototype=rl.prototype={constructor:Pe,select:Ka,selectAll:qa,selectChild:at.selectChild,selectChildren:at.selectChildren,filter:Wa,merge:Xa,selection:Za,transition:ol,call:at.call,nodes:at.nodes,node:at.node,size:at.size,empty:at.empty,each:at.each,on:Ua,attr:Ha,attrTween:Ga,style:Qa,styleTween:ja,text:el,textTween:tl,remove:$a,tween:Va,delay:Ba,duration:za,ease:Ya,easeVarying:Fa,end:nl,[Symbol.iterator]:at[Symbol.iterator]};function jn(e){return((e*=2)<=1?e*e*e:(e-=2)*e*e+2)/2}var Uf={time:null,delay:0,duration:250,ease:jn};function $f(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 il(e){var t,o;e instanceof Pe?(t=e._id,e=e._name):(t=Qn(),(o=Uf).time=Fo(),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])&&yt(l,e,t,c,a,o||$f(l,t));return new Pe(n,this._parents,e,t)}st.prototype.interrupt=Oa;st.prototype.transition=il;function xt(e,t,o){this.k=e,this.x=t,this.y=o}xt.prototype={constructor:xt,scale:function(e){return e===1?this:new xt(this.k*e,this.x,this.y)},translate:function(e,t){return e===0&t===0?this:new xt(this.k,this.x+this.k*e,this.y+this.k*t)},apply:function(e){return[e[0]*this.k+this.x,e[1]*this.k+this.y]},applyX:function(e){return e*this.k+this.x},applyY:function(e){return e*this.k+this.y},invert:function(e){return[(e[0]-this.x)/this.k,(e[1]-this.y)/this.k]},invertX:function(e){return(e-this.x)/this.k},invertY:function(e){return(e-this.y)/this.k},rescaleX:function(e){return e.copy().domain(e.range().map(this.invertX,this).map(e.invert,e))},rescaleY:function(e){return e.copy().domain(e.range().map(this.invertY,this).map(e.invert,e))},toString:function(){return"translate("+this.x+","+this.y+") scale("+this.k+")"}};var er=new xt(1,0,0);tr.prototype=xt.prototype;function tr(e){for(;!e.__zoom;)if(!(e=e.parentNode))return er;return e.__zoom}var qf=[[Number.NEGATIVE_INFINITY,Number.NEGATIVE_INFINITY],[Number.POSITIVE_INFINITY,Number.POSITIVE_INFINITY]];var sl;(function(e){e.Strict="strict",e.Loose="loose"})(sl||(sl={}));var al;(function(e){e.Free="free",e.Vertical="vertical",e.Horizontal="horizontal"})(al||(al={}));var ll;(function(e){e.Partial="partial",e.Full="full"})(ll||(ll={}));var cl;(function(e){e.Bezier="default",e.Straight="straight",e.Step="step",e.SmoothStep="smoothstep",e.SimpleBezier="simplebezier"})(cl||(cl={}));var dl;(function(e){e.Arrow="arrow",e.ArrowClosed="arrowclosed"})(dl||(dl={}));var Oe;(function(e){e.Left="left",e.Top="top",e.Right="right",e.Bottom="bottom"})(Oe||(Oe={}));var wv={[Oe.Left]:Oe.Right,[Oe.Right]:Oe.Left,[Oe.Top]:Oe.Bottom,[Oe.Bottom]:Oe.Top};var Zf=e=>"id"in e&&"internals"in e&&!("source"in e)&&!("target"in e);var Jf=(e,t=[0,0])=>{var s;let{width:o,height:n}=Qf(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 lt=(e,t=[0,0])=>{var r,i,a,s,l,c,d,u;let{x:o,y:n}=Zf(e)?e.internals.positionAbsolute:Jf(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 Qf(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 Av={[Oe.Left]:{x:-1,y:0},[Oe.Right]:{x:1,y:0},[Oe.Top]:{x:0,y:-1},[Oe.Bottom]:{x:0,y:1}};var jf={nodeOrigin:[0,0],nodeExtent:qf,elevateNodesOnSelect:!0,defaults:{}},Iv=v(_({},jf),{checkEquality:!0});var ul;(function(e){e.Line="line",e.Handle="handle"})(ul||(ul={}));var em={width:0,height:0,x:0,y:0},Cv=v(_({},em),{pointerX:0,pointerY:0,aspectRatio:1});var tm=(e,t)=>e.x<t.x2&&e.x2>t.x&&e.y<t.y2&&e.y2>t.y;function om(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 nm(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 or=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)||!tm(p.nodeBox,r))continue;let g=Math.abs(p.position-o);if(g>nr)continue;let m=om(p.nodeBox,n)>0?0:nm(p.nodeBox,n);c.push({line:p,lineDist:g,nodeDist:m})}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 f=c.length>0?c[0].line:void 0;return f&&(t==="horizontal"?this.lastHorizontalLine=f:this.lastVerticalLine=f),f}};function pl(e,t=Vt,o){let n=[];return e==null||e.forEach(r=>{let i=o(r.id);if(!i)throw new Error(`Node with id ${r.id} not found in internal nodes.`);let a=lt(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 fl(e,t,o,n,r=Object.keys(Vt)){let i=[];for(let s of r){let l=Vt[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 ml(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,Vt={top:{orientation:"horizontal",resolve:(e,t)=>t.y},bottom:{orientation:"horizontal",resolve:(e,t)=>t.y2},left:{orientation:"vertical",resolve:(e,t)=>t.x},right:{orientation:"vertical",resolve:(e,t)=>t.x2},centerX:{orientation:"vertical",resolve:(e,t)=>(t.x+t.x2)/2},centerY:{orientation:"horizontal",resolve:(e,t)=>(t.y+t.y2)/2}};import{jsx as um}from"react/jsx-runtime";var dm=new or;function rr(){let[e,t]=gl(void 0),[o,n]=gl(void 0),{width:r,height:i}=sm(m=>({width:m.width,height:m.height}),cm),a=rm(),s=lm(dm),{screenToFlowPosition:l,getInternalNode:c,getNodes:d}=im(),u=Uo(()=>{t(void 0),n(void 0)},[]),f=Uo(m=>{let E=m!=null?m:d();u();let y=pl(E,Vt,c);s.current.initialize(y)},[c,u,d]),p=Uo(()=>{setTimeout(()=>{f()},100)},[f]);am(()=>{a&&f(d())},[a,f,d]);let g=Uo((m,E)=>{var q,P,H,Y,z,D,J,X,W,B;if(!s.current||m.length===0)return m;u();let y=m.filter(F=>F.type==="position"&&!!F.position),x=m.find(F=>F.type==="dimensions");if(y.length===0&&!x)return m;let T=Object.keys(Vt),N=new Set,b=1/0,w=1/0,C=-1/0,I=-1/0;if(y.length>0)y.forEach(F=>{var ye,fe,se,re,ve,ke;let Z=E.find(ft=>ft.id===F.id);if(!Z)return;N.add(Z.id);let j=c(Z.id);if(!j)return;let le=j.parentId?c(j.parentId):void 0,ce=F.position.x+((ye=le==null?void 0:le.internals.positionAbsolute.x)!=null?ye:0),de=F.position.y+((fe=le==null?void 0:le.internals.positionAbsolute.y)!=null?fe:0),ue=(re=(se=Z.measured)==null?void 0:se.width)!=null?re:0,he=(ke=(ve=Z.measured)==null?void 0:ve.height)!=null?ke:0;b=Math.min(b,ce),w=Math.min(w,de),C=Math.max(C,ce+ue),I=Math.max(I,de+he)}),x&&(T=["top","left"]);else if(x){let F=E.find(ue=>ue.id===x.id);if(!F)return m;N.add(F.id);let Z=c(F.id);if(!Z)return m;let j=Z.internals.positionAbsolute.x,le=Z.internals.positionAbsolute.y,ce=(Y=(H=(q=x.dimensions)==null?void 0:q.width)!=null?H:(P=F.measured)==null?void 0:P.width)!=null?Y:0,de=(X=(J=(z=x.dimensions)==null?void 0:z.height)!=null?J:(D=F.measured)==null?void 0:D.height)!=null?X:0;b=j,w=le,C=j+ce,I=le+de,T=["right","bottom"]}if(b===1/0)return m;let k={x:b,y:w,x2:C,y2:I},{x:S,y:R}=l({x:0,y:0}),{x:U,y:K}=l({x:r,y:i}),ee={x:S,y:R,x2:U,y2:K},{horizontal:A,vertical:M}=fl(s.current,ee,k,N,T),{deltaX:$,deltaY:V,snappedX:L,snappedY:G}=ml(k,A,M);if(L||G){let F=y.some(j=>j.dragging),Z=!!(x!=null&&x.resizing);(F||Z)&&(L&&n(M==null?void 0:M.line),G&&t(A==null?void 0:A.line)),L&&(y.forEach(j=>{j.position&&(j.position.x-=$)}),(x==null?void 0:x.id)===((W=y[0])==null?void 0:W.id)?x.dimensions&&(x.dimensions.width+=$):x&&!y.length&&x.dimensions&&(x.dimensions.width-=$)),G&&(y.forEach(j=>{j.position&&(j.position.y-=V)}),(x==null?void 0:x.id)===((B=y[0])==null?void 0:B.id)?x.dimensions&&(x.dimensions.height+=V):x&&!y.length&&x.dimensions&&(x.dimensions.height-=V))}return m},[l,c,r,i,t,n,u]),h=Uo(()=>um(hl,{horizontal:e,vertical:o}),[e,o]);return{rebuildIndex:f,forceRebuildIndex:p,updateHelperLines:g,helperLineHorizontal:e,helperLineVertical:o,HelperLines:h}}import{reconnectEdge as my,useReactFlow as gy}from"@xyflow/react";import{useCallback as Ft,useRef as hy}from"react";var Et=e=>new Map(e.map(t=>[t.id,t])),$o=(e,t,o)=>t.filter(n=>!(n.source!==e||o&&n.id===o)),yl=(e,t,o)=>t.filter(n=>!(n.target!==e||o&&n.id===o)),Ai=e=>e.some(t=>t.type==="START_EVENT"),bt=(e,t)=>e==="START_EVENT"?!Ai(t):!0,xl=(e,t,o,n,r)=>{let i=Et(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:$o(e,n,r).filter(c=>{let d=i.get(c.target);return(d==null?void 0:d.type)!=="ANNOTATION"}).length>=1},El=(e,t,o,n,r)=>{let i=Et(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:yl(t,n,r).filter(c=>{let d=i.get(c.source);return(d==null?void 0:d.type)!=="ANNOTATION"}).length>=1},ir=(e,t,o,n,r)=>{var c;let i=Et(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:$o(e,n,r).filter(d=>{let u=i.get(d.target);return(u==null?void 0:u.type)!=="ANNOTATION"}).length>=2},bl=(e,t,o)=>{var a,s,l,c;let n=Et(o),r=n.get(e),i=n.get(t);return(r==null?void 0:r.type)!=="GATEWAY"||(i==null?void 0:i.type)!=="GATEWAY"||((a=r==null?void 0:r.data)==null?void 0:a.variant)==="EXCLUSIVE"&&((s=i==null?void 0:i.data)==null?void 0:s.variant)==="PARALLEL"||((l=r==null?void 0:r.data)==null?void 0:l.variant)==="COMPLEX"&&((c=i==null?void 0:i.data)==null?void 0:c.variant)==="PARALLEL"},sr=(e,t)=>{var n;let o=t.find(r=>r.id===e);return!o||o.type!=="TASK"?!1:((n=o.data)==null?void 0:n.variant)==="SCRIPT"},_l=(e,t)=>{var n;let o=t.find(r=>r.id===e);return!o||o.type!=="TASK"?!1:((n=o.data)==null?void 0:n.variant)==="SUBPROCESS"},ar=(e,t)=>{var n;let o=t.find(r=>r.id===e);return!o||o.type!=="TASK"?!1:((n=o.data)==null?void 0:n.attribute)==="LOOP"},Ko=(e,t,o,n)=>{let r=Et(t),i=r.get(e);return!i||i.type!=="TASK"?!1:yl(e,o,n).some(s=>{let l=r.get(s.source);return(l==null?void 0:l.type)==="START_EVENT"})},qo=(e,t,o,n)=>{let r=Et(t),i=r.get(e);return!i||i.type!=="TASK"?!1:$o(e,o,n).some(s=>{let l=r.get(s.target);return(l==null?void 0:l.type)==="END_EVENT"})},Tl=(e,t,o,n,r)=>{let i=Et(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"?qo(t,o,n,r):(s==null?void 0:s.type)==="END_EVENT"&&(a==null?void 0:a.type)==="TASK"?Ko(e,o,n,r):!1},lr=(e,t,o)=>$o(e,t,o).length>0,cr=(e,t,o,n,r)=>{let i=Et(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:$o(e,n,r).filter(c=>{let d=i.get(c.target);return(d==null?void 0:d.type)!=="ANNOTATION"}).length>=2};var Nl=(e,t,o,n)=>o.some(r=>n&&r.id===n?!1:r.source===e&&r.target===t);var pm=[e=>({isValid:e.sourceNodeId!==e.targetNodeId,reason:"self_connection_not_allowed"}),e=>({isValid:!Nl(e.sourceNodeId,e.targetNodeId,e.edges,e.reconnectingEdgeId),reason:"duplicate_connection_not_allowed"}),e=>({isValid:!xl(e.sourceNodeId,e.targetNodeId,e.nodes,e.edges,e.reconnectingEdgeId),reason:"start_event_limit_reached"}),e=>({isValid:!El(e.sourceNodeId,e.targetNodeId,e.nodes,e.edges,e.reconnectingEdgeId),reason:"end_event_limit_reached"}),e=>({isValid:!ir(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:bl(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"&&_l(e.targetNodeId,e.nodes)),reason:"start_event_to_subprocess_not_allowed"}),e=>({isValid:!(e.sourceNodeType==="GATEWAY"&&e.targetNodeType==="END_EVENT"),reason:"gateway_to_end_not_allowed"}),e=>({isValid:!(e.sourceNodeType==="START_EVENT"&&e.targetNodeType==="GATEWAY"),reason:"start_to_gateway_not_allowed"}),e=>({isValid:!(sr(e.sourceNodeId,e.nodes)&&e.targetNodeType==="END_EVENT"),reason:"script_to_end_not_allowed"}),e=>({isValid:!(ar(e.sourceNodeId,e.nodes)&&e.targetNodeType==="END_EVENT"),reason:"loop_to_end_not_allowed"}),e=>({isValid:!(Ko(e.sourceNodeId,e.nodes,e.edges,e.reconnectingEdgeId)&&e.targetNodeType==="END_EVENT"),reason:"initial_activity_to_end_not_allowed"}),e=>({isValid:!Tl(e.sourceNodeId,e.targetNodeId,e.nodes,e.edges,e.reconnectingEdgeId),reason:"concurrent_initial_and_final_activity"}),e=>({isValid:!(qo(e.sourceNodeId,e.nodes,e.edges,e.reconnectingEdgeId)&&e.targetNodeType!=="ANNOTATION"),reason:"final_activity_cannot_connect"}),e=>({isValid:!(lr(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"})],Ii=e=>{for(let t of pm){let o=t(e);if(!o.isValid)return o}return{isValid:!0}};var fm=[{sourceTypes:["GATEWAY"],targetTypes:["TASK","GATEWAY"],validate:e=>({shouldDisable:ir(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:Ai(e.nodes),reason:"start_event_already_exists"})},{sourceTypes:["TASK"],targetTypes:["END_EVENT"],validate:e=>({shouldDisable:sr(e.sourceNodeId,e.nodes),reason:"script_to_end_not_allowed"})},{sourceTypes:["TASK"],targetTypes:["END_EVENT"],validate:e=>({shouldDisable:ar(e.sourceNodeId,e.nodes),reason:"loop_to_end_not_allowed"})},{sourceTypes:["TASK"],targetTypes:["END_EVENT"],validate:e=>({shouldDisable:Ko(e.sourceNodeId,e.nodes,e.edges),reason:"initial_activity_to_end_not_allowed"})},{sourceTypes:["TASK"],validate:e=>({shouldDisable:qo(e.sourceNodeId,e.nodes,e.edges)&&e.targetNodeType!=="ANNOTATION",reason:"final_activity_cannot_connect"})},{targetTypes:["END_EVENT"],validate:e=>({shouldDisable:lr(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"})}],vl=e=>{let t=fm.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 Ym,EdgeLabelRenderer as Fm,getStraightPath as Wm,useInternalNode as Al}from"@xyflow/react";import{Button as hm,Tooltip as ym,TooltipContent as xm,TooltipTrigger as Em,useTranslation as bm}from"@produto-lecom/lecom-ui";import{Settings as _m}from"lucide-react";import{getIncomers as dr,getOutgoers as ur,useReactFlow as gm}from"@xyflow/react";import{useStoreApi as mm}from"@xyflow/react";var _t=()=>{let e=mm();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 _n(),!0}}};var pr=()=>{let{getNode:e,getEdge:t,getNodes:o,getEdges:n}=gm(),{selectElements:r}=_t(),i=m=>{let E=o(),y=n(),x=dr(m,E,y),T=ur(m,E,y),N=x.some(w=>w.type==="START_EVENT"),b=T.some(w=>w.type==="END_EVENT");return N?"start":b?"end":"between"},a=(m,E,y)=>{var N,b,w,C;if(!m)return;let x={type:m.type,variant:(N=m.data)==null?void 0:N.variant,attribute:(b=m.data)==null?void 0:b.attribute},T={id:m.id,position:i(m),label:(w=m.data)==null?void 0:w.label,node:x};return m.type==="TASK"&&((C=m.data)==null?void 0:C.variant)==="SUBPROCESS"?v(_({},T),{type:"sub_process"}):m.type==="GATEWAY"?v(_({},T),{type:"gateway",variant:s(m,E,y)}):v(_({},T),{type:"activity"})},s=(m,E,y)=>{if(m.type!=="GATEWAY")return;let x=dr(m,E,y),T=!1,N=!1;if(x.forEach(b=>{var w,C;b.type==="TASK"&&(((w=b.data)==null?void 0:w.variant)==="SCRIPT"&&(T=!0),((C=b.data)==null?void 0:C.attribute)==="LOOP"&&(N=!0))}),T&&N)return"script_loop";if(T)return"script";if(N)return"loop"},l=(m,E,y)=>{var w,C,I,k;let x=e(m.source),T=e(m.target);if(!x||!T)return"simple";if(ur(x,E,y).some(S=>S.type==="END_EVENT"))return"final";if(x.type==="GATEWAY")switch((w=x.data)==null?void 0:w.variant){case"PARALLEL":return"parallel";case"EXCLUSIVE":return"exclusive";case"COMPLEX":return"complex";default:return"simple"}if(x.type==="TASK"){let S=(C=x.data)==null?void 0:C.variant,R=(I=x.data)==null?void 0:I.attribute;if(S==="SUBPROCESS")return"from_sub_process";if(T.type==="TASK"&&((k=T.data)==null?void 0:k.variant)==="SUBPROCESS")return"to_sub_process";let U=S==="SCRIPT",K=R==="LOOP";return U&&K?"script_loop":U?"script":K?"loop":"simple"}return"simple"},c=(m,E,y)=>{let x=[];function T(b,w,C=0){let I=a(b,E,y);if(I.depth=C,w.push(I),b.type==="TASK"){x.push([...w]),w.pop();return}let k=dr(b,E,y);if(k.length)for(let S of k)T(S,w,C+1);w.pop()}let N=dr(m,E,y);for(let b of N)T(b,[]);return x},d=(m,E,y)=>{let x=[];function T(b,w,C=0){let I=a(b,E,y);if(I.depth=C,w.push(I),b.type==="TASK"){x.push([...w]),w.pop();return}let k=ur(b,E,y);if(k.length)for(let S of k)T(S,w,C+1);w.pop()}let N=ur(m,E,y);for(let b of N)T(b,[]);return x},u=(m,E,y)=>(y=y.filter(T=>T.source===m.id),y.map(T=>{var w;let N=e(T.target),b;return N&&(b=a(N,E,y)),{id:T.id,type:"routing",variant:l(T,E,y),label:(w=T.data)==null?void 0:w.label,target:b}})),f=m=>{let E=e(m);if(!E)return;let y=o(),x=n(),T=a(E,y,x);return T.sources=c(E,y,x),T.targets=d(E,y,x),T.edgeTargets=u(E,y,x),E.type==="GATEWAY"&&(T.variant=s(E,y,x)),T},p=m=>{let E=t(m);if(!E)return;let y=o(),x=n(),T=l(E,y,x),b={id:E.id,type:"routing",variant:T,gatewayVariant:void 0},w=e(E.source);if(w){let I=a(w,y,x);b.source=I;let k=s(w,y,x);if(b.gatewayVariant=k,w.type==="TASK")b.sources=[[I]];else{let S=c(w,y,x);b.sources=S.length?S:[[I]]}}let C=e(E.target);if(C){let I=a(C,y,x);if(b.target=I,C.type==="TASK")b.targets=[[I]];else{let k=d(C,y,x);b.targets=k.length?k:[[I]]}}return b},g=m=>{let E=e(m);if(E)return f(E.id);let y=t(m);if(y)return p(y.id)};return{configureElement:m=>{let E=g(m);if(E)return r([m]),E},getConfigureElement:g,getNodeConfigure:f,getEdgeConfigure:p}};import{jsx as fr,jsxs as Tm}from"react/jsx-runtime";var Tt=({elementId:e,elementType:t="node"})=>{let{t:o}=bm(),{onConfigureElement:n}=Q(),{getConfigureElement:r}=pr();return Tm(ym,{children:[fr(Em,{asChild:!0,children:fr(hm,{variant:"ghost",color:"grey",size:"small",iconButton:!0,onClick:()=>{let a=r(e);a&&(n==null||n(a))},children:fr(_m,{size:16})})}),fr(xm,{color:"black",children:o(t==="node"?"editor.toolbar.configure_node":"editor.toolbar.configure_edge")})]})};import{Button as vm,Tooltip as wm,TooltipContent as Am,TooltipTrigger as Im,useTranslation as Cm}from"@produto-lecom/lecom-ui";import{useReactFlow as Sm}from"@xyflow/react";import{TrashIcon as Mm}from"lucide-react";import{useNotificationToast as Nm}from"@produto-lecom/lecom-ui";function Ve(){let{toast:e}=Zo(),{toast:t}=Nm();return{toast:e||t}}import{jsx as mr,jsxs as Pm}from"react/jsx-runtime";var gr=({elementId:e,elementType:t="node"})=>{let{t:o}=Cm(),{toast:n}=Ve(),{deleteElements:r,getNodes:i}=Sm();return Pm(wm,{children:[mr(Im,{asChild:!0,children:mr(vm,{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(Mm,{size:16})})}),mr(Am,{color:"black",children:o("editor.toolbar.delete")})]})};import{Button as Lm,Tooltip as km,TooltipContent as Rm,TooltipTrigger as Dm,useTranslation as Om}from"@produto-lecom/lecom-ui";import{MoveUpRightIcon as Vm}from"lucide-react";import{useCallback as Hm}from"react";import{jsx as hr,jsxs as Gm}from"react/jsx-runtime";var Ht=({nodeId:e,disabled:t=!1,tooltipMessage:o})=>{let{t:n}=Om(),r=Hm(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 g=f.getBoundingClientRect(),h=p.getBoundingClientRect(),m=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))<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 Gm(km,{children:[hr(Dm,{asChild:!0,children:hr(Lm,{variant:"ghost",color:"grey",size:"small",iconButton:!0,disabled:t,className:t?"opacity-50 cursor-not-allowed":"",onMouseDown:t?void 0:r,children:hr(Vm,{size:16})})}),hr(Rm,{color:"black",children:o||n("editor.toolbar.connect_node")})]})};import{jsx as Jo}from"react/jsx-runtime";var io=i=>{var a=i,{edgeId:e,edgeType:t,sourceNode:o,targetNode:n}=a,r=je(a,["edgeId","edgeType","sourceNode","targetNode"]);let{mode:s}=Q(),{isFromStartEvent:l,isGatewayToGateway:c,isActiviyToAndGateway:d}=An(o,n),u=!l&&!c&&!d,f=[{component:Jo(gr,{elementId:e,elementType:"edge"})}],p=()=>s==="view"?u?[{component:Jo(Tt,{elementId:e,elementType:"edge"})}]:[]:u?[{component:Jo(Tt,{elementId:e,elementType:"edge"})},...f]:f,h=(m=>{switch(m){case"SEQUENCE_EDGE":return p();case"MESSAGE_EDGE":return s==="view"?[]:[...f];case"ANNOTATION_EDGE":return s==="view"?[]:[...f];default:return[]}})(t);if(!(h.length===0||s==="view"))return Jo("div",v(_({className:"flex items-center gap-1 w-fit px-3 py-2 bg-white rounded-sm shadow-md"},r),{children:h.map((m,E)=>Jo("div",{children:m.component},E))}))};import{useViewport as Bm}from"@xyflow/react";import{useMemo as zm}from"react";import{jsx as wl}from"react/jsx-runtime";var ot=12,so=({sx:e,sy:t,tx:o,ty:n,hasLabel:r=!1,children:i})=>{let{zoom:a}=Bm(),s=1/a,l=zm(()=>t===n?{bottom:`${ot}px`,transform:"translateX(-50%)"}:e===o?{left:`${ot}px`,transform:r?"translateY(-100%)":"translateY(-50%)"}:n>t&&o>e?{left:`${ot}px`,bottom:`${ot}px`}:n>t&&o<e?{right:`${ot}px`,bottom:`${ot}px`}:t>n&&o>e?{right:`${ot}px`,bottom:`${ot}px`}:{left:`${ot}px`,bottom:`${ot}px`},[e,t,o,n,r]);return wl("div",{style:{transform:`scale(${s})`},children:wl("div",{className:"absolute pointer-events-auto",style:_({},l),children:i})})};import{jsx as Qo,jsxs as Xm}from"react/jsx-runtime";var ao={type:"ANNOTATION_EDGE",reconnectable:!0},Il=({id:e,source:t,target:o,selected:n,data:r})=>{let{isMultipleSelection:i}=Q(),a=Al(t),s=Al(o);if(!a||!s)return null;let{sx:l,sy:c,tx:d,ty:u}=jt(a,s),[f,p,g]=Wm({sourceX:l,sourceY:c,targetX:d,targetY:u}),h=n||(a==null?void 0:a.selected)||(s==null?void 0:s.selected);return Xm("g",{className:O("text-grey-500 hover:text-grey-600",{"text-blue-500 hover:text-blue-600":h}),children:[Qo(Ym,{id:e,path:f,strokeDasharray:4,className:O("stroke-2 stroke-current transition-colors duration-75",{"stroke-red-500 hover:stroke-red-600":r==null?void 0:r.hasError,"stroke-blue-500 hover:stroke-blue-600 drop-shadow-[0_0_3px_rgba(59,130,246,0.5)]":h&&!(r!=null&&r.hasError)})}),Qo(Fm,{children:Qo("div",{className:"absolute z-[3000] pointer-events-auto flex flex-col items-center gap-1",style:{transform:`translate(-50%, -50%) translate(${p}px, ${g}px)`},children:n&&!i&&Qo(so,{sx:l,sy:c,tx:d,ty:u,children:Qo(io,{edgeId:e,edgeType:"ANNOTATION_EDGE"})})})})]})};import{useState as Ol,useCallback as ag,useMemo as Mi,useEffect as lg,useRef as Vl}from"react";import{BaseEdge as cg,EdgeLabelRenderer as dg,MarkerType as Hl,useInternalNode as Gl,useReactFlow as ug,useViewport as pg,useEdges as fg,Position as uo}from"@xyflow/react";import{useCallback as Um,useEffect as Ci,useRef as Cl,useState as $m}from"react";import{jsx as Ml}from"react/jsx-runtime";var Si=/[a-zA-Z0-9À-ÖØ-öø-ÿ]/,Sl=["Backspace","Delete","ArrowLeft","ArrowRight","ArrowUp","ArrowDown","Home","End","Tab","Escape","Shift"],Ie=({value:e,maxLength:t,style:o,className:n,contentClassName:r,isEditing:i,onChange:a,onBlur:s,onInput:l,onInvalidFirstCharacter:c})=>{let d=Cl(null),u=Cl(null),[f,p]=$m(!1);Ci(()=>()=>{u.current&&clearTimeout(u.current)},[]),Ci(()=>{p(i!=null?i:!1)},[i]),Ci(()=>{if(f&&d.current){d.current.focus();let T=document.createRange();T.selectNodeContents(d.current);let N=window.getSelection();N&&(N.removeAllRanges(),N.addRange(T))}},[f]);let g=Um(()=>{u.current||(c==null||c(),u.current=setTimeout(()=>{u.current=null},500))},[c]),h=T=>{T.stopPropagation(),f||p(!0)},m=T=>{let N=T.currentTarget.innerText.replace(/\n$/,""),b=t&&N.length>=t,w=window.getSelection(),C=(w==null?void 0:w.toString())||"",I=C.length>0,k=(T.ctrlKey||T.metaKey)&&!T.altKey,S=k&&T.key==="a",R=k&&T.key==="c",U=k&&T.key==="x",K=k&&T.key==="v";if((N.length===0||I&&C.length===N.length)&&!Si.test(T.key)&&!Sl.includes(T.key)&&!k){T.preventDefault(),g();return}b&&!I&&(Sl.includes(T.key)||S||R||U||K||T.preventDefault())},E=T=>{T.preventDefault();let N=T.clipboardData.getData("text/plain").replace(/\r\n/g,`
2
2
  `).replace(/\r/g,`
3
- `),x=T.currentTarget.innerText.replace(/\n$/,""),w=window.getSelection();if(!w||w.rangeCount===0)return;let C=w.toString(),I=x.length-C.length,R=t?Math.max(0,t-I):1/0;if(R<=0&&C.length===0)return;let S=N;if(S.length>R&&(S=S.substring(0,R)),!S&&C.length===0)return;let D=w.getRangeAt(0);if(D.startOffset===0&&(D.startContainer===T.currentTarget||D.startContainer.parentNode===T.currentTarget)&&S.length>0&&!wi.test(S[0])){h();return}D.deleteContents();let Z=document.createTextNode(S);D.insertNode(Z),D.setStartAfter(Z),D.collapse(!0),w.removeAllRanges(),w.addRange(D),l==null||l(T.currentTarget.innerText.replace(/\n$/,""))},_=T=>{let N=T.currentTarget,x=N.innerText.replace(/\n$/,"");if(x.length>0&&!wi.test(x[0])){let w=x.slice(1);if(N.innerText=w,w.length>0&&N.firstChild){let C=document.createRange(),I=window.getSelection();C.setStart(N.firstChild,0),C.collapse(!0),I==null||I.removeAllRanges(),I==null||I.addRange(C)}h(),l==null||l(w);return}l==null||l(x)},b=T=>{f(!1);let N=T.currentTarget.innerText.replace(/\r\n/g,`
3
+ `),b=T.currentTarget.innerText.replace(/\n$/,""),w=window.getSelection();if(!w||w.rangeCount===0)return;let C=w.toString(),I=b.length-C.length,k=t?Math.max(0,t-I):1/0;if(k<=0&&C.length===0)return;let S=N;if(S.length>k&&(S=S.substring(0,k)),!S&&C.length===0)return;let R=w.getRangeAt(0);if(R.startOffset===0&&(R.startContainer===T.currentTarget||R.startContainer.parentNode===T.currentTarget)&&S.length>0&&!Si.test(S[0])){g();return}R.deleteContents();let K=document.createTextNode(S);R.insertNode(K),R.setStartAfter(K),R.collapse(!0),w.removeAllRanges(),w.addRange(R),l==null||l(T.currentTarget.innerText.replace(/\n$/,""))},y=T=>{let N=T.currentTarget,b=N.innerText.replace(/\n$/,"");if(b.length>0&&!Si.test(b[0])){let w=b.slice(1);if(N.innerText=w,w.length>0&&N.firstChild){let C=document.createRange(),I=window.getSelection();C.setStart(N.firstChild,0),C.collapse(!0),I==null||I.removeAllRanges(),I==null||I.addRange(C)}g(),l==null||l(w);return}l==null||l(b)},x=T=>{p(!1);let N=T.currentTarget.innerText.replace(/\r\n/g,`
4
4
  `).replace(/\r/g,`
5
- `).trim();t&&N.length>t&&(N=N.substring(0,t)),T.currentTarget.innerText=N,a==null||a(),N!==e&&(s==null||s(N))};return Cl("div",{className:O("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:g,children:Cl("div",{ref:d,className:O("outline-none whitespace-pre-wrap overflow-hidden",r,{"nodrag nopan cursor-text":p}),contentEditable:p,suppressContentEditableWarning:!0,onKeyDown:m,onPaste:E,onInput:_,onBlur:b,children:e})})};import{Position as hr}from"@xyflow/react";var Zo=e=>e===hr.Left||e===hr.Right,Ai=(e,t=30)=>e===hr.Right||e===hr.Bottom?t:-t,Ii=(e,t,o,n=1)=>Math.abs(e[o]-t[o])<n,yr=(e,t)=>Math.sqrt((t.x-e.x)**2+(t.y-e.y)**2),xr=(e,t)=>({x:(e.x+t.x)/2,y:(e.y+t.y)/2});var Jo={OFFSET:30,TOLERANCE:1,MOVE_THRESHOLD:5,MIN_SEGMENT_LENGTH:15,PARALLEL_OFFSET:15};function Ym(e,t,o,n,r,i,s=0){let a=Ai(r,Jo.OFFSET),l=Ai(i,Jo.OFFSET),c=Zo(r),d=Zo(i),u=c?0:s,p=c?s:0,f=d?0:s,h=d?s:0,g={x:e+u,y:t+p},m={x:o+f,y:n+h};if(c&&d){let E=(t+n)/2+s;return[g,{x:e+a,y:t+s},{x:e+a,y:E},{x:o+l,y:E},{x:o+l,y:n+s},m]}if(!c&&!d){let E=(e+o)/2+s;return[g,{x:e+s,y:t+a},{x:E,y:t+a},{x:E,y:n+l},{x:o+s,y:n+l},m]}return c?[g,{x:e+a,y:t+s},{x:e+a,y:n+l+s},{x:o+s,y:n+l+s},m]:[g,{x:e+s,y:t+a},{x:o+l+s,y:t+a},{x:o+l+s,y:n+s},m]}function Er(e,t,o,n,r,i,s,a=0){let l=Ym(e,t,o,n,r,i,a);if(!(s!=null&&s.length))return l;let c=[...s];if(c.length>0){let d={x:e,y:t},u=c[0],p=Zo(r);p&&Math.abs(d.y-u.y)>1?c.unshift({x:u.x,y:d.y}):!p&&Math.abs(d.x-u.x)>1&&c.unshift({x:d.x,y:u.y})}if(c.length>0){let d={x:o,y:n},u=c[c.length-1],p=Zo(i);p&&Math.abs(d.y-u.y)>1?c.push({x:u.x,y:d.y}):!p&&Math.abs(d.x-u.x)>1&&c.push({x:d.x,y:u.y})}return[{x:e,y:t},...c,{x:o,y:n}]}var Sl=(e,t)=>Math.sqrt(Math.pow(t.x-e.x,2)+Math.pow(t.y-e.y,2));function Um(e,t,o,n){let r=Math.min(Sl(e,t)/2,Sl(t,o)/2,n),{x:i,y:s}=t;if(e.x===i&&i===o.x||e.y===s&&s===o.y)return`L${i} ${s}`;if(e.y===s){let c=e.x<o.x?-1:1,d=e.y<o.y?1:-1;return`L ${i+r*c},${s}Q ${i},${s} ${i},${s+r*d}`}let a=e.x<o.x?1:-1,l=e.y<o.y?-1:1;return`L ${i},${s+r*l}Q ${i},${s} ${i+r*a},${s}`}var Ml=(e,t=5)=>e.length<2?"":e.reduce((o,n,r)=>{let i="";return r>0&&r<e.length-1?i=Um(e[r-1],n,e[r+1],t):i=`${r===0?"M":"L"}${n.x} ${n.y}`,o+=i,o},"");import{useCallback as io,useEffect as br,useRef as Qo,useState as so}from"react";import{useReactFlow as $m,useStore as Xm}from"@xyflow/react";var Km=50,Pl=.1,qm=.6,_r=({edgeId:e,source:t,target:o,instanceId:n,isReadOnly:r})=>{let{setEdges:i,getNode:s,getNodes:a,getEdge:l,screenToFlowPosition:c}=$m(),{setIsDragging:d,setReconnectingEdgeId:u}=Q(),p=Xm(L=>L.isValidConnection),[f,h]=so(null),[g,m]=so(null),[E,_]=so(null),[b,T]=so(null),[N,x]=so(null),[w,C]=so(!1),I=Qo(null),R=Qo(null),S=Qo(null),D=Qo(t),X=Qo(o);br(()=>{D.current=t,X.current=o},[t,o]),br(()=>{I.current=f},[f]),br(()=>{R.current=N},[N]);let Z=io(L=>{let G=a(),K=G.find(z=>z.id===L);if(!K)return{x:0,y:0};let P=K.position.x,H=K.position.y,F=K.parentId;for(;F;){let z=G.find(k=>k.id===F);if(!z)break;P+=z.position.x,H+=z.position.y,F=z.parentId}return{x:P,y:H}},[a]),te=io(L=>{var F,z,k,J,U,Y;let G=a(),K=null,P=Km,H=G.filter(B=>B.type!=="LANE"&&B.type!=="ANNOTATION");for(let B of H){if(B.id===e)continue;let W=Z(B.id),q=(k=(z=(F=B.measured)==null?void 0:F.width)!=null?z:B.width)!=null?k:0,j=(Y=(U=(J=B.measured)==null?void 0:J.height)!=null?U:B.height)!=null?Y:0;if(L.x>=W.x&&L.x<=W.x+q&&L.y>=W.y&&L.y<=W.y+j)return B.id;let ae=Math.max(W.x-L.x,0,L.x-(W.x+q)),le=Math.max(W.y-L.y,0,L.y-(W.y+j)),ce=Math.sqrt(ae*ae+le*le);ce<P&&(P=ce,K=B.id)}return K},[a,Z,e]),A=io((L,G)=>{var ae,le,ce,me,ge,ue;let K=s(L);if(!K)return null;let P=Z(L),H=(ce=(le=(ae=K.measured)==null?void 0:ae.width)!=null?le:K.width)!=null?ce:0,F=(ue=(ge=(me=K.measured)==null?void 0:me.height)!=null?ge:K.height)!=null?ue:0,z=Math.abs(P.x+H-G.x),k=Math.abs(G.x-P.x),J=Math.abs(P.y+F-G.y),U=Math.abs(G.y-P.y),Y={right:z,left:k,bottom:J,top:U},B=Object.entries(Y).reduce((ie,[ne,Te])=>Te<ie[1]?[ne,Te]:ie,["right",Y.right])[0],W=S.current;if(W&&W!==B){let ie=Y[B],ne=Y[W],Te=Math.abs(ne-ie),Pe=Math.min(Math.abs(ne),Math.abs(ie));Te<Pe*qm&&(B=W)}let q=B,j,se;if(q==="right"||q==="left"){let ne=(Math.max(P.y,Math.min(P.y+F,G.y))-P.y)/(F||1);Math.abs(ne-.5)<Pl&&(ne=.5),se=ne,j={x:q==="right"?P.x+H:P.x,y:P.y+se*F}}else{let ne=(Math.max(P.x,Math.min(P.x+H,G.x))-P.x)/(H||1);Math.abs(ne-.5)<Pl&&(ne=.5),se=ne,j={x:P.x+se*H,y:q==="bottom"?P.y+F:P.y}}return{side:q,snapPosition:j,offset:se}},[s,Z]),M=io(L=>{var k,J,U;let G=I.current;if(!G)return;let K=c({x:L.clientX,y:L.clientY}),P=te(K);_(P);let H=K,F=null,z=null;if(P){let Y=A(P,K);Y&&(F=Y.side,H=Y.snapPosition,z=Y.offset,S.current=F);let B=l(e),W={source:G==="source"?P:D.current,target:G==="target"?P:X.current,sourceHandle:G==="source"?F:(k=B==null?void 0:B.sourceHandle)!=null?k:null,targetHandle:G==="target"?F:(J=B==null?void 0:B.targetHandle)!=null?J:null},q=(U=p==null?void 0:p(W))!=null?U:!0;C(q)}else S.current=null,C(!1);T(F),x(z),m(H)},[te,A,l,e,c,p]),$=io(L=>{var F,z,k,J,U;let G=I.current;if(!G)return;let K=c({x:L.clientX,y:L.clientY}),P=te(K);if(P){let Y=A(P,K),B=(F=Y==null?void 0:Y.side)!=null?F:null,W=(z=Y==null?void 0:Y.offset)!=null?z:.5,q=l(e),j={source:G==="source"?P:D.current,target:G==="target"?P:X.current,sourceHandle:G==="source"?B:(k=q==null?void 0:q.sourceHandle)!=null?k:null,targetHandle:G==="target"?B:(J=q==null?void 0:q.targetHandle)!=null?J:null};((U=p==null?void 0:p(j))==null||U)&&i(se=>se.map(ae=>{var le,ce;return ae.id===e?v(y({},ae),{source:j.source,target:j.target,sourceHandle:j.sourceHandle,targetHandle:j.targetHandle,data:v(y({},ae.data),{points:void 0,sourceOffset:G==="source"?W:(le=ae.data)==null?void 0:le.sourceOffset,targetOffset:G==="target"?W:(ce=ae.data)==null?void 0:ce.targetOffset})}):ae}))}h(null),m(null),_(null),T(null),x(null),d(!1),C(!1),u(null),S.current=null,document.removeEventListener("mouseup",$),document.removeEventListener("mousemove",M);let H=tt.get(n);H==null||H.clearReconnectingEdge()},[e,te,A,l,i,n,M,p,c,d,u]),V=io((L,G)=>{if(r||G.button!==0)return;G.stopPropagation(),G.preventDefault(),i(P=>P.map(H=>H.id===e?v(y({},H),{data:v(y({},H.data),{points:void 0})}):H)),h(L),u(e);let K=tt.get(n);K==null||K.setReconnectingEdge(e),document.addEventListener("mousemove",M),document.addEventListener("mouseup",$)},[r,e,n,M,$,u,i]);return br(()=>()=>{if(I.current){document.removeEventListener("mousemove",M),document.removeEventListener("mouseup",$),u(null);let L=tt.get(n);L==null||L.clearReconnectingEdge()}},[n,M,$,u]),{reconnectingHandle:f,cursorPosition:g,hoveredNodeId:E,reconnectingSide:b,reconnectingOffset:N,isValidReconnection:w,handleReconnectStart:V}};import{Fragment as Vl,jsx as Ae,jsxs as _t}from"react/jsx-runtime";var Be={type:"SEQUENCE_EDGE",reconnectable:!0,markerStart:{type:Rl.ArrowClosed},markerEnd:{type:Rl.Arrow},data:{label:""}},{MOVE_THRESHOLD:Tr,MIN_SEGMENT_LENGTH:ng,PARALLEL_OFFSET:Ol}=Jo;function rg(e,t,o,n){let r=n.filter(a=>a.source===t&&a.target===o||a.source===o&&a.target===t);if(r.length<=1){let a=n.filter(d=>d.source===t);if(a.length<=1)return 0;let l=a.findIndex(d=>d.id===e);if(l<=0)return 0;let c=(a.length-1)/2;return(l-c)*Ol}let i=r.findIndex(a=>a.id===e),s=(r.length-1)/2;return(i-s)*Ol}var Hl=({id:e,source:t,target:o,data:n,selected:r,sourcePosition:i,targetPosition:s,sourceHandleId:a,targetHandleId:l})=>{var F,z;let{zoom:c}=tg(),{updateEdgeData:d}=eg(),u=og(),{isMultipleSelection:p,mode:f,instanceId:h}=Q(),[g,m]=Ll(!1),[E,_]=Ll(null),b=kl(null),T=kl(null),N=f!=="edit",{reconnectingHandle:x,cursorPosition:w,hoveredNodeId:C,reconnectingSide:I,isValidReconnection:R,handleReconnectStart:S}=_r({edgeId:e,source:t,target:o,instanceId:h,isReadOnly:N}),D=Dl(t),X=Dl(o),{sx:Z,sy:te,tx:A,ty:M,sourcePos:$,targetPos:V}=Ci(()=>{var le,ce;let k=D&&X?Zt(D,X):{sx:0,sy:0,tx:0,ty:0,sourcePos:ao.Right,targetPos:ao.Left},J=a?i:k.sourcePos,U=l?s:k.targetPos,Y=(me,ge,ue)=>{var ut,Yt,Ut,ye,ve,Ze;let{x:ie,y:ne}=me.internals.positionAbsolute,Te=(Ut=(Yt=(ut=me.measured)==null?void 0:ut.width)!=null?Yt:me.width)!=null?Ut:0,Pe=(Ze=(ve=(ye=me.measured)==null?void 0:ye.height)!=null?ve:me.height)!=null?Ze:0;switch(ge){case ao.Top:return{x:ie+Te*ue,y:ne};case ao.Bottom:return{x:ie+Te*ue,y:ne+Pe};case ao.Left:return{x:ie,y:ne+Pe*ue};case ao.Right:return{x:ie+Te,y:ne+Pe*ue};default:return{x:ie+Te/2,y:ne+Pe/2}}},B=(le=n==null?void 0:n.sourceOffset)!=null?le:.5,W=(ce=n==null?void 0:n.targetOffset)!=null?ce:.5,q=D?Y(D,J,B).x:k.sx,j=D?Y(D,J,B).y:k.sy,se=X?Y(X,U,W).x:k.tx,ae=X?Y(X,U,W).y:k.ty;return x==="source"&&w?(q=w.x,j=w.y,I&&(J=I)):x==="target"&&w&&(se=w.x,ae=w.y,I&&(U=I)),{sx:q,sy:j,tx:se,ty:ae,sourcePos:J,targetPos:U}},[D,X,a,l,i,s,x,w,I,n==null?void 0:n.sourceOffset,n==null?void 0:n.targetOffset]);Jm(()=>{var U;if(!T.current){T.current={sx:Z,sy:te,tx:A,ty:M,sourcePos:$,targetPos:V};return}let k=T.current;(Math.abs(Z-k.sx)>Tr||Math.abs(te-k.sy)>Tr||Math.abs(A-k.tx)>Tr||Math.abs(M-k.ty)>Tr||k.sourcePos!==$||k.targetPos!==V)&&((U=n==null?void 0:n.points)!=null&&U.length)&&!x&&d(e,v(y({},n),{points:void 0})),T.current={sx:Z,sy:te,tx:A,ty:M,sourcePos:$,targetPos:V}},[Z,te,A,M,$,V,n,e,d,x]);let L=Ci(()=>{let k=rg(e,t,o,u);return Er(Z,te,A,M,$,V,n==null?void 0:n.points,k)},[Z,te,A,M,$,V,n==null?void 0:n.points,u,e,t,o]),G=Ci(()=>{if(L.length<2)return xr({x:Z,y:te},{x:A,y:M});let k=0;for(let Y=0;Y<L.length-1;Y++)k+=yr(L[Y],L[Y+1]);let J=k/2,U=0;for(let Y=0;Y<L.length-1;Y++){let B=yr(L[Y],L[Y+1]);if(U+B>=J){let W=(J-U)/B,q=L[Y],j=L[Y+1];return{x:q.x+(j.x-q.x)*W,y:q.y+(j.y-q.y)*W}}U+=B}return xr({x:Z,y:te},{x:A,y:M})},[L,Z,te,A,M]),K=Zm((k,J)=>{if(f!=="edit"||J.button!==0)return;J.stopPropagation(),J.preventDefault();let U=L[k],Y=L[k+1],B=Ii(U,Y,"y"),W=B?U.y:U.x,q=[...L],j=q.length,se=k,ae=k+1;_(k);let le=me=>{let ge=W+(B?me.clientY-J.clientY:me.clientX-J.clientX)/c;b.current=B?{x:(U.x+Y.x)/2,y:ge}:{x:ge,y:(U.y+Y.y)/2};let ue=[];for(let ie=1;ie<j-1;ie++){let ne=q[ie];ie===se||ie===ae?B?ue.push({x:ne.x,y:ge}):ue.push({x:ge,y:ne.y}):ue.push(y({},ne))}d(e,v(y({},n),{points:ue}))},ce=()=>{_(null),b.current=null,document.removeEventListener("mousemove",le),document.removeEventListener("mouseup",ce)};document.addEventListener("mousemove",le),document.addEventListener("mouseup",ce)},[f,L,c,n,e,d]);if(!D||!X)return null;let P=Ml(L),H=r||D.selected||X.selected;return _t(Vl,{children:[_t("g",{className:O("text-grey-500 hover:text-grey-600",{"text-blue-500 hover:text-blue-600":H}),onDoubleClick:()=>m(!0),children:[Ae(Qm,{id:e,path:P,markerEnd:`url(#${H?"sequence-edge-marker-highlighted":"sequence-edge-marker"})`,className:O("stroke-2 stroke-current transition-colors duration-75",{"stroke-red-500 hover:stroke-red-600":(n==null?void 0:n.hasError)||x&&C&&!R,"stroke-green-500":x&&C&&R,"stroke-blue-500 hover:stroke-blue-600 drop-shadow-[0_0_3px_rgba(59,130,246,0.5)]":H&&!(n!=null&&n.hasError)&&!x})}),r&&!p&&!N&&Ae("g",{children:L.slice(0,-1).map((k,J)=>{let U=L[J+1];if(J===0||J===L.length-2||yr(k,U)<ng)return null;let Y=Ii(k,U,"y"),B=E===J,W=B&&b.current?b.current:xr(k,U);return _t("g",{children:[Ae("line",{x1:k.x,y1:k.y,x2:U.x,y2:U.y,stroke:"transparent",strokeWidth:20/c,className:O("cursor-pointer",{"cursor-ns-resize":Y,"cursor-ew-resize":!Y}),onMouseDown:q=>K(J,q)}),Ae("circle",{cx:W.x,cy:W.y,r:4/c,fill:B?"#3b82f6":"#fff",stroke:"#3b82f6",strokeWidth:2/c,className:"pointer-events-none"}),Ae("circle",{cx:W.x,cy:W.y,r:6/c,fill:"none",stroke:"#3b82f6",strokeWidth:1/c,opacity:B?.6:.3,className:"pointer-events-none"})]},J)})})]}),_t(jm,{children:[_t("div",{className:"absolute z-[3000] pointer-events-none flex flex-col items-center gap-1",style:{transform:`translate(-50%, -50%) translate(${G.x}px, ${G.y}px)`},children:[r&&!p&&Ae(no,{sx:Z,sy:te,tx:A,ty:M,hasLabel:!!((F=n==null?void 0:n.label)!=null&&F.trim()),children:Ae(oo,{edgeId:e,edgeType:"SEQUENCE_EDGE",sourceNode:D,targetNode:X})}),(g||((z=n==null?void 0:n.label)==null?void 0:z.trim()))&&Ae(we,{value:n==null?void 0:n.label,className:O("min-w-8 max-w-56 px-2 py-1 body-small-400",{"pointer-events-auto":g,"pointer-events-none":!g}),isEditing:g,onBlur:()=>m(!1),onChange:k=>d(e,{label:k.trim()})})]}),r&&!p&&!N&&_t(Vl,{children:[Ae("div",{className:"absolute z-[10000] pointer-events-none",style:{transform:`translate(-50%, -50%) translate(${L[0].x}px, ${L[0].y}px)`},children:_t("svg",{width:12/c,height:12/c,style:{overflow:"visible",position:"absolute",left:"50%",top:"50%",transform:"translate(-50%, -50%)"},children:[Ae("circle",{cx:6/c,cy:6/c,r:4/c,fill:x==="source"?"#3b82f6":"#fff",stroke:"#3b82f6",strokeWidth:2/c,className:"pointer-events-none"}),Ae("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"}),Ae("circle",{cx:6/c,cy:6/c,r:8/c,fill:"transparent",className:O("pointer-events-auto",{"cursor-move":!x||x!=="source","cursor-not-allowed":x==="source"&&C&&!R,"cursor-grabbing":x==="source"&&(!C||R)}),onMouseDown:k=>S("source",k.nativeEvent)})]})}),Ae("div",{className:"absolute z-[10000] pointer-events-none",style:{transform:`translate(-50%, -50%) translate(${L[L.length-1].x}px, ${L[L.length-1].y}px)`},children:_t("svg",{width:12/c,height:12/c,style:{overflow:"visible",position:"absolute",left:"50%",top:"50%",transform:"translate(-50%, -50%)"},children:[Ae("circle",{cx:6/c,cy:6/c,r:4/c,fill:x==="target"?"#3b82f6":"#fff",stroke:"#3b82f6",strokeWidth:2/c,className:"pointer-events-none"}),Ae("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"}),Ae("circle",{cx:6/c,cy:6/c,r:8/c,fill:"transparent",className:O("pointer-events-auto",{"cursor-move":!x||x!=="target","cursor-not-allowed":x==="target"&&C&&!R,"cursor-grabbing":x==="target"&&(!C||R)}),onMouseDown:k=>S("target",k.nativeEvent)})]})})]})]})]})};import{Position as at}from"@xyflow/react";var ig={right:at.Right,left:at.Left,top:at.Top,bottom:at.Bottom},Nr=e=>{var t;return(t=ig[e!=null?e:""])!=null?t:at.Right},Si=(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,s=(u=(d=e.measured)==null?void 0:d.height)!=null?u:0;switch(Nr(t)){case at.Right:return{x:n+i,y:r+s*o};case at.Left:return{x:n,y:r+s*o};case at.Top:return{x:n+i*o,y:r};case at.Bottom:return{x:n+i*o,y:r+s};default:return{x:n+i/2,y:r+s/2}}},Gl=(e,t,o)=>{var d,u;let{position:{x:n,y:r},measured:i}=e,s=(d=i.width)!=null?d:0,a=(u=i.height)!=null?u:0;return[{id:"left",x:n,y:r+a/2},{id:"right",x:n+s,y:r+a/2},{id:"top",x:n+s/2,y:r},{id:"bottom",x:n+s/2,y:r+a}].reduce((p,f)=>{let h=Math.hypot(t-p.x,o-p.y);return Math.hypot(t-f.x,o-f.y)<h?f:p}).id};import{useDebouncedCallback as ty}from"use-debounce";import{getViewportForBounds as Qh,useReactFlow as jh,useStoreApi as ey}from"@xyflow/react";import{useCallback as jc}from"react";var jo=(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))(jo||{});import{xml2json as sg,json2xml as ag}from"xml-js";var Bl={compact:!0,spaces:4},lg=e=>e.replace(/\n/g,"&#xA;");function vr(e,t=Bl){if(e)return JSON.parse(sg(e,t))}function zl(e,t=Bl){return e?ag(e,v(y({},t),{attributeValueFn:lg})):""}var cg={MIN_WIDTH:36,MIN_HEIGHT:36},dg={MIN_WIDTH:36,MIN_HEIGHT:36},ug={MIN_WIDTH:56,MIN_HEIGHT:56},lo={MIN_WIDTH:176,MIN_HEIGHT:96},wr={HEADER_WIDTH:40,MIN_WIDTH:840,MIN_HEIGHT:256},pe={HEADER_WIDTH:40,MIN_WIDTH:800,MIN_HEIGHT:256},co={MIN_WIDTH:176,MIN_HEIGHT:64},pg={MIN_WIDTH:128,MIN_HEIGHT:64},oe={START_EVENT:cg,END_EVENT:dg,GATEWAY:ug,TASK:lo,LANE:pe,ANNOTATION:co,UNSUPPORTED:pg};var Fl={"attribute-loop":"LOOP"},Wl={"task-script":"SCRIPT","subprocess-collapsed":"SUBPROCESS"},Yl={"gateway-exclusive":"EXCLUSIVE","gateway-parallel":"PARALLEL","gateway-complex":"COMPLEX"},Ul={SCRIPT:"task-script",SUBPROCESS:"subprocess-collapsed"},$l={EXCLUSIVE:"gateway-exclusive",PARALLEL:"gateway-parallel",COMPLEX:"gateway-complex"};var uo=(e,t,o,n,r,i)=>{let s=e._attributes.width||0,a=e._attributes.height||0,l=0,c=0;if(n&&r!==void 0&&i!==void 0){let h=n.split(`
6
- `),g=h.length;l=h.reduce((E,_)=>Math.max(E,_.length),0)*7+r,c=g*20+i}let d=Math.max(pt(Number(s),t),l),u=Math.max(pt(Number(a),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,s={x:Number(o._attributes.x||0),y:Number(o._attributes.y||0)},a={id:n,position:s,data:{label:i||""}},l=r==="1"?void 0:r;return l&&(a.parentId=l),a},mg=e=>{let{mxGeometry:t}=e,o=po(e),n=uo(t,oe.START_EVENT.MIN_WIDTH,oe.START_EVENT.MIN_HEIGHT);return v(y(y({},o),n),{type:"START_EVENT"})},gg=e=>{let{mxGeometry:t}=e,o=po(e),n=uo(t,oe.END_EVENT.MIN_WIDTH,oe.END_EVENT.MIN_HEIGHT);return v(y(y({},o),n),{type:"END_EVENT"})},Mi=(e,t)=>{let{_attributes:o,mxGeometry:n}=e,r=po(e),a=uo(n,oe.TASK.MIN_WIDTH,oe.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=Fl[d];u&&(r.data.attribute=u)}let c=Wl[o.style];return c&&(r.data.variant=c),v(y(y({},r),a),{type:"TASK"})},Pi=e=>{let{_attributes:t,mxGeometry:o}=e,{style:n}=t,r=po(e),i=uo(o,oe.GATEWAY.MIN_WIDTH,oe.GATEWAY.MIN_HEIGHT);return r.data.variant=Yl[n],v(y(y({},r),i),{type:"GATEWAY"})},hg=e=>{let{mxGeometry:t}=e,o=po(e),i=uo(t,oe.ANNOTATION.MIN_WIDTH,oe.ANNOTATION.MIN_HEIGHT,o.data.label,32,24);return v(y(y({},o),i),{type:"ANNOTATION"})},yg=e=>{let{mxGeometry:t}=e,o=po(e),n=uo(t,oe.LANE.MIN_WIDTH,oe.LANE.MIN_HEIGHT);return v(y(y({},o),n),{type:"LANE"})},Xl={task:Mi,"task-script":Mi,"subprocess-collapsed":Mi,"start-event":mg,"end-event-terminate":gg,"gateway-parallel":Pi,"gateway-exclusive":Pi,"gateway-complex":Pi,annotation:hg,lane:yg},xg=e=>{if(e&&Array.isArray(e))return e.map(t=>({x:Number(t._attributes.x),y:Number(t._attributes.y)}))},Kl=e=>{let{_attributes:t,mxGeometry:o}=e,{id:n,source:r,target:i,value:s,style:a,sourceHandle:l,targetHandle:c,sourceOffset:d,targetOffset:u}=t,p=xg(o==null?void 0:o.Array),f=d!==void 0?Number(d):void 0,h=u!==void 0?Number(u):void 0,g=v(y(y({id:n,source:r,target:i},l?{sourceHandle:l}:{}),c?{targetHandle:c}:{}),{data:y(y(y({label:s||""},p&&p.length>0?{points:p}:{}),f!==void 0?{sourceOffset:f}:{}),h!==void 0?{targetOffset:h}:{})});return a.includes("association")&&a.includes('endArrow=""')?y(y({},ro),g):y(y({},Be),g)},ql=(e,t)=>{let{id:o,type:n,source:r,target:i,sourceHandle:s,targetHandle:a,data:l}=e,c=t==null?void 0:t.find(f=>f.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(f=>({_attributes:{as:"mxPoint",x:f.x,y:f.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:s!=null?s:void 0,targetHandle:a!=null?a: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}},fo=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}}}},Eg=e=>{let{variant:t}=e.data,o=fo(e);return v(y({},o),{_attributes:v(y({},o._attributes),{style:Ul[t]||"task"})})},bg=e=>{let t=fo(e);return v(y({},t),{_attributes:v(y({},t._attributes),{style:"start-event"})})},_g=e=>{let t=fo(e);return v(y({},t),{_attributes:v(y({},t._attributes),{style:"end-event-terminate"})})},Tg=e=>{let{variant:t}=e.data,o=fo(e);return v(y({},o),{_attributes:v(y({},o._attributes),{style:$l[t]})})},Ng=e=>{let t=fo(e);return v(y({},t),{_attributes:v(y({},t._attributes),{style:"lane"})})},vg=e=>{let t=fo(e);return v(y({},t),{_attributes:v(y({},t._attributes),{style:"annotation"})})},Zl={TASK:Eg,START_EVENT:bg,END_EVENT:_g,GATEWAY:Tg,ANNOTATION:vg,LANE:Ng},Jl=(e,t)=>{var s,a;let r=((s=e.measured)==null?void 0:s.width)||0,i=((a=e.measured)==null?void 0:a.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 oc from"@dagrejs/dagre";import{getNodesBounds as Cg}from"@xyflow/react";import{orderBy as Sg}from"lodash";import{orderBy as wg}from"lodash";var lt=e=>{var t,o,n,r,i,s,a,l;return{x:(o=(t=e.internals)==null?void 0:t.positionAbsolute.x)!=null?o:0,y:(r=(n=e.internals)==null?void 0:n.positionAbsolute.y)!=null?r:0,w:(s=(i=e.measured)==null?void 0:i.width)!=null?s:0,h:(l=(a=e.measured)==null?void 0:a.height)!=null?l:0}},Ot=e=>wg(e,[o=>{let n=o.type==="LANE";return n&&!o.parentId?0:n?1:2}],["asc"]),Ql=(e,t)=>{let{x:o,y:n}=lt(e),{x:r,y:i}=lt(t);return{x:o-r,y:n-i}};var mo=({parentId:e,nodes:t,includeTypes:o=[...Object.values(ee)],excludeTypes:n=[]})=>t.some(r=>r.parentId===e&&(!o.length||o.includes(r.type))&&!n.includes(r.type)),Ag=(e,t)=>{let{x:o,y:n}=lt(e),{x:r,y:i}=lt(t),s=o-r,a=n-i;return Math.sqrt(s*s+a*a)},Ig=(e,t)=>{let{x:o,y:n,w:r,h:i}=lt(e),{x:s,y:a,w:l,h:c}=lt(t),d=o+r/2,u=n+i/2;return d>=s&&d<=s+l&&u>=a&&u<=a+c},en=(e,t)=>{let o=null,n=1/0;for(let r of t)if(r.id!==e.id&&Ig(e,r)){let i=Ag(e,r);i<n&&(n=i,o=r)}return o},jl=(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),ec=(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)),s=Math.min(...r.map(c=>c.position.y||0)),a=e.map(c=>c.parentId?c:v(y({},c),{position:{x:c.position.x-i,y:c.position.y-s}})),l=t.map(c=>{let d=c.data;return d!=null&&d.points?v(y({},c),{data:v(y({},d),{points:d.points.map(u=>({x:u.x-i,y:u.y-s}))})}):c});return{nodes:a,edges:l}},tc=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,s=-1/0,a=-1/0;for(let d of n){let u=d.position.x+((l=d.width)!=null?l:0),p=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>s&&(s=u),p>a&&(a=p)}return{x:r,y:i,width:s-r,height:a-i}};var nc=(e=[],t=[],o="LR")=>{let n=new oc.graphlib.Graph;return n.setDefaultEdgeLabel(()=>({})),n.setGraph({rankdir:o}),e.forEach(({id:i,width:s,height:a})=>n.setNode(i,{width:s,height:a})),t.forEach(i=>n.setEdge(i.source,i.target)),oc.layout(n),{nodes:e.map(i=>{let s=n.node(i.id);return v(y({},i),{position:{x:s.x-i.width/2,y:s.y-i.height/2}})}),edges:t}},tn=e=>{let t=e.filter(n=>n.type==="LANE"&&!n.parentId),o=[...e];return t.forEach(n=>{o=on(n.id,o)}),o},on=(e,t)=>{var f,h;let o=[...t],n=o.find(g=>g.id===e);if(!n)return o;let r=o.filter(g=>g.parentId===e&&g.type==="LANE");if(r.length===0)return o;let i=Sg(r,["position.y"]),s=Math.max((h=(f=n.measured)==null?void 0:f.width)!=null?h:0,wr.MIN_WIDTH),a=jl(e,i)||pe.MIN_WIDTH,l=Math.max(s,a),c=s-pe.HEADER_WIDTH>=a,d=0,u=0;i.forEach(g=>{var m,E,_,b;o=o.map(T=>T.id===g.id?v(y({},T),{width:c?l-pe.HEADER_WIDTH:l,measured:v(y({},T.measured),{width:c?l-pe.HEADER_WIDTH:l}),position:{x:pe.HEADER_WIDTH,y:d}}):T),d+=(E=(m=g.measured)==null?void 0:m.height)!=null?E:0,u+=(b=(_=g.measured)==null?void 0:_.height)!=null?b:0}),o=o.map(g=>g.id===e?v(y({},g),{height:u,width:c?l:l+pe.HEADER_WIDTH,measured:v(y({},g.measured),{height:u,width:c?l:l+pe.HEADER_WIDTH})}):g);let p=o.find(g=>g.id===e);return p!=null&&p.parentId&&(o=on(p.parentId,o)),o},rc=(e,t,o)=>{if(e.type==="LANE")return o;let n=st(t),r=st(e);return r.y<n.y&&(e.position.y=0),r.x<n.x+pe.HEADER_WIDTH&&(e.position.x=pe.HEADER_WIDTH),r.y2>n.y2&&(t.height=r.y2-n.y,t.measured.height=r.y2-n.y),r.x2>n.x2&&(t.width=r.x2-n.x,t.measured.width=r.x2-n.x),o=o.map(i=>i.id===t.id?v(y({},i),{height:t.height,width:t.width,measured:t.measured}):i.id===e.id?v(y({},i),{position:e.position}):i),o},ic=()=>{let e=document.querySelector(".react-flow__viewport");return e||(console.error("Flow element (.react-flow__viewport) not found."),null)},Mg=50,sc=(e,t=Mg)=>{let o=Cg(e);return{x:o.x-t,y:o.y-t,width:o.width+t*2,height:o.height+t*2}};var nn=1,ac=e=>`<mxGraphModel>
5
+ `).trim();t&&N.length>t&&(N=N.substring(0,t)),T.currentTarget.innerText=N,s==null||s(),N!==e&&(a==null||a(N))};return Ml("div",{className:O("flex-1 p-2 self-stretch flex items-center justify-center border border-transparent overflow-hidden text-ellipsis body-medium-400 text-center rounded-sm",{"border border-dashed border-grey-400 bg-white shadow-md":f,"bg-white":e.length>0},n),style:o,onDoubleClick:h,children:Ml("div",{ref:d,className:O("outline-none whitespace-pre-wrap overflow-hidden",r,{"nodrag nopan cursor-text":f}),contentEditable:f,suppressContentEditableWarning:!0,onKeyDown:m,onPaste:E,onInput:y,onBlur:x,children:e})})};import{Position as b2}from"@xyflow/react";var ae=(e,t,o,n=1)=>Math.abs(e[o]-t[o])<n,yr=(e,t)=>Math.sqrt((t.x-e.x)**2+(t.y-e.y)**2),xr=(e,t)=>({x:(e.x+t.x)/2,y:(e.y+t.y)/2});import{Position as Er}from"@xyflow/react";var Nt={OFFSET:30,TOLERANCE:1,MOVE_THRESHOLD:5,MIN_SEGMENT_LENGTH:15,PARALLEL_OFFSET:15};var{TOLERANCE:oe}=Nt;function Km(e,t,o){return ae(e,t,"x",oe)&&ae(t,o,"x",oe)&&ae(e,o,"x",oe)}function qm(e,t,o){return ae(e,t,"y",oe)&&ae(t,o,"y",oe)&&ae(e,o,"y",oe)}function Zm(e,t,o){if(!Km(e,t,o))return!1;let n=t.y-e.y,r=o.y-t.y;return Math.abs(n)<oe||Math.abs(r)<oe?!1:n*r<0}function Jm(e,t,o){if(!qm(e,t,o))return!1;let n=t.x-e.x,r=o.x-t.x;return Math.abs(n)<oe||Math.abs(r)<oe?!1:n*r<0}function Qm(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 Pl(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];ae(n,r,"x",oe)&&ae(r,i,"x",oe)||ae(n,r,"y",oe)&&ae(r,i,"y",oe)||t.push(r)}return t.push(e[e.length-1]),t}function br(e){let t=[];for(let o of e){let n=t[t.length-1];(!n||Math.abs(n.x-o.x)>=oe||Math.abs(n.y-o.y)>=oe)&&t.push(o)}return t}function jm(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(Zm(r,i,a)||Jm(r,i,a)){t.splice(n,1),o=!0;break}}}return t}function Ll(e){let t=br(Pl([...e]));return t=jm(t),br(Pl(t))}function _r(e){switch(e){case Er.Left:return{x:-1,y:0};case Er.Right:return{x:1,y:0};case Er.Top:return{x:0,y:-1};case Er.Bottom:return{x:0,y:1};default:return{x:0,y:0}}}function kl(e,t,o,n){let r=Nt.OFFSET,i=Nt.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*Nt.OFFSET&&(r=a/2,i=a/2)}else{let a=(o.y-e.y)*t.y;a>0&&a<2*Nt.OFFSET&&(r=a/2,i=a/2)}return{sourceOffset:r,targetOffset:i}}function eg(e,t,o,n,r,i,a=0){let s=_r(r),l=_r(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},g={x:o+u,y:n+f},{sourceOffset:h,targetOffset:m}=kl(p,s,g,l),E={x:p.x+s.x*h,y:p.y+s.y*h},y={x:g.x+l.x*m,y:g.y+l.y*m},x=Qm(E,s,y,l),T=[p,E,...x,y,g],N=Ll(T);if(N.length===2&&Tr(p,g)>oe){let b=ae(p,E,"x",oe)&&ae(E,y,"x",oe)&&ae(y,g,"x",oe),w=ae(p,E,"y",oe)&&ae(E,y,"y",oe)&&ae(y,g,"y",oe);if(b||w){let C=w&&(y.x-E.x)*s.x<0,I=b&&(y.y-E.y)*s.y<0;if(!C&&!I)return br([p,E,y,g])}}return N}function Nr(e,t,o,n,r,i,a,s=0){if(!(a!=null&&a.length))return eg(e,t,o,n,r,i,s);let l=_r(r),c=_r(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,g={x:e+d,y:t+u},h={x:o+f,y:n+p},{sourceOffset:m,targetOffset:E}=kl(g,l,h,c),y={x:g.x+l.x*m,y:g.y+l.y*m},x={x:h.x+c.x*E,y:h.y+c.y*E},T=[...a],N=T[0],b=l.y===0;b&&Math.abs(g.y-N.y)>oe?T.unshift({x:N.x,y:g.y}):!b&&Math.abs(g.x-N.x)>oe&&T.unshift({x:g.x,y:N.y});let w=T[T.length-1],C=c.y===0,I=[];(Math.abs(w.x-x.x)>oe||Math.abs(w.y-x.y)>oe)&&(C?I.push({x:x.x,y:w.y}):I.push({x:w.x,y:x.y})),I.push(x);let k=[g,...T,...I,h],S=Ll(k);if(S.length===2&&Tr(g,h)>oe){let R=ae(g,y,"x",oe)&&ae(y,x,"x",oe)&&ae(x,h,"x",oe),U=ae(g,y,"y",oe)&&ae(y,x,"y",oe)&&ae(x,h,"y",oe);if(R||U){let K=U&&(x.x-y.x)*l.x<0,ee=R&&(x.y-y.y)*l.y<0;if(!K&&!ee)return br([g,y,x,h])}}return S}var Tr=(e,t)=>Math.sqrt(Math.pow(t.x-e.x,2)+Math.pow(t.y-e.y,2));function tg(e,t,o){return ae(e,t,"x",oe)&&ae(t,o,"x",oe)||ae(e,t,"y",oe)&&ae(t,o,"y",oe)}function og(e,t,o,n){if(tg(e,t,o))return`L${t.x} ${t.y}`;let r=Tr(e,t),i=Tr(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},g={x:t.x+f.x*a,y:t.y+f.y*a},h=-u.x,m=-u.y,E=f.x,y=f.y,T=h*y-m*E>0?1:0;return`L${p.x} ${p.y}A${a} ${a} 0 0 ${T} ${g.x} ${g.y}`}var Rl=(e,t=5)=>e.length<2?"":e.reduce((o,n,r)=>{let i="";return r>0&&r<e.length-1?i=og(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 vr,useRef as jo,useState as co}from"react";import{useReactFlow as ng,useStore as rg}from"@xyflow/react";var ig=50,Dl=.1,sg=.6,wr=({edgeId:e,source:t,target:o,instanceId:n,isReadOnly:r})=>{let{setEdges:i,getNode:a,getNodes:s,getEdge:l,screenToFlowPosition:c}=ng(),{setIsDragging:d,setReconnectingEdgeId:u}=Q(),f=rg(L=>L.isValidConnection),[p,g]=co(null),[h,m]=co(null),[E,y]=co(null),[x,T]=co(null),[N,b]=co(null),[w,C]=co(!1),I=jo(null),k=jo(null),S=jo(null),R=jo(t),U=jo(o);vr(()=>{R.current=t,U.current=o},[t,o]),vr(()=>{I.current=p},[p]),vr(()=>{k.current=N},[N]);let K=lo(L=>{let G=s(),q=G.find(z=>z.id===L);if(!q)return{x:0,y:0};let P=q.position.x,H=q.position.y,Y=q.parentId;for(;Y;){let z=G.find(D=>D.id===Y);if(!z)break;P+=z.position.x,H+=z.position.y,Y=z.parentId}return{x:P,y:H}},[s]),ee=lo(L=>{var Y,z,D,J,X,W;let G=s(),q=null,P=ig,H=G.filter(B=>B.type!=="LANE"&&B.type!=="ANNOTATION");for(let B of H){if(B.id===e)continue;let F=K(B.id),Z=(D=(z=(Y=B.measured)==null?void 0:Y.width)!=null?z:B.width)!=null?D:0,j=(W=(X=(J=B.measured)==null?void 0:J.height)!=null?X:B.height)!=null?W:0;if(L.x>=F.x&&L.x<=F.x+Z&&L.y>=F.y&&L.y<=F.y+j)return B.id;let ce=Math.max(F.x-L.x,0,L.x-(F.x+Z)),de=Math.max(F.y-L.y,0,L.y-(F.y+j)),ue=Math.sqrt(ce*ce+de*de);ue<P&&(P=ue,q=B.id)}return q},[s,K,e]),A=lo((L,G)=>{var ce,de,ue,he,ye,fe;let q=a(L);if(!q)return null;let P=K(L),H=(ue=(de=(ce=q.measured)==null?void 0:ce.width)!=null?de:q.width)!=null?ue:0,Y=(fe=(ye=(he=q.measured)==null?void 0:he.height)!=null?ye:q.height)!=null?fe:0,z=Math.abs(P.x+H-G.x),D=Math.abs(G.x-P.x),J=Math.abs(P.y+Y-G.y),X=Math.abs(G.y-P.y),W={right:z,left:D,bottom:J,top:X},B=Object.entries(W).reduce((se,[re,ve])=>ve<se[1]?[re,ve]:se,["right",W.right])[0],F=S.current;if(F&&F!==B){let se=W[B],re=W[F],ve=Math.abs(re-se),ke=Math.min(Math.abs(re),Math.abs(se));ve<ke*sg&&(B=F)}let Z=B,j,le;if(Z==="right"||Z==="left"){let re=(Math.max(P.y,Math.min(P.y+Y,G.y))-P.y)/(Y||1);Math.abs(re-.5)<Dl&&(re=.5),le=re,j={x:Z==="right"?P.x+H:P.x,y:P.y+le*Y}}else{let re=(Math.max(P.x,Math.min(P.x+H,G.x))-P.x)/(H||1);Math.abs(re-.5)<Dl&&(re=.5),le=re,j={x:P.x+le*H,y:Z==="bottom"?P.y+Y:P.y}}return{side:Z,snapPosition:j,offset:le}},[a,K]),M=lo(L=>{var D,J,X;let G=I.current;if(!G)return;let q=c({x:L.clientX,y:L.clientY}),P=ee(q);y(P);let H=q,Y=null,z=null;if(P){let W=A(P,q);W&&(Y=W.side,H=W.snapPosition,z=W.offset,S.current=Y);let B=l(e),F={source:G==="source"?P:R.current,target:G==="target"?P:U.current,sourceHandle:G==="source"?Y:(D=B==null?void 0:B.sourceHandle)!=null?D:null,targetHandle:G==="target"?Y:(J=B==null?void 0:B.targetHandle)!=null?J:null},Z=(X=f==null?void 0:f(F))!=null?X:!0;C(Z)}else S.current=null,C(!1);T(Y),b(z),m(H)},[ee,A,l,e,c,f]),$=lo(L=>{var Y,z,D,J,X;let G=I.current;if(!G)return;let q=c({x:L.clientX,y:L.clientY}),P=ee(q);if(P){let W=A(P,q),B=(Y=W==null?void 0:W.side)!=null?Y:null,F=(z=W==null?void 0:W.offset)!=null?z:.5,Z=l(e),j={source:G==="source"?P:R.current,target:G==="target"?P:U.current,sourceHandle:G==="source"?B:(D=Z==null?void 0:Z.sourceHandle)!=null?D:null,targetHandle:G==="target"?B:(J=Z==null?void 0:Z.targetHandle)!=null?J:null};((X=f==null?void 0:f(j))==null||X)&&i(le=>le.map(ce=>{var de,ue;return ce.id===e?v(_({},ce),{source:j.source,target:j.target,sourceHandle:j.sourceHandle,targetHandle:j.targetHandle,data:v(_({},ce.data),{points:void 0,sourceOffset:G==="source"?F:(de=ce.data)==null?void 0:de.sourceOffset,targetOffset:G==="target"?F:(ue=ce.data)==null?void 0:ue.targetOffset})}):ce}))}g(null),m(null),y(null),T(null),b(null),d(!1),C(!1),u(null),S.current=null,document.removeEventListener("mouseup",$),document.removeEventListener("mousemove",M);let H=nt.get(n);H==null||H.clearReconnectingEdge()},[e,ee,A,l,i,n,M,f,c,d,u]),V=lo((L,G)=>{if(r||G.button!==0)return;G.stopPropagation(),G.preventDefault(),i(P=>P.map(H=>H.id===e?v(_({},H),{data:v(_({},H.data),{points:void 0})}):H)),g(L),u(e);let q=nt.get(n);q==null||q.setReconnectingEdge(e),document.addEventListener("mousemove",M),document.addEventListener("mouseup",$)},[r,e,n,M,$,u,i]);return vr(()=>()=>{if(I.current){document.removeEventListener("mousemove",M),document.removeEventListener("mouseup",$),u(null);let L=nt.get(n);L==null||L.clearReconnectingEdge()}},[n,M,$,u]),{reconnectingHandle:p,cursorPosition:h,hoveredNodeId:E,reconnectingSide:x,reconnectingOffset:N,isValidReconnection:w,handleReconnectStart:V}};import{Fragment as zl,jsx as Ce,jsxs as vt}from"react/jsx-runtime";var Ye={type:"SEQUENCE_EDGE",reconnectable:!0,markerStart:{type:Hl.ArrowClosed},markerEnd:{type:Hl.Arrow},data:{label:""}},{MOVE_THRESHOLD:Ar,MIN_SEGMENT_LENGTH:mg,PARALLEL_OFFSET:Bl}=Nt;function gg(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)*Bl}let i=r.findIndex(s=>s.id===e),a=(r.length-1)/2;return(i-a)*Bl}var Yl=({id:e,source:t,target:o,data:n,selected:r,sourcePosition:i,targetPosition:a,sourceHandleId:s,targetHandleId:l})=>{var Y,z;let{zoom:c}=pg(),{updateEdgeData:d}=ug(),u=fg(),{isMultipleSelection:f,mode:p,instanceId:g}=Q(),[h,m]=Ol(!1),[E,y]=Ol(null),x=Vl(null),T=Vl(null),N=p!=="edit",{reconnectingHandle:b,cursorPosition:w,hoveredNodeId:C,reconnectingSide:I,isValidReconnection:k,handleReconnectStart:S}=wr({edgeId:e,source:t,target:o,instanceId:g,isReadOnly:N}),R=Gl(t),U=Gl(o),{sx:K,sy:ee,tx:A,ty:M,sourcePos:$,targetPos:V}=Mi(()=>{var de,ue;let D=R&&U?jt(R,U):{sx:0,sy:0,tx:0,ty:0,sourcePos:uo.Right,targetPos:uo.Left},J=s?i:D.sourcePos,X=l?a:D.targetPos,W=(he,ye,fe)=>{var ft,$t,Kt,Ee,Ae,Qe;let{x:se,y:re}=he.internals.positionAbsolute,ve=(Kt=($t=(ft=he.measured)==null?void 0:ft.width)!=null?$t:he.width)!=null?Kt:0,ke=(Qe=(Ae=(Ee=he.measured)==null?void 0:Ee.height)!=null?Ae:he.height)!=null?Qe:0;switch(ye){case uo.Top:return{x:se+ve*fe,y:re};case uo.Bottom:return{x:se+ve*fe,y:re+ke};case uo.Left:return{x:se,y:re+ke*fe};case uo.Right:return{x:se+ve,y:re+ke*fe};default:return{x:se+ve/2,y:re+ke/2}}},B=(de=n==null?void 0:n.sourceOffset)!=null?de:.5,F=(ue=n==null?void 0:n.targetOffset)!=null?ue:.5,Z=R?W(R,J,B).x:D.sx,j=R?W(R,J,B).y:D.sy,le=U?W(U,X,F).x:D.tx,ce=U?W(U,X,F).y:D.ty;return b==="source"&&w?(Z=w.x,j=w.y,I&&(J=I)):b==="target"&&w&&(le=w.x,ce=w.y,I&&(X=I)),{sx:Z,sy:j,tx:le,ty:ce,sourcePos:J,targetPos:X}},[R,U,s,l,i,a,b,w,I,n==null?void 0:n.sourceOffset,n==null?void 0:n.targetOffset]);lg(()=>{var X;if(!T.current){T.current={sx:K,sy:ee,tx:A,ty:M,sourcePos:$,targetPos:V};return}let D=T.current;(Math.abs(K-D.sx)>Ar||Math.abs(ee-D.sy)>Ar||Math.abs(A-D.tx)>Ar||Math.abs(M-D.ty)>Ar||D.sourcePos!==$||D.targetPos!==V)&&((X=n==null?void 0:n.points)!=null&&X.length)&&d(e,v(_({},n),{points:void 0})),T.current={sx:K,sy:ee,tx:A,ty:M,sourcePos:$,targetPos:V}},[K,ee,A,M,$,V,n,e,d,b]);let L=Mi(()=>{let D=gg(e,t,o,u);return Nr(K,ee,A,M,$,V,n==null?void 0:n.points,D)},[K,ee,A,M,$,V,n==null?void 0:n.points,u,e,t,o]),G=Mi(()=>{if(L.length<2)return xr({x:K,y:ee},{x:A,y:M});let D=0;for(let W=0;W<L.length-1;W++)D+=yr(L[W],L[W+1]);let J=D/2,X=0;for(let W=0;W<L.length-1;W++){let B=yr(L[W],L[W+1]);if(X+B>=J){let F=(J-X)/B,Z=L[W],j=L[W+1];return{x:Z.x+(j.x-Z.x)*F,y:Z.y+(j.y-Z.y)*F}}X+=B}return xr({x:K,y:ee},{x:A,y:M})},[L,K,ee,A,M]),q=ag((D,J)=>{if(p!=="edit"||J.button!==0)return;J.stopPropagation(),J.preventDefault();let X=L[D],W=L[D+1],B=ae(X,W,"y"),F=B?X.y:X.x,Z=[...L],j=Z.length,le=D,ce=D+1;y(D);let de=he=>{let ye=F+(B?he.clientY-J.clientY:he.clientX-J.clientX)/c;x.current=B?{x:(X.x+W.x)/2,y:ye}:{x:ye,y:(X.y+W.y)/2};let fe=[];for(let se=1;se<j-1;se++){let re=Z[se];se===le||se===ce?B?fe.push({x:re.x,y:ye}):fe.push({x:ye,y:re.y}):fe.push(_({},re))}d(e,v(_({},n),{points:fe}))},ue=()=>{y(null),x.current=null,document.removeEventListener("mousemove",de),document.removeEventListener("mouseup",ue)};document.addEventListener("mousemove",de),document.addEventListener("mouseup",ue)},[p,L,c,n,e,d]);if(!R||!U)return null;let P=Rl(L),H=r||R.selected||U.selected;return vt(zl,{children:[vt("g",{className:O("text-grey-500 hover:text-grey-600",{"text-blue-500 hover:text-blue-600":H}),onDoubleClick:()=>m(!0),children:[Ce(cg,{id:e,path:P,markerEnd:`url(#${H?"sequence-edge-marker-highlighted":"sequence-edge-marker"})`,className:O("stroke-2 stroke-current transition-colors duration-75",{"stroke-red-500 hover:stroke-red-600":(n==null?void 0:n.hasError)||b&&C&&!k,"stroke-green-500":b&&C&&k,"stroke-blue-500 hover:stroke-blue-600 drop-shadow-[0_0_3px_rgba(59,130,246,0.5)]":H&&!(n!=null&&n.hasError)&&!b})}),r&&!f&&!N&&Ce("g",{children:L.slice(0,-1).map((D,J)=>{let X=L[J+1];if(J===0||J===L.length-2||yr(D,X)<mg)return null;let W=ae(D,X,"y"),B=E===J,F=B&&x.current?x.current:xr(D,X);return vt("g",{children:[Ce("line",{x1:D.x,y1:D.y,x2:X.x,y2:X.y,stroke:"transparent",strokeWidth:20/c,className:O("cursor-pointer",{"cursor-ns-resize":W,"cursor-ew-resize":!W}),onMouseDown:Z=>q(J,Z)}),Ce("circle",{cx:F.x,cy:F.y,r:4/c,fill:B?"#3b82f6":"#fff",stroke:"#3b82f6",strokeWidth:2/c,className:"pointer-events-none"}),Ce("circle",{cx:F.x,cy:F.y,r:6/c,fill:"none",stroke:"#3b82f6",strokeWidth:1/c,opacity:B?.6:.3,className:"pointer-events-none"})]},J)})})]}),vt(dg,{children:[vt("div",{className:"absolute z-[3000] pointer-events-none flex flex-col items-center gap-1",style:{transform:`translate(-50%, -50%) translate(${G.x}px, ${G.y}px)`},children:[r&&!f&&Ce(so,{sx:K,sy:ee,tx:A,ty:M,hasLabel:!!((Y=n==null?void 0:n.label)!=null&&Y.trim()),children:Ce(io,{edgeId:e,edgeType:"SEQUENCE_EDGE",sourceNode:R,targetNode:U})}),(h||((z=n==null?void 0:n.label)==null?void 0:z.trim()))&&Ce(Ie,{value:n==null?void 0:n.label,className:O("min-w-8 max-w-56 px-2 py-1 body-small-400",{"pointer-events-auto":h,"pointer-events-none":!h}),isEditing:h,onBlur:()=>m(!1),onChange:D=>d(e,{label:D.trim()})})]}),r&&!f&&!N&&vt(zl,{children:[Ce("div",{className:"absolute z-[10000] pointer-events-none",style:{transform:`translate(-50%, -50%) translate(${L[0].x}px, ${L[0].y}px)`},children:vt("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:b==="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:b==="source"?.6:.3,className:"pointer-events-none"}),Ce("circle",{cx:6/c,cy:6/c,r:8/c,fill:"transparent",className:O("pointer-events-auto",{"cursor-move":!b||b!=="source","cursor-not-allowed":b==="source"&&C&&!k,"cursor-grabbing":b==="source"&&(!C||k)}),onMouseDown:D=>S("source",D.nativeEvent)})]})}),Ce("div",{className:"absolute z-[10000] pointer-events-none",style:{transform:`translate(-50%, -50%) translate(${L[L.length-1].x}px, ${L[L.length-1].y}px)`},children:vt("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:b==="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:b==="target"?.6:.3,className:"pointer-events-none"}),Ce("circle",{cx:6/c,cy:6/c,r:8/c,fill:"transparent",className:O("pointer-events-auto",{"cursor-move":!b||b!=="target","cursor-not-allowed":b==="target"&&C&&!k,"cursor-grabbing":b==="target"&&(!C||k)}),onMouseDown:D=>S("target",D.nativeEvent)})]})})]})]})]})};import{Position as ct}from"@xyflow/react";var hg={right:ct.Right,left:ct.Left,top:ct.Top,bottom:ct.Bottom},Ir=e=>{var t;return(t=hg[e!=null?e:""])!=null?t:ct.Right},Pi=(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(Ir(t)){case ct.Right:return{x:n+i,y:r+a*o};case ct.Left:return{x:n,y:r+a*o};case ct.Top:return{x:n+i*o,y:r};case ct.Bottom:return{x:n+i*o,y:r+a};default:return{x:n+i/2,y:r+a/2}}},Fl=(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 g=Math.hypot(t-f.x,o-f.y);return Math.hypot(t-p.x,o-p.y)<g?p:f}).id};import{useDebouncedCallback as py}from"use-debounce";import{getViewportForBounds as cy,useReactFlow as dy,useStoreApi as uy}from"@xyflow/react";import{useCallback as nd}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 yg,json2xml as xg}from"xml-js";var Wl={compact:!0,spaces:4},Eg=e=>e.replace(/\n/g,"&#xA;");function Cr(e,t=Wl){if(e)return JSON.parse(yg(e,t))}function Xl(e,t=Wl){return e?xg(e,v(_({},t),{attributeValueFn:Eg})):""}var bg={MIN_WIDTH:36,MIN_HEIGHT:36},_g={MIN_WIDTH:36,MIN_HEIGHT:36},Tg={MIN_WIDTH:56,MIN_HEIGHT:56},po={MIN_WIDTH:176,MIN_HEIGHT:96},Sr={HEADER_WIDTH:40,MIN_WIDTH:840,MIN_HEIGHT:256},me={HEADER_WIDTH:40,MIN_WIDTH:800,MIN_HEIGHT:256},fo={MIN_WIDTH:176,MIN_HEIGHT:64},Ng={MIN_WIDTH:128,MIN_HEIGHT:64},ne={START_EVENT:bg,END_EVENT:_g,GATEWAY:Tg,TASK:po,LANE:me,ANNOTATION:fo,UNSUPPORTED:Ng};var Ul={"attribute-loop":"LOOP"},$l={"task-script":"SCRIPT","subprocess-collapsed":"SUBPROCESS"},Kl={"gateway-exclusive":"EXCLUSIVE","gateway-parallel":"PARALLEL","gateway-complex":"COMPLEX"},ql={SCRIPT:"task-script",SUBPROCESS:"subprocess-collapsed"},Zl={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 g=n.split(`
6
+ `),h=g.length;l=g.reduce((E,y)=>Math.max(E,y.length),0)*7+r,c=h*20+i}let d=Math.max(mt(Number(a),t),l),u=Math.max(mt(Number(s),o),c);return{width:d,height:u,measured:{width:d,height:u}}},go=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},wg=e=>{let{mxGeometry:t}=e,o=go(e),n=mo(t,ne.START_EVENT.MIN_WIDTH,ne.START_EVENT.MIN_HEIGHT);return v(_(_({},o),n),{type:"START_EVENT"})},Ag=e=>{let{mxGeometry:t}=e,o=go(e),n=mo(t,ne.END_EVENT.MIN_WIDTH,ne.END_EVENT.MIN_HEIGHT);return v(_(_({},o),n),{type:"END_EVENT"})},Li=(e,t)=>{let{_attributes:o,mxGeometry:n}=e,r=go(e),s=mo(n,ne.TASK.MIN_WIDTH,ne.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=Ul[d];u&&(r.data.attribute=u)}let c=$l[o.style];return c&&(r.data.variant=c),v(_(_({},r),s),{type:"TASK"})},ki=e=>{let{_attributes:t,mxGeometry:o}=e,{style:n}=t,r=go(e),i=mo(o,ne.GATEWAY.MIN_WIDTH,ne.GATEWAY.MIN_HEIGHT);return r.data.variant=Kl[n],v(_(_({},r),i),{type:"GATEWAY"})},Ig=e=>{let{mxGeometry:t}=e,o=go(e),i=mo(t,ne.ANNOTATION.MIN_WIDTH,ne.ANNOTATION.MIN_HEIGHT,o.data.label,32,24);return v(_(_({},o),i),{type:"ANNOTATION"})},Cg=e=>{let{mxGeometry:t}=e,o=go(e),n=mo(t,ne.LANE.MIN_WIDTH,ne.LANE.MIN_HEIGHT);return v(_(_({},o),n),{type:"LANE"})},Jl={task:Li,"task-script":Li,"subprocess-collapsed":Li,"start-event":wg,"end-event-terminate":Ag,"gateway-parallel":ki,"gateway-exclusive":ki,"gateway-complex":ki,annotation:Ig,lane:Cg},Sg=e=>{if(e&&Array.isArray(e))return e.map(t=>({x:Number(t._attributes.x),y:Number(t._attributes.y)}))},Ql=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=Sg(o==null?void 0:o.Array),p=d!==void 0?Number(d):void 0,g=u!==void 0?Number(u):void 0,h=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}:{}),g!==void 0?{targetOffset:g}:{})});return s.includes("association")&&s.includes('endArrow=""')?_(_({},ao),h):_(_({},Ye),h)},jl=(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}},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}}}},Mg=e=>{let{variant:t}=e.data,o=ho(e);return v(_({},o),{_attributes:v(_({},o._attributes),{style:ql[t]||"task"})})},Pg=e=>{let t=ho(e);return v(_({},t),{_attributes:v(_({},t._attributes),{style:"start-event"})})},Lg=e=>{let t=ho(e);return v(_({},t),{_attributes:v(_({},t._attributes),{style:"end-event-terminate"})})},kg=e=>{let{variant:t}=e.data,o=ho(e);return v(_({},o),{_attributes:v(_({},o._attributes),{style:Zl[t]})})},Rg=e=>{let t=ho(e);return v(_({},t),{_attributes:v(_({},t._attributes),{style:"lane"})})},Dg=e=>{let t=ho(e);return v(_({},t),{_attributes:v(_({},t._attributes),{style:"annotation"})})},ec={TASK:Mg,START_EVENT:Pg,END_EVENT:Lg,GATEWAY:kg,ANNOTATION:Dg,LANE:Rg},tc=(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 sc from"@dagrejs/dagre";import{getNodesBounds as Gg}from"@xyflow/react";import{orderBy as Bg}from"lodash";import{orderBy as Og}from"lodash";var dt=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}},Gt=e=>Og(e,[o=>{let n=o.type==="LANE";return n&&!o.parentId?0:n?1:2}],["asc"]),oc=(e,t)=>{let{x:o,y:n}=dt(e),{x:r,y:i}=dt(t);return{x:o-r,y:n-i}};var yo=({parentId:e,nodes:t,includeTypes:o=[...Object.values(te)],excludeTypes:n=[]})=>t.some(r=>r.parentId===e&&(!o.length||o.includes(r.type))&&!n.includes(r.type)),Vg=(e,t)=>{let{x:o,y:n}=dt(e),{x:r,y:i}=dt(t),a=o-r,s=n-i;return Math.sqrt(a*a+s*s)},Hg=(e,t)=>{let{x:o,y:n,w:r,h:i}=dt(e),{x:a,y:s,w:l,h:c}=dt(t),d=o+r/2,u=n+i/2;return d>=a&&d<=a+l&&u>=s&&u<=s+c},tn=(e,t)=>{let o=null,n=1/0;for(let r of t)if(r.id!==e.id&&Hg(e,r)){let i=Vg(e,r);i<n&&(n=i,o=r)}return o},nc=(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),rc=(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}},ic=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 ac=(e=[],t=[],o="LR")=>{let n=new sc.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)),sc.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}},on=e=>{let t=e.filter(n=>n.type==="LANE"&&!n.parentId),o=[...e];return t.forEach(n=>{o=nn(n.id,o)}),o},nn=(e,t)=>{var p,g;let o=[...t],n=o.find(h=>h.id===e);if(!n)return o;let r=o.filter(h=>h.parentId===e&&h.type==="LANE");if(r.length===0)return o;let i=Bg(r,["position.y"]),a=Math.max((g=(p=n.measured)==null?void 0:p.width)!=null?g:0,Sr.MIN_WIDTH),s=nc(e,i)||me.MIN_WIDTH,l=Math.max(a,s),c=a-me.HEADER_WIDTH>=s,d=0,u=0;i.forEach(h=>{var m,E,y,x;o=o.map(T=>T.id===h.id?v(_({},T),{width:c?l-me.HEADER_WIDTH:l,measured:v(_({},T.measured),{width:c?l-me.HEADER_WIDTH:l}),position:{x:me.HEADER_WIDTH,y:d}}):T),d+=(E=(m=h.measured)==null?void 0:m.height)!=null?E:0,u+=(x=(y=h.measured)==null?void 0:y.height)!=null?x:0}),o=o.map(h=>h.id===e?v(_({},h),{height:u,width:c?l:l+me.HEADER_WIDTH,measured:v(_({},h.measured),{height:u,width:c?l:l+me.HEADER_WIDTH})}):h);let f=o.find(h=>h.id===e);return f!=null&&f.parentId&&(o=nn(f.parentId,o)),o},lc=(e,t,o)=>{if(e.type==="LANE")return o;let n=lt(t),r=lt(e);return r.y<n.y&&(e.position.y=0),r.x<n.x+me.HEADER_WIDTH&&(e.position.x=me.HEADER_WIDTH),r.y2>n.y2&&(t.height=r.y2-n.y,t.measured.height=r.y2-n.y),r.x2>n.x2&&(t.width=r.x2-n.x,t.measured.width=r.x2-n.x),o=o.map(i=>i.id===t.id?v(_({},i),{height:t.height,width:t.width,measured:t.measured}):i.id===e.id?v(_({},i),{position:e.position}):i),o},cc=()=>{let e=document.querySelector(".react-flow__viewport");return e||(console.error("Flow element (.react-flow__viewport) not found."),null)},zg=50,dc=(e,t=zg)=>{let o=Gg(e);return{x:o.x-t,y:o.y-t,width:o.width+t*2,height:o.height+t*2}};var rn=1,uc=e=>`<mxGraphModel>
7
7
  <root version="1.1">
8
8
  <mxCell id="0" />
9
9
  <mxCell id="1" parent="0" />
@@ -36,11 +36,11 @@ var hu=Object.defineProperty,yu=Object.defineProperties;var xu=Object.getOwnProp
36
36
  <mxGeometry as="geometry" relative="1" />
37
37
  </mxCell>
38
38
  </root>
39
- </mxGraphModel>`,lc=(e,t)=>{if(!e.length&&!t.length)return nn;let o=[...e.map(r=>r.id),...t.map(r=>r.id)];return Math.max(...o.map(r=>Number(r)))};var Pg=e=>{let t=Object.values(jo),o=e.filter(i=>{var a;let s=(a=i._attributes)==null?void 0:a.style;return t.includes(s)}),n=e.filter(i=>{var a;let s=(a=i._attributes)==null?void 0:a.style;return["attribute-loop"].includes(s)}),r=[];for(let i of o){let{style:s}=i._attributes,a=Xl[s],l=a==null?void 0:a(i,n);if(!l){console.warn(`Node ${s} not supported`);continue}r.push(l)}return r},Lg=(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=Kl(r),s=t.find(l=>l.id===i.source),a=t.find(l=>l.id===i.target);(s==null?void 0:s.type)==="LANE"||(a==null?void 0:a.type)==="LANE"||n.push(i)}return n},kg=(e,t)=>{let o=[];return e.forEach(n=>{var s,a;let r=(a=(s=Zl)[n.type])==null?void 0:a.call(s,n);if(!r){console.warn(`Node ${n.type} not supported`);return}if(o.push(r),n.type==="TASK"&&n.data.attribute==="LOOP"){let l=Jl(n,t);o.push(l)}}),o},Rg=(e,t)=>{let o=[];return e.forEach(n=>{let r=ql(n,t);o.push(r)}),o},cc=(e=[],t=[],o)=>{let n=kg(e,o),r=Rg(t,e),i={mxGraphModel:{root:{_attributes:{version:"1.1",lastId:o},mxCell:[{_attributes:{id:"0"}},{_attributes:{id:"1",parent:"0"}},...n,...r]}}};return zl(JSON.stringify(i),{compact:!0,spaces:0})},dc=async e=>{var c,d,u,p,f;let t=await vr(e),o=((d=(c=t==null?void 0:t.mxGraphModel)==null?void 0:c.root)==null?void 0:d.mxCell)||[],n=Number(((f=(p=(u=t==null?void 0:t.mxGraphModel)==null?void 0:u.root)==null?void 0:p._attributes)==null?void 0:f.lastId)||nn),r=Pg(o),i=Lg(o,r),s=tn(r),{nodes:a,edges:l}=ec(s,i);return{lastElementId:n,edges:l,nodes:Ot(a)}};import{Position as xc,useConnection as fh,useReactFlow as mh}from"@xyflow/react";import{useCallback as Oi}from"react";import{Handle as uc,useReactFlow as Dg}from"@xyflow/react";import{jsx as pc}from"react/jsx-runtime";var re=i=>{var s=i,{type:e,position:t,className:o,nodeType:n}=s,r=Je(s,["type","position","className","nodeType"]);let a=n==="TASK";return pc(uc,y({type:e,position:t,className:O("size-2.5 border border-grey-400 bg-white relative",{"before:content-[''] before:absolute before:inset-[-16px] before:bg-transparent":a,"before:content-[''] before:absolute before:inset-[-4px] before:bg-transparent":!a},o)},r))},Me=a=>{var l=a,{nodeId:e,nodeType:t,gatewayVariant:o,type:n,position:r,className:i}=l,s=Je(l,["nodeId","nodeType","gatewayVariant","type","position","className"]);let{getEdges:c,getNodes:d}=Dg(),p=(()=>{if(n!=="source")return!1;let f=c();if(t==="TASK")return f.filter(g=>g.source===e).length>=2;if(t==="GATEWAY"&&o==="EXCLUSIVE")return f.filter(g=>g.source===e).length>=2;if(t==="START_EVENT"){let h=d();return f.filter(m=>{if(m.source!==e)return!1;let E=h.find(_=>_.id===m.target);return(E==null?void 0:E.type)!=="ANNOTATION"}).length>=1}return!1})();return pc(uc,y({type:n,position:r,className:O("size-2.5 border border-grey-400 bg-white transition-all duration-200 relative",{"before:content-[''] before:absolute before:inset-[-16px] before:bg-transparent":t==="TASK","before:content-[''] before:absolute before:inset-[-4px] before:bg-transparent":t!=="TASK","opacity-50 cursor-not-allowed pointer-events-none":p,"hover:border-grey-500":!p},i),style:{pointerEvents:p?"none":"auto"}},s))};import{NodeResizer as Og,useReactFlow as Vg}from"@xyflow/react";import{orderBy as Hg}from"lodash";import{jsx as Gg}from"react/jsx-runtime";var go=n=>{var r=n,{nodeId:e,isVisible:t}=r,o=Je(r,["nodeId","isVisible"]);let{getNode:i,getNodes:s,setNodes:a}=Vg(),{isMultipleSelection:l}=Q(),c=({width:u,height:p})=>{if(!e)return;let f=i(e);if((f==null?void 0:f.type)!=="LANE")return;let h=[...s()],g=!f.parentId,m=g?f.id:f.parentId,E=h.filter(T=>T.type==="LANE"&&T.parentId===m);if(!E.length)return;let _=Hg(E,["position.y"]),b=0;_.forEach((T,N)=>{var C,I;let x=N===_.length-1,w=(I=(C=T.measured)==null?void 0:C.height)!=null?I:0;h=h.map(R=>{if(R.id===T.id){let S=g?u-pe.HEADER_WIDTH:u,D=v(y({},R),{width:S,measured:v(y({},R.measured),{width:S}),position:v(y({},R.position),{y:b})});return x&&g&&(D.height=p-b),D}return R}),b+=w}),h=h.map(T=>{if(T.id===m){let N=g?u:u+pe.HEADER_WIDTH;return v(y({},T),{width:N,height:g?p:b,measured:{width:N,height:g?p:b}})}return T}),a(h)};return Gg(Og,y({nodeId:e,handleClassName:"size-1.5 bg-blue-400 relative before:content-[''] before:absolute before:w-5 before:h-5 before:left-1/2 before:top-1/2 before:-translate-x-1/2 before:-translate-y-1/2 before:cursor-[inherit]",lineClassName:"border-blue-400/90 border-dashed",isVisible:!l&&t,onResizeEnd:(u,p)=>c(p)},o))};import{NodeToolbar as nh,useReactFlow as rh}from"@xyflow/react";import{Button as ih,Tooltip as sh,TooltipContent as ah,TooltipTrigger as lh,useTranslation as ch}from"@produto-lecom/lecom-ui";import{useCallback as Di,useEffect as dh,useRef as Ar,useState as uh}from"react";import{create as Bg}from"zustand";var ho=Bg(e=>({draggableNode:null,setDraggableNode:t=>{e({draggableNode:t})}}));import{useEffect as zg,useState as Fg}from"react";var fc=(e,t=!1)=>{let[o,n]=Fg({width:0,height:0});return zg(()=>{if(e.current&&t){let r=e.current.getBoundingClientRect();n({width:r.width,height:r.height})}},[t,e]),{dimensions:o}};import{Position as rn,useReactFlow as Wg}from"@xyflow/react";import{useMemo as Yg}from"react";var Ug=120,$g=12,mc=(e,t=!1,o)=>{let{getNode:n,getViewport:r}=Wg(),{instanceId:i}=Q();return Yg(()=>{var f,h;if(!t)return{position:rn.Right,align:"start"};let s=n(e);if(!s)return{position:rn.Right,align:"start"};let a=r(),l=s.position.x*a.zoom+a.x,c=(((f=s.measured)==null?void 0:f.width)||s.width||100)*a.zoom,d=(h=document.getElementById(`modeler-${i}`))==null?void 0:h.clientWidth;if(!d)return{position:rn.Right,align:"start"};let u=(o==null?void 0:o.width)||Ug;return{position:l+c+u+$g>d?rn.Left:rn.Right}},[i,e,t,o,n,r])};import{useNodesData as Xg,useReactFlow as Kg}from"@xyflow/react";import{Button as gc,DropdownMenu as qg,DropdownMenuContent as Zg,DropdownMenuGroup as Jg,DropdownMenuItem as Qg,DropdownMenuLabel as jg,DropdownMenuTrigger as eh,Tooltip as Li,TooltipContent as ki,TooltipTrigger as Ri,useTranslation as th}from"@produto-lecom/lecom-ui";import{WrenchIcon as oh}from"lucide-react";import{jsx as Ie,jsxs as Vt}from"react/jsx-runtime";var hc=({nodeId:e})=>{let{t}=th(),{updateNodeData:o,getEdges:n,getNode:r}=Kg(),i=Xg(e),a=n().filter(f=>f.source===e).some(f=>{let h=r(f.target);return(h==null?void 0:h.type)==="END_EVENT"}),l=(i==null?void 0:i.data.variant)==="SUBPROCESS",c=u=>{o(e,{variant:(i==null?void 0:i.data.variant)===u?"":u})},d=u=>{o(e,{attribute:(i==null?void 0:i.data.attribute)===u?"":u})};return Vt(qg,{children:[Vt(Li,{children:[Ie(Ri,{asChild:!0,children:Ie(eh,{asChild:!0,children:Ie(gc,{variant:"ghost",color:"grey",size:"small",iconButton:!0,children:Ie(oh,{})})})}),Ie(ki,{color:"black",children:t("bpmn.task.menu.title")})]}),Vt(Zg,{align:"start",className:"w-60 bg-white text-grey-600",children:[Vt(jg,{className:"flex items-center gap-1",children:[Ie("div",{className:"flex-1 body-medium-500",children:t("bpmn.task.menu.title")}),Ie("div",{className:"flex items-center gap-1",children:Object.entries(vn).map(([u,p])=>{let f=u==="LOOP"&&(a||l),g=(()=>{if(u==="LOOP"&&a)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 Vt(Li,{children:[Ie(Ri,{asChild:!0,children:Ie(gc,{variant:"ghost",color:"grey",size:"small",iconButton:!0,disabled:f,className:O({"bg-grey-100 text-blue-500":(i==null?void 0:i.data.attribute)===u,"opacity-50 cursor-not-allowed":f}),onClick:f?void 0:()=>d(u),children:Ie(p.icon,{className:"stroke-inherit"})})}),g&&Ie(ki,{color:"black",children:g})]},u)})})]}),Ie(Jg,{children:Vt(Li,{children:[Ie(Ri,{asChild:!0,children:Ie("div",{className:O({"cursor-not-allowed":a}),children:Vt(Qg,{className:O({"bg-grey-100 text-blue-500":(i==null?void 0:i.data.variant)==="SCRIPT","opacity-50":a}),disabled:a,onClick:()=>c("SCRIPT"),children:[Ie(Nn.SCRIPT.icon,{className:"stroke-current"}),t(`bpmn.task.variant.${"SCRIPT".toLowerCase()}`)]})})}),a&&Ie(ki,{color:"black",children:t("editor.task_menu.script_not_allowed_when_connected_to_end")})]})})]})]})};import{jsx as he,jsxs as yc}from"react/jsx-runtime";var Ht={START_EVENT:{type:"START_EVENT",icon:Ao,label:"bpmn.start_event.variant.default"},END_EVENT:{type:"END_EVENT",icon:$t,label:"bpmn.end_event.variant.default"},TASK:{type:"TASK",icon:Ao,label:"bpmn.task.variant.default"},ANNOTATION:{type:"ANNOTATION",icon:En,label:"bpmn.annotation.variant.default"}},ph={EXCLUSIVE:{type:"GATEWAY",variant:"EXCLUSIVE",icon:Kt,label:"bpmn.gateway.variant.exclusive"},PARALLEL:{type:"GATEWAY",variant:"PARALLEL",icon:qt,label:"bpmn.gateway.variant.parallel"},COMPLEX:{type:"GATEWAY",variant:"COMPLEX",icon:Xt,label:"bpmn.gateway.variant.complex"}},Oe=({nodeId:e,nodeType:t,nodeVariant:o})=>{let n=Ar(null),r=Ar(null),{t:i}=ch(),{setDraggableNode:s}=ho(),{getEdges:a,getNodes:l,getNode:c}=rh(),{setIsDragging:d,mode:u,isConnecting:p,isDragging:f,isMultipleSelection:h}=Q(),g=c(e),m=!!(g!=null&&g.selected)&&!g.dragging&&!p&&!f&&!h,{dimensions:E}=fc(n,m),{position:_}=mc(e,m,E),[b,T]=uh(void 0),N=l(),x=a(),w=o==="SUBPROCESS",C=Ar(null),I=Ar(!1),R=Di(()=>{C.current!==null&&(clearTimeout(C.current),C.current=null),I.current=!1,d(!1),s(null),T(void 0)},[d,s]);dh(()=>{let P=H=>{I.current&&H.buttons===0&&R()};return document.addEventListener("dragend",R),document.addEventListener("mousemove",P),()=>{document.removeEventListener("dragend",R),document.removeEventListener("mousemove",P)}},[R]);let S=Di((P,H)=>{I.current=!0,d(!1),s({type:H.type,variant:H.variant,attribute:H.attribute,icon:H.icon}),H.icon&&T(he(H.icon,{})),P.dataTransfer.effectAllowed="move",P.dataTransfer.setData("sourceId",e),r.current&&P.dataTransfer.setDragImage(r.current,10,10),C.current=setTimeout(()=>{C.current=null,d(!0)},100)},[e,s,d]),D=Di(()=>{R()},[R]),X=[{component:he(mr,{elementId:e})}],Z=()=>{if(u==="view")return[];let P=!x.some(H=>{var F;return H.source===e&&((F=N.find(z=>z.id===H.target))==null?void 0:F.type)!=="ANNOTATION"});return[{component:he(Dt,{nodeId:e,disabled:!P,tooltipMessage:P?void 0:i("editor.toolbar.start_event_limit_reached")})},Ht.TASK,Ht.ANNOTATION,...X]},te=()=>u==="view"?[{component:he(bt,{elementId:e})}]:[{component:he(bt,{elementId:e})},...w?[]:[{component:he(hc,{nodeId:e})}],{component:he(Dt,{nodeId:e})},Ht.TASK,...Object.values(ph),...X],A=()=>u==="view"?[{component:he(bt,{elementId:e})}]:[{component:he(bt,{elementId:e})},{component:he(Dt,{nodeId:e})},Ht.TASK,Ht.ANNOTATION,...X],M=()=>u==="view"?[]:[{component:he(Dt,{nodeId:e})},Ht.ANNOTATION,...X],$=()=>u==="view"?[]:[{component:he(Dt,{nodeId:e})},Ht.ANNOTATION,...X],V=()=>u==="view"?[]:[{component:he(Dt,{nodeId:e})},...X],L=()=>u==="view"?[]:[...X],K=(P=>{switch(P){case"START_EVENT":return Z();case"TASK":return te();case"GATEWAY":return A();case"END_EVENT":return M();case"LANE":return $();case"ANNOTATION":return V();case"UNSUPPORTED":return L();default:return[]}})(t);if(!(K.length===0||u==="readonly"))return yc(nh,{position:_,align:"start",className:"-top-8",isVisible:m,children:[he("div",{ref:n,className:"flex items-center gap-1 px-3 py-2 bg-white rounded-sm shadow-md",children:K.map((P,H)=>{if(P.component)return he("div",{children:P.component},H);let F={sourceNodeType:t,targetNodeType:P.type,sourceNodeId:e,nodes:N,edges:x},z=Tl(F),k={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")},J=z.shouldDisable&&z.reason?k[z.reason]||i(P.label):i(P.label)||"";return yc(sh,{children:[he(lh,{asChild:!0,children:he(ih,{variant:"ghost",color:"grey",size:"small",iconButton:!0,draggable:!z.shouldDisable,disabled:z.shouldDisable,className:z.shouldDisable?"opacity-50 cursor-not-allowed":"",onDragStart:z.shouldDisable?void 0:U=>S(U,P),onDragEnd:z.shouldDisable?void 0:D,children:P.icon&&he(P.icon,{size:16})})}),he(ah,{color:"black",children:J})]},H)})}),he("div",{ref:r,className:"absolute w-0 h-0 top-0 left-0 z-[-1] bg-transparent",children:b})]})};import{jsx as sn,jsxs as gh}from"react/jsx-runtime";var Ec=({id:e,data:t,selected:o,dragging:n})=>{let{updateNodeData:r,setNodes:i}=mh(),{inProgress:s,fromNode:a}=fh(),{mode:l}=Q(),c=s&&(a==null?void 0:a.id)!==e,d=Oi(f=>{let _=f.split(`
40
- `),b=_.reduce((w,C)=>Math.max(w,C.length),0),T=_.length,N=Math.max(co.MIN_WIDTH,b*7+32),x=Math.max(co.MIN_HEIGHT,T*20+24);i(w=>w.map(C=>C.id===e?v(y({},C),{width:N,height:x,style:v(y({},C.style),{width:N,height:x})}):C))},[e,i]),u=Oi(f=>{r(e,{label:f}),d(f)},[e,r,d]),p=Oi(f=>{d(f)},[d]);return gh("div",{className:O("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:[sn(we,{value:t.label,className:"m-1 text-grey-600 text-left",onChange:u,onInput:p}),sn(Oe,{nodeId:e,nodeType:"ANNOTATION"}),l==="edit"&&sn(go,{minWidth:co.MIN_WIDTH,minHeight:co.MIN_HEIGHT,isVisible:!n&&o}),!s&&sn(re,{type:"source",position:xc.Right}),(!s||c)&&sn(re,{type:"target",position:xc.Left,className:O({"annotation-handle":c})})]})};import{Position as Tt,useConnection as hh,useReactFlow as yh}from"@xyflow/react";import{useState as xh}from"react";import{Fragment as bc,jsx as ze,jsxs as Vi}from"react/jsx-runtime";var _c=({id:e,data:t,selected:o})=>{let{updateNodeData:n}=yh(),{inProgress:r,fromNode:i}=hh(),{reconnectingEdgeId:s}=Q(),[a,l]=xh(!1),c=r&&(i==null?void 0:i.id)!==e||!!s,d=f=>{n(e,{label:f})},u=()=>{l(!0)},p=()=>{l(!1)};return Vi("div",{className:"relative",onDoubleClick:u,children:[ze($t,{className:O("size-9 hover:stroke-[#d33b3b] transition-colors duration-75",{"stroke-blue-500 hover:stroke-blue-600":o,"stroke-red-500 hover:stroke-red-600 drop-shadow-[0_0_3px_rgba(255,0,0,0.5)] fill-red-100":t.hasError})}),ze("div",{className:"absolute top-10 left-1/2 -translate-x-1/2 max-w-80 w-max",children:ze(we,{value:t.label,isEditing:a,onBlur:p,onChange:d})}),ze(Oe,{nodeId:e,nodeType:"END_EVENT"}),(!r||c)&&Vi(bc,{children:[ze(re,{type:"target",position:Tt.Left,id:"left",className:O({"event-handle":c})}),ze(re,{type:"target",position:Tt.Right,id:"right",className:O({"event-handle":c})}),ze(re,{type:"target",position:Tt.Top,id:"top",className:O({"event-handle":c})}),ze(re,{type:"target",position:Tt.Bottom,id:"bottom",className:O({"event-handle":c})})]}),!r&&Vi(bc,{children:[ze(re,{type:"source",position:Tt.Left,id:"left"}),ze(re,{type:"source",position:Tt.Right,id:"right"}),ze(re,{type:"source",position:Tt.Top,id:"top"}),ze(re,{type:"source",position:Tt.Bottom,id:"bottom"})]})]})};import{Position as Nt,useConnection as Eh,useReactFlow as bh}from"@xyflow/react";import{useCallback as _h,useState as Th}from"react";import{Fragment as Tc,jsx as Fe,jsxs as Hi}from"react/jsx-runtime";var Nc=({id:e,data:t,selected:o})=>{let n=ii[t.variant].icon,{updateNodeData:r}=bh(),{inProgress:i,fromNode:s}=Eh(),{reconnectingEdgeId:a}=Q(),[l,c]=Th(!1),d=i&&(s==null?void 0:s.id)!==e||!!a,u=_h(h=>{r(e,{label:h})},[e,r]),p=()=>{c(!0)},f=()=>{c(!1)};return Hi("div",{className:"relative",onDoubleClick:p,children:[Fe(n,{className:O("size-14 stroke-1 stroke-grey-400 hover:stroke-grey-500 transition-colors duration-75",{"stroke-blue-500 hover:stroke-blue-600":o,"stroke-red-500 hover:stroke-red-600 drop-shadow-[0_0_3px_rgba(255,0,0,0.5)]":t.hasError})}),Fe("div",{className:"absolute top-14 left-1/2 -translate-x-1/2 max-w-80 w-max",children:Fe(we,{value:t.label,isEditing:l,onBlur:f,onChange:u})}),Fe(Oe,{nodeId:e,nodeType:"GATEWAY"}),(!i||d)&&Hi(Tc,{children:[Fe(re,{type:"target",position:Nt.Left,id:"left",className:O({"gateway-handle":d})}),Fe(re,{type:"target",position:Nt.Right,id:"right",className:O({"gateway-handle":d})}),Fe(re,{type:"target",position:Nt.Top,id:"top",className:O({"gateway-handle":d})}),Fe(re,{type:"target",position:Nt.Bottom,id:"bottom",className:O({"gateway-handle":d})})]}),!i&&Hi(Tc,{children:[Fe(Me,{type:"source",position:Nt.Left,id:"left",nodeId:e,nodeType:"GATEWAY",gatewayVariant:t.variant}),Fe(Me,{type:"source",position:Nt.Right,id:"right",nodeId:e,nodeType:"GATEWAY",gatewayVariant:t.variant}),Fe(Me,{type:"source",position:Nt.Top,id:"top",nodeId:e,nodeType:"GATEWAY",gatewayVariant:t.variant}),Fe(Me,{type:"source",position:Nt.Bottom,id:"bottom",nodeId:e,nodeType:"GATEWAY",gatewayVariant:t.variant})]})]})};import{useNodesData as PC,useReactFlow as LC}from"@xyflow/react";import{Button as RC,DropdownMenu as DC,DropdownMenuContent as OC,DropdownMenuGroup as VC,DropdownMenuItem as HC,DropdownMenuLabel as GC,DropdownMenuTrigger as BC,Tooltip as zC,TooltipContent as FC,TooltipTrigger as WC,useTranslation as YC}from"@produto-lecom/lecom-ui";import{WrenchIcon as $C}from"lucide-react";import{jsx as ZC,jsxs as JC}from"react/jsx-runtime";import{Position as vt,useConnection as Nh,useReactFlow as vh}from"@xyflow/react";import{useState as wh}from"react";import{Fragment as vc,jsx as We,jsxs as Gi}from"react/jsx-runtime";var wc=({id:e,data:t,selected:o})=>{let{updateNodeData:n}=vh(),{inProgress:r,fromNode:i}=Nh(),{reconnectingEdgeId:s}=Q(),[a,l]=wh(!1),c=r&&(i==null?void 0:i.id)!==e||!!s,d=f=>{n(e,{label:f})},u=()=>{l(!0)},p=()=>{l(!1)};return Gi("div",{className:"relative",onDoubleClick:u,children:[We(_n,{className:O("size-9 hover:stroke-[#54890b] transition-colors duration-75",{"stroke-blue-500 hover:stroke-blue-600":o,"stroke-red-500 hover:stroke-red-600 drop-shadow-[0_0_3px_rgba(255,0,0,0.5)] fill-red-100":t.hasError})}),We("div",{className:"absolute top-10 left-1/2 -translate-x-1/2 max-w-80 w-max",children:We(we,{value:t.label,isEditing:a,onBlur:p,onChange:d})}),We(Oe,{nodeId:e,nodeType:"START_EVENT"}),(!r||c)&&Gi(vc,{children:[We(re,{type:"target",position:vt.Left,id:"left",className:O({"event-handle":c})}),We(re,{type:"target",position:vt.Right,id:"right",className:O({"event-handle":c})}),We(re,{type:"target",position:vt.Top,id:"top",className:O({"event-handle":c})}),We(re,{type:"target",position:vt.Bottom,id:"bottom",className:O({"event-handle":c})})]}),!r&&Gi(vc,{children:[We(Me,{type:"source",position:vt.Left,id:"left",nodeId:e,nodeType:"START_EVENT"}),We(Me,{type:"source",position:vt.Right,id:"right",nodeId:e,nodeType:"START_EVENT"}),We(Me,{type:"source",position:vt.Top,id:"top",nodeId:e,nodeType:"START_EVENT"}),We(Me,{type:"source",position:vt.Bottom,id:"bottom",nodeId:e,nodeType:"START_EVENT"})]})]})};import{useTranslation as Ch}from"@produto-lecom/lecom-ui";import{Position as wt,useConnection as Sh,useReactFlow as Mh}from"@xyflow/react";import{useCallback as Cr}from"react";var an=60,Ir=(e,t)=>{var s;let o=[],n=`${t} `;for(let a of e){if(!(a.type==="TASK"))continue;let c=(s=a.data)==null?void 0:s.label;if(c&&c.startsWith(n)){let d=c.substring(n.length);/^\d{1,15}$/.test(d)&&o.push(parseInt(d,10))}}let r=o.length>0?Math.max(...o)+1:1,i=`${t} ${r}`;return i.length<=an?i:i.substring(0,an).trim()},yo=(e,t)=>{var a;let o=new Set;for(let l of t)l.type==="TASK"&&((a=l.data)!=null&&a.label)&&o.add(l.data.label);let n=e;if(n.length>an&&(n=n.substring(0,an).trim()),!o.has(n))return n;let r=n.replace(/\s+\(\d+\)$/,""),i=2,s=o.size+2;for(;i<=s;){let l=` (${i})`,c=an-l.length,u=`${r.substring(0,c).trim()}${l}`;if(!o.has(u))return u;i++}return n};import{jsx as Ac,jsxs as Ah}from"react/jsx-runtime";var Ic=e=>Ah("svg",v(y({width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",xmlns:"http://www.w3.org/2000/svg"},e),{children:[Ac("circle",{cx:"12",cy:"12",r:"10",fill:"#10B981"}),Ac("path",{d:"M7 12L10 15L17 8",stroke:"white",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"})]}));import{jsx as Cc}from"react/jsx-runtime";var Sc=e=>Cc("svg",v(y({width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",xmlns:"http://www.w3.org/2000/svg"},e),{children:Cc("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 Mc,jsxs as Ih}from"react/jsx-runtime";var Pc=e=>Ih("svg",v(y({width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",xmlns:"http://www.w3.org/2000/svg"},e),{children:[Mc("circle",{cx:"12",cy:"12",r:"10",fill:"#EF4444"}),Mc("path",{d:"M8 8L16 16M8 16L16 8",stroke:"white",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"})]}));import{Fragment as Sr,jsx as fe,jsxs as ln}from"react/jsx-runtime";var Ph={APROVADO:Ic,EM_ANDAMENTO:Sc,REJEITADO:Pc},Bi={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)]"},Lc=({id:e,data:t,selected:o,dragging:n})=>{let{t:r}=Ch(),{toast:i}=De(),{updateNodeData:s,getNodes:a,setNodes:l}=Mh(),{inProgress:c,fromNode:d}=Sh(),{mode:u,onSubprocessValidationClick:p,reconnectingEdgeId:f}=Q(),{getTaskStatus:h}=St(),g=c&&(d==null?void 0:d.id)!==e||!!f,m=h(e),E=t.variant==="SUBPROCESS",_=!!t.variant&&!E||!!m,b=!!t.attribute||E,T=Cr(X=>{let M=_||b?80:40,$=X.split(`
41
- `),V=$.reduce((P,H)=>Math.max(P,H.length),0),L=$.length,G=Math.max(lo.MIN_WIDTH,V*7+64),K=Math.max(lo.MIN_HEIGHT,L*24+M);l(P=>P.map(H=>H.id===e?v(y({},H),{width:G,height:K,style:v(y({},H.style),{width:G,height:K})}):H))},[e,l,_,b]),N=Cr(X=>{let Z=X.trim(),te=t.label||"";if(Z===te)return;let A=Z,M=a();if(!(Z&&Z!=="")){A=Ir(M,r("bpmn.task.label.prefix")),s(e,{label:A}),T(A),i({variant:"warning",content:ln(Sr,{children:[r("bpmn.task.feedback.label_empty.prefix")," ",fe("strong",{children:A})]})});return}let V=yo(A,M);V===te||(s(e,{label:V}),T(V),V!==A&&i({variant:"warning",content:ln(Sr,{children:[r("bpmn.task.feedback.label_already_exists.prefix")," ",fe("strong",{children:Z})," ",r("bpmn.task.feedback.label_already_exists.middle")," ",fe("strong",{children:V})]})}))},[t.label,a,e,r,s,T,i]),x=Cr(X=>{T(X)},[T]),w=Cr(()=>{i({variant:"error",content:r("bpmn.task.feedback.invalid_first_character")})},[r,i]),C=m?Ph[m]:null,I=t.variant?Nn[t.variant].icon:null,R=t.attribute?vn[t.attribute].icon:null,S=()=>t.hasError?Bi.error:m?Bi[m]:Bi.default,D=()=>{p==null||p({id:e,type:"sub_process",label:t.label})};return ln("div",{className:O("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:[fe("div",{className:"flex-1 flex items-stretch justify-stretch overflow-hidden",children:fe(we,{value:t.label,maxLength:60,className:O({"py-10 px-8":_||b}),onChange:N,onInput:x,onInvalidFirstCharacter:w})}),I&&fe("div",{className:O("absolute flex items-center p-1",E?"bottom-0":"top-0 left-0"),children:fe(I,{size:16,className:O(t.hasError?"text-red-500":"text-grey-500",E&&"cursor-pointer"),onClick:E?D:void 0})}),R&&fe("div",{className:"absolute bottom-0 left-0 w-full flex items-center justify-center",children:fe("div",{className:O("flex items-center w-16 p-1",E?"justify-between":"justify-center"),children:fe(R,{size:16,className:O(t.hasError?"text-red-500":"text-grey-500")})})}),C&&fe("div",{className:"absolute top-0 right-0 flex items-center p-1",children:fe(C,{})}),fe(Oe,{nodeId:e,nodeType:"TASK",nodeVariant:t.variant}),u==="edit"&&fe(go,{minWidth:lo.MIN_WIDTH,minHeight:lo.MIN_HEIGHT,isVisible:!n&&o}),(!c||g)&&ln(Sr,{children:[fe(re,{type:"target",position:wt.Left,id:"left",className:O({"task-handle":g})}),fe(re,{type:"target",position:wt.Right,id:"right",className:O({"task-handle":g})}),fe(re,{type:"target",position:wt.Top,id:"top",className:O({"task-handle":g})}),fe(re,{type:"target",position:wt.Bottom,id:"bottom",className:O({"task-handle":g})})]}),!c&&ln(Sr,{children:[fe(Me,{type:"source",position:wt.Left,id:"left",nodeId:e,nodeType:"TASK"}),fe(Me,{type:"source",position:wt.Right,id:"right",nodeId:e,nodeType:"TASK"}),fe(Me,{type:"source",position:wt.Top,id:"top",nodeId:e,nodeType:"TASK"}),fe(Me,{type:"source",position:wt.Bottom,id:"bottom",nodeId:e,nodeType:"TASK"})]})]})};import{Position as kc}from"@xyflow/react";import{Fragment as Lh,jsx as Mr,jsxs as kh}from"react/jsx-runtime";var Rc=({id:e,data:t})=>kh(Lh,{children:[Mr("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}),Mr(Oe,{nodeId:e,nodeType:"UNSUPPORTED"}),Mr(re,{type:"source",position:kc.Right}),Mr(re,{type:"target",position:kc.Left})]});import{BaseEdge as Rh,EdgeLabelRenderer as Dh,getSmoothStepPath as Oh,MarkerType as Vh,useInternalNode as Dc,useReactFlow as Hh,useViewport as Gh,Position as xo}from"@xyflow/react";import{useState as Bh,useMemo as zh}from"react";import{Fragment as Oc,jsx as Ve,jsxs as Eo}from"react/jsx-runtime";var L5={type:"MESSAGE_EDGE",reconnectable:!0,markerEnd:{type:Vh.Arrow},data:{label:""}},Vc=({id:e,source:t,target:o,data:n,selected:r,sourcePosition:i,targetPosition:s,sourceHandleId:a,targetHandleId:l})=>{var H;let{zoom:c}=Gh(),{updateEdgeData:d}=Hh(),{isMultipleSelection:u,mode:p,instanceId:f}=Q(),h=p!=="edit",[g,m]=Bh(!1),{reconnectingHandle:E,cursorPosition:_,hoveredNodeId:b,reconnectingSide:T,isValidReconnection:N,handleReconnectStart:x}=_r({edgeId:e,source:t,target:o,instanceId:f,isReadOnly:h}),w=Dc(t),C=Dc(o),{sx:I,sy:R,tx:S,ty:D,sourcePos:X,targetPos:Z}=zh(()=>{var se,ae;if(!w||!C)return{sx:0,sy:0,tx:0,ty:0,sourcePos:xo.Left,targetPos:xo.Right};let F=Zt(w,C),z=a?i:F.sourcePos,k=l?s:F.targetPos,J=(le,ce,me)=>{var Te,Pe,ut,Yt,Ut,ye;let{x:ge,y:ue}=le.internals.positionAbsolute,ie=(ut=(Pe=(Te=le.measured)==null?void 0:Te.width)!=null?Pe:le.width)!=null?ut:0,ne=(ye=(Ut=(Yt=le.measured)==null?void 0:Yt.height)!=null?Ut:le.height)!=null?ye:0;switch(ce){case xo.Top:return{x:ge+ie*me,y:ue};case xo.Bottom:return{x:ge+ie*me,y:ue+ne};case xo.Left:return{x:ge,y:ue+ne*me};case xo.Right:return{x:ge+ie,y:ue+ne*me};default:return{x:ge+ie/2,y:ue+ne/2}}},U=(se=n==null?void 0:n.sourceOffset)!=null?se:.5,Y=(ae=n==null?void 0:n.targetOffset)!=null?ae:.5,B=w?J(w,z,U).x:F.sx,W=w?J(w,z,U).y:F.sy,q=C?J(C,k,Y).x:F.tx,j=C?J(C,k,Y).y:F.ty;return E==="source"&&_?(B=_.x,W=_.y,T&&(z=T)):E==="target"&&_&&(q=_.x,j=_.y,T&&(k=T)),{sx:B,sy:W,tx:q,ty:j,sourcePos:z,targetPos:k}},[w,C,a,l,i,s,E,_,T,n==null?void 0:n.sourceOffset,n==null?void 0:n.targetOffset]);if(!w||!C)return null;let[te,A,M]=Oh({sourceX:I,sourceY:R,targetX:S,targetY:D,sourcePosition:X,targetPosition:Z}),$=r||(w==null?void 0:w.selected)||(C==null?void 0:C.selected),V=$?"sequence-edge-marker-highlighted":"sequence-edge-marker",L=g||(n==null?void 0:n.label.trim().length)>0,G=()=>{m(!0)},K=()=>{m(!1)},P=F=>{d(e,{label:F.trim()})};return Ve(Oc,{children:Eo("g",{className:O("text-grey-500 hover:text-grey-600",{"text-blue-500 hover:text-blue-600":$}),onDoubleClick:G,children:[Ve(Rh,{id:e,path:te,markerEnd:`url(#${V})`,strokeDasharray:4,className:O("stroke-2 stroke-current transition-colors duration-75",{"stroke-red-500 hover:stroke-red-600":(n==null?void 0:n.hasError)||E&&b&&!N,"stroke-green-500":E&&b&&N,"stroke-blue-500 hover:stroke-blue-600 drop-shadow-[0_0_3px_rgba(59,130,246,0.5)]":$&&!(n!=null&&n.hasError)&&!E})}),Eo(Dh,{children:[Eo("div",{className:"absolute z-[3000] pointer-events-auto flex flex-col items-center gap-1",style:{transform:`translate(-50%, -50%) translate(${A}px, ${M}px)`},children:[r&&!u&&Ve(no,{sx:I,sy:R,tx:S,ty:D,hasLabel:!!((H=n==null?void 0:n.label)!=null&&H.trim()),children:Ve(oo,{edgeId:e,edgeType:"MESSAGE_EDGE"})}),L&&Ve(we,{value:n==null?void 0:n.label,className:"min-w-8 max-w-56 bg-white rounded-md px-2 py-1 text-xs",isEditing:g,onBlur:K,onChange:P})]}),r&&!u&&!h&&Eo(Oc,{children:[Ve("div",{className:"absolute z-[1000] pointer-events-none",style:{transform:`translate(-50%, -50%) translate(${I}px, ${R}px)`},children:Eo("svg",{width:12/c,height:12/c,style:{overflow:"visible",position:"absolute",left:"50%",top:"50%",transform:"translate(-50%, -50%)"},children:[Ve("circle",{cx:6/c,cy:6/c,r:4/c,fill:E==="source"?"#3b82f6":"#fff",stroke:"#3b82f6",strokeWidth:2/c,className:"pointer-events-none"}),Ve("circle",{cx:6/c,cy:6/c,r:6/c,fill:"none",stroke:"#3b82f6",strokeWidth:1/c,opacity:E==="source"?.6:.3,className:"pointer-events-none"}),Ve("circle",{cx:6/c,cy:6/c,r:8/c,fill:"transparent",className:O("pointer-events-auto",{"cursor-move":!E||E!=="source","cursor-not-allowed":E==="source"&&b&&!N,"cursor-grabbing":E==="source"&&(!b||N)}),onMouseDown:F=>x("source",F.nativeEvent)})]})}),Ve("div",{className:"absolute z-[1000] pointer-events-none",style:{transform:`translate(-50%, -50%) translate(${S}px, ${D}px)`},children:Eo("svg",{width:12/c,height:12/c,style:{overflow:"visible",position:"absolute",left:"50%",top:"50%",transform:"translate(-50%, -50%)"},children:[Ve("circle",{cx:6/c,cy:6/c,r:4/c,fill:E==="target"?"#3b82f6":"#fff",stroke:"#3b82f6",strokeWidth:2/c,className:"pointer-events-none"}),Ve("circle",{cx:6/c,cy:6/c,r:6/c,fill:"none",stroke:"#3b82f6",strokeWidth:1/c,opacity:E==="target"?.6:.3,className:"pointer-events-none"}),Ve("circle",{cx:6/c,cy:6/c,r:8/c,fill:"transparent",className:O("pointer-events-auto",{"cursor-move":!E||E!=="target","cursor-not-allowed":E==="target"&&b&&!N,"cursor-grabbing":E==="target"&&(!b||N)}),onMouseDown:F=>x("target",F.nativeEvent)})]})})]})]})]})})};import{getStraightPath as Fh,Position as Pr}from"@xyflow/react";import{jsx as Hc,jsxs as Wh}from"react/jsx-runtime";var Gc=({toX:e,toY:t,fromNode:o})=>{var u,p;if(!o)return null;let{internals:{positionAbsolute:{x:n,y:r}},measured:i}=o,s=(u=i.width)!=null?u:0,a=(p=i.height)!=null?p:0,c=[{x:n,y:r+a/2,pos:Pr.Left},{x:n+s,y:r+a/2,pos:Pr.Right},{x:n+s/2,y:r,pos:Pr.Top},{x:n+s/2,y:r+a,pos:Pr.Bottom}].reduce((f,h)=>{let g=Math.hypot(e-f.x,t-f.y);return Math.hypot(e-h.x,t-h.y)<g?h:f}),[d]=Fh({sourceX:c.x,sourceY:c.y,targetX:e,targetY:t});return Wh("g",{children:[Hc("path",{fill:"none",className:"stroke-2 stroke-grey-500 animated",d}),Hc("circle",{cx:e,cy:t,fill:"none",r:4,className:"stroke-2 stroke-grey-600"})]})};import{Position as Yh,useReactFlow as Uh}from"@xyflow/react";import{orderBy as $h}from"lodash";import{useMemo as Bc,useState as Xh}from"react";import{Fragment as Kh,jsx as Gt,jsxs as zc}from"react/jsx-runtime";var Fc=({id:e,data:t,selected:o,dragging:n,parentId:r})=>{let{updateNodeData:i,getNodes:s}=Uh(),{mode:a}=Q(),[l,c]=Xh(!1),d=s(),u=!r,p=Bc(()=>$h([...d.filter(_=>_.parentId===e&&_.type==="LANE")],"position.y","asc"),[d,e]),f=u?wr.MIN_WIDTH:pe.MIN_WIDTH,h=Bc(()=>{if(u&&p.length>1){let _=[...p];return _.pop(),_.reduce((T,N)=>{var x,w;return T+((w=(x=N.measured)==null?void 0:x.height)!=null?w:0)},0)+pe.MIN_HEIGHT}return pe.MIN_HEIGHT},[u,p]),g=_=>{i(e,{label:_})},m=()=>{c(!0)},E=()=>{c(!1)};return zc(Kh,{children:[zc("div",{className:O("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:[Gt("div",{className:"flex align-items justify-center w-10 border-r border-grey-300",onDoubleClick:m,children:Gt("div",{className:"relative flex-1 [writing-mode:vertical-rl] [text-orientation:sideways] transform rotate-180",children:Gt(we,{value:t.label,className:"w-full h-full self-auto",contentClassName:O({"whitespace-nowrap":l}),isEditing:l,onBlur:E,onChange:g})})}),Gt("div",{className:"flex-1"})]}),Gt(Oe,{nodeId:e,nodeType:"LANE",isChild:!u}),a==="edit"&&Gt(go,{nodeId:e,minWidth:f,minHeight:h,isVisible:!n&&o}),Gt(re,{type:"source",position:Yh.Right})]})};var Wc={START_EVENT:wc,END_EVENT:_c,TASK:Lc,GATEWAY:Nc,ANNOTATION:Ec,LANE:Fc,UNSUPPORTED:Rc},Yc={SEQUENCE_EDGE:Hl,MESSAGE_EDGE:Vc,ANNOTATION_EDGE:wl},Uc="#fafafa",$c="#bebebe",Xc=1,Kc=10,qc="bottom-left",zi=.05,Zc=5,bo=.5,_o=zi,To=1,Jc={x:0,y:0,zoom:.75},qh=1,Zh=2,Qc=[qh,Zh];import{useReactFlow as Jh}from"@xyflow/react";var Ye=()=>{let{getEdges:e,getNodes:t}=Jh(),{lastElementId:o}=Q(),n=()=>{let i=t(),s=e(),a=lc(i,s);return Math.max(a,o)};return{getLastId:n,getNextId:()=>n()+1}};var No=()=>{let{getNodes:e,getEdges:t,setNodes:o,setEdges:n,setViewport:r}=jh(),{getLastId:i}=Ye(),s=ey(),{setLastElementId:a}=Q(),l=jc(async(d="")=>{let{nodes:u,edges:p,lastElementId:f}=await dc(d),{width:h,height:g}=s.getState();if(h>0&&g>0){let m=tc(u);m&&r(Qh(m,h,g,_o,To,bo))}o(u),n(p),a(f)},[o,n,a,s,r]),c=jc(()=>{let d=e(),u=t(),p=i();return cc(d,u,p)},[e,t,i]);return{importFromMxGraph:l,exportToMxGraph:c}};import{useCallback as ed}from"react";var oy=500,Lr=()=>{let{isInitialized:e,onElementChanges:t}=Q(),{exportToMxGraph:o}=No(),n=ty(()=>{if(!e)return;let s=o();t==null||t(s)},oy),r=ed(s=>{s.every(c=>c.type==="select")||s.some(c=>c.type==="position"&&c.dragging)||n()},[n]),i=ed(s=>{s.some(l=>l.type==="select")||n()},[n]);return{emitElementChanges:n,handleNodeChanges:r,handleEdgeChanges:i}};var td=({setEdges:e,saveHistory:t})=>{let{getNode:o,getEdges:n,getNodes:r,getInternalNode:i}=ry(),{emitElementChanges:s}=Lr(),a=iy(null),{getNextId:l}=Ye(),c=Bt(m=>{var N;let E=o(m.source),_=o(m.target);if(!E||!_)return!1;let b={sourceNodeId:E.id,targetNodeId:_.id,sourceNodeType:E.type,targetNodeType:_.type,nodes:r(),edges:n(),reconnectingEdgeId:(N=a.current)!=null?N:void 0};return Ni(b).isValid},[o,n,r]),d=Bt(m=>{var b,T;let E=l(),_=i(m.source);if(_){let N=i(m.target),x=N?N.internals.positionAbsolute.x+((b=N.measured.width)!=null?b:0)/2:0,w=N?N.internals.positionAbsolute.y+((T=N.measured.height)!=null?T:0)/2:0,C=Gl(_,x,w),I=(N==null?void 0:N.type)==="ANNOTATION"||(_==null?void 0:_.type)==="ANNOTATION",R=I?ro:Be,S;if(!I&&N&&m.targetHandle){let Z=Nr(C),te=Nr(m.targetHandle),{x:A,y:M}=Si(_,C),{x:$,y:V}=Si(N,m.targetHandle),G=Er(A,M,$,V,Z,te).slice(1,-1);G.length>0&&(S=G)}let D=v(y(y({},m),R),{id:String(E),sourceHandle:C,data:y(y({},I?{}:Be.data),S?{points:S}:{})}),X=n().concat(D);e(X),t("forceSave",{nodes:r(),edges:X}),s()}},[l,e,s,i,n,r,t]),u=Bt((m,E)=>{a.current=E.id},[]),p=Bt(()=>{a.current=null},[]),f=Bt((m,E)=>{let _=o(E.source),b=o(E.target);if(!_||!b){a.current=null;return}let T={sourceNodeId:_.id,targetNodeId:b.id,sourceNodeType:_.type,targetNodeType:b.type,nodes:r(),edges:n(),reconnectingEdgeId:m.id};if(!Ni(T).isValid){a.current=null;return}let x=ny(m,E,n()).map(w=>w.id===m.id?v(y({},w),{data:v(y({},w.data),{points:void 0})}):w);e(x),t("forceSave",{nodes:r(),edges:x}),a.current=null,s()},[o,r,n,e,s,t]),h=Bt(m=>{a.current=m},[]),g=Bt(()=>{a.current=null},[]);return{isValidConnection:c,onConnect:d,onReconnect:f,onReconnectStart:u,onReconnectEnd:p,setReconnectingEdge:h,clearReconnectingEdge:g}};import{useTranslation as sy}from"@produto-lecom/lecom-ui";import{useReactFlow as ay}from"@xyflow/react";import{useCallback as pn,useRef as dd,useState as ly}from"react";var cn=(e=[])=>e.filter(t=>t.type==="START_EVENT"),zt=(e=[])=>e.filter(t=>t.type==="END_EVENT"),At=(e=[])=>e.filter(t=>t.type==="TASK")||[],od=(e=[])=>e.filter(t=>{var o;return t.type==="TASK"&&((o=t.properties)==null?void 0:o.variant)==="SCRIPT"}),nd=(e=[])=>e.filter(t=>{var o;return t.type==="TASK"&&((o=t.properties)==null?void 0:o.variant)==="SUBPROCESS"}),kr=(e=[])=>e.filter(t=>t.type==="GATEWAY"),rd=(e=[])=>e.filter(t=>{var o;return t.type==="GATEWAY"&&((o=t.properties)==null?void 0:o.variant)==="EXCLUSIVE"}),He=(e,t=[])=>t.filter(o=>o.source===e),dn=(e,t=[])=>t.filter(o=>o.target===e),id=(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"},sd=(e,t)=>{let o=He(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},ad=e=>e?/[^\s]/.test(e.trim()):!1,de=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:[]}},ot=(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)}},ld=(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 un=[{id:"start_event_not_found",validate:e=>{let t=cn(e.nodes);return de({isValid:t.length>=1})}},{id:"end_event_not_found",validate:e=>{let t=zt(e.nodes);return de({isValid:t.length>=1})}},{id:"multiple_start_event_not_allowed",validate:e=>{let t=cn(e.nodes),o=t.length===1;if(t.length===0)return de({isValid:!0});if(!o)return de({isValid:!1,nodeIds:t.map(i=>i.id)});let n=He(t[0].id,e.edges);if(!(n.length<=1)){let i=[...t.map(s=>s.id),...n.map(s=>s.target)];return de({isValid:!1,nodeIds:[...new Set(i)]})}return de({isValid:!0})}},{id:"task_flows_limit_exceeds",validate:e=>{let t=At(e.nodes),o=ot(t,n=>He(n.id,e.edges).length<=2);return de({isValid:o.isValid,nodeIds:o.invalidIds})}},{id:"task_label_empty",highlightRelatedEdges:!1,validate:e=>{let t=At(e.nodes),o=ot(t,n=>!!n.label&&n.label.trim()!=="");return de({isValid:o.isValid,nodeIds:o.invalidIds})}},{id:"task_label_length",highlightRelatedEdges:!1,validate:e=>{let o=At(e.nodes),n=ot(o,r=>!r.label||r.label.length<=60);return de({isValid:n.isValid,nodeIds:n.invalidIds})}},{id:"duplicate_task_name",highlightRelatedEdges:!1,validate:e=>{let t=At(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 de({isValid:n.length===0,nodeIds:n})}},{id:"nested_gateway",validate:e=>{let t=kr(e.nodes),o=[],n=[];for(let r of t){let i=He(r.id,e.edges);for(let s of i){let a=e.nodes.find(l=>l.id===s.target);a&&a.type==="GATEWAY"&&(o.push(r.id,a.id),n.push(s.id))}}return de({isValid:o.length===0,nodeIds:o.length>0?[...new Set(o)]:[],edgeIds:n})}},{id:"events_nested",validate:e=>{let t=[...cn(e.nodes),...zt(e.nodes)],o=[],n=[];for(let r of t){let i=He(r.id,e.edges);for(let s of i){let a=e.nodes.find(l=>l.id===s.target);a&&(a.type==="START_EVENT"||a.type==="END_EVENT")&&(o.push(r.id,a.id),n.push(s.id))}}return de({isValid:o.length===0,nodeIds:o.length>0?[...new Set(o)]:[],edgeIds:n})}},{id:"flows_on_end_tasks_not_allowed",validate:e=>{let t=zt(e.nodes),o=[],n=[];for(let r of t){let i=dn(r.id,e.edges);for(let s of i){let a=e.nodes.find(l=>l.id===s.source);if(a&&a.type==="TASK"){let l=He(a.id,e.edges);l.length>1&&(o.push(a.id),l.forEach(c=>n.push(c.id)))}}}return de({isValid:o.length===0,nodeIds:o,edgeIds:n})}},{id:"conditions_flows_limit_exceeds",validate:e=>{let t=rd(e.nodes),o=ot(t,r=>He(r.id,e.edges).length<=2),n=o.invalidIds.flatMap(r=>He(r,e.edges).map(i=>i.id));return de({isValid:o.isValid,nodeIds:o.invalidIds,edgeIds:n})}},{id:"activity_name_invalid",validate:e=>{let t=At(e.nodes),o=ot(t,n=>!n.label||ad(n.label));return de({isValid:o.isValid,nodeIds:o.invalidIds})}},{id:"final_activity_has_loop",validate:e=>{var s,a;if(!((s=e==null?void 0:e.nodes)!=null&&s.length)||!((a=e==null?void 0:e.edges)!=null&&a.length))return de({isValid:!0});let t=zt(e.nodes)[0];if(!t)return de({isValid:!0});let o=dn(t.id,e.edges);if(!o.length)return de({isValid:!0});let r=At(e.nodes).filter(l=>o.some(c=>c.source===l.id)),i=ot(r,l=>!id(l.id,e));return de({isValid:i.isValid,nodeIds:i.isValid?[]:[t.id,...i.invalidIds]})}},{id:"concurrent_initial_and_final_event",validate:e=>{let t=At(e.nodes),o=zt(e.nodes)[0];if(!o)return de({isValid:!0});let n=t.filter(l=>{let c=dn(l.id,e.edges),d=He(l.id,e.edges),u=c.some(f=>{var h;return((h=e.nodes.find(g=>g.id===f.source))==null?void 0:h.type)==="START_EVENT"}),p=d.some(f=>{var h;return((h=e.nodes.find(g=>g.id===f.target))==null?void 0:h.type)==="END_EVENT"});return u&&p}),r=dn(o.id,e.edges),i=r.length>1,s=r.map(l=>l.source),a={isValid:n.length===0&&!i,nodeIds:[...n.map(l=>l.id),...i?s:[]]};return de(a)}},{id:"gateway_flow_to_event",validate:e=>{let t=kr(e.nodes),o=[],n=[];for(let r of t){let i=He(r.id,e.edges);for(let s of i){let a=e.nodes.find(l=>l.id===s.target);a&&a.type==="END_EVENT"&&(o.push(r.id,a.id),n.push(s.id))}}return de({isValid:o.length===0,nodeIds:o.length>0?[...new Set(o)]:[],edgeIds:n})}},{id:"gateway_missing_output_streams",validate:e=>{let t=kr(e.nodes),o=ot(t,n=>He(n.id,e.edges).length>=1);return de({isValid:o.isValid,nodeIds:o.invalidIds})}},{id:"event_to_condition",validate:e=>{let t=[...cn(e.nodes),...zt(e.nodes)],o=[],n=[];for(let r of t){let i=He(r.id,e.edges);for(let s of i){let a=e.nodes.find(l=>l.id===s.target);a&&a.type==="GATEWAY"&&(o.push(r.id,a.id),n.push(s.id))}}return de({isValid:o.length===0,nodeIds:o.length>0?[...new Set(o)]:[],edgeIds:n})}},{id:"script_in_final_activity",validate:e=>{let t=od(e.nodes),o=ot(t,n=>!sd(n.id,e));return de({isValid:o.isValid,nodeIds:o.invalidIds})}},{id:"subprocess_referenced_not_configured",validate:e=>{let t=nd(e.nodes),o=ot(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 de({isValid:o.isValid,nodeIds:o.invalidIds})}}];var cd=e=>{e=e||{nodes:[],edges:[]},e.nodes=e.nodes||[],e.edges=e.edges||[];let t=[];for(let n of un){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 Rr,jsxs as cy}from"react/jsx-runtime";var ud=()=>{let{t:e}=sy(),{toast:t}=De(),{setNodes:o,setEdges:n,getNodes:r,getEdges:i}=ay(),[s,a]=ly(!1),l=dd(!1),c=dd(!1),d=pn(g=>{let m=ld(g.nodes,g.edges),E=cd(m),_=E.errors.map(b=>v(y({},b),{message:e(`validation.errors.${b.id}`)}));return s||a(!0),{isValid:E.isValid,errors:_}},[s,e]),u=pn((g,m=!0)=>{if(m&&g&&t({variant:g.isValid?"success":"error",duration:5e3,title:g.isValid?e("validation.success.title"):e("validation.errors.title"),content:cy("div",{className:"flex flex-col gap-1",children:[!g.isValid&&Rr("span",{className:"body-small-500",children:e("validation.errors.subtitle")}),Rr("ul",{className:"list-disc list-inside max-h-40 overflow-y-auto",children:g.isValid?Rr("li",{children:e("validation.success.message")}):g.errors.map(S=>Rr("li",{className:"text-xs",children:S.message},S.id))})]})}),!g)return;l.current=!0,c.current=!0;let E=[],_=[];g.errors.forEach(S=>{S.nodeIds&&S.nodeIds.length>0&&S.nodeIds.forEach(D=>E.push(D)),S.edgeIds&&S.edgeIds.length>0&&S.edgeIds.forEach(D=>_.push(D))});let b=[...new Set(E)];o(S=>S.map(D=>v(y({},D),{data:v(y({},D.data),{hasError:!1})}))),n(S=>S.map(D=>v(y({},D),{data:v(y({},D.data),{hasError:!1})})));let T=r(),N=i(),x=new Set(b),w=new Set;g.errors.forEach(S=>{var Z,te;let D=un.find(A=>A.id===S.id);(D==null?void 0:D.highlightRelatedEdges)!==!1&&((Z=S.edgeIds)==null||Z.forEach(A=>w.add(A)),(te=S.nodeIds)==null||te.forEach(A=>{N.forEach(M=>{(M.source===A||M.target===A)&&w.add(M.id)})}))});let C=new Set,I=new Set,R=new Set;T.forEach(S=>{S.type==="START_EVENT"?C.add(S.id):S.type==="END_EVENT"&&I.add(S.id)}),N.forEach(S=>{C.has(S.source)&&R.add(S.target),I.has(S.target)&&R.add(S.source)}),R.forEach(S=>{var D,X;if(x.has(S)){let Z=(D=g.errors.find(A=>{var M;return(M=A.nodeIds)==null?void 0:M.includes(S)}))==null?void 0:D.id;((X=un.find(A=>A.id===Z))==null?void 0:X.highlightRelatedEdges)!==!1&&N.forEach(A=>{A.source===S&&I.has(A.target)&&(x.add(A.target),w.add(A.id)),A.target===S&&C.has(A.source)&&(x.add(A.source),w.add(A.id))})}}),x.size>0&&o(S=>S.map(D=>v(y({},D),{data:v(y({},D.data),{hasError:x.has(D.id)})}))),w.size>0&&n(S=>S.map(D=>v(y({},D),{data:v(y({},D.data),{hasError:w.has(D.id)})}))),setTimeout(()=>{l.current=!1},0)},[e,i,r,n,o,t]),p=pn(()=>{a(!1),c.current=!1,o(g=>g.map(m=>v(y({},m),{data:v(y({},m.data),{hasError:!1})}))),n(g=>g.map(m=>v(y({},m),{data:v(y({},m.data),{hasError:!1})})))},[n,o]),f=pn(()=>{c.current&&(l.current=!0,c.current=!1,o(g=>g.map(m=>v(y({},m),{data:v(y({},m.data),{hasError:!1})}))),n(g=>g.map(m=>v(y({},m),{data:v(y({},m.data),{hasError:!1})}))),setTimeout(()=>{l.current=!1},0))},[n,o]),h=pn(()=>l.current,[]);return{validateDiagram:d,handleValidationComplete:u,clearValidation:p,dismissValidationPanel:f,isAutoValidationEnabled:s,getIsClearingValidation:h}};import{useReactFlow as dy}from"@xyflow/react";import{useTranslation as uy}from"@produto-lecom/lecom-ui";import{useEffect as py}from"react";var fy=15,pd="bpmn:selection",my=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},fd=e=>{if(!my(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},md=({offset:e=fy,saveHistory:t})=>{let{t:o}=uy(),{getNodes:n,setNodes:r,getEdges:i,setEdges:s}=dy(),{getNextId:a}=Ye();py(()=>{let l=d=>{var E,_;if(!fd(d))return;let u=n(),p=i(),f=u.filter(b=>b.selected);if(!f.length)return;d.preventDefault(),d.stopPropagation();let h=p.filter(b=>f.some(T=>T.id===b.source)&&f.some(T=>T.id===b.target)),m=JSON.stringify({nodes:f,edges:h});(E=d.clipboardData)==null||E.setData(pd,m),(_=d.clipboardData)==null||_.setData("text/plain",`BPMN Selection: ${f.length} nodes`)},c=d=>{var w,C;if(!fd(d))return;let u=(w=d.clipboardData)==null?void 0:w.getData(pd);if(!u)return;d.preventDefault(),d.stopPropagation();let p;try{p=JSON.parse(u)}catch(I){return}if(!((C=p.nodes)!=null&&C.length))return;let f=new Map,h=n(),g=[],m=p.nodes.filter(I=>xt(I.type,h));if(m.length===0)return;let E=a(),_=m.map(I=>{var D;let R=String(E++);f.set(I.id,R);let S=v(y({},I),{id:R,selected:!0,position:{x:I.position.x+e,y:I.position.y+e}});if(I.type==="TASK"){let X=(D=I.data)==null?void 0:D.label,Z=yo(X||o("bpmn.task.label.prefix"),[...h,...g]);S.data=v(y({},I.data),{label:Z})}return g.push(S),S}),b=p.edges.map(I=>v(y({},I),{id:String(E++),selected:!0,source:f.get(I.source)||I.source,target:f.get(I.target)||I.target})),T=[...h.map(I=>v(y({},I),{selected:!1})),..._],x=[...i().map(I=>v(y({},I),{selected:!1})),...b];r(T),s(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,s,a,e,o,t])};import{useReactFlow as gy,useStoreApi as hy}from"@xyflow/react";import{useTranslation as yy}from"@produto-lecom/lecom-ui";import{useState as xy}from"react";var gd=({nodes:e,setNodes:t,setEdges:o,saveHistory:n})=>{let r=hy(),{draggableNode:i,setDraggableNode:s}=ho(),{t:a}=yy(),{getInternalNode:l,getNodes:c,getEdges:d,screenToFlowPosition:u}=gy(),{getNextId:p}=Ye(),{setIsDragging:f}=Q(),{rebuildIndex:h,forceRebuildIndex:g}=nr(),[m,E]=xy(null),_=(A,M=!1)=>{let $=M?"node-drop-target-error":"node-drop-target",V=M?"node-drop-target-lane-error":"node-drop-target-lane";t(L=>L.map(G=>G.id===A?v(y({},G),{className:$}):A!==void 0&&G.parentId===A&&G.type==="LANE"?v(y({},G),{className:V}):v(y({},G),{className:""})))},b=()=>{let{nodeLookup:A}=r.getState();return Array.from(A.values())},T=(A,M)=>{let $=b();if(A.type==="LANE"){if(M){_();return}let P=$.filter(z=>z.id!==A.id&&z.type==="LANE"&&!z.parentId),H=en(A,P);if(!H){_();return}if(mo({parentId:H.id,nodes:e,excludeTypes:["LANE"]})){_(H.id,!0);return}_(H.id);return}let L=$.filter(P=>P.id!==A.id&&P.type==="LANE"),G=en(A,L);if(!G){_();return}if(mo({parentId:G.id,nodes:e,includeTypes:["LANE"]})){_();return}_(G.id)},N=A=>{let M=l(A.id),$=A.type==="LANE"&&mo({parentId:A.id,nodes:e,includeTypes:["LANE"]});T(M,$)},x=A=>A.map(M=>v(y({},M),{className:void 0})),w=A=>A.some($=>$.dragging)?A.map($=>$.dragging?v(y({},$),{dragging:!1}):$):A,C=A=>{if(A.preventDefault(),A.dataTransfer.dropEffect="move",!(i!=null&&i.type))return;let M=u({x:A.clientX,y:A.clientY}),$={id:"__sidebar_drag__",type:i.type,position:M,measured:{width:1,height:1},internals:{positionAbsolute:M}};T($,!1)},I=A=>{let M=A.relatedTarget;(!M||!A.currentTarget.contains(M))&&_()},R=(A,M)=>{A.preventDefault(),N(M)},S=(A,M,$)=>{var P,H;let V=[...$];if(A.parentId===M.id)return V=rc(A,M,V),V=tn(V),x(V);if(A.type==="LANE"){if(mo({parentId:M.id,nodes:V,excludeTypes:["LANE"]})){let U=st(M),Y=50,B=50;return V.map(W=>{var q,j;return W.id===A.id?v(y({},W),{position:{x:(q=m==null?void 0:m.x)!=null?q:U.x+Y,y:(j=m==null?void 0:m.y)!=null?j:U.y2+B}}):W})}let k=V.filter(U=>U.parentId===M.id).reduce((U,Y)=>{var B,W;return U+((W=(B=Y.measured)==null?void 0:B.height)!=null?W:0)},0),J={x:pe.HEADER_WIDTH,y:k};return V=V.map(U=>U.id===A.id?v(y({},U),{parentId:M.id,position:J,className:void 0}):v(y({},U),{className:void 0})),V=on(M.id,V),V}if(mo({parentId:M.id,nodes:V,includeTypes:["LANE"]})){let F;if(A.parentId){let z=l(A.parentId),{x:k,y:J}=lt(z);F={x:k+((P=A.position.x)!=null?P:0),y:J+((H=A.position.y)!=null?H:0)}}return V=V.map(z=>z.id===A.id?v(y({},z),{position:F!=null?F:z.position,parentId:void 0,className:void 0}):v(y({},z),{className:void 0})),V}let K=Ql(A,M);return V=V.map(F=>{if(F.id===A.id){let z=st(A),k=st(M);return z.y<k.y&&(K.y=0),z.x<k.x+pe.HEADER_WIDTH&&(K.x=pe.HEADER_WIDTH),v(y({},F),{parentId:M.id,position:K,className:void 0})}return v(y({},F),{className:void 0})}),V=tn(V),V},D=A=>{if(A.preventDefault(),!(i!=null&&i.type))return;if(!xt(i.type,c())){f(!1),s(null);return}let M=u({x:A.clientX,y:A.clientY}),$={width:oe[i.type].MIN_WIDTH,height:oe[i.type].MIN_HEIGHT},V=p(),L={id:String(V),type:i.type,position:M,measured:$,data:{label:i.type==="TASK"?Ir(e,a("bpmn.task.label.prefix")):"",variant:i.variant,attribute:i.attribute},selected:!0},G=v(y({},L),{internals:{positionAbsolute:M}}),K=v(y({},G),{measured:{width:1,height:1}}),P=b(),H=i.type==="LANE",F=P.filter(B=>H?B.type==="LANE"&&!B.parentId:B.type==="LANE"),z=en(K,F),k=[...e.map(B=>v(y({},B),{selected:!1})),L];z&&(k=S(G,z,k)),k=Ot(k),k=x(k),t(k),g();let J=A.dataTransfer.getData("sourceId"),U=d(),Y=U;if(J){let B={id:String(V+1),source:J,target:L.id},W=i.type==="ANNOTATION"?y(y({},B),ro):y(y({},B),Be);Y=U.concat(W),o(Y)}n("forceSave",{nodes:k,edges:Y}),f(!1),s(null)},X=async(A,M,$)=>{let V=[...e];$.forEach(L=>{let G=b(),K=l(L.id),P=L.type==="LANE",H=G.filter(z=>z.id!==L.id&&(P?z.type==="LANE"&&!z.parentId:z.type==="LANE")),F=en(K,H);if(F){V=S(K,F,V);return}L.parentId&&(V=te(L,V))}),V=w(V),V=Ot(V),V=x(V),t(V),h(V),E(null)},Z=(A,M)=>{E({x:M.position.x,y:M.position.y})},te=(A,M)=>{var K,P;let $=l(A.parentId),{x:V,y:L}=lt($),G={x:V+((K=A.position.x)!=null?K:0),y:L+((P=A.position.y)!=null?P:0)};return M=M.map(H=>H.id===A.id?v(y({},H),{position:G,parentId:void 0}):H),M=on(A.parentId,M),M};return{onDragOver:C,onDragLeave:I,onDrop:D,onNodeDrag:R,onNodeDragStart:Z,onNodeDragStop:X}};import{useReactFlow as Ey}from"@xyflow/react";import{useTranslation as by}from"@produto-lecom/lecom-ui";import{useEffect as _y}from"react";var Ty=30,Ny=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},vy=e=>!Ny(e.target),hd=({offset:e=Ty,saveHistory:t})=>{let{t:o}=by(),{getNodes:n,setNodes:r,getEdges:i,setEdges:s}=Ey(),{getNextId:a}=Ye();_y(()=>{let l=c=>{if(c.ctrlKey&&c.key.toLowerCase()==="d"&&vy(c)){c.preventDefault(),c.stopPropagation();let d=n(),u=i(),p=d.filter(x=>x.selected);if(!p.length)return;let f=new Map,h=[],g=p.filter(x=>xt(x.type,d));if(g.length===0)return;let m=u.filter(x=>g.some(w=>w.id===x.source)&&g.some(w=>w.id===x.target)),E=a(),_=g.map(x=>{var I;let w=String(E++);f.set(x.id,w);let C=v(y({},x),{id:w,selected:!0,position:{x:x.position.x+e,y:x.position.y+e}});if(x.type==="TASK"){let R=(I=x.data)==null?void 0:I.label,S=yo(R||o("bpmn.task.label.prefix"),[...d,...h]);C.data=v(y({},x.data),{label:S})}return h.push(C),C}),b=m.map(x=>v(y({},x),{id:String(E++),selected:!0,source:f.get(x.source)||x.source,target:f.get(x.target)||x.target})),T=[...d.map(x=>v(y({},x),{selected:!1})),..._],N=[...u.map(x=>v(y({},x),{selected:!1})),...b];r(T),s(N),t("forceSave",{nodes:T,edges:N})}};return document.addEventListener("keydown",l,!0),()=>{document.removeEventListener("keydown",l,!0)}},[n,r,i,s,a,e,o,t])};import{useEffect as wy,useRef as yd}from"react";import{useReactFlow as Ay}from"@xyflow/react";var Iy=20,Cy=50,fn={UP:"ArrowUp",DOWN:"ArrowDown",LEFT:"ArrowLeft",RIGHT:"ArrowRight"},Sy=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},xd=e=>{let{getNodes:t}=Ay(),{mode:o,isMoveTool:n}=Q(),r=yd(0),i=yd(new Map);wy(()=>{let s=a=>{if(o!=="edit"||!n||Sy(a.target)||!Object.values(fn).includes(a.key))return;let u=t().filter(_=>_.selected);if(u.length===0){i.current.clear();return}a.preventDefault();let p=Date.now(),f=p-r.current<500;r.current=p;let h=a.shiftKey?Cy:Iy,g=0,m=0;switch(a.key){case fn.UP:m=-h;break;case fn.DOWN:m=h;break;case fn.LEFT:g=-h;break;case fn.RIGHT:g=h;break}let E=u.map(_=>{let b=i.current.get(_.id);(!f||!b)&&(b={x:_.position.x,y:_.position.y});let T={x:b.x+g,y:b.y+m};return i.current.set(_.id,T),{id:_.id,dragging:!0,type:"position",position:T}});e&&e(E)};return window.addEventListener("keydown",s),()=>{window.removeEventListener("keydown",s)}},[t,e,o,n])};import{useReactFlow as Py}from"@xyflow/react";var bd={"start-event":"START_EVENT","end-event":"END_EVENT",task:"TASK","gateway-exclusive":"GATEWAY"},_d={"start-event":"","end-event":"",task:"","gateway-exclusive":"EXCLUSIVE"},Ed=(e,t)=>{if(!e){console.warn("Step not found");return}e=e.trim();let o=e.match(/(\<.*?\>)/)||[],n=e.match(/(\[.*?\])/)||[],r=e.match(/(\{.*?\})/)||[],i=e.match(/(--.*|\|.*?\|)/i)||[],s="",a="",l="";if(o.length){switch(o[1]){case"<start>":s="start-event";break;case"<end>":s="end-event";break}e=e.replace(o[1],"")}return n.length&&(s="task",a=n[1].replace(/\[|\]/g,""),e=e.replace(n[1],"")),r.length&&(s="gateway-exclusive",a=r[1].replace(/\{|\}/g,""),e=e.replace(r[1],"")),s||(s="task",a=e),i.length&&(l=i[1].replace(/(\||--)/g,""),e=e.replace(i[1],"")),e=e.trim(),t[e]||(t[e]={type:s,label:a}),{step:e,type:s,label:a,edgeLabel:l}},My=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 s=Ed(i[0],o),a=Ed(i[1],o);s&&a&&n.push({sourceId:s.step,targetId:a.step,label:s.edgeLabel||a.edgeLabel||""})}),{components:o,connections:n}},Td=e=>{let{components:t,connections:o}=My(e);return{nodes:t,edges:o}};var Nd=()=>{let{setNodes:e,setEdges:t,fitView:o}=Py(),{getNextId:n}=Ye();return{importFromLia:i=>{let s=typeof i=="string"?i:i.diagramXml||"",{nodes:a,edges:l}=Td(s),c=[],d=new Map,u=!1,p=n();for(let[m,E]of Object.entries(a)){let _=String(p++),b=bd[E.type],T=_d[E.type];b==="START_EVENT"&&(u=!0),d.set(m,_);let N=oe[b].MIN_WIDTH,x=oe[b].MIN_HEIGHT;c.push({id:_,type:b,data:{label:E.label||"",variant:T,attribute:""},position:{x:0,y:0},width:N,height:x,measured:{width:N,height:x}})}let f=[];for(let m of l){let E=v(y({},Be),{id:String(p++),source:d.get(m.sourceId)||m.sourceId,target:d.get(m.targetId)||m.targetId});f.push(E)}if(!u&&c.length>0){let m=String(p++),E={id:m,type:"START_EVENT",data:{label:"",variant:"",attribute:""},position:{x:0,y:0},width:oe.START_EVENT.MIN_WIDTH,height:oe.START_EVENT.MIN_HEIGHT,measured:{width:oe.START_EVENT.MIN_WIDTH,height:oe.START_EVENT.MIN_HEIGHT}};c.unshift(E);let _=c[1];if(_){let b=v(y({},Be),{id:String(p++),source:m,target:_.id});f.unshift(b)}}let{nodes:h,edges:g}=nc(c,f);e(h),t(g),o({padding:bo,minZoom:_o,maxZoom:To})}}};import{useEffect as Ly,useCallback as ky}from"react";var Ry={origin:"*",debug:!1};function vd(e,t=Ry){let{origin:o,debug:n}=t,r=ky((i,s)=>{let a={event:i,data:[i,{event:i,data:s}]};window.parent.postMessage(a,o||"*")},[o]);return Ly(()=>{let i=s=>{let a=s.data;if(!(a!=null&&a.event)||(a==null?void 0:a.data)===void 0)return;let{event:l,data:c}=a,d;if(Array.isArray(c)){let[,u]=c;d=u.data}else d=c;n&&(console.debug("[postMessage] received:",a),console.debug("[postMessage] eventData:",d)),l&&e[l]&&e[l](d)};return window.addEventListener("message",i),()=>window.removeEventListener("message",i)},[e,n]),{sendMessage:r}}import{useNodesInitialized as Dy}from"@xyflow/react";import{useEffect as wd}from"react";var Ad=()=>{let e=Dy(),{initialDiagram:t,setIsInitialized:o}=Q(),{importFromMxGraph:n}=No();wd(()=>{t&&n(t)},[t,n,o]),wd(()=>{if(!e)return;(async()=>{await bn(),o(!0)})()},[e,o])};import{useCallback as Id}from"react";import{useReactFlow as Oy}from"@xyflow/react";function Cd(){let{setTaskStatuses:e,clearTaskStatuses:t,calculateFlowPath:o}=St(),{getEdges:n}=Oy(),r=An(),i=Id(a=>{if(!(a!=null&&a.activities))return;e(a.activities);let l=a.activities.map(d=>d.diagramId),c=n();o(c,l),setTimeout(()=>{r()},0)},[e,o,n,r]),s=Id(()=>{t(),setTimeout(()=>{r()},0)},[t,r]);return{handleTasksStatus:i,handleClearTaskStatus:s}}import{useReactFlow as Vy}from"@xyflow/react";import{useCallback as ct,useState as Hy,useEffect as Sd}from"react";import{useDebouncedCallback as Gy}from"use-debounce";var By=500,Md=100,Pd=(e=!1)=>{let{getNodes:t,getEdges:o,setNodes:n,setEdges:r}=Vy(),[i,s]=Hy({history:[],currentStep:0}),{history:a,currentStep:l}=i,c=l>0,d=l<a.length-1,u=ct((N,x)=>{n(N[x].nodes),r(N[x].edges)},[n,r]),p=ct(()=>{if(l>0){let N=l-1;s(x=>v(y({},x),{currentStep:N})),u(a,N)}},[l,a,u]),f=ct(()=>{if(l<a.length-1){let N=l+1;s(x=>v(y({},x),{currentStep:N})),u(a,N)}},[a,l,u]),h=ct(N=>{s(x=>{let w=x.history[x.currentStep];if(w&&JSON.stringify(w)===JSON.stringify(N))return x;let R=[...x.history.slice(0,x.currentStep+1),N],S=R.length>Md?R.slice(R.length-Md):R;return{history:S,currentStep:S.length-1}})},[]),g=ct((N,x)=>{let w=N.map(I=>v(y({},I),{selected:!1,className:"",data:v(y({},I.data),{hasError:!1})})),C=x.map(I=>v(y({},I),{data:v(y({},I.data),{hasError:!1})}));return{nodes:Ot(w),edges:C}},[]),m=ct(()=>g(t(),o()),[t,o,g]),E=Gy(()=>{let N=m();h(N)},By),_=ct((N,x)=>{if(!e)return;if(a.length===0){let I=m();s({history:[I],currentStep:0})}if(N==="forceSave"){if(x){h(g(x.nodes,x.edges));return}E();return}N.some(I=>I.type==="select")||N.some(I=>I.type==="position"&&I.dragging)||E()},[e,E,a.length,m,h,g]);Sd(()=>{if(e&&a.length===0){let N=m();s({history:[N],currentStep:0})}},[e,a.length,m]);let b=ct(N=>{s({history:N||[],currentStep:0})},[]),T=ct(()=>{s({history:[],currentStep:0})},[]);return Sd(()=>{let N=x=>{(x.ctrlKey||x.metaKey)&&(x.shiftKey&&x.key.toLowerCase()==="z"?(x.preventDefault(),f()):x.key.toLowerCase()==="z"&&(x.preventDefault(),p()))};return document.addEventListener("keydown",N),()=>{document.removeEventListener("keydown",N)}},[p,f]),{history:a,undo:p,redo:f,canUndo:c,canRedo:d,saveHistory:_,resetHistory:b,clearHistory:T}};var Ld=()=>{let{t:e}=zy(),[t,o,n]=Wy([]),[r,i,s]=Fy([]),{getNode:a}=Uy(),{toast:l}=De(),c=$y(),{instanceId:d,isInitialized:u,setIsConnecting:p,setIsMultipleSelection:f,onElementClick:h}=Q(),{updateHelperLines:g,HelperLines:m}=nr(),{undo:E,redo:_,canUndo:b,canRedo:T,saveHistory:N}=Pd(u),{onNodeDrag:x,onDrop:w,onDragOver:C,onDragLeave:I,onNodeDragStop:R,onNodeDragStart:S}=gd({nodes:t,setNodes:o,setEdges:i,saveHistory:N}),{isValidConnection:D,onConnect:X,onReconnect:Z,onReconnectStart:te,onReconnectEnd:A,setReconnectingEdge:M,clearReconnectingEdge:$}=td({setEdges:i,saveHistory:N}),{handleValidationComplete:V,clearValidation:L,dismissValidationPanel:G,validateDiagram:K,getIsClearingValidation:P}=ud(),{importFromLia:H}=Nd(),{handleTasksStatus:F,handleClearTaskStatus:z}=Cd(),{clearPathEdges:k}=St(),{emitElementChanges:J,handleNodeChanges:U,handleEdgeChanges:Y}=Lr(),B=An();md({saveHistory:N}),hd({saveHistory:N}),Ad();let W=It(()=>{o([]),i([]),k(),setTimeout(B,0)},[o,i,k,B]);vd({LIA_CREATE_DIAGRAM:H,CLEAR_DIAGRAM:W,TASKS_STATUS:F,CLEAR_TASKS_STATUS:z});let{selectElements:q,clearSelection:j}=Et(),{importFromMxGraph:se,exportToMxGraph:ae}=No(),{configureElement:le,getConfigureElement:ce}=ur(),me=It(()=>t.length+r.length,[t,r]);Xy(()=>(tt.set(d,{importFromMxGraph:se,exportToMxGraph:ae,selectElements:q,clearSelection:j,configureElement:le,getConfigureElement:ce,getElementsCount:me,setReconnectingEdge:M,clearReconnectingEdge:$}),()=>{tt.delete(d)}),[d,se,ae,q,j,le,ce,me,M,$]);let ge=It((ye,ve)=>{if(ve.type!=="TASK"&&ve.type!=="GATEWAY")return;let Ze=ce(ve.id);Ze&&(h==null||h(Ze))},[ce,h]),ue=It((ye,ve)=>{if(ve.type!=="SEQUENCE_EDGE")return;let Ze=a(ve.source),qr=a(ve.target),{isFromStartEvent:fu,isGatewayToGateway:mu,isActiviyToAndGateway:gu}=wn(Ze,qr);if(!(!fu&&!mu&&!gu))return;let Qi=ce(ve.id);Qi&&(h==null||h(Qi))},[ce,a,h]),ie=It(ye=>{let ve=g(ye,t);n(ve),N(ye),P()||G(),U(ye)},[t,n,N,P,G,g,U]),ne=It(ye=>{s(ye),N(ye),P()||G(),Y(ye)},[s,N,P,G,Y]);xd(ie);let Te=It(({nodes:ye,edges:ve})=>{f(ye.length+ve.length>=2)},[f]);Yy({onChange:Te});let Pe=It(async({nodes:ye})=>ye.some(Ze=>Ze.type==="LANE"&&t.some(qr=>qr.parentId===Ze.id))?(l({variant:"error",title:e("validation.errors.title"),content:e("editor.toolbar.delete_pool_lane_error")}),!1):!0,[t,e,l]);return{nodes:t,setNodes:o,edges:r,setEdges:i,events:{isValidConnection:D,onConnect:X,onReconnect:Z,onReconnectStart:te,onReconnectEnd:A,onDrop:w,onDragOver:C,onDragLeave:I,onNodeDrag:x,onNodeDragStop:R,onNodeDragStart:S,onNodeClick:ge,onEdgeClick:ue,onDropCapture:()=>{N("forceSave"),J(),G()},onConnectStart:()=>{p(!0)},onConnectEnd:()=>{p(!1),G()},onSelectionEnd:()=>setTimeout(()=>c.setState({nodesSelectionActive:!1}),0),onNodesChange:ie,onEdgesChange:ne,onBeforeDelete:Pe},ui:{handleCloseValidationPanel:L},controls:{undo:E,redo:_,canUndo:b,canRedo:T},components:{HelperLines:m},actions:{saveHistory:N,selectElements:q,clearSelection:j,exportToMxGraph:ae,validateDiagram:K,handleValidationComplete:V,setReconnectingEdge:M,clearReconnectingEdge:$}}};import{jsx as kd}from"react/jsx-runtime";var Fi=({id:e,className:t})=>kd("marker",{id:e,className:O("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:kd("path",{d:"M 0 0 L 10 5 L 0 10 Z"})});import{jsx as Wi,jsxs as Ky}from"react/jsx-runtime";var Rd=()=>Wi("svg",{style:{position:"absolute",top:0,left:0},children:Ky("defs",{children:[Wi(Fi,{id:"sequence-edge-marker",className:"text-grey-500"}),Wi(Fi,{id:"sequence-edge-marker-highlighted",className:"text-blue-500"})]})});import{Tooltip as px,TooltipContent as fx,TooltipTrigger as mx,useTranslation as gx}from"@produto-lecom/lecom-ui";import{useKeyPress as Qd,useReactFlow as D0}from"@xyflow/react";import{Button as Br,Tooltip as zr,TooltipContent as Fr,TooltipTrigger as Wr,useTranslation as O0}from"@produto-lecom/lecom-ui";import{HandIcon as V0,ListCheckIcon as H0,MapIcon as G0,MousePointerIcon as B0}from"lucide-react";import{useCallback as Xi,useEffect as jd}from"react";import{Tooltip as m0,TooltipContent as g0,TooltipTrigger as h0,useTranslation as y0}from"@produto-lecom/lecom-ui";var mn=(b=>(b.START_EVENT="START_EVENT",b.END_EVENT="END_EVENT",b.TASK="TASK",b.SUBPROCESS="SUBPROCESS",b.GATEWAY="GATEWAY",b.LANE="LANE",b.ANNOTATION="ANNOTATION",b.CONNECTION="CONNECTION",b.INTERMEDIATE_EVENT="INTERMEDIATE_EVENT",b.ACTIVITY="ACTIVITY",b.PROCESS_INTERFACE="PROCESS_INTERFACE",b.WORKFLOW_INTERFACE="WORKFLOW_INTERFACE",b.VARIANT_ACTIVITY="VARIANT_ACTIVITY",b.AUTO_ACTIVITY="AUTO_ACTIVITY",b.DATA_STORE="DATA_STORE",b.DATA_OBJECT="DATA_OBJECT",b.DATA_OUTPUT="DATA_OUTPUT",b.DATA_INPUT="DATA_INPUT",b.MARKER="MARKER",b))(mn||{});import{Button as s0,useTranslation as a0}from"@produto-lecom/lecom-ui";import{useReactFlow as l0}from"@xyflow/react";var Dd=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 Od({columns:e=[],rows:t=[],fileName:o="report"}){if(!e.length||!t.length)return;let r="data:text/csv;charset=utf-8,"+[e,...t].map(s=>s.join(",")).join(`
43
- `),i=encodeURI(r);Dr(i,`${o}.csv`)}var Dr=(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 Vd(e){return e==null?void 0:e.replaceAll("&#xA;"," ")}var PL={START_EVENT:"START_EVENT",END_EVENT:"END_EVENT",TASK:"TASK",GATEWAY:"GATEWAY",ANNOTATION:"ANNOTATION"},Hd={script:"SCRIPT",subprocess:"SUBPROCESS"},Gd={"marker-loop":"LOOP"},Bd={complex:"COMPLEX",none:"EXCLUSIVE",exclusive:"EXCLUSIVE",parallel:"PARALLEL",inclusive:"EXCLUSIVE"};var Ft=({cell:e,type:t,variant:o="",attribute:n=""})=>{let{_attributes:r,mxGeometry:i}=e,{value:s,parent:a}=r,l=Number(i._attributes.width),c=Number(i._attributes.height),d=a==="1"?void 0:a;return{id:r.id,parentId:d,type:t,data:{label:s||"",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}}},Zy=e=>{let{subType:t,style:o}=e._attributes,n="imported";return["none"].includes(t)||(n="adapted"),e.mxGeometry._attributes.width=oe.START_EVENT.MIN_WIDTH,e.mxGeometry._attributes.height=oe.START_EVENT.MIN_HEIGHT,{node:Ft({cell:e,type:"START_EVENT"}),status:n,originalType:o}},Jy=e=>{let{subType:t,style:o}=e==null?void 0:e._attributes,n="imported";return["none"].includes(t)||(n="adapted"),e.mxGeometry._attributes.width=oe.END_EVENT.MIN_WIDTH,e.mxGeometry._attributes.height=oe.END_EVENT.MIN_HEIGHT,{node:Ft({cell:e,type:"END_EVENT"}),status:n,originalType:o}},Qy=(e,t)=>{let{id:o,subType:n,style:r}=e==null?void 0:e._attributes,i=Hd[n],s=t.get(o)||"",a=Gd[s]||"",l=a==="LOOP",c="imported";return!["script","none"].includes(n)&&!l&&(c="adapted"),e.mxGeometry._attributes.width=pt(e.mxGeometry._attributes.width||0,oe.TASK.MIN_WIDTH),e.mxGeometry._attributes.height=pt(e.mxGeometry._attributes.height||0,oe.TASK.MIN_HEIGHT),{node:Ft({cell:e,type:"TASK",variant:i,attribute:a}),status:c,originalType:r}},jy=e=>{let{style:t,subType:o}=e==null?void 0:e._attributes,n=Bd[o],r=["none","inclusive","event-based"],i="imported";return r.includes(o)&&(i="adapted"),e.mxGeometry._attributes.width=oe.GATEWAY.MIN_WIDTH,e.mxGeometry._attributes.height=oe.GATEWAY.MIN_HEIGHT,{node:Ft({cell:e,type:"GATEWAY",variant:n}),status:i,originalType:t}},e0=e=>{let{style:t}=e==null?void 0:e._attributes;return{node:Ft({cell:e,type:"LANE"}),status:"imported",originalType:t}},t0=e=>{let{style:t}=e==null?void 0:e._attributes;return e.mxGeometry._attributes.width=pt(e.mxGeometry._attributes.width||0,oe.ANNOTATION.MIN_WIDTH),e.mxGeometry._attributes.height=pt(e.mxGeometry._attributes.height||0,oe.ANNOTATION.MIN_HEIGHT),{node:Ft({cell:e,type:"ANNOTATION"}),status:"imported",originalType:t}},zd=e=>{let{style:t}=e==null?void 0:e._attributes;return e.mxGeometry._attributes.width=oe.UNSUPPORTED.MIN_WIDTH,e.mxGeometry._attributes.height=oe.UNSUPPORTED.MIN_HEIGHT,{node:Ft({cell:e,type:"UNSUPPORTED"}),status:"unsupported",originalType:t}},Fd=(e,t)=>{let{id:o,source:n,target:r,value:i}=e._attributes;return v(y({},Be),{id:o,source:t.get(n)||n,target:t.get(r)||r,data:{label:i||""}})},Wd={TASK:Qy,GATEWAY:jy,START_EVENT:Zy,END_EVENT:Jy,LANE:e0,ANNOTATION:t0};var o0=e=>{let t=new Map,o=Object.values(mn),n=[],r=new Map;e.forEach(a=>{var c;let l=(c=a._attributes)==null?void 0:c.type;if(l==="MARKER"){r.set(a._attributes.parent,a._attributes.style);return}if(o.includes(l)){n.push(a);return}});let i=[],s=[];for(let a of n){let{type:l}=a._attributes,c=Wd[l]||zd,{node:d,status:u,originalType:p}=c(a,r);s.push(d),i.push({originalType:p,type:d.type,variant:d.data.variant,value:Vd(d.data.label),status:u})}return{nodes:s,governanceIdToNodeIdMap:t,summary:i}},n0=(e,t)=>e.filter(r=>{var i;return(i=r._attributes)==null?void 0:i.edge}).map(r=>Fd(r,t)),r0=e=>{let{mxGraphModel:t}=e,{nodes:o,governanceIdToNodeIdMap:n,summary:r}=o0(t.root.mxCell),i=n0(t.root.mxCell,n);return{nodes:o,edges:i,summary:r}},i0=async e=>{let t=await Dd(e),o=vr(t);if(!o)throw new Error("EMPTY_FILE");let{metadata:n,mxGraphModel:r}=o.modeler||{},i=(n==null?void 0:n.app)&&(n==null?void 0:n.diagramType)&&(n==null?void 0:n.version),s=r==null?void 0:r.root;if(!i||!s)throw new Error("INVALID_FILE");if(!Object.keys(r.root.mxCell||{}).length)throw new Error("CONTAIN_NO_CELLS");return{metadata:n,mxGraphModel:r}},Yd=async e=>{try{let t=await i0(e),{nodes:o,edges:n,summary:r}=r0(t)||{};return{nodes:o,edges:n,summary:r}}catch(t){throw t}};import{jsx as c0}from"react/jsx-runtime";var Ud=()=>{let{t:e}=a0(),{toast:t}=De(),{setNodes:o,setEdges:n,fitView:r}=l0(),i=a=>{let l=[e("adapter.governance.report.columns.type"),e("adapter.governance.report.columns.value"),e("adapter.governance.report.columns.status")],c=a.map(d=>[d.originalType,d.value,e(`adapter.governance.report.status.${d.status.toLowerCase()}`)]);t({variant:"warning",content:e("adapter.governance.success.incompatible_cells"),duration:1e3*60*1,action:c0(s0,{size:"small",variant:"ghost",onClick:()=>Od({columns:l,rows:c,fileName:"governance-imported-cells"}),children:e("adapter.governance.action.download")})})};return{importFromGovernance:async a=>{try{let{nodes:l,edges:c,summary:d}=await Yd(a);if(o(p=>p.concat(l)),n(p=>p.concat(c)),r({padding:bo,minZoom:_o,maxZoom:To}),d.some(p=>p.status==="unsupported")){i(d);return}t({variant:"success",content:e("adapter.governance.success.default")})}catch(l){let c=l instanceof Error?l.message:"DEFAULT";t({variant:"error",content:e(`adapter.governance.error.${c}`)})}}}};import{Button as d0}from"@produto-lecom/lecom-ui";import{useRef as u0}from"react";import{Fragment as p0,jsx as $d,jsxs as f0}from"react/jsx-runtime";var Xd=a=>{var l=a,{children:e,accept:t="*",multiple:o=!1,disabled:n=!1,onClick:r,onFilesSelected:i}=l,s=Je(l,["children","accept","multiple","disabled","onClick","onFilesSelected"]);let c=u0(null),d=p=>{let f=p.target.files;f!=null&&f.length&&i(f),c.current&&(c.current.value="")};return f0(p0,{children:[$d(d0,v(y({disabled:n,onClick:p=>{var f;(f=c.current)==null||f.click(),r==null||r(p)}},s),{children:e})),$d("input",{type:"file",ref:c,className:"sr-only",accept:t,multiple:o,disabled:n,onChange:d})]})};import{jsx as Or,jsxs as x0}from"react/jsx-runtime";var Kd=({disabled:e=!1})=>{let{t}=y0(),{toast:o}=De(),{importFromGovernance:n}=Ud(),r=()=>{if(e){o({variant:"error",content:t("adapter.governance.error.ALREADY_INITIALIZED")});return}},i=s=>{let a=s[0];if(!a){o({variant:"error",content:t("adapter.governance.error.NO_FILE")});return}n(a)};return x0(m0,{children:[Or(h0,{asChild:!0,children:Or(Xd,{className:"[&>svg]:size-7 p-0",variant:"ghost",size:"small",color:"grey",iconButton:!0,accept:".mdr",disabled:e,onClick:r,onFilesSelected:i,children:Or(cs,{})})}),Or(g0,{color:"black",children:t("editor.controls.actions.import_governance")})]})};import{jsx as E0}from"react/jsx-runtime";var Yi=({shortcut:e})=>E0("span",{className:"min-h-7.5 inline-flex justify-center items-center py-0.5 px-1.5 bg-grey-100 border border-grey-300 font-mono text-gray-800 shadow-lg rounded-md text-grey-900",children:e});import{Button as w0,DropdownMenu as A0,DropdownMenuContent as I0,DropdownMenuItem as $i,DropdownMenuTrigger as C0,Tooltip as Vr,TooltipContent as Hr,TooltipTrigger as Gr,useTranslation as S0}from"@produto-lecom/lecom-ui";import{FileCodeIcon as M0,FileImageIcon as P0,FolderOutputIcon as L0,PrinterIcon as k0}from"lucide-react";import{useState as R0}from"react";import{useTranslation as b0}from"@produto-lecom/lecom-ui";import{useReactFlow as _0}from"@xyflow/react";import{toPng as qd,toSvg as T0}from"html-to-image";import{useState as N0}from"react";var v0=3,Ui="diagram",Zd=()=>{let{t:e}=b0(),{toast:t}=De(),{getNodes:o}=_0(),{clearSelection:n}=Et(),[r,i]=N0({png:!1,html:!1,print:!1}),s=()=>{let{x:u,y:p,width:f,height:h}=sc(o());return{width:f,height:h,style:{width:`${f}px`,height:`${h}px`,transform:`translate(${-u}px, ${-p}px)`}}},a=async(u,p)=>{i(v(y({},r),{[p]:!0})),await n();try{let f=ic();if(!f)throw new Error("Flow element not found");let h=s();return await u(f,h)}catch(f){t({content:e("editor.controls.actions.export.feedback.error"),variant:"error"})}finally{i(v(y({},r),{[p]:!1}))}};return{exportAsPng:async(u=Ui)=>{await a(async(p,f)=>{let h=await qd(p,v(y({},f),{backgroundColor:"#fcfcfc"}));Dr(h,`${u}.png`)},"png")},exportAsHtml:async(u=Ui)=>{await a(async(p,f)=>{let h=await T0(p,v(y({},f),{backgroundColor:"#fcfcfc"})),g=`
39
+ </mxGraphModel>`,pc=(e,t)=>{if(!e.length&&!t.length)return rn;let o=[...e.map(r=>r.id),...t.map(r=>r.id)];return Math.max(...o.map(r=>Number(r)))};var Yg=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=Jl[a],l=s==null?void 0:s(i,n);if(!l){console.warn(`Node ${a} not supported`);continue}r.push(l)}return r},Fg=(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=Ql(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},Wg=(e,t)=>{let o=[];return e.forEach(n=>{var a,s;let r=(s=(a=ec)[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=tc(n,t);o.push(l)}}),o},Xg=(e,t)=>{let o=[];return e.forEach(n=>{let r=jl(n,t);o.push(r)}),o},fc=(e=[],t=[],o)=>{let n=Wg(e,o),r=Xg(t,e),i={mxGraphModel:{root:{_attributes:{version:"1.1",lastId:o},mxCell:[{_attributes:{id:"0"}},{_attributes:{id:"1",parent:"0"}},...n,...r]}}};return Xl(JSON.stringify(i),{compact:!0,spaces:0})},mc=async e=>{var c,d,u,f,p;let t=await Cr(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)||rn),r=Yg(o),i=Fg(o,r),a=on(r),{nodes:s,edges:l}=rc(a,i);return{lastElementId:n,edges:l,nodes:Gt(s)}};import{Position as Tc,useConnection as vh,useReactFlow as wh}from"@xyflow/react";import{useCallback as Hi}from"react";import{Handle as gc,useReactFlow as Ug}from"@xyflow/react";import{jsx as hc}from"react/jsx-runtime";var ie=i=>{var a=i,{type:e,position:t,className:o,nodeType:n}=a,r=je(a,["type","position","className","nodeType"]);let s=n==="TASK";return hc(gc,_({type:e,position:t,className:O("size-2.5 border border-grey-400 bg-white relative",{"before:content-[''] before:absolute before:inset-[-16px] before:bg-transparent":s,"before:content-[''] before:absolute before:inset-[-4px] before:bg-transparent":!s},o)},r))},Le=s=>{var l=s,{nodeId:e,nodeType:t,gatewayVariant:o,type:n,position:r,className:i}=l,a=je(l,["nodeId","nodeType","gatewayVariant","type","position","className"]);let{getEdges:c,getNodes:d}=Ug(),f=(()=>{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(m=>{if(m.source!==e)return!1;let E=g.find(y=>y.id===m.target);return(E==null?void 0:E.type)!=="ANNOTATION"}).length>=1}return!1})();return hc(gc,_({type:n,position:r,className:O("size-2.5 border border-grey-400 bg-white transition-all duration-200 relative",{"before:content-[''] before:absolute before:inset-[-16px] before:bg-transparent":t==="TASK","before:content-[''] before:absolute before:inset-[-4px] before:bg-transparent":t!=="TASK","opacity-50 cursor-not-allowed pointer-events-none":f,"hover:border-grey-500":!f},i),style:{pointerEvents:f?"none":"auto"}},a))};import{NodeResizer as $g,useReactFlow as Kg}from"@xyflow/react";import{orderBy as qg}from"lodash";import{jsx as Zg}from"react/jsx-runtime";var xo=n=>{var r=n,{nodeId:e,isVisible:t}=r,o=je(r,["nodeId","isVisible"]);let{getNode:i,getNodes:a,setNodes:s}=Kg(),{isMultipleSelection:l}=Q(),c=({width:u,height:f})=>{if(!e)return;let p=i(e);if((p==null?void 0:p.type)!=="LANE")return;let g=[...a()],h=!p.parentId,m=h?p.id:p.parentId,E=g.filter(T=>T.type==="LANE"&&T.parentId===m);if(!E.length)return;let y=qg(E,["position.y"]),x=0;y.forEach((T,N)=>{var C,I;let b=N===y.length-1,w=(I=(C=T.measured)==null?void 0:C.height)!=null?I:0;g=g.map(k=>{if(k.id===T.id){let S=h?u-me.HEADER_WIDTH:u,R=v(_({},k),{width:S,measured:v(_({},k.measured),{width:S}),position:v(_({},k.position),{y:x})});return b&&h&&(R.height=f-x),R}return k}),x+=w}),g=g.map(T=>{if(T.id===m){let N=h?u:u+me.HEADER_WIDTH;return v(_({},T),{width:N,height:h?f:x,measured:{width:N,height:h?f:x}})}return T}),s(g)};return Zg($g,_({nodeId:e,handleClassName:"size-1.5 bg-blue-400 relative before:content-[''] before:absolute before:w-5 before:h-5 before:left-1/2 before:top-1/2 before:-translate-x-1/2 before:-translate-y-1/2 before:cursor-[inherit]",lineClassName:"border-blue-400/90 border-dashed",isVisible:!l&&t,onResizeEnd:(u,f)=>c(f)},o))};import{NodeToolbar as mh,useReactFlow as gh}from"@xyflow/react";import{Button as hh,Tooltip as yh,TooltipContent as xh,TooltipTrigger as Eh,useTranslation as bh}from"@produto-lecom/lecom-ui";import{useCallback as Vi,useEffect as _h,useRef as Mr,useState as Th}from"react";import{create as Jg}from"zustand";var Eo=Jg(e=>({draggableNode:null,setDraggableNode:t=>{e({draggableNode:t})}}));import{useEffect as Qg,useState as jg}from"react";var yc=(e,t=!1)=>{let[o,n]=jg({width:0,height:0});return Qg(()=>{if(e.current&&t){let r=e.current.getBoundingClientRect();n({width:r.width,height:r.height})}},[t,e]),{dimensions:o}};import{Position as sn,useReactFlow as eh}from"@xyflow/react";import{useMemo as th}from"react";var oh=120,nh=12,xc=(e,t=!1,o)=>{let{getNode:n,getViewport:r}=eh(),{instanceId:i}=Q();return th(()=>{var p,g;if(!t)return{position:sn.Right,align:"start"};let a=n(e);if(!a)return{position:sn.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:sn.Right,align:"start"};let u=(o==null?void 0:o.width)||oh;return{position:l+c+u+nh>d?sn.Left:sn.Right}},[i,e,t,o,n,r])};import{useNodesData as rh,useReactFlow as ih}from"@xyflow/react";import{Button as Ec,DropdownMenu as sh,DropdownMenuContent as ah,DropdownMenuGroup as lh,DropdownMenuItem as ch,DropdownMenuLabel as dh,DropdownMenuTrigger as uh,Tooltip as Ri,TooltipContent as Di,TooltipTrigger as Oi,useTranslation as ph}from"@produto-lecom/lecom-ui";import{WrenchIcon as fh}from"lucide-react";import{jsx as Se,jsxs as Bt}from"react/jsx-runtime";var bc=({nodeId:e})=>{let{t}=ph(),{updateNodeData:o,getEdges:n,getNode:r}=ih(),i=rh(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 Bt(sh,{children:[Bt(Ri,{children:[Se(Oi,{asChild:!0,children:Se(uh,{asChild:!0,children:Se(Ec,{variant:"ghost",color:"grey",size:"small",iconButton:!0,children:Se(fh,{})})})}),Se(Di,{color:"black",children:t("bpmn.task.menu.title")})]}),Bt(ah,{align:"start",className:"w-60 bg-white text-grey-600",children:[Bt(dh,{className:"flex items-center gap-1",children:[Se("div",{className:"flex-1 body-medium-500",children:t("bpmn.task.menu.title")}),Se("div",{className:"flex items-center gap-1",children:Object.entries(wn).map(([u,f])=>{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 Bt(Ri,{children:[Se(Oi,{asChild:!0,children:Se(Ec,{variant:"ghost",color:"grey",size:"small",iconButton:!0,disabled:p,className:O({"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:Se(f.icon,{className:"stroke-inherit"})})}),h&&Se(Di,{color:"black",children:h})]},u)})})]}),Se(lh,{children:Bt(Ri,{children:[Se(Oi,{asChild:!0,children:Se("div",{className:O({"cursor-not-allowed":s}),children:Bt(ch,{className:O({"bg-grey-100 text-blue-500":(i==null?void 0:i.data.variant)==="SCRIPT","opacity-50":s}),disabled:s,onClick:()=>c("SCRIPT"),children:[Se(vn.SCRIPT.icon,{className:"stroke-current"}),t(`bpmn.task.variant.${"SCRIPT".toLowerCase()}`)]})})}),s&&Se(Di,{color:"black",children:t("editor.task_menu.script_not_allowed_when_connected_to_end")})]})})]})]})};import{jsx as xe,jsxs as _c}from"react/jsx-runtime";var zt={START_EVENT:{type:"START_EVENT",icon:So,label:"bpmn.start_event.variant.default"},END_EVENT:{type:"END_EVENT",icon:qt,label:"bpmn.end_event.variant.default"},TASK:{type:"TASK",icon:So,label:"bpmn.task.variant.default"},ANNOTATION:{type:"ANNOTATION",icon:bn,label:"bpmn.annotation.variant.default"}},Nh={EXCLUSIVE:{type:"GATEWAY",variant:"EXCLUSIVE",icon:Jt,label:"bpmn.gateway.variant.exclusive"},PARALLEL:{type:"GATEWAY",variant:"PARALLEL",icon:Qt,label:"bpmn.gateway.variant.parallel"},COMPLEX:{type:"GATEWAY",variant:"COMPLEX",icon:Zt,label:"bpmn.gateway.variant.complex"}},He=({nodeId:e,nodeType:t,nodeVariant:o})=>{let n=Mr(null),r=Mr(null),{t:i}=bh(),{setDraggableNode:a}=Eo(),{getEdges:s,getNodes:l,getNode:c}=gh(),{setIsDragging:d,mode:u,isConnecting:f,isDragging:p,isMultipleSelection:g}=Q(),h=c(e),m=!!(h!=null&&h.selected)&&!h.dragging&&!f&&!p&&!g,{dimensions:E}=yc(n,m),{position:y}=xc(e,m,E),[x,T]=Th(void 0),N=l(),b=s(),w=o==="SUBPROCESS",C=Mr(null),I=Mr(!1),k=Vi(()=>{C.current!==null&&(clearTimeout(C.current),C.current=null),I.current=!1,d(!1),a(null),T(void 0)},[d,a]);_h(()=>{let P=H=>{I.current&&H.buttons===0&&k()};return document.addEventListener("dragend",k),document.addEventListener("mousemove",P),()=>{document.removeEventListener("dragend",k),document.removeEventListener("mousemove",P)}},[k]);let S=Vi((P,H)=>{I.current=!0,d(!1),a({type:H.type,variant:H.variant,attribute:H.attribute,icon:H.icon}),H.icon&&T(xe(H.icon,{})),P.dataTransfer.effectAllowed="move",P.dataTransfer.setData("sourceId",e),r.current&&P.dataTransfer.setDragImage(r.current,10,10),C.current=setTimeout(()=>{C.current=null,d(!0)},100)},[e,a,d]),R=Vi(()=>{k()},[k]),U=[{component:xe(gr,{elementId:e})}],K=()=>{if(u==="view")return[];let P=!b.some(H=>{var Y;return H.source===e&&((Y=N.find(z=>z.id===H.target))==null?void 0:Y.type)!=="ANNOTATION"});return[{component:xe(Ht,{nodeId:e,disabled:!P,tooltipMessage:P?void 0:i("editor.toolbar.start_event_limit_reached")})},zt.TASK,zt.ANNOTATION,...U]},ee=()=>u==="view"?[{component:xe(Tt,{elementId:e})}]:[{component:xe(Tt,{elementId:e})},...w?[]:[{component:xe(bc,{nodeId:e})}],{component:xe(Ht,{nodeId:e})},zt.TASK,...Object.values(Nh),...U],A=()=>u==="view"?[{component:xe(Tt,{elementId:e})}]:[{component:xe(Tt,{elementId:e})},{component:xe(Ht,{nodeId:e})},zt.TASK,zt.ANNOTATION,...U],M=()=>u==="view"?[]:[{component:xe(Ht,{nodeId:e})},zt.ANNOTATION,...U],$=()=>u==="view"?[]:[{component:xe(Ht,{nodeId:e})},zt.ANNOTATION,...U],V=()=>u==="view"?[]:[{component:xe(Ht,{nodeId:e})},...U],L=()=>u==="view"?[]:[...U],q=(P=>{switch(P){case"START_EVENT":return K();case"TASK":return ee();case"GATEWAY":return A();case"END_EVENT":return M();case"LANE":return $();case"ANNOTATION":return V();case"UNSUPPORTED":return L();default:return[]}})(t);if(!(q.length===0||u==="readonly"))return _c(mh,{position:y,align:"start",className:"-top-8",isVisible:m,children:[xe("div",{ref:n,className:"flex items-center gap-1 px-3 py-2 bg-white rounded-sm shadow-md",children:q.map((P,H)=>{if(P.component)return xe("div",{children:P.component},H);let Y={sourceNodeType:t,targetNodeType:P.type,sourceNodeId:e,nodes:N,edges:b},z=vl(Y),D={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")},J=z.shouldDisable&&z.reason?D[z.reason]||i(P.label):i(P.label)||"";return _c(yh,{children:[xe(Eh,{asChild:!0,children:xe(hh,{variant:"ghost",color:"grey",size:"small",iconButton:!0,draggable:!z.shouldDisable,disabled:z.shouldDisable,className:z.shouldDisable?"opacity-50 cursor-not-allowed":"",onDragStart:z.shouldDisable?void 0:X=>S(X,P),onDragEnd:z.shouldDisable?void 0:R,children:P.icon&&xe(P.icon,{size:16})})}),xe(xh,{color:"black",children:J})]},H)})}),xe("div",{ref:r,className:"absolute w-0 h-0 top-0 left-0 z-[-1] bg-transparent",children:x})]})};import{jsx as an,jsxs as Ah}from"react/jsx-runtime";var Nc=({id:e,data:t,selected:o,dragging:n})=>{let{updateNodeData:r,setNodes:i}=wh(),{inProgress:a,fromNode:s}=vh(),{mode:l}=Q(),c=a&&(s==null?void 0:s.id)!==e,d=Hi(p=>{let y=p.split(`
40
+ `),x=y.reduce((w,C)=>Math.max(w,C.length),0),T=y.length,N=Math.max(fo.MIN_WIDTH,x*7+32),b=Math.max(fo.MIN_HEIGHT,T*20+24);i(w=>w.map(C=>C.id===e?v(_({},C),{width:N,height:b,style:v(_({},C.style),{width:N,height:b})}):C))},[e,i]),u=Hi(p=>{r(e,{label:p}),d(p)},[e,r,d]),f=Hi(p=>{d(p)},[d]);return Ah("div",{className:O("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:[an(Ie,{value:t.label,className:"m-1 text-grey-600 text-left",onChange:u,onInput:f}),an(He,{nodeId:e,nodeType:"ANNOTATION"}),l==="edit"&&an(xo,{minWidth:fo.MIN_WIDTH,minHeight:fo.MIN_HEIGHT,isVisible:!n&&o}),!a&&an(ie,{type:"source",position:Tc.Right}),(!a||c)&&an(ie,{type:"target",position:Tc.Left,className:O({"annotation-handle":c})})]})};import{Position as wt,useConnection as Ih,useReactFlow as Ch}from"@xyflow/react";import{useState as Sh}from"react";import{Fragment as vc,jsx as Fe,jsxs as Gi}from"react/jsx-runtime";var wc=({id:e,data:t,selected:o})=>{let{updateNodeData:n}=Ch(),{inProgress:r,fromNode:i}=Ih(),{reconnectingEdgeId:a}=Q(),[s,l]=Sh(!1),c=r&&(i==null?void 0:i.id)!==e||!!a,d=p=>{n(e,{label:p})},u=()=>{l(!0)},f=()=>{l(!1)};return Gi("div",{className:"relative",onDoubleClick:u,children:[Fe(qt,{className:O("size-9 hover:stroke-[#d33b3b] transition-colors duration-75",{"stroke-blue-500 hover:stroke-blue-600":o,"stroke-red-500 hover:stroke-red-600 drop-shadow-[0_0_3px_rgba(255,0,0,0.5)] fill-red-100":t.hasError})}),Fe("div",{className:"absolute top-10 left-1/2 -translate-x-1/2 max-w-80 w-max",children:Fe(Ie,{value:t.label,isEditing:s,onBlur:f,onChange:d})}),Fe(He,{nodeId:e,nodeType:"END_EVENT"}),(!r||c)&&Gi(vc,{children:[Fe(ie,{type:"target",position:wt.Left,id:"left",className:O({"event-handle":c})}),Fe(ie,{type:"target",position:wt.Right,id:"right",className:O({"event-handle":c})}),Fe(ie,{type:"target",position:wt.Top,id:"top",className:O({"event-handle":c})}),Fe(ie,{type:"target",position:wt.Bottom,id:"bottom",className:O({"event-handle":c})})]}),!r&&Gi(vc,{children:[Fe(ie,{type:"source",position:wt.Left,id:"left"}),Fe(ie,{type:"source",position:wt.Right,id:"right"}),Fe(ie,{type:"source",position:wt.Top,id:"top"}),Fe(ie,{type:"source",position:wt.Bottom,id:"bottom"})]})]})};import{Position as At,useConnection as Mh,useReactFlow as Ph}from"@xyflow/react";import{useCallback as Lh,useState as kh}from"react";import{Fragment as Ac,jsx as We,jsxs as Bi}from"react/jsx-runtime";var Ic=({id:e,data:t,selected:o})=>{let n=ci[t.variant].icon,{updateNodeData:r}=Ph(),{inProgress:i,fromNode:a}=Mh(),{reconnectingEdgeId:s}=Q(),[l,c]=kh(!1),d=i&&(a==null?void 0:a.id)!==e||!!s,u=Lh(g=>{r(e,{label:g})},[e,r]),f=()=>{c(!0)},p=()=>{c(!1)};return Bi("div",{className:"relative",onDoubleClick:f,children:[We(n,{className:O("size-14 stroke-1 stroke-grey-400 hover:stroke-grey-500 transition-colors duration-75",{"stroke-blue-500 hover:stroke-blue-600":o,"stroke-red-500 hover:stroke-red-600 drop-shadow-[0_0_3px_rgba(255,0,0,0.5)]":t.hasError})}),We("div",{className:"absolute top-14 left-1/2 -translate-x-1/2 max-w-80 w-max",children:We(Ie,{value:t.label,isEditing:l,onBlur:p,onChange:u})}),We(He,{nodeId:e,nodeType:"GATEWAY"}),(!i||d)&&Bi(Ac,{children:[We(ie,{type:"target",position:At.Left,id:"left",className:O({"gateway-handle":d})}),We(ie,{type:"target",position:At.Right,id:"right",className:O({"gateway-handle":d})}),We(ie,{type:"target",position:At.Top,id:"top",className:O({"gateway-handle":d})}),We(ie,{type:"target",position:At.Bottom,id:"bottom",className:O({"gateway-handle":d})})]}),!i&&Bi(Ac,{children:[We(Le,{type:"source",position:At.Left,id:"left",nodeId:e,nodeType:"GATEWAY",gatewayVariant:t.variant}),We(Le,{type:"source",position:At.Right,id:"right",nodeId:e,nodeType:"GATEWAY",gatewayVariant:t.variant}),We(Le,{type:"source",position:At.Top,id:"top",nodeId:e,nodeType:"GATEWAY",gatewayVariant:t.variant}),We(Le,{type:"source",position:At.Bottom,id:"bottom",nodeId:e,nodeType:"GATEWAY",gatewayVariant:t.variant})]})]})};import{useNodesData as WC,useReactFlow as XC}from"@xyflow/react";import{Button as $C,DropdownMenu as KC,DropdownMenuContent as qC,DropdownMenuGroup as ZC,DropdownMenuItem as JC,DropdownMenuLabel as QC,DropdownMenuTrigger as jC,Tooltip as eS,TooltipContent as tS,TooltipTrigger as oS,useTranslation as nS}from"@produto-lecom/lecom-ui";import{WrenchIcon as iS}from"lucide-react";import{jsx as cS,jsxs as dS}from"react/jsx-runtime";import{Position as It,useConnection as Rh,useReactFlow as Dh}from"@xyflow/react";import{useState as Oh}from"react";import{Fragment as Cc,jsx as Xe,jsxs as zi}from"react/jsx-runtime";var Sc=({id:e,data:t,selected:o})=>{let{updateNodeData:n}=Dh(),{inProgress:r,fromNode:i}=Rh(),{reconnectingEdgeId:a}=Q(),[s,l]=Oh(!1),c=r&&(i==null?void 0:i.id)!==e||!!a,d=p=>{n(e,{label:p})},u=()=>{l(!0)},f=()=>{l(!1)};return zi("div",{className:"relative",onDoubleClick:u,children:[Xe(Tn,{className:O("size-9 hover:stroke-[#54890b] transition-colors duration-75",{"stroke-blue-500 hover:stroke-blue-600":o,"stroke-red-500 hover:stroke-red-600 drop-shadow-[0_0_3px_rgba(255,0,0,0.5)] fill-red-100":t.hasError})}),Xe("div",{className:"absolute top-10 left-1/2 -translate-x-1/2 max-w-80 w-max",children:Xe(Ie,{value:t.label,isEditing:s,onBlur:f,onChange:d})}),Xe(He,{nodeId:e,nodeType:"START_EVENT"}),(!r||c)&&zi(Cc,{children:[Xe(ie,{type:"target",position:It.Left,id:"left",className:O({"event-handle":c})}),Xe(ie,{type:"target",position:It.Right,id:"right",className:O({"event-handle":c})}),Xe(ie,{type:"target",position:It.Top,id:"top",className:O({"event-handle":c})}),Xe(ie,{type:"target",position:It.Bottom,id:"bottom",className:O({"event-handle":c})})]}),!r&&zi(Cc,{children:[Xe(Le,{type:"source",position:It.Left,id:"left",nodeId:e,nodeType:"START_EVENT"}),Xe(Le,{type:"source",position:It.Right,id:"right",nodeId:e,nodeType:"START_EVENT"}),Xe(Le,{type:"source",position:It.Top,id:"top",nodeId:e,nodeType:"START_EVENT"}),Xe(Le,{type:"source",position:It.Bottom,id:"bottom",nodeId:e,nodeType:"START_EVENT"})]})]})};import{useTranslation as Gh}from"@produto-lecom/lecom-ui";import{Position as Ct,useConnection as Bh,useReactFlow as zh}from"@xyflow/react";import{useCallback as Lr}from"react";var ln=60,Pr=(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<=ln?i:i.substring(0,ln).trim()},bo=(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>ln&&(n=n.substring(0,ln).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=ln-l.length,u=`${r.substring(0,c).trim()}${l}`;if(!o.has(u))return u;i++}return n};import{jsx as Mc,jsxs as Vh}from"react/jsx-runtime";var Pc=e=>Vh("svg",v(_({width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",xmlns:"http://www.w3.org/2000/svg"},e),{children:[Mc("circle",{cx:"12",cy:"12",r:"10",fill:"#10B981"}),Mc("path",{d:"M7 12L10 15L17 8",stroke:"white",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"})]}));import{jsx as Lc}from"react/jsx-runtime";var kc=e=>Lc("svg",v(_({width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",xmlns:"http://www.w3.org/2000/svg"},e),{children:Lc("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 Rc,jsxs as Hh}from"react/jsx-runtime";var Dc=e=>Hh("svg",v(_({width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",xmlns:"http://www.w3.org/2000/svg"},e),{children:[Rc("circle",{cx:"12",cy:"12",r:"10",fill:"#EF4444"}),Rc("path",{d:"M8 8L16 16M8 16L16 8",stroke:"white",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"})]}));import{Fragment as kr,jsx as ge,jsxs as cn}from"react/jsx-runtime";var Yh={APROVADO:Pc,EM_ANDAMENTO:kc,REJEITADO:Dc},Yi={APROVADO:"border-green-500 border-[3px] border-solid",EM_ANDAMENTO:"border-turquoise-400 border-[3px] border-solid",REJEITADO:"border-red-500 border-[3px] border-solid",default:"border-grey-400 border-2 border-solid",error:"border-red-500 border-[3px] shadow-[0_0_5px_rgba(255,0,0,0.5)]"},Oc=({id:e,data:t,selected:o,dragging:n})=>{let{t:r}=Gh(),{toast:i}=Ve(),{updateNodeData:a,getNodes:s,setNodes:l}=zh(),{inProgress:c,fromNode:d}=Bh(),{mode:u,onSubprocessValidationClick:f,reconnectingEdgeId:p}=Q(),{getTaskStatus:g}=Lt(),h=c&&(d==null?void 0:d.id)!==e||!!p,m=g(e),E=t.variant==="SUBPROCESS",y=!!t.variant&&!E||!!m,x=!!t.attribute||E,T=Lr(U=>{let M=y||x?80:40,$=U.split(`
41
+ `),V=$.reduce((P,H)=>Math.max(P,H.length),0),L=$.length,G=Math.max(po.MIN_WIDTH,V*7+64),q=Math.max(po.MIN_HEIGHT,L*24+M);l(P=>P.map(H=>H.id===e?v(_({},H),{width:G,height:q,style:v(_({},H.style),{width:G,height:q})}):H))},[e,l,y,x]),N=Lr(U=>{let K=U.trim(),ee=t.label||"";if(K===ee)return;let A=K,M=s();if(!(K&&K!=="")){A=Pr(M,r("bpmn.task.label.prefix")),a(e,{label:A}),T(A),i({variant:"warning",content:cn(kr,{children:[r("bpmn.task.feedback.label_empty.prefix")," ",ge("strong",{children:A})]})});return}let V=bo(A,M);V===ee||(a(e,{label:V}),T(V),V!==A&&i({variant:"warning",content:cn(kr,{children:[r("bpmn.task.feedback.label_already_exists.prefix")," ",ge("strong",{children:K})," ",r("bpmn.task.feedback.label_already_exists.middle")," ",ge("strong",{children:V})]})}))},[t.label,s,e,r,a,T,i]),b=Lr(U=>{T(U)},[T]),w=Lr(()=>{i({variant:"error",content:r("bpmn.task.feedback.invalid_first_character")})},[r,i]),C=m?Yh[m]:null,I=t.variant?vn[t.variant].icon:null,k=t.attribute?wn[t.attribute].icon:null,S=()=>t.hasError?Yi.error:m?Yi[m]:Yi.default,R=()=>{f==null||f({id:e,type:"sub_process",label:t.label})};return cn("div",{className:O("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:[ge("div",{className:"flex-1 flex items-stretch justify-stretch overflow-hidden",children:ge(Ie,{value:t.label,maxLength:60,className:O({"py-10 px-8":y||x}),onChange:N,onInput:b,onInvalidFirstCharacter:w})}),I&&ge("div",{className:O("absolute flex items-center p-1",E?"bottom-0":"top-0 left-0"),children:ge(I,{size:16,className:O(t.hasError?"text-red-500":"text-grey-500",E&&"cursor-pointer"),onClick:E?R:void 0})}),k&&ge("div",{className:"absolute bottom-0 left-0 w-full flex items-center justify-center",children:ge("div",{className:O("flex items-center w-16 p-1",E?"justify-between":"justify-center"),children:ge(k,{size:16,className:O(t.hasError?"text-red-500":"text-grey-500")})})}),C&&ge("div",{className:"absolute top-0 right-0 flex items-center p-1",children:ge(C,{})}),ge(He,{nodeId:e,nodeType:"TASK",nodeVariant:t.variant}),u==="edit"&&ge(xo,{minWidth:po.MIN_WIDTH,minHeight:po.MIN_HEIGHT,isVisible:!n&&o}),(!c||h)&&cn(kr,{children:[ge(ie,{type:"target",position:Ct.Left,id:"left",className:O({"task-handle":h})}),ge(ie,{type:"target",position:Ct.Right,id:"right",className:O({"task-handle":h})}),ge(ie,{type:"target",position:Ct.Top,id:"top",className:O({"task-handle":h})}),ge(ie,{type:"target",position:Ct.Bottom,id:"bottom",className:O({"task-handle":h})})]}),!c&&cn(kr,{children:[ge(Le,{type:"source",position:Ct.Left,id:"left",nodeId:e,nodeType:"TASK"}),ge(Le,{type:"source",position:Ct.Right,id:"right",nodeId:e,nodeType:"TASK"}),ge(Le,{type:"source",position:Ct.Top,id:"top",nodeId:e,nodeType:"TASK"}),ge(Le,{type:"source",position:Ct.Bottom,id:"bottom",nodeId:e,nodeType:"TASK"})]})]})};import{Position as Vc}from"@xyflow/react";import{Fragment as Fh,jsx as Rr,jsxs as Wh}from"react/jsx-runtime";var Hc=({id:e,data:t})=>Wh(Fh,{children:[Rr("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}),Rr(He,{nodeId:e,nodeType:"UNSUPPORTED"}),Rr(ie,{type:"source",position:Vc.Right}),Rr(ie,{type:"target",position:Vc.Left})]});import{BaseEdge as Xh,EdgeLabelRenderer as Uh,getSmoothStepPath as $h,MarkerType as Kh,useInternalNode as Gc,useReactFlow as qh,useViewport as Zh,Position as _o}from"@xyflow/react";import{useState as Jh,useMemo as Qh}from"react";import{Fragment as Bc,jsx as Ge,jsxs as To}from"react/jsx-runtime";var XM={type:"MESSAGE_EDGE",reconnectable:!0,markerEnd:{type:Kh.Arrow},data:{label:""}},zc=({id:e,source:t,target:o,data:n,selected:r,sourcePosition:i,targetPosition:a,sourceHandleId:s,targetHandleId:l})=>{var H;let{zoom:c}=Zh(),{updateEdgeData:d}=qh(),{isMultipleSelection:u,mode:f,instanceId:p}=Q(),g=f!=="edit",[h,m]=Jh(!1),{reconnectingHandle:E,cursorPosition:y,hoveredNodeId:x,reconnectingSide:T,isValidReconnection:N,handleReconnectStart:b}=wr({edgeId:e,source:t,target:o,instanceId:p,isReadOnly:g}),w=Gc(t),C=Gc(o),{sx:I,sy:k,tx:S,ty:R,sourcePos:U,targetPos:K}=Qh(()=>{var le,ce;if(!w||!C)return{sx:0,sy:0,tx:0,ty:0,sourcePos:_o.Left,targetPos:_o.Right};let Y=jt(w,C),z=s?i:Y.sourcePos,D=l?a:Y.targetPos,J=(de,ue,he)=>{var ve,ke,ft,$t,Kt,Ee;let{x:ye,y:fe}=de.internals.positionAbsolute,se=(ft=(ke=(ve=de.measured)==null?void 0:ve.width)!=null?ke:de.width)!=null?ft:0,re=(Ee=(Kt=($t=de.measured)==null?void 0:$t.height)!=null?Kt:de.height)!=null?Ee:0;switch(ue){case _o.Top:return{x:ye+se*he,y:fe};case _o.Bottom:return{x:ye+se*he,y:fe+re};case _o.Left:return{x:ye,y:fe+re*he};case _o.Right:return{x:ye+se,y:fe+re*he};default:return{x:ye+se/2,y:fe+re/2}}},X=(le=n==null?void 0:n.sourceOffset)!=null?le:.5,W=(ce=n==null?void 0:n.targetOffset)!=null?ce:.5,B=w?J(w,z,X).x:Y.sx,F=w?J(w,z,X).y:Y.sy,Z=C?J(C,D,W).x:Y.tx,j=C?J(C,D,W).y:Y.ty;return E==="source"&&y?(B=y.x,F=y.y,T&&(z=T)):E==="target"&&y&&(Z=y.x,j=y.y,T&&(D=T)),{sx:B,sy:F,tx:Z,ty:j,sourcePos:z,targetPos:D}},[w,C,s,l,i,a,E,y,T,n==null?void 0:n.sourceOffset,n==null?void 0:n.targetOffset]);if(!w||!C)return null;let[ee,A,M]=$h({sourceX:I,sourceY:k,targetX:S,targetY:R,sourcePosition:U,targetPosition:K}),$=r||(w==null?void 0:w.selected)||(C==null?void 0:C.selected),V=$?"sequence-edge-marker-highlighted":"sequence-edge-marker",L=h||(n==null?void 0:n.label.trim().length)>0,G=()=>{m(!0)},q=()=>{m(!1)},P=Y=>{d(e,{label:Y.trim()})};return Ge(Bc,{children:To("g",{className:O("text-grey-500 hover:text-grey-600",{"text-blue-500 hover:text-blue-600":$}),onDoubleClick:G,children:[Ge(Xh,{id:e,path:ee,markerEnd:`url(#${V})`,strokeDasharray:4,className:O("stroke-2 stroke-current transition-colors duration-75",{"stroke-red-500 hover:stroke-red-600":(n==null?void 0:n.hasError)||E&&x&&!N,"stroke-green-500":E&&x&&N,"stroke-blue-500 hover:stroke-blue-600 drop-shadow-[0_0_3px_rgba(59,130,246,0.5)]":$&&!(n!=null&&n.hasError)&&!E})}),To(Uh,{children:[To("div",{className:"absolute z-[3000] pointer-events-auto flex flex-col items-center gap-1",style:{transform:`translate(-50%, -50%) translate(${A}px, ${M}px)`},children:[r&&!u&&Ge(so,{sx:I,sy:k,tx:S,ty:R,hasLabel:!!((H=n==null?void 0:n.label)!=null&&H.trim()),children:Ge(io,{edgeId:e,edgeType:"MESSAGE_EDGE"})}),L&&Ge(Ie,{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:q,onChange:P})]}),r&&!u&&!g&&To(Bc,{children:[Ge("div",{className:"absolute z-[1000] pointer-events-none",style:{transform:`translate(-50%, -50%) translate(${I}px, ${k}px)`},children:To("svg",{width:12/c,height:12/c,style:{overflow:"visible",position:"absolute",left:"50%",top:"50%",transform:"translate(-50%, -50%)"},children:[Ge("circle",{cx:6/c,cy:6/c,r:4/c,fill:E==="source"?"#3b82f6":"#fff",stroke:"#3b82f6",strokeWidth:2/c,className:"pointer-events-none"}),Ge("circle",{cx:6/c,cy:6/c,r:6/c,fill:"none",stroke:"#3b82f6",strokeWidth:1/c,opacity:E==="source"?.6:.3,className:"pointer-events-none"}),Ge("circle",{cx:6/c,cy:6/c,r:8/c,fill:"transparent",className:O("pointer-events-auto",{"cursor-move":!E||E!=="source","cursor-not-allowed":E==="source"&&x&&!N,"cursor-grabbing":E==="source"&&(!x||N)}),onMouseDown:Y=>b("source",Y.nativeEvent)})]})}),Ge("div",{className:"absolute z-[1000] pointer-events-none",style:{transform:`translate(-50%, -50%) translate(${S}px, ${R}px)`},children:To("svg",{width:12/c,height:12/c,style:{overflow:"visible",position:"absolute",left:"50%",top:"50%",transform:"translate(-50%, -50%)"},children:[Ge("circle",{cx:6/c,cy:6/c,r:4/c,fill:E==="target"?"#3b82f6":"#fff",stroke:"#3b82f6",strokeWidth:2/c,className:"pointer-events-none"}),Ge("circle",{cx:6/c,cy:6/c,r:6/c,fill:"none",stroke:"#3b82f6",strokeWidth:1/c,opacity:E==="target"?.6:.3,className:"pointer-events-none"}),Ge("circle",{cx:6/c,cy:6/c,r:8/c,fill:"transparent",className:O("pointer-events-auto",{"cursor-move":!E||E!=="target","cursor-not-allowed":E==="target"&&x&&!N,"cursor-grabbing":E==="target"&&(!x||N)}),onMouseDown:Y=>b("target",Y.nativeEvent)})]})})]})]})]})})};import{getStraightPath as jh,Position as Dr}from"@xyflow/react";import{jsx as Yc,jsxs as ey}from"react/jsx-runtime";var Fc=({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:Dr.Left},{x:n+a,y:r+s/2,pos:Dr.Right},{x:n+a/2,y:r,pos:Dr.Top},{x:n+a/2,y:r+s,pos:Dr.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]=jh({sourceX:c.x,sourceY:c.y,targetX:e,targetY:t});return ey("g",{children:[Yc("path",{fill:"none",className:"stroke-2 stroke-grey-500 animated",d}),Yc("circle",{cx:e,cy:t,fill:"none",r:4,className:"stroke-2 stroke-grey-600"})]})};import{Position as ty,useReactFlow as oy}from"@xyflow/react";import{orderBy as ny}from"lodash";import{useMemo as Wc,useState as ry}from"react";import{Fragment as iy,jsx as Yt,jsxs as Xc}from"react/jsx-runtime";var Uc=({id:e,data:t,selected:o,dragging:n,parentId:r})=>{let{updateNodeData:i,getNodes:a}=oy(),{mode:s}=Q(),[l,c]=ry(!1),d=a(),u=!r,f=Wc(()=>ny([...d.filter(y=>y.parentId===e&&y.type==="LANE")],"position.y","asc"),[d,e]),p=u?Sr.MIN_WIDTH:me.MIN_WIDTH,g=Wc(()=>{if(u&&f.length>1){let y=[...f];return y.pop(),y.reduce((T,N)=>{var b,w;return T+((w=(b=N.measured)==null?void 0:b.height)!=null?w:0)},0)+me.MIN_HEIGHT}return me.MIN_HEIGHT},[u,f]),h=y=>{i(e,{label:y})},m=()=>{c(!0)},E=()=>{c(!1)};return Xc(iy,{children:[Xc("div",{className:O("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:[Yt("div",{className:"flex align-items justify-center w-10 border-r border-grey-300",onDoubleClick:m,children:Yt("div",{className:"relative flex-1 [writing-mode:vertical-rl] [text-orientation:sideways] transform rotate-180",children:Yt(Ie,{value:t.label,className:"w-full h-full self-auto",contentClassName:O({"whitespace-nowrap":l}),isEditing:l,onBlur:E,onChange:h})})}),Yt("div",{className:"flex-1"})]}),Yt(He,{nodeId:e,nodeType:"LANE",isChild:!u}),s==="edit"&&Yt(xo,{nodeId:e,minWidth:p,minHeight:g,isVisible:!n&&o}),Yt(ie,{type:"source",position:ty.Right})]})};var $c={START_EVENT:Sc,END_EVENT:wc,TASK:Oc,GATEWAY:Ic,ANNOTATION:Nc,LANE:Uc,UNSUPPORTED:Hc},Kc={SEQUENCE_EDGE:Yl,MESSAGE_EDGE:zc,ANNOTATION_EDGE:Il},qc="#fafafa",Zc="#bebebe",Jc=1,Qc=10,jc="bottom-left",Fi=.05,ed=5,No=.5,vo=Fi,wo=1,td={x:0,y:0,zoom:.75},sy=1,ay=2,od=[sy,ay];import{useReactFlow as ly}from"@xyflow/react";var Ue=()=>{let{getEdges:e,getNodes:t}=ly(),{lastElementId:o}=Q(),n=()=>{let i=t(),a=e(),s=pc(i,a);return Math.max(s,o)};return{getLastId:n,getNextId:()=>n()+1}};var Ao=()=>{let{getNodes:e,getEdges:t,setNodes:o,setEdges:n,setViewport:r}=dy(),{getLastId:i}=Ue(),a=uy(),{setLastElementId:s}=Q(),l=nd(async(d="")=>{let{nodes:u,edges:f,lastElementId:p}=await mc(d),{width:g,height:h}=a.getState();if(g>0&&h>0){let m=ic(u);m&&r(cy(m,g,h,vo,wo,No))}o(u),n(f),s(p)},[o,n,s,a,r]),c=nd(()=>{let d=e(),u=t(),f=i();return fc(d,u,f)},[e,t,i]);return{importFromMxGraph:l,exportToMxGraph:c}};import{useCallback as rd}from"react";var fy=500,Or=()=>{let{isInitialized:e,onElementChanges:t}=Q(),{exportToMxGraph:o}=Ao(),n=py(()=>{if(!e)return;let a=o();t==null||t(a)},fy),r=rd(a=>{a.every(c=>c.type==="select")||a.some(c=>c.type==="position"&&c.dragging)||n()},[n]),i=rd(a=>{a.some(l=>l.type==="select")||n()},[n]);return{emitElementChanges:n,handleNodeChanges:r,handleEdgeChanges:i}};var id=({setEdges:e,saveHistory:t})=>{let{getNode:o,getEdges:n,getNodes:r,getInternalNode:i}=gy(),{emitElementChanges:a}=Or(),s=hy(null),{getNextId:l}=Ue(),c=Ft(m=>{var N;let E=o(m.source),y=o(m.target);if(!E||!y)return!1;let x={sourceNodeId:E.id,targetNodeId:y.id,sourceNodeType:E.type,targetNodeType:y.type,nodes:r(),edges:n(),reconnectingEdgeId:(N=s.current)!=null?N:void 0};return Ii(x).isValid},[o,n,r]),d=Ft(m=>{var x,T;let E=l(),y=i(m.source);if(y){let N=i(m.target),b=N?N.internals.positionAbsolute.x+((x=N.measured.width)!=null?x:0)/2:0,w=N?N.internals.positionAbsolute.y+((T=N.measured.height)!=null?T:0)/2:0,C=Fl(y,b,w),I=(N==null?void 0:N.type)==="ANNOTATION"||(y==null?void 0:y.type)==="ANNOTATION",k=I?ao:Ye,S;if(!I&&N&&m.targetHandle){let K=Ir(C),ee=Ir(m.targetHandle),{x:A,y:M}=Pi(y,C),{x:$,y:V}=Pi(N,m.targetHandle),G=Nr(A,M,$,V,K,ee).slice(1,-1);G.length>0&&(S=G)}let R=v(_(_({},m),k),{id:String(E),sourceHandle:C,data:_(_({},I?{}:Ye.data),S?{points:S}:{})}),U=n().concat(R);e(U),t("forceSave",{nodes:r(),edges:U}),a()}},[l,e,a,i,n,r,t]),u=Ft((m,E)=>{s.current=E.id},[]),f=Ft(()=>{s.current=null},[]),p=Ft((m,E)=>{let y=o(E.source),x=o(E.target);if(!y||!x){s.current=null;return}let T={sourceNodeId:y.id,targetNodeId:x.id,sourceNodeType:y.type,targetNodeType:x.type,nodes:r(),edges:n(),reconnectingEdgeId:m.id};if(!Ii(T).isValid){s.current=null;return}let b=my(m,E,n()).map(w=>w.id===m.id?v(_({},w),{data:v(_({},w.data),{points:void 0})}):w);e(b),t("forceSave",{nodes:r(),edges:b}),s.current=null,a()},[o,r,n,e,a,t]),g=Ft(m=>{s.current=m},[]),h=Ft(()=>{s.current=null},[]);return{isValidConnection:c,onConnect:d,onReconnect:p,onReconnectStart:u,onReconnectEnd:f,setReconnectingEdge:g,clearReconnectingEdge:h}};import{useTranslation as yy}from"@produto-lecom/lecom-ui";import{useReactFlow as xy}from"@xyflow/react";import{useCallback as fn,useRef as md,useState as Ey}from"react";var dn=(e=[])=>e.filter(t=>t.type==="START_EVENT"),Wt=(e=[])=>e.filter(t=>t.type==="END_EVENT"),St=(e=[])=>e.filter(t=>t.type==="TASK")||[],sd=(e=[])=>e.filter(t=>{var o;return t.type==="TASK"&&((o=t.properties)==null?void 0:o.variant)==="SCRIPT"}),ad=(e=[])=>e.filter(t=>{var o;return t.type==="TASK"&&((o=t.properties)==null?void 0:o.variant)==="SUBPROCESS"}),Vr=(e=[])=>e.filter(t=>t.type==="GATEWAY"),ld=(e=[])=>e.filter(t=>{var o;return t.type==="GATEWAY"&&((o=t.properties)==null?void 0:o.variant)==="EXCLUSIVE"}),Be=(e,t=[])=>t.filter(o=>o.source===e),un=(e,t=[])=>t.filter(o=>o.target===e),cd=(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"},dd=(e,t)=>{let o=Be(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},ud=e=>e?/[^\s]/.test(e.trim()):!1,pe=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:[]}},rt=(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)}},pd=(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 pn=[{id:"start_event_not_found",validate:e=>{let t=dn(e.nodes);return pe({isValid:t.length>=1})}},{id:"end_event_not_found",validate:e=>{let t=Wt(e.nodes);return pe({isValid:t.length>=1})}},{id:"multiple_start_event_not_allowed",validate:e=>{let t=dn(e.nodes),o=t.length===1;if(t.length===0)return pe({isValid:!0});if(!o)return pe({isValid:!1,nodeIds:t.map(i=>i.id)});let n=Be(t[0].id,e.edges);if(!(n.length<=1)){let i=[...t.map(a=>a.id),...n.map(a=>a.target)];return pe({isValid:!1,nodeIds:[...new Set(i)]})}return pe({isValid:!0})}},{id:"task_flows_limit_exceeds",validate:e=>{let t=St(e.nodes),o=rt(t,n=>Be(n.id,e.edges).length<=2);return pe({isValid:o.isValid,nodeIds:o.invalidIds})}},{id:"task_label_empty",highlightRelatedEdges:!1,validate:e=>{let t=St(e.nodes),o=rt(t,n=>!!n.label&&n.label.trim()!=="");return pe({isValid:o.isValid,nodeIds:o.invalidIds})}},{id:"task_label_length",highlightRelatedEdges:!1,validate:e=>{let o=St(e.nodes),n=rt(o,r=>!r.label||r.label.length<=60);return pe({isValid:n.isValid,nodeIds:n.invalidIds})}},{id:"duplicate_task_name",highlightRelatedEdges:!1,validate:e=>{let t=St(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 pe({isValid:n.length===0,nodeIds:n})}},{id:"nested_gateway",validate:e=>{let t=Vr(e.nodes),o=[],n=[];for(let r of t){let i=Be(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 pe({isValid:o.length===0,nodeIds:o.length>0?[...new Set(o)]:[],edgeIds:n})}},{id:"events_nested",validate:e=>{let t=[...dn(e.nodes),...Wt(e.nodes)],o=[],n=[];for(let r of t){let i=Be(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 pe({isValid:o.length===0,nodeIds:o.length>0?[...new Set(o)]:[],edgeIds:n})}},{id:"flows_on_end_tasks_not_allowed",validate:e=>{let t=Wt(e.nodes),o=[],n=[];for(let r of t){let i=un(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=Be(s.id,e.edges);l.length>1&&(o.push(s.id),l.forEach(c=>n.push(c.id)))}}}return pe({isValid:o.length===0,nodeIds:o,edgeIds:n})}},{id:"conditions_flows_limit_exceeds",validate:e=>{let t=ld(e.nodes),o=rt(t,r=>Be(r.id,e.edges).length<=2),n=o.invalidIds.flatMap(r=>Be(r,e.edges).map(i=>i.id));return pe({isValid:o.isValid,nodeIds:o.invalidIds,edgeIds:n})}},{id:"activity_name_invalid",validate:e=>{let t=St(e.nodes),o=rt(t,n=>!n.label||ud(n.label));return pe({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 pe({isValid:!0});let t=Wt(e.nodes)[0];if(!t)return pe({isValid:!0});let o=un(t.id,e.edges);if(!o.length)return pe({isValid:!0});let r=St(e.nodes).filter(l=>o.some(c=>c.source===l.id)),i=rt(r,l=>!cd(l.id,e));return pe({isValid:i.isValid,nodeIds:i.isValid?[]:[t.id,...i.invalidIds]})}},{id:"concurrent_initial_and_final_event",validate:e=>{let t=St(e.nodes),o=Wt(e.nodes)[0];if(!o)return pe({isValid:!0});let n=t.filter(l=>{let c=un(l.id,e.edges),d=Be(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"}),f=d.some(p=>{var g;return((g=e.nodes.find(h=>h.id===p.target))==null?void 0:g.type)==="END_EVENT"});return u&&f}),r=un(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 pe(s)}},{id:"gateway_flow_to_event",validate:e=>{let t=Vr(e.nodes),o=[],n=[];for(let r of t){let i=Be(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 pe({isValid:o.length===0,nodeIds:o.length>0?[...new Set(o)]:[],edgeIds:n})}},{id:"gateway_missing_output_streams",validate:e=>{let t=Vr(e.nodes),o=rt(t,n=>Be(n.id,e.edges).length>=1);return pe({isValid:o.isValid,nodeIds:o.invalidIds})}},{id:"event_to_condition",validate:e=>{let t=[...dn(e.nodes),...Wt(e.nodes)],o=[],n=[];for(let r of t){let i=Be(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 pe({isValid:o.length===0,nodeIds:o.length>0?[...new Set(o)]:[],edgeIds:n})}},{id:"script_in_final_activity",validate:e=>{let t=sd(e.nodes),o=rt(t,n=>!dd(n.id,e));return pe({isValid:o.isValid,nodeIds:o.invalidIds})}},{id:"subprocess_referenced_not_configured",validate:e=>{let t=ad(e.nodes),o=rt(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 pe({isValid:o.isValid,nodeIds:o.invalidIds})}}];var fd=e=>{e=e||{nodes:[],edges:[]},e.nodes=e.nodes||[],e.edges=e.edges||[];let t=[];for(let n of pn){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 Hr,jsxs as by}from"react/jsx-runtime";var gd=()=>{let{t:e}=yy(),{toast:t}=Ve(),{setNodes:o,setEdges:n,getNodes:r,getEdges:i}=xy(),[a,s]=Ey(!1),l=md(!1),c=md(!1),d=fn(h=>{let m=pd(h.nodes,h.edges),E=fd(m),y=E.errors.map(x=>v(_({},x),{message:e(`validation.errors.${x.id}`)}));return a||s(!0),{isValid:E.isValid,errors:y}},[a,e]),u=fn((h,m=!0)=>{if(m&&h&&t({variant:h.isValid?"success":"error",duration:5e3,title:h.isValid?e("validation.success.title"):e("validation.errors.title"),content:by("div",{className:"flex flex-col gap-1",children:[!h.isValid&&Hr("span",{className:"body-small-500",children:e("validation.errors.subtitle")}),Hr("ul",{className:"list-disc list-inside max-h-40 overflow-y-auto",children:h.isValid?Hr("li",{children:e("validation.success.message")}):h.errors.map(S=>Hr("li",{className:"text-xs",children:S.message},S.id))})]})}),!h)return;l.current=!0,c.current=!0;let E=[],y=[];h.errors.forEach(S=>{S.nodeIds&&S.nodeIds.length>0&&S.nodeIds.forEach(R=>E.push(R)),S.edgeIds&&S.edgeIds.length>0&&S.edgeIds.forEach(R=>y.push(R))});let x=[...new Set(E)];o(S=>S.map(R=>v(_({},R),{data:v(_({},R.data),{hasError:!1})}))),n(S=>S.map(R=>v(_({},R),{data:v(_({},R.data),{hasError:!1})})));let T=r(),N=i(),b=new Set(x),w=new Set;h.errors.forEach(S=>{var K,ee;let R=pn.find(A=>A.id===S.id);(R==null?void 0:R.highlightRelatedEdges)!==!1&&((K=S.edgeIds)==null||K.forEach(A=>w.add(A)),(ee=S.nodeIds)==null||ee.forEach(A=>{N.forEach(M=>{(M.source===A||M.target===A)&&w.add(M.id)})}))});let C=new Set,I=new Set,k=new Set;T.forEach(S=>{S.type==="START_EVENT"?C.add(S.id):S.type==="END_EVENT"&&I.add(S.id)}),N.forEach(S=>{C.has(S.source)&&k.add(S.target),I.has(S.target)&&k.add(S.source)}),k.forEach(S=>{var R,U;if(b.has(S)){let K=(R=h.errors.find(A=>{var M;return(M=A.nodeIds)==null?void 0:M.includes(S)}))==null?void 0:R.id;((U=pn.find(A=>A.id===K))==null?void 0:U.highlightRelatedEdges)!==!1&&N.forEach(A=>{A.source===S&&I.has(A.target)&&(b.add(A.target),w.add(A.id)),A.target===S&&C.has(A.source)&&(b.add(A.source),w.add(A.id))})}}),b.size>0&&o(S=>S.map(R=>v(_({},R),{data:v(_({},R.data),{hasError:b.has(R.id)})}))),w.size>0&&n(S=>S.map(R=>v(_({},R),{data:v(_({},R.data),{hasError:w.has(R.id)})}))),setTimeout(()=>{l.current=!1},0)},[e,i,r,n,o,t]),f=fn(()=>{s(!1),c.current=!1,o(h=>h.map(m=>v(_({},m),{data:v(_({},m.data),{hasError:!1})}))),n(h=>h.map(m=>v(_({},m),{data:v(_({},m.data),{hasError:!1})})))},[n,o]),p=fn(()=>{c.current&&(l.current=!0,c.current=!1,o(h=>h.map(m=>v(_({},m),{data:v(_({},m.data),{hasError:!1})}))),n(h=>h.map(m=>v(_({},m),{data:v(_({},m.data),{hasError:!1})}))),setTimeout(()=>{l.current=!1},0))},[n,o]),g=fn(()=>l.current,[]);return{validateDiagram:d,handleValidationComplete:u,clearValidation:f,dismissValidationPanel:p,isAutoValidationEnabled:a,getIsClearingValidation:g}};import{useReactFlow as _y}from"@xyflow/react";import{useTranslation as Ty}from"@produto-lecom/lecom-ui";import{useEffect as Ny}from"react";var vy=15,hd="bpmn:selection",wy=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},yd=e=>{if(!wy(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},xd=({offset:e=vy,saveHistory:t})=>{let{t:o}=Ty(),{getNodes:n,setNodes:r,getEdges:i,setEdges:a}=_y(),{getNextId:s}=Ue();Ny(()=>{let l=d=>{var E,y;if(!yd(d))return;let u=n(),f=i(),p=u.filter(x=>x.selected);if(!p.length)return;d.preventDefault(),d.stopPropagation();let g=f.filter(x=>p.some(T=>T.id===x.source)&&p.some(T=>T.id===x.target)),m=JSON.stringify({nodes:p,edges:g});(E=d.clipboardData)==null||E.setData(hd,m),(y=d.clipboardData)==null||y.setData("text/plain",`BPMN Selection: ${p.length} nodes`)},c=d=>{var w,C;if(!yd(d))return;let u=(w=d.clipboardData)==null?void 0:w.getData(hd);if(!u)return;d.preventDefault(),d.stopPropagation();let f;try{f=JSON.parse(u)}catch(I){return}if(!((C=f.nodes)!=null&&C.length))return;let p=new Map,g=n(),h=[],m=f.nodes.filter(I=>bt(I.type,g));if(m.length===0)return;let E=s(),y=m.map(I=>{var R;let k=String(E++);p.set(I.id,k);let S=v(_({},I),{id:k,selected:!0,position:{x:I.position.x+e,y:I.position.y+e}});if(I.type==="TASK"){let U=(R=I.data)==null?void 0:R.label,K=bo(U||o("bpmn.task.label.prefix"),[...g,...h]);S.data=v(_({},I.data),{label:K})}return h.push(S),S}),x=f.edges.map(I=>v(_({},I),{id:String(E++),selected:!0,source:p.get(I.source)||I.source,target:p.get(I.target)||I.target})),T=[...g.map(I=>v(_({},I),{selected:!1})),...y],b=[...i().map(I=>v(_({},I),{selected:!1})),...x];r(T),a(b),t("forceSave",{nodes:T,edges:b})};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{useReactFlow as Ay,useStoreApi as Iy}from"@xyflow/react";import{useTranslation as Cy}from"@produto-lecom/lecom-ui";import{useState as Sy}from"react";var Ed=({nodes:e,setNodes:t,setEdges:o,saveHistory:n})=>{let r=Iy(),{draggableNode:i,setDraggableNode:a}=Eo(),{t:s}=Cy(),{getInternalNode:l,getNodes:c,getEdges:d,screenToFlowPosition:u}=Ay(),{getNextId:f}=Ue(),{setIsDragging:p}=Q(),{rebuildIndex:g,forceRebuildIndex:h}=rr(),[m,E]=Sy(null),y=(A,M=!1)=>{let $=M?"node-drop-target-error":"node-drop-target",V=M?"node-drop-target-lane-error":"node-drop-target-lane";t(L=>L.map(G=>G.id===A?v(_({},G),{className:$}):A!==void 0&&G.parentId===A&&G.type==="LANE"?v(_({},G),{className:V}):v(_({},G),{className:""})))},x=()=>{let{nodeLookup:A}=r.getState();return Array.from(A.values())},T=(A,M)=>{let $=x();if(A.type==="LANE"){if(M){y();return}let P=$.filter(z=>z.id!==A.id&&z.type==="LANE"&&!z.parentId),H=tn(A,P);if(!H){y();return}if(yo({parentId:H.id,nodes:e,excludeTypes:["LANE"]})){y(H.id,!0);return}y(H.id);return}let L=$.filter(P=>P.id!==A.id&&P.type==="LANE"),G=tn(A,L);if(!G){y();return}if(yo({parentId:G.id,nodes:e,includeTypes:["LANE"]})){y();return}y(G.id)},N=A=>{let M=l(A.id),$=A.type==="LANE"&&yo({parentId:A.id,nodes:e,includeTypes:["LANE"]});T(M,$)},b=A=>A.map(M=>v(_({},M),{className:void 0})),w=A=>A.some($=>$.dragging)?A.map($=>$.dragging?v(_({},$),{dragging:!1}):$):A,C=A=>{if(A.preventDefault(),A.dataTransfer.dropEffect="move",!(i!=null&&i.type))return;let M=u({x:A.clientX,y:A.clientY}),$={id:"__sidebar_drag__",type:i.type,position:M,measured:{width:1,height:1},internals:{positionAbsolute:M}};T($,!1)},I=A=>{let M=A.relatedTarget;(!M||!A.currentTarget.contains(M))&&y()},k=(A,M)=>{A.preventDefault(),N(M)},S=(A,M,$)=>{var P,H;let V=[...$];if(A.parentId===M.id)return V=lc(A,M,V),V=on(V),b(V);if(A.type==="LANE"){if(yo({parentId:M.id,nodes:V,excludeTypes:["LANE"]})){let X=lt(M),W=50,B=50;return V.map(F=>{var Z,j;return F.id===A.id?v(_({},F),{position:{x:(Z=m==null?void 0:m.x)!=null?Z:X.x+W,y:(j=m==null?void 0:m.y)!=null?j:X.y2+B}}):F})}let D=V.filter(X=>X.parentId===M.id).reduce((X,W)=>{var B,F;return X+((F=(B=W.measured)==null?void 0:B.height)!=null?F:0)},0),J={x:me.HEADER_WIDTH,y:D};return V=V.map(X=>X.id===A.id?v(_({},X),{parentId:M.id,position:J,className:void 0}):v(_({},X),{className:void 0})),V=nn(M.id,V),V}if(yo({parentId:M.id,nodes:V,includeTypes:["LANE"]})){let Y;if(A.parentId){let z=l(A.parentId),{x:D,y:J}=dt(z);Y={x:D+((P=A.position.x)!=null?P:0),y:J+((H=A.position.y)!=null?H:0)}}return V=V.map(z=>z.id===A.id?v(_({},z),{position:Y!=null?Y:z.position,parentId:void 0,className:void 0}):v(_({},z),{className:void 0})),V}let q=oc(A,M);return V=V.map(Y=>{if(Y.id===A.id){let z=lt(A),D=lt(M);return z.y<D.y&&(q.y=0),z.x<D.x+me.HEADER_WIDTH&&(q.x=me.HEADER_WIDTH),v(_({},Y),{parentId:M.id,position:q,className:void 0})}return v(_({},Y),{className:void 0})}),V=on(V),V},R=A=>{if(A.preventDefault(),!(i!=null&&i.type))return;if(!bt(i.type,c())){p(!1),a(null);return}let M=u({x:A.clientX,y:A.clientY}),$={width:ne[i.type].MIN_WIDTH,height:ne[i.type].MIN_HEIGHT},V=f(),L={id:String(V),type:i.type,position:M,measured:$,data:{label:i.type==="TASK"?Pr(e,s("bpmn.task.label.prefix")):"",variant:i.variant,attribute:i.attribute},selected:!0},G=v(_({},L),{internals:{positionAbsolute:M}}),q=v(_({},G),{measured:{width:1,height:1}}),P=x(),H=i.type==="LANE",Y=P.filter(B=>H?B.type==="LANE"&&!B.parentId:B.type==="LANE"),z=tn(q,Y),D=[...e.map(B=>v(_({},B),{selected:!1})),L];z&&(D=S(G,z,D)),D=Gt(D),D=b(D),t(D),h();let J=A.dataTransfer.getData("sourceId"),X=d(),W=X;if(J){let B={id:String(V+1),source:J,target:L.id},F=i.type==="ANNOTATION"?_(_({},B),ao):_(_({},B),Ye);W=X.concat(F),o(W)}n("forceSave",{nodes:D,edges:W}),p(!1),a(null)},U=async(A,M,$)=>{let V=[...e];$.forEach(L=>{let G=x(),q=l(L.id),P=L.type==="LANE",H=G.filter(z=>z.id!==L.id&&(P?z.type==="LANE"&&!z.parentId:z.type==="LANE")),Y=tn(q,H);if(Y){V=S(q,Y,V);return}L.parentId&&(V=ee(L,V))}),V=w(V),V=Gt(V),V=b(V),t(V),g(V),E(null)},K=(A,M)=>{E({x:M.position.x,y:M.position.y})},ee=(A,M)=>{var q,P;let $=l(A.parentId),{x:V,y:L}=dt($),G={x:V+((q=A.position.x)!=null?q:0),y:L+((P=A.position.y)!=null?P:0)};return M=M.map(H=>H.id===A.id?v(_({},H),{position:G,parentId:void 0}):H),M=nn(A.parentId,M),M};return{onDragOver:C,onDragLeave:I,onDrop:R,onNodeDrag:k,onNodeDragStart:K,onNodeDragStop:U}};import{useReactFlow as My}from"@xyflow/react";import{useTranslation as Py}from"@produto-lecom/lecom-ui";import{useEffect as Ly}from"react";var ky=30,Ry=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},Dy=e=>!Ry(e.target),bd=({offset:e=ky,saveHistory:t})=>{let{t:o}=Py(),{getNodes:n,setNodes:r,getEdges:i,setEdges:a}=My(),{getNextId:s}=Ue();Ly(()=>{let l=c=>{if(c.ctrlKey&&c.key.toLowerCase()==="d"&&Dy(c)){c.preventDefault(),c.stopPropagation();let d=n(),u=i(),f=d.filter(b=>b.selected);if(!f.length)return;let p=new Map,g=[],h=f.filter(b=>bt(b.type,d));if(h.length===0)return;let m=u.filter(b=>h.some(w=>w.id===b.source)&&h.some(w=>w.id===b.target)),E=s(),y=h.map(b=>{var I;let w=String(E++);p.set(b.id,w);let C=v(_({},b),{id:w,selected:!0,position:{x:b.position.x+e,y:b.position.y+e}});if(b.type==="TASK"){let k=(I=b.data)==null?void 0:I.label,S=bo(k||o("bpmn.task.label.prefix"),[...d,...g]);C.data=v(_({},b.data),{label:S})}return g.push(C),C}),x=m.map(b=>v(_({},b),{id:String(E++),selected:!0,source:p.get(b.source)||b.source,target:p.get(b.target)||b.target})),T=[...d.map(b=>v(_({},b),{selected:!1})),...y],N=[...u.map(b=>v(_({},b),{selected:!1})),...x];r(T),a(N),t("forceSave",{nodes:T,edges:N})}};return document.addEventListener("keydown",l,!0),()=>{document.removeEventListener("keydown",l,!0)}},[n,r,i,a,s,e,o,t])};import{useEffect as Oy,useRef as _d}from"react";import{useReactFlow as Vy}from"@xyflow/react";var Hy=20,Gy=50,mn={UP:"ArrowUp",DOWN:"ArrowDown",LEFT:"ArrowLeft",RIGHT:"ArrowRight"},By=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},Td=e=>{let{getNodes:t}=Vy(),{mode:o,isMoveTool:n}=Q(),r=_d(0),i=_d(new Map);Oy(()=>{let a=s=>{if(o!=="edit"||!n||By(s.target)||!Object.values(mn).includes(s.key))return;let u=t().filter(y=>y.selected);if(u.length===0){i.current.clear();return}s.preventDefault();let f=Date.now(),p=f-r.current<500;r.current=f;let g=s.shiftKey?Gy:Hy,h=0,m=0;switch(s.key){case mn.UP:m=-g;break;case mn.DOWN:m=g;break;case mn.LEFT:h=-g;break;case mn.RIGHT:h=g;break}let E=u.map(y=>{let x=i.current.get(y.id);(!p||!x)&&(x={x:y.position.x,y:y.position.y});let T={x:x.x+h,y:x.y+m};return i.current.set(y.id,T),{id:y.id,dragging:!0,type:"position",position:T}});e&&e(E)};return window.addEventListener("keydown",a),()=>{window.removeEventListener("keydown",a)}},[t,e,o,n])};import{useReactFlow as Yy}from"@xyflow/react";var vd={"start-event":"START_EVENT","end-event":"END_EVENT",task:"TASK","gateway-exclusive":"GATEWAY"},wd={"start-event":"","end-event":"",task:"","gateway-exclusive":"EXCLUSIVE"},Nd=(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}},zy=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=Nd(i[0],o),s=Nd(i[1],o);a&&s&&n.push({sourceId:a.step,targetId:s.step,label:a.edgeLabel||s.edgeLabel||""})}),{components:o,connections:n}},Ad=e=>{let{components:t,connections:o}=zy(e);return{nodes:t,edges:o}};var Id=()=>{let{setNodes:e,setEdges:t,fitView:o}=Yy(),{getNextId:n}=Ue();return{importFromLia:i=>{let a=typeof i=="string"?i:i.diagramXml||"",{nodes:s,edges:l}=Ad(a),c=[],d=new Map,u=!1,f=n();for(let[m,E]of Object.entries(s)){let y=String(f++),x=vd[E.type],T=wd[E.type];x==="START_EVENT"&&(u=!0),d.set(m,y);let N=ne[x].MIN_WIDTH,b=ne[x].MIN_HEIGHT;c.push({id:y,type:x,data:{label:E.label||"",variant:T,attribute:""},position:{x:0,y:0},width:N,height:b,measured:{width:N,height:b}})}let p=[];for(let m of l){let E=v(_({},Ye),{id:String(f++),source:d.get(m.sourceId)||m.sourceId,target:d.get(m.targetId)||m.targetId});p.push(E)}if(!u&&c.length>0){let m=String(f++),E={id:m,type:"START_EVENT",data:{label:"",variant:"",attribute:""},position:{x:0,y:0},width:ne.START_EVENT.MIN_WIDTH,height:ne.START_EVENT.MIN_HEIGHT,measured:{width:ne.START_EVENT.MIN_WIDTH,height:ne.START_EVENT.MIN_HEIGHT}};c.unshift(E);let y=c[1];if(y){let x=v(_({},Ye),{id:String(f++),source:m,target:y.id});p.unshift(x)}}let{nodes:g,edges:h}=ac(c,p);e(g),t(h),o({padding:No,minZoom:vo,maxZoom:wo})}}};import{useEffect as Fy,useCallback as Wy}from"react";var Xy={origin:"*",debug:!1};function Cd(e,t=Xy){let{origin:o,debug:n}=t,r=Wy((i,a)=>{let s={event:i,data:[i,{event:i,data:a}]};window.parent.postMessage(s,o||"*")},[o]);return Fy(()=>{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 Uy}from"@xyflow/react";import{useEffect as Sd}from"react";var Md=()=>{let e=Uy(),{initialDiagram:t,setIsInitialized:o}=Q(),{importFromMxGraph:n}=Ao();Sd(()=>{t&&n(t)},[t,n,o]),Sd(()=>{if(!e)return;(async()=>{await _n(),o(!0)})()},[e,o])};import{useCallback as Pd}from"react";import{useReactFlow as $y}from"@xyflow/react";function Ld(){let{setTaskStatuses:e,clearTaskStatuses:t,calculateFlowPath:o}=Lt(),{getEdges:n}=$y(),r=In(),i=Pd(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=Pd(()=>{t(),setTimeout(()=>{r()},0)},[t,r]);return{handleTasksStatus:i,handleClearTaskStatus:a}}import{useReactFlow as Ky}from"@xyflow/react";import{useCallback as ut,useState as qy,useEffect as kd}from"react";import{useDebouncedCallback as Zy}from"use-debounce";var Jy=500,Rd=100,Dd=(e=!1)=>{let{getNodes:t,getEdges:o,setNodes:n,setEdges:r}=Ky(),[i,a]=qy({history:[],currentStep:0}),{history:s,currentStep:l}=i,c=l>0,d=l<s.length-1,u=ut((N,b)=>{n(N[b].nodes),r(N[b].edges)},[n,r]),f=ut(()=>{if(l>0){let N=l-1;a(b=>v(_({},b),{currentStep:N})),u(s,N)}},[l,s,u]),p=ut(()=>{if(l<s.length-1){let N=l+1;a(b=>v(_({},b),{currentStep:N})),u(s,N)}},[s,l,u]),g=ut(N=>{a(b=>{let w=b.history[b.currentStep];if(w&&JSON.stringify(w)===JSON.stringify(N))return b;let k=[...b.history.slice(0,b.currentStep+1),N],S=k.length>Rd?k.slice(k.length-Rd):k;return{history:S,currentStep:S.length-1}})},[]),h=ut((N,b)=>{let w=N.map(I=>v(_({},I),{selected:!1,className:"",data:v(_({},I.data),{hasError:!1})})),C=b.map(I=>v(_({},I),{data:v(_({},I.data),{hasError:!1})}));return{nodes:Gt(w),edges:C}},[]),m=ut(()=>h(t(),o()),[t,o,h]),E=Zy(()=>{let N=m();g(N)},Jy),y=ut((N,b)=>{if(!e)return;if(s.length===0){let I=m();a({history:[I],currentStep:0})}if(N==="forceSave"){if(b){g(h(b.nodes,b.edges));return}E();return}N.some(I=>I.type==="select")||N.some(I=>I.type==="position"&&I.dragging)||E()},[e,E,s.length,m,g,h]);kd(()=>{if(e&&s.length===0){let N=m();a({history:[N],currentStep:0})}},[e,s.length,m]);let x=ut(N=>{a({history:N||[],currentStep:0})},[]),T=ut(()=>{a({history:[],currentStep:0})},[]);return kd(()=>{let N=b=>{(b.ctrlKey||b.metaKey)&&(b.shiftKey&&b.key.toLowerCase()==="z"?(b.preventDefault(),p()):b.key.toLowerCase()==="z"&&(b.preventDefault(),f()))};return document.addEventListener("keydown",N),()=>{document.removeEventListener("keydown",N)}},[f,p]),{history:s,undo:f,redo:p,canUndo:c,canRedo:d,saveHistory:y,resetHistory:x,clearHistory:T}};var Od=()=>{let{t:e}=Qy(),[t,o,n]=e0([]),[r,i,a]=jy([]),{getNode:s}=o0(),{toast:l}=Ve(),c=n0(),{instanceId:d,isInitialized:u,setIsConnecting:f,setIsMultipleSelection:p,onElementClick:g}=Q(),{updateHelperLines:h,HelperLines:m}=rr(),{undo:E,redo:y,canUndo:x,canRedo:T,saveHistory:N}=Dd(u),{onNodeDrag:b,onDrop:w,onDragOver:C,onDragLeave:I,onNodeDragStop:k,onNodeDragStart:S}=Ed({nodes:t,setNodes:o,setEdges:i,saveHistory:N}),{isValidConnection:R,onConnect:U,onReconnect:K,onReconnectStart:ee,onReconnectEnd:A,setReconnectingEdge:M,clearReconnectingEdge:$}=id({setEdges:i,saveHistory:N}),{handleValidationComplete:V,clearValidation:L,dismissValidationPanel:G,validateDiagram:q,getIsClearingValidation:P}=gd(),{importFromLia:H}=Id(),{handleTasksStatus:Y,handleClearTaskStatus:z}=Ld(),{clearPathEdges:D}=Lt(),{emitElementChanges:J,handleNodeChanges:X,handleEdgeChanges:W}=Or(),B=In();xd({saveHistory:N}),bd({saveHistory:N}),Md();let F=Mt(()=>{o([]),i([]),D(),setTimeout(B,0)},[o,i,D,B]);Cd({LIA_CREATE_DIAGRAM:H,CLEAR_DIAGRAM:F,TASKS_STATUS:Y,CLEAR_TASKS_STATUS:z});let{selectElements:Z,clearSelection:j}=_t(),{importFromMxGraph:le,exportToMxGraph:ce}=Ao(),{configureElement:de,getConfigureElement:ue}=pr(),he=Mt(()=>t.length+r.length,[t,r]);r0(()=>(nt.set(d,{importFromMxGraph:le,exportToMxGraph:ce,selectElements:Z,clearSelection:j,configureElement:de,getConfigureElement:ue,getElementsCount:he,setReconnectingEdge:M,clearReconnectingEdge:$}),()=>{nt.delete(d)}),[d,le,ce,Z,j,de,ue,he,M,$]);let ye=Mt((Ee,Ae)=>{if(Ae.type!=="TASK"&&Ae.type!=="GATEWAY")return;let Qe=ue(Ae.id);Qe&&(g==null||g(Qe))},[ue,g]),fe=Mt((Ee,Ae)=>{if(Ae.type!=="SEQUENCE_EDGE")return;let Qe=s(Ae.source),jr=s(Ae.target),{isFromStartEvent:yu,isGatewayToGateway:xu,isActiviyToAndGateway:Eu}=An(Qe,jr);if(!(!yu&&!xu&&!Eu))return;let es=ue(Ae.id);es&&(g==null||g(es))},[ue,s,g]),se=Mt(Ee=>{let Ae=h(Ee,t);n(Ae),N(Ee),P()||G(),X(Ee)},[t,n,N,P,G,h,X]),re=Mt(Ee=>{a(Ee),N(Ee),P()||G(),W(Ee)},[a,N,P,G,W]);Td(se);let ve=Mt(({nodes:Ee,edges:Ae})=>{p(Ee.length+Ae.length>=2)},[p]);t0({onChange:ve});let ke=Mt(async({nodes:Ee})=>Ee.some(Qe=>Qe.type==="LANE"&&t.some(jr=>jr.parentId===Qe.id))?(l({variant:"error",title:e("validation.errors.title"),content:e("editor.toolbar.delete_pool_lane_error")}),!1):!0,[t,e,l]);return{nodes:t,setNodes:o,edges:r,setEdges:i,events:{isValidConnection:R,onConnect:U,onReconnect:K,onReconnectStart:ee,onReconnectEnd:A,onDrop:w,onDragOver:C,onDragLeave:I,onNodeDrag:b,onNodeDragStop:k,onNodeDragStart:S,onNodeClick:ye,onEdgeClick:fe,onDropCapture:()=>{N("forceSave"),J(),G()},onConnectStart:()=>{f(!0)},onConnectEnd:()=>{f(!1),G()},onSelectionEnd:()=>setTimeout(()=>c.setState({nodesSelectionActive:!1}),0),onNodesChange:se,onEdgesChange:re,onBeforeDelete:ke},ui:{handleCloseValidationPanel:L},controls:{undo:E,redo:y,canUndo:x,canRedo:T},components:{HelperLines:m},actions:{saveHistory:N,selectElements:Z,clearSelection:j,exportToMxGraph:ce,validateDiagram:q,handleValidationComplete:V,setReconnectingEdge:M,clearReconnectingEdge:$}}};import{jsx as Vd}from"react/jsx-runtime";var Wi=({id:e,className:t})=>Vd("marker",{id:e,className:O("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:Vd("path",{d:"M 0 0 L 10 5 L 0 10 Z"})});import{jsx as Xi,jsxs as i0}from"react/jsx-runtime";var Hd=()=>Xi("svg",{style:{position:"absolute",top:0,left:0},children:i0("defs",{children:[Xi(Wi,{id:"sequence-edge-marker",className:"text-grey-500"}),Xi(Wi,{id:"sequence-edge-marker-highlighted",className:"text-blue-500"})]})});import{Tooltip as Nx,TooltipContent as vx,TooltipTrigger as wx,useTranslation as Ax}from"@produto-lecom/lecom-ui";import{useKeyPress as ou,useReactFlow as U0}from"@xyflow/react";import{Button as Wr,Tooltip as Xr,TooltipContent as Ur,TooltipTrigger as $r,useTranslation as $0}from"@produto-lecom/lecom-ui";import{HandIcon as K0,ListCheckIcon as q0,MapIcon as Z0,MousePointerIcon as J0}from"lucide-react";import{useCallback as qi,useEffect as nu}from"react";import{Tooltip as w0,TooltipContent as A0,TooltipTrigger as I0,useTranslation as C0}from"@produto-lecom/lecom-ui";var gn=(x=>(x.START_EVENT="START_EVENT",x.END_EVENT="END_EVENT",x.TASK="TASK",x.SUBPROCESS="SUBPROCESS",x.GATEWAY="GATEWAY",x.LANE="LANE",x.ANNOTATION="ANNOTATION",x.CONNECTION="CONNECTION",x.INTERMEDIATE_EVENT="INTERMEDIATE_EVENT",x.ACTIVITY="ACTIVITY",x.PROCESS_INTERFACE="PROCESS_INTERFACE",x.WORKFLOW_INTERFACE="WORKFLOW_INTERFACE",x.VARIANT_ACTIVITY="VARIANT_ACTIVITY",x.AUTO_ACTIVITY="AUTO_ACTIVITY",x.DATA_STORE="DATA_STORE",x.DATA_OBJECT="DATA_OBJECT",x.DATA_OUTPUT="DATA_OUTPUT",x.DATA_INPUT="DATA_INPUT",x.MARKER="MARKER",x))(gn||{});import{Button as y0,useTranslation as x0}from"@produto-lecom/lecom-ui";import{useReactFlow as E0}from"@xyflow/react";var Gd=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 Bd({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);Gr(i,`${o}.csv`)}var Gr=(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 zd(e){return e==null?void 0:e.replaceAll("&#xA;"," ")}var WL={START_EVENT:"START_EVENT",END_EVENT:"END_EVENT",TASK:"TASK",GATEWAY:"GATEWAY",ANNOTATION:"ANNOTATION"},Yd={script:"SCRIPT",subprocess:"SUBPROCESS"},Fd={"marker-loop":"LOOP"},Wd={complex:"COMPLEX",none:"EXCLUSIVE",exclusive:"EXCLUSIVE",parallel:"PARALLEL",inclusive:"EXCLUSIVE"};var Xt=({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}}},a0=e=>{let{subType:t,style:o}=e._attributes,n="imported";return["none"].includes(t)||(n="adapted"),e.mxGeometry._attributes.width=ne.START_EVENT.MIN_WIDTH,e.mxGeometry._attributes.height=ne.START_EVENT.MIN_HEIGHT,{node:Xt({cell:e,type:"START_EVENT"}),status:n,originalType:o}},l0=e=>{let{subType:t,style:o}=e==null?void 0:e._attributes,n="imported";return["none"].includes(t)||(n="adapted"),e.mxGeometry._attributes.width=ne.END_EVENT.MIN_WIDTH,e.mxGeometry._attributes.height=ne.END_EVENT.MIN_HEIGHT,{node:Xt({cell:e,type:"END_EVENT"}),status:n,originalType:o}},c0=(e,t)=>{let{id:o,subType:n,style:r}=e==null?void 0:e._attributes,i=Yd[n],a=t.get(o)||"",s=Fd[a]||"",l=s==="LOOP",c="imported";return!["script","none"].includes(n)&&!l&&(c="adapted"),e.mxGeometry._attributes.width=mt(e.mxGeometry._attributes.width||0,ne.TASK.MIN_WIDTH),e.mxGeometry._attributes.height=mt(e.mxGeometry._attributes.height||0,ne.TASK.MIN_HEIGHT),{node:Xt({cell:e,type:"TASK",variant:i,attribute:s}),status:c,originalType:r}},d0=e=>{let{style:t,subType:o}=e==null?void 0:e._attributes,n=Wd[o],r=["none","inclusive","event-based"],i="imported";return r.includes(o)&&(i="adapted"),e.mxGeometry._attributes.width=ne.GATEWAY.MIN_WIDTH,e.mxGeometry._attributes.height=ne.GATEWAY.MIN_HEIGHT,{node:Xt({cell:e,type:"GATEWAY",variant:n}),status:i,originalType:t}},u0=e=>{let{style:t}=e==null?void 0:e._attributes;return{node:Xt({cell:e,type:"LANE"}),status:"imported",originalType:t}},p0=e=>{let{style:t}=e==null?void 0:e._attributes;return e.mxGeometry._attributes.width=mt(e.mxGeometry._attributes.width||0,ne.ANNOTATION.MIN_WIDTH),e.mxGeometry._attributes.height=mt(e.mxGeometry._attributes.height||0,ne.ANNOTATION.MIN_HEIGHT),{node:Xt({cell:e,type:"ANNOTATION"}),status:"imported",originalType:t}},Xd=e=>{let{style:t}=e==null?void 0:e._attributes;return e.mxGeometry._attributes.width=ne.UNSUPPORTED.MIN_WIDTH,e.mxGeometry._attributes.height=ne.UNSUPPORTED.MIN_HEIGHT,{node:Xt({cell:e,type:"UNSUPPORTED"}),status:"unsupported",originalType:t}},Ud=(e,t)=>{let{id:o,source:n,target:r,value:i}=e._attributes;return v(_({},Ye),{id:o,source:t.get(n)||n,target:t.get(r)||r,data:{label:i||""}})},$d={TASK:c0,GATEWAY:d0,START_EVENT:a0,END_EVENT:l0,LANE:u0,ANNOTATION:p0};var f0=e=>{let t=new Map,o=Object.values(gn),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=$d[l]||Xd,{node:d,status:u,originalType:f}=c(s,r);a.push(d),i.push({originalType:f,type:d.type,variant:d.data.variant,value:zd(d.data.label),status:u})}return{nodes:a,governanceIdToNodeIdMap:t,summary:i}},m0=(e,t)=>e.filter(r=>{var i;return(i=r._attributes)==null?void 0:i.edge}).map(r=>Ud(r,t)),g0=e=>{let{mxGraphModel:t}=e,{nodes:o,governanceIdToNodeIdMap:n,summary:r}=f0(t.root.mxCell),i=m0(t.root.mxCell,n);return{nodes:o,edges:i,summary:r}},h0=async e=>{let t=await Gd(e),o=Cr(t);if(!o)throw new Error("EMPTY_FILE");let{metadata:n,mxGraphModel:r}=o.modeler||{},i=(n==null?void 0:n.app)&&(n==null?void 0:n.diagramType)&&(n==null?void 0:n.version),a=r==null?void 0:r.root;if(!i||!a)throw new Error("INVALID_FILE");if(!Object.keys(r.root.mxCell||{}).length)throw new Error("CONTAIN_NO_CELLS");return{metadata:n,mxGraphModel:r}},Kd=async e=>{try{let t=await h0(e),{nodes:o,edges:n,summary:r}=g0(t)||{};return{nodes:o,edges:n,summary:r}}catch(t){throw t}};import{jsx as b0}from"react/jsx-runtime";var qd=()=>{let{t:e}=x0(),{toast:t}=Ve(),{setNodes:o,setEdges:n,fitView:r}=E0(),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:b0(y0,{size:"small",variant:"ghost",onClick:()=>Bd({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 Kd(s);if(o(f=>f.concat(l)),n(f=>f.concat(c)),r({padding:No,minZoom:vo,maxZoom:wo}),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 _0}from"@produto-lecom/lecom-ui";import{useRef as T0}from"react";import{Fragment as N0,jsx as Zd,jsxs as v0}from"react/jsx-runtime";var Jd=s=>{var l=s,{children:e,accept:t="*",multiple:o=!1,disabled:n=!1,onClick:r,onFilesSelected:i}=l,a=je(l,["children","accept","multiple","disabled","onClick","onFilesSelected"]);let c=T0(null),d=f=>{let p=f.target.files;p!=null&&p.length&&i(p),c.current&&(c.current.value="")};return v0(N0,{children:[Zd(_0,v(_({disabled:n,onClick:f=>{var p;(p=c.current)==null||p.click(),r==null||r(f)}},a),{children:e})),Zd("input",{type:"file",ref:c,className:"sr-only",accept:t,multiple:o,disabled:n,onChange:d})]})};import{jsx as Br,jsxs as S0}from"react/jsx-runtime";var Qd=({disabled:e=!1})=>{let{t}=C0(),{toast:o}=Ve(),{importFromGovernance:n}=qd(),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 S0(w0,{children:[Br(I0,{asChild:!0,children:Br(Jd,{className:"[&>svg]:size-7 p-0",variant:"ghost",size:"small",color:"grey",iconButton:!0,accept:".mdr",disabled:e,onClick:r,onFilesSelected:i,children:Br(us,{})})}),Br(A0,{color:"black",children:t("editor.controls.actions.import_governance")})]})};import{jsx as M0}from"react/jsx-runtime";var Ui=({shortcut:e})=>M0("span",{className:"min-h-7.5 inline-flex justify-center items-center py-0.5 px-1.5 bg-grey-100 border border-grey-300 font-mono text-gray-800 shadow-lg rounded-md text-grey-900",children:e});import{Button as O0,DropdownMenu as V0,DropdownMenuContent as H0,DropdownMenuItem as Ki,DropdownMenuTrigger as G0,Tooltip as zr,TooltipContent as Yr,TooltipTrigger as Fr,useTranslation as B0}from"@produto-lecom/lecom-ui";import{FileCodeIcon as z0,FileImageIcon as Y0,FolderOutputIcon as F0,PrinterIcon as W0}from"lucide-react";import{useState as X0}from"react";import{useTranslation as P0}from"@produto-lecom/lecom-ui";import{useReactFlow as L0}from"@xyflow/react";import{toPng as jd,toSvg as k0}from"html-to-image";import{useState as R0}from"react";var D0=3,$i="diagram",eu=()=>{let{t:e}=P0(),{toast:t}=Ve(),{getNodes:o}=L0(),{clearSelection:n}=_t(),[r,i]=R0({png:!1,html:!1,print:!1}),a=()=>{let{x:u,y:f,width:p,height:g}=dc(o());return{width:p,height:g,style:{width:`${p}px`,height:`${g}px`,transform:`translate(${-u}px, ${-f}px)`}}},s=async(u,f)=>{i(v(_({},r),{[f]:!0})),await n();try{let p=cc();if(!p)throw new Error("Flow element not found");let g=a();return await u(p,g)}catch(p){t({content:e("editor.controls.actions.export.feedback.error"),variant:"error"})}finally{i(v(_({},r),{[f]:!1}))}};return{exportAsPng:async(u=$i)=>{await s(async(f,p)=>{let g=await jd(f,v(_({},p),{backgroundColor:"#fcfcfc"}));Gr(g,`${u}.png`)},"png")},exportAsHtml:async(u=$i)=>{await s(async(f,p)=>{let g=await k0(f,v(_({},p),{backgroundColor:"#fcfcfc"})),h=`
44
44
  <!DOCTYPE html>
45
45
  <html>
46
46
  <head>
@@ -51,10 +51,10 @@ var hu=Object.defineProperty,yu=Object.defineProperties;var xu=Object.getOwnProp
51
51
  </style>
52
52
  </head>
53
53
  <body>
54
- <img src="${h}" alt="Diagram" />
54
+ <img src="${g}" alt="Diagram" />
55
55
  </body>
56
56
  </html>
57
- `,m=new Blob([g],{type:"text/html"}),E=URL.createObjectURL(m);Dr(E,`${u}.html`),setTimeout(()=>URL.revokeObjectURL(E),100)},"html")},printDiagram:async(u=Ui)=>{await a(async(p,f)=>{let h=await qd(p,v(y({},f),{pixelRatio:v0})),g=window.open("","_blank");if(!g)throw new Error("Failed to open print window.");let m=g.document;m.open(),m.write(`
57
+ `,m=new Blob([h],{type:"text/html"}),E=URL.createObjectURL(m);Gr(E,`${u}.html`),setTimeout(()=>URL.revokeObjectURL(E),100)},"html")},printDiagram:async(u=$i)=>{await s(async(f,p)=>{let g=await jd(f,v(_({},p),{pixelRatio:D0})),h=window.open("","_blank");if(!h)throw new Error("Failed to open print window.");let m=h.document;m.open(),m.write(`
58
58
  <!DOCTYPE html>
59
59
  <html>
60
60
  <head>
@@ -67,7 +67,7 @@ var hu=Object.defineProperty,yu=Object.defineProperties;var xu=Object.getOwnProp
67
67
  </style>
68
68
  </head>
69
69
  <body>
70
- <img src="${h}" alt="Diagram" onload="window.print(); window.close();" />
70
+ <img src="${g}" alt="Diagram" onload="window.print(); window.close();" />
71
71
  </body>
72
72
  </html>
73
- `),m.close()},"print")},isPrintingPng:r.png,isPrintingHtml:r.html,isPrinting:r.print}};import{jsx as be,jsxs as vo}from"react/jsx-runtime";function Jd(){let{t:e}=S0(),{exportAsPng:t,exportAsHtml:o,printDiagram:n,isPrinting:r,isPrintingPng:i,isPrintingHtml:s}=Zd(),[a,l]=R0(!1);return vo(A0,{modal:!1,open:a,onOpenChange:l,children:[be(C0,{asChild:!0,children:be("div",{children:vo(Vr,{children:[be(Gr,{asChild:!0,children:be(w0,{size:"small",variant:"ghost",color:"grey",iconButton:!0,children:be(L0,{})})}),!a&&be(Hr,{color:"black",children:e("editor.controls.actions.export.title")})]})})}),vo(I0,{align:"center",side:"top",sideOffset:16,className:"min-w-0 flex flex-col gap-2 p-2 shadow-sm",children:[vo(Vr,{children:[be(Gr,{asChild:!0,children:be($i,{className:"p-1.5",disabled:i,onClick:()=>t(),children:be(P0,{})})}),be(Hr,{side:"right",color:"black",children:e("editor.controls.actions.export.png")})]}),vo(Vr,{children:[be(Gr,{asChild:!0,children:be($i,{className:"p-1.5",disabled:s,onClick:()=>o(),children:be(M0,{})})}),be(Hr,{side:"right",color:"black",children:e("editor.controls.actions.export.html")})]}),vo(Vr,{children:[be(Gr,{asChild:!0,children:be($i,{className:"p-1.5",disabled:r,onClick:()=>n(),children:be(k0,{})})}),be(Hr,{side:"right",color:"black",children:e("editor.controls.actions.export.print")})]})]})]})}import{Fragment as eu,jsx as _e,jsxs as dt}from"react/jsx-runtime";var tu=({nodes:e,edges:t,validateDiagram:o,handleValidationComplete:n})=>{let{t:r}=O0(),{clearSelection:i}=Et(),{mode:s,isMinimapOpen:a,setIsMinimapOpen:l,isMoveTool:c,isHandTool:d,setIsMoveTool:u,setIsHandTool:p}=Q(),{getNodes:f,getEdges:h}=D0(),g=Qd(["v","V"]),m=Qd(["h","H"]),E=Xi(()=>{i(),p(!0),u(!1)},[i,p,u]),_=Xi(()=>{u(!0),p(!1)},[u,p]),b=Xi(()=>{let T=f(),N=h(),x=o({nodes:T,edges:N});n(x)},[f,h,o,n]);return jd(()=>{g&&!c&&s==="edit"&&_()},[g,_,c,s]),jd(()=>{m&&!d&&s==="edit"&&E()},[m,E,d,s]),dt("div",{className:"flex items-center gap-2 px-3 py-2 bg-white rounded-sm shadow-md",children:[s==="edit"&&dt(eu,{children:[dt(zr,{children:[_e(Wr,{asChild:!0,children:_e(Br,{size:"small",variant:"ghost",color:"grey",className:O(c&&"bg-grey-400"),iconButton:!0,onClick:_,children:_e(B0,{})})}),dt(Fr,{color:"black",className:"flex items-center gap-2",children:[r("editor.controls.actions.move_tool"),_e(Yi,{shortcut:"V"})]})]}),dt(zr,{children:[_e(Wr,{asChild:!0,children:_e(Br,{size:"small",variant:"ghost",color:"grey",className:O(d&&"bg-grey-400"),iconButton:!0,onClick:E,children:_e(V0,{})})}),dt(Fr,{color:"black",className:"flex items-center gap-2",children:[r("editor.controls.actions.hand_tool")," ",_e(Yi,{shortcut:"H"})]})]})]}),_e(Jd,{}),s==="edit"&&dt(eu,{children:[dt(zr,{children:[_e(Wr,{asChild:!0,children:_e(Br,{size:"small",variant:"ghost",color:"grey",iconButton:!0,onClick:b,children:_e(H0,{})})}),_e(Fr,{color:"black",children:r("editor.controls.actions.check")})]}),_e(Kd,{disabled:e.length>0||t.length>0})]}),dt(zr,{children:[_e(Wr,{asChild:!0,children:_e(Br,{size:"small",variant:"ghost",color:"grey",className:O(a&&"bg-grey-400"),iconButton:!0,onClick:()=>l(!a),children:_e(G0,{})})}),_e(Fr,{color:"black",children:r(a?"editor.controls.actions.minimap.close":"editor.controls.actions.minimap.open")})]})]})};import{Button as ou,Tooltip as nu,TooltipContent as ru,TooltipTrigger as iu,useTranslation as z0}from"@produto-lecom/lecom-ui";import{RedoIcon as F0,UndoIcon as W0}from"lucide-react";import{jsx as Ct,jsxs as Ki}from"react/jsx-runtime";var su=({undo:e,redo:t,canUndo:o,canRedo:n})=>{let{t:r}=z0();return Ki("div",{className:"flex items-center gap-2 px-3 py-2 bg-white rounded-sm shadow-md",children:[Ki(nu,{children:[Ct(iu,{asChild:!0,children:Ct(ou,{size:"small",variant:"ghost",color:"grey",iconButton:!0,disabled:!o,onClick:e,children:Ct(W0,{})})}),Ct(ru,{color:"black",children:r("editor.controls.history.undo")})]}),Ki(nu,{children:[Ct(iu,{asChild:!0,children:Ct(ou,{size:"small",variant:"ghost",color:"grey",iconButton:!0,disabled:!n,onClick:t,children:Ct(F0,{})})}),Ct(ru,{color:"black",children:r("editor.controls.history.redo")})]})]})};import{useEdges as Y0,useNodes as U0,useReactFlow as $0}from"@xyflow/react";import{Button as Yr,Tooltip as Ur,TooltipContent as $r,TooltipTrigger as Xr,useTranslation as X0}from"@produto-lecom/lecom-ui";import{ScanIcon as K0,ZoomIn as q0,ZoomOut as Z0}from"lucide-react";import{jsx as Ce,jsxs as gn}from"react/jsx-runtime";var au=()=>{let{t:e}=X0(),t=U0(),o=Y0(),{zoomIn:n,zoomOut:r,zoomTo:i,fitView:s}=$0(),a=t.length===0&&o.length===0;return gn("div",{className:"flex items-center gap-2 px-3 py-2 bg-white rounded-sm shadow-md",children:[gn(Ur,{children:[Ce(Xr,{asChild:!0,children:Ce(Yr,{iconButton:!0,size:"small",color:"grey",variant:"ghost",disabled:a,onClick:()=>s(),children:Ce(K0,{})})}),Ce($r,{color:"black",children:e("editor.controls.zoom.fit")})]}),gn(Ur,{children:[Ce(Xr,{asChild:!0,children:Ce(Yr,{iconButton:!0,size:"small",color:"grey",variant:"ghost",disabled:a,onClick:()=>r(),children:Ce(Z0,{})})}),Ce($r,{color:"black",children:e("editor.controls.zoom.out")})]}),gn(Ur,{children:[Ce(Xr,{asChild:!0,children:Ce(Yr,{iconButton:!0,size:"small",color:"grey",variant:"ghost",disabled:a,onClick:()=>i(1),children:Ce(ps,{})})}),Ce($r,{color:"black",children:e("editor.controls.zoom.reset")})]}),gn(Ur,{children:[Ce(Xr,{asChild:!0,children:Ce(Yr,{iconButton:!0,size:"small",color:"grey",variant:"ghost",disabled:a,onClick:()=>n(),children:Ce(q0,{})})}),Ce($r,{color:"black",children:e("editor.controls.zoom.in")})]})]})};import{useNodes as J0}from"@xyflow/react";import{Button as Q0,Tooltip as j0,TooltipContent as ex,TooltipTrigger as tx,useTranslation as ox}from"@produto-lecom/lecom-ui";import{useRef as nx,useState as rx}from"react";import{jsx as Wt,jsxs as lu}from"react/jsx-runtime";var cu=()=>{let e=nx(null),{t}=ox(),{setDraggableNode:o}=ho(),n=J0(),{setIsDragging:r}=Q(),[i,s]=rx(void 0),a=[{type:"START_EVENT",icon:_n,label:t("bpmn.start_event.variant.default")},{type:"END_EVENT",icon:$t,label:t("bpmn.end_event.variant.default")},{type:"TASK",icon:Ao,label:t("bpmn.task.variant.default")},{type:"TASK",variant:"SUBPROCESS",icon:ys,label:t("bpmn.task.variant.subprocess")},{type:"TASK",variant:"SCRIPT",icon:hs,label:t("bpmn.task.variant.script")},{type:"TASK",attribute:"LOOP",icon:gs,label:t("bpmn.task.attribute.loop")},{type:"GATEWAY",variant:"EXCLUSIVE",icon:Kt,label:t("bpmn.gateway.variant.exclusive")},{type:"GATEWAY",variant:"PARALLEL",icon:qt,label:t("bpmn.gateway.variant.parallel")},{type:"GATEWAY",variant:"COMPLEX",icon:Xt,label:t("bpmn.gateway.variant.complex")},{type:"LANE",icon:us,label:t("bpmn.lane.variant.default")},{type:"ANNOTATION",icon:En,label:t("bpmn.annotation.variant.default")}],l=(c,d)=>{o({type:d.type,variant:d.variant,attribute:d.attribute,icon:d.icon}),s(Wt(d.icon,{})),c.dataTransfer.effectAllowed="move",e.current&&c.dataTransfer.setDragImage(e.current,10,10),setTimeout(()=>{r(!0)},100)};return lu("aside",{className:"sidebar absolute z-[1] top-4 left-4",children:[Wt("div",{className:"grid grid-cols-1 gap-2 p-2 bg-white rounded-md shadow-md",children:a.map((c,d)=>{let u=!xt(c.type,n),p=u?t("editor.toolbar.start_event_already_exists"):c.label;return lu(j0,{children:[Wt(tx,{asChild:!0,children:Wt(Q0,{className:O("[&>svg]:size-6",{"opacity-50 cursor-not-allowed":u}),size:"small",variant:"ghost",color:"grey",draggable:!u,disabled:u,iconButton:!0,onDragStart:u?void 0:f=>l(f,c),children:Wt(c.icon,{})},d)}),Wt(ex,{color:"black",side:"right",children:p})]},d)})}),Wt("div",{ref:e,className:"absolute w-0 h-0 top-0 left-0 z-[-1] bg-transparent",children:i})]})};import{jsx as Ke,jsxs as Kr}from"react/jsx-runtime";var qi=dx((e,t)=>{let o=cx("Space"),{instanceId:n,mode:r,isMinimapOpen:i,isMoveTool:s,isHandTool:a}=Q(),{nodes:l,edges:c,actions:d,events:u,components:p,controls:f}=Ld(),{t:h}=gx();ux(t,()=>({selectElements:d.selectElements,clearSelection:d.clearSelection}));let g=a||o||r!=="edit"?!0:Qc,m=r!=="readonly"&&s&&!o,E=r==="edit"&&s&&!o,_=r==="edit"&&s&&!o;return Kr("div",{className:"w-full h-full",children:[r==="edit"&&Ke(cu,{}),Ke(Rd,{}),Kr(ax,v(y({},u),{id:`modeler-${n}`,className:O({"is-hand-tool":a||o}),edges:c,nodes:l,nodeTypes:Wc,edgeTypes:Yc,minZoom:zi,maxZoom:Zc,panOnDrag:g,panOnScroll:!0,selectionOnDrag:!0,elevateEdgesOnSelect:!0,elevateNodesOnSelect:!1,elementsSelectable:m,nodesConnectable:E,nodesDraggable:_,connectionLineComponent:Gc,selectionMode:lx.Partial,multiSelectionKeyCode:["Control","Meta"],deleteKeyCode:"Delete",selectionKeyCode:null,defaultViewport:Jc,connectOnClick:!1,connectionRadius:50,proOptions:{hideAttribution:!0},children:[Ke(ix,{gap:Kc,size:Xc,color:$c,bgColor:Uc}),i&&Kr(px,{children:[Ke(mx,{asChild:!0,children:Ke("div",{className:"absolute bottom-[0px] left-[0px] z-[5]",children:Ke(sx,{pannable:!0,zoomable:!0,position:qc,className:"shadow-md rounded-md",ariaLabel:"",style:{pointerEvents:"all",position:"relative"}})})}),Ke(fx,{color:"black",children:h("editor.controls.actions.minimap.label")})]}),Kr("div",{className:"absolute z-10 bottom-4 left-1/2 -translate-x-1/2 flex gap-4",children:[r==="edit"&&Ke(su,y({},f)),Ke(tu,{nodes:l,edges:c,validateDiagram:d.validateDiagram,handleValidationComplete:d.handleValidationComplete}),Ke(au,{})]}),Ke(p.HelperLines,{})]}))]})});qi.displayName="Editor";import{useStore as hx}from"@xyflow/react";import{useEffect as yx,useRef as xx}from"react";import{jsx as bx}from"react/jsx-runtime";var Ex=e=>({width:e.width,height:e.height,transform:e.transform}),Zi="rgba(51, 103, 217, 0.4)",ml=({horizontal:e,vertical:t})=>{let{width:o,height:n,transform:r}=hx(Ex),i=xx(null);return yx(()=>{let s=i.current,a=s==null?void 0:s.getContext("2d");if(!a||!s)return;let l=window.devicePixelRatio;s.width=o*l,s.height=n*l,a.clearRect(0,0,o,n),a.scale(l,l),a.strokeStyle=Zi,t&&(a.beginPath(),a.strokeStyle=t.color||Zi,a.moveTo(t.position*r[2]+r[0],0),a.lineTo(t.position*r[2]+r[0],n),a.stroke()),e&&(a.beginPath(),a.strokeStyle=e.color||Zi,a.moveTo(0,e.position*r[2]+r[1]),a.lineTo(o,e.position*r[2]+r[1]),a.stroke())},[o,n,r,e,t]),bx("canvas",{ref:i,className:"w-full h-full absolute z-10 pointer-events-none"})};import{i18n as _x,Notification as Tx,TooltipProvider as Nx}from"@produto-lecom/lecom-ui";import{createContext as vx,useContext as wx,useEffect as Ax,useState as Ix}from"react";import{jsx as du,jsxs as Sx}from"react/jsx-runtime";var tt=new Map,uu=vx(null),Xo=()=>{let e=wx(uu);if(!e)throw new Error("useModeler must be used within an <ModelerProvider />");return e},Cx=({locale:e,defaultMode:t="view",toast:o,children:n})=>{let[r,i]=Ix(e||"pt_BR");Ax(()=>{e&&(i(e),_x.changeLanguage(e))},[e]);let s=h=>{let g=tt.size;if(g===0)throw new Error("No modeler instances found");if(g===1||!h){let[E]=tt.values();return E}let m=tt.get(h);if(!m)throw new Error(`Modeler instance with ID "${h}" not found`);return m},a=(h,g)=>{let m=s(g);return m==null?void 0:m.selectElements(h)},l=async h=>{let g=s(h);return g==null?void 0:g.clearSelection()},c=(h,g)=>{let m=s(g);return m==null?void 0:m.configureElement(h)},d=(h,g)=>{let m=s(g);return m==null?void 0:m.getConfigureElement(h)},u=async(h,g)=>{let m=s(g);await(m==null?void 0:m.importFromMxGraph(h))},p=h=>{let g=s(h);return g==null?void 0:g.exportToMxGraph()},f=h=>{let g=s(h);return(g==null?void 0:g.getElementsCount())||0};return du(uu.Provider,{value:{defaultMode:t,locale:r,selectElements:a,clearSelection:l,configureElement:c,getConfigureElement:d,importDiagram:u,exportDiagram:p,getElementsCount:f,toast:o},children:Sx(Nx,{children:[!o&&du(Tx,{type:"toast",placement:"topRight",enableClose:!0,showProgress:!0,pauseOnHover:!0}),n]})})};import{useTranslation as Ox}from"@produto-lecom/lecom-ui";import{jsx as Ji}from"react/jsx-runtime";var pu=Px(null),Q=()=>{let e=Lx(pu);if(!e)throw new Error("useModelerInstance must be used within an <Modeler />");return e},Vx=({selectorRef:e,initialDiagram:t,instanceId:o,mode:n,onElementChanges:r,onConfigureElement:i,onElementClick:s,onSubprocessValidationClick:a})=>{let{t:l}=Ox(),{defaultMode:c}=Xo(),d=Rx(),[u]=qe(o||d),[p,f]=qe(n||c||"edit"),[h,g]=qe(nn),[m,E]=qe(!1),[_,b]=qe(!0),[T,N]=qe(!1),[x,w]=qe(!1),[C,I]=qe(!1),[R,S]=qe(!1),[D,X]=qe(!1),[Z,te]=qe(null);kx(()=>{n&&f(n)},[n]);let A=Dx(()=>t||ac(l),[t,l]),M={instanceId:u,initialDiagram:A,mode:p,lastElementId:h,isInitialized:m,isMinimapOpen:x,isMoveTool:_,isHandTool:T,isDragging:C,isMultipleSelection:D,isConnecting:R,setLastElementId:g,setIsInitialized:E,reconnectingEdgeId:Z,setIsMinimapOpen:w,setIsMoveTool:b,setIsHandTool:N,setIsDragging:I,setIsConnecting:S,setIsMultipleSelection:X,setReconnectingEdgeId:te,onElementChanges:r,onConfigureElement:i,onElementClick:s,onSubprocessValidationClick:a};return Ji(Mx,{children:Ji(pu.Provider,{value:M,children:Ji(qi,{ref:e})})})};export{Le as EditorMode,Jr as ElementPosition,yn as ElementType,Qr as GatewayElementVariant,$e as GatewayVariant,Vx as Modeler,Cx as ModelerProvider,Qe as NodeAttribute,ee as NodeType,Ue as NodeVariant,jr as RoutingVariant,Xo as useModeler};
73
+ `),m.close()},"print")},isPrintingPng:r.png,isPrintingHtml:r.html,isPrinting:r.print}};import{jsx as Te,jsxs as Io}from"react/jsx-runtime";function tu(){let{t:e}=B0(),{exportAsPng:t,exportAsHtml:o,printDiagram:n,isPrinting:r,isPrintingPng:i,isPrintingHtml:a}=eu(),[s,l]=X0(!1);return Io(V0,{modal:!1,open:s,onOpenChange:l,children:[Te(G0,{asChild:!0,children:Te("div",{children:Io(zr,{children:[Te(Fr,{asChild:!0,children:Te(O0,{size:"small",variant:"ghost",color:"grey",iconButton:!0,children:Te(F0,{})})}),!s&&Te(Yr,{color:"black",children:e("editor.controls.actions.export.title")})]})})}),Io(H0,{align:"center",side:"top",sideOffset:16,className:"min-w-0 flex flex-col gap-2 p-2 shadow-sm",children:[Io(zr,{children:[Te(Fr,{asChild:!0,children:Te(Ki,{className:"p-1.5",disabled:i,onClick:()=>t(),children:Te(Y0,{})})}),Te(Yr,{side:"right",color:"black",children:e("editor.controls.actions.export.png")})]}),Io(zr,{children:[Te(Fr,{asChild:!0,children:Te(Ki,{className:"p-1.5",disabled:a,onClick:()=>o(),children:Te(z0,{})})}),Te(Yr,{side:"right",color:"black",children:e("editor.controls.actions.export.html")})]}),Io(zr,{children:[Te(Fr,{asChild:!0,children:Te(Ki,{className:"p-1.5",disabled:r,onClick:()=>n(),children:Te(W0,{})})}),Te(Yr,{side:"right",color:"black",children:e("editor.controls.actions.export.print")})]})]})]})}import{Fragment as ru,jsx as Ne,jsxs as pt}from"react/jsx-runtime";var iu=({nodes:e,edges:t,validateDiagram:o,handleValidationComplete:n})=>{let{t:r}=$0(),{clearSelection:i}=_t(),{mode:a,isMinimapOpen:s,setIsMinimapOpen:l,isMoveTool:c,isHandTool:d,setIsMoveTool:u,setIsHandTool:f}=Q(),{getNodes:p,getEdges:g}=U0(),h=ou(["v","V"]),m=ou(["h","H"]),E=qi(()=>{i(),f(!0),u(!1)},[i,f,u]),y=qi(()=>{u(!0),f(!1)},[u,f]),x=qi(()=>{let T=p(),N=g(),b=o({nodes:T,edges:N});n(b)},[p,g,o,n]);return nu(()=>{h&&!c&&a==="edit"&&y()},[h,y,c,a]),nu(()=>{m&&!d&&a==="edit"&&E()},[m,E,d,a]),pt("div",{className:"flex items-center gap-2 px-3 py-2 bg-white rounded-sm shadow-md",children:[a==="edit"&&pt(ru,{children:[pt(Xr,{children:[Ne($r,{asChild:!0,children:Ne(Wr,{size:"small",variant:"ghost",color:"grey",className:O(c&&"bg-grey-400"),iconButton:!0,onClick:y,children:Ne(J0,{})})}),pt(Ur,{color:"black",className:"flex items-center gap-2",children:[r("editor.controls.actions.move_tool"),Ne(Ui,{shortcut:"V"})]})]}),pt(Xr,{children:[Ne($r,{asChild:!0,children:Ne(Wr,{size:"small",variant:"ghost",color:"grey",className:O(d&&"bg-grey-400"),iconButton:!0,onClick:E,children:Ne(K0,{})})}),pt(Ur,{color:"black",className:"flex items-center gap-2",children:[r("editor.controls.actions.hand_tool")," ",Ne(Ui,{shortcut:"H"})]})]})]}),Ne(tu,{}),a==="edit"&&pt(ru,{children:[pt(Xr,{children:[Ne($r,{asChild:!0,children:Ne(Wr,{size:"small",variant:"ghost",color:"grey",iconButton:!0,onClick:x,children:Ne(q0,{})})}),Ne(Ur,{color:"black",children:r("editor.controls.actions.check")})]}),Ne(Qd,{disabled:e.length>0||t.length>0})]}),pt(Xr,{children:[Ne($r,{asChild:!0,children:Ne(Wr,{size:"small",variant:"ghost",color:"grey",className:O(s&&"bg-grey-400"),iconButton:!0,onClick:()=>l(!s),children:Ne(Z0,{})})}),Ne(Ur,{color:"black",children:r(s?"editor.controls.actions.minimap.close":"editor.controls.actions.minimap.open")})]})]})};import{Button as su,Tooltip as au,TooltipContent as lu,TooltipTrigger as cu,useTranslation as Q0}from"@produto-lecom/lecom-ui";import{RedoIcon as j0,UndoIcon as ex}from"lucide-react";import{jsx as Pt,jsxs as Zi}from"react/jsx-runtime";var du=({undo:e,redo:t,canUndo:o,canRedo:n})=>{let{t:r}=Q0();return Zi("div",{className:"flex items-center gap-2 px-3 py-2 bg-white rounded-sm shadow-md",children:[Zi(au,{children:[Pt(cu,{asChild:!0,children:Pt(su,{size:"small",variant:"ghost",color:"grey",iconButton:!0,disabled:!o,onClick:e,children:Pt(ex,{})})}),Pt(lu,{color:"black",children:r("editor.controls.history.undo")})]}),Zi(au,{children:[Pt(cu,{asChild:!0,children:Pt(su,{size:"small",variant:"ghost",color:"grey",iconButton:!0,disabled:!n,onClick:t,children:Pt(j0,{})})}),Pt(lu,{color:"black",children:r("editor.controls.history.redo")})]})]})};import{useEdges as tx,useNodes as ox,useReactFlow as nx}from"@xyflow/react";import{Button as Kr,Tooltip as qr,TooltipContent as Zr,TooltipTrigger as Jr,useTranslation as rx}from"@produto-lecom/lecom-ui";import{ScanIcon as ix,ZoomIn as sx,ZoomOut as ax}from"lucide-react";import{jsx as Me,jsxs as hn}from"react/jsx-runtime";var uu=()=>{let{t:e}=rx(),t=ox(),o=tx(),{zoomIn:n,zoomOut:r,zoomTo:i,fitView:a}=nx(),s=t.length===0&&o.length===0;return hn("div",{className:"flex items-center gap-2 px-3 py-2 bg-white rounded-sm shadow-md",children:[hn(qr,{children:[Me(Jr,{asChild:!0,children:Me(Kr,{iconButton:!0,size:"small",color:"grey",variant:"ghost",disabled:s,onClick:()=>a(),children:Me(ix,{})})}),Me(Zr,{color:"black",children:e("editor.controls.zoom.fit")})]}),hn(qr,{children:[Me(Jr,{asChild:!0,children:Me(Kr,{iconButton:!0,size:"small",color:"grey",variant:"ghost",disabled:s,onClick:()=>r(),children:Me(ax,{})})}),Me(Zr,{color:"black",children:e("editor.controls.zoom.out")})]}),hn(qr,{children:[Me(Jr,{asChild:!0,children:Me(Kr,{iconButton:!0,size:"small",color:"grey",variant:"ghost",disabled:s,onClick:()=>i(1),children:Me(ms,{})})}),Me(Zr,{color:"black",children:e("editor.controls.zoom.reset")})]}),hn(qr,{children:[Me(Jr,{asChild:!0,children:Me(Kr,{iconButton:!0,size:"small",color:"grey",variant:"ghost",disabled:s,onClick:()=>n(),children:Me(sx,{})})}),Me(Zr,{color:"black",children:e("editor.controls.zoom.in")})]})]})};import{useNodes as lx}from"@xyflow/react";import{Button as cx,Tooltip as dx,TooltipContent as ux,TooltipTrigger as px,useTranslation as fx}from"@produto-lecom/lecom-ui";import{useRef as mx,useState as gx}from"react";import{jsx as Ut,jsxs as pu}from"react/jsx-runtime";var fu=()=>{let e=mx(null),{t}=fx(),{setDraggableNode:o}=Eo(),n=lx(),{setIsDragging:r}=Q(),[i,a]=gx(void 0),s=[{type:"START_EVENT",icon:Tn,label:t("bpmn.start_event.variant.default")},{type:"END_EVENT",icon:qt,label:t("bpmn.end_event.variant.default")},{type:"TASK",icon:So,label:t("bpmn.task.variant.default")},{type:"TASK",variant:"SUBPROCESS",icon:Es,label:t("bpmn.task.variant.subprocess")},{type:"TASK",variant:"SCRIPT",icon:xs,label:t("bpmn.task.variant.script")},{type:"TASK",attribute:"LOOP",icon:ys,label:t("bpmn.task.attribute.loop")},{type:"GATEWAY",variant:"EXCLUSIVE",icon:Jt,label:t("bpmn.gateway.variant.exclusive")},{type:"GATEWAY",variant:"PARALLEL",icon:Qt,label:t("bpmn.gateway.variant.parallel")},{type:"GATEWAY",variant:"COMPLEX",icon:Zt,label:t("bpmn.gateway.variant.complex")},{type:"LANE",icon:fs,label:t("bpmn.lane.variant.default")},{type:"ANNOTATION",icon:bn,label:t("bpmn.annotation.variant.default")}],l=(c,d)=>{o({type:d.type,variant:d.variant,attribute:d.attribute,icon:d.icon}),a(Ut(d.icon,{})),c.dataTransfer.effectAllowed="move",e.current&&c.dataTransfer.setDragImage(e.current,10,10),setTimeout(()=>{r(!0)},100)};return pu("aside",{className:"sidebar absolute z-[1] top-4 left-4",children:[Ut("div",{className:"grid grid-cols-1 gap-2 p-2 bg-white rounded-md shadow-md",children:s.map((c,d)=>{let u=!bt(c.type,n),f=u?t("editor.toolbar.start_event_already_exists"):c.label;return pu(dx,{children:[Ut(px,{asChild:!0,children:Ut(cx,{className:O("[&>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:Ut(c.icon,{})},d)}),Ut(ux,{color:"black",side:"right",children:f})]},d)})}),Ut("div",{ref:e,className:"absolute w-0 h-0 top-0 left-0 z-[-1] bg-transparent",children:i})]})};import{jsx as Ze,jsxs as Qr}from"react/jsx-runtime";var Ji=_x((e,t)=>{let o=bx("Space"),{instanceId:n,mode:r,isMinimapOpen:i,isMoveTool:a,isHandTool:s}=Q(),{nodes:l,edges:c,actions:d,events:u,components:f,controls:p}=Od(),{t:g}=Ax();Tx(t,()=>({selectElements:d.selectElements,clearSelection:d.clearSelection}));let h=s||o||r!=="edit"?!0:od,m=r!=="readonly"&&a&&!o,E=r==="edit"&&a&&!o,y=r==="edit"&&a&&!o;return Qr("div",{className:"w-full h-full",children:[r==="edit"&&Ze(fu,{}),Ze(Hd,{}),Qr(xx,v(_({},u),{id:`modeler-${n}`,className:O({"is-hand-tool":s||o}),edges:c,nodes:l,nodeTypes:$c,edgeTypes:Kc,minZoom:Fi,maxZoom:ed,panOnDrag:h,panOnScroll:!0,selectionOnDrag:!0,elevateEdgesOnSelect:!0,elevateNodesOnSelect:!1,elementsSelectable:m,nodesConnectable:E,nodesDraggable:y,connectionLineComponent:Fc,selectionMode:Ex.Partial,multiSelectionKeyCode:["Control","Meta"],deleteKeyCode:"Delete",selectionKeyCode:null,defaultViewport:td,connectOnClick:!1,connectionRadius:50,proOptions:{hideAttribution:!0},children:[Ze(hx,{gap:Qc,size:Jc,color:Zc,bgColor:qc}),i&&Qr(Nx,{children:[Ze(wx,{asChild:!0,children:Ze("div",{className:"absolute bottom-[0px] left-[0px] z-[5]",children:Ze(yx,{pannable:!0,zoomable:!0,position:jc,className:"shadow-md rounded-md",ariaLabel:"",style:{pointerEvents:"all",position:"relative"}})})}),Ze(vx,{color:"black",children:g("editor.controls.actions.minimap.label")})]}),Qr("div",{className:"absolute z-10 bottom-4 left-1/2 -translate-x-1/2 flex gap-4",children:[r==="edit"&&Ze(du,_({},p)),Ze(iu,{nodes:l,edges:c,validateDiagram:d.validateDiagram,handleValidationComplete:d.handleValidationComplete}),Ze(uu,{})]}),Ze(f.HelperLines,{})]}))]})});Ji.displayName="Editor";import{useStore as Ix}from"@xyflow/react";import{useEffect as Cx,useRef as Sx}from"react";import{jsx as Px}from"react/jsx-runtime";var Mx=e=>({width:e.width,height:e.height,transform:e.transform}),Qi="rgba(51, 103, 217, 0.4)",hl=({horizontal:e,vertical:t})=>{let{width:o,height:n,transform:r}=Ix(Mx),i=Sx(null);return Cx(()=>{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=Qi,t&&(s.beginPath(),s.strokeStyle=t.color||Qi,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||Qi,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]),Px("canvas",{ref:i,className:"w-full h-full absolute z-10 pointer-events-none"})};import{i18n as Lx,Notification as kx,TooltipProvider as Rx}from"@produto-lecom/lecom-ui";import{createContext as Dx,useContext as Ox,useEffect as Vx,useState as Hx}from"react";import{jsx as mu,jsxs as Bx}from"react/jsx-runtime";var nt=new Map,gu=Dx(null),Zo=()=>{let e=Ox(gu);if(!e)throw new Error("useModeler must be used within an <ModelerProvider />");return e},Gx=({locale:e,defaultMode:t="view",toast:o,children:n})=>{let[r,i]=Hx(e||"pt_BR");Vx(()=>{e&&(i(e),Lx.changeLanguage(e))},[e]);let a=g=>{let h=nt.size;if(h===0)throw new Error("No modeler instances found");if(h===1||!g){let[E]=nt.values();return E}let m=nt.get(g);if(!m)throw new Error(`Modeler instance with ID "${g}" not found`);return m},s=(g,h)=>{let m=a(h);return m==null?void 0:m.selectElements(g)},l=async g=>{let h=a(g);return h==null?void 0:h.clearSelection()},c=(g,h)=>{let m=a(h);return m==null?void 0:m.configureElement(g)},d=(g,h)=>{let m=a(h);return m==null?void 0:m.getConfigureElement(g)},u=async(g,h)=>{let m=a(h);await(m==null?void 0:m.importFromMxGraph(g))},f=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 mu(gu.Provider,{value:{defaultMode:t,locale:r,selectElements:s,clearSelection:l,configureElement:c,getConfigureElement:d,importDiagram:u,exportDiagram:f,getElementsCount:p,toast:o},children:Bx(Rx,{children:[!o&&mu(kx,{type:"toast",placement:"topRight",enableClose:!0,showProgress:!0,pauseOnHover:!0}),n]})})};import{useTranslation as $x}from"@produto-lecom/lecom-ui";import{jsx as ji}from"react/jsx-runtime";var hu=Yx(null),Q=()=>{let e=Fx(hu);if(!e)throw new Error("useModelerInstance must be used within an <Modeler />");return e},Kx=({selectorRef:e,initialDiagram:t,instanceId:o,mode:n,onElementChanges:r,onConfigureElement:i,onElementClick:a,onSubprocessValidationClick:s})=>{let{t:l}=$x(),{defaultMode:c}=Zo(),d=Xx(),[u]=Je(o||d),[f,p]=Je(n||c||"edit"),[g,h]=Je(rn),[m,E]=Je(!1),[y,x]=Je(!0),[T,N]=Je(!1),[b,w]=Je(!1),[C,I]=Je(!1),[k,S]=Je(!1),[R,U]=Je(!1),[K,ee]=Je(null);Wx(()=>{n&&p(n)},[n]);let A=Ux(()=>t||uc(l),[t,l]),M={instanceId:u,initialDiagram:A,mode:f,lastElementId:g,isInitialized:m,isMinimapOpen:b,isMoveTool:y,isHandTool:T,isDragging:C,isMultipleSelection:R,isConnecting:k,setLastElementId:h,setIsInitialized:E,reconnectingEdgeId:K,setIsMinimapOpen:w,setIsMoveTool:x,setIsHandTool:N,setIsDragging:I,setIsConnecting:S,setIsMultipleSelection:U,setReconnectingEdgeId:ee,onElementChanges:r,onConfigureElement:i,onElementClick:a,onSubprocessValidationClick:s};return ji(zx,{children:ji(hu.Provider,{value:M,children:ji(Ji,{ref:e})})})};export{Re as EditorMode,ti as ElementPosition,xn as ElementType,oi as GatewayElementVariant,Ke as GatewayVariant,Kx as Modeler,Gx as ModelerProvider,et as NodeAttribute,te as NodeType,$e as NodeVariant,ni as RoutingVariant,Zo as useModeler};