lecom-modeler 0.21.0 → 0.22.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/index.cjs +13 -11
- package/lib/index.css +1 -1
- package/lib/index.js +13 -11
- package/lib/style.min.css +1 -1
- package/package.json +1 -1
package/lib/index.js
CHANGED
|
@@ -1,8 +1,9 @@
|
|
|
1
|
-
var uu=Object.defineProperty,pu=Object.defineProperties;var fu=Object.getOwnPropertyDescriptors;var gn=Object.getOwnPropertySymbols;var qi=Object.prototype.hasOwnProperty,Zi=Object.prototype.propertyIsEnumerable;var Ki=(e,t,o)=>t in e?uu(e,t,{enumerable:!0,configurable:!0,writable:!0,value:o}):e[t]=o,x=(e,t)=>{for(var o in t||(t={}))qi.call(t,o)&&Ki(e,o,t[o]);if(gn)for(var o of gn(t))Zi.call(t,o)&&Ki(e,o,t[o]);return e},v=(e,t)=>pu(e,fu(t));var Je=(e,t)=>{var o={};for(var n in e)qi.call(e,n)&&t.indexOf(n)<0&&(o[n]=e[n]);if(e!=null&&gn)for(var n of gn(e))t.indexOf(n)<0&&Zi.call(e,n)&&(o[n]=e[n]);return o};var Kr=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 mu,Translations as gu}from"@produto-lecom/lecom-ui";var Ji={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 Qi={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 ji={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 es={pt_BR:ji,en_US:Ji,es_ES:Qi};var ts,os,hu=(os=(ts=Kr("LecomUserLanguage"))!=null?ts:Kr("org.springframework.web.servlet.i18n.CookieLocaleResolver.LOCALE"))!=null?os:gu.PT_BR;mu({lng:hu,resources:es});var Pe=(n=>(n.EDIT="edit",n.VIEW="view",n.READONLY="readonly",n))(Pe||{});var hn=(r=>(r.ACTIVITY="activity",r.ROUTING="routing",r.GATEWAY="gateway",r.SUB_PROCESS="sub_process",r))(hn||{}),qr=(n=>(n.START="start",n.END="end",n.BETWEEN="between",n))(qr||{}),Zr=(n=>(n.SCRIPT="script",n.LOOP="loop",n.SCRIPT_LOOP="script_loop",n))(Zr||{}),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 Cu,ScrollText as Su,SquarePlus as Mu}from"lucide-react";import{jsx as yn,jsxs as yu}from"react/jsx-runtime";var xn=({size:e=24,className:t})=>yu("svg",{width:e,height:e,viewBox:"0 0 24 24",xmlns:"http://www.w3.org/2000/svg",fill:"#6b7280",className:t,children:[yn("path",{strokeWidth:"2",d:"M16 3V3.5085V11.9998V20.4915V21H16.5411H21.4592H22V19.123H21.4592H17.9974V11.9998V4.8773H21.4592H22V3H21.4592H16.5411H16Z"}),yn("path",{d:"M4.41026 16.9999L2 18.7861L3.89693 21.1103L6.3072 19.324L4.41026 16.9999Z"}),yn("path",{d:"M8.41026 13.9999L6 15.7861L7.89693 18.1103L10.3072 16.324L8.41026 13.9999Z"}),yn("path",{d:"M12.4313 10.954L10.021 12.7402L11.9179 15.0644L14.3282 13.2781L12.4313 10.954Z"})]});import{jsx as ns}from"react/jsx-runtime";var $t=({size:e=24,className:t})=>ns("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:ns("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 vo,jsxs as xu}from"react/jsx-runtime";var Xt=({size:e=24,className:t})=>xu("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:[vo("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"}),vo("path",{d:"M12 8V16",strokeLinecap:"round",strokeLinejoin:"round"}),vo("path",{d:"M8 12H16",strokeLinecap:"round",strokeLinejoin:"round"}),vo("path",{d:"M9.17139 9.17188L14.8282 14.8287",strokeLinecap:"round",strokeLinejoin:"round"}),vo("path",{d:"M14.8281 9.17188L9.17127 14.8287",strokeLinecap:"round",strokeLinejoin:"round"})]});import{jsx as Qr,jsxs as Eu}from"react/jsx-runtime";var Kt=({size:e=24,className:t})=>Eu("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:[Qr("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"}),Qr("path",{d:"M14.8286 9.17188L9.17176 14.8287",strokeLinecap:"round",strokeLinejoin:"round"}),Qr("path",{d:"M9.17139 9.17188L14.8282 14.8287",strokeLinecap:"round",strokeLinejoin:"round"})]});import{jsx as jr,jsxs as bu}from"react/jsx-runtime";var qt=({size:e=24,className:t})=>bu("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:[jr("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"}),jr("path",{d:"M12 8V16",strokeLinecap:"round",strokeLinejoin:"round"}),jr("path",{d:"M8 12H16",strokeLinecap:"round",strokeLinejoin:"round"})]});import{jsx as ei,jsxs as _u}from"react/jsx-runtime";var rs=({size:e=24,className:t})=>ei("svg",{width:e,height:e,viewBox:"0 0 34 24",xmlns:"http://www.w3.org/2000/svg",fill:"currentColor",className:t,children:_u("g",{children:[ei("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"}),ei("path",{d:"M24.5 4.5L28 1M28 1L31.5 4.5M28 1V8",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round"})]})});import{clsx as Tu}from"clsx";import{twMerge as Nu}from"tailwind-merge";function R(...e){return Nu(Tu(e))}var ut=(e=0,t=0)=>e<t?t:e,En=(e=1e3)=>new Promise(t=>{setTimeout(t,e)});import{jsx as is,jsxs as vu}from"react/jsx-runtime";var ss=({size:e=24,className:t})=>vu("svg",{width:e,height:e,viewBox:"0 0 24 24",fill:"none",stroke:"#6b7280",strokeWidth:2,xmlns:"http://www.w3.org/2000/svg",className:R("stroke-2",t),children:[is("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"}),is("path",{d:"M9 3V21",strokeLinecap:"round",strokeLinejoin:"round"})]});import{jsx as ti}from"react/jsx-runtime";var as=({size:e=24,className:t})=>ti("svg",{width:e,height:e,viewBox:"0 0 24 24",xmlns:"http://www.w3.org/2000/svg",stroke:"currentColor",className:t,children:ti("g",{children:ti("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 ls}from"react/jsx-runtime";var bn=({size:e=24,className:t})=>ls("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: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 cs}from"react/jsx-runtime";var wo=({size:e=24,className:t})=>cs("svg",{width:e,height:e,viewBox:"0 0 24 24",xmlns:"http://www.w3.org/2000/svg",fill:"white",stroke:"#6b7280",className:R("stroke-2",t),children:cs("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 oi,jsxs as wu}from"react/jsx-runtime";var ds=({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:[oi("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"}),oi("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"}),oi("path",{d:"M7.5 7.5V10H10",strokeWidth:"1.5",fill:"none",strokeLinecap:"round",strokeLinejoin:"round"})]});import{jsx as Ao,jsxs as Au}from"react/jsx-runtime";var us=({size:e=24,className:t})=>Au("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:[Ao("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"}),Ao("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"}),Ao("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"}),Ao("path",{d:"M13.5 12H11",strokeWidth:"1",strokeLinecap:"round",strokeLinejoin:"round"}),Ao("path",{d:"M13.5 10H11",strokeWidth:"1",strokeLinecap:"round",strokeLinejoin:"round"})]});import{jsx as _n,jsxs as Iu}from"react/jsx-runtime";var ps=({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:[_n("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"}),_n("path",{d:"M8 21V14C8 13.4477 8.44772 13 9 13H15C15.5523 13 16 13.4477 16 14V21",strokeWidth:"1",fill:"none"}),_n("path",{d:"M10.2222 17H13.7777",strokeWidth:"1",strokeLinecap:"round",strokeLinejoin:"round"}),_n("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||{}),Tn={SCRIPT:{icon:Su},SUBPROCESS:{icon:Mu}},Qe=(t=>(t.LOOP="LOOP",t))(Qe||{}),Nn={LOOP:{icon:Cu}},$e=(n=>(n.EXCLUSIVE="EXCLUSIVE",n.PARALLEL="PARALLEL",n.COMPLEX="COMPLEX",n))($e||{}),ni={EXCLUSIVE:{icon:Kt},PARALLEL:{icon:qt},COMPLEX:{icon:Xt}};import{ReactFlowProvider as Nx}from"@xyflow/react";import{createContext as vx,useContext as wx,useEffect as Ax,useId as Ix,useMemo as Cx,useState as qe}from"react";import{Background as Q0,MiniMap as j0,ReactFlow as ex,SelectionMode as tx,useKeyPress as ox}from"@xyflow/react";import{forwardRef as nx,useImperativeHandle as rx}from"react";import{useTranslation as Ry}from"@produto-lecom/lecom-ui";import{useEdgesState as Dy,useNodesState as Oy,useOnSelectionChange as Vy,useReactFlow as Hy,useStoreApi as Gy}from"@xyflow/react";import{useCallback as It,useEffect as By}from"react";import{Position as Io}from"@xyflow/react";function fs(e,t){var h,_,b,N;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+((_=(h=t==null?void 0:t.measured)==null?void 0:h.width)!=null?_:0)/2,u=i.y+((N=(b=t==null?void 0:t.measured)==null?void 0:b.height)!=null?N:0)/2,p=(d-l)/(2*s)-(u-c)/(2*a),f=(d-l)/(2*s)+(u-c)/(2*a),y=1/(Math.abs(p)+Math.abs(f)||1),g=y*p,m=y*f,E=s*(g+m)+l,T=a*(-g+m)+c;return{x:E,y:T}}function ms(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?Io.Left:a>=i+n-1?Io.Right:l<=s+1?Io.Top:l>=s+r-1?Io.Bottom:Io.Top}function Zt(e,t){let o=fs(e,t),n=fs(t,e),r=ms(e,o),i=ms(t,n);return{sx:o.x,sy:o.y,tx:n.x,ty:n.y,sourcePos:r,targetPos:i}}function vn(e,t){return{isFromStartEvent:(e==null?void 0:e.type)==="START_EVENT",isGatewayToGateway:(e==null?void 0:e.type)==="GATEWAY"&&(t==null?void 0:t.type)==="GATEWAY",isActiviyToAndGateway:(e==null?void 0:e.type)==="TASK"&&(t==null?void 0:t.type)==="GATEWAY"}}import{create as Pu}from"zustand";import{useReactFlow as Lu}from"@xyflow/react";import{useCallback as ku}from"react";var wn=()=>{let{setEdges:e}=Lu();return ku(()=>{let o=St.getState().pathEdgeIds;e(n=>n.map(r=>v(x({},r),{selected:o.includes(r.id)})))},[e])},St=Pu((e,t)=>({statusByNodeId:{},statusData:{},pathEdgeIds:[],setTaskStatuses:o=>{o!=null&&o.length&&e(n=>{let r=x({},n.statusByNodeId),i=x({},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:y,path:g}=p.shift();if(y===u)return g;let m=s[y]||[];for(let{targetId:E,edgeId:T}of m)f.has(E)||(f.add(E),p.push({node:E,path:[...g,T]}))}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 qf,useReactFlow as Zf,useStore as Jf}from"@xyflow/react";import{useCallback as Fo,useEffect as Qf,useRef as jf,useState as ll}from"react";import{shallow as em}from"zustand/shallow";var Ru={value:()=>{}};function hs(){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 An(o)}function An(e){this._=e}function Du(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}})}An.prototype=hs.prototype={constructor:An,on:function(e,t){var o=this._,n=Du(e+"",o),r,i=-1,s=n.length;if(arguments.length<2){for(;++i<s;)if((r=(e=n[i]).type)&&(r=Ou(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]=gs(o[r],e.name,t);else if(t==null)for(r in o)o[r]=gs(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 An(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 Ou(e,t){for(var o=0,n=e.length,r;o<n;++o)if((r=e[o]).name===t)return r.value}function gs(e,t,o){for(var n=0,r=e.length;n<r;++n)if(e[n].name===t){e[n]=Ru,e=e.slice(0,n).concat(e.slice(n+1));break}return o!=null&&e.push({name:t,value:o}),e}var ri=hs;var In="http://www.w3.org/1999/xhtml",ii={svg:"http://www.w3.org/2000/svg",xhtml:In,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)),ii.hasOwnProperty(t)?{space:ii[t],local:e}:e}function Vu(e){return function(){var t=this.ownerDocument,o=this.namespaceURI;return o===In&&t.documentElement.namespaceURI===In?t.createElement(e):t.createElementNS(o,e)}}function Hu(e){return function(){return this.ownerDocument.createElementNS(e.space,e.local)}}function Cn(e){var t=nt(e);return(t.local?Hu:Vu)(t)}function Gu(){}function Mt(e){return e==null?Gu:function(){return this.querySelector(e)}}function ys(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 Ee(n,this._parents)}function si(e){return e==null?[]:Array.isArray(e)?e:Array.from(e)}function Bu(){return[]}function Co(e){return e==null?Bu:function(){return this.querySelectorAll(e)}}function zu(e){return function(){return si(e.apply(this,arguments))}}function xs(e){typeof e=="function"?e=zu(e):e=Co(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 Ee(n,r)}function So(e){return function(){return this.matches(e)}}function Sn(e){return function(t){return t.matches(e)}}var Fu=Array.prototype.find;function Wu(e){return function(){return Fu.call(this.children,e)}}function Yu(){return this.firstElementChild}function Es(e){return this.select(e==null?Yu:Wu(typeof e=="function"?e:Sn(e)))}var Uu=Array.prototype.filter;function $u(){return Array.from(this.children)}function Xu(e){return function(){return Uu.call(this.children,e)}}function bs(e){return this.selectAll(e==null?$u:Xu(typeof e=="function"?e:Sn(e)))}function _s(e){typeof e!="function"&&(e=So(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 Ee(n,this._parents)}function Mn(e){return new Array(e.length)}function Ts(){return new Ee(this._enter||this._groups.map(Mn),this._parents)}function Mo(e,t){this.ownerDocument=e.ownerDocument,this.namespaceURI=e.namespaceURI,this._next=null,this._parent=e,this.__data__=t}Mo.prototype={constructor:Mo,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 Ns(e){return function(){return e}}function Ku(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 Mo(e,i[s]);for(;s<l;++s)(a=t[s])&&(r[s]=a)}function qu(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 Mo(e,i[a]);for(a=0;a<d;++a)(l=t[a])&&c.get(p[a])===l&&(r[a]=l)}function Zu(e){return e.__data__}function vs(e,t){if(!arguments.length)return Array.from(this,Zu);var o=t?qu:Ku,n=this._parents,r=this._groups;typeof e!="function"&&(e=Ns(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=Ju(e.call(d,d&&d.__data__,c,n)),y=f.length,g=a[c]=new Array(y),m=s[c]=new Array(y),E=l[c]=new Array(p);o(d,u,g,m,E,f,t);for(var T=0,h=0,_,b;T<y;++T)if(_=g[T]){for(T>=h&&(h=T+1);!(b=m[h])&&++h<y;);_._next=b||null}}return s=new Ee(s,n),s._enter=a,s._exit=l,s}function Ju(e){return typeof e=="object"&&"length"in e?e:Array.from(e)}function ws(){return new Ee(this._exit||this._groups.map(Mn),this._parents)}function As(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 Is(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,y=0;y<u;++y)(f=c[y]||d[y])&&(p[y]=f);for(;l<r;++l)a[l]=o[l];return new Ee(a,this._parents)}function Cs(){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 Ss(e){e||(e=Qu);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 Ee(r,this._parents).order()}function Qu(e,t){return e<t?-1:e>t?1:e>=t?0:NaN}function Ms(){var e=arguments[0];return arguments[0]=this,e.apply(null,arguments),this}function Ps(){return Array.from(this)}function Ls(){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 ks(){let e=0;for(let t of this)++e;return e}function Rs(){return!this.node()}function Ds(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 ju(e){return function(){this.removeAttribute(e)}}function ep(e){return function(){this.removeAttributeNS(e.space,e.local)}}function tp(e,t){return function(){this.setAttribute(e,t)}}function op(e,t){return function(){this.setAttributeNS(e.space,e.local,t)}}function np(e,t){return function(){var o=t.apply(this,arguments);o==null?this.removeAttribute(e):this.setAttribute(e,o)}}function rp(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 Os(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?ep:ju:typeof t=="function"?o.local?rp:np:o.local?op:tp)(o,t))}function Pn(e){return e.ownerDocument&&e.ownerDocument.defaultView||e.document&&e||e.defaultView}function ip(e){return function(){this.style.removeProperty(e)}}function sp(e,t,o){return function(){this.style.setProperty(e,t,o)}}function ap(e,t,o){return function(){var n=t.apply(this,arguments);n==null?this.style.removeProperty(e):this.style.setProperty(e,n,o)}}function Vs(e,t,o){return arguments.length>1?this.each((t==null?ip:typeof t=="function"?ap:sp)(e,t,o==null?"":o)):pt(this.node(),e)}function pt(e,t){return e.style.getPropertyValue(t)||Pn(e).getComputedStyle(e,null).getPropertyValue(t)}function lp(e){return function(){delete this[e]}}function cp(e,t){return function(){this[e]=t}}function dp(e,t){return function(){var o=t.apply(this,arguments);o==null?delete this[e]:this[e]=o}}function Hs(e,t){return arguments.length>1?this.each((t==null?lp:typeof t=="function"?dp:cp)(e,t)):this.node()[e]}function Gs(e){return e.trim().split(/^|\s+/)}function ai(e){return e.classList||new Bs(e)}function Bs(e){this._node=e,this._names=Gs(e.getAttribute("class")||"")}Bs.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 zs(e,t){for(var o=ai(e),n=-1,r=t.length;++n<r;)o.add(t[n])}function Fs(e,t){for(var o=ai(e),n=-1,r=t.length;++n<r;)o.remove(t[n])}function up(e){return function(){zs(this,e)}}function pp(e){return function(){Fs(this,e)}}function fp(e,t){return function(){(t.apply(this,arguments)?zs:Fs)(this,e)}}function Ws(e,t){var o=Gs(e+"");if(arguments.length<2){for(var n=ai(this.node()),r=-1,i=o.length;++r<i;)if(!n.contains(o[r]))return!1;return!0}return this.each((typeof t=="function"?fp:t?up:pp)(o,t))}function mp(){this.textContent=""}function gp(e){return function(){this.textContent=e}}function hp(e){return function(){var t=e.apply(this,arguments);this.textContent=t==null?"":t}}function Ys(e){return arguments.length?this.each(e==null?mp:(typeof e=="function"?hp:gp)(e)):this.node().textContent}function yp(){this.innerHTML=""}function xp(e){return function(){this.innerHTML=e}}function Ep(e){return function(){var t=e.apply(this,arguments);this.innerHTML=t==null?"":t}}function Us(e){return arguments.length?this.each(e==null?yp:(typeof e=="function"?Ep:xp)(e)):this.node().innerHTML}function bp(){this.nextSibling&&this.parentNode.appendChild(this)}function $s(){return this.each(bp)}function _p(){this.previousSibling&&this.parentNode.insertBefore(this,this.parentNode.firstChild)}function Xs(){return this.each(_p)}function Ks(e){var t=typeof e=="function"?e:Cn(e);return this.select(function(){return this.appendChild(t.apply(this,arguments))})}function Tp(){return null}function qs(e,t){var o=typeof e=="function"?e:Cn(e),n=t==null?Tp:typeof t=="function"?t:Mt(t);return this.select(function(){return this.insertBefore(o.apply(this,arguments),n.apply(this,arguments)||null)})}function Np(){var e=this.parentNode;e&&e.removeChild(this)}function Zs(){return this.each(Np)}function vp(){var e=this.cloneNode(!1),t=this.parentNode;return t?t.insertBefore(e,this.nextSibling):e}function wp(){var e=this.cloneNode(!0),t=this.parentNode;return t?t.insertBefore(e,this.nextSibling):e}function Js(e){return this.select(e?wp:vp)}function Qs(e){return arguments.length?this.property("__data__",e):this.node().__data__}function Ap(e){return function(t){e.call(this,t,this.__data__)}}function Ip(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 Cp(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 Sp(e,t,o){return function(){var n=this.__on,r,i=Ap(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 js(e,t,o){var n=Ip(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?Sp:Cp,r=0;r<i;++r)this.each(a(n[r],t,o));return this}function ea(e,t,o){var n=Pn(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 Mp(e,t){return function(){return ea(this,e,t)}}function Pp(e,t){return function(){return ea(this,e,t.apply(this,arguments))}}function ta(e,t){return this.each((typeof t=="function"?Pp:Mp)(e,t))}function*oa(){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 Lp=[null];function Ee(e,t){this._groups=e,this._parents=t}function na(){return new Ee([[document.documentElement]],Lp)}function kp(){return this}Ee.prototype=na.prototype={constructor:Ee,select:ys,selectAll:xs,selectChild:Es,selectChildren:bs,filter:_s,data:vs,enter:Ts,exit:ws,join:As,merge:Is,selection:kp,order:Cs,sort:Ss,call:Ms,nodes:Ps,node:Ls,size:ks,empty:Rs,each:Ds,attr:Os,style:Vs,property:Hs,classed:Ws,text:Ys,html:Us,raise:$s,lower:Xs,append:Ks,insert:qs,remove:Zs,clone:Js,datum:Qs,on:js,dispatch:ta,[Symbol.iterator]:oa};var rt=na;function Ln(e,t,o){e.prototype=t.prototype=o,o.constructor=e}function li(e,t){var o=Object.create(e.prototype);for(var n in t)o[n]=t[n];return o}function ko(){}var Po=.7,Dn=1/Po,Jt="\\s*([+-]?\\d+)\\s*",Lo="\\s*([+-]?(?:\\d*\\.)?\\d+(?:[eE][+-]?\\d+)?)\\s*",je="\\s*([+-]?(?:\\d*\\.)?\\d+(?:[eE][+-]?\\d+)?)%\\s*",Rp=/^#([0-9a-f]{3,8})$/,Dp=new RegExp(`^rgb\\(${Jt},${Jt},${Jt}\\)$`),Op=new RegExp(`^rgb\\(${je},${je},${je}\\)$`),Vp=new RegExp(`^rgba\\(${Jt},${Jt},${Jt},${Lo}\\)$`),Hp=new RegExp(`^rgba\\(${je},${je},${je},${Lo}\\)$`),Gp=new RegExp(`^hsl\\(${Lo},${je},${je}\\)$`),Bp=new RegExp(`^hsla\\(${Lo},${je},${je},${Lo}\\)$`),ra={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};Ln(ko,ft,{copy(e){return Object.assign(new this.constructor,this,e)},displayable(){return this.rgb().displayable()},hex:ia,formatHex:ia,formatHex8:zp,formatHsl:Fp,formatRgb:sa,toString:sa});function ia(){return this.rgb().formatHex()}function zp(){return this.rgb().formatHex8()}function Fp(){return pa(this).formatHsl()}function sa(){return this.rgb().formatRgb()}function ft(e){var t,o;return e=(e+"").trim().toLowerCase(),(t=Rp.exec(e))?(o=t[1].length,t=parseInt(t[1],16),o===6?aa(t):o===3?new Le(t>>8&15|t>>4&240,t>>4&15|t&240,(t&15)<<4|t&15,1):o===8?kn(t>>24&255,t>>16&255,t>>8&255,(t&255)/255):o===4?kn(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=Dp.exec(e))?new Le(t[1],t[2],t[3],1):(t=Op.exec(e))?new Le(t[1]*255/100,t[2]*255/100,t[3]*255/100,1):(t=Vp.exec(e))?kn(t[1],t[2],t[3],t[4]):(t=Hp.exec(e))?kn(t[1]*255/100,t[2]*255/100,t[3]*255/100,t[4]):(t=Gp.exec(e))?da(t[1],t[2]/100,t[3]/100,1):(t=Bp.exec(e))?da(t[1],t[2]/100,t[3]/100,t[4]):ra.hasOwnProperty(e)?aa(ra[e]):e==="transparent"?new Le(NaN,NaN,NaN,0):null}function aa(e){return new Le(e>>16&255,e>>8&255,e&255,1)}function kn(e,t,o,n){return n<=0&&(e=t=o=NaN),new Le(e,t,o,n)}function Wp(e){return e instanceof ko||(e=ft(e)),e?(e=e.rgb(),new Le(e.r,e.g,e.b,e.opacity)):new Le}function Qt(e,t,o,n){return arguments.length===1?Wp(e):new Le(e,t,o,n==null?1:n)}function Le(e,t,o,n){this.r=+e,this.g=+t,this.b=+o,this.opacity=+n}Ln(Le,Qt,li(ko,{brighter(e){return e=e==null?Dn:Math.pow(Dn,e),new Le(this.r*e,this.g*e,this.b*e,this.opacity)},darker(e){return e=e==null?Po:Math.pow(Po,e),new Le(this.r*e,this.g*e,this.b*e,this.opacity)},rgb(){return this},clamp(){return new Le(Lt(this.r),Lt(this.g),Lt(this.b),On(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:la,formatHex:la,formatHex8:Yp,formatRgb:ca,toString:ca}));function la(){return`#${Pt(this.r)}${Pt(this.g)}${Pt(this.b)}`}function Yp(){return`#${Pt(this.r)}${Pt(this.g)}${Pt(this.b)}${Pt((isNaN(this.opacity)?1:this.opacity)*255)}`}function ca(){let e=On(this.opacity);return`${e===1?"rgb(":"rgba("}${Lt(this.r)}, ${Lt(this.g)}, ${Lt(this.b)}${e===1?")":`, ${e})`}`}function On(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 da(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 pa(e){if(e instanceof Xe)return new Xe(e.h,e.s,e.l,e.opacity);if(e instanceof ko||(e=ft(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 fa(e,t,o,n){return arguments.length===1?pa(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}Ln(Xe,fa,li(ko,{brighter(e){return e=e==null?Dn:Math.pow(Dn,e),new Xe(this.h,this.s,this.l*e,this.opacity)},darker(e){return e=e==null?Po:Math.pow(Po,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 Le(ci(e>=240?e-240:e+120,r,n),ci(e,r,n),ci(e<120?e+240:e-120,r,n),this.opacity)},clamp(){return new Xe(ua(this.h),Rn(this.s),Rn(this.l),On(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=On(this.opacity);return`${e===1?"hsl(":"hsla("}${ua(this.h)}, ${Rn(this.s)*100}%, ${Rn(this.l)*100}%${e===1?")":`, ${e})`}`}}));function ua(e){return e=(e||0)%360,e<0?e+360:e}function Rn(e){return Math.max(0,Math.min(1,e||0))}function ci(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 di(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 ma(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 di((o-n/t)*t,s,r,i,a)}}function ga(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 di((o-n/t)*t,r,i,s,a)}}var ui=e=>()=>e;function Up(e,t){return function(o){return e+o*t}}function $p(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 ha(e){return(e=+e)==1?Vn:function(t,o){return o-t?$p(t,o,e):ui(isNaN(t)?o:t)}}function Vn(e,t){var o=t-e;return o?Up(e,o):ui(isNaN(e)?t:e)}var Hn=function e(t){var o=ha(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=Vn(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 ya(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 Xp=ya(ma),Kp=ya(ga);function Ge(e,t){return e=+e,t=+t,function(o){return e*(1-o)+t*o}}var fi=/[-+]?(?:\d+\.?\d*|\.?\d+)(?:[eE][-+]?\d+)?/g,pi=new RegExp(fi.source,"g");function qp(e){return function(){return e}}function Zp(e){return function(t){return e(t)+""}}function mi(e,t){var o=fi.lastIndex=pi.lastIndex=0,n,r,i,s=-1,a=[],l=[];for(e=e+"",t=t+"";(n=fi.exec(e))&&(r=pi.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=pi.lastIndex;return o<t.length&&(i=t.slice(o),a[s]?a[s]+=i:a[++s]=i),a.length<2?l[0]?Zp(l[0].x):qp(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 xa=180/Math.PI,Gn={translateX:0,translateY:0,rotate:0,skewX:0,scaleX:1,scaleY:1};function gi(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)*xa,skewX:Math.atan(l)*xa,scaleX:s,scaleY:a}}var Bn;function Ea(e){let t=new(typeof DOMMatrix=="function"?DOMMatrix:WebKitCSSMatrix)(e+"");return t.isIdentity?Gn:gi(t.a,t.b,t.c,t.d,t.e,t.f)}function ba(e){return e==null?Gn:(Bn||(Bn=document.createElementNS("http://www.w3.org/2000/svg","g")),Bn.setAttribute("transform",e),(e=Bn.transform.baseVal.consolidate())?(e=e.matrix,gi(e.a,e.b,e.c,e.d,e.e,e.f)):Gn)}function _a(e,t,o,n){function r(c){return c.length?c.pop()+" ":""}function i(c,d,u,p,f,y){if(c!==u||d!==p){var g=f.push("translate(",null,t,null,o);y.push({i:g-4,x: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,y){if(c!==u||d!==p){var g=f.push(r(f)+"scale(",null,",",null,")");y.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 y=-1,g=p.length,m;++y<g;)u[(m=p[y]).i]=m.x(f);return u.join("")}}}var hi=_a(Ea,"px, ","px)","deg)"),yi=_a(ba,", ",")",")");var jt=0,Do=0,Ro=0,Na=1e3,zn,Oo,Fn=0,kt=0,Wn=0,Vo=typeof performance=="object"&&performance.now?performance:Date,va=typeof window=="object"&&window.requestAnimationFrame?window.requestAnimationFrame.bind(window):function(e){setTimeout(e,17)};function Go(){return kt||(va(Jp),kt=Vo.now()+Wn)}function Jp(){kt=0}function Ho(){this._call=this._time=this._next=null}Ho.prototype=Yn.prototype={constructor:Ho,restart:function(e,t,o){if(typeof e!="function")throw new TypeError("callback is not a function");o=(o==null?Go():+o)+(t==null?0:+t),!this._next&&Oo!==this&&(Oo?Oo._next=this:zn=this,Oo=this),this._call=e,this._time=o,xi()},stop:function(){this._call&&(this._call=null,this._time=1/0,xi())}};function Yn(e,t,o){var n=new Ho;return n.restart(e,t,o),n}function wa(){Go(),++jt;for(var e=zn,t;e;)(t=kt-e._time)>=0&&e._call.call(void 0,t),e=e._next;--jt}function Ta(){kt=(Fn=Vo.now())+Wn,jt=Do=0;try{wa()}finally{jt=0,jp(),kt=0}}function Qp(){var e=Vo.now(),t=e-Fn;t>Na&&(Wn-=t,Fn=e)}function jp(){for(var e,t=zn,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:zn=o);Oo=e,xi(n)}function xi(e){if(!jt){Do&&(Do=clearTimeout(Do));var t=e-kt;t>24?(e<1/0&&(Do=setTimeout(Ta,e-Vo.now()-Wn)),Ro&&(Ro=clearInterval(Ro))):(Ro||(Fn=Vo.now(),Ro=setInterval(Qp,Na)),jt=1,va(Ta))}}function Un(e,t,o){var n=new Ho;return t=t==null?0:+t,n.restart(r=>{n.stop(),e(r+t)},t,o),n}var ef=ri("start","end","cancel","interrupt"),tf=[],Ca=0,Aa=1,Xn=2,$n=3,Ia=4,Kn=5,Bo=6;function mt(e,t,o,n,r,i){var s=e.__transition;if(!s)e.__transition={};else if(o in s)return;of(e,o,{name:t,index:n,group:r,on:ef,tween:tf,time:i.time,delay:i.delay,duration:i.duration,ease:i.ease,timer:null,state:Ca})}function zo(e,t){var o=be(e,t);if(o.state>Ca)throw new Error("too late; already scheduled");return o}function ve(e,t){var o=be(e,t);if(o.state>$n)throw new Error("too late; already running");return o}function be(e,t){var o=e.__transition;if(!o||!(o=o[t]))throw new Error("transition not found");return o}function of(e,t,o){var n=e.__transition,r;n[t]=o,o.timer=Yn(i,0,o.time);function i(c){o.state=Aa,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!==Aa)return l();for(d in n)if(f=n[d],f.name===o.name){if(f.state===$n)return Un(s);f.state===Ia?(f.state=Bo,f.timer.stop(),f.on.call("interrupt",e,e.__data__,f.index,f.group),delete n[d]):+d<t&&(f.state=Bo,f.timer.stop(),f.on.call("cancel",e,e.__data__,f.index,f.group),delete n[d])}if(Un(function(){o.state===$n&&(o.state=Ia,o.timer.restart(a,o.delay,o.time),a(c))}),o.state=Xn,o.on.call("start",e,e.__data__,o.index,o.group),o.state===Xn){for(o.state=$n,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=Kn,1),u=-1,p=r.length;++u<p;)r[u].call(e,d);o.state===Kn&&(o.on.call("end",e,e.__data__,o.index,o.group),l())}function l(){o.state=Bo,o.timer.stop(),delete n[t];for(var c in n)return;delete e.__transition}}function Ei(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>Xn&&n.state<Kn,n.state=Bo,n.timer.stop(),n.on.call(r?"interrupt":"cancel",e,e.__data__,n.index,n.group),delete o[s]}i&&delete e.__transition}}function Sa(e){return this.each(function(){Ei(this,e)})}function nf(e,t){var o,n;return function(){var r=ve(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 rf(e,t,o){var n,r;if(typeof o!="function")throw new Error;return function(){var i=ve(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 Ma(e,t){var o=this._id;if(e+="",arguments.length<2){for(var n=be(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?nf:rf)(o,e,t))}function eo(e,t,o){var n=e._id;return e.each(function(){var r=ve(this,n);(r.value||(r.value={}))[t]=o.apply(this,arguments)}),function(r){return be(r,n).value[t]}}function qn(e,t){var o;return(typeof t=="number"?Ge:t instanceof ft?Hn:(o=ft(t))?(t=o,Hn):mi)(e,t)}function sf(e){return function(){this.removeAttribute(e)}}function af(e){return function(){this.removeAttributeNS(e.space,e.local)}}function lf(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 cf(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 df(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 uf(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 Pa(e,t){var o=nt(e),n=o==="transform"?yi:qn;return this.attrTween(e,typeof t=="function"?(o.local?uf:df)(o,n,eo(this,"attr."+e,t)):t==null?(o.local?af:sf)(o):(o.local?cf:lf)(o,n,t))}function pf(e,t){return function(o){this.setAttribute(e,t.call(this,o))}}function ff(e,t){return function(o){this.setAttributeNS(e.space,e.local,t.call(this,o))}}function mf(e,t){var o,n;function r(){var i=t.apply(this,arguments);return i!==n&&(o=(n=i)&&ff(e,i)),o}return r._value=t,r}function gf(e,t){var o,n;function r(){var i=t.apply(this,arguments);return i!==n&&(o=(n=i)&&pf(e,i)),o}return r._value=t,r}function La(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?mf:gf)(n,t))}function hf(e,t){return function(){zo(this,e).delay=+t.apply(this,arguments)}}function yf(e,t){return t=+t,function(){zo(this,e).delay=t}}function ka(e){var t=this._id;return arguments.length?this.each((typeof e=="function"?hf:yf)(t,e)):be(this.node(),t).delay}function xf(e,t){return function(){ve(this,e).duration=+t.apply(this,arguments)}}function Ef(e,t){return t=+t,function(){ve(this,e).duration=t}}function Ra(e){var t=this._id;return arguments.length?this.each((typeof e=="function"?xf:Ef)(t,e)):be(this.node(),t).duration}function bf(e,t){if(typeof t!="function")throw new Error;return function(){ve(this,e).ease=t}}function Da(e){var t=this._id;return arguments.length?this.each(bf(t,e)):be(this.node(),t).ease}function _f(e,t){return function(){var o=t.apply(this,arguments);if(typeof o!="function")throw new Error;ve(this,e).ease=o}}function Oa(e){if(typeof e!="function")throw new Error;return this.each(_f(this._id,e))}function Va(e){typeof e!="function"&&(e=So(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 Ha(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 Tf(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 Nf(e,t,o){var n,r,i=Tf(t)?zo:ve;return function(){var s=i(this,e),a=s.on;a!==n&&(r=(n=a).copy()).on(t,o),s.on=r}}function Ga(e,t){var o=this._id;return arguments.length<2?be(this.node(),o).on.on(e):this.each(Nf(o,e,t))}function vf(e){return function(){var t=this.parentNode;for(var o in this.__transition)if(+o!==e)return;t&&t.removeChild(this)}}function Ba(){return this.on("end.remove",vf(this._id))}function za(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,mt(c[p],t,o,p,c,be(d,o)));return new Se(i,this._parents,t,o)}function Fa(e){var t=this._name,o=this._id;typeof e!="function"&&(e=Co(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,y=be(d,o),g=0,m=p.length;g<m;++g)(f=p[g])&&mt(f,t,o,g,p,y);i.push(p),s.push(d)}return new Se(i,s,t,o)}var wf=rt.prototype.constructor;function Wa(){return new wf(this._groups,this._parents)}function Af(e,t){var o,n,r;return function(){var i=pt(this,e),s=(this.style.removeProperty(e),pt(this,e));return i===s?null:i===o&&s===n?r:r=t(o=i,n=s)}}function Ya(e){return function(){this.style.removeProperty(e)}}function If(e,t,o){var n,r=o+"",i;return function(){var s=pt(this,e);return s===r?null:s===n?i:i=t(n=s,o)}}function Cf(e,t,o){var n,r,i;return function(){var s=pt(this,e),a=o(this),l=a+"";return a==null&&(l=a=(this.style.removeProperty(e),pt(this,e))),s===l?null:s===n&&l===r?i:(r=l,i=t(n=s,a))}}function Sf(e,t){var o,n,r,i="style."+t,s="end."+i,a;return function(){var l=ve(this,e),c=l.on,d=l.value[i]==null?a||(a=Ya(t)):void 0;(c!==o||r!==d)&&(n=(o=c).copy()).on(s,r=d),l.on=n}}function Ua(e,t,o){var n=(e+="")=="transform"?hi:qn;return t==null?this.styleTween(e,Af(e,n)).on("end.style."+e,Ya(e)):typeof t=="function"?this.styleTween(e,Cf(e,n,eo(this,"style."+e,t))).each(Sf(this._id,e)):this.styleTween(e,If(e,n,t),o).on("end.style."+e,null)}function Mf(e,t,o){return function(n){this.style.setProperty(e,t.call(this,n),o)}}function Pf(e,t,o){var n,r;function i(){var s=t.apply(this,arguments);return s!==r&&(n=(r=s)&&Mf(e,s,o)),n}return i._value=t,i}function $a(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,Pf(e,t,o==null?"":o))}function Lf(e){return function(){this.textContent=e}}function kf(e){return function(){var t=e(this);this.textContent=t==null?"":t}}function Xa(e){return this.tween("text",typeof e=="function"?kf(eo(this,"text",e)):Lf(e==null?"":e+""))}function Rf(e){return function(t){this.textContent=e.call(this,t)}}function Df(e){var t,o;function n(){var r=e.apply(this,arguments);return r!==o&&(t=(o=r)&&Rf(r)),t}return n._value=e,n}function Ka(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,Df(e))}function qa(){for(var e=this._name,t=this._id,o=Zn(),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=be(l,t);mt(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 Za(){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=ve(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 Of=0;function Se(e,t,o,n){this._groups=e,this._parents=t,this._name=o,this._id=n}function Ja(e){return rt().transition(e)}function Zn(){return++Of}var it=rt.prototype;Se.prototype=Ja.prototype={constructor:Se,select:za,selectAll:Fa,selectChild:it.selectChild,selectChildren:it.selectChildren,filter:Va,merge:Ha,selection:Wa,transition:qa,call:it.call,nodes:it.nodes,node:it.node,size:it.size,empty:it.empty,each:it.each,on:Ga,attr:Pa,attrTween:La,style:Ua,styleTween:$a,text:Xa,textTween:Ka,remove:Ba,tween:Ma,delay:ka,duration:Ra,ease:Da,easeVarying:Oa,end:Za,[Symbol.iterator]:it[Symbol.iterator]};function Jn(e){return((e*=2)<=1?e*e*e:(e-=2)*e*e+2)/2}var Vf={time:null,delay:0,duration:250,ease:Jn};function Hf(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 Qa(e){var t,o;e instanceof Se?(t=e._id,e=e._name):(t=Zn(),(o=Vf).time=Go(),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])&&mt(l,e,t,c,s,o||Hf(l,t));return new Se(n,this._parents,e,t)}rt.prototype.interrupt=Sa;rt.prototype.transition=Qa;function gt(e,t,o){this.k=e,this.x=t,this.y=o}gt.prototype={constructor:gt,scale:function(e){return e===1?this:new gt(this.k*e,this.x,this.y)},translate:function(e,t){return e===0&t===0?this:new gt(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 Qn=new gt(1,0,0);jn.prototype=gt.prototype;function jn(e){for(;!e.__zoom;)if(!(e=e.parentNode))return Qn;return e.__zoom}var Bf=[[Number.NEGATIVE_INFINITY,Number.NEGATIVE_INFINITY],[Number.POSITIVE_INFINITY,Number.POSITIVE_INFINITY]];var ja;(function(e){e.Strict="strict",e.Loose="loose"})(ja||(ja={}));var el;(function(e){e.Free="free",e.Vertical="vertical",e.Horizontal="horizontal"})(el||(el={}));var tl;(function(e){e.Partial="partial",e.Full="full"})(tl||(tl={}));var ol;(function(e){e.Bezier="default",e.Straight="straight",e.Step="step",e.SmoothStep="smoothstep",e.SimpleBezier="simplebezier"})(ol||(ol={}));var nl;(function(e){e.Arrow="arrow",e.ArrowClosed="arrowclosed"})(nl||(nl={}));var ke;(function(e){e.Left="left",e.Top="top",e.Right="right",e.Bottom="bottom"})(ke||(ke={}));var av={[ke.Left]:ke.Right,[ke.Right]:ke.Left,[ke.Top]:ke.Bottom,[ke.Bottom]:ke.Top};var zf=e=>"id"in e&&"internals"in e&&!("source"in e)&&!("target"in e);var Ff=(e,t=[0,0])=>{var a;let{width:o,height:n}=Wf(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}=zf(e)?e.internals.positionAbsolute:Ff(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 Wf(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 lv={[ke.Left]:{x:-1,y:0},[ke.Right]:{x:1,y:0},[ke.Top]:{x:0,y:-1},[ke.Bottom]:{x:0,y:1}};var Yf={nodeOrigin:[0,0],nodeExtent:Bf,elevateNodesOnSelect:!0,defaults:{}},cv=v(x({},Yf),{checkEquality:!0});var rl;(function(e){e.Line="line",e.Handle="handle"})(rl||(rl={}));var Uf={width:0,height:0,x:0,y:0},dv=v(x({},Uf),{pointerX:0,pointerY:0,aspectRatio:1});var $f=(e,t)=>e.x<t.x2&&e.x2>t.x&&e.y<t.y2&&e.y2>t.y;function Xf(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 Kf(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 er=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)||!$f(f.nodeBox,r))continue;let y=Math.abs(f.position-o);if(y>tr)continue;let m=Xf(f.nodeBox,n)>0?0:Kf(f.nodeBox,n);c.push({line:f,lineDist:y,nodeDist:m})}let d=.5,u=t==="horizontal"?this.lastHorizontalLine:this.lastVerticalLine;c.sort((f,y)=>{if(u){if(f.line===u&&y.line!==u)return-1;if(y.line===u&&f.line!==u)return 1}return Math.abs(f.lineDist-y.lineDist)<=d?f.nodeDist-y.nodeDist:f.lineDist-y.lineDist});let p=c.length>0?c[0].line:void 0;return p&&(t==="horizontal"?this.lastHorizontalLine=p:this.lastVerticalLine=p),p}};function il(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 sl(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 al(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)<=tr&&(r=l,s=!0)}if(o){let l=o.anchor.resolve(null,e)-o.line.position;Math.abs(l)<=tr&&(n=l,i=!0)}return{deltaX:n,deltaY:r,snappedX:i,snappedY:s}}var tr=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 om}from"react/jsx-runtime";var tm=new er;function or(){let[e,t]=ll(void 0),[o,n]=ll(void 0),{width:r,height:i}=Jf(m=>({width:m.width,height:m.height}),em),s=qf(),a=jf(tm),{screenToFlowPosition:l,getInternalNode:c,getNodes:d}=Zf(),u=Fo(()=>{t(void 0),n(void 0)},[]),p=Fo(m=>{let E=m!=null?m:d();u();let T=il(E,Rt,c);a.current.initialize(T)},[c,u,d]),f=Fo(()=>{setTimeout(()=>{p()},100)},[p]);Qf(()=>{s&&p(d())},[s,p,d]);let y=Fo((m,E)=>{var O,G,Y,z,oe,B,X,J,U,K;if(!a.current||m.length===0)return m;u();let T=m.filter($=>$.type==="position"&&!!$.position),h=m.find($=>$.type==="dimensions");if(T.length===0&&!h)return m;let _=Object.keys(Rt),b=new Set,N=1/0,A=1/0,I=-1/0,M=-1/0;if(T.length>0)T.forEach($=>{var ge,de,ae,re,Ne,Oe;let Z=E.find(dt=>dt.id===$.id);if(!Z)return;b.add(Z.id);let j=c(Z.id);if(!j)return;let se=j.parentId?c(j.parentId):void 0,le=$.position.x+((ge=se==null?void 0:se.internals.positionAbsolute.x)!=null?ge:0),ne=$.position.y+((de=se==null?void 0:se.internals.positionAbsolute.y)!=null?de:0),ue=(re=(ae=Z.measured)==null?void 0:ae.width)!=null?re:0,me=(Oe=(Ne=Z.measured)==null?void 0:Ne.height)!=null?Oe:0;N=Math.min(N,le),A=Math.min(A,ne),I=Math.max(I,le+ue),M=Math.max(M,ne+me)}),h&&(_=["top","left"]);else if(h){let $=E.find(ue=>ue.id===h.id);if(!$)return m;b.add($.id);let Z=c($.id);if(!Z)return m;let j=Z.internals.positionAbsolute.x,se=Z.internals.positionAbsolute.y,le=(z=(Y=(O=h.dimensions)==null?void 0:O.width)!=null?Y:(G=$.measured)==null?void 0:G.width)!=null?z:0,ne=(J=(X=(oe=h.dimensions)==null?void 0:oe.height)!=null?X:(B=$.measured)==null?void 0:B.height)!=null?J:0;N=j,A=se,I=j+le,M=se+ne,_=["right","bottom"]}if(N===1/0)return m;let H={x:N,y:A,x2:I,y2:M},{x:S,y:w}=l({x:0,y:0}),{x:k,y:V}=l({x:r,y:i}),P={x:S,y:w,x2:k,y2:V},{horizontal:L,vertical:W}=sl(a.current,P,H,b,_),{deltaX:Q,deltaY:F,snappedX:C,snappedY:D}=al(H,L,W);if(C||D){let $=T.some(j=>j.dragging),Z=!!(h!=null&&h.resizing);($||Z)&&(C&&n(W==null?void 0:W.line),D&&t(L==null?void 0:L.line)),C&&(T.forEach(j=>{j.position&&(j.position.x-=Q)}),(h==null?void 0:h.id)===((U=T[0])==null?void 0:U.id)?h.dimensions&&(h.dimensions.width+=Q):h&&!T.length&&h.dimensions&&(h.dimensions.width-=Q)),D&&(T.forEach(j=>{j.position&&(j.position.y-=F)}),(h==null?void 0:h.id)===((K=T[0])==null?void 0:K.id)?h.dimensions&&(h.dimensions.height+=F):h&&!T.length&&h.dimensions&&(h.dimensions.height-=F))}return m},[l,c,r,i,t,n,u]),g=Fo(()=>om(cl,{horizontal:e,vertical:o}),[e,o]);return{rebuildIndex:p,forceRebuildIndex:f,updateHelperLines:y,helperLineHorizontal:e,helperLineVertical:o,HelperLines:g}}import{reconnectEdge as Zh,useReactFlow as Jh}from"@xyflow/react";import{useCallback as Bt,useRef as Qh}from"react";var ht=e=>new Map(e.map(t=>[t.id,t])),Wo=(e,t,o)=>t.filter(n=>!(n.source!==e||o&&n.id===o)),dl=(e,t,o)=>t.filter(n=>!(n.target!==e||o&&n.id===o)),bi=e=>e.some(t=>t.type==="START_EVENT"),yt=(e,t)=>e==="START_EVENT"?!bi(t):!0,ul=(e,t,o,n,r)=>{let i=ht(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:Wo(e,n,r).filter(c=>{let d=i.get(c.target);return(d==null?void 0:d.type)!=="ANNOTATION"}).length>=1},pl=(e,t,o,n,r)=>{let i=ht(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:dl(t,n,r).filter(c=>{let d=i.get(c.source);return(d==null?void 0:d.type)!=="ANNOTATION"}).length>=1},nr=(e,t,o,n,r)=>{var c;let i=ht(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:Wo(e,n,r).filter(d=>{let u=i.get(d.target);return(u==null?void 0:u.type)!=="ANNOTATION"}).length>=2},fl=(e,t,o)=>{var s,a,l,c;let n=ht(o),r=n.get(e),i=n.get(t);return(r==null?void 0:r.type)!=="GATEWAY"||(i==null?void 0:i.type)!=="GATEWAY"||((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"},rr=(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"},ml=(e,t)=>{var n;let o=t.find(r=>r.id===e);return!o||o.type!=="TASK"?!1:((n=o.data)==null?void 0:n.variant)==="SUBPROCESS"},ir=(e,t)=>{var n;let o=t.find(r=>r.id===e);return!o||o.type!=="TASK"?!1:((n=o.data)==null?void 0:n.attribute)==="LOOP"},Yo=(e,t,o,n)=>{let r=ht(t),i=r.get(e);return!i||i.type!=="TASK"?!1:dl(e,o,n).some(a=>{let l=r.get(a.source);return(l==null?void 0:l.type)==="START_EVENT"})},Uo=(e,t,o,n)=>{let r=ht(t),i=r.get(e);return!i||i.type!=="TASK"?!1:Wo(e,o,n).some(a=>{let l=r.get(a.target);return(l==null?void 0:l.type)==="END_EVENT"})},gl=(e,t,o,n,r)=>{let i=ht(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"?Uo(t,o,n,r):(a==null?void 0:a.type)==="END_EVENT"&&(s==null?void 0:s.type)==="TASK"?Yo(e,o,n,r):!1},sr=(e,t,o)=>Wo(e,t,o).length>0,ar=(e,t,o,n,r)=>{let i=ht(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:Wo(e,n,r).filter(c=>{let d=i.get(c.target);return(d==null?void 0:d.type)!=="ANNOTATION"}).length>=2};var hl=(e,t,o,n)=>o.some(r=>n&&r.id===n?!1:r.source===e&&r.target===t);var nm=[e=>({isValid:e.sourceNodeId!==e.targetNodeId,reason:"self_connection_not_allowed"}),e=>({isValid:!hl(e.sourceNodeId,e.targetNodeId,e.edges,e.reconnectingEdgeId),reason:"duplicate_connection_not_allowed"}),e=>({isValid:!ul(e.sourceNodeId,e.targetNodeId,e.nodes,e.edges,e.reconnectingEdgeId),reason:"start_event_limit_reached"}),e=>({isValid:!pl(e.sourceNodeId,e.targetNodeId,e.nodes,e.edges,e.reconnectingEdgeId),reason:"end_event_limit_reached"}),e=>({isValid:!nr(e.sourceNodeId,e.targetNodeId,e.nodes,e.edges,e.reconnectingEdgeId),reason:"gateway_limit_reached"}),e=>({isValid:!ar(e.sourceNodeId,e.targetNodeId,e.nodes,e.edges,e.reconnectingEdgeId),reason:"task_limit_reached"}),e=>({isValid:fl(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"&&ml(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:!(rr(e.sourceNodeId,e.nodes)&&e.targetNodeType==="END_EVENT"),reason:"script_to_end_not_allowed"}),e=>({isValid:!(ir(e.sourceNodeId,e.nodes)&&e.targetNodeType==="END_EVENT"),reason:"loop_to_end_not_allowed"}),e=>({isValid:!(Yo(e.sourceNodeId,e.nodes,e.edges,e.reconnectingEdgeId)&&e.targetNodeType==="END_EVENT"),reason:"initial_activity_to_end_not_allowed"}),e=>({isValid:!gl(e.sourceNodeId,e.targetNodeId,e.nodes,e.edges,e.reconnectingEdgeId),reason:"concurrent_initial_and_final_activity"}),e=>({isValid:!(Uo(e.sourceNodeId,e.nodes,e.edges,e.reconnectingEdgeId)&&e.targetNodeType!=="ANNOTATION"),reason:"final_activity_cannot_connect"}),e=>({isValid:!(sr(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"})],_i=e=>{for(let t of nm){let o=t(e);if(!o.isValid)return o}return{isValid:!0}};var rm=[{sourceTypes:["GATEWAY"],targetTypes:["TASK","GATEWAY"],validate:e=>({shouldDisable:nr(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:bi(e.nodes),reason:"start_event_already_exists"})},{sourceTypes:["TASK"],targetTypes:["END_EVENT"],validate:e=>({shouldDisable:rr(e.sourceNodeId,e.nodes),reason:"script_to_end_not_allowed"})},{sourceTypes:["TASK"],targetTypes:["END_EVENT"],validate:e=>({shouldDisable:ir(e.sourceNodeId,e.nodes),reason:"loop_to_end_not_allowed"})},{sourceTypes:["TASK"],targetTypes:["END_EVENT"],validate:e=>({shouldDisable:Yo(e.sourceNodeId,e.nodes,e.edges),reason:"initial_activity_to_end_not_allowed"})},{sourceTypes:["TASK"],validate:e=>({shouldDisable:Uo(e.sourceNodeId,e.nodes,e.edges)&&e.targetNodeType!=="ANNOTATION",reason:"final_activity_cannot_connect"})},{targetTypes:["END_EVENT"],validate:e=>({shouldDisable:sr(e.sourceNodeId,e.edges),reason:"activity_has_outgoing_connections"})},{sourceTypes:["TASK"],validate:e=>({shouldDisable:ar(e.sourceNodeId,null,e.nodes,e.edges)&&e.targetNodeType!=="ANNOTATION",reason:"task_limit_reached"})}],yl=e=>{let t=rm.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 km,EdgeLabelRenderer as Rm,getStraightPath as Dm,useInternalNode as El}from"@xyflow/react";import{Button as am,Tooltip as lm,TooltipContent as cm,TooltipTrigger as dm,useTranslation as um}from"@produto-lecom/lecom-ui";import{Settings as pm}from"lucide-react";import{getIncomers as lr,getOutgoers as cr,useReactFlow as sm}from"@xyflow/react";import{useStoreApi as im}from"@xyflow/react";var xt=()=>{let e=im();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 En(),!0}}};var dr=()=>{let{getNode:e,getEdge:t,getNodes:o,getEdges:n}=sm(),{selectElements:r}=xt(),i=m=>{let E=o(),T=n(),h=lr(m,E,T),_=cr(m,E,T),b=h.some(A=>A.type==="START_EVENT"),N=_.some(A=>A.type==="END_EVENT");return b?"start":N?"end":"between"},s=(m,E,T)=>{var b,N,A,I;if(!m)return;let h={type:m.type,variant:(b=m.data)==null?void 0:b.variant,attribute:(N=m.data)==null?void 0:N.attribute},_={id:m.id,position:i(m),label:(A=m.data)==null?void 0:A.label,node:h};return m.type==="TASK"&&((I=m.data)==null?void 0:I.variant)==="SUBPROCESS"?v(x({},_),{type:"sub_process"}):m.type==="GATEWAY"?v(x({},_),{type:"gateway",variant:a(m,E,T)}):v(x({},_),{type:"activity"})},a=(m,E,T)=>{if(m.type!=="GATEWAY")return;let h=lr(m,E,T),_=!1,b=!1;if(h.forEach(N=>{var A,I;N.type==="TASK"&&(((A=N.data)==null?void 0:A.variant)==="SCRIPT"&&(_=!0),((I=N.data)==null?void 0:I.attribute)==="LOOP"&&(b=!0))}),_&&b)return"script_loop";if(_)return"script";if(b)return"loop"},l=(m,E,T)=>{var A,I,M,H;let h=e(m.source),_=e(m.target);if(!h||!_)return"simple";if(cr(h,E,T).some(S=>S.type==="END_EVENT"))return"final";if(h.type==="GATEWAY")switch((A=h.data)==null?void 0:A.variant){case"PARALLEL":return"parallel";case"EXCLUSIVE":return"exclusive";case"COMPLEX":return"complex";default:return"simple"}if(h.type==="TASK"){let S=(I=h.data)==null?void 0:I.variant,w=(M=h.data)==null?void 0:M.attribute;if(S==="SUBPROCESS")return"from_sub_process";if(_.type==="TASK"&&((H=_.data)==null?void 0:H.variant)==="SUBPROCESS")return"to_sub_process";let k=S==="SCRIPT",V=w==="LOOP";return k&&V?"script_loop":k?"script":V?"loop":"simple"}return"simple"},c=(m,E,T)=>{let h=[];function _(N,A,I=0){let M=s(N,E,T);if(M.depth=I,A.push(M),N.type==="TASK"){h.push([...A]),A.pop();return}let H=lr(N,E,T);if(H.length)for(let S of H)_(S,A,I+1);A.pop()}let b=lr(m,E,T);for(let N of b)_(N,[]);return h},d=(m,E,T)=>{let h=[];function _(N,A,I=0){let M=s(N,E,T);if(M.depth=I,A.push(M),N.type==="TASK"){h.push([...A]),A.pop();return}let H=cr(N,E,T);if(H.length)for(let S of H)_(S,A,I+1);A.pop()}let b=cr(m,E,T);for(let N of b)_(N,[]);return h},u=(m,E,T)=>(T=T.filter(_=>_.source===m.id),T.map(_=>{var A;let b=e(_.target),N;return b&&(N=s(b,E,T)),{id:_.id,type:"routing",variant:l(_,E,T),label:(A=_.data)==null?void 0:A.label,target:N}})),p=m=>{let E=e(m);if(!E)return;let T=o(),h=n(),_=s(E,T,h);return _.sources=c(E,T,h),_.targets=d(E,T,h),_.edgeTargets=u(E,T,h),E.type==="GATEWAY"&&(_.variant=a(E,T,h)),_},f=m=>{let E=t(m);if(!E)return;let T=o(),h=n(),_=l(E,T,h),N={id:E.id,type:"routing",variant:_,gatewayVariant:void 0},A=e(E.source);if(A){let M=s(A,T,h);N.source=M;let H=a(A,T,h);if(N.gatewayVariant=H,A.type==="TASK")N.sources=[[M]];else{let S=c(A,T,h);N.sources=S.length?S:[[M]]}}let I=e(E.target);if(I){let M=s(I,T,h);if(N.target=M,I.type==="TASK")N.targets=[[M]];else{let H=d(I,T,h);N.targets=H.length?H:[[M]]}}return N},y=m=>{let E=e(m);if(E)return p(E.id);let T=t(m);if(T)return f(T.id)};return{configureElement:m=>{let E=y(m);if(E)return r([m]),E},getConfigureElement:y,getNodeConfigure:p,getEdgeConfigure:f}};import{jsx as ur,jsxs as fm}from"react/jsx-runtime";var Et=({elementId:e,elementType:t="node"})=>{let{t:o}=um(),{onConfigureElement:n}=q(),{getConfigureElement:r}=dr();return fm(lm,{children:[ur(dm,{asChild:!0,children:ur(am,{variant:"ghost",color:"grey",size:"small",iconButton:!0,onClick:()=>{let s=r(e);s&&(n==null||n(s))},children:ur(pm,{size:16})})}),ur(cm,{color:"black",children:o(t==="node"?"editor.toolbar.configure_node":"editor.toolbar.configure_edge")})]})};import{Button as gm,Tooltip as hm,TooltipContent as ym,TooltipTrigger as xm,useTranslation as Em}from"@produto-lecom/lecom-ui";import{useReactFlow as bm}from"@xyflow/react";import{TrashIcon as _m}from"lucide-react";import{useNotificationToast as mm}from"@produto-lecom/lecom-ui";function Re(){let{toast:e}=$o(),{toast:t}=mm();return{toast:e||t}}import{jsx as pr,jsxs as Tm}from"react/jsx-runtime";var fr=({elementId:e,elementType:t="node"})=>{let{t:o}=Em(),{toast:n}=Re(),{deleteElements:r,getNodes:i}=bm();return Tm(hm,{children:[pr(xm,{asChild:!0,children:pr(gm,{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:pr(_m,{size:16})})}),pr(ym,{color:"black",children:o("editor.toolbar.delete")})]})};import{Button as Nm,Tooltip as vm,TooltipContent as wm,TooltipTrigger as Am,useTranslation as Im}from"@produto-lecom/lecom-ui";import{MoveUpRightIcon as Cm}from"lucide-react";import{useCallback as Sm}from"react";import{jsx as mr,jsxs as Mm}from"react/jsx-runtime";var Dt=({nodeId:e,disabled:t=!1,tooltipMessage:o})=>{let{t:n}=Im(),r=Sm(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 y=p.getBoundingClientRect(),g=f.getBoundingClientRect(),m=Math.hypot(i.clientX-(y.left+y.width/2),i.clientY-(y.top+y.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 Mm(vm,{children:[mr(Am,{asChild:!0,children:mr(Nm,{variant:"ghost",color:"grey",size:"small",iconButton:!0,disabled:t,className:t?"opacity-50 cursor-not-allowed":"",onMouseDown:t?void 0:r,children:mr(Cm,{size:16})})}),mr(wm,{color:"black",children:o||n("editor.toolbar.connect_node")})]})};import{jsx as Xo}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}=vn(o,n),u=!l&&!c&&!d,p=[{component:Xo(fr,{elementId:e,elementType:"edge"})}],f=()=>a==="view"?u?[{component:Xo(Et,{elementId:e,elementType:"edge"})}]:[]:u?[{component:Xo(Et,{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 Xo("div",v(x({className:"flex items-center gap-1 w-fit px-3 py-2 bg-white rounded-sm shadow-md"},r),{children:g.map((m,E)=>Xo("div",{children:m.component},E))}))};import{useViewport as Pm}from"@xyflow/react";import{useMemo as Lm}from"react";import{jsx as xl}from"react/jsx-runtime";var et=12,no=({sx:e,sy:t,tx:o,ty:n,hasLabel:r=!1,children:i})=>{let{zoom:s}=Pm(),a=1/s,l=Lm(()=>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 xl("div",{style:{transform:`scale(${a})`},children:xl("div",{className:"absolute pointer-events-auto",style:x({},l),children:i})})};import{jsx as Ko,jsxs as Om}from"react/jsx-runtime";var ro={type:"ANNOTATION_EDGE",reconnectable:!0},bl=({id:e,source:t,target:o,selected:n,data:r})=>{let{isMultipleSelection:i}=q(),s=El(t),a=El(o);if(!s||!a)return null;let{sx:l,sy:c,tx:d,ty:u}=Zt(s,a),[p,f,y]=Dm({sourceX:l,sourceY:c,targetX:d,targetY:u}),g=n||(s==null?void 0:s.selected)||(a==null?void 0:a.selected);return Om("g",{className:R("text-grey-400 hover:text-grey-500",{"text-blue-500 hover:text-blue-600":g}),children:[Ko(km,{id:e,path:p,strokeDasharray:4,className:R("stroke-2 stroke-current transition-colors duration-75",{"stroke-red-500 hover:stroke-red-600":r==null?void 0:r.hasError,"stroke-blue-500 hover:stroke-blue-600 drop-shadow-[0_0_3px_rgba(59,130,246,0.5)]":g&&!(r!=null&&r.hasError)})}),Ko(Rm,{children:Ko("div",{className:"absolute z-[3000] pointer-events-auto flex flex-col items-center gap-1",style:{transform:`translate(-50%, -50%) translate(${f}px, ${y}px)`},children:n&&!i&&Ko(no,{sx:l,sy:c,tx:d,ty:u,children:Ko(oo,{edgeId:e,edgeType:"ANNOTATION_EDGE"})})})})]})};import{useState as Il,useCallback as Um,useMemo as Ai,useEffect as $m,useRef as Cl}from"react";import{BaseEdge as Xm,EdgeLabelRenderer as Km,MarkerType as Sl,useInternalNode as Ml,useReactFlow as qm,useViewport as Zm,useEdges as Jm,Position as ao}from"@xyflow/react";import{useCallback as Vm,useEffect as Ti,useRef as _l,useState as Hm}from"react";import{jsx as Nl}from"react/jsx-runtime";var Ni=/[a-zA-Z0-9À-ÖØ-öø-ÿ]/,Tl=["Backspace","Delete","ArrowLeft","ArrowRight","ArrowUp","ArrowDown","Home","End","Tab","Enter","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=_l(null),u=_l(null),[p,f]=Hm(!1);Ti(()=>()=>{u.current&&clearTimeout(u.current)},[]),Ti(()=>{f(i!=null?i:!1)},[i]),Ti(()=>{if(p&&d.current){d.current.focus();let _=document.createRange();_.selectNodeContents(d.current);let b=window.getSelection();b&&(b.removeAllRanges(),b.addRange(_))}},[p]);let y=Vm(()=>{u.current||(c==null||c(),u.current=setTimeout(()=>{u.current=null},500))},[c]),g=_=>{_.stopPropagation(),p||f(!0)},m=_=>{let b=_.currentTarget.innerText.replace(/\n$/,""),N=t&&b.length>=t,A=window.getSelection(),I=(A==null?void 0:A.toString())||"",M=I.length>0,H=(_.ctrlKey||_.metaKey)&&!_.altKey,S=H&&_.key==="a",w=H&&_.key==="c",k=H&&_.key==="x",V=H&&_.key==="v";if((b.length===0||M&&I.length===b.length)&&!Ni.test(_.key)&&!Tl.includes(_.key)&&!H){_.preventDefault(),y();return}if(_.key==="Enter"&&!_.shiftKey){_.preventDefault(),_.currentTarget.blur();return}N&&!M&&(Tl.includes(_.key)||S||w||k||V||_.preventDefault())},E=_=>{_.preventDefault();let b=_.clipboardData.getData("text/plain").replace(/\r\n/g,`
|
|
1
|
+
var gu=Object.defineProperty,hu=Object.defineProperties;var yu=Object.getOwnPropertyDescriptors;var hn=Object.getOwnPropertySymbols;var Qi=Object.prototype.hasOwnProperty,ji=Object.prototype.propertyIsEnumerable;var Ji=(e,t,o)=>t in e?gu(e,t,{enumerable:!0,configurable:!0,writable:!0,value:o}):e[t]=o,x=(e,t)=>{for(var o in t||(t={}))Qi.call(t,o)&&Ji(e,o,t[o]);if(hn)for(var o of hn(t))ji.call(t,o)&&Ji(e,o,t[o]);return e},v=(e,t)=>hu(e,yu(t));var Je=(e,t)=>{var o={};for(var n in e)Qi.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&&ji.call(e,n)&&(o[n]=e[n]);return o};var qr=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 xu,Translations as Eu}from"@produto-lecom/lecom-ui";var es={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 ts={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 os={translations:{general:{layout:{title:"Modeler"}},editor:{toolbar:{delete:"Excluir",configure_node:"Configurar atividade",configure_edge:"Configurar roteamento",initial_task:"Atividade Inicial",gateway_limit_reached:"Gateway exclusivo n\xE3o pode ter mais de 2 conex\xF5es de sa\xEDda",task_limit_reached:"Atividade n\xE3o pode ter mais de 2 conex\xF5es de sa\xEDda",start_event_limit_reached:"Evento inicial s\xF3 pode se conectar a um \xFAnico elemento",gateway_to_gateway_not_allowed:"Gateways n\xE3o podem se conectar diretamente com outros gateways",start_event_already_exists:"J\xE1 existe um evento de in\xEDcio. Exclua o evento atual para adicionar outro",script_to_end_not_allowed:"Atividades Script n\xE3o podem se conectar diretamente ao evento final",loop_to_end_not_allowed:"Atividades Loop n\xE3o podem se conectar diretamente ao evento final",initial_activity_to_end_not_allowed:"Atividade inicial n\xE3o pode se conectar diretamente ao evento final",final_activity_cannot_connect:"Atividade final n\xE3o pode se conectar a outros elementos",activity_has_outgoing_connections:"Atividade com conex\xF5es de sa\xEDda n\xE3o pode se conectar a um evento final",end_event_cannot_connect_to_initial_activity:"O evento final n\xE3o pode ser conectado a uma atividade inicial",initial_activity_cannot_connect_to_start_event:"Atividade inicial n\xE3o pode se conectar a evento de in\xEDcio",concurrent_initial_and_final_activity:"Uma atividade n\xE3o pode estar conectada ao evento inicial e final ao mesmo tempo",duplicate_connection_not_allowed:"J\xE1 existe uma conex\xE3o entre esses elementos",start_event_to_subprocess_not_allowed:"Evento inicial n\xE3o pode se conectar a um subprocesso",connect_node:"Conectar elemento",connecting:"Conectando...",delete_pool_lane_error:"N\xE3o \xE9 poss\xEDvel excluir a piscina ou raia enquanto houver elementos dentro dela."},controls:{zoom:{fit:"Ajustar o zoom",in:"Aumentar o zoom",out:"Diminuir o zoom",reset:"Resetar o zoom"},actions:{move_tool:"Selecionar elementos",hand_tool:"Navegar pelo diagrama",check:"Validar diagrama",export:{title:"Exportar diagrama",print:"Imprimir",html:"Exportar como HTML",png:"Exportar como PNG",feedback:{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 ns={pt_BR:os,en_US:es,es_ES:ts};var rs,is,bu=(is=(rs=qr("LecomUserLanguage"))!=null?rs:qr("org.springframework.web.servlet.i18n.CookieLocaleResolver.LOCALE"))!=null?is:Eu.PT_BR;xu({lng:bu,resources:ns});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||{}),Zr=(n=>(n.START="start",n.END="end",n.BETWEEN="between",n))(Zr||{}),Jr=(n=>(n.SCRIPT="script",n.LOOP="loop",n.SCRIPT_LOOP="script_loop",n))(Jr||{}),Qr=(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))(Qr||{});import{RotateCcw as Lu,ScrollText as ku,SquarePlus as Ru}from"lucide-react";import{jsx as xn,jsxs as _u}from"react/jsx-runtime";var En=({size:e=24,className:t})=>_u("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 ss}from"react/jsx-runtime";var $t=({size:e=24,className:t})=>ss("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:ss("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 Tu}from"react/jsx-runtime";var Xt=({size:e=24,className:t})=>Tu("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 jr,jsxs as Nu}from"react/jsx-runtime";var Kt=({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:[jr("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"}),jr("path",{d:"M14.8286 9.17188L9.17176 14.8287",strokeLinecap:"round",strokeLinejoin:"round"}),jr("path",{d:"M9.17139 9.17188L14.8282 14.8287",strokeLinecap:"round",strokeLinejoin:"round"})]});import{jsx as ei,jsxs as vu}from"react/jsx-runtime";var qt=({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:"M12 8V16",strokeLinecap:"round",strokeLinejoin:"round"}),ei("path",{d:"M8 12H16",strokeLinecap:"round",strokeLinejoin:"round"})]});import{jsx as ti,jsxs as wu}from"react/jsx-runtime";var as=({size:e=24,className:t})=>ti("svg",{width:e,height:e,viewBox:"0 0 34 24",xmlns:"http://www.w3.org/2000/svg",fill:"currentColor",className:t,children:wu("g",{children:[ti("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"}),ti("path",{d:"M24.5 4.5L28 1M28 1L31.5 4.5M28 1V8",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round"})]})});import{clsx as Au}from"clsx";import{twMerge as Iu}from"tailwind-merge";function O(...e){return Iu(Au(e))}var ut=(e=0,t=0)=>e<t?t:e,bn=(e=1e3)=>new Promise(t=>{setTimeout(t,e)});import{jsx as ls,jsxs as Cu}from"react/jsx-runtime";var cs=({size:e=24,className:t})=>Cu("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:[ls("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"}),ls("path",{d:"M9 3V21",strokeLinecap:"round",strokeLinejoin:"round"})]});import{jsx as oi}from"react/jsx-runtime";var ds=({size:e=24,className:t})=>oi("svg",{width:e,height:e,viewBox:"0 0 24 24",xmlns:"http://www.w3.org/2000/svg",stroke:"currentColor",className:t,children:oi("g",{children:oi("path",{d:"M4.85372 6.17472L5.31292 5.71552L5.31993 5.70863C6.88908 4.1924 8.98352 3.34122 11.1655 3.33301L11.1668 3.33301C11.167 3.33301 11.1673 3.33301 11.1675 3.33301C12.7165 3.33314 14.2308 3.79255 15.5188 4.65317C16.807 5.5139 17.811 6.7373 18.4039 8.16866C18.9968 9.60001 19.1519 11.175 18.8497 12.6945C18.5986 13.9567 18.0414 15.1334 17.232 16.1236L16.9457 16.4738L17.2655 16.7936L20.6617 20.1899L20.6617 20.1899C20.7919 20.3201 20.7919 20.5311 20.6617 20.6612L20.6616 20.6613C20.5316 20.7915 20.3205 20.7915 20.1903 20.6613L16.7941 17.265L16.4743 16.9452L16.1241 17.2315C15.1339 18.0409 13.9571 18.5981 12.695 18.8492C11.1755 19.1514 9.6005 18.9963 8.16915 18.4034C6.73778 17.8105 5.51439 16.8065 4.65365 15.5183C3.79291 14.2301 3.3335 12.7156 3.3335 11.1663C3.3335 10.9822 3.48273 10.833 3.66683 10.833C3.85093 10.833 4.00016 10.9822 4.00016 11.1663C4.00016 12.5838 4.42048 13.9694 5.20796 15.148C5.99545 16.3265 7.11474 17.245 8.42426 17.7874C9.73378 18.3299 11.1748 18.4719 12.565 18.1953C13.9552 17.9188 15.2321 17.2362 16.2344 16.234L16.2345 16.234C17.2367 15.2316 17.9193 13.9547 18.1958 12.5645C18.4724 11.1743 18.3304 9.7333 17.7879 8.42378C17.2455 7.11426 16.327 5.99497 15.1484 5.20748L14.8707 5.62322L15.1484 5.20748C13.9703 4.42031 12.5854 4.00001 11.1685 3.99968L11.1664 3.99969C9.15876 4.00767 7.23176 4.7903 5.78712 6.18424L5.78706 6.18418L5.78075 6.1905L5.32512 6.64613L4.47156 7.49968H5.67867H7.8335C8.01759 7.49968 8.16683 7.64892 8.16683 7.83302C8.16683 8.01711 8.01759 8.16635 7.8335 8.16635H3.66683C3.48274 8.16635 3.3335 8.01711 3.3335 7.83302V3.66635C3.3335 3.48225 3.48274 3.33302 3.66683 3.33302C3.85092 3.33302 4.00016 3.48225 4.00016 3.66635V5.82117V7.02827L4.85372 6.17472Z"})})});import{jsx as us}from"react/jsx-runtime";var _n=({size:e=24,className:t})=>us("svg",{width:e,height:e,viewBox:"0 0 24 24",xmlns:"http://www.w3.org/2000/svg",fill:"#5fd9b0",stroke:"#1cad86",strokeWidth:"2",className:t,children:us("path",{d:"M12 22C17.5228 22 22 17.5228 22 12C22 6.47715 17.5228 2 12 2C6.47715 2 2 6.47715 2 12C2 17.5228 6.47715 22 12 22Z",strokeLinecap:"round",strokeLinejoin:"round"})});import{jsx as ps}from"react/jsx-runtime";var Ao=({size:e=24,className:t})=>ps("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:ps("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 ni,jsxs as Su}from"react/jsx-runtime";var fs=({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:[ni("path",{d:"M20 3H4C2.89543 3 2 4.34315 2 6V18C2 19.6569 2.89543 21 4 21H20C21.1046 21 22 19.6569 22 18V6C22 4.34315 21.1046 3 20 3Z",strokeLinecap:"round",strokeLinejoin:"round"}),ni("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"}),ni("path",{d:"M7.5 7.5V10H10",strokeWidth:"1.5",fill:"none",strokeLinecap:"round",strokeLinejoin:"round"})]});import{jsx as Io,jsxs as Mu}from"react/jsx-runtime";var ms=({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:[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 Pu}from"react/jsx-runtime";var gs=({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:[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:ku},SUBPROCESS:{icon:Ru}},Qe=(t=>(t.LOOP="LOOP",t))(Qe||{}),vn={LOOP:{icon:Lu}},$e=(n=>(n.EXCLUSIVE="EXCLUSIVE",n.PARALLEL="PARALLEL",n.COMPLEX="COMPLEX",n))($e||{}),ri={EXCLUSIVE:{icon:Kt},PARALLEL:{icon:qt},COMPLEX:{icon:Xt}};import{ReactFlowProvider as Sx}from"@xyflow/react";import{createContext as Mx,useContext as Px,useEffect as Lx,useId as kx,useMemo as Rx,useState as qe}from"react";import{Background as rx,MiniMap as ix,ReactFlow as sx,SelectionMode as ax,useKeyPress as lx}from"@xyflow/react";import{forwardRef as cx,useImperativeHandle as dx}from"react";import{useTranslation as By}from"@produto-lecom/lecom-ui";import{useEdgesState as zy,useNodesState as Fy,useOnSelectionChange as Wy,useReactFlow as Yy,useStoreApi as Uy}from"@xyflow/react";import{useCallback as It,useEffect as $y}from"react";import{Position as Co}from"@xyflow/react";function hs(e,t){var y,E,_,N;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+((E=(y=t==null?void 0:t.measured)==null?void 0:y.width)!=null?E:0)/2,u=i.y+((N=(_=t==null?void 0:t.measured)==null?void 0:_.height)!=null?N: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,b=s*(g+m)+l,T=a*(-g+m)+c;return{x:b,y:T}}function ys(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=hs(e,t),n=hs(t,e),r=ys(e,o),i=ys(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 Du}from"zustand";import{useReactFlow as Ou}from"@xyflow/react";import{useCallback as Vu}from"react";var An=()=>{let{setEdges:e}=Ou();return Vu(()=>{let o=St.getState().pathEdgeIds;e(n=>n.map(r=>v(x({},r),{selected:o.includes(r.id)})))},[e])},St=Du((e,t)=>({statusByNodeId:{},statusData:{},pathEdgeIds:[],setTaskStatuses:o=>{o!=null&&o.length&&e(n=>{let r=x({},n.statusByNodeId),i=x({},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:b,edgeId:T}of m)f.has(b)||(f.add(b),p.push({node:b,path:[...g,T]}))}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 jf,useReactFlow as em,useStore as tm}from"@xyflow/react";import{useCallback as Wo,useEffect as om,useRef as nm,useState as ul}from"react";import{shallow as rm}from"zustand/shallow";var Hu={value:()=>{}};function Es(){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 Gu(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=Es.prototype={constructor:In,on:function(e,t){var o=this._,n=Gu(e+"",o),r,i=-1,s=n.length;if(arguments.length<2){for(;++i<s;)if((r=(e=n[i]).type)&&(r=Bu(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]=xs(o[r],e.name,t);else if(t==null)for(r in o)o[r]=xs(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 Bu(e,t){for(var o=0,n=e.length,r;o<n;++o)if((r=e[o]).name===t)return r.value}function xs(e,t,o){for(var n=0,r=e.length;n<r;++n)if(e[n].name===t){e[n]=Hu,e=e.slice(0,n).concat(e.slice(n+1));break}return o!=null&&e.push({name:t,value:o}),e}var ii=Es;var Cn="http://www.w3.org/1999/xhtml",si={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)),si.hasOwnProperty(t)?{space:si[t],local:e}:e}function zu(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 Fu(e){return function(){return this.ownerDocument.createElementNS(e.space,e.local)}}function Sn(e){var t=nt(e);return(t.local?Fu:zu)(t)}function Wu(){}function Mt(e){return e==null?Wu:function(){return this.querySelector(e)}}function bs(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 ai(e){return e==null?[]:Array.isArray(e)?e:Array.from(e)}function Yu(){return[]}function So(e){return e==null?Yu:function(){return this.querySelectorAll(e)}}function Uu(e){return function(){return ai(e.apply(this,arguments))}}function _s(e){typeof e=="function"?e=Uu(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 $u=Array.prototype.find;function Xu(e){return function(){return $u.call(this.children,e)}}function Ku(){return this.firstElementChild}function Ts(e){return this.select(e==null?Ku:Xu(typeof e=="function"?e:Mn(e)))}var qu=Array.prototype.filter;function Zu(){return Array.from(this.children)}function Ju(e){return function(){return qu.call(this.children,e)}}function Ns(e){return this.selectAll(e==null?Zu:Ju(typeof e=="function"?e:Mn(e)))}function vs(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 ws(){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 As(e){return function(){return e}}function Qu(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 ju(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 ep(e){return e.__data__}function Is(e,t){if(!arguments.length)return Array.from(this,ep);var o=t?ju:Qu,n=this._parents,r=this._groups;typeof e!="function"&&(e=As(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=tp(e.call(d,d&&d.__data__,c,n)),h=f.length,g=a[c]=new Array(h),m=s[c]=new Array(h),b=l[c]=new Array(p);o(d,u,g,m,b,f,t);for(var T=0,y=0,E,_;T<h;++T)if(E=g[T]){for(T>=y&&(y=T+1);!(_=m[y])&&++y<h;);E._next=_||null}}return s=new xe(s,n),s._enter=a,s._exit=l,s}function tp(e){return typeof e=="object"&&"length"in e?e:Array.from(e)}function Cs(){return new xe(this._exit||this._groups.map(Pn),this._parents)}function Ss(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 Ms(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 Ps(){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 Ls(e){e||(e=op);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 op(e,t){return e<t?-1:e>t?1:e>=t?0:NaN}function ks(){var e=arguments[0];return arguments[0]=this,e.apply(null,arguments),this}function Rs(){return Array.from(this)}function Ds(){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 Os(){let e=0;for(let t of this)++e;return e}function Vs(){return!this.node()}function Hs(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 np(e){return function(){this.removeAttribute(e)}}function rp(e){return function(){this.removeAttributeNS(e.space,e.local)}}function ip(e,t){return function(){this.setAttribute(e,t)}}function sp(e,t){return function(){this.setAttributeNS(e.space,e.local,t)}}function ap(e,t){return function(){var o=t.apply(this,arguments);o==null?this.removeAttribute(e):this.setAttribute(e,o)}}function lp(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 Gs(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?rp:np:typeof t=="function"?o.local?lp:ap:o.local?sp:ip)(o,t))}function Ln(e){return e.ownerDocument&&e.ownerDocument.defaultView||e.document&&e||e.defaultView}function cp(e){return function(){this.style.removeProperty(e)}}function dp(e,t,o){return function(){this.style.setProperty(e,t,o)}}function up(e,t,o){return function(){var n=t.apply(this,arguments);n==null?this.style.removeProperty(e):this.style.setProperty(e,n,o)}}function Bs(e,t,o){return arguments.length>1?this.each((t==null?cp:typeof t=="function"?up:dp)(e,t,o==null?"":o)):pt(this.node(),e)}function pt(e,t){return e.style.getPropertyValue(t)||Ln(e).getComputedStyle(e,null).getPropertyValue(t)}function pp(e){return function(){delete this[e]}}function fp(e,t){return function(){this[e]=t}}function mp(e,t){return function(){var o=t.apply(this,arguments);o==null?delete this[e]:this[e]=o}}function zs(e,t){return arguments.length>1?this.each((t==null?pp:typeof t=="function"?mp:fp)(e,t)):this.node()[e]}function Fs(e){return e.trim().split(/^|\s+/)}function li(e){return e.classList||new Ws(e)}function Ws(e){this._node=e,this._names=Fs(e.getAttribute("class")||"")}Ws.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 Ys(e,t){for(var o=li(e),n=-1,r=t.length;++n<r;)o.add(t[n])}function Us(e,t){for(var o=li(e),n=-1,r=t.length;++n<r;)o.remove(t[n])}function gp(e){return function(){Ys(this,e)}}function hp(e){return function(){Us(this,e)}}function yp(e,t){return function(){(t.apply(this,arguments)?Ys:Us)(this,e)}}function $s(e,t){var o=Fs(e+"");if(arguments.length<2){for(var n=li(this.node()),r=-1,i=o.length;++r<i;)if(!n.contains(o[r]))return!1;return!0}return this.each((typeof t=="function"?yp:t?gp:hp)(o,t))}function xp(){this.textContent=""}function Ep(e){return function(){this.textContent=e}}function bp(e){return function(){var t=e.apply(this,arguments);this.textContent=t==null?"":t}}function Xs(e){return arguments.length?this.each(e==null?xp:(typeof e=="function"?bp:Ep)(e)):this.node().textContent}function _p(){this.innerHTML=""}function Tp(e){return function(){this.innerHTML=e}}function Np(e){return function(){var t=e.apply(this,arguments);this.innerHTML=t==null?"":t}}function Ks(e){return arguments.length?this.each(e==null?_p:(typeof e=="function"?Np:Tp)(e)):this.node().innerHTML}function vp(){this.nextSibling&&this.parentNode.appendChild(this)}function qs(){return this.each(vp)}function wp(){this.previousSibling&&this.parentNode.insertBefore(this,this.parentNode.firstChild)}function Zs(){return this.each(wp)}function Js(e){var t=typeof e=="function"?e:Sn(e);return this.select(function(){return this.appendChild(t.apply(this,arguments))})}function Ap(){return null}function Qs(e,t){var o=typeof e=="function"?e:Sn(e),n=t==null?Ap:typeof t=="function"?t:Mt(t);return this.select(function(){return this.insertBefore(o.apply(this,arguments),n.apply(this,arguments)||null)})}function Ip(){var e=this.parentNode;e&&e.removeChild(this)}function js(){return this.each(Ip)}function Cp(){var e=this.cloneNode(!1),t=this.parentNode;return t?t.insertBefore(e,this.nextSibling):e}function Sp(){var e=this.cloneNode(!0),t=this.parentNode;return t?t.insertBefore(e,this.nextSibling):e}function ea(e){return this.select(e?Sp:Cp)}function ta(e){return arguments.length?this.property("__data__",e):this.node().__data__}function Mp(e){return function(t){e.call(this,t,this.__data__)}}function Pp(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 Lp(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 kp(e,t,o){return function(){var n=this.__on,r,i=Mp(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 oa(e,t,o){var n=Pp(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?kp:Lp,r=0;r<i;++r)this.each(a(n[r],t,o));return this}function na(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 Rp(e,t){return function(){return na(this,e,t)}}function Dp(e,t){return function(){return na(this,e,t.apply(this,arguments))}}function ra(e,t){return this.each((typeof t=="function"?Dp:Rp)(e,t))}function*ia(){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 Op=[null];function xe(e,t){this._groups=e,this._parents=t}function sa(){return new xe([[document.documentElement]],Op)}function Vp(){return this}xe.prototype=sa.prototype={constructor:xe,select:bs,selectAll:_s,selectChild:Ts,selectChildren:Ns,filter:vs,data:Is,enter:ws,exit:Cs,join:Ss,merge:Ms,selection:Vp,order:Ps,sort:Ls,call:ks,nodes:Rs,node:Ds,size:Os,empty:Vs,each:Hs,attr:Gs,style:Bs,property:zs,classed:$s,text:Xs,html:Ks,raise:qs,lower:Zs,append:Js,insert:Qs,remove:js,clone:ea,datum:ta,on:oa,dispatch:ra,[Symbol.iterator]:ia};var rt=sa;function kn(e,t,o){e.prototype=t.prototype=o,o.constructor=e}function ci(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*",Hp=/^#([0-9a-f]{3,8})$/,Gp=new RegExp(`^rgb\\(${Jt},${Jt},${Jt}\\)$`),Bp=new RegExp(`^rgb\\(${je},${je},${je}\\)$`),zp=new RegExp(`^rgba\\(${Jt},${Jt},${Jt},${ko}\\)$`),Fp=new RegExp(`^rgba\\(${je},${je},${je},${ko}\\)$`),Wp=new RegExp(`^hsl\\(${ko},${je},${je}\\)$`),Yp=new RegExp(`^hsla\\(${ko},${je},${je},${ko}\\)$`),aa={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,ft,{copy(e){return Object.assign(new this.constructor,this,e)},displayable(){return this.rgb().displayable()},hex:la,formatHex:la,formatHex8:Up,formatHsl:$p,formatRgb:ca,toString:ca});function la(){return this.rgb().formatHex()}function Up(){return this.rgb().formatHex8()}function $p(){return ga(this).formatHsl()}function ca(){return this.rgb().formatRgb()}function ft(e){var t,o;return e=(e+"").trim().toLowerCase(),(t=Hp.exec(e))?(o=t[1].length,t=parseInt(t[1],16),o===6?da(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=Gp.exec(e))?new ke(t[1],t[2],t[3],1):(t=Bp.exec(e))?new ke(t[1]*255/100,t[2]*255/100,t[3]*255/100,1):(t=zp.exec(e))?Rn(t[1],t[2],t[3],t[4]):(t=Fp.exec(e))?Rn(t[1]*255/100,t[2]*255/100,t[3]*255/100,t[4]):(t=Wp.exec(e))?fa(t[1],t[2]/100,t[3]/100,1):(t=Yp.exec(e))?fa(t[1],t[2]/100,t[3]/100,t[4]):aa.hasOwnProperty(e)?da(aa[e]):e==="transparent"?new ke(NaN,NaN,NaN,0):null}function da(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 Xp(e){return e instanceof Ro||(e=ft(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?Xp(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,ci(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:ua,formatHex:ua,formatHex8:Kp,formatRgb:pa,toString:pa}));function ua(){return`#${Pt(this.r)}${Pt(this.g)}${Pt(this.b)}`}function Kp(){return`#${Pt(this.r)}${Pt(this.g)}${Pt(this.b)}${Pt((isNaN(this.opacity)?1:this.opacity)*255)}`}function pa(){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 fa(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 ga(e){if(e instanceof Xe)return new Xe(e.h,e.s,e.l,e.opacity);if(e instanceof Ro||(e=ft(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 ha(e,t,o,n){return arguments.length===1?ga(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,ha,ci(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(di(e>=240?e-240:e+120,r,n),di(e,r,n),di(e<120?e+240:e-120,r,n),this.opacity)},clamp(){return new Xe(ma(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("}${ma(this.h)}, ${Dn(this.s)*100}%, ${Dn(this.l)*100}%${e===1?")":`, ${e})`}`}}));function ma(e){return e=(e||0)%360,e<0?e+360:e}function Dn(e){return Math.max(0,Math.min(1,e||0))}function di(e,t,o){return(e<60?t+(o-t)*e/60:e<180?o:e<240?t+(o-t)*(240-e)/60:t)*255}function ui(e,t,o,n,r){var i=e*e,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 ya(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 ui((o-n/t)*t,s,r,i,a)}}function xa(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 ui((o-n/t)*t,r,i,s,a)}}var pi=e=>()=>e;function qp(e,t){return function(o){return e+o*t}}function Zp(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 Ea(e){return(e=+e)==1?Hn:function(t,o){return o-t?Zp(t,o,e):pi(isNaN(t)?o:t)}}function Hn(e,t){var o=t-e;return o?qp(e,o):pi(isNaN(e)?t:e)}var Gn=function e(t){var o=Ea(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 ba(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 Jp=ba(ya),Qp=ba(xa);function Ge(e,t){return e=+e,t=+t,function(o){return e*(1-o)+t*o}}var mi=/[-+]?(?:\d+\.?\d*|\.?\d+)(?:[eE][-+]?\d+)?/g,fi=new RegExp(mi.source,"g");function jp(e){return function(){return e}}function ef(e){return function(t){return e(t)+""}}function gi(e,t){var o=mi.lastIndex=fi.lastIndex=0,n,r,i,s=-1,a=[],l=[];for(e=e+"",t=t+"";(n=mi.exec(e))&&(r=fi.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=fi.lastIndex;return o<t.length&&(i=t.slice(o),a[s]?a[s]+=i:a[++s]=i),a.length<2?l[0]?ef(l[0].x):jp(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 _a=180/Math.PI,Bn={translateX:0,translateY:0,rotate:0,skewX:0,scaleX:1,scaleY:1};function hi(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)*_a,skewX:Math.atan(l)*_a,scaleX:s,scaleY:a}}var zn;function Ta(e){let t=new(typeof DOMMatrix=="function"?DOMMatrix:WebKitCSSMatrix)(e+"");return t.isIdentity?Bn:hi(t.a,t.b,t.c,t.d,t.e,t.f)}function Na(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,hi(e.a,e.b,e.c,e.d,e.e,e.f)):Bn)}function va(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 yi=va(Ta,"px, ","px)","deg)"),xi=va(Na,", ",")",")");var jt=0,Oo=0,Do=0,Aa=1e3,Fn,Vo,Wn=0,kt=0,Yn=0,Ho=typeof performance=="object"&&performance.now?performance:Date,Ia=typeof window=="object"&&window.requestAnimationFrame?window.requestAnimationFrame.bind(window):function(e){setTimeout(e,17)};function Bo(){return kt||(Ia(tf),kt=Ho.now()+Yn)}function tf(){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,Ei()},stop:function(){this._call&&(this._call=null,this._time=1/0,Ei())}};function Un(e,t,o){var n=new Go;return n.restart(e,t,o),n}function Ca(){Bo(),++jt;for(var e=Fn,t;e;)(t=kt-e._time)>=0&&e._call.call(void 0,t),e=e._next;--jt}function wa(){kt=(Wn=Ho.now())+Yn,jt=Oo=0;try{Ca()}finally{jt=0,nf(),kt=0}}function of(){var e=Ho.now(),t=e-Wn;t>Aa&&(Yn-=t,Wn=e)}function nf(){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,Ei(n)}function Ei(e){if(!jt){Oo&&(Oo=clearTimeout(Oo));var t=e-kt;t>24?(e<1/0&&(Oo=setTimeout(wa,e-Ho.now()-Yn)),Do&&(Do=clearInterval(Do))):(Do||(Wn=Ho.now(),Do=setInterval(of,Aa)),jt=1,Ia(wa))}}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 rf=ii("start","end","cancel","interrupt"),sf=[],Pa=0,Sa=1,Kn=2,Xn=3,Ma=4,qn=5,zo=6;function mt(e,t,o,n,r,i){var s=e.__transition;if(!s)e.__transition={};else if(o in s)return;af(e,o,{name:t,index:n,group:r,on:rf,tween:sf,time:i.time,delay:i.delay,duration:i.duration,ease:i.ease,timer:null,state:Pa})}function Fo(e,t){var o=Ee(e,t);if(o.state>Pa)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 af(e,t,o){var n=e.__transition,r;n[t]=o,o.timer=Un(i,0,o.time);function i(c){o.state=Sa,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!==Sa)return l();for(d in n)if(f=n[d],f.name===o.name){if(f.state===Xn)return $n(s);f.state===Ma?(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=Ma,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 bi(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 La(e){return this.each(function(){bi(this,e)})}function lf(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 cf(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 ka(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?lf:cf)(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 ft?Gn:(o=ft(t))?(t=o,Gn):gi)(e,t)}function df(e){return function(){this.removeAttribute(e)}}function uf(e){return function(){this.removeAttributeNS(e.space,e.local)}}function pf(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 ff(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 mf(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 gf(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 Ra(e,t){var o=nt(e),n=o==="transform"?xi:Zn;return this.attrTween(e,typeof t=="function"?(o.local?gf:mf)(o,n,eo(this,"attr."+e,t)):t==null?(o.local?uf:df)(o):(o.local?ff:pf)(o,n,t))}function hf(e,t){return function(o){this.setAttribute(e,t.call(this,o))}}function yf(e,t){return function(o){this.setAttributeNS(e.space,e.local,t.call(this,o))}}function xf(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 Ef(e,t){var o,n;function r(){var i=t.apply(this,arguments);return i!==n&&(o=(n=i)&&hf(e,i)),o}return r._value=t,r}function Da(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?xf:Ef)(n,t))}function bf(e,t){return function(){Fo(this,e).delay=+t.apply(this,arguments)}}function _f(e,t){return t=+t,function(){Fo(this,e).delay=t}}function Oa(e){var t=this._id;return arguments.length?this.each((typeof e=="function"?bf:_f)(t,e)):Ee(this.node(),t).delay}function Tf(e,t){return function(){Ne(this,e).duration=+t.apply(this,arguments)}}function Nf(e,t){return t=+t,function(){Ne(this,e).duration=t}}function Va(e){var t=this._id;return arguments.length?this.each((typeof e=="function"?Tf:Nf)(t,e)):Ee(this.node(),t).duration}function vf(e,t){if(typeof t!="function")throw new Error;return function(){Ne(this,e).ease=t}}function Ha(e){var t=this._id;return arguments.length?this.each(vf(t,e)):Ee(this.node(),t).ease}function wf(e,t){return function(){var o=t.apply(this,arguments);if(typeof o!="function")throw new Error;Ne(this,e).ease=o}}function Ga(e){if(typeof e!="function")throw new Error;return this.each(wf(this._id,e))}function Ba(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 za(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 Af(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 If(e,t,o){var n,r,i=Af(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 Fa(e,t){var o=this._id;return arguments.length<2?Ee(this.node(),o).on.on(e):this.each(If(o,e,t))}function Cf(e){return function(){var t=this.parentNode;for(var o in this.__transition)if(+o!==e)return;t&&t.removeChild(this)}}function Wa(){return this.on("end.remove",Cf(this._id))}function Ya(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,mt(c[p],t,o,p,c,Ee(d,o)));return new Se(i,this._parents,t,o)}function Ua(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])&&mt(f,t,o,g,p,h);i.push(p),s.push(d)}return new Se(i,s,t,o)}var Sf=rt.prototype.constructor;function $a(){return new Sf(this._groups,this._parents)}function Mf(e,t){var o,n,r;return function(){var i=pt(this,e),s=(this.style.removeProperty(e),pt(this,e));return i===s?null:i===o&&s===n?r:r=t(o=i,n=s)}}function Xa(e){return function(){this.style.removeProperty(e)}}function Pf(e,t,o){var n,r=o+"",i;return function(){var s=pt(this,e);return s===r?null:s===n?i:i=t(n=s,o)}}function Lf(e,t,o){var n,r,i;return function(){var s=pt(this,e),a=o(this),l=a+"";return a==null&&(l=a=(this.style.removeProperty(e),pt(this,e))),s===l?null:s===n&&l===r?i:(r=l,i=t(n=s,a))}}function kf(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=Xa(t)):void 0;(c!==o||r!==d)&&(n=(o=c).copy()).on(s,r=d),l.on=n}}function Ka(e,t,o){var n=(e+="")=="transform"?yi:Zn;return t==null?this.styleTween(e,Mf(e,n)).on("end.style."+e,Xa(e)):typeof t=="function"?this.styleTween(e,Lf(e,n,eo(this,"style."+e,t))).each(kf(this._id,e)):this.styleTween(e,Pf(e,n,t),o).on("end.style."+e,null)}function Rf(e,t,o){return function(n){this.style.setProperty(e,t.call(this,n),o)}}function Df(e,t,o){var n,r;function i(){var s=t.apply(this,arguments);return s!==r&&(n=(r=s)&&Rf(e,s,o)),n}return i._value=t,i}function qa(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,Df(e,t,o==null?"":o))}function Of(e){return function(){this.textContent=e}}function Vf(e){return function(){var t=e(this);this.textContent=t==null?"":t}}function Za(e){return this.tween("text",typeof e=="function"?Vf(eo(this,"text",e)):Of(e==null?"":e+""))}function Hf(e){return function(t){this.textContent=e.call(this,t)}}function Gf(e){var t,o;function n(){var r=e.apply(this,arguments);return r!==o&&(t=(o=r)&&Hf(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,Gf(e))}function Qa(){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);mt(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 ja(){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 Bf=0;function Se(e,t,o,n){this._groups=e,this._parents=t,this._name=o,this._id=n}function el(e){return rt().transition(e)}function Jn(){return++Bf}var it=rt.prototype;Se.prototype=el.prototype={constructor:Se,select:Ya,selectAll:Ua,selectChild:it.selectChild,selectChildren:it.selectChildren,filter:Ba,merge:za,selection:$a,transition:Qa,call:it.call,nodes:it.nodes,node:it.node,size:it.size,empty:it.empty,each:it.each,on:Fa,attr:Ra,attrTween:Da,style:Ka,styleTween:qa,text:Za,textTween:Ja,remove:Wa,tween:ka,delay:Oa,duration:Va,ease:Ha,easeVarying:Ga,end:ja,[Symbol.iterator]:it[Symbol.iterator]};function Qn(e){return((e*=2)<=1?e*e*e:(e-=2)*e*e+2)/2}var zf={time:null,delay:0,duration:250,ease:Qn};function Ff(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 tl(e){var t,o;e instanceof Se?(t=e._id,e=e._name):(t=Jn(),(o=zf).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])&&mt(l,e,t,c,s,o||Ff(l,t));return new Se(n,this._parents,e,t)}rt.prototype.interrupt=La;rt.prototype.transition=tl;function gt(e,t,o){this.k=e,this.x=t,this.y=o}gt.prototype={constructor:gt,scale:function(e){return e===1?this:new gt(this.k*e,this.x,this.y)},translate:function(e,t){return e===0&t===0?this:new gt(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 gt(1,0,0);er.prototype=gt.prototype;function er(e){for(;!e.__zoom;)if(!(e=e.parentNode))return jn;return e.__zoom}var Yf=[[Number.NEGATIVE_INFINITY,Number.NEGATIVE_INFINITY],[Number.POSITIVE_INFINITY,Number.POSITIVE_INFINITY]];var ol;(function(e){e.Strict="strict",e.Loose="loose"})(ol||(ol={}));var nl;(function(e){e.Free="free",e.Vertical="vertical",e.Horizontal="horizontal"})(nl||(nl={}));var rl;(function(e){e.Partial="partial",e.Full="full"})(rl||(rl={}));var il;(function(e){e.Bezier="default",e.Straight="straight",e.Step="step",e.SmoothStep="smoothstep",e.SimpleBezier="simplebezier"})(il||(il={}));var sl;(function(e){e.Arrow="arrow",e.ArrowClosed="arrowclosed"})(sl||(sl={}));var Re;(function(e){e.Left="left",e.Top="top",e.Right="right",e.Bottom="bottom"})(Re||(Re={}));var fv={[Re.Left]:Re.Right,[Re.Right]:Re.Left,[Re.Top]:Re.Bottom,[Re.Bottom]:Re.Top};var Uf=e=>"id"in e&&"internals"in e&&!("source"in e)&&!("target"in e);var $f=(e,t=[0,0])=>{var a;let{width:o,height:n}=Xf(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}=Uf(e)?e.internals.positionAbsolute:$f(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 Xf(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 mv={[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 Kf={nodeOrigin:[0,0],nodeExtent:Yf,elevateNodesOnSelect:!0,defaults:{}},gv=v(x({},Kf),{checkEquality:!0});var al;(function(e){e.Line="line",e.Handle="handle"})(al||(al={}));var qf={width:0,height:0,x:0,y:0},hv=v(x({},qf),{pointerX:0,pointerY:0,aspectRatio:1});var Zf=(e,t)=>e.x<t.x2&&e.x2>t.x&&e.y<t.y2&&e.y2>t.y;function Jf(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 Qf(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)||!Zf(f.nodeBox,r))continue;let h=Math.abs(f.position-o);if(h>or)continue;let m=Jf(f.nodeBox,n)>0?0:Qf(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 ll(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 cl(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 dl(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 sm}from"react/jsx-runtime";var im=new tr;function nr(){let[e,t]=ul(void 0),[o,n]=ul(void 0),{width:r,height:i}=tm(m=>({width:m.width,height:m.height}),rm),s=jf(),a=nm(im),{screenToFlowPosition:l,getInternalNode:c,getNodes:d}=em(),u=Wo(()=>{t(void 0),n(void 0)},[]),p=Wo(m=>{let b=m!=null?m:d();u();let T=ll(b,Rt,c);a.current.initialize(T)},[c,u,d]),f=Wo(()=>{setTimeout(()=>{p()},100)},[p]);om(()=>{s&&p(d())},[s,p,d]);let h=Wo((m,b)=>{var F,V,G,W,te,k,X,J,Y,$;if(!a.current||m.length===0)return m;u();let T=m.filter(U=>U.type==="position"&&!!U.position),y=m.find(U=>U.type==="dimensions");if(T.length===0&&!y)return m;let E=Object.keys(Rt),_=new Set,N=1/0,w=1/0,A=-1/0,P=-1/0;if(T.length>0)T.forEach(U=>{var ge,ue,ie,ne,Te,Pe;let Z=b.find(dt=>dt.id===U.id);if(!Z)return;_.add(Z.id);let j=c(Z.id);if(!j)return;let se=j.parentId?c(j.parentId):void 0,ae=U.position.x+((ge=se==null?void 0:se.internals.positionAbsolute.x)!=null?ge:0),le=U.position.y+((ue=se==null?void 0:se.internals.positionAbsolute.y)!=null?ue:0),ce=(ne=(ie=Z.measured)==null?void 0:ie.width)!=null?ne:0,fe=(Pe=(Te=Z.measured)==null?void 0:Te.height)!=null?Pe:0;N=Math.min(N,ae),w=Math.min(w,le),A=Math.max(A,ae+ce),P=Math.max(P,le+fe)}),y&&(E=["top","left"]);else if(y){let U=b.find(ce=>ce.id===y.id);if(!U)return m;_.add(U.id);let Z=c(U.id);if(!Z)return m;let j=Z.internals.positionAbsolute.x,se=Z.internals.positionAbsolute.y,ae=(W=(G=(F=y.dimensions)==null?void 0:F.width)!=null?G:(V=U.measured)==null?void 0:V.width)!=null?W:0,le=(J=(X=(te=y.dimensions)==null?void 0:te.height)!=null?X:(k=U.measured)==null?void 0:k.height)!=null?J:0;N=j,w=se,A=j+ae,P=se+le,E=["right","bottom"]}if(N===1/0)return m;let B={x:N,y:w,x2:A,y2:P},{x:S,y:D}=l({x:0,y:0}),{x:Q,y:I}=l({x:r,y:i}),R={x:S,y:D,x2:Q,y2:I},{horizontal:L,vertical:M}=cl(a.current,R,B,_,E),{deltaX:q,deltaY:z,snappedX:C,snappedY:H}=dl(B,L,M);if(C||H){let U=T.some(j=>j.dragging),Z=!!(y!=null&&y.resizing);(U||Z)&&(C&&n(M==null?void 0:M.line),H&&t(L==null?void 0:L.line)),C&&(T.forEach(j=>{j.position&&(j.position.x-=q)}),(y==null?void 0:y.id)===((Y=T[0])==null?void 0:Y.id)?y.dimensions&&(y.dimensions.width+=q):y&&!T.length&&y.dimensions&&(y.dimensions.width-=q)),H&&(T.forEach(j=>{j.position&&(j.position.y-=z)}),(y==null?void 0:y.id)===(($=T[0])==null?void 0:$.id)?y.dimensions&&(y.dimensions.height+=z):y&&!T.length&&y.dimensions&&(y.dimensions.height-=z))}return m},[l,c,r,i,t,n,u]),g=Wo(()=>sm(pl,{horizontal:e,vertical:o}),[e,o]);return{rebuildIndex:p,forceRebuildIndex:f,updateHelperLines:h,helperLineHorizontal:e,helperLineVertical:o,HelperLines:g}}import{reconnectEdge as oy,useReactFlow as ny}from"@xyflow/react";import{useCallback as Bt,useRef as ry}from"react";var ht=e=>new Map(e.map(t=>[t.id,t])),Yo=(e,t,o)=>t.filter(n=>!(n.source!==e||o&&n.id===o)),fl=(e,t,o)=>t.filter(n=>!(n.target!==e||o&&n.id===o)),_i=e=>e.some(t=>t.type==="START_EVENT"),yt=(e,t)=>e==="START_EVENT"?!_i(t):!0,ml=(e,t,o,n,r)=>{let i=ht(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},gl=(e,t,o,n,r)=>{let i=ht(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:fl(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=ht(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},hl=(e,t,o)=>{var s,a,l,c;let n=ht(o),r=n.get(e),i=n.get(t);return(r==null?void 0:r.type)!=="GATEWAY"||(i==null?void 0:i.type)!=="GATEWAY"||((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"},yl=(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=ht(t),i=r.get(e);return!i||i.type!=="TASK"?!1:fl(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=ht(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"})},xl=(e,t,o,n,r)=>{let i=ht(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=ht(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 El=(e,t,o,n)=>o.some(r=>n&&r.id===n?!1:r.source===e&&r.target===t);var am=[e=>({isValid:e.sourceNodeId!==e.targetNodeId,reason:"self_connection_not_allowed"}),e=>({isValid:!El(e.sourceNodeId,e.targetNodeId,e.edges,e.reconnectingEdgeId),reason:"duplicate_connection_not_allowed"}),e=>({isValid:!ml(e.sourceNodeId,e.targetNodeId,e.nodes,e.edges,e.reconnectingEdgeId),reason:"start_event_limit_reached"}),e=>({isValid:!gl(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:hl(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"&&yl(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:!xl(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"})],Ti=e=>{for(let t of am){let o=t(e);if(!o.isValid)return o}return{isValid:!0}};var lm=[{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:_i(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"})}],bl=e=>{let t=lm.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 Vm,EdgeLabelRenderer as Hm,getStraightPath as Gm,useInternalNode as Tl}from"@xyflow/react";import{Button as um,Tooltip as pm,TooltipContent as fm,TooltipTrigger as mm,useTranslation as gm}from"@produto-lecom/lecom-ui";import{Settings as hm}from"lucide-react";import{getIncomers as cr,getOutgoers as dr,useReactFlow as dm}from"@xyflow/react";import{useStoreApi as cm}from"@xyflow/react";var xt=()=>{let e=cm();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}=dm(),{selectElements:r}=xt(),i=m=>{let b=o(),T=n(),y=cr(m,b,T),E=dr(m,b,T),_=y.some(w=>w.type==="START_EVENT"),N=E.some(w=>w.type==="END_EVENT");return _?"start":N?"end":"between"},s=(m,b,T)=>{var _,N,w,A;if(!m)return;let y={type:m.type,variant:(_=m.data)==null?void 0:_.variant,attribute:(N=m.data)==null?void 0:N.attribute},E={id:m.id,position:i(m),label:(w=m.data)==null?void 0:w.label,node:y};return m.type==="TASK"&&((A=m.data)==null?void 0:A.variant)==="SUBPROCESS"?v(x({},E),{type:"sub_process"}):m.type==="GATEWAY"?v(x({},E),{type:"gateway",variant:a(m,b,T)}):v(x({},E),{type:"activity"})},a=(m,b,T)=>{if(m.type!=="GATEWAY")return;let y=cr(m,b,T),E=!1,_=!1;if(y.forEach(N=>{var w,A;N.type==="TASK"&&(((w=N.data)==null?void 0:w.variant)==="SCRIPT"&&(E=!0),((A=N.data)==null?void 0:A.attribute)==="LOOP"&&(_=!0))}),E&&_)return"script_loop";if(E)return"script";if(_)return"loop"},l=(m,b,T)=>{var w,A,P,B;let y=e(m.source),E=e(m.target);if(!y||!E)return"simple";if(dr(y,b,T).some(S=>S.type==="END_EVENT"))return"final";if(y.type==="GATEWAY")switch((w=y.data)==null?void 0:w.variant){case"PARALLEL":return"parallel";case"EXCLUSIVE":return"exclusive";case"COMPLEX":return"complex";default:return"simple"}if(y.type==="TASK"){let S=(A=y.data)==null?void 0:A.variant,D=(P=y.data)==null?void 0:P.attribute;if(S==="SUBPROCESS")return"from_sub_process";if(E.type==="TASK"&&((B=E.data)==null?void 0:B.variant)==="SUBPROCESS")return"to_sub_process";let Q=S==="SCRIPT",I=D==="LOOP";return Q&&I?"script_loop":Q?"script":I?"loop":"simple"}return"simple"},c=(m,b,T)=>{let y=[];function E(N,w,A=0){let P=s(N,b,T);if(P.depth=A,w.push(P),N.type==="TASK"){y.push([...w]),w.pop();return}let B=cr(N,b,T);if(B.length)for(let S of B)E(S,w,A+1);w.pop()}let _=cr(m,b,T);for(let N of _)E(N,[]);return y},d=(m,b,T)=>{let y=[];function E(N,w,A=0){let P=s(N,b,T);if(P.depth=A,w.push(P),N.type==="TASK"){y.push([...w]),w.pop();return}let B=dr(N,b,T);if(B.length)for(let S of B)E(S,w,A+1);w.pop()}let _=dr(m,b,T);for(let N of _)E(N,[]);return y},u=(m,b,T)=>(T=T.filter(E=>E.source===m.id),T.map(E=>{var w;let _=e(E.target),N;return _&&(N=s(_,b,T)),{id:E.id,type:"routing",variant:l(E,b,T),label:(w=E.data)==null?void 0:w.label,target:N}})),p=m=>{let b=e(m);if(!b)return;let T=o(),y=n(),E=s(b,T,y);return E.sources=c(b,T,y),E.targets=d(b,T,y),E.edgeTargets=u(b,T,y),b.type==="GATEWAY"&&(E.variant=a(b,T,y)),E},f=m=>{let b=t(m);if(!b)return;let T=o(),y=n(),E=l(b,T,y),N={id:b.id,type:"routing",variant:E,gatewayVariant:void 0},w=e(b.source);if(w){let P=s(w,T,y);N.source=P;let B=a(w,T,y);if(N.gatewayVariant=B,w.type==="TASK")N.sources=[[P]];else{let S=c(w,T,y);N.sources=S.length?S:[[P]]}}let A=e(b.target);if(A){let P=s(A,T,y);if(N.target=P,A.type==="TASK")N.targets=[[P]];else{let B=d(A,T,y);N.targets=B.length?B:[[P]]}}return N},h=m=>{let b=e(m);if(b)return p(b.id);let T=t(m);if(T)return f(T.id)};return{configureElement:m=>{let b=h(m);if(b)return r([m]),b},getConfigureElement:h,getNodeConfigure:p,getEdgeConfigure:f}};import{jsx as pr,jsxs as ym}from"react/jsx-runtime";var Et=({elementId:e,elementType:t="node"})=>{let{t:o}=gm(),{onConfigureElement:n}=K(),{getConfigureElement:r}=ur();return ym(pm,{children:[pr(mm,{asChild:!0,children:pr(um,{variant:"ghost",color:"grey",size:"small",iconButton:!0,onClick:()=>{let s=r(e);s&&(n==null||n(s))},children:pr(hm,{size:16})})}),pr(fm,{color:"black",children:o(t==="node"?"editor.toolbar.configure_node":"editor.toolbar.configure_edge")})]})};import{Button as Em,Tooltip as bm,TooltipContent as _m,TooltipTrigger as Tm,useTranslation as Nm}from"@produto-lecom/lecom-ui";import{useReactFlow as vm}from"@xyflow/react";import{TrashIcon as wm}from"lucide-react";import{useNotificationToast as xm}from"@produto-lecom/lecom-ui";function De(){let{toast:e}=Xo(),{toast:t}=xm();return{toast:e||t}}import{jsx as fr,jsxs as Am}from"react/jsx-runtime";var mr=({elementId:e,elementType:t="node"})=>{let{t:o}=Nm(),{toast:n}=De(),{deleteElements:r,getNodes:i}=vm();return Am(bm,{children:[fr(Tm,{asChild:!0,children:fr(Em,{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(wm,{size:16})})}),fr(_m,{color:"black",children:o("editor.toolbar.delete")})]})};import{Button as Im,Tooltip as Cm,TooltipContent as Sm,TooltipTrigger as Mm,useTranslation as Pm}from"@produto-lecom/lecom-ui";import{MoveUpRightIcon as Lm}from"lucide-react";import{useCallback as km}from"react";import{jsx as gr,jsxs as Rm}from"react/jsx-runtime";var Dt=({nodeId:e,disabled:t=!1,tooltipMessage:o})=>{let{t:n}=Pm(),r=km(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 Rm(Cm,{children:[gr(Mm,{asChild:!0,children:gr(Im,{variant:"ghost",color:"grey",size:"small",iconButton:!0,disabled:t,className:t?"opacity-50 cursor-not-allowed":"",onMouseDown:t?void 0:r,children:gr(Lm,{size:16})})}),gr(Sm,{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}=K(),{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(Et,{elementId:e,elementType:"edge"})}]:[]:u?[{component:Ko(Et,{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(x({className:"flex items-center gap-1 w-fit px-3 py-2 bg-white rounded-sm shadow-md"},r),{children:g.map((m,b)=>Ko("div",{children:m.component},b))}))};import{useViewport as Dm}from"@xyflow/react";import{useMemo as Om}from"react";import{jsx as _l}from"react/jsx-runtime";var et=12,no=({sx:e,sy:t,tx:o,ty:n,hasLabel:r=!1,children:i})=>{let{zoom:s}=Dm(),a=1/s,l=Om(()=>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 _l("div",{style:{transform:`scale(${a})`},children:_l("div",{className:"absolute pointer-events-auto",style:x({},l),children:i})})};import{jsx as qo,jsxs as Bm}from"react/jsx-runtime";var ro={type:"ANNOTATION_EDGE",reconnectable:!0},Nl=({id:e,source:t,target:o,selected:n,data:r})=>{let{isMultipleSelection:i}=K(),s=Tl(t),a=Tl(o);if(!s||!a)return null;let{sx:l,sy:c,tx:d,ty:u}=Zt(s,a),[p,f,h]=Gm({sourceX:l,sourceY:c,targetX:d,targetY:u}),g=n||(s==null?void 0:s.selected)||(a==null?void 0:a.selected);return Bm("g",{className:O("text-grey-400 hover:text-grey-500",{"text-blue-500 hover:text-blue-600":g}),children:[qo(Vm,{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(Hm,{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 Ml,useCallback as qm,useMemo as Ii,useEffect as Zm,useRef as Pl}from"react";import{BaseEdge as Jm,EdgeLabelRenderer as Qm,MarkerType as Ll,useInternalNode as kl,useReactFlow as jm,useViewport as eg,useEdges as tg,Position as ao}from"@xyflow/react";import{useCallback as zm,useEffect as Ni,useRef as vl,useState as Fm}from"react";import{jsx as Al}from"react/jsx-runtime";var vi=/[a-zA-Z0-9À-ÖØ-öø-ÿ]/,wl=["Backspace","Delete","ArrowLeft","ArrowRight","ArrowUp","ArrowDown","Home","End","Tab","Enter","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=vl(null),u=vl(null),[p,f]=Fm(!1);Ni(()=>()=>{u.current&&clearTimeout(u.current)},[]),Ni(()=>{f(i!=null?i:!1)},[i]),Ni(()=>{if(p&&d.current){d.current.focus();let E=document.createRange();E.selectNodeContents(d.current);let _=window.getSelection();_&&(_.removeAllRanges(),_.addRange(E))}},[p]);let h=zm(()=>{u.current||(c==null||c(),u.current=setTimeout(()=>{u.current=null},500))},[c]),g=E=>{E.stopPropagation(),p||f(!0)},m=E=>{let _=E.currentTarget.innerText.replace(/\n$/,""),N=t&&_.length>=t,w=window.getSelection(),A=(w==null?void 0:w.toString())||"",P=A.length>0,B=(E.ctrlKey||E.metaKey)&&!E.altKey,S=B&&E.key==="a",D=B&&E.key==="c",Q=B&&E.key==="x",I=B&&E.key==="v";if((_.length===0||P&&A.length===_.length)&&!vi.test(E.key)&&!wl.includes(E.key)&&!B){E.preventDefault(),h();return}if(E.key==="Enter"&&!E.shiftKey){E.preventDefault(),E.currentTarget.blur();return}N&&!P&&(wl.includes(E.key)||S||D||Q||I||E.preventDefault())},b=E=>{E.preventDefault();let _=E.clipboardData.getData("text/plain").replace(/\r\n/g,`
|
|
2
2
|
`).replace(/\r/g,`
|
|
3
|
-
`),N=
|
|
3
|
+
`),N=E.currentTarget.innerText.replace(/\n$/,""),w=window.getSelection();if(!w||w.rangeCount===0)return;let A=w.toString(),P=N.length-A.length,B=t?Math.max(0,t-P):1/0;if(B<=0&&A.length===0)return;let S=_;if(S.length>B&&(S=S.substring(0,B)),!S&&A.length===0)return;let D=w.getRangeAt(0);if(D.startOffset===0&&(D.startContainer===E.currentTarget||D.startContainer.parentNode===E.currentTarget)&&S.length>0&&!vi.test(S[0])){h();return}D.deleteContents();let I=document.createTextNode(S);D.insertNode(I),D.setStartAfter(I),D.collapse(!0),w.removeAllRanges(),w.addRange(D),l==null||l(E.currentTarget.innerText.replace(/\n$/,""))},T=E=>{let _=E.currentTarget,N=_.innerText.replace(/\n$/,"");if(N.length>0&&!vi.test(N[0])){let w=N.slice(1);if(_.innerText=w,w.length>0&&_.firstChild){let A=document.createRange(),P=window.getSelection();A.setStart(_.firstChild,0),A.collapse(!0),P==null||P.removeAllRanges(),P==null||P.addRange(A)}h(),l==null||l(w);return}l==null||l(N)},y=E=>{f(!1);let _=E.currentTarget.innerText.replace(/\r\n/g,`
|
|
4
4
|
`).replace(/\r/g,`
|
|
5
|
-
`).trim();t&&b.length>t&&(b=b.substring(0,t)),_.currentTarget.innerText=b,a==null||a(),b!==e&&(s==null||s(b))};return Nl("div",{className:R("flex-1 p-2 self-stretch content-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:Nl("div",{ref:d,className:R("outline-none whitespace-pre-wrap overflow-hidden",r,{"nodrag nopan cursor-text":p}),contentEditable:p,suppressContentEditableWarning:!0,onKeyDown:m,onPaste:E,onInput:T,onBlur:h,children:e})})};import{Position as gr}from"@xyflow/react";var qo=e=>e===gr.Left||e===gr.Right,vi=(e,t=30)=>e===gr.Right||e===gr.Bottom?t:-t,wi=(e,t,o,n=1)=>Math.abs(e[o]-t[o])<n,hr=(e,t)=>Math.sqrt((t.x-e.x)**2+(t.y-e.y)**2),yr=(e,t)=>({x:(e.x+t.x)/2,y:(e.y+t.y)/2});var Zo={OFFSET:30,TOLERANCE:1,MOVE_THRESHOLD:5,MIN_SEGMENT_LENGTH:15,PARALLEL_OFFSET:15};function Gm(e,t,o,n,r,i,s=0){let a=vi(r,Zo.OFFSET),l=vi(i,Zo.OFFSET),c=qo(r),d=qo(i),u=c?0:s,p=c?s:0,f=d?0:s,y=d?s:0,g={x:e+u,y:t+p},m={x:o+f,y:n+y};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 xr(e,t,o,n,r,i,s,a=0){let l=Gm(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=qo(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=qo(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 vl=(e,t)=>Math.sqrt(Math.pow(t.x-e.x,2)+Math.pow(t.y-e.y,2));function Bm(e,t,o,n){let r=Math.min(vl(e,t)/2,vl(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 wl=(e,t=5)=>e.length<2?"":e.reduce((o,n,r)=>{let i="";return r>0&&r<e.length-1?i=Bm(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 Er,useRef as Jo,useState as so}from"react";import{useReactFlow as zm,useStore as Fm}from"@xyflow/react";var Wm=50,Al=.1,Ym=.6,br=({edgeId:e,source:t,target:o,instanceId:n,isReadOnly:r})=>{let{setEdges:i,getNode:s,getNodes:a,getEdge:l,screenToFlowPosition:c}=zm(),{setIsDragging:d,setReconnectingEdgeId:u}=q(),p=Fm(C=>C.isValidConnection),[f,y]=so(null),[g,m]=so(null),[E,T]=so(null),[h,_]=so(null),[b,N]=so(null),[A,I]=so(!1),M=Jo(null),H=Jo(null),S=Jo(null),w=Jo(t),k=Jo(o);Er(()=>{w.current=t,k.current=o},[t,o]),Er(()=>{M.current=f},[f]),Er(()=>{H.current=b},[b]);let V=io(C=>{let D=a(),O=D.find(oe=>oe.id===C);if(!O)return{x:0,y:0};let G=O.position.x,Y=O.position.y,z=O.parentId;for(;z;){let oe=D.find(B=>B.id===z);if(!oe)break;G+=oe.position.x,Y+=oe.position.y,z=oe.parentId}return{x:G,y:Y}},[a]),P=io(C=>{var z,oe,B,X,J,U;let D=a(),O=null,G=Wm,Y=D.filter(K=>K.type!=="LANE"&&K.type!=="ANNOTATION");for(let K of Y){if(K.id===e)continue;let $=V(K.id),Z=(B=(oe=(z=K.measured)==null?void 0:z.width)!=null?oe:K.width)!=null?B:0,j=(U=(J=(X=K.measured)==null?void 0:X.height)!=null?J:K.height)!=null?U:0;if(C.x>=$.x&&C.x<=$.x+Z&&C.y>=$.y&&C.y<=$.y+j)return K.id;let le=Math.max($.x-C.x,0,C.x-($.x+Z)),ne=Math.max($.y-C.y,0,C.y-($.y+j)),ue=Math.sqrt(le*le+ne*ne);ue<G&&(G=ue,O=K.id)}return O},[a,V,e]),L=io((C,D)=>{var le,ne,ue,me,ge,de;let O=s(C);if(!O)return null;let G=V(C),Y=(ue=(ne=(le=O.measured)==null?void 0:le.width)!=null?ne:O.width)!=null?ue:0,z=(de=(ge=(me=O.measured)==null?void 0:me.height)!=null?ge:O.height)!=null?de:0,oe=Math.abs(G.x+Y-D.x),B=Math.abs(D.x-G.x),X=Math.abs(G.y+z-D.y),J=Math.abs(D.y-G.y),U={right:oe,left:B,bottom:X,top:J},K=Object.entries(U).reduce((ae,[re,Ne])=>Ne<ae[1]?[re,Ne]:ae,["right",U.right])[0],$=S.current;if($&&$!==K){let ae=U[K],re=U[$],Ne=Math.abs(re-ae),Oe=Math.min(Math.abs(re),Math.abs(ae));Ne<Oe*Ym&&(K=$)}let Z=K,j,se;if(Z==="right"||Z==="left"){let re=(Math.max(G.y,Math.min(G.y+z,D.y))-G.y)/(z||1);Math.abs(re-.5)<Al&&(re=.5),se=re,j={x:Z==="right"?G.x+Y:G.x,y:G.y+se*z}}else{let re=(Math.max(G.x,Math.min(G.x+Y,D.x))-G.x)/(Y||1);Math.abs(re-.5)<Al&&(re=.5),se=re,j={x:G.x+se*Y,y:Z==="bottom"?G.y+z:G.y}}return{side:Z,snapPosition:j,offset:se}},[s,V]),W=io(C=>{var B,X,J;let D=M.current;if(!D)return;let O=c({x:C.clientX,y:C.clientY}),G=P(O);T(G);let Y=O,z=null,oe=null;if(G){let U=L(G,O);U&&(z=U.side,Y=U.snapPosition,oe=U.offset,S.current=z);let K=l(e),$={source:D==="source"?G:w.current,target:D==="target"?G:k.current,sourceHandle:D==="source"?z:(B=K==null?void 0:K.sourceHandle)!=null?B:null,targetHandle:D==="target"?z:(X=K==null?void 0:K.targetHandle)!=null?X:null},Z=(J=p==null?void 0:p($))!=null?J:!0;I(Z)}else S.current=null,I(!1);_(z),N(oe),m(Y)},[P,L,l,e,c,p]),Q=io(C=>{var z,oe,B,X,J;let D=M.current;if(!D)return;let O=c({x:C.clientX,y:C.clientY}),G=P(O);if(G){let U=L(G,O),K=(z=U==null?void 0:U.side)!=null?z:null,$=(oe=U==null?void 0:U.offset)!=null?oe:.5,Z=l(e),j={source:D==="source"?G:w.current,target:D==="target"?G:k.current,sourceHandle:D==="source"?K:(B=Z==null?void 0:Z.sourceHandle)!=null?B:null,targetHandle:D==="target"?K:(X=Z==null?void 0:Z.targetHandle)!=null?X:null};((J=p==null?void 0:p(j))==null||J)&&i(se=>se.map(le=>{var ne,ue;return le.id===e?v(x({},le),{source:j.source,target:j.target,sourceHandle:j.sourceHandle,targetHandle:j.targetHandle,data:v(x({},le.data),{points:void 0,sourceOffset:D==="source"?$:(ne=le.data)==null?void 0:ne.sourceOffset,targetOffset:D==="target"?$:(ue=le.data)==null?void 0:ue.targetOffset})}):le}))}y(null),m(null),T(null),_(null),N(null),d(!1),I(!1),u(null),S.current=null,document.removeEventListener("mouseup",Q),document.removeEventListener("mousemove",W);let Y=tt.get(n);Y==null||Y.clearReconnectingEdge()},[e,P,L,l,i,n,W,p,c,d,u]),F=io((C,D)=>{if(r||D.button!==0)return;D.stopPropagation(),D.preventDefault(),i(G=>G.map(Y=>Y.id===e?v(x({},Y),{data:v(x({},Y.data),{points:void 0})}):Y)),y(C),u(e);let O=tt.get(n);O==null||O.setReconnectingEdge(e),document.addEventListener("mousemove",W),document.addEventListener("mouseup",Q)},[r,e,n,W,Q,u,i]);return Er(()=>()=>{if(M.current){document.removeEventListener("mousemove",W),document.removeEventListener("mouseup",Q),u(null);let C=tt.get(n);C==null||C.clearReconnectingEdge()}},[n,W,Q,u]),{reconnectingHandle:f,cursorPosition:g,hoveredNodeId:E,reconnectingSide:h,reconnectingOffset:b,isValidReconnection:A,handleReconnectStart:F}};import{Fragment as Ll,jsx as Ae,jsxs as bt}from"react/jsx-runtime";var Be={type:"SEQUENCE_EDGE",reconnectable:!0,markerStart:{type:Sl.ArrowClosed},markerEnd:{type:Sl.Arrow},data:{label:""}},{MOVE_THRESHOLD:_r,MIN_SEGMENT_LENGTH:Qm,PARALLEL_OFFSET:Pl}=Zo;function jm(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)*Pl}let i=r.findIndex(a=>a.id===e),s=(r.length-1)/2;return(i-s)*Pl}var kl=({id:e,source:t,target:o,data:n,selected:r,sourcePosition:i,targetPosition:s,sourceHandleId:a,targetHandleId:l})=>{var z,oe;let{zoom:c}=Zm(),{updateEdgeData:d}=qm(),u=Jm(),{isMultipleSelection:p,mode:f,instanceId:y}=q(),[g,m]=Il(!1),[E,T]=Il(null),h=Cl(null),_=Cl(null),b=f!=="edit",{reconnectingHandle:N,cursorPosition:A,hoveredNodeId:I,reconnectingSide:M,isValidReconnection:H,handleReconnectStart:S}=br({edgeId:e,source:t,target:o,instanceId:y,isReadOnly:b}),w=Ml(t),k=Ml(o),{sx:V,sy:P,tx:L,ty:W,sourcePos:Q,targetPos:F}=Ai(()=>{var ne,ue;let B=w&&k?Zt(w,k):{sx:0,sy:0,tx:0,ty:0,sourcePos:ao.Right,targetPos:ao.Left},X=a?i:B.sourcePos,J=l?s:B.targetPos,U=(me,ge,de)=>{var dt,Yt,ye,xe,Ze,Ut;let{x:ae,y:re}=me.internals.positionAbsolute,Ne=(ye=(Yt=(dt=me.measured)==null?void 0:dt.width)!=null?Yt:me.width)!=null?ye:0,Oe=(Ut=(Ze=(xe=me.measured)==null?void 0:xe.height)!=null?Ze:me.height)!=null?Ut:0;switch(ge){case ao.Top:return{x:ae+Ne*de,y:re};case ao.Bottom:return{x:ae+Ne*de,y:re+Oe};case ao.Left:return{x:ae,y:re+Oe*de};case ao.Right:return{x:ae+Ne,y:re+Oe*de};default:return{x:ae+Ne/2,y:re+Oe/2}}},K=(ne=n==null?void 0:n.sourceOffset)!=null?ne:.5,$=(ue=n==null?void 0:n.targetOffset)!=null?ue:.5,Z=w?U(w,X,K).x:B.sx,j=w?U(w,X,K).y:B.sy,se=k?U(k,J,$).x:B.tx,le=k?U(k,J,$).y:B.ty;return N==="source"&&A?(Z=A.x,j=A.y,M&&(X=M)):N==="target"&&A&&(se=A.x,le=A.y,M&&(J=M)),{sx:Z,sy:j,tx:se,ty:le,sourcePos:X,targetPos:J}},[w,k,a,l,i,s,N,A,M,n==null?void 0:n.sourceOffset,n==null?void 0:n.targetOffset]);$m(()=>{var J;if(!_.current){_.current={sx:V,sy:P,tx:L,ty:W,sourcePos:Q,targetPos:F};return}let B=_.current;(Math.abs(V-B.sx)>_r||Math.abs(P-B.sy)>_r||Math.abs(L-B.tx)>_r||Math.abs(W-B.ty)>_r||B.sourcePos!==Q||B.targetPos!==F)&&((J=n==null?void 0:n.points)!=null&&J.length)&&!N&&d(e,v(x({},n),{points:void 0})),_.current={sx:V,sy:P,tx:L,ty:W,sourcePos:Q,targetPos:F}},[V,P,L,W,Q,F,n,e,d,N]);let C=Ai(()=>{let B=jm(e,t,o,u);return xr(V,P,L,W,Q,F,n==null?void 0:n.points,B)},[V,P,L,W,Q,F,n==null?void 0:n.points,u,e,t,o]),D=Ai(()=>{if(C.length<2)return yr({x:V,y:P},{x:L,y:W});let B=0;for(let U=0;U<C.length-1;U++)B+=hr(C[U],C[U+1]);let X=B/2,J=0;for(let U=0;U<C.length-1;U++){let K=hr(C[U],C[U+1]);if(J+K>=X){let $=(X-J)/K,Z=C[U],j=C[U+1];return{x:Z.x+(j.x-Z.x)*$,y:Z.y+(j.y-Z.y)*$}}J+=K}return yr({x:V,y:P},{x:L,y:W})},[C,V,P,L,W]),O=Um((B,X)=>{if(f!=="edit"||X.button!==0)return;X.stopPropagation(),X.preventDefault();let J=C[B],U=C[B+1],K=wi(J,U,"y"),$=K?J.y:J.x,Z=[...C],j=Z.length,se=B,le=B+1;T(B);let ne=me=>{let ge=$+(K?me.clientY-X.clientY:me.clientX-X.clientX)/c;h.current=K?{x:(J.x+U.x)/2,y:ge}:{x:ge,y:(J.y+U.y)/2};let de=[];for(let ae=1;ae<j-1;ae++){let re=Z[ae];ae===se||ae===le?K?de.push({x:re.x,y:ge}):de.push({x:ge,y:re.y}):de.push(x({},re))}d(e,v(x({},n),{points:de}))},ue=()=>{T(null),h.current=null,document.removeEventListener("mousemove",ne),document.removeEventListener("mouseup",ue)};document.addEventListener("mousemove",ne),document.addEventListener("mouseup",ue)},[f,C,c,n,e,d]);if(!w||!k)return null;let G=wl(C),Y=r||w.selected||k.selected;return bt(Ll,{children:[bt("g",{className:R("text-grey-400 hover:text-grey-500",{"text-blue-500 hover:text-blue-600":Y}),onDoubleClick:()=>m(!0),children:[Ae(Xm,{id:e,path:G,markerEnd:`url(#${Y?"sequence-edge-marker-highlighted":"sequence-edge-marker"})`,className:R("stroke-2 stroke-current transition-colors duration-75",{"stroke-red-500 hover:stroke-red-600":(n==null?void 0:n.hasError)||N&&I&&!H,"stroke-green-500":N&&I&&H,"stroke-blue-500 hover:stroke-blue-600 drop-shadow-[0_0_3px_rgba(59,130,246,0.5)]":Y&&!(n!=null&&n.hasError)&&!N})}),r&&!p&&!b&&Ae("g",{children:C.slice(0,-1).map((B,X)=>{let J=C[X+1];if(X===0||X===C.length-2||hr(B,J)<Qm)return null;let U=wi(B,J,"y"),K=E===X,$=K&&h.current?h.current:yr(B,J);return bt("g",{children:[Ae("line",{x1:B.x,y1:B.y,x2:J.x,y2:J.y,stroke:"transparent",strokeWidth:20/c,className:R("cursor-pointer",{"cursor-ns-resize":U,"cursor-ew-resize":!U}),onMouseDown:Z=>O(X,Z)}),Ae("circle",{cx:$.x,cy:$.y,r:4/c,fill:K?"#3b82f6":"#fff",stroke:"#3b82f6",strokeWidth:2/c,className:"pointer-events-none"}),Ae("circle",{cx:$.x,cy:$.y,r:6/c,fill:"none",stroke:"#3b82f6",strokeWidth:1/c,opacity:K?.6:.3,className:"pointer-events-none"})]},X)})})]}),bt(Km,{children:[bt("div",{className:"absolute z-[3000] pointer-events-none flex flex-col items-center gap-1",style:{transform:`translate(-50%, -50%) translate(${D.x}px, ${D.y}px)`},children:[r&&!p&&Ae(no,{sx:V,sy:P,tx:L,ty:W,hasLabel:!!((z=n==null?void 0:n.label)!=null&&z.trim()),children:Ae(oo,{edgeId:e,edgeType:"SEQUENCE_EDGE",sourceNode:w,targetNode:k})}),(g||((oe=n==null?void 0:n.label)==null?void 0:oe.trim()))&&Ae(we,{value:n==null?void 0:n.label,className:R("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:B=>d(e,{label:B.trim()})})]}),r&&!p&&!b&&bt(Ll,{children:[Ae("div",{className:"absolute z-[10000] pointer-events-none",style:{transform:`translate(-50%, -50%) translate(${C[0].x}px, ${C[0].y}px)`},children:bt("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:N==="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:N==="source"?.6:.3,className:"pointer-events-none"}),Ae("circle",{cx:6/c,cy:6/c,r:8/c,fill:"transparent",className:R("pointer-events-auto",{"cursor-move":!N||N!=="source","cursor-not-allowed":N==="source"&&I&&!H,"cursor-grabbing":N==="source"&&(!I||H)}),onMouseDown:B=>S("source",B.nativeEvent)})]})}),Ae("div",{className:"absolute z-[10000] pointer-events-none",style:{transform:`translate(-50%, -50%) translate(${C[C.length-1].x}px, ${C[C.length-1].y}px)`},children:bt("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:N==="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:N==="target"?.6:.3,className:"pointer-events-none"}),Ae("circle",{cx:6/c,cy:6/c,r:8/c,fill:"transparent",className:R("pointer-events-auto",{"cursor-move":!N||N!=="target","cursor-not-allowed":N==="target"&&I&&!H,"cursor-grabbing":N==="target"&&(!I||H)}),onMouseDown:B=>S("target",B.nativeEvent)})]})})]})]})]})};import{Position as at}from"@xyflow/react";var eg={right:at.Right,left:at.Left,top:at.Top,bottom:at.Bottom},Tr=e=>{var t;return(t=eg[e!=null?e:""])!=null?t:at.Right},Ii=(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(Tr(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}}},Rl=(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 y=Math.hypot(t-p.x,o-p.y);return Math.hypot(t-f.x,o-f.y)<y?f:p}).id};import{useDebouncedCallback as Kh}from"use-debounce";import{useReactFlow as Xh}from"@xyflow/react";import{useCallback as Kc}from"react";var Qo=(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))(Qo||{});import{xml2json as tg,json2xml as og}from"xml-js";var Dl={compact:!0,spaces:4},ng=e=>e.replace(/\n/g,"
");function Nr(e,t=Dl){if(e)return JSON.parse(tg(e,t))}function Ol(e,t=Dl){return e?og(e,v(x({},t),{attributeValueFn:ng})):""}var rg={MIN_WIDTH:36,MIN_HEIGHT:36},ig={MIN_WIDTH:36,MIN_HEIGHT:36},sg={MIN_WIDTH:56,MIN_HEIGHT:56},lo={MIN_WIDTH:176,MIN_HEIGHT:96},vr={HEADER_WIDTH:40,MIN_WIDTH:840,MIN_HEIGHT:256},pe={HEADER_WIDTH:40,MIN_WIDTH:800,MIN_HEIGHT:256},wr={MIN_WIDTH:176,MIN_HEIGHT:64},ag={MIN_WIDTH:128,MIN_HEIGHT:64},te={START_EVENT:rg,END_EVENT:ig,GATEWAY:sg,TASK:lo,LANE:pe,ANNOTATION:wr,UNSUPPORTED:ag};var Vl={"attribute-loop":"LOOP"},Hl={"task-script":"SCRIPT","subprocess-collapsed":"SUBPROCESS"},Gl={"gateway-exclusive":"EXCLUSIVE","gateway-parallel":"PARALLEL","gateway-complex":"COMPLEX"},Bl={SCRIPT:"task-script",SUBPROCESS:"subprocess-collapsed"},zl={EXCLUSIVE:"gateway-exclusive",PARALLEL:"gateway-parallel",COMPLEX:"gateway-complex"};var co=(e,t,o)=>{let n=e._attributes.width||0,r=e._attributes.height||0,i=ut(Number(n),t),s=ut(Number(r),o);return{width:i,height:s,measured:{width:i,height:s}}},uo=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},cg=e=>{let{mxGeometry:t}=e,o=uo(e),n=co(t,te.START_EVENT.MIN_WIDTH,te.START_EVENT.MIN_HEIGHT);return v(x(x({},o),n),{type:"START_EVENT"})},dg=e=>{let{mxGeometry:t}=e,o=uo(e),n=co(t,te.END_EVENT.MIN_WIDTH,te.END_EVENT.MIN_HEIGHT);return v(x(x({},o),n),{type:"END_EVENT"})},Ci=(e,t)=>{let{_attributes:o,mxGeometry:n}=e,r=uo(e),i=co(n,te.TASK.MIN_WIDTH,te.TASK.MIN_HEIGHT),s=t==null?void 0:t.find(l=>{let{parent:c}=l._attributes;return c===e._attributes.id});if(s){let{style:l}=s._attributes,c=Vl[l];c&&(r.data.attribute=c)}let a=Hl[o.style];return a&&(r.data.variant=a),v(x(x({},r),i),{type:"TASK"})},Si=e=>{let{_attributes:t,mxGeometry:o}=e,{style:n}=t,r=uo(e),i=co(o,te.GATEWAY.MIN_WIDTH,te.GATEWAY.MIN_HEIGHT);return r.data.variant=Gl[n],v(x(x({},r),i),{type:"GATEWAY"})},ug=e=>{let{mxGeometry:t}=e,o=uo(e),n=co(t,te.ANNOTATION.MIN_WIDTH,te.ANNOTATION.MIN_HEIGHT);return v(x(x({},o),n),{type:"ANNOTATION"})},pg=e=>{let{mxGeometry:t}=e,o=uo(e),n=co(t,te.LANE.MIN_WIDTH,te.LANE.MIN_HEIGHT);return v(x(x({},o),n),{type:"LANE"})},Fl={task:Ci,"task-script":Ci,"subprocess-collapsed":Ci,"start-event":cg,"end-event-terminate":dg,"gateway-parallel":Si,"gateway-exclusive":Si,"gateway-complex":Si,annotation:ug,lane:pg},fg=e=>{if(e&&Array.isArray(e))return e.map(t=>({x:Number(t._attributes.x),y:Number(t._attributes.y)}))},Wl=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=fg(o==null?void 0:o.Array),f=d!==void 0?Number(d):void 0,y=u!==void 0?Number(u):void 0,g=v(x(x({id:n,source:r,target:i},l?{sourceHandle:l}:{}),c?{targetHandle:c}:{}),{data:x(x(x({label:s||""},p&&p.length>0?{points:p}:{}),f!==void 0?{sourceOffset:f}:{}),y!==void 0?{targetOffset:y}:{})});return a.includes("association")&&a.includes('endArrow=""')?x(x({},ro),g):x(x({},Be),g)},Yl=(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}},po=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=po(e);return v(x({},o),{_attributes:v(x({},o._attributes),{style:Bl[t]||"task"})})},gg=e=>{let t=po(e);return v(x({},t),{_attributes:v(x({},t._attributes),{style:"start-event"})})},hg=e=>{let t=po(e);return v(x({},t),{_attributes:v(x({},t._attributes),{style:"end-event-terminate"})})},yg=e=>{let{variant:t}=e.data,o=po(e);return v(x({},o),{_attributes:v(x({},o._attributes),{style:zl[t]})})},xg=e=>{let t=po(e);return v(x({},t),{_attributes:v(x({},t._attributes),{style:"lane"})})},Eg=e=>{let t=po(e);return v(x({},t),{_attributes:v(x({},t._attributes),{style:"annotation"})})},Ul={TASK:mg,START_EVENT:gg,END_EVENT:hg,GATEWAY:yg,ANNOTATION:Eg,LANE:xg},$l=(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 ql from"@dagrejs/dagre";import{getNodesBounds as Ng}from"@xyflow/react";import{orderBy as vg}from"lodash";import{orderBy as bg}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=>bg(e,[o=>{let n=o.type==="LANE";return n&&!o.parentId?0:n?1:2}],["asc"]),Xl=(e,t)=>{let{x:o,y:n}=lt(e),{x:r,y:i}=lt(t);return{x:o-r,y:n-i}};var fo=({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)),_g=(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)},Tg=(e,t)=>{let{x:o,y:n,w:r,h:i}=lt(e),{x:s,y:a,w:l,h:c}=lt(t);return o<s+l&&s<o+r&&n<a+c&&a<n+i},jo=(e,t)=>{let o=null,n=1/0;for(let r of t)if(r.id!==e.id&&Tg(e,r)){let i=_g(e,r);i<n&&(n=i,o=r)}return o},Kl=(e,t)=>t.filter(o=>o.parentId===e).reduce((o,n)=>{var r,i;return Math.max(o,(i=(r=n.measured)==null?void 0:r.width)!=null?i:0)},0);var Zl=(e=[],t=[],o="LR")=>{let n=new ql.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)),ql.layout(n),{nodes:e.map(i=>{let s=n.node(i.id);return v(x({},i),{position:{x:s.x-i.width/2,y:s.y-i.height/2}})}),edges:t}},en=e=>{let t=e.filter(n=>n.type==="LANE"&&!n.parentId),o=[...e];return t.forEach(n=>{o=tn(n.id,o)}),o},tn=(e,t)=>{var f,y;let o=[...t],n=o.find(g=>g.id===e);if(!n)return o;let r=o.filter(g=>g.parentId===e&&g.type==="LANE");if(r.length===0)return o;let i=vg(r,["position.y"]),s=Math.max((y=(f=n.measured)==null?void 0:f.width)!=null?y:0,vr.MIN_WIDTH),a=Kl(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,T,h;o=o.map(_=>_.id===g.id?v(x({},_),{width:c?l-pe.HEADER_WIDTH:l,measured:v(x({},_.measured),{width:c?l-pe.HEADER_WIDTH:l}),position:{x:pe.HEADER_WIDTH,y:d}}):_),d+=(E=(m=g.measured)==null?void 0:m.height)!=null?E:0,u+=(h=(T=g.measured)==null?void 0:T.height)!=null?h:0}),o=o.map(g=>g.id===e?v(x({},g),{height:u,width:c?l:l+pe.HEADER_WIDTH,measured:v(x({},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=tn(p.parentId,o)),o},Jl=(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(x({},i),{height:t.height,width:t.width,measured:t.measured}):i.id===e.id?v(x({},i),{position:e.position}):i),o},Ql=()=>{let e=document.querySelector(".react-flow__viewport");return e||(console.error("Flow element (.react-flow__viewport) not found."),null)},wg=50,jl=(e,t=wg)=>{let o=Ng(e);return{x:o.x-t,y:o.y-t,width:o.width+t*2,height:o.height+t*2}};var on=1,ec=e=>`<mxGraphModel>
|
|
5
|
+
`).trim();t&&_.length>t&&(_=_.substring(0,t)),E.currentTarget.innerText=_,a==null||a(),_!==e&&(s==null||s(_))};return Al("div",{className:O("flex-1 p-2 self-stretch content-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:Al("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:b,onInput:T,onBlur:y,children:e})})};import{Position as hr}from"@xyflow/react";var Zo=e=>e===hr.Left||e===hr.Right,wi=(e,t=30)=>e===hr.Right||e===hr.Bottom?t:-t,Ai=(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 Wm(e,t,o,n,r,i,s=0){let a=wi(r,Jo.OFFSET),l=wi(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 b=(t+n)/2+s;return[g,{x:e+a,y:t+s},{x:e+a,y:b},{x:o+l,y:b},{x:o+l,y:n+s},m]}if(!c&&!d){let b=(e+o)/2+s;return[g,{x:e+s,y:t+a},{x:b,y:t+a},{x:b,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=Wm(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 Il=(e,t)=>Math.sqrt(Math.pow(t.x-e.x,2)+Math.pow(t.y-e.y,2));function Ym(e,t,o,n){let r=Math.min(Il(e,t)/2,Il(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 Cl=(e,t=5)=>e.length<2?"":e.reduce((o,n,r)=>{let i="";return r>0&&r<e.length-1?i=Ym(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 Um,useStore as $m}from"@xyflow/react";var Xm=50,Sl=.1,Km=.6,_r=({edgeId:e,source:t,target:o,instanceId:n,isReadOnly:r})=>{let{setEdges:i,getNode:s,getNodes:a,getEdge:l,screenToFlowPosition:c}=Um(),{setIsDragging:d,setReconnectingEdgeId:u}=K(),p=$m(C=>C.isValidConnection),[f,h]=so(null),[g,m]=so(null),[b,T]=so(null),[y,E]=so(null),[_,N]=so(null),[w,A]=so(!1),P=Qo(null),B=Qo(null),S=Qo(null),D=Qo(t),Q=Qo(o);br(()=>{D.current=t,Q.current=o},[t,o]),br(()=>{P.current=f},[f]),br(()=>{B.current=_},[_]);let I=io(C=>{let H=a(),F=H.find(te=>te.id===C);if(!F)return{x:0,y:0};let V=F.position.x,G=F.position.y,W=F.parentId;for(;W;){let te=H.find(k=>k.id===W);if(!te)break;V+=te.position.x,G+=te.position.y,W=te.parentId}return{x:V,y:G}},[a]),R=io(C=>{var W,te,k,X,J,Y;let H=a(),F=null,V=Xm,G=H.filter($=>$.type!=="LANE"&&$.type!=="ANNOTATION");for(let $ of G){if($.id===e)continue;let U=I($.id),Z=(k=(te=(W=$.measured)==null?void 0:W.width)!=null?te:$.width)!=null?k:0,j=(Y=(J=(X=$.measured)==null?void 0:X.height)!=null?J:$.height)!=null?Y:0;if(C.x>=U.x&&C.x<=U.x+Z&&C.y>=U.y&&C.y<=U.y+j)return $.id;let ae=Math.max(U.x-C.x,0,C.x-(U.x+Z)),le=Math.max(U.y-C.y,0,C.y-(U.y+j)),ce=Math.sqrt(ae*ae+le*le);ce<V&&(V=ce,F=$.id)}return F},[a,I,e]),L=io((C,H)=>{var ae,le,ce,fe,ge,ue;let F=s(C);if(!F)return null;let V=I(C),G=(ce=(le=(ae=F.measured)==null?void 0:ae.width)!=null?le:F.width)!=null?ce:0,W=(ue=(ge=(fe=F.measured)==null?void 0:fe.height)!=null?ge:F.height)!=null?ue:0,te=Math.abs(V.x+G-H.x),k=Math.abs(H.x-V.x),X=Math.abs(V.y+W-H.y),J=Math.abs(H.y-V.y),Y={right:te,left:k,bottom:X,top:J},$=Object.entries(Y).reduce((ie,[ne,Te])=>Te<ie[1]?[ne,Te]:ie,["right",Y.right])[0],U=S.current;if(U&&U!==$){let ie=Y[$],ne=Y[U],Te=Math.abs(ne-ie),Pe=Math.min(Math.abs(ne),Math.abs(ie));Te<Pe*Km&&($=U)}let Z=$,j,se;if(Z==="right"||Z==="left"){let ne=(Math.max(V.y,Math.min(V.y+W,H.y))-V.y)/(W||1);Math.abs(ne-.5)<Sl&&(ne=.5),se=ne,j={x:Z==="right"?V.x+G:V.x,y:V.y+se*W}}else{let ne=(Math.max(V.x,Math.min(V.x+G,H.x))-V.x)/(G||1);Math.abs(ne-.5)<Sl&&(ne=.5),se=ne,j={x:V.x+se*G,y:Z==="bottom"?V.y+W:V.y}}return{side:Z,snapPosition:j,offset:se}},[s,I]),M=io(C=>{var k,X,J;let H=P.current;if(!H)return;let F=c({x:C.clientX,y:C.clientY}),V=R(F);T(V);let G=F,W=null,te=null;if(V){let Y=L(V,F);Y&&(W=Y.side,G=Y.snapPosition,te=Y.offset,S.current=W);let $=l(e),U={source:H==="source"?V:D.current,target:H==="target"?V:Q.current,sourceHandle:H==="source"?W:(k=$==null?void 0:$.sourceHandle)!=null?k:null,targetHandle:H==="target"?W:(X=$==null?void 0:$.targetHandle)!=null?X:null},Z=(J=p==null?void 0:p(U))!=null?J:!0;A(Z)}else S.current=null,A(!1);E(W),N(te),m(G)},[R,L,l,e,c,p]),q=io(C=>{var W,te,k,X,J;let H=P.current;if(!H)return;let F=c({x:C.clientX,y:C.clientY}),V=R(F);if(V){let Y=L(V,F),$=(W=Y==null?void 0:Y.side)!=null?W:null,U=(te=Y==null?void 0:Y.offset)!=null?te:.5,Z=l(e),j={source:H==="source"?V:D.current,target:H==="target"?V:Q.current,sourceHandle:H==="source"?$:(k=Z==null?void 0:Z.sourceHandle)!=null?k:null,targetHandle:H==="target"?$:(X=Z==null?void 0:Z.targetHandle)!=null?X:null};((J=p==null?void 0:p(j))==null||J)&&i(se=>se.map(ae=>{var le,ce;return ae.id===e?v(x({},ae),{source:j.source,target:j.target,sourceHandle:j.sourceHandle,targetHandle:j.targetHandle,data:v(x({},ae.data),{points:void 0,sourceOffset:H==="source"?U:(le=ae.data)==null?void 0:le.sourceOffset,targetOffset:H==="target"?U:(ce=ae.data)==null?void 0:ce.targetOffset})}):ae}))}h(null),m(null),T(null),E(null),N(null),d(!1),A(!1),u(null),S.current=null,document.removeEventListener("mouseup",q),document.removeEventListener("mousemove",M);let G=tt.get(n);G==null||G.clearReconnectingEdge()},[e,R,L,l,i,n,M,p,c,d,u]),z=io((C,H)=>{if(r||H.button!==0)return;H.stopPropagation(),H.preventDefault(),i(V=>V.map(G=>G.id===e?v(x({},G),{data:v(x({},G.data),{points:void 0})}):G)),h(C),u(e);let F=tt.get(n);F==null||F.setReconnectingEdge(e),document.addEventListener("mousemove",M),document.addEventListener("mouseup",q)},[r,e,n,M,q,u,i]);return br(()=>()=>{if(P.current){document.removeEventListener("mousemove",M),document.removeEventListener("mouseup",q),u(null);let C=tt.get(n);C==null||C.clearReconnectingEdge()}},[n,M,q,u]),{reconnectingHandle:f,cursorPosition:g,hoveredNodeId:b,reconnectingSide:y,reconnectingOffset:_,isValidReconnection:w,handleReconnectStart:z}};import{Fragment as Dl,jsx as Ae,jsxs as bt}from"react/jsx-runtime";var Be={type:"SEQUENCE_EDGE",reconnectable:!0,markerStart:{type:Ll.ArrowClosed},markerEnd:{type:Ll.Arrow},data:{label:""}},{MOVE_THRESHOLD:Tr,MIN_SEGMENT_LENGTH:og,PARALLEL_OFFSET:Rl}=Jo;function ng(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)*Rl}let i=r.findIndex(a=>a.id===e),s=(r.length-1)/2;return(i-s)*Rl}var Ol=({id:e,source:t,target:o,data:n,selected:r,sourcePosition:i,targetPosition:s,sourceHandleId:a,targetHandleId:l})=>{var W,te;let{zoom:c}=eg(),{updateEdgeData:d}=jm(),u=tg(),{isMultipleSelection:p,mode:f,instanceId:h}=K(),[g,m]=Ml(!1),[b,T]=Ml(null),y=Pl(null),E=Pl(null),_=f!=="edit",{reconnectingHandle:N,cursorPosition:w,hoveredNodeId:A,reconnectingSide:P,isValidReconnection:B,handleReconnectStart:S}=_r({edgeId:e,source:t,target:o,instanceId:h,isReadOnly:_}),D=kl(t),Q=kl(o),{sx:I,sy:R,tx:L,ty:M,sourcePos:q,targetPos:z}=Ii(()=>{var le,ce;let k=D&&Q?Zt(D,Q):{sx:0,sy:0,tx:0,ty:0,sourcePos:ao.Right,targetPos:ao.Left},X=a?i:k.sourcePos,J=l?s:k.targetPos,Y=(fe,ge,ue)=>{var dt,Yt,Ut,ye,ve,Ze;let{x:ie,y:ne}=fe.internals.positionAbsolute,Te=(Ut=(Yt=(dt=fe.measured)==null?void 0:dt.width)!=null?Yt:fe.width)!=null?Ut:0,Pe=(Ze=(ve=(ye=fe.measured)==null?void 0:ye.height)!=null?ve:fe.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}}},$=(le=n==null?void 0:n.sourceOffset)!=null?le:.5,U=(ce=n==null?void 0:n.targetOffset)!=null?ce:.5,Z=D?Y(D,X,$).x:k.sx,j=D?Y(D,X,$).y:k.sy,se=Q?Y(Q,J,U).x:k.tx,ae=Q?Y(Q,J,U).y:k.ty;return N==="source"&&w?(Z=w.x,j=w.y,P&&(X=P)):N==="target"&&w&&(se=w.x,ae=w.y,P&&(J=P)),{sx:Z,sy:j,tx:se,ty:ae,sourcePos:X,targetPos:J}},[D,Q,a,l,i,s,N,w,P,n==null?void 0:n.sourceOffset,n==null?void 0:n.targetOffset]);Zm(()=>{var J;if(!E.current){E.current={sx:I,sy:R,tx:L,ty:M,sourcePos:q,targetPos:z};return}let k=E.current;(Math.abs(I-k.sx)>Tr||Math.abs(R-k.sy)>Tr||Math.abs(L-k.tx)>Tr||Math.abs(M-k.ty)>Tr||k.sourcePos!==q||k.targetPos!==z)&&((J=n==null?void 0:n.points)!=null&&J.length)&&!N&&d(e,v(x({},n),{points:void 0})),E.current={sx:I,sy:R,tx:L,ty:M,sourcePos:q,targetPos:z}},[I,R,L,M,q,z,n,e,d,N]);let C=Ii(()=>{let k=ng(e,t,o,u);return Er(I,R,L,M,q,z,n==null?void 0:n.points,k)},[I,R,L,M,q,z,n==null?void 0:n.points,u,e,t,o]),H=Ii(()=>{if(C.length<2)return xr({x:I,y:R},{x:L,y:M});let k=0;for(let Y=0;Y<C.length-1;Y++)k+=yr(C[Y],C[Y+1]);let X=k/2,J=0;for(let Y=0;Y<C.length-1;Y++){let $=yr(C[Y],C[Y+1]);if(J+$>=X){let U=(X-J)/$,Z=C[Y],j=C[Y+1];return{x:Z.x+(j.x-Z.x)*U,y:Z.y+(j.y-Z.y)*U}}J+=$}return xr({x:I,y:R},{x:L,y:M})},[C,I,R,L,M]),F=qm((k,X)=>{if(f!=="edit"||X.button!==0)return;X.stopPropagation(),X.preventDefault();let J=C[k],Y=C[k+1],$=Ai(J,Y,"y"),U=$?J.y:J.x,Z=[...C],j=Z.length,se=k,ae=k+1;T(k);let le=fe=>{let ge=U+($?fe.clientY-X.clientY:fe.clientX-X.clientX)/c;y.current=$?{x:(J.x+Y.x)/2,y:ge}:{x:ge,y:(J.y+Y.y)/2};let ue=[];for(let ie=1;ie<j-1;ie++){let ne=Z[ie];ie===se||ie===ae?$?ue.push({x:ne.x,y:ge}):ue.push({x:ge,y:ne.y}):ue.push(x({},ne))}d(e,v(x({},n),{points:ue}))},ce=()=>{T(null),y.current=null,document.removeEventListener("mousemove",le),document.removeEventListener("mouseup",ce)};document.addEventListener("mousemove",le),document.addEventListener("mouseup",ce)},[f,C,c,n,e,d]);if(!D||!Q)return null;let V=Cl(C),G=r||D.selected||Q.selected;return bt(Dl,{children:[bt("g",{className:O("text-grey-400 hover:text-grey-500",{"text-blue-500 hover:text-blue-600":G}),onDoubleClick:()=>m(!0),children:[Ae(Jm,{id:e,path:V,markerEnd:`url(#${G?"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)||N&&A&&!B,"stroke-green-500":N&&A&&B,"stroke-blue-500 hover:stroke-blue-600 drop-shadow-[0_0_3px_rgba(59,130,246,0.5)]":G&&!(n!=null&&n.hasError)&&!N})}),r&&!p&&!_&&Ae("g",{children:C.slice(0,-1).map((k,X)=>{let J=C[X+1];if(X===0||X===C.length-2||yr(k,J)<og)return null;let Y=Ai(k,J,"y"),$=b===X,U=$&&y.current?y.current:xr(k,J);return bt("g",{children:[Ae("line",{x1:k.x,y1:k.y,x2:J.x,y2:J.y,stroke:"transparent",strokeWidth:20/c,className:O("cursor-pointer",{"cursor-ns-resize":Y,"cursor-ew-resize":!Y}),onMouseDown:Z=>F(X,Z)}),Ae("circle",{cx:U.x,cy:U.y,r:4/c,fill:$?"#3b82f6":"#fff",stroke:"#3b82f6",strokeWidth:2/c,className:"pointer-events-none"}),Ae("circle",{cx:U.x,cy:U.y,r:6/c,fill:"none",stroke:"#3b82f6",strokeWidth:1/c,opacity:$?.6:.3,className:"pointer-events-none"})]},X)})})]}),bt(Qm,{children:[bt("div",{className:"absolute z-[3000] pointer-events-none flex flex-col items-center gap-1",style:{transform:`translate(-50%, -50%) translate(${H.x}px, ${H.y}px)`},children:[r&&!p&&Ae(no,{sx:I,sy:R,tx:L,ty:M,hasLabel:!!((W=n==null?void 0:n.label)!=null&&W.trim()),children:Ae(oo,{edgeId:e,edgeType:"SEQUENCE_EDGE",sourceNode:D,targetNode:Q})}),(g||((te=n==null?void 0:n.label)==null?void 0:te.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&&!_&&bt(Dl,{children:[Ae("div",{className:"absolute z-[10000] pointer-events-none",style:{transform:`translate(-50%, -50%) translate(${C[0].x}px, ${C[0].y}px)`},children:bt("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:N==="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:N==="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":!N||N!=="source","cursor-not-allowed":N==="source"&&A&&!B,"cursor-grabbing":N==="source"&&(!A||B)}),onMouseDown:k=>S("source",k.nativeEvent)})]})}),Ae("div",{className:"absolute z-[10000] pointer-events-none",style:{transform:`translate(-50%, -50%) translate(${C[C.length-1].x}px, ${C[C.length-1].y}px)`},children:bt("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:N==="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:N==="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":!N||N!=="target","cursor-not-allowed":N==="target"&&A&&!B,"cursor-grabbing":N==="target"&&(!A||B)}),onMouseDown:k=>S("target",k.nativeEvent)})]})})]})]})]})};import{Position as at}from"@xyflow/react";var rg={right:at.Right,left:at.Left,top:at.Top,bottom:at.Bottom},Nr=e=>{var t;return(t=rg[e!=null?e:""])!=null?t:at.Right},Ci=(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}}},Vl=(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 ey}from"use-debounce";import{getViewportForBounds as Jh,useReactFlow as Qh,useStoreApi as jh}from"@xyflow/react";import{useCallback as Qc}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 ig,json2xml as sg}from"xml-js";var Hl={compact:!0,spaces:4},ag=e=>e.replace(/\n/g,"
");function vr(e,t=Hl){if(e)return JSON.parse(ig(e,t))}function Gl(e,t=Hl){return e?sg(e,v(x({},t),{attributeValueFn:ag})):""}var lg={MIN_WIDTH:36,MIN_HEIGHT:36},cg={MIN_WIDTH:36,MIN_HEIGHT:36},dg={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},ug={MIN_WIDTH:128,MIN_HEIGHT:64},oe={START_EVENT:lg,END_EVENT:cg,GATEWAY:dg,TASK:lo,LANE:pe,ANNOTATION:co,UNSUPPORTED:ug};var Bl={"attribute-loop":"LOOP"},zl={"task-script":"SCRIPT","subprocess-collapsed":"SUBPROCESS"},Fl={"gateway-exclusive":"EXCLUSIVE","gateway-parallel":"PARALLEL","gateway-complex":"COMPLEX"},Wl={SCRIPT:"task-script",SUBPROCESS:"subprocess-collapsed"},Yl={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((b,T)=>Math.max(b,T.length),0)*7+r,c=g*20+i}let d=Math.max(ut(Number(s),t),l),u=Math.max(ut(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},fg=e=>{let{mxGeometry:t}=e,o=po(e),n=uo(t,oe.START_EVENT.MIN_WIDTH,oe.START_EVENT.MIN_HEIGHT);return v(x(x({},o),n),{type:"START_EVENT"})},mg=e=>{let{mxGeometry:t}=e,o=po(e),n=uo(t,oe.END_EVENT.MIN_WIDTH,oe.END_EVENT.MIN_HEIGHT);return v(x(x({},o),n),{type:"END_EVENT"})},Si=(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=Bl[d];u&&(r.data.attribute=u)}let c=zl[o.style];return c&&(r.data.variant=c),v(x(x({},r),a),{type:"TASK"})},Mi=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=Fl[n],v(x(x({},r),i),{type:"GATEWAY"})},gg=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(x(x({},o),i),{type:"ANNOTATION"})},hg=e=>{let{mxGeometry:t}=e,o=po(e),n=uo(t,oe.LANE.MIN_WIDTH,oe.LANE.MIN_HEIGHT);return v(x(x({},o),n),{type:"LANE"})},Ul={task:Si,"task-script":Si,"subprocess-collapsed":Si,"start-event":fg,"end-event-terminate":mg,"gateway-parallel":Mi,"gateway-exclusive":Mi,"gateway-complex":Mi,annotation:gg,lane:hg},yg=e=>{if(e&&Array.isArray(e))return e.map(t=>({x:Number(t._attributes.x),y:Number(t._attributes.y)}))},$l=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=yg(o==null?void 0:o.Array),f=d!==void 0?Number(d):void 0,h=u!==void 0?Number(u):void 0,g=v(x(x({id:n,source:r,target:i},l?{sourceHandle:l}:{}),c?{targetHandle:c}:{}),{data:x(x(x({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=""')?x(x({},ro),g):x(x({},Be),g)},Xl=(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}}}},xg=e=>{let{variant:t}=e.data,o=fo(e);return v(x({},o),{_attributes:v(x({},o._attributes),{style:Wl[t]||"task"})})},Eg=e=>{let t=fo(e);return v(x({},t),{_attributes:v(x({},t._attributes),{style:"start-event"})})},bg=e=>{let t=fo(e);return v(x({},t),{_attributes:v(x({},t._attributes),{style:"end-event-terminate"})})},_g=e=>{let{variant:t}=e.data,o=fo(e);return v(x({},o),{_attributes:v(x({},o._attributes),{style:Yl[t]})})},Tg=e=>{let t=fo(e);return v(x({},t),{_attributes:v(x({},t._attributes),{style:"lane"})})},Ng=e=>{let t=fo(e);return v(x({},t),{_attributes:v(x({},t._attributes),{style:"annotation"})})},Kl={TASK:xg,START_EVENT:Eg,END_EVENT:bg,GATEWAY:_g,ANNOTATION:Ng,LANE:Tg},ql=(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 ec from"@dagrejs/dagre";import{getNodesBounds as Ig}from"@xyflow/react";import{orderBy as Cg}from"lodash";import{orderBy as vg}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=>vg(e,[o=>{let n=o.type==="LANE";return n&&!o.parentId?0:n?1:2}],["asc"]),Zl=(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)),wg=(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)},Ag=(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&&Ag(e,r)){let i=wg(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),Ql=(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(x({},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(x({},c),{data:v(x({},d),{points:d.points.map(u=>({x:u.x-i,y:u.y-s}))})}):c});return{nodes:a,edges:l}},jl=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 tc=(e=[],t=[],o="LR")=>{let n=new ec.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)),ec.layout(n),{nodes:e.map(i=>{let s=n.node(i.id);return v(x({},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=Cg(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,b,T,y;o=o.map(E=>E.id===g.id?v(x({},E),{width:c?l-pe.HEADER_WIDTH:l,measured:v(x({},E.measured),{width:c?l-pe.HEADER_WIDTH:l}),position:{x:pe.HEADER_WIDTH,y:d}}):E),d+=(b=(m=g.measured)==null?void 0:m.height)!=null?b:0,u+=(y=(T=g.measured)==null?void 0:T.height)!=null?y:0}),o=o.map(g=>g.id===e?v(x({},g),{height:u,width:c?l:l+pe.HEADER_WIDTH,measured:v(x({},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},oc=(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(x({},i),{height:t.height,width:t.width,measured:t.measured}):i.id===e.id?v(x({},i),{position:e.position}):i),o},nc=()=>{let e=document.querySelector(".react-flow__viewport");return e||(console.error("Flow element (.react-flow__viewport) not found."),null)},Sg=50,rc=(e,t=Sg)=>{let o=Ig(e);return{x:o.x-t,y:o.y-t,width:o.width+t*2,height:o.height+t*2}};var nn=1,ic=e=>`<mxGraphModel>
|
|
6
7
|
<root version="1.1">
|
|
7
8
|
<mxCell id="0" />
|
|
8
9
|
<mxCell id="1" parent="0" />
|
|
@@ -35,10 +36,11 @@ var uu=Object.defineProperty,pu=Object.defineProperties;var fu=Object.getOwnProp
|
|
|
35
36
|
<mxGeometry as="geometry" relative="1" />
|
|
36
37
|
</mxCell>
|
|
37
38
|
</root>
|
|
38
|
-
</mxGraphModel>`,tc=(e,t)=>{if(!e.length&&!t.length)return on;let o=[...e.map(r=>r.id),...t.map(r=>r.id)];return Math.max(...o.map(r=>Number(r)))};var Ag=e=>{let t=Object.values(Qo),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=Fl[s],l=a==null?void 0:a(i,n);if(!l){console.warn(`Node ${s} not supported`);continue}r.push(l)}return r},Ig=(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=Wl(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},Cg=(e,t)=>{let o=[];return e.forEach(n=>{var s,a;let r=(a=(s=Ul)[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=$l(n,t);o.push(l)}}),o},Sg=(e,t)=>{let o=[];return e.forEach(n=>{let r=Yl(n,t);o.push(r)}),o},oc=(e=[],t=[],o)=>{let n=Cg(e,o),r=Sg(t,e),i={mxGraphModel:{root:{_attributes:{version:"1.1",lastId:o},mxCell:[{_attributes:{id:"0"}},{_attributes:{id:"1",parent:"0"}},...n,...r]}}};return Ol(JSON.stringify(i),{compact:!0,spaces:0})},nc=async e=>{var a,l,c,d,u;let t=await Nr(e),o=((l=(a=t==null?void 0:t.mxGraphModel)==null?void 0:a.root)==null?void 0:l.mxCell)||[],n=Number(((u=(d=(c=t==null?void 0:t.mxGraphModel)==null?void 0:c.root)==null?void 0:d._attributes)==null?void 0:u.lastId)||on),r=Ag(o),i=Ig(o,r);return{nodes:Ot(en(r)),edges:i,lastElementId:n}};import{Position as pc,useConnection as lh,useReactFlow as ch}from"@xyflow/react";import{Handle as rc,useReactFlow as Mg}from"@xyflow/react";import{jsx as ic}from"react/jsx-runtime";var ie=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 ic(rc,x({type:e,position:t,className:R("size-2.5 border border-grey-400 bg-white relative",{"before:content-[''] before:absolute before:inset-[-16px] before:bg-transparent":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}=Mg(),p=(()=>{if(n!=="source")return!1;let f=c();if(t==="TASK")return f.filter(g=>g.source===e).length>=2;if(t==="GATEWAY"&&o==="EXCLUSIVE")return f.filter(g=>g.source===e).length>=2;if(t==="START_EVENT"){let y=d();return f.filter(m=>{if(m.source!==e)return!1;let E=y.find(T=>T.id===m.target);return(E==null?void 0:E.type)!=="ANNOTATION"}).length>=1}return!1})();return ic(rc,x({type:n,position:r,className:R("size-2.5 border border-grey-400 bg-white transition-all duration-200 relative",{"before:content-[''] before:absolute before:inset-[-16px] before:bg-transparent":t==="TASK","before:content-[''] before:absolute before:inset-[-4px] before:bg-transparent":t!=="TASK","opacity-50 cursor-not-allowed pointer-events-none":p,"hover:border-grey-500":!p},i),style:{pointerEvents:p?"none":"auto"}},s))};import{NodeResizer as Pg,useReactFlow as Lg}from"@xyflow/react";import{orderBy as kg}from"lodash";import{jsx as Rg}from"react/jsx-runtime";var mo=n=>{var r=n,{nodeId:e,isVisible:t}=r,o=Je(r,["nodeId","isVisible"]);let{getNode:i,getNodes:s,setNodes:a}=Lg(),{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 y=[...s()],g=!f.parentId,m=g?f.id:f.parentId,E=y.filter(_=>_.type==="LANE"&&_.parentId===m);if(!E.length)return;let T=kg(E,["position.y"]),h=0;T.forEach((_,b)=>{var I,M;let N=b===T.length-1,A=(M=(I=_.measured)==null?void 0:I.height)!=null?M:0;y=y.map(H=>{if(H.id===_.id){let S=g?u-pe.HEADER_WIDTH:u,w=v(x({},H),{width:S,measured:v(x({},H.measured),{width:S}),position:v(x({},H.position),{y:h})});return N&&g&&(w.height=p-h),w}return H}),h+=A}),y=y.map(_=>{if(_.id===m){let b=g?u:u+pe.HEADER_WIDTH;return v(x({},_),{width:b,height:g?p:h,measured:{width:b,height:g?p:h}})}return _}),a(y)};return Rg(Pg,x({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 Qg,useReactFlow as jg}from"@xyflow/react";import{Button as eh,Tooltip as th,TooltipContent as oh,TooltipTrigger as nh,useTranslation as rh}from"@produto-lecom/lecom-ui";import{useCallback as ih,useRef as dc,useState as sh}from"react";import{create as Dg}from"zustand";var go=Dg(e=>({draggableNode:null,setDraggableNode:t=>{e({draggableNode:t})}}));import{useEffect as Og,useState as Vg}from"react";var sc=(e,t=!1)=>{let[o,n]=Vg({width:0,height:0});return Og(()=>{if(e.current&&t){let r=e.current.getBoundingClientRect();n({width:r.width,height:r.height})}},[t,e]),{dimensions:o}};import{Position as nn,useReactFlow as Hg}from"@xyflow/react";import{useMemo as Gg}from"react";var Bg=120,zg=12,ac=(e,t=!1,o)=>{let{getNode:n,getViewport:r}=Hg(),{instanceId:i}=q();return Gg(()=>{var f,y;if(!t)return{position:nn.Right,align:"start"};let s=n(e);if(!s)return{position:nn.Right,align:"start"};let a=r(),l=s.position.x*a.zoom+a.x,c=(((f=s.measured)==null?void 0:f.width)||s.width||100)*a.zoom,d=(y=document.getElementById(`modeler-${i}`))==null?void 0:y.clientWidth;if(!d)return{position:nn.Right,align:"start"};let u=(o==null?void 0:o.width)||Bg;return{position:l+c+u+zg>d?nn.Left:nn.Right}},[i,e,t,o,n,r])};import{useNodesData as Fg,useReactFlow as Wg}from"@xyflow/react";import{Button as lc,DropdownMenu as Yg,DropdownMenuContent as Ug,DropdownMenuGroup as $g,DropdownMenuItem as Xg,DropdownMenuLabel as Kg,DropdownMenuTrigger as qg,Tooltip as Mi,TooltipContent as Pi,TooltipTrigger as Li,useTranslation as Zg}from"@produto-lecom/lecom-ui";import{WrenchIcon as Jg}from"lucide-react";import{jsx as Ie,jsxs as Vt}from"react/jsx-runtime";var cc=({nodeId:e})=>{let{t}=Zg(),{updateNodeData:o,getEdges:n,getNode:r}=Wg(),i=Fg(e),a=n().filter(f=>f.source===e).some(f=>{let y=r(f.target);return(y==null?void 0:y.type)==="END_EVENT"}),l=(i==null?void 0:i.data.variant)==="SUBPROCESS",c=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(Yg,{children:[Vt(Mi,{children:[Ie(Li,{asChild:!0,children:Ie(qg,{asChild:!0,children:Ie(lc,{variant:"ghost",color:"grey",size:"small",iconButton:!0,children:Ie(Jg,{})})})}),Ie(Pi,{color:"black",children:t("bpmn.task.menu.title")})]}),Vt(Ug,{align:"start",className:"w-60 bg-white text-grey-600",children:[Vt(Kg,{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(Nn).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(Mi,{children:[Ie(Li,{asChild:!0,children:Ie(lc,{variant:"ghost",color:"grey",size:"small",iconButton:!0,disabled:f,className:R({"bg-grey-100 text-blue-500":(i==null?void 0:i.data.attribute)===u,"opacity-50 cursor-not-allowed":f}),onClick:f?void 0:()=>d(u),children:Ie(p.icon,{className:"stroke-inherit"})})}),g&&Ie(Pi,{color:"black",children:g})]},u)})})]}),Ie($g,{children:Vt(Mi,{children:[Ie(Li,{asChild:!0,children:Ie("div",{className:R({"cursor-not-allowed":a}),children:Vt(Xg,{className:R({"bg-grey-100 text-blue-500":(i==null?void 0:i.data.variant)==="SCRIPT","opacity-50":a}),disabled:a,onClick:()=>c("SCRIPT"),children:[Ie(Tn.SCRIPT.icon,{className:"stroke-current"}),t(`bpmn.task.variant.${"SCRIPT".toLowerCase()}`)]})})}),a&&Ie(Pi,{color:"black",children:t("editor.task_menu.script_not_allowed_when_connected_to_end")})]})})]})]})};import{jsx as he,jsxs as uc}from"react/jsx-runtime";var Ht={START_EVENT:{type:"START_EVENT",icon:wo,label:"bpmn.start_event.variant.default"},END_EVENT:{type:"END_EVENT",icon:$t,label:"bpmn.end_event.variant.default"},TASK:{type:"TASK",icon:wo,label:"bpmn.task.variant.default"},ANNOTATION:{type:"ANNOTATION",icon:xn,label:"bpmn.annotation.variant.default"}},ah={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"}},De=({nodeId:e,nodeType:t,nodeVariant:o})=>{let n=dc(null),r=dc(null),{t:i}=rh(),{setDraggableNode:s}=go(),{getEdges:a,getNodes:l,getNode:c}=jg(),{setIsDragging:d,mode:u,isConnecting:p,isDragging:f,isMultipleSelection:y}=q(),g=c(e),m=!!(g!=null&&g.selected)&&!g.dragging&&!p&&!f&&!y,{dimensions:E}=sc(n,m),{position:T}=ac(e,m,E),[h,_]=sh(void 0),b=l(),N=a(),A=o==="SUBPROCESS",I=ih((F,C)=>{d(!1),s({type:C.type,variant:C.variant,attribute:C.attribute,icon:C.icon}),C.icon&&_(he(C.icon,{})),F.dataTransfer.effectAllowed="move",F.dataTransfer.setData("sourceId",e),r.current&&F.dataTransfer.setDragImage(r.current,10,10),setTimeout(()=>{d(!0)},100)},[e,s,d]),M=[{component:he(fr,{elementId:e})}],H=()=>{if(u==="view")return[];let F=!N.some(C=>{var D;return C.source===e&&((D=b.find(O=>O.id===C.target))==null?void 0:D.type)!=="ANNOTATION"});return[{component:he(Dt,{nodeId:e,disabled:!F,tooltipMessage:F?void 0:i("editor.toolbar.start_event_limit_reached")})},Ht.TASK,Ht.ANNOTATION,...M]},S=()=>u==="view"?[{component:he(Et,{elementId:e})}]:[{component:he(Et,{elementId:e})},...A?[]:[{component:he(cc,{nodeId:e})}],{component:he(Dt,{nodeId:e})},Ht.TASK,...Object.values(ah),...M],w=()=>u==="view"?[{component:he(Et,{elementId:e})}]:[{component:he(Et,{elementId:e})},{component:he(Dt,{nodeId:e})},Ht.TASK,Ht.ANNOTATION,...M],k=()=>u==="view"?[]:[{component:he(Dt,{nodeId:e})},Ht.ANNOTATION,...M],V=()=>u==="view"?[]:[{component:he(Dt,{nodeId:e})},Ht.ANNOTATION,...M],P=()=>u==="view"?[]:[{component:he(Dt,{nodeId:e})},...M],L=()=>u==="view"?[]:[...M],Q=(F=>{switch(F){case"START_EVENT":return H();case"TASK":return S();case"GATEWAY":return w();case"END_EVENT":return k();case"LANE":return V();case"ANNOTATION":return P();case"UNSUPPORTED":return L();default:return[]}})(t);if(!(Q.length===0||u==="readonly"))return uc(Qg,{position:T,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:Q.map((F,C)=>{if(F.component)return he("div",{children:F.component},C);let D={sourceNodeType:t,targetNodeType:F.type,sourceNodeId:e,nodes:b,edges:N},O=yl(D),G={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")},Y=O.shouldDisable&&O.reason?G[O.reason]||i(F.label):i(F.label)||"";return uc(th,{children:[he(nh,{asChild:!0,children:he(eh,{variant:"ghost",color:"grey",size:"small",iconButton:!0,draggable:!O.shouldDisable,disabled:O.shouldDisable,className:O.shouldDisable?"opacity-50 cursor-not-allowed":"",onDragStart:O.shouldDisable?void 0:z=>I(z,F),children:F.icon&&he(F.icon,{size:16})})}),he(oh,{color:"black",children:Y})]},C)})}),he("div",{ref:r,className:"absolute w-0 h-0 top-0 left-0 z-[-1] bg-transparent",children:h})]})};import{jsx as rn,jsxs as dh}from"react/jsx-runtime";var fc=({id:e,data:t,selected:o,dragging:n})=>{let{updateNodeData:r}=ch(),{inProgress:i,fromNode:s}=lh(),{mode:a}=q(),l=i&&(s==null?void 0:s.id)!==e,c=d=>{r(e,{label:d})};return dh("div",{className:R("relative w-full h-full min-w-44 min-h-16 flex text-grey-400 hover:text-grey-500 bg-white rounded-sm border-l-2 border-current before:absolute before:top-0 before:left-0 before:w-4 before:border-t-2 before:border-current after:absolute after:bottom-0 after:left-0 after:w-4 after:border-t-2 after:border-current hover:shadow-md transition-colors duration-75",{"text-blue-500 hover:text-blue-600 shadow-md":o,"border-red-500 border-l-[3px] shadow-[0_0_5px_rgba(255,0,0,0.5)] before:absolute before:top-0 before:left-0 before:w-4 before:border-t-2 before:border-red-500 after:absolute after:bottom-0 after:left-0 after:w-4 after:border-t-2 after:border-red-500":t.hasError}),children:[rn(we,{value:t.label,className:"m-1 text-grey-600 text-left",onChange:c}),rn(De,{nodeId:e,nodeType:"ANNOTATION"}),a==="edit"&&rn(mo,{minWidth:wr.MIN_WIDTH,minHeight:wr.MIN_HEIGHT,isVisible:!n&&o}),!i&&rn(ie,{type:"source",position:pc.Right}),(!i||l)&&rn(ie,{type:"target",position:pc.Left,className:R({"annotation-handle":l})})]})};import{Position as _t,useConnection as uh,useReactFlow as ph}from"@xyflow/react";import{useState as fh}from"react";import{Fragment as mc,jsx as ze,jsxs as ki}from"react/jsx-runtime";var gc=({id:e,data:t,selected:o})=>{let{updateNodeData:n}=ph(),{inProgress:r,fromNode:i}=uh(),{reconnectingEdgeId:s}=q(),[a,l]=fh(!1),c=r&&(i==null?void 0:i.id)!==e||!!s,d=f=>{n(e,{label:f})},u=()=>{l(!0)},p=()=>{l(!1)};return ki("div",{className:"relative",onDoubleClick:u,children:[ze($t,{className:R("size-9 hover:stroke-[#d33b3b] transition-colors duration-75",{"stroke-blue-500 hover:stroke-blue-600":o,"stroke-red-500 hover:stroke-red-600 drop-shadow-[0_0_3px_rgba(255,0,0,0.5)] fill-red-100":t.hasError})}),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(De,{nodeId:e,nodeType:"END_EVENT"}),(!r||c)&&ki(mc,{children:[ze(ie,{type:"target",position:_t.Left,id:"left",className:R({"event-handle":c})}),ze(ie,{type:"target",position:_t.Right,id:"right",className:R({"event-handle":c})}),ze(ie,{type:"target",position:_t.Top,id:"top",className:R({"event-handle":c})}),ze(ie,{type:"target",position:_t.Bottom,id:"bottom",className:R({"event-handle":c})})]}),!r&&ki(mc,{children:[ze(ie,{type:"source",position:_t.Left,id:"left"}),ze(ie,{type:"source",position:_t.Right,id:"right"}),ze(ie,{type:"source",position:_t.Top,id:"top"}),ze(ie,{type:"source",position:_t.Bottom,id:"bottom"})]})]})};import{Position as Tt,useConnection as mh,useReactFlow as gh}from"@xyflow/react";import{useCallback as hh,useState as yh}from"react";import{Fragment as hc,jsx as Fe,jsxs as Ri}from"react/jsx-runtime";var yc=({id:e,data:t,selected:o})=>{let n=ni[t.variant].icon,{updateNodeData:r}=gh(),{inProgress:i,fromNode:s}=mh(),{reconnectingEdgeId:a}=q(),[l,c]=yh(!1),d=i&&(s==null?void 0:s.id)!==e||!!a,u=hh(y=>{r(e,{label:y})},[e,r]),p=()=>{c(!0)},f=()=>{c(!1)};return Ri("div",{className:"relative",onDoubleClick:p,children:[Fe(n,{className:R("size-14 stroke-1 stroke-grey-400 hover:stroke-grey-500 transition-colors duration-75",{"stroke-blue-500 hover:stroke-blue-600":o,"stroke-red-500 hover:stroke-red-600 drop-shadow-[0_0_3px_rgba(255,0,0,0.5)]":t.hasError})}),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(De,{nodeId:e,nodeType:"GATEWAY"}),(!i||d)&&Ri(hc,{children:[Fe(ie,{type:"target",position:Tt.Left,id:"left",className:R({"gateway-handle":d})}),Fe(ie,{type:"target",position:Tt.Right,id:"right",className:R({"gateway-handle":d})}),Fe(ie,{type:"target",position:Tt.Top,id:"top",className:R({"gateway-handle":d})}),Fe(ie,{type:"target",position:Tt.Bottom,id:"bottom",className:R({"gateway-handle":d})})]}),!i&&Ri(hc,{children:[Fe(Me,{type:"source",position:Tt.Left,id:"left",nodeId:e,nodeType:"GATEWAY",gatewayVariant:t.variant}),Fe(Me,{type:"source",position:Tt.Right,id:"right",nodeId:e,nodeType:"GATEWAY",gatewayVariant:t.variant}),Fe(Me,{type:"source",position:Tt.Top,id:"top",nodeId:e,nodeType:"GATEWAY",gatewayVariant:t.variant}),Fe(Me,{type:"source",position:Tt.Bottom,id:"bottom",nodeId:e,nodeType:"GATEWAY",gatewayVariant:t.variant})]})]})};import{useNodesData as _C,useReactFlow as TC}from"@xyflow/react";import{Button as vC,DropdownMenu as wC,DropdownMenuContent as AC,DropdownMenuGroup as IC,DropdownMenuItem as CC,DropdownMenuLabel as SC,DropdownMenuTrigger as MC,Tooltip as PC,TooltipContent as LC,TooltipTrigger as kC,useTranslation as RC}from"@produto-lecom/lecom-ui";import{WrenchIcon as OC}from"lucide-react";import{jsx as BC,jsxs as zC}from"react/jsx-runtime";import{Position as Nt,useConnection as xh,useReactFlow as Eh}from"@xyflow/react";import{useState as bh}from"react";import{Fragment as xc,jsx as We,jsxs as Di}from"react/jsx-runtime";var Ec=({id:e,data:t,selected:o})=>{let{updateNodeData:n}=Eh(),{inProgress:r,fromNode:i}=xh(),{reconnectingEdgeId:s}=q(),[a,l]=bh(!1),c=r&&(i==null?void 0:i.id)!==e||!!s,d=f=>{n(e,{label:f})},u=()=>{l(!0)},p=()=>{l(!1)};return Di("div",{className:"relative",onDoubleClick:u,children:[We(bn,{className:R("size-9 hover:stroke-[#54890b] transition-colors duration-75",{"stroke-blue-500 hover:stroke-blue-600":o,"stroke-red-500 hover:stroke-red-600 drop-shadow-[0_0_3px_rgba(255,0,0,0.5)] fill-red-100":t.hasError})}),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(De,{nodeId:e,nodeType:"START_EVENT"}),(!r||c)&&Di(xc,{children:[We(ie,{type:"target",position:Nt.Left,id:"left",className:R({"event-handle":c})}),We(ie,{type:"target",position:Nt.Right,id:"right",className:R({"event-handle":c})}),We(ie,{type:"target",position:Nt.Top,id:"top",className:R({"event-handle":c})}),We(ie,{type:"target",position:Nt.Bottom,id:"bottom",className:R({"event-handle":c})})]}),!r&&Di(xc,{children:[We(Me,{type:"source",position:Nt.Left,id:"left",nodeId:e,nodeType:"START_EVENT"}),We(Me,{type:"source",position:Nt.Right,id:"right",nodeId:e,nodeType:"START_EVENT"}),We(Me,{type:"source",position:Nt.Top,id:"top",nodeId:e,nodeType:"START_EVENT"}),We(Me,{type:"source",position:Nt.Bottom,id:"bottom",nodeId:e,nodeType:"START_EVENT"})]})]})};import{useTranslation as Nh}from"@produto-lecom/lecom-ui";import{Position as vt,useConnection as vh,useReactFlow as wh}from"@xyflow/react";import{useCallback as Ir}from"react";var sn=60,Ar=(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<=sn?i:i.substring(0,sn).trim()},ho=(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>sn&&(n=n.substring(0,sn).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=sn-l.length,u=`${r.substring(0,c).trim()}${l}`;if(!o.has(u))return u;i++}return n};import{jsx as bc,jsxs as _h}from"react/jsx-runtime";var _c=e=>_h("svg",v(x({width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",xmlns:"http://www.w3.org/2000/svg"},e),{children:[bc("circle",{cx:"12",cy:"12",r:"10",fill:"#10B981"}),bc("path",{d:"M7 12L10 15L17 8",stroke:"white",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"})]}));import{jsx as Tc}from"react/jsx-runtime";var Nc=e=>Tc("svg",v(x({width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",xmlns:"http://www.w3.org/2000/svg"},e),{children:Tc("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 vc,jsxs as Th}from"react/jsx-runtime";var wc=e=>Th("svg",v(x({width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",xmlns:"http://www.w3.org/2000/svg"},e),{children:[vc("circle",{cx:"12",cy:"12",r:"10",fill:"#EF4444"}),vc("path",{d:"M8 8L16 16M8 16L16 8",stroke:"white",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"})]}));import{Fragment as Cr,jsx as fe,jsxs as an}from"react/jsx-runtime";var Ah={APROVADO:_c,EM_ANDAMENTO:Nc,REJEITADO:wc},Oi={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)]"},Ac=({id:e,data:t,selected:o,dragging:n})=>{let{t:r}=Nh(),{toast:i}=Re(),{updateNodeData:s,getNodes:a,setNodes:l}=wh(),{inProgress:c,fromNode:d}=vh(),{mode:u,onSubprocessValidationClick:p,reconnectingEdgeId:f}=q(),{getTaskStatus:y}=St(),g=c&&(d==null?void 0:d.id)!==e||!!f,m=Ir(k=>{let Q=k.split(`
|
|
39
|
-
`),F=Q.reduce((G,Y)=>Math.max(G,Y.length),0),C=Q.length,D=Math.max(lo.MIN_WIDTH,F*7+48),O=Math.max(lo.MIN_HEIGHT,C*20+24);l(G=>G.map(Y=>Y.id===e?v(x({},Y),{width:D,height:O,style:v(x({},Y.style),{width:D,height:O})}):Y))},[e,l]),E=Ir(k=>{let V=k.trim(),P=t.label||"";if(V===P)return;let L=V,W=a();if(!(V&&V!=="")){L=Ar(W,r("bpmn.task.label.prefix")),s(e,{label:L}),m(L),i({variant:"warning",content:an(Cr,{children:[r("bpmn.task.feedback.label_empty.prefix")," ",fe("strong",{children:L})]})});return}let F=ho(L,W);F===P||(s(e,{label:F}),m(F),F!==L&&i({variant:"warning",content:an(Cr,{children:[r("bpmn.task.feedback.label_already_exists.prefix")," ",fe("strong",{children:V})," ",r("bpmn.task.feedback.label_already_exists.middle")," ",fe("strong",{children:F})]})}))},[t.label,a,e,r,s,m]),T=Ir(k=>{m(k)},[m]),h=Ir(()=>{i({variant:"error",content:r("bpmn.task.feedback.invalid_first_character")})},[r]),_=y(e),b=_?Ah[_]:null,N=t.variant?Tn[t.variant].icon:null,A=t.attribute?Nn[t.attribute].icon:null,I=t.variant==="SUBPROCESS",M=N&&!I,H=A||I,S=()=>t.hasError?Oi.error:_?Oi[_]:Oi.default,w=()=>{p==null||p({id:e,type:"sub_process",label:t.label})};return an("div",{className:R("relative w-full h-full min-w-44 min-h-24 flex items-center justify-center bg-white border-2 border-grey-400 hover:border-grey-500 rounded-md hover:shadow-md transition-colors duration-75",S(),{"border-blue-500 hover:border-blue-600 shadow-md":o,"border-red-500 hover:border-red-600 shadow-[0_0_5px_rgba(255,0,0,0.5)]":t.hasError}),children:[fe(we,{value:t.label,maxLength:60,className:R("m-1",{"py-6":M||H}),onChange:E,onInput:T,onInvalidFirstCharacter:h}),N&&fe("div",{className:R("absolute flex items-center p-1",I?"bottom-0":"top-0 left-0"),children:fe(N,{size:16,className:R(t.hasError?"text-red-500":"text-grey-500",I&&"cursor-pointer"),onClick:I?w:void 0})}),A&&fe("div",{className:"absolute bottom-0 left-0 w-full flex items-center justify-center",children:fe("div",{className:R("flex items-center w-16 p-1",I?"justify-between":"justify-center"),children:fe(A,{size:16,className:R(t.hasError?"text-red-500":"text-grey-500")})})}),b&&fe("div",{className:"absolute top-0 right-0 flex items-center p-1",children:fe(b,{})}),fe(De,{nodeId:e,nodeType:"TASK",nodeVariant:t.variant}),u==="edit"&&fe(mo,{minWidth:lo.MIN_WIDTH,minHeight:lo.MIN_HEIGHT,isVisible:!n&&o}),(!c||g)&&an(Cr,{children:[fe(ie,{type:"target",position:vt.Left,id:"left",className:R({"task-handle":g})}),fe(ie,{type:"target",position:vt.Right,id:"right",className:R({"task-handle":g})}),fe(ie,{type:"target",position:vt.Top,id:"top",className:R({"task-handle":g})}),fe(ie,{type:"target",position:vt.Bottom,id:"bottom",className:R({"task-handle":g})})]}),!c&&an(Cr,{children:[fe(Me,{type:"source",position:vt.Left,id:"left",nodeId:e,nodeType:"TASK"}),fe(Me,{type:"source",position:vt.Right,id:"right",nodeId:e,nodeType:"TASK"}),fe(Me,{type:"source",position:vt.Top,id:"top",nodeId:e,nodeType:"TASK"}),fe(Me,{type:"source",position:vt.Bottom,id:"bottom",nodeId:e,nodeType:"TASK"})]})]})};import{Position as Ic}from"@xyflow/react";import{Fragment as Ih,jsx as Sr,jsxs as Ch}from"react/jsx-runtime";var Cc=({id:e,data:t})=>Ch(Ih,{children:[Sr("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}),Sr(De,{nodeId:e,nodeType:"UNSUPPORTED"}),Sr(ie,{type:"source",position:Ic.Right}),Sr(ie,{type:"target",position:Ic.Left})]});import{BaseEdge as Sh,EdgeLabelRenderer as Mh,getSmoothStepPath as Ph,MarkerType as Lh,useInternalNode as Sc,useReactFlow as kh,useViewport as Rh,Position as yo}from"@xyflow/react";import{useState as Dh,useMemo as Oh}from"react";import{Fragment as Mc,jsx as Ve,jsxs as xo}from"react/jsx-runtime";var T5={type:"MESSAGE_EDGE",reconnectable:!0,markerEnd:{type:Lh.Arrow},data:{label:""}},Pc=({id:e,source:t,target:o,data:n,selected:r,sourcePosition:i,targetPosition:s,sourceHandleId:a,targetHandleId:l})=>{var Y;let{zoom:c}=Rh(),{updateEdgeData:d}=kh(),{isMultipleSelection:u,mode:p,instanceId:f}=q(),y=p!=="edit",[g,m]=Dh(!1),{reconnectingHandle:E,cursorPosition:T,hoveredNodeId:h,reconnectingSide:_,isValidReconnection:b,handleReconnectStart:N}=br({edgeId:e,source:t,target:o,instanceId:f,isReadOnly:y}),A=Sc(t),I=Sc(o),{sx:M,sy:H,tx:S,ty:w,sourcePos:k,targetPos:V}=Oh(()=>{var se,le;if(!A||!I)return{sx:0,sy:0,tx:0,ty:0,sourcePos:yo.Left,targetPos:yo.Right};let z=Zt(A,I),oe=a?i:z.sourcePos,B=l?s:z.targetPos,X=(ne,ue,me)=>{var Ne,Oe,dt,Yt,ye,xe;let{x:ge,y:de}=ne.internals.positionAbsolute,ae=(dt=(Oe=(Ne=ne.measured)==null?void 0:Ne.width)!=null?Oe:ne.width)!=null?dt:0,re=(xe=(ye=(Yt=ne.measured)==null?void 0:Yt.height)!=null?ye:ne.height)!=null?xe:0;switch(ue){case yo.Top:return{x:ge+ae*me,y:de};case yo.Bottom:return{x:ge+ae*me,y:de+re};case yo.Left:return{x:ge,y:de+re*me};case yo.Right:return{x:ge+ae,y:de+re*me};default:return{x:ge+ae/2,y:de+re/2}}},J=(se=n==null?void 0:n.sourceOffset)!=null?se:.5,U=(le=n==null?void 0:n.targetOffset)!=null?le:.5,K=A?X(A,oe,J).x:z.sx,$=A?X(A,oe,J).y:z.sy,Z=I?X(I,B,U).x:z.tx,j=I?X(I,B,U).y:z.ty;return E==="source"&&T?(K=T.x,$=T.y,_&&(oe=_)):E==="target"&&T&&(Z=T.x,j=T.y,_&&(B=_)),{sx:K,sy:$,tx:Z,ty:j,sourcePos:oe,targetPos:B}},[A,I,a,l,i,s,E,T,_,n==null?void 0:n.sourceOffset,n==null?void 0:n.targetOffset]);if(!A||!I)return null;let[P,L,W]=Ph({sourceX:M,sourceY:H,targetX:S,targetY:w,sourcePosition:k,targetPosition:V}),Q=r||(A==null?void 0:A.selected)||(I==null?void 0:I.selected),F=Q?"sequence-edge-marker-highlighted":"sequence-edge-marker",C=g||(n==null?void 0:n.label.trim().length)>0,D=()=>{m(!0)},O=()=>{m(!1)},G=z=>{d(e,{label:z.trim()})};return Ve(Mc,{children:xo("g",{className:R("text-grey-400 hover:text-grey-500",{"text-blue-500 hover:text-blue-600":Q}),onDoubleClick:D,children:[Ve(Sh,{id:e,path:P,markerEnd:`url(#${F})`,strokeDasharray:4,className:R("stroke-2 stroke-current transition-colors duration-75",{"stroke-red-500 hover:stroke-red-600":(n==null?void 0:n.hasError)||E&&h&&!b,"stroke-green-500":E&&h&&b,"stroke-blue-500 hover:stroke-blue-600 drop-shadow-[0_0_3px_rgba(59,130,246,0.5)]":Q&&!(n!=null&&n.hasError)&&!E})}),xo(Mh,{children:[xo("div",{className:"absolute z-[3000] pointer-events-auto flex flex-col items-center gap-1",style:{transform:`translate(-50%, -50%) translate(${L}px, ${W}px)`},children:[r&&!u&&Ve(no,{sx:M,sy:H,tx:S,ty:w,hasLabel:!!((Y=n==null?void 0:n.label)!=null&&Y.trim()),children:Ve(oo,{edgeId:e,edgeType:"MESSAGE_EDGE"})}),C&&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:O,onChange:G})]}),r&&!u&&!y&&xo(Mc,{children:[Ve("div",{className:"absolute z-[1000] pointer-events-none",style:{transform:`translate(-50%, -50%) translate(${M}px, ${H}px)`},children:xo("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:R("pointer-events-auto",{"cursor-move":!E||E!=="source","cursor-not-allowed":E==="source"&&h&&!b,"cursor-grabbing":E==="source"&&(!h||b)}),onMouseDown:z=>N("source",z.nativeEvent)})]})}),Ve("div",{className:"absolute z-[1000] pointer-events-none",style:{transform:`translate(-50%, -50%) translate(${S}px, ${w}px)`},children:xo("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:R("pointer-events-auto",{"cursor-move":!E||E!=="target","cursor-not-allowed":E==="target"&&h&&!b,"cursor-grabbing":E==="target"&&(!h||b)}),onMouseDown:z=>N("target",z.nativeEvent)})]})})]})]})]})})};import{getStraightPath as Vh,Position as Mr}from"@xyflow/react";import{jsx as Lc,jsxs as Hh}from"react/jsx-runtime";var kc=({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:Mr.Left},{x:n+s,y:r+a/2,pos:Mr.Right},{x:n+s/2,y:r,pos:Mr.Top},{x:n+s/2,y:r+a,pos:Mr.Bottom}].reduce((f,y)=>{let g=Math.hypot(e-f.x,t-f.y);return Math.hypot(e-y.x,t-y.y)<g?y:f}),[d]=Vh({sourceX:c.x,sourceY:c.y,targetX:e,targetY:t});return Hh("g",{children:[Lc("path",{fill:"none",className:"stroke-2 stroke-grey-400 animated",d}),Lc("circle",{cx:e,cy:t,fill:"none",r:4,className:"stroke-2 stroke-grey-500"})]})};import{Position as Gh,useReactFlow as Bh}from"@xyflow/react";import{orderBy as zh}from"lodash";import{useMemo as Rc,useState as Fh}from"react";import{Fragment as Wh,jsx as Gt,jsxs as Dc}from"react/jsx-runtime";var Oc=({id:e,data:t,selected:o,dragging:n,parentId:r})=>{let{updateNodeData:i,getNodes:s}=Bh(),{mode:a}=q(),[l,c]=Fh(!1),d=s(),u=!r,p=Rc(()=>zh([...d.filter(T=>T.parentId===e&&T.type==="LANE")],"position.y","asc"),[d,e]),f=u?vr.MIN_WIDTH:pe.MIN_WIDTH,y=Rc(()=>{if(u&&p.length>1){let T=[...p];return T.pop(),T.reduce((_,b)=>{var N,A;return _+((A=(N=b.measured)==null?void 0:N.height)!=null?A:0)},0)+pe.MIN_HEIGHT}return pe.MIN_HEIGHT},[u,p]),g=T=>{i(e,{label:T})},m=()=>{c(!0)},E=()=>{c(!1)};return Dc(Wh,{children:[Dc("div",{className:R("flex h-full min-h-64 w-full min-w-[50rem] hover:shadow-md bg-white outline outline-2 outline-grey-400",{"outline-offset-2 outline-blue-500 shadow-sm":o}),children:[Gt("div",{className:"flex align-items justify-center w-10 border-r-2 border-grey-400",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:R({"whitespace-nowrap":l}),isEditing:l,onBlur:E,onChange:g})})}),Gt("div",{className:"flex-1"})]}),Gt(De,{nodeId:e,nodeType:"LANE",isChild:!u}),a==="edit"&&Gt(mo,{nodeId:e,minWidth:f,minHeight:y,isVisible:!n&&o}),Gt(ie,{type:"source",position:Gh.Right})]})};var Vc={START_EVENT:Ec,END_EVENT:gc,TASK:Ac,GATEWAY:yc,ANNOTATION:fc,LANE:Oc,UNSUPPORTED:Cc},Hc={SEQUENCE_EDGE:kl,MESSAGE_EDGE:Pc,ANNOTATION_EDGE:bl},Gc="#fafafa",Bc="#bebebe",zc=1,Fc=10,Wc="bottom-left",Yc=.2,Uc=5,Eo=.5,bo=.4,_o=1,$c={x:0,y:0,zoom:.75},Yh=1,Uh=2,Xc=[Yh,Uh];import{useReactFlow as $h}from"@xyflow/react";var Ye=()=>{let{getEdges:e,getNodes:t}=$h(),{lastElementId:o}=q(),n=()=>{let i=t(),s=e(),a=tc(i,s);return Math.max(a,o)};return{getLastId:n,getNextId:()=>n()+1}};var To=()=>{let{getNodes:e,getEdges:t,setNodes:o,setEdges:n,fitView:r}=Xh(),{getLastId:i}=Ye(),{setLastElementId:s}=q(),a=Kc(async(c="")=>{let{nodes:d,edges:u,lastElementId:p}=await nc(c);o(d),n(u),s(p),r({padding:Eo,minZoom:bo,maxZoom:_o})},[o,n,s,r]),l=Kc((c,d)=>{let u=c||e()||[],p=d||t()||[],f=i();return oc(u,p,f)},[e,t,i]);return{importFromMxGraph:a,exportToMxGraph:l}};import{useCallback as qc}from"react";var qh=500,Pr=()=>{let{isInitialized:e,onElementChanges:t}=q(),{exportToMxGraph:o}=To(),n=Kh(()=>{if(!e)return;let s=o();t==null||t(s)},qh),r=qc(s=>{s.every(c=>c.type==="select")||s.some(c=>c.type==="position"&&c.dragging)||n()},[n]),i=qc(s=>{s.some(l=>l.type==="select")||n()},[n]);return{emitElementChanges:n,handleNodeChanges:r,handleEdgeChanges:i}};var Zc=({setEdges:e})=>{let{getNode:t,getEdges:o,getNodes:n,getInternalNode:r}=Jh(),{emitElementChanges:i}=Pr(),s=Qh(null),{getNextId:a}=Ye(),l=Bt(g=>{var _;let m=t(g.source),E=t(g.target);if(!m||!E)return!1;let T={sourceNodeId:m.id,targetNodeId:E.id,sourceNodeType:m.type,targetNodeType:E.type,nodes:n(),edges:o(),reconnectingEdgeId:(_=s.current)!=null?_:void 0};return _i(T).isValid},[t,o,n]),c=Bt(g=>{var T,h,_;let m=a(),E=r(g.source);if(E){let b=r(g.target),N=b?b.internals.positionAbsolute.x+((T=b.measured.width)!=null?T:0)/2:0,A=b?b.internals.positionAbsolute.y+((h=b.measured.height)!=null?h:0)/2:0,I=Rl(E,N,A),M=(_=g.sourceHandle)!=null?_:I,H=(b==null?void 0:b.type)==="ANNOTATION"||(E==null?void 0:E.type)==="ANNOTATION",S=H?ro:Be,w;if(!H&&b&&g.targetHandle){let V=Tr(M),P=Tr(g.targetHandle),{x:L,y:W}=Ii(E,M),{x:Q,y:F}=Ii(b,g.targetHandle),D=xr(L,W,Q,F,V,P).slice(1,-1);D.length>0&&(w=D)}let k=v(x(x({},g),S),{id:String(m),sourceHandle:M,data:x(x({},H?{}:Be.data),w?{points:w}:{})});e(V=>V.concat(k))}i()},[a,e,i,r]),d=Bt((g,m)=>{s.current=m.id},[]),u=Bt(()=>{s.current=null},[]),p=Bt((g,m)=>{let E=t(m.source),T=t(m.target);if(!E||!T){s.current=null;return}let h={sourceNodeId:E.id,targetNodeId:T.id,sourceNodeType:E.type,targetNodeType:T.type,nodes:n(),edges:o(),reconnectingEdgeId:g.id};if(!_i(h).isValid){s.current=null;return}e(b=>Zh(g,m,b).map(A=>A.id===g.id?v(x({},A),{data:v(x({},A.data),{points:void 0})}):A)),s.current=null,i()},[t,n,o,e,i]),f=Bt(g=>{s.current=g},[]),y=Bt(()=>{s.current=null},[]);return{isValidConnection:l,onConnect:c,onReconnect:p,onReconnectStart:d,onReconnectEnd:u,setReconnectingEdge:f,clearReconnectingEdge:y}};import{useTranslation as jh}from"@produto-lecom/lecom-ui";import{useReactFlow as ey}from"@xyflow/react";import{useCallback as un,useRef as id,useState as ty}from"react";var ln=(e=[])=>e.filter(t=>t.type==="START_EVENT"),zt=(e=[])=>e.filter(t=>t.type==="END_EVENT"),wt=(e=[])=>e.filter(t=>t.type==="TASK")||[],Jc=(e=[])=>e.filter(t=>{var o;return t.type==="TASK"&&((o=t.properties)==null?void 0:o.variant)==="SCRIPT"}),Qc=(e=[])=>e.filter(t=>{var o;return t.type==="TASK"&&((o=t.properties)==null?void 0:o.variant)==="SUBPROCESS"}),Lr=(e=[])=>e.filter(t=>t.type==="GATEWAY"),jc=(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),cn=(e,t=[])=>t.filter(o=>o.target===e),ed=(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"},td=(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},od=e=>e?/[^\s]/.test(e.trim()):!1,ce=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)}},nd=(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 dn=[{id:"start_event_not_found",validate:e=>{let t=ln(e.nodes);return ce({isValid:t.length>=1})}},{id:"end_event_not_found",validate:e=>{let t=zt(e.nodes);return ce({isValid:t.length>=1})}},{id:"multiple_start_event_not_allowed",validate:e=>{let t=ln(e.nodes),o=t.length===1;if(t.length===0)return ce({isValid:!0});if(!o)return ce({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 ce({isValid:!1,nodeIds:[...new Set(i)]})}return ce({isValid:!0})}},{id:"task_flows_limit_exceeds",validate:e=>{let t=wt(e.nodes),o=ot(t,n=>He(n.id,e.edges).length<=2);return ce({isValid:o.isValid,nodeIds:o.invalidIds})}},{id:"task_label_empty",highlightRelatedEdges:!1,validate:e=>{let t=wt(e.nodes),o=ot(t,n=>!!n.label&&n.label.trim()!=="");return ce({isValid:o.isValid,nodeIds:o.invalidIds})}},{id:"task_label_length",highlightRelatedEdges:!1,validate:e=>{let o=wt(e.nodes),n=ot(o,r=>!r.label||r.label.length<=60);return ce({isValid:n.isValid,nodeIds:n.invalidIds})}},{id:"duplicate_task_name",highlightRelatedEdges:!1,validate:e=>{let t=wt(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 ce({isValid:n.length===0,nodeIds:n})}},{id:"nested_gateway",validate:e=>{let t=Lr(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 ce({isValid:o.length===0,nodeIds:o.length>0?[...new Set(o)]:[],edgeIds:n})}},{id:"events_nested",validate:e=>{let t=[...ln(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 ce({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=cn(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 ce({isValid:o.length===0,nodeIds:o,edgeIds:n})}},{id:"conditions_flows_limit_exceeds",validate:e=>{let t=jc(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 ce({isValid:o.isValid,nodeIds:o.invalidIds,edgeIds:n})}},{id:"activity_name_invalid",validate:e=>{let t=wt(e.nodes),o=ot(t,n=>!n.label||od(n.label));return ce({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 ce({isValid:!0});let t=zt(e.nodes)[0];if(!t)return ce({isValid:!0});let o=cn(t.id,e.edges);if(!o.length)return ce({isValid:!0});let r=wt(e.nodes).filter(l=>o.some(c=>c.source===l.id)),i=ot(r,l=>!ed(l.id,e));return ce({isValid:i.isValid,nodeIds:i.isValid?[]:[t.id,...i.invalidIds]})}},{id:"concurrent_initial_and_final_event",validate:e=>{let t=wt(e.nodes),o=zt(e.nodes)[0];if(!o)return ce({isValid:!0});let n=t.filter(l=>{let c=cn(l.id,e.edges),d=He(l.id,e.edges),u=c.some(f=>{var y;return((y=e.nodes.find(g=>g.id===f.source))==null?void 0:y.type)==="START_EVENT"}),p=d.some(f=>{var y;return((y=e.nodes.find(g=>g.id===f.target))==null?void 0:y.type)==="END_EVENT"});return u&&p}),r=cn(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 ce(a)}},{id:"gateway_flow_to_event",validate:e=>{let t=Lr(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 ce({isValid:o.length===0,nodeIds:o.length>0?[...new Set(o)]:[],edgeIds:n})}},{id:"gateway_missing_output_streams",validate:e=>{let t=Lr(e.nodes),o=ot(t,n=>He(n.id,e.edges).length>=1);return ce({isValid:o.isValid,nodeIds:o.invalidIds})}},{id:"event_to_condition",validate:e=>{let t=[...ln(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 ce({isValid:o.length===0,nodeIds:o.length>0?[...new Set(o)]:[],edgeIds:n})}},{id:"script_in_final_activity",validate:e=>{let t=Jc(e.nodes),o=ot(t,n=>!td(n.id,e));return ce({isValid:o.isValid,nodeIds:o.invalidIds})}},{id:"subprocess_referenced_not_configured",validate:e=>{let t=Qc(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 ce({isValid:o.isValid,nodeIds:o.invalidIds})}}];var rd=e=>{e=e||{nodes:[],edges:[]},e.nodes=e.nodes||[],e.edges=e.edges||[];let t=[];for(let n of dn){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 kr,jsxs as oy}from"react/jsx-runtime";var sd=()=>{let{t:e}=jh(),{toast:t}=Re(),{setNodes:o,setEdges:n,getNodes:r,getEdges:i}=ey(),[s,a]=ty(!1),l=id(!1),c=id(!1),d=un(g=>{let m=nd(g.nodes,g.edges),E=rd(m),T=E.errors.map(h=>v(x({},h),{message:e(`validation.errors.${h.id}`)}));return s||a(!0),{isValid:E.isValid,errors:T}},[s,e]),u=un((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:oy("div",{className:"flex flex-col gap-1",children:[!g.isValid&&kr("span",{className:"body-small-500",children:e("validation.errors.subtitle")}),kr("ul",{className:"list-disc list-inside max-h-40 overflow-y-auto",children:g.isValid?kr("li",{children:e("validation.success.message")}):g.errors.map(S=>kr("li",{className:"text-xs",children:S.message},S.id))})]})}),!g)return;l.current=!0,c.current=!0;let E=[],T=[];g.errors.forEach(S=>{S.nodeIds&&S.nodeIds.length>0&&S.nodeIds.forEach(w=>E.push(w)),S.edgeIds&&S.edgeIds.length>0&&S.edgeIds.forEach(w=>T.push(w))});let h=[...new Set(E)];o(S=>S.map(w=>v(x({},w),{data:v(x({},w.data),{hasError:!1})}))),n(S=>S.map(w=>v(x({},w),{data:v(x({},w.data),{hasError:!1})})));let _=r(),b=i(),N=new Set(h),A=new Set;g.errors.forEach(S=>{var V,P;let w=dn.find(L=>L.id===S.id);(w==null?void 0:w.highlightRelatedEdges)!==!1&&((V=S.edgeIds)==null||V.forEach(L=>A.add(L)),(P=S.nodeIds)==null||P.forEach(L=>{b.forEach(W=>{(W.source===L||W.target===L)&&A.add(W.id)})}))});let I=new Set,M=new Set,H=new Set;_.forEach(S=>{S.type==="START_EVENT"?I.add(S.id):S.type==="END_EVENT"&&M.add(S.id)}),b.forEach(S=>{I.has(S.source)&&H.add(S.target),M.has(S.target)&&H.add(S.source)}),H.forEach(S=>{var w,k;if(N.has(S)){let V=(w=g.errors.find(L=>{var W;return(W=L.nodeIds)==null?void 0:W.includes(S)}))==null?void 0:w.id;((k=dn.find(L=>L.id===V))==null?void 0:k.highlightRelatedEdges)!==!1&&b.forEach(L=>{L.source===S&&M.has(L.target)&&(N.add(L.target),A.add(L.id)),L.target===S&&I.has(L.source)&&(N.add(L.source),A.add(L.id))})}}),N.size>0&&o(S=>S.map(w=>v(x({},w),{data:v(x({},w.data),{hasError:N.has(w.id)})}))),A.size>0&&n(S=>S.map(w=>v(x({},w),{data:v(x({},w.data),{hasError:A.has(w.id)})}))),setTimeout(()=>{l.current=!1},0)},[e,i,r,n,o]),p=un(()=>{a(!1),c.current=!1,o(g=>g.map(m=>v(x({},m),{data:v(x({},m.data),{hasError:!1})}))),n(g=>g.map(m=>v(x({},m),{data:v(x({},m.data),{hasError:!1})})))},[n,o]),f=un(()=>{c.current&&(l.current=!0,c.current=!1,o(g=>g.map(m=>v(x({},m),{data:v(x({},m.data),{hasError:!1})}))),n(g=>g.map(m=>v(x({},m),{data:v(x({},m.data),{hasError:!1})}))),setTimeout(()=>{l.current=!1},0))},[n,o]),y=un(()=>l.current,[]);return{validateDiagram:d,handleValidationComplete:u,clearValidation:p,dismissValidationPanel:f,isAutoValidationEnabled:s,getIsClearingValidation:y}};import{useReactFlow as ny}from"@xyflow/react";import{useTranslation as ry}from"@produto-lecom/lecom-ui";import{useEffect as iy}from"react";var sy=15,ad="bpmn:selection",ay=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},ld=e=>{if(!ay(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},cd=({offset:e=sy}={})=>{let{t}=ry(),{getNodes:o,setNodes:n,getEdges:r,setEdges:i}=ny(),{getNextId:s}=Ye();iy(()=>{let a=c=>{var m,E;if(!ld(c))return;let d=o(),u=r(),p=d.filter(T=>T.selected);if(!p.length)return;c.preventDefault(),c.stopPropagation();let f=u.filter(T=>p.some(h=>h.id===T.source)&&p.some(h=>h.id===T.target)),g=JSON.stringify({nodes:p,edges:f});(m=c.clipboardData)==null||m.setData(ad,g),(E=c.clipboardData)==null||E.setData("text/plain",`BPMN Selection: ${p.length} nodes`)},l=c=>{var h,_;if(!ld(c))return;let d=(h=c.clipboardData)==null?void 0:h.getData(ad);if(!d)return;c.preventDefault(),c.stopPropagation();let u;try{u=JSON.parse(d)}catch(b){return}if(!((_=u.nodes)!=null&&_.length))return;let p=new Map,f=o(),y=[],g=u.nodes.filter(b=>yt(b.type,f));if(g.length===0)return;let m=s(),E=g.map(b=>{var I;let N=String(m++);p.set(b.id,N);let A=v(x({},b),{id:N,selected:!0,position:{x:b.position.x+e,y:b.position.y+e}});if(b.type==="TASK"){let M=(I=b.data)==null?void 0:I.label,H=ho(M||t("bpmn.task.label.prefix"),[...f,...y]);A.data=v(x({},b.data),{label:H})}return y.push(A),A}),T=u.edges.map(b=>v(x({},b),{id:String(m++),selected:!0,source:p.get(b.source)||b.source,target:p.get(b.target)||b.target}));n(b=>[...b.map(N=>v(x({},N),{selected:!1})),...E]),i(b=>[...b.map(N=>v(x({},N),{selected:!1})),...T])};return document.addEventListener("copy",a,!0),document.addEventListener("paste",l,!0),()=>{document.removeEventListener("copy",a,!0),document.removeEventListener("paste",l,!0)}},[o,n,r,i,s,e,t])};import{useReactFlow as ly,useStoreApi as cy}from"@xyflow/react";import{useTranslation as dy}from"@produto-lecom/lecom-ui";import{useState as uy}from"react";var dd=({nodes:e,setNodes:t,setEdges:o})=>{let n=cy(),{draggableNode:r,setDraggableNode:i}=go(),{t:s}=dy(),{getInternalNode:a,getNodes:l,screenToFlowPosition:c}=ly(),{getNextId:d}=Ye(),{setIsDragging:u}=q(),{rebuildIndex:p,forceRebuildIndex:f}=or(),[y,g]=uy(null),m=(w,k=!1)=>{let V=k?"[&>div]:bg-red-50 [&>div]:outline [&>div]:outline-[3px] [&>div]:outline-red-500":"[&>div]:bg-green-50/75 [&>div]:outline [&>div]:outline-[3px] [&>div]:outline-green-500";t(P=>P.map(L=>v(x({},L),{className:L.id===w?V:""})))},E=()=>{let{nodeLookup:w}=n.getState();return Array.from(w.values())},T=w=>{let k=a(w.id),V=E();if(w.type==="LANE"){if(fo({parentId:w.id,nodes:e,includeTypes:["LANE"]})){m();return}let C=V.filter(G=>G.id!==w.id&&G.type==="LANE"&&!G.parentId),D=jo(k,C);if(!D){m();return}if(fo({parentId:D.id,nodes:e,excludeTypes:["LANE"]})){m(D.id,!0);return}m(D.id);return}let L=V.filter(F=>F.id!==w.id&&F.type==="LANE"),W=jo(k,L);if(!W){m();return}if(fo({parentId:W.id,nodes:e,includeTypes:["LANE"]})){m();return}m(W.id)},h=w=>w.map(k=>v(x({},k),{className:void 0})),_=w=>w.some(V=>V.dragging)?w.map(V=>V.dragging?v(x({},V),{dragging:!1}):V):w,b=w=>{w.preventDefault(),w.dataTransfer.dropEffect="move"},N=(w,k)=>{w.preventDefault(),T(k)},A=(w,k,V)=>{var F,C;let P=[...V];if(w.parentId===k.id)return P=Jl(w,k,P),P=en(P),h(P);if(w.type==="LANE"){if(fo({parentId:k.id,nodes:P,excludeTypes:["LANE"]})){let z=st(k),oe=50,B=50;return P.map(X=>{var J,U;return X.id===w.id?v(x({},X),{position:{x:(J=y==null?void 0:y.x)!=null?J:z.x+oe,y:(U=y==null?void 0:y.y)!=null?U:z.y2+B}}):X})}let G=P.filter(z=>z.parentId===k.id).reduce((z,oe)=>{var B,X;return z+((X=(B=oe.measured)==null?void 0:B.height)!=null?X:0)},0),Y={x:pe.HEADER_WIDTH,y:G};return P=P.map(z=>z.id===w.id?v(x({},z),{parentId:k.id,position:Y,className:void 0}):v(x({},z),{className:void 0})),P=tn(k.id,P),P}if(fo({parentId:k.id,nodes:P,includeTypes:["LANE"]})){let D;if(w.parentId){let O=a(w.parentId),{x:G,y:Y}=lt(O);D={x:G+((F=w.position.x)!=null?F:0),y:Y+((C=w.position.y)!=null?C:0)}}return P=P.map(O=>O.id===w.id?v(x({},O),{position:D!=null?D:O.position,parentId:void 0,className:void 0}):v(x({},O),{className:void 0})),P}let Q=Xl(w,k);return P=P.map(D=>{if(D.id===w.id){let O=st(w),G=st(k);return O.y<G.y&&(Q.y=0),O.x<G.x+pe.HEADER_WIDTH&&(Q.x=pe.HEADER_WIDTH),v(x({},D),{parentId:k.id,position:Q,className:void 0})}return v(x({},D),{className:void 0})}),P=en(P),P},I=w=>{if(w.preventDefault(),!(r!=null&&r.type))return;if(!yt(r.type,l())){u(!1),i(null);return}let k=c({x:w.clientX,y:w.clientY}),V={width:te[r.type].MIN_WIDTH,height:te[r.type].MIN_HEIGHT},P=d(),L={id:String(P),type:r.type,position:k,measured:V,data:{label:r.type==="TASK"?Ar(e,s("bpmn.task.label.prefix")):"",variant:r.variant,attribute:r.attribute},selected:!0},W=v(x({},L),{internals:{positionAbsolute:k}}),Q=E(),F=r.type==="LANE",C=Q.filter(Y=>F?Y.type==="LANE"&&!Y.parentId:Y.type==="LANE"),D=jo(W,C),O=[...e.map(Y=>v(x({},Y),{selected:!1})),L];D&&(O=A(W,D,O)),O=Ot(O),t(O),f();let G=w.dataTransfer.getData("sourceId");if(G){let Y={id:String(P+1),source:G,target:L.id};r.type==="ANNOTATION"?o(z=>z.concat(x(x({},Y),ro))):o(z=>z.concat(x(x({},Y),Be)))}u(!1),i(null)},M=async(w,k,V)=>{let P=[...e];V.forEach(L=>{let W=E(),Q=a(L.id),F=L.type==="LANE",C=W.filter(O=>O.id!==L.id&&(F?O.type==="LANE"&&!O.parentId:O.type==="LANE")),D=jo(Q,C);if(D){P=A(Q,D,P);return}L.parentId&&(P=S(L,P))}),P=_(P),P=Ot(P),P=h(P),t(P),p(P),g(null)},H=(w,k)=>{g({x:k.position.x,y:k.position.y})},S=(w,k)=>{var Q,F;let V=a(w.parentId),{x:P,y:L}=lt(V),W={x:P+((Q=w.position.x)!=null?Q:0),y:L+((F=w.position.y)!=null?F:0)};return k=k.map(C=>C.id===w.id?v(x({},C),{position:W,parentId:void 0}):C),k=tn(w.parentId,k),k};return{onDragOver:b,onDrop:I,onNodeDrag:N,onNodeDragStart:H,onNodeDragStop:M}};import{useReactFlow as py}from"@xyflow/react";import{useTranslation as fy}from"@produto-lecom/lecom-ui";import{useEffect as my}from"react";var gy=30,hy=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},yy=e=>!hy(e.target),ud=({offset:e=gy}={})=>{let{t}=fy(),{getNodes:o,setNodes:n,getEdges:r,setEdges:i}=py(),{getNextId:s}=Ye();my(()=>{let a=l=>{if(l.ctrlKey&&l.key.toLowerCase()==="d"&&yy(l)){l.preventDefault(),l.stopPropagation();let c=o(),d=r(),u=c.filter(h=>h.selected);if(!u.length)return;let p=new Map,f=[],y=u.filter(h=>yt(h.type,c));if(y.length===0)return;let g=d.filter(h=>y.some(_=>_.id===h.source)&&y.some(_=>_.id===h.target)),m=s(),E=y.map(h=>{var N;let _=String(m++);p.set(h.id,_);let b=v(x({},h),{id:_,selected:!0,position:{x:h.position.x+e,y:h.position.y+e}});if(h.type==="TASK"){let A=(N=h.data)==null?void 0:N.label,I=ho(A||t("bpmn.task.label.prefix"),[...c,...f]);b.data=v(x({},h.data),{label:I})}return f.push(b),b}),T=g.map(h=>v(x({},h),{id:String(m++),selected:!0,source:p.get(h.source)||h.source,target:p.get(h.target)||h.target}));n(h=>[...h.map(_=>v(x({},_),{selected:!1})),...E]),i(h=>[...h.map(_=>v(x({},_),{selected:!1})),...T])}};return document.addEventListener("keydown",a,!0),()=>{document.removeEventListener("keydown",a,!0)}},[o,n,r,i,s,e,t])};import{useEffect as xy,useRef as pd}from"react";import{useReactFlow as Ey}from"@xyflow/react";var by=20,_y=50,pn={UP:"ArrowUp",DOWN:"ArrowDown",LEFT:"ArrowLeft",RIGHT:"ArrowRight"},Ty=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=>{let{getNodes:t}=Ey(),{mode:o,isMoveTool:n}=q(),r=pd(0),i=pd(new Map);xy(()=>{let s=a=>{if(o!=="edit"||!n||Ty(a.target)||!Object.values(pn).includes(a.key))return;let u=t().filter(T=>T.selected);if(u.length===0){i.current.clear();return}a.preventDefault();let p=Date.now(),f=p-r.current<500;r.current=p;let y=a.shiftKey?_y:by,g=0,m=0;switch(a.key){case pn.UP:m=-y;break;case pn.DOWN:m=y;break;case pn.LEFT:g=-y;break;case pn.RIGHT:g=y;break}let E=u.map(T=>{let h=i.current.get(T.id);(!f||!h)&&(h={x:T.position.x,y:T.position.y});let _={x:h.x+g,y:h.y+m};return i.current.set(T.id,_),{id:T.id,dragging:!0,type:"position",position:_}});e&&e(E)};return window.addEventListener("keydown",s),()=>{window.removeEventListener("keydown",s)}},[t,e,o,n])};import{useReactFlow as vy}from"@xyflow/react";var gd={"start-event":"START_EVENT","end-event":"END_EVENT",task:"TASK","gateway-exclusive":"GATEWAY"},hd={"start-event":"","end-event":"",task:"","gateway-exclusive":"EXCLUSIVE"},md=(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}},Ny=e=>{e=e||"";let t=e.trim().split(`
|
|
40
|
-
`),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=md(i[0],o),a=md(i[1],o);s&&a&&n.push({sourceId:s.step,targetId:a.step,label:s.edgeLabel||a.edgeLabel||""})}),{components:o,connections:n}},yd=e=>{let{components:t,connections:o}=Ny(e);return{nodes:t,edges:o}};var xd=()=>{let{setNodes:e,setEdges:t,fitView:o}=vy(),{getNextId:n}=Ye();return{importFromLia:i=>{let s=typeof i=="string"?i:i.diagramXml||"",{nodes:a,edges:l}=yd(s),c=[],d=new Map,u=!1,p=n();for(let[m,E]of Object.entries(a)){let T=String(p++),h=gd[E.type],_=hd[E.type];h==="START_EVENT"&&(u=!0),d.set(m,T);let b=te[h].MIN_WIDTH,N=te[h].MIN_HEIGHT;c.push({id:T,type:h,data:{label:E.label||"",variant:_,attribute:""},position:{x:0,y:0},width:b,height:N,measured:{width:b,height:N}})}let f=[];for(let m of l){let E=v(x({},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:te.START_EVENT.MIN_WIDTH,height:te.START_EVENT.MIN_HEIGHT,measured:{width:te.START_EVENT.MIN_WIDTH,height:te.START_EVENT.MIN_HEIGHT}};c.unshift(E);let T=c[1];if(T){let h=v(x({},Be),{id:String(p++),source:m,target:T.id});f.unshift(h)}}let{nodes:y,edges:g}=Zl(c,f);e(y),t(g),o({padding:Eo,minZoom:bo,maxZoom:_o})}}};import{useEffect as wy,useCallback as Ay}from"react";var Iy={origin:"*",debug:!1};function Ed(e,t=Iy){let{origin:o,debug:n}=t,r=Ay((i,s)=>{let a={event:i,data:[i,{event:i,data:s}]};window.parent.postMessage(a,o||"*")},[o]);return wy(()=>{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 Cy}from"@xyflow/react";import{useEffect as bd}from"react";var _d=()=>{let e=Cy(),{initialDiagram:t,setIsInitialized:o}=q(),{importFromMxGraph:n}=To();bd(()=>{t&&n(t)},[t,n,o]),bd(()=>{if(!e)return;(async()=>{await En(),o(!0)})()},[e,o])};import{useCallback as Td}from"react";import{useReactFlow as Sy}from"@xyflow/react";function Nd(){let{setTaskStatuses:e,clearTaskStatuses:t,calculateFlowPath:o}=St(),{getEdges:n}=Sy(),r=wn(),i=Td(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=Td(()=>{t(),setTimeout(()=>{r()},0)},[t,r]);return{handleTasksStatus:i,handleClearTaskStatus:s}}import{useReactFlow as My}from"@xyflow/react";import{useCallback as At,useState as Py,useEffect as vd}from"react";import{useDebouncedCallback as Ly}from"use-debounce";var ky=500,wd=100,Ad=(e=!1)=>{let{getNodes:t,getEdges:o,setNodes:n,setEdges:r}=My(),[i,s]=Py({history:[],currentStep:0}),{history:a,currentStep:l}=i,c=a[l],d=l>0,u=l<a.length-1,p=At((b,N)=>{n(b[N].nodes),r(b[N].edges)},[n,r]),f=At(()=>{if(l>0){let b=l-1;s(N=>v(x({},N),{currentStep:b})),p(a,b)}},[l,a,p]),y=At(()=>{if(l<a.length-1){let b=l+1;s(N=>v(x({},N),{currentStep:b})),p(a,b)}},[a,l,p]),g=At(b=>{s(N=>{let I=[...N.history.slice(0,N.currentStep+1),b],M=I.length>wd?I.slice(I.length-wd):I;return{history:M,currentStep:M.length-1}})},[]),m=At(()=>{let b=t(),N=o(),A=b.map(M=>v(x({},M),{selected:!1,className:"",data:v(x({},M.data),{hasError:!1})})),I=N.map(M=>v(x({},M),{data:v(x({},M.data),{hasError:!1})}));return{nodes:Ot(A),edges:I}},[t,o]),E=Ly(()=>{let b=m();JSON.stringify(c)!==JSON.stringify(b)&&g(b)},ky),T=At(b=>{if(!e)return;if(a.length===0){let I=m();s({history:[I],currentStep:0})}if(b==="forceSave"){E();return}b.some(I=>I.type==="select")||b.some(I=>I.type==="position"&&I.dragging)||E()},[e,E,a.length,m]);vd(()=>{if(e&&a.length===0){let b=m();s({history:[b],currentStep:0})}},[e,a.length,m]);let h=At(b=>{s({history:b||[],currentStep:0})},[]),_=At(()=>{s({history:[],currentStep:0})},[]);return vd(()=>{let b=N=>{(N.ctrlKey||N.metaKey)&&(N.shiftKey&&N.key.toLowerCase()==="z"?(N.preventDefault(),y()):N.key.toLowerCase()==="z"&&(N.preventDefault(),f()))};return document.addEventListener("keydown",b),()=>{document.removeEventListener("keydown",b)}},[f,y]),{history:a,undo:f,redo:y,canUndo:d,canRedo:u,saveHistory:T,resetHistory:h,clearHistory:_}};var Id=()=>{let{t:e}=Ry(),[t,o,n]=Oy([]),[r,i,s]=Dy([]),{getNode:a}=Hy(),{toast:l}=Re(),c=Gy(),{instanceId:d,isInitialized:u,setIsConnecting:p,setIsMultipleSelection:f,onElementClick:y}=q(),{updateHelperLines:g,HelperLines:m}=or(),{undo:E,redo:T,canUndo:h,canRedo:_,saveHistory:b}=Ad(u),{onNodeDrag:N,onDrop:A,onDragOver:I,onNodeDragStop:M,onNodeDragStart:H}=dd({nodes:t,setNodes:o,setEdges:i}),{isValidConnection:S,onConnect:w,onReconnect:k,onReconnectStart:V,onReconnectEnd:P,setReconnectingEdge:L,clearReconnectingEdge:W}=Zc({setEdges:i}),{handleValidationComplete:Q,clearValidation:F,dismissValidationPanel:C,validateDiagram:D,getIsClearingValidation:O}=sd(),{importFromLia:G}=xd(),{handleTasksStatus:Y,handleClearTaskStatus:z}=Nd(),{clearPathEdges:oe}=St(),{emitElementChanges:B,handleNodeChanges:X,handleEdgeChanges:J}=Pr(),U=wn();cd(),ud(),_d();let K=It(()=>{o([]),i([]),oe(),setTimeout(U,0)},[o,i,oe,U]);Ed({LIA_CREATE_DIAGRAM:G,CLEAR_DIAGRAM:K,TASKS_STATUS:Y,CLEAR_TASKS_STATUS:z});let{selectElements:$,clearSelection:Z}=xt(),{importFromMxGraph:j,exportToMxGraph:se}=To(),{configureElement:le,getConfigureElement:ne}=dr(),ue=It(()=>t.length+r.length,[t,r]);By(()=>(tt.set(d,{importFromMxGraph:j,exportToMxGraph:se,selectElements:$,clearSelection:Z,configureElement:le,getConfigureElement:ne,getElementsCount:ue,setReconnectingEdge:L,clearReconnectingEdge:W}),()=>{tt.delete(d)}),[d,j,se,$,Z,le,ne,ue,L,W]);let me=It((ye,xe)=>{if(xe.type!=="TASK"&&xe.type!=="GATEWAY")return;let Ze=ne(xe.id);Ze&&(y==null||y(Ze))},[ne,y]),ge=It((ye,xe)=>{if(xe.type!=="SEQUENCE_EDGE")return;let Ze=a(xe.source),Ut=a(xe.target),{isFromStartEvent:lu,isGatewayToGateway:cu,isActiviyToAndGateway:du}=vn(Ze,Ut);if(!(!lu&&!cu&&!du))return;let Xi=ne(xe.id);Xi&&(y==null||y(Xi))},[ne,a,y]),de=It(ye=>{let xe=g(ye,t);n(xe),b(ye),O()||C(),X(ye)},[t,n,b,O,C,g,X]),ae=It(ye=>{s(ye),b(ye),O()||C(),J(ye)},[s,b,O,C,J]);fd(de);let re=It(({nodes:ye,edges:xe})=>{f(ye.length+xe.length>=2)},[f]);Vy({onChange:re});let Ne=It(async({nodes:ye})=>ye.some(Ze=>Ze.type==="LANE"&&t.some(Ut=>Ut.parentId===Ze.id))?(l({variant:"error",title:e("validation.errors.title"),content:e("editor.toolbar.delete_pool_lane_error")}),!1):!0,[t,e]);return{nodes:t,setNodes:o,edges:r,setEdges:i,events:{isValidConnection:S,onConnect:w,onReconnect:k,onReconnectStart:V,onReconnectEnd:P,onDrop:A,onDragOver:I,onNodeDrag:N,onNodeDragStop:M,onNodeDragStart:H,onNodeClick:me,onEdgeClick:ge,onDropCapture:()=>{b("forceSave"),B(),C()},onConnectStart:()=>{p(!0)},onConnectEnd:()=>{p(!1),C()},onSelectionEnd:()=>c.setState({nodesSelectionActive:!1}),onNodesChange:de,onEdgesChange:ae,onBeforeDelete:Ne},ui:{handleCloseValidationPanel:F},controls:{undo:E,redo:T,canUndo:h,canRedo:_},components:{HelperLines:m},actions:{saveHistory:b,selectElements:$,clearSelection:Z,exportToMxGraph:se,validateDiagram:D,handleValidationComplete:Q,setReconnectingEdge:L,clearReconnectingEdge:W}}};import{jsx as Cd}from"react/jsx-runtime";var Vi=({id:e,className:t})=>Cd("marker",{id:e,className:R("react-flow__arrowhead",t),viewBox:"0 0 10 10",refX:"9",refY:"5",markerWidth:"7",markerHeight:"7",orient:"auto",markerUnits:"userSpaceOnUse",fill:"currentColor",stroke:"currentColor",children:Cd("path",{d:"M 0 0 L 10 5 L 0 10 Z"})});import{jsx as Hi,jsxs as zy}from"react/jsx-runtime";var Sd=()=>Hi("svg",{style:{position:"absolute",top:0,left:0},children:zy("defs",{children:[Hi(Vi,{id:"sequence-edge-marker",className:"text-grey-400"}),Hi(Vi,{id:"sequence-edge-marker-highlighted",className:"text-blue-500"})]})});import{Tooltip as ix,TooltipContent as sx,TooltipTrigger as ax,useTranslation as lx}from"@produto-lecom/lecom-ui";import{useKeyPress as Xd,useReactFlow as C0}from"@xyflow/react";import{Button as Gr,Tooltip as Br,TooltipContent as zr,TooltipTrigger as Fr,useTranslation as S0}from"@produto-lecom/lecom-ui";import{HandIcon as M0,ListCheckIcon as P0,MapIcon as L0,MousePointerIcon as k0}from"lucide-react";import{useCallback as Fi,useEffect as Kd}from"react";import{Tooltip as a0,TooltipContent as l0,TooltipTrigger as c0,useTranslation as d0}from"@produto-lecom/lecom-ui";var fn=(h=>(h.START_EVENT="START_EVENT",h.END_EVENT="END_EVENT",h.TASK="TASK",h.SUBPROCESS="SUBPROCESS",h.GATEWAY="GATEWAY",h.LANE="LANE",h.ANNOTATION="ANNOTATION",h.CONNECTION="CONNECTION",h.INTERMEDIATE_EVENT="INTERMEDIATE_EVENT",h.ACTIVITY="ACTIVITY",h.PROCESS_INTERFACE="PROCESS_INTERFACE",h.WORKFLOW_INTERFACE="WORKFLOW_INTERFACE",h.VARIANT_ACTIVITY="VARIANT_ACTIVITY",h.AUTO_ACTIVITY="AUTO_ACTIVITY",h.DATA_STORE="DATA_STORE",h.DATA_OBJECT="DATA_OBJECT",h.DATA_OUTPUT="DATA_OUTPUT",h.DATA_INPUT="DATA_INPUT",h.MARKER="MARKER",h))(fn||{});import{Button as jy,useTranslation as e0}from"@produto-lecom/lecom-ui";import{useReactFlow as t0}from"@xyflow/react";var Md=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 Pd({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(`
|
|
41
|
-
`),
|
|
39
|
+
</mxGraphModel>`,sc=(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 Mg=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=Ul[s],l=a==null?void 0:a(i,n);if(!l){console.warn(`Node ${s} not supported`);continue}r.push(l)}return r},Pg=(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=$l(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},Lg=(e,t)=>{let o=[];return e.forEach(n=>{var s,a;let r=(a=(s=Kl)[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=ql(n,t);o.push(l)}}),o},kg=(e,t)=>{let o=[];return e.forEach(n=>{let r=Xl(n,t);o.push(r)}),o},ac=(e=[],t=[],o)=>{let n=Lg(e,o),r=kg(t,e),i={mxGraphModel:{root:{_attributes:{version:"1.1",lastId:o},mxCell:[{_attributes:{id:"0"}},{_attributes:{id:"1",parent:"0"}},...n,...r]}}};return Gl(JSON.stringify(i),{compact:!0,spaces:0})},lc=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=Mg(o),i=Pg(o,r),s=tn(r),{nodes:a,edges:l}=Ql(s,i);return{lastElementId:n,edges:l,nodes:Ot(a)}};import{Position as yc,useConnection as ph,useReactFlow as fh}from"@xyflow/react";import{useCallback as Ri}from"react";import{Handle as cc,useReactFlow as Rg}from"@xyflow/react";import{jsx as dc}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 dc(cc,x({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}=Rg(),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 b=h.find(T=>T.id===m.target);return(b==null?void 0:b.type)!=="ANNOTATION"}).length>=1}return!1})();return dc(cc,x({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 Dg,useReactFlow as Og}from"@xyflow/react";import{orderBy as Vg}from"lodash";import{jsx as Hg}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}=Og(),{isMultipleSelection:l}=K(),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,b=h.filter(E=>E.type==="LANE"&&E.parentId===m);if(!b.length)return;let T=Vg(b,["position.y"]),y=0;T.forEach((E,_)=>{var A,P;let N=_===T.length-1,w=(P=(A=E.measured)==null?void 0:A.height)!=null?P:0;h=h.map(B=>{if(B.id===E.id){let S=g?u-pe.HEADER_WIDTH:u,D=v(x({},B),{width:S,measured:v(x({},B.measured),{width:S}),position:v(x({},B.position),{y})});return N&&g&&(D.height=p-y),D}return B}),y+=w}),h=h.map(E=>{if(E.id===m){let _=g?u:u+pe.HEADER_WIDTH;return v(x({},E),{width:_,height:g?p:y,measured:{width:_,height:g?p:y}})}return E}),a(h)};return Hg(Dg,x({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 oh,useReactFlow as nh}from"@xyflow/react";import{Button as rh,Tooltip as ih,TooltipContent as sh,TooltipTrigger as ah,useTranslation as lh}from"@produto-lecom/lecom-ui";import{useCallback as ch,useRef as gc,useState as dh}from"react";import{create as Gg}from"zustand";var ho=Gg(e=>({draggableNode:null,setDraggableNode:t=>{e({draggableNode:t})}}));import{useEffect as Bg,useState as zg}from"react";var uc=(e,t=!1)=>{let[o,n]=zg({width:0,height:0});return Bg(()=>{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 Fg}from"@xyflow/react";import{useMemo as Wg}from"react";var Yg=120,Ug=12,pc=(e,t=!1,o)=>{let{getNode:n,getViewport:r}=Fg(),{instanceId:i}=K();return Wg(()=>{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)||Yg;return{position:l+c+u+Ug>d?rn.Left:rn.Right}},[i,e,t,o,n,r])};import{useNodesData as $g,useReactFlow as Xg}from"@xyflow/react";import{Button as fc,DropdownMenu as Kg,DropdownMenuContent as qg,DropdownMenuGroup as Zg,DropdownMenuItem as Jg,DropdownMenuLabel as Qg,DropdownMenuTrigger as jg,Tooltip as Pi,TooltipContent as Li,TooltipTrigger as ki,useTranslation as eh}from"@produto-lecom/lecom-ui";import{WrenchIcon as th}from"lucide-react";import{jsx as Ie,jsxs as Vt}from"react/jsx-runtime";var mc=({nodeId:e})=>{let{t}=eh(),{updateNodeData:o,getEdges:n,getNode:r}=Xg(),i=$g(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(Kg,{children:[Vt(Pi,{children:[Ie(ki,{asChild:!0,children:Ie(jg,{asChild:!0,children:Ie(fc,{variant:"ghost",color:"grey",size:"small",iconButton:!0,children:Ie(th,{})})})}),Ie(Li,{color:"black",children:t("bpmn.task.menu.title")})]}),Vt(qg,{align:"start",className:"w-60 bg-white text-grey-600",children:[Vt(Qg,{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(Pi,{children:[Ie(ki,{asChild:!0,children:Ie(fc,{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(Li,{color:"black",children:g})]},u)})})]}),Ie(Zg,{children:Vt(Pi,{children:[Ie(ki,{asChild:!0,children:Ie("div",{className:O({"cursor-not-allowed":a}),children:Vt(Jg,{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(Li,{color:"black",children:t("editor.task_menu.script_not_allowed_when_connected_to_end")})]})})]})]})};import{jsx as he,jsxs as hc}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"}},uh={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=gc(null),r=gc(null),{t:i}=lh(),{setDraggableNode:s}=ho(),{getEdges:a,getNodes:l,getNode:c}=nh(),{setIsDragging:d,mode:u,isConnecting:p,isDragging:f,isMultipleSelection:h}=K(),g=c(e),m=!!(g!=null&&g.selected)&&!g.dragging&&!p&&!f&&!h,{dimensions:b}=uc(n,m),{position:T}=pc(e,m,b),[y,E]=dh(void 0),_=l(),N=a(),w=o==="SUBPROCESS",A=ch((z,C)=>{d(!1),s({type:C.type,variant:C.variant,attribute:C.attribute,icon:C.icon}),C.icon&&E(he(C.icon,{})),z.dataTransfer.effectAllowed="move",z.dataTransfer.setData("sourceId",e),r.current&&z.dataTransfer.setDragImage(r.current,10,10),setTimeout(()=>{d(!0)},100)},[e,s,d]),P=[{component:he(mr,{elementId:e})}],B=()=>{if(u==="view")return[];let z=!N.some(C=>{var H;return C.source===e&&((H=_.find(F=>F.id===C.target))==null?void 0:H.type)!=="ANNOTATION"});return[{component:he(Dt,{nodeId:e,disabled:!z,tooltipMessage:z?void 0:i("editor.toolbar.start_event_limit_reached")})},Ht.TASK,Ht.ANNOTATION,...P]},S=()=>u==="view"?[{component:he(Et,{elementId:e})}]:[{component:he(Et,{elementId:e})},...w?[]:[{component:he(mc,{nodeId:e})}],{component:he(Dt,{nodeId:e})},Ht.TASK,...Object.values(uh),...P],D=()=>u==="view"?[{component:he(Et,{elementId:e})}]:[{component:he(Et,{elementId:e})},{component:he(Dt,{nodeId:e})},Ht.TASK,Ht.ANNOTATION,...P],Q=()=>u==="view"?[]:[{component:he(Dt,{nodeId:e})},Ht.ANNOTATION,...P],I=()=>u==="view"?[]:[{component:he(Dt,{nodeId:e})},Ht.ANNOTATION,...P],R=()=>u==="view"?[]:[{component:he(Dt,{nodeId:e})},...P],L=()=>u==="view"?[]:[...P],q=(z=>{switch(z){case"START_EVENT":return B();case"TASK":return S();case"GATEWAY":return D();case"END_EVENT":return Q();case"LANE":return I();case"ANNOTATION":return R();case"UNSUPPORTED":return L();default:return[]}})(t);if(!(q.length===0||u==="readonly"))return hc(oh,{position:T,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:q.map((z,C)=>{if(z.component)return he("div",{children:z.component},C);let H={sourceNodeType:t,targetNodeType:z.type,sourceNodeId:e,nodes:_,edges:N},F=bl(H),V={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")},G=F.shouldDisable&&F.reason?V[F.reason]||i(z.label):i(z.label)||"";return hc(ih,{children:[he(ah,{asChild:!0,children:he(rh,{variant:"ghost",color:"grey",size:"small",iconButton:!0,draggable:!F.shouldDisable,disabled:F.shouldDisable,className:F.shouldDisable?"opacity-50 cursor-not-allowed":"",onDragStart:F.shouldDisable?void 0:W=>A(W,z),children:z.icon&&he(z.icon,{size:16})})}),he(sh,{color:"black",children:G})]},C)})}),he("div",{ref:r,className:"absolute w-0 h-0 top-0 left-0 z-[-1] bg-transparent",children:y})]})};import{jsx as sn,jsxs as mh}from"react/jsx-runtime";var xc=({id:e,data:t,selected:o,dragging:n})=>{let{updateNodeData:r,setNodes:i}=fh(),{inProgress:s,fromNode:a}=ph(),{mode:l}=K(),c=s&&(a==null?void 0:a.id)!==e,d=Ri(f=>{let T=f.split(`
|
|
40
|
+
`),y=T.reduce((w,A)=>Math.max(w,A.length),0),E=T.length,_=Math.max(co.MIN_WIDTH,y*7+32),N=Math.max(co.MIN_HEIGHT,E*20+24);i(w=>w.map(A=>A.id===e?v(x({},A),{width:_,height:N,style:v(x({},A.style),{width:_,height:N})}):A))},[e,i]),u=Ri(f=>{r(e,{label:f}),d(f)},[e,r,d]),p=Ri(f=>{d(f)},[d]);return mh("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:yc.Right}),(!s||c)&&sn(re,{type:"target",position:yc.Left,className:O({"annotation-handle":c})})]})};import{Position as _t,useConnection as gh,useReactFlow as hh}from"@xyflow/react";import{useState as yh}from"react";import{Fragment as Ec,jsx as ze,jsxs as Di}from"react/jsx-runtime";var bc=({id:e,data:t,selected:o})=>{let{updateNodeData:n}=hh(),{inProgress:r,fromNode:i}=gh(),{reconnectingEdgeId:s}=K(),[a,l]=yh(!1),c=r&&(i==null?void 0:i.id)!==e||!!s,d=f=>{n(e,{label:f})},u=()=>{l(!0)},p=()=>{l(!1)};return Di("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)&&Di(Ec,{children:[ze(re,{type:"target",position:_t.Left,id:"left",className:O({"event-handle":c})}),ze(re,{type:"target",position:_t.Right,id:"right",className:O({"event-handle":c})}),ze(re,{type:"target",position:_t.Top,id:"top",className:O({"event-handle":c})}),ze(re,{type:"target",position:_t.Bottom,id:"bottom",className:O({"event-handle":c})})]}),!r&&Di(Ec,{children:[ze(re,{type:"source",position:_t.Left,id:"left"}),ze(re,{type:"source",position:_t.Right,id:"right"}),ze(re,{type:"source",position:_t.Top,id:"top"}),ze(re,{type:"source",position:_t.Bottom,id:"bottom"})]})]})};import{Position as Tt,useConnection as xh,useReactFlow as Eh}from"@xyflow/react";import{useCallback as bh,useState as _h}from"react";import{Fragment as _c,jsx as Fe,jsxs as Oi}from"react/jsx-runtime";var Tc=({id:e,data:t,selected:o})=>{let n=ri[t.variant].icon,{updateNodeData:r}=Eh(),{inProgress:i,fromNode:s}=xh(),{reconnectingEdgeId:a}=K(),[l,c]=_h(!1),d=i&&(s==null?void 0:s.id)!==e||!!a,u=bh(h=>{r(e,{label:h})},[e,r]),p=()=>{c(!0)},f=()=>{c(!1)};return Oi("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)&&Oi(_c,{children:[Fe(re,{type:"target",position:Tt.Left,id:"left",className:O({"gateway-handle":d})}),Fe(re,{type:"target",position:Tt.Right,id:"right",className:O({"gateway-handle":d})}),Fe(re,{type:"target",position:Tt.Top,id:"top",className:O({"gateway-handle":d})}),Fe(re,{type:"target",position:Tt.Bottom,id:"bottom",className:O({"gateway-handle":d})})]}),!i&&Oi(_c,{children:[Fe(Me,{type:"source",position:Tt.Left,id:"left",nodeId:e,nodeType:"GATEWAY",gatewayVariant:t.variant}),Fe(Me,{type:"source",position:Tt.Right,id:"right",nodeId:e,nodeType:"GATEWAY",gatewayVariant:t.variant}),Fe(Me,{type:"source",position:Tt.Top,id:"top",nodeId:e,nodeType:"GATEWAY",gatewayVariant:t.variant}),Fe(Me,{type:"source",position:Tt.Bottom,id:"bottom",nodeId:e,nodeType:"GATEWAY",gatewayVariant:t.variant})]})]})};import{useNodesData as MC,useReactFlow as PC}from"@xyflow/react";import{Button as kC,DropdownMenu as RC,DropdownMenuContent as DC,DropdownMenuGroup as OC,DropdownMenuItem as VC,DropdownMenuLabel as HC,DropdownMenuTrigger as GC,Tooltip as BC,TooltipContent as zC,TooltipTrigger as FC,useTranslation as WC}from"@produto-lecom/lecom-ui";import{WrenchIcon as UC}from"lucide-react";import{jsx as qC,jsxs as ZC}from"react/jsx-runtime";import{Position as Nt,useConnection as Th,useReactFlow as Nh}from"@xyflow/react";import{useState as vh}from"react";import{Fragment as Nc,jsx as We,jsxs as Vi}from"react/jsx-runtime";var vc=({id:e,data:t,selected:o})=>{let{updateNodeData:n}=Nh(),{inProgress:r,fromNode:i}=Th(),{reconnectingEdgeId:s}=K(),[a,l]=vh(!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:[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)&&Vi(Nc,{children:[We(re,{type:"target",position:Nt.Left,id:"left",className:O({"event-handle":c})}),We(re,{type:"target",position:Nt.Right,id:"right",className:O({"event-handle":c})}),We(re,{type:"target",position:Nt.Top,id:"top",className:O({"event-handle":c})}),We(re,{type:"target",position:Nt.Bottom,id:"bottom",className:O({"event-handle":c})})]}),!r&&Vi(Nc,{children:[We(Me,{type:"source",position:Nt.Left,id:"left",nodeId:e,nodeType:"START_EVENT"}),We(Me,{type:"source",position:Nt.Right,id:"right",nodeId:e,nodeType:"START_EVENT"}),We(Me,{type:"source",position:Nt.Top,id:"top",nodeId:e,nodeType:"START_EVENT"}),We(Me,{type:"source",position:Nt.Bottom,id:"bottom",nodeId:e,nodeType:"START_EVENT"})]})]})};import{useTranslation as Ih}from"@produto-lecom/lecom-ui";import{Position as vt,useConnection as Ch,useReactFlow as Sh}from"@xyflow/react";import{useCallback as Ir}from"react";var an=60,Ar=(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 wc,jsxs as wh}from"react/jsx-runtime";var Ac=e=>wh("svg",v(x({width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",xmlns:"http://www.w3.org/2000/svg"},e),{children:[wc("circle",{cx:"12",cy:"12",r:"10",fill:"#10B981"}),wc("path",{d:"M7 12L10 15L17 8",stroke:"white",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"})]}));import{jsx as Ic}from"react/jsx-runtime";var Cc=e=>Ic("svg",v(x({width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",xmlns:"http://www.w3.org/2000/svg"},e),{children:Ic("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 Sc,jsxs as Ah}from"react/jsx-runtime";var Mc=e=>Ah("svg",v(x({width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",xmlns:"http://www.w3.org/2000/svg"},e),{children:[Sc("circle",{cx:"12",cy:"12",r:"10",fill:"#EF4444"}),Sc("path",{d:"M8 8L16 16M8 16L16 8",stroke:"white",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"})]}));import{Fragment as Cr,jsx as me,jsxs as ln}from"react/jsx-runtime";var Mh={APROVADO:Ac,EM_ANDAMENTO:Cc,REJEITADO:Mc},Hi={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)]"},Pc=({id:e,data:t,selected:o,dragging:n})=>{let{t:r}=Ih(),{toast:i}=De(),{updateNodeData:s,getNodes:a,setNodes:l}=Sh(),{inProgress:c,fromNode:d}=Ch(),{mode:u,onSubprocessValidationClick:p,reconnectingEdgeId:f}=K(),{getTaskStatus:h}=St(),g=c&&(d==null?void 0:d.id)!==e||!!f,m=Ir(Q=>{let q=Q.split(`
|
|
41
|
+
`),z=q.reduce((V,G)=>Math.max(V,G.length),0),C=q.length,H=Math.max(lo.MIN_WIDTH,z*7+48),F=Math.max(lo.MIN_HEIGHT,C*20+24);l(V=>V.map(G=>G.id===e?v(x({},G),{width:H,height:F,style:v(x({},G.style),{width:H,height:F})}):G))},[e,l]),b=Ir(Q=>{let I=Q.trim(),R=t.label||"";if(I===R)return;let L=I,M=a();if(!(I&&I!=="")){L=Ar(M,r("bpmn.task.label.prefix")),s(e,{label:L}),m(L),i({variant:"warning",content:ln(Cr,{children:[r("bpmn.task.feedback.label_empty.prefix")," ",me("strong",{children:L})]})});return}let z=yo(L,M);z===R||(s(e,{label:z}),m(z),z!==L&&i({variant:"warning",content:ln(Cr,{children:[r("bpmn.task.feedback.label_already_exists.prefix")," ",me("strong",{children:I})," ",r("bpmn.task.feedback.label_already_exists.middle")," ",me("strong",{children:z})]})}))},[t.label,a,e,r,s,m,i]),T=Ir(Q=>{m(Q)},[m]),y=Ir(()=>{i({variant:"error",content:r("bpmn.task.feedback.invalid_first_character")})},[r,i]),E=h(e),_=E?Mh[E]:null,N=t.variant?Nn[t.variant].icon:null,w=t.attribute?vn[t.attribute].icon:null,A=t.variant==="SUBPROCESS",P=N&&!A,B=w||A,S=()=>t.hasError?Hi.error:E?Hi[E]:Hi.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 items-center justify-center bg-white border-2 border-grey-400 hover:border-grey-500 rounded-md hover:shadow-md transition-colors duration-75",S(),{"border-blue-500 hover:border-blue-600 shadow-md":o,"border-red-500 hover:border-red-600 shadow-[0_0_5px_rgba(255,0,0,0.5)]":t.hasError}),children:[me(we,{value:t.label,maxLength:60,className:O("m-1",{"py-6":P||B}),onChange:b,onInput:T,onInvalidFirstCharacter:y}),N&&me("div",{className:O("absolute flex items-center p-1",A?"bottom-0":"top-0 left-0"),children:me(N,{size:16,className:O(t.hasError?"text-red-500":"text-grey-500",A&&"cursor-pointer"),onClick:A?D:void 0})}),w&&me("div",{className:"absolute bottom-0 left-0 w-full flex items-center justify-center",children:me("div",{className:O("flex items-center w-16 p-1",A?"justify-between":"justify-center"),children:me(w,{size:16,className:O(t.hasError?"text-red-500":"text-grey-500")})})}),_&&me("div",{className:"absolute top-0 right-0 flex items-center p-1",children:me(_,{})}),me(Oe,{nodeId:e,nodeType:"TASK",nodeVariant:t.variant}),u==="edit"&&me(go,{minWidth:lo.MIN_WIDTH,minHeight:lo.MIN_HEIGHT,isVisible:!n&&o}),(!c||g)&&ln(Cr,{children:[me(re,{type:"target",position:vt.Left,id:"left",className:O({"task-handle":g})}),me(re,{type:"target",position:vt.Right,id:"right",className:O({"task-handle":g})}),me(re,{type:"target",position:vt.Top,id:"top",className:O({"task-handle":g})}),me(re,{type:"target",position:vt.Bottom,id:"bottom",className:O({"task-handle":g})})]}),!c&&ln(Cr,{children:[me(Me,{type:"source",position:vt.Left,id:"left",nodeId:e,nodeType:"TASK"}),me(Me,{type:"source",position:vt.Right,id:"right",nodeId:e,nodeType:"TASK"}),me(Me,{type:"source",position:vt.Top,id:"top",nodeId:e,nodeType:"TASK"}),me(Me,{type:"source",position:vt.Bottom,id:"bottom",nodeId:e,nodeType:"TASK"})]})]})};import{Position as Lc}from"@xyflow/react";import{Fragment as Ph,jsx as Sr,jsxs as Lh}from"react/jsx-runtime";var kc=({id:e,data:t})=>Lh(Ph,{children:[Sr("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}),Sr(Oe,{nodeId:e,nodeType:"UNSUPPORTED"}),Sr(re,{type:"source",position:Lc.Right}),Sr(re,{type:"target",position:Lc.Left})]});import{BaseEdge as kh,EdgeLabelRenderer as Rh,getSmoothStepPath as Dh,MarkerType as Oh,useInternalNode as Rc,useReactFlow as Vh,useViewport as Hh,Position as xo}from"@xyflow/react";import{useState as Gh,useMemo as Bh}from"react";import{Fragment as Dc,jsx as Ve,jsxs as Eo}from"react/jsx-runtime";var P5={type:"MESSAGE_EDGE",reconnectable:!0,markerEnd:{type:Oh.Arrow},data:{label:""}},Oc=({id:e,source:t,target:o,data:n,selected:r,sourcePosition:i,targetPosition:s,sourceHandleId:a,targetHandleId:l})=>{var G;let{zoom:c}=Hh(),{updateEdgeData:d}=Vh(),{isMultipleSelection:u,mode:p,instanceId:f}=K(),h=p!=="edit",[g,m]=Gh(!1),{reconnectingHandle:b,cursorPosition:T,hoveredNodeId:y,reconnectingSide:E,isValidReconnection:_,handleReconnectStart:N}=_r({edgeId:e,source:t,target:o,instanceId:f,isReadOnly:h}),w=Rc(t),A=Rc(o),{sx:P,sy:B,tx:S,ty:D,sourcePos:Q,targetPos:I}=Bh(()=>{var se,ae;if(!w||!A)return{sx:0,sy:0,tx:0,ty:0,sourcePos:xo.Left,targetPos:xo.Right};let W=Zt(w,A),te=a?i:W.sourcePos,k=l?s:W.targetPos,X=(le,ce,fe)=>{var Te,Pe,dt,Yt,Ut,ye;let{x:ge,y:ue}=le.internals.positionAbsolute,ie=(dt=(Pe=(Te=le.measured)==null?void 0:Te.width)!=null?Pe:le.width)!=null?dt: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*fe,y:ue};case xo.Bottom:return{x:ge+ie*fe,y:ue+ne};case xo.Left:return{x:ge,y:ue+ne*fe};case xo.Right:return{x:ge+ie,y:ue+ne*fe};default:return{x:ge+ie/2,y:ue+ne/2}}},J=(se=n==null?void 0:n.sourceOffset)!=null?se:.5,Y=(ae=n==null?void 0:n.targetOffset)!=null?ae:.5,$=w?X(w,te,J).x:W.sx,U=w?X(w,te,J).y:W.sy,Z=A?X(A,k,Y).x:W.tx,j=A?X(A,k,Y).y:W.ty;return b==="source"&&T?($=T.x,U=T.y,E&&(te=E)):b==="target"&&T&&(Z=T.x,j=T.y,E&&(k=E)),{sx:$,sy:U,tx:Z,ty:j,sourcePos:te,targetPos:k}},[w,A,a,l,i,s,b,T,E,n==null?void 0:n.sourceOffset,n==null?void 0:n.targetOffset]);if(!w||!A)return null;let[R,L,M]=Dh({sourceX:P,sourceY:B,targetX:S,targetY:D,sourcePosition:Q,targetPosition:I}),q=r||(w==null?void 0:w.selected)||(A==null?void 0:A.selected),z=q?"sequence-edge-marker-highlighted":"sequence-edge-marker",C=g||(n==null?void 0:n.label.trim().length)>0,H=()=>{m(!0)},F=()=>{m(!1)},V=W=>{d(e,{label:W.trim()})};return Ve(Dc,{children:Eo("g",{className:O("text-grey-400 hover:text-grey-500",{"text-blue-500 hover:text-blue-600":q}),onDoubleClick:H,children:[Ve(kh,{id:e,path:R,markerEnd:`url(#${z})`,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)||b&&y&&!_,"stroke-green-500":b&&y&&_,"stroke-blue-500 hover:stroke-blue-600 drop-shadow-[0_0_3px_rgba(59,130,246,0.5)]":q&&!(n!=null&&n.hasError)&&!b})}),Eo(Rh,{children:[Eo("div",{className:"absolute z-[3000] pointer-events-auto flex flex-col items-center gap-1",style:{transform:`translate(-50%, -50%) translate(${L}px, ${M}px)`},children:[r&&!u&&Ve(no,{sx:P,sy:B,tx:S,ty:D,hasLabel:!!((G=n==null?void 0:n.label)!=null&&G.trim()),children:Ve(oo,{edgeId:e,edgeType:"MESSAGE_EDGE"})}),C&&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:F,onChange:V})]}),r&&!u&&!h&&Eo(Dc,{children:[Ve("div",{className:"absolute z-[1000] pointer-events-none",style:{transform:`translate(-50%, -50%) translate(${P}px, ${B}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:b==="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:b==="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":!b||b!=="source","cursor-not-allowed":b==="source"&&y&&!_,"cursor-grabbing":b==="source"&&(!y||_)}),onMouseDown:W=>N("source",W.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:b==="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:b==="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":!b||b!=="target","cursor-not-allowed":b==="target"&&y&&!_,"cursor-grabbing":b==="target"&&(!y||_)}),onMouseDown:W=>N("target",W.nativeEvent)})]})})]})]})]})})};import{getStraightPath as zh,Position as Mr}from"@xyflow/react";import{jsx as Vc,jsxs as Fh}from"react/jsx-runtime";var Hc=({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:Mr.Left},{x:n+s,y:r+a/2,pos:Mr.Right},{x:n+s/2,y:r,pos:Mr.Top},{x:n+s/2,y:r+a,pos:Mr.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]=zh({sourceX:c.x,sourceY:c.y,targetX:e,targetY:t});return Fh("g",{children:[Vc("path",{fill:"none",className:"stroke-2 stroke-grey-400 animated",d}),Vc("circle",{cx:e,cy:t,fill:"none",r:4,className:"stroke-2 stroke-grey-500"})]})};import{Position as Wh,useReactFlow as Yh}from"@xyflow/react";import{orderBy as Uh}from"lodash";import{useMemo as Gc,useState as $h}from"react";import{Fragment as Xh,jsx as Gt,jsxs as Bc}from"react/jsx-runtime";var zc=({id:e,data:t,selected:o,dragging:n,parentId:r})=>{let{updateNodeData:i,getNodes:s}=Yh(),{mode:a}=K(),[l,c]=$h(!1),d=s(),u=!r,p=Gc(()=>Uh([...d.filter(T=>T.parentId===e&&T.type==="LANE")],"position.y","asc"),[d,e]),f=u?wr.MIN_WIDTH:pe.MIN_WIDTH,h=Gc(()=>{if(u&&p.length>1){let T=[...p];return T.pop(),T.reduce((E,_)=>{var N,w;return E+((w=(N=_.measured)==null?void 0:N.height)!=null?w:0)},0)+pe.MIN_HEIGHT}return pe.MIN_HEIGHT},[u,p]),g=T=>{i(e,{label:T})},m=()=>{c(!0)},b=()=>{c(!1)};return Bc(Xh,{children:[Bc("div",{className:O("flex h-full min-h-64 w-full min-w-[50rem] hover:shadow-md bg-white outline outline-2 outline-grey-400",{"outline-offset-2 outline-blue-500 shadow-sm":o}),children:[Gt("div",{className:"flex align-items justify-center w-10 border-r-2 border-grey-400",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:b,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:Wh.Right})]})};var Fc={START_EVENT:vc,END_EVENT:bc,TASK:Pc,GATEWAY:Tc,ANNOTATION:xc,LANE:zc,UNSUPPORTED:kc},Wc={SEQUENCE_EDGE:Ol,MESSAGE_EDGE:Oc,ANNOTATION_EDGE:Nl},Yc="#fafafa",Uc="#bebebe",$c=1,Xc=10,Kc="bottom-left",Gi=.05,qc=5,bo=.5,_o=Gi,To=1,Zc={x:0,y:0,zoom:.75},Kh=1,qh=2,Jc=[Kh,qh];import{useReactFlow as Zh}from"@xyflow/react";var Ye=()=>{let{getEdges:e,getNodes:t}=Zh(),{lastElementId:o}=K(),n=()=>{let i=t(),s=e(),a=sc(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}=Qh(),{getLastId:i}=Ye(),s=jh(),{setLastElementId:a}=K(),l=Qc(async(d="")=>{let{nodes:u,edges:p,lastElementId:f}=await lc(d),{width:h,height:g}=s.getState();if(h>0&&g>0){let m=jl(u);m&&r(Jh(m,h,g,_o,To,bo))}o(u),n(p),a(f)},[o,n,a,s,r]),c=Qc(()=>{let d=e(),u=t(),p=i();return ac(d,u,p)},[e,t,i]);return{importFromMxGraph:l,exportToMxGraph:c}};import{useCallback as jc}from"react";var ty=500,Pr=()=>{let{isInitialized:e,onElementChanges:t}=K(),{exportToMxGraph:o}=No(),n=ey(()=>{if(!e)return;let s=o();t==null||t(s)},ty),r=jc(s=>{s.every(c=>c.type==="select")||s.some(c=>c.type==="position"&&c.dragging)||n()},[n]),i=jc(s=>{s.some(l=>l.type==="select")||n()},[n]);return{emitElementChanges:n,handleNodeChanges:r,handleEdgeChanges:i}};var ed=({setEdges:e})=>{let{getNode:t,getEdges:o,getNodes:n,getInternalNode:r}=ny(),{emitElementChanges:i}=Pr(),s=ry(null),{getNextId:a}=Ye(),l=Bt(g=>{var E;let m=t(g.source),b=t(g.target);if(!m||!b)return!1;let T={sourceNodeId:m.id,targetNodeId:b.id,sourceNodeType:m.type,targetNodeType:b.type,nodes:n(),edges:o(),reconnectingEdgeId:(E=s.current)!=null?E:void 0};return Ti(T).isValid},[t,o,n]),c=Bt(g=>{var T,y;let m=a(),b=r(g.source);if(b){let E=r(g.target),_=E?E.internals.positionAbsolute.x+((T=E.measured.width)!=null?T:0)/2:0,N=E?E.internals.positionAbsolute.y+((y=E.measured.height)!=null?y:0)/2:0,w=Vl(b,_,N),A=(E==null?void 0:E.type)==="ANNOTATION"||(b==null?void 0:b.type)==="ANNOTATION",P=A?ro:Be,B;if(!A&&E&&g.targetHandle){let D=Nr(w),Q=Nr(g.targetHandle),{x:I,y:R}=Ci(b,w),{x:L,y:M}=Ci(E,g.targetHandle),z=Er(I,R,L,M,D,Q).slice(1,-1);z.length>0&&(B=z)}let S=v(x(x({},g),P),{id:String(m),sourceHandle:w,data:x(x({},A?{}:Be.data),B?{points:B}:{})});e(D=>D.concat(S))}i()},[a,e,i,r]),d=Bt((g,m)=>{s.current=m.id},[]),u=Bt(()=>{s.current=null},[]),p=Bt((g,m)=>{let b=t(m.source),T=t(m.target);if(!b||!T){s.current=null;return}let y={sourceNodeId:b.id,targetNodeId:T.id,sourceNodeType:b.type,targetNodeType:T.type,nodes:n(),edges:o(),reconnectingEdgeId:g.id};if(!Ti(y).isValid){s.current=null;return}e(_=>oy(g,m,_).map(w=>w.id===g.id?v(x({},w),{data:v(x({},w.data),{points:void 0})}):w)),s.current=null,i()},[t,n,o,e,i]),f=Bt(g=>{s.current=g},[]),h=Bt(()=>{s.current=null},[]);return{isValidConnection:l,onConnect:c,onReconnect:p,onReconnectStart:d,onReconnectEnd:u,setReconnectingEdge:f,clearReconnectingEdge:h}};import{useTranslation as iy}from"@produto-lecom/lecom-ui";import{useReactFlow as sy}from"@xyflow/react";import{useCallback as pn,useRef as cd,useState as ay}from"react";var cn=(e=[])=>e.filter(t=>t.type==="START_EVENT"),zt=(e=[])=>e.filter(t=>t.type==="END_EVENT"),wt=(e=[])=>e.filter(t=>t.type==="TASK")||[],td=(e=[])=>e.filter(t=>{var o;return t.type==="TASK"&&((o=t.properties)==null?void 0:o.variant)==="SCRIPT"}),od=(e=[])=>e.filter(t=>{var o;return t.type==="TASK"&&((o=t.properties)==null?void 0:o.variant)==="SUBPROCESS"}),Lr=(e=[])=>e.filter(t=>t.type==="GATEWAY"),nd=(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),rd=(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"},id=(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},sd=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)}},ad=(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=wt(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=wt(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=wt(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=wt(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=Lr(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=nd(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=wt(e.nodes),o=ot(t,n=>!n.label||sd(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=wt(e.nodes).filter(l=>o.some(c=>c.source===l.id)),i=ot(r,l=>!rd(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=wt(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=Lr(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=Lr(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=td(e.nodes),o=ot(t,n=>!id(n.id,e));return de({isValid:o.isValid,nodeIds:o.invalidIds})}},{id:"subprocess_referenced_not_configured",validate:e=>{let t=od(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 ld=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 kr,jsxs as ly}from"react/jsx-runtime";var dd=()=>{let{t:e}=iy(),{toast:t}=De(),{setNodes:o,setEdges:n,getNodes:r,getEdges:i}=sy(),[s,a]=ay(!1),l=cd(!1),c=cd(!1),d=pn(g=>{let m=ad(g.nodes,g.edges),b=ld(m),T=b.errors.map(y=>v(x({},y),{message:e(`validation.errors.${y.id}`)}));return s||a(!0),{isValid:b.isValid,errors:T}},[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:ly("div",{className:"flex flex-col gap-1",children:[!g.isValid&&kr("span",{className:"body-small-500",children:e("validation.errors.subtitle")}),kr("ul",{className:"list-disc list-inside max-h-40 overflow-y-auto",children:g.isValid?kr("li",{children:e("validation.success.message")}):g.errors.map(S=>kr("li",{className:"text-xs",children:S.message},S.id))})]})}),!g)return;l.current=!0,c.current=!0;let b=[],T=[];g.errors.forEach(S=>{S.nodeIds&&S.nodeIds.length>0&&S.nodeIds.forEach(D=>b.push(D)),S.edgeIds&&S.edgeIds.length>0&&S.edgeIds.forEach(D=>T.push(D))});let y=[...new Set(b)];o(S=>S.map(D=>v(x({},D),{data:v(x({},D.data),{hasError:!1})}))),n(S=>S.map(D=>v(x({},D),{data:v(x({},D.data),{hasError:!1})})));let E=r(),_=i(),N=new Set(y),w=new Set;g.errors.forEach(S=>{var I,R;let D=un.find(L=>L.id===S.id);(D==null?void 0:D.highlightRelatedEdges)!==!1&&((I=S.edgeIds)==null||I.forEach(L=>w.add(L)),(R=S.nodeIds)==null||R.forEach(L=>{_.forEach(M=>{(M.source===L||M.target===L)&&w.add(M.id)})}))});let A=new Set,P=new Set,B=new Set;E.forEach(S=>{S.type==="START_EVENT"?A.add(S.id):S.type==="END_EVENT"&&P.add(S.id)}),_.forEach(S=>{A.has(S.source)&&B.add(S.target),P.has(S.target)&&B.add(S.source)}),B.forEach(S=>{var D,Q;if(N.has(S)){let I=(D=g.errors.find(L=>{var M;return(M=L.nodeIds)==null?void 0:M.includes(S)}))==null?void 0:D.id;((Q=un.find(L=>L.id===I))==null?void 0:Q.highlightRelatedEdges)!==!1&&_.forEach(L=>{L.source===S&&P.has(L.target)&&(N.add(L.target),w.add(L.id)),L.target===S&&A.has(L.source)&&(N.add(L.source),w.add(L.id))})}}),N.size>0&&o(S=>S.map(D=>v(x({},D),{data:v(x({},D.data),{hasError:N.has(D.id)})}))),w.size>0&&n(S=>S.map(D=>v(x({},D),{data:v(x({},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(x({},m),{data:v(x({},m.data),{hasError:!1})}))),n(g=>g.map(m=>v(x({},m),{data:v(x({},m.data),{hasError:!1})})))},[n,o]),f=pn(()=>{c.current&&(l.current=!0,c.current=!1,o(g=>g.map(m=>v(x({},m),{data:v(x({},m.data),{hasError:!1})}))),n(g=>g.map(m=>v(x({},m),{data:v(x({},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 cy}from"@xyflow/react";import{useTranslation as dy}from"@produto-lecom/lecom-ui";import{useEffect as uy}from"react";var py=15,ud="bpmn:selection",fy=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},pd=e=>{if(!fy(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},fd=({offset:e=py}={})=>{let{t}=dy(),{getNodes:o,setNodes:n,getEdges:r,setEdges:i}=cy(),{getNextId:s}=Ye();uy(()=>{let a=c=>{var m,b;if(!pd(c))return;let d=o(),u=r(),p=d.filter(T=>T.selected);if(!p.length)return;c.preventDefault(),c.stopPropagation();let f=u.filter(T=>p.some(y=>y.id===T.source)&&p.some(y=>y.id===T.target)),g=JSON.stringify({nodes:p,edges:f});(m=c.clipboardData)==null||m.setData(ud,g),(b=c.clipboardData)==null||b.setData("text/plain",`BPMN Selection: ${p.length} nodes`)},l=c=>{var y,E;if(!pd(c))return;let d=(y=c.clipboardData)==null?void 0:y.getData(ud);if(!d)return;c.preventDefault(),c.stopPropagation();let u;try{u=JSON.parse(d)}catch(_){return}if(!((E=u.nodes)!=null&&E.length))return;let p=new Map,f=o(),h=[],g=u.nodes.filter(_=>yt(_.type,f));if(g.length===0)return;let m=s(),b=g.map(_=>{var A;let N=String(m++);p.set(_.id,N);let w=v(x({},_),{id:N,selected:!0,position:{x:_.position.x+e,y:_.position.y+e}});if(_.type==="TASK"){let P=(A=_.data)==null?void 0:A.label,B=yo(P||t("bpmn.task.label.prefix"),[...f,...h]);w.data=v(x({},_.data),{label:B})}return h.push(w),w}),T=u.edges.map(_=>v(x({},_),{id:String(m++),selected:!0,source:p.get(_.source)||_.source,target:p.get(_.target)||_.target}));n(_=>[..._.map(N=>v(x({},N),{selected:!1})),...b]),i(_=>[..._.map(N=>v(x({},N),{selected:!1})),...T])};return document.addEventListener("copy",a,!0),document.addEventListener("paste",l,!0),()=>{document.removeEventListener("copy",a,!0),document.removeEventListener("paste",l,!0)}},[o,n,r,i,s,e,t])};import{useReactFlow as my,useStoreApi as gy}from"@xyflow/react";import{useTranslation as hy}from"@produto-lecom/lecom-ui";import{useState as yy}from"react";var md=({nodes:e,setNodes:t,setEdges:o})=>{let n=gy(),{draggableNode:r,setDraggableNode:i}=ho(),{t:s}=hy(),{getInternalNode:a,getNodes:l,screenToFlowPosition:c}=my(),{getNextId:d}=Ye(),{setIsDragging:u}=K(),{rebuildIndex:p,forceRebuildIndex:f}=nr(),[h,g]=yy(null),m=(I,R=!1)=>{let L=R?"node-drop-target-error":"node-drop-target",M=R?"node-drop-target-lane-error":"node-drop-target-lane";t(q=>q.map(z=>z.id===I?v(x({},z),{className:L}):I!==void 0&&z.parentId===I&&z.type==="LANE"?v(x({},z),{className:M}):v(x({},z),{className:""})))},b=()=>{let{nodeLookup:I}=n.getState();return Array.from(I.values())},T=(I,R)=>{let L=b();if(I.type==="LANE"){if(R){m();return}let H=L.filter(G=>G.id!==I.id&&G.type==="LANE"&&!G.parentId),F=en(I,H);if(!F){m();return}if(mo({parentId:F.id,nodes:e,excludeTypes:["LANE"]})){m(F.id,!0);return}m(F.id);return}let q=L.filter(H=>H.id!==I.id&&H.type==="LANE"),z=en(I,q);if(!z){m();return}if(mo({parentId:z.id,nodes:e,includeTypes:["LANE"]})){m();return}m(z.id)},y=I=>{let R=a(I.id),L=I.type==="LANE"&&mo({parentId:I.id,nodes:e,includeTypes:["LANE"]});T(R,L)},E=I=>I.map(R=>v(x({},R),{className:void 0})),_=I=>I.some(L=>L.dragging)?I.map(L=>L.dragging?v(x({},L),{dragging:!1}):L):I,N=I=>{if(I.preventDefault(),I.dataTransfer.dropEffect="move",!(r!=null&&r.type))return;let R=c({x:I.clientX,y:I.clientY}),L={id:"__sidebar_drag__",type:r.type,position:R,measured:{width:1,height:1},internals:{positionAbsolute:R}};T(L,!1)},w=I=>{let R=I.relatedTarget;(!R||!I.currentTarget.contains(R))&&m()},A=(I,R)=>{I.preventDefault(),y(R)},P=(I,R,L)=>{var H,F;let M=[...L];if(I.parentId===R.id)return M=oc(I,R,M),M=tn(M),E(M);if(I.type==="LANE"){if(mo({parentId:R.id,nodes:M,excludeTypes:["LANE"]})){let k=st(R),X=50,J=50;return M.map(Y=>{var $,U;return Y.id===I.id?v(x({},Y),{position:{x:($=h==null?void 0:h.x)!=null?$:k.x+X,y:(U=h==null?void 0:h.y)!=null?U:k.y2+J}}):Y})}let W=M.filter(k=>k.parentId===R.id).reduce((k,X)=>{var J,Y;return k+((Y=(J=X.measured)==null?void 0:J.height)!=null?Y:0)},0),te={x:pe.HEADER_WIDTH,y:W};return M=M.map(k=>k.id===I.id?v(x({},k),{parentId:R.id,position:te,className:void 0}):v(x({},k),{className:void 0})),M=on(R.id,M),M}if(mo({parentId:R.id,nodes:M,includeTypes:["LANE"]})){let V;if(I.parentId){let G=a(I.parentId),{x:W,y:te}=lt(G);V={x:W+((H=I.position.x)!=null?H:0),y:te+((F=I.position.y)!=null?F:0)}}return M=M.map(G=>G.id===I.id?v(x({},G),{position:V!=null?V:G.position,parentId:void 0,className:void 0}):v(x({},G),{className:void 0})),M}let C=Zl(I,R);return M=M.map(V=>{if(V.id===I.id){let G=st(I),W=st(R);return G.y<W.y&&(C.y=0),G.x<W.x+pe.HEADER_WIDTH&&(C.x=pe.HEADER_WIDTH),v(x({},V),{parentId:R.id,position:C,className:void 0})}return v(x({},V),{className:void 0})}),M=tn(M),M},B=I=>{if(I.preventDefault(),!(r!=null&&r.type))return;if(!yt(r.type,l())){u(!1),i(null);return}let R=c({x:I.clientX,y:I.clientY}),L={width:oe[r.type].MIN_WIDTH,height:oe[r.type].MIN_HEIGHT},M=d(),q={id:String(M),type:r.type,position:R,measured:L,data:{label:r.type==="TASK"?Ar(e,s("bpmn.task.label.prefix")):"",variant:r.variant,attribute:r.attribute},selected:!0},z=v(x({},q),{internals:{positionAbsolute:R}}),C=v(x({},z),{measured:{width:1,height:1}}),H=b(),F=r.type==="LANE",V=H.filter(k=>F?k.type==="LANE"&&!k.parentId:k.type==="LANE"),G=en(C,V),W=[...e.map(k=>v(x({},k),{selected:!1})),q];G&&(W=P(z,G,W)),W=Ot(W),W=E(W),t(W),f();let te=I.dataTransfer.getData("sourceId");if(te){let k={id:String(M+1),source:te,target:q.id};r.type==="ANNOTATION"?o(X=>X.concat(x(x({},k),ro))):o(X=>X.concat(x(x({},k),Be)))}u(!1),i(null)},S=async(I,R,L)=>{let M=[...e];L.forEach(q=>{let z=b(),C=a(q.id),H=q.type==="LANE",F=z.filter(G=>G.id!==q.id&&(H?G.type==="LANE"&&!G.parentId:G.type==="LANE")),V=en(C,F);if(V){M=P(C,V,M);return}q.parentId&&(M=Q(q,M))}),M=_(M),M=Ot(M),M=E(M),t(M),p(M),g(null)},D=(I,R)=>{g({x:R.position.x,y:R.position.y})},Q=(I,R)=>{var C,H;let L=a(I.parentId),{x:M,y:q}=lt(L),z={x:M+((C=I.position.x)!=null?C:0),y:q+((H=I.position.y)!=null?H:0)};return R=R.map(F=>F.id===I.id?v(x({},F),{position:z,parentId:void 0}):F),R=on(I.parentId,R),R};return{onDragOver:N,onDragLeave:w,onDrop:B,onNodeDrag:A,onNodeDragStart:D,onNodeDragStop:S}};import{useReactFlow as xy}from"@xyflow/react";import{useTranslation as Ey}from"@produto-lecom/lecom-ui";import{useEffect as by}from"react";var _y=30,Ty=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},Ny=e=>!Ty(e.target),gd=({offset:e=_y}={})=>{let{t}=Ey(),{getNodes:o,setNodes:n,getEdges:r,setEdges:i}=xy(),{getNextId:s}=Ye();by(()=>{let a=l=>{if(l.ctrlKey&&l.key.toLowerCase()==="d"&&Ny(l)){l.preventDefault(),l.stopPropagation();let c=o(),d=r(),u=c.filter(y=>y.selected);if(!u.length)return;let p=new Map,f=[],h=u.filter(y=>yt(y.type,c));if(h.length===0)return;let g=d.filter(y=>h.some(E=>E.id===y.source)&&h.some(E=>E.id===y.target)),m=s(),b=h.map(y=>{var N;let E=String(m++);p.set(y.id,E);let _=v(x({},y),{id:E,selected:!0,position:{x:y.position.x+e,y:y.position.y+e}});if(y.type==="TASK"){let w=(N=y.data)==null?void 0:N.label,A=yo(w||t("bpmn.task.label.prefix"),[...c,...f]);_.data=v(x({},y.data),{label:A})}return f.push(_),_}),T=g.map(y=>v(x({},y),{id:String(m++),selected:!0,source:p.get(y.source)||y.source,target:p.get(y.target)||y.target}));n(y=>[...y.map(E=>v(x({},E),{selected:!1})),...b]),i(y=>[...y.map(E=>v(x({},E),{selected:!1})),...T])}};return document.addEventListener("keydown",a,!0),()=>{document.removeEventListener("keydown",a,!0)}},[o,n,r,i,s,e,t])};import{useEffect as vy,useRef as hd}from"react";import{useReactFlow as wy}from"@xyflow/react";var Ay=20,Iy=50,fn={UP:"ArrowUp",DOWN:"ArrowDown",LEFT:"ArrowLeft",RIGHT:"ArrowRight"},Cy=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=>{let{getNodes:t}=wy(),{mode:o,isMoveTool:n}=K(),r=hd(0),i=hd(new Map);vy(()=>{let s=a=>{if(o!=="edit"||!n||Cy(a.target)||!Object.values(fn).includes(a.key))return;let u=t().filter(T=>T.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?Iy:Ay,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 b=u.map(T=>{let y=i.current.get(T.id);(!f||!y)&&(y={x:T.position.x,y:T.position.y});let E={x:y.x+g,y:y.y+m};return i.current.set(T.id,E),{id:T.id,dragging:!0,type:"position",position:E}});e&&e(b)};return window.addEventListener("keydown",s),()=>{window.removeEventListener("keydown",s)}},[t,e,o,n])};import{useReactFlow as My}from"@xyflow/react";var Ed={"start-event":"START_EVENT","end-event":"END_EVENT",task:"TASK","gateway-exclusive":"GATEWAY"},bd={"start-event":"","end-event":"",task:"","gateway-exclusive":"EXCLUSIVE"},xd=(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}},Sy=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=xd(i[0],o),a=xd(i[1],o);s&&a&&n.push({sourceId:s.step,targetId:a.step,label:s.edgeLabel||a.edgeLabel||""})}),{components:o,connections:n}},_d=e=>{let{components:t,connections:o}=Sy(e);return{nodes:t,edges:o}};var Td=()=>{let{setNodes:e,setEdges:t,fitView:o}=My(),{getNextId:n}=Ye();return{importFromLia:i=>{let s=typeof i=="string"?i:i.diagramXml||"",{nodes:a,edges:l}=_d(s),c=[],d=new Map,u=!1,p=n();for(let[m,b]of Object.entries(a)){let T=String(p++),y=Ed[b.type],E=bd[b.type];y==="START_EVENT"&&(u=!0),d.set(m,T);let _=oe[y].MIN_WIDTH,N=oe[y].MIN_HEIGHT;c.push({id:T,type:y,data:{label:b.label||"",variant:E,attribute:""},position:{x:0,y:0},width:_,height:N,measured:{width:_,height:N}})}let f=[];for(let m of l){let b=v(x({},Be),{id:String(p++),source:d.get(m.sourceId)||m.sourceId,target:d.get(m.targetId)||m.targetId});f.push(b)}if(!u&&c.length>0){let m=String(p++),b={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(b);let T=c[1];if(T){let y=v(x({},Be),{id:String(p++),source:m,target:T.id});f.unshift(y)}}let{nodes:h,edges:g}=tc(c,f);e(h),t(g),o({padding:bo,minZoom:_o,maxZoom:To})}}};import{useEffect as Py,useCallback as Ly}from"react";var ky={origin:"*",debug:!1};function Nd(e,t=ky){let{origin:o,debug:n}=t,r=Ly((i,s)=>{let a={event:i,data:[i,{event:i,data:s}]};window.parent.postMessage(a,o||"*")},[o]);return Py(()=>{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 Ry}from"@xyflow/react";import{useEffect as vd}from"react";var wd=()=>{let e=Ry(),{initialDiagram:t,setIsInitialized:o}=K(),{importFromMxGraph:n}=No();vd(()=>{t&&n(t)},[t,n,o]),vd(()=>{if(!e)return;(async()=>{await bn(),o(!0)})()},[e,o])};import{useCallback as Ad}from"react";import{useReactFlow as Dy}from"@xyflow/react";function Id(){let{setTaskStatuses:e,clearTaskStatuses:t,calculateFlowPath:o}=St(),{getEdges:n}=Dy(),r=An(),i=Ad(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=Ad(()=>{t(),setTimeout(()=>{r()},0)},[t,r]);return{handleTasksStatus:i,handleClearTaskStatus:s}}import{useReactFlow as Oy}from"@xyflow/react";import{useCallback as At,useState as Vy,useEffect as Cd}from"react";import{useDebouncedCallback as Hy}from"use-debounce";var Gy=500,Sd=100,Md=(e=!1)=>{let{getNodes:t,getEdges:o,setNodes:n,setEdges:r}=Oy(),[i,s]=Vy({history:[],currentStep:0}),{history:a,currentStep:l}=i,c=a[l],d=l>0,u=l<a.length-1,p=At((_,N)=>{n(_[N].nodes),r(_[N].edges)},[n,r]),f=At(()=>{if(l>0){let _=l-1;s(N=>v(x({},N),{currentStep:_})),p(a,_)}},[l,a,p]),h=At(()=>{if(l<a.length-1){let _=l+1;s(N=>v(x({},N),{currentStep:_})),p(a,_)}},[a,l,p]),g=At(_=>{s(N=>{let A=[...N.history.slice(0,N.currentStep+1),_],P=A.length>Sd?A.slice(A.length-Sd):A;return{history:P,currentStep:P.length-1}})},[]),m=At(()=>{let _=t(),N=o(),w=_.map(P=>v(x({},P),{selected:!1,className:"",data:v(x({},P.data),{hasError:!1})})),A=N.map(P=>v(x({},P),{data:v(x({},P.data),{hasError:!1})}));return{nodes:Ot(w),edges:A}},[t,o]),b=Hy(()=>{let _=m();JSON.stringify(c)!==JSON.stringify(_)&&g(_)},Gy),T=At(_=>{if(!e)return;if(a.length===0){let A=m();s({history:[A],currentStep:0})}if(_==="forceSave"){b();return}_.some(A=>A.type==="select")||_.some(A=>A.type==="position"&&A.dragging)||b()},[e,b,a.length,m]);Cd(()=>{if(e&&a.length===0){let _=m();s({history:[_],currentStep:0})}},[e,a.length,m]);let y=At(_=>{s({history:_||[],currentStep:0})},[]),E=At(()=>{s({history:[],currentStep:0})},[]);return Cd(()=>{let _=N=>{(N.ctrlKey||N.metaKey)&&(N.shiftKey&&N.key.toLowerCase()==="z"?(N.preventDefault(),h()):N.key.toLowerCase()==="z"&&(N.preventDefault(),f()))};return document.addEventListener("keydown",_),()=>{document.removeEventListener("keydown",_)}},[f,h]),{history:a,undo:f,redo:h,canUndo:d,canRedo:u,saveHistory:T,resetHistory:y,clearHistory:E}};var Pd=()=>{let{t:e}=By(),[t,o,n]=Fy([]),[r,i,s]=zy([]),{getNode:a}=Yy(),{toast:l}=De(),c=Uy(),{instanceId:d,isInitialized:u,setIsConnecting:p,setIsMultipleSelection:f,onElementClick:h}=K(),{updateHelperLines:g,HelperLines:m}=nr(),{undo:b,redo:T,canUndo:y,canRedo:E,saveHistory:_}=Md(u),{onNodeDrag:N,onDrop:w,onDragOver:A,onDragLeave:P,onNodeDragStop:B,onNodeDragStart:S}=md({nodes:t,setNodes:o,setEdges:i}),{isValidConnection:D,onConnect:Q,onReconnect:I,onReconnectStart:R,onReconnectEnd:L,setReconnectingEdge:M,clearReconnectingEdge:q}=ed({setEdges:i}),{handleValidationComplete:z,clearValidation:C,dismissValidationPanel:H,validateDiagram:F,getIsClearingValidation:V}=dd(),{importFromLia:G}=Td(),{handleTasksStatus:W,handleClearTaskStatus:te}=Id(),{clearPathEdges:k}=St(),{emitElementChanges:X,handleNodeChanges:J,handleEdgeChanges:Y}=Pr(),$=An();fd(),gd(),wd();let U=It(()=>{o([]),i([]),k(),setTimeout($,0)},[o,i,k,$]);Nd({LIA_CREATE_DIAGRAM:G,CLEAR_DIAGRAM:U,TASKS_STATUS:W,CLEAR_TASKS_STATUS:te});let{selectElements:Z,clearSelection:j}=xt(),{importFromMxGraph:se,exportToMxGraph:ae}=No(),{configureElement:le,getConfigureElement:ce}=ur(),fe=It(()=>t.length+r.length,[t,r]);$y(()=>(tt.set(d,{importFromMxGraph:se,exportToMxGraph:ae,selectElements:Z,clearSelection:j,configureElement:le,getConfigureElement:ce,getElementsCount:fe,setReconnectingEdge:M,clearReconnectingEdge:q}),()=>{tt.delete(d)}),[d,se,ae,Z,j,le,ce,fe,M,q]);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),Kr=a(ve.target),{isFromStartEvent:pu,isGatewayToGateway:fu,isActiviyToAndGateway:mu}=wn(Ze,Kr);if(!(!pu&&!fu&&!mu))return;let Zi=ce(ve.id);Zi&&(h==null||h(Zi))},[ce,a,h]),ie=It(ye=>{let ve=g(ye,t);n(ve),_(ye),V()||H(),J(ye)},[t,n,_,V,H,g,J]),ne=It(ye=>{s(ye),_(ye),V()||H(),Y(ye)},[s,_,V,H,Y]);yd(ie);let Te=It(({nodes:ye,edges:ve})=>{f(ye.length+ve.length>=2)},[f]);Wy({onChange:Te});let Pe=It(async({nodes:ye})=>ye.some(Ze=>Ze.type==="LANE"&&t.some(Kr=>Kr.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:Q,onReconnect:I,onReconnectStart:R,onReconnectEnd:L,onDrop:w,onDragOver:A,onDragLeave:P,onNodeDrag:N,onNodeDragStop:B,onNodeDragStart:S,onNodeClick:ge,onEdgeClick:ue,onDropCapture:()=>{_("forceSave"),X(),H()},onConnectStart:()=>{p(!0)},onConnectEnd:()=>{p(!1),H()},onSelectionEnd:()=>c.setState({nodesSelectionActive:!1}),onNodesChange:ie,onEdgesChange:ne,onBeforeDelete:Pe},ui:{handleCloseValidationPanel:C},controls:{undo:b,redo:T,canUndo:y,canRedo:E},components:{HelperLines:m},actions:{saveHistory:_,selectElements:Z,clearSelection:j,exportToMxGraph:ae,validateDiagram:F,handleValidationComplete:z,setReconnectingEdge:M,clearReconnectingEdge:q}}};import{jsx as Ld}from"react/jsx-runtime";var Bi=({id:e,className:t})=>Ld("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:Ld("path",{d:"M 0 0 L 10 5 L 0 10 Z"})});import{jsx as zi,jsxs as Xy}from"react/jsx-runtime";var kd=()=>zi("svg",{style:{position:"absolute",top:0,left:0},children:Xy("defs",{children:[zi(Bi,{id:"sequence-edge-marker",className:"text-grey-400"}),zi(Bi,{id:"sequence-edge-marker-highlighted",className:"text-blue-500"})]})});import{Tooltip as ux,TooltipContent as px,TooltipTrigger as fx,useTranslation as mx}from"@produto-lecom/lecom-ui";import{useKeyPress as Jd,useReactFlow as R0}from"@xyflow/react";import{Button as Gr,Tooltip as Br,TooltipContent as zr,TooltipTrigger as Fr,useTranslation as D0}from"@produto-lecom/lecom-ui";import{HandIcon as O0,ListCheckIcon as V0,MapIcon as H0,MousePointerIcon as G0}from"lucide-react";import{useCallback as Ui,useEffect as Qd}from"react";import{Tooltip as f0,TooltipContent as m0,TooltipTrigger as g0,useTranslation as h0}from"@produto-lecom/lecom-ui";var mn=(y=>(y.START_EVENT="START_EVENT",y.END_EVENT="END_EVENT",y.TASK="TASK",y.SUBPROCESS="SUBPROCESS",y.GATEWAY="GATEWAY",y.LANE="LANE",y.ANNOTATION="ANNOTATION",y.CONNECTION="CONNECTION",y.INTERMEDIATE_EVENT="INTERMEDIATE_EVENT",y.ACTIVITY="ACTIVITY",y.PROCESS_INTERFACE="PROCESS_INTERFACE",y.WORKFLOW_INTERFACE="WORKFLOW_INTERFACE",y.VARIANT_ACTIVITY="VARIANT_ACTIVITY",y.AUTO_ACTIVITY="AUTO_ACTIVITY",y.DATA_STORE="DATA_STORE",y.DATA_OBJECT="DATA_OBJECT",y.DATA_OUTPUT="DATA_OUTPUT",y.DATA_INPUT="DATA_INPUT",y.MARKER="MARKER",y))(mn||{});import{Button as i0,useTranslation as s0}from"@produto-lecom/lecom-ui";import{useReactFlow as a0}from"@xyflow/react";var Rd=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 Dd({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);Rr(i,`${o}.csv`)}var Rr=(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 Od(e){return e==null?void 0:e.replaceAll("
"," ")}var TL={START_EVENT:"START_EVENT",END_EVENT:"END_EVENT",TASK:"TASK",GATEWAY:"GATEWAY",ANNOTATION:"ANNOTATION"},Vd={script:"SCRIPT",subprocess:"SUBPROCESS"},Hd={"marker-loop":"LOOP"},Gd={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}}},qy=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}},Zy=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}},Jy=(e,t)=>{let{id:o,subType:n,style:r}=e==null?void 0:e._attributes,i=Vd[n],s=t.get(o)||"",a=Hd[s]||"",l=a==="LOOP",c="imported";return!["script","none"].includes(n)&&!l&&(c="adapted"),e.mxGeometry._attributes.width=ut(e.mxGeometry._attributes.width||0,oe.TASK.MIN_WIDTH),e.mxGeometry._attributes.height=ut(e.mxGeometry._attributes.height||0,oe.TASK.MIN_HEIGHT),{node:Ft({cell:e,type:"TASK",variant:i,attribute:a}),status:c,originalType:r}},Qy=e=>{let{style:t,subType:o}=e==null?void 0:e._attributes,n=Gd[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}},jy=e=>{let{style:t}=e==null?void 0:e._attributes;return{node:Ft({cell:e,type:"LANE"}),status:"imported",originalType:t}},e0=e=>{let{style:t}=e==null?void 0:e._attributes;return e.mxGeometry._attributes.width=ut(e.mxGeometry._attributes.width||0,oe.ANNOTATION.MIN_WIDTH),e.mxGeometry._attributes.height=ut(e.mxGeometry._attributes.height||0,oe.ANNOTATION.MIN_HEIGHT),{node:Ft({cell:e,type:"ANNOTATION"}),status:"imported",originalType:t}},Bd=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}},zd=(e,t)=>{let{id:o,source:n,target:r,value:i}=e._attributes;return v(x({},Be),{id:o,source:t.get(n)||n,target:t.get(r)||r,data:{label:i||""}})},Fd={TASK:Jy,GATEWAY:Qy,START_EVENT:qy,END_EVENT:Zy,LANE:jy,ANNOTATION:e0};var t0=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=Fd[l]||Bd,{node:d,status:u,originalType:p}=c(a,r);s.push(d),i.push({originalType:p,type:d.type,variant:d.data.variant,value:Od(d.data.label),status:u})}return{nodes:s,governanceIdToNodeIdMap:t,summary:i}},o0=(e,t)=>e.filter(r=>{var i;return(i=r._attributes)==null?void 0:i.edge}).map(r=>zd(r,t)),n0=e=>{let{mxGraphModel:t}=e,{nodes:o,governanceIdToNodeIdMap:n,summary:r}=t0(t.root.mxCell),i=o0(t.root.mxCell,n);return{nodes:o,edges:i,summary:r}},r0=async e=>{let t=await Rd(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}},Wd=async e=>{try{let t=await r0(e),{nodes:o,edges:n,summary:r}=n0(t)||{};return{nodes:o,edges:n,summary:r}}catch(t){throw t}};import{jsx as l0}from"react/jsx-runtime";var Yd=()=>{let{t:e}=s0(),{toast:t}=De(),{setNodes:o,setEdges:n,fitView:r}=a0(),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:l0(i0,{size:"small",variant:"ghost",onClick:()=>Dd({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 Wd(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 c0}from"@produto-lecom/lecom-ui";import{useRef as d0}from"react";import{Fragment as u0,jsx as Ud,jsxs as p0}from"react/jsx-runtime";var $d=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=d0(null),d=p=>{let f=p.target.files;f!=null&&f.length&&i(f),c.current&&(c.current.value="")};return p0(u0,{children:[Ud(c0,v(x({disabled:n,onClick:p=>{var f;(f=c.current)==null||f.click(),r==null||r(p)}},s),{children:e})),Ud("input",{type:"file",ref:c,className:"sr-only",accept:t,multiple:o,disabled:n,onChange:d})]})};import{jsx as Dr,jsxs as y0}from"react/jsx-runtime";var Xd=({disabled:e=!1})=>{let{t}=h0(),{toast:o}=De(),{importFromGovernance:n}=Yd(),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 y0(f0,{children:[Dr(g0,{asChild:!0,children:Dr($d,{className:"[&>svg]:size-7 p-0",variant:"ghost",size:"small",color:"grey",iconButton:!0,accept:".mdr",disabled:e,onClick:r,onFilesSelected:i,children:Dr(as,{})})}),Dr(m0,{color:"black",children:t("editor.controls.actions.import_governance")})]})};import{jsx as x0}from"react/jsx-runtime";var Fi=({shortcut:e})=>x0("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 v0,DropdownMenu as w0,DropdownMenuContent as A0,DropdownMenuItem as Yi,DropdownMenuTrigger as I0,Tooltip as Or,TooltipContent as Vr,TooltipTrigger as Hr,useTranslation as C0}from"@produto-lecom/lecom-ui";import{FileCodeIcon as S0,FileImageIcon as M0,FolderOutputIcon as P0,PrinterIcon as L0}from"lucide-react";import{useState as k0}from"react";import{useTranslation as E0}from"@produto-lecom/lecom-ui";import{useReactFlow as b0}from"@xyflow/react";import{toPng as Kd,toSvg as _0}from"html-to-image";import{useState as T0}from"react";var N0=3,Wi="diagram",qd=()=>{let{t:e}=E0(),{toast:t}=De(),{getNodes:o}=b0(),{clearSelection:n}=xt(),[r,i]=T0({png:!1,html:!1,print:!1}),s=()=>{let{x:u,y:p,width:f,height:h}=rc(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(x({},r),{[p]:!0})),await n();try{let f=nc();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(x({},r),{[p]:!1}))}};return{exportAsPng:async(u=Wi)=>{await a(async(p,f)=>{let h=await Kd(p,v(x({},f),{backgroundColor:"#fcfcfc"}));Rr(h,`${u}.png`)},"png")},exportAsHtml:async(u=Wi)=>{await a(async(p,f)=>{let h=await _0(p,v(x({},f),{backgroundColor:"#fcfcfc"})),g=`
|
|
42
44
|
<!DOCTYPE html>
|
|
43
45
|
<html>
|
|
44
46
|
<head>
|
|
@@ -49,10 +51,10 @@ var uu=Object.defineProperty,pu=Object.defineProperties;var fu=Object.getOwnProp
|
|
|
49
51
|
</style>
|
|
50
52
|
</head>
|
|
51
53
|
<body>
|
|
52
|
-
<img src="${
|
|
54
|
+
<img src="${h}" alt="Diagram" />
|
|
53
55
|
</body>
|
|
54
56
|
</html>
|
|
55
|
-
`,m=new Blob([g],{type:"text/html"}),
|
|
57
|
+
`,m=new Blob([g],{type:"text/html"}),b=URL.createObjectURL(m);Rr(b,`${u}.html`),setTimeout(()=>URL.revokeObjectURL(b),100)},"html")},printDiagram:async(u=Wi)=>{await a(async(p,f)=>{let h=await Kd(p,v(x({},f),{pixelRatio:N0})),g=window.open("","_blank");if(!g)throw new Error("Failed to open print window.");let m=g.document;m.open(),m.write(`
|
|
56
58
|
<!DOCTYPE html>
|
|
57
59
|
<html>
|
|
58
60
|
<head>
|
|
@@ -65,7 +67,7 @@ var uu=Object.defineProperty,pu=Object.defineProperties;var fu=Object.getOwnProp
|
|
|
65
67
|
</style>
|
|
66
68
|
</head>
|
|
67
69
|
<body>
|
|
68
|
-
<img src="${
|
|
70
|
+
<img src="${h}" alt="Diagram" onload="window.print(); window.close();" />
|
|
69
71
|
</body>
|
|
70
72
|
</html>
|
|
71
|
-
`),m.close()},"print")},isPrintingPng:r.png,isPrintingHtml:r.html,isPrinting:r.print}};import{jsx as _e,jsxs as No}from"react/jsx-runtime";function $d(){let{t:e}=T0(),{exportAsPng:t,exportAsHtml:o,printDiagram:n,isPrinting:r,isPrintingPng:i,isPrintingHtml:s}=Ud(),[a,l]=I0(!1);return No(E0,{modal:!1,open:a,onOpenChange:l,children:[_e(_0,{asChild:!0,children:_e("div",{children:No(Or,{children:[_e(Hr,{asChild:!0,children:_e(x0,{size:"small",variant:"ghost",color:"grey",iconButton:!0,children:_e(w0,{})})}),!a&&_e(Vr,{color:"black",children:e("editor.controls.actions.export.title")})]})})}),No(b0,{align:"center",side:"top",sideOffset:16,className:"min-w-0 flex flex-col gap-2 p-2 shadow-sm",children:[No(Or,{children:[_e(Hr,{asChild:!0,children:_e(zi,{className:"p-1.5",disabled:i,onClick:()=>t(),children:_e(v0,{})})}),_e(Vr,{side:"right",color:"black",children:e("editor.controls.actions.export.png")})]}),No(Or,{children:[_e(Hr,{asChild:!0,children:_e(zi,{className:"p-1.5",disabled:s,onClick:()=>o(),children:_e(N0,{})})}),_e(Vr,{side:"right",color:"black",children:e("editor.controls.actions.export.html")})]}),No(Or,{children:[_e(Hr,{asChild:!0,children:_e(zi,{className:"p-1.5",disabled:r,onClick:()=>n(),children:_e(A0,{})})}),_e(Vr,{side:"right",color:"black",children:e("editor.controls.actions.export.print")})]})]})]})}import{Fragment as qd,jsx as Te,jsxs as ct}from"react/jsx-runtime";var Zd=({nodes:e,edges:t,validateDiagram:o,handleValidationComplete:n})=>{let{t:r}=S0(),{clearSelection:i}=xt(),{mode:s,isMinimapOpen:a,setIsMinimapOpen:l,isMoveTool:c,isHandTool:d,setIsMoveTool:u,setIsHandTool:p}=q(),{getNodes:f,getEdges:y}=C0(),g=Xd(["v","V"]),m=Xd(["h","H"]),E=Fi(()=>{i(),p(!0),u(!1)},[i,p,u]),T=Fi(()=>{u(!0),p(!1)},[u,p]),h=Fi(()=>{let _=f(),b=y(),N=o({nodes:_,edges:b});n(N)},[f,y,o,n]);return Kd(()=>{g&&!c&&s==="edit"&&T()},[g,T,c,s]),Kd(()=>{m&&!d&&s==="edit"&&E()},[m,E,d,s]),ct("div",{className:"flex items-center gap-2 px-3 py-2 bg-white rounded-sm shadow-md",children:[s==="edit"&&ct(qd,{children:[ct(Br,{children:[Te(Fr,{asChild:!0,children:Te(Gr,{size:"small",variant:"ghost",color:"grey",className:R(c&&"bg-grey-400"),iconButton:!0,onClick:T,children:Te(k0,{})})}),ct(zr,{color:"black",className:"flex items-center gap-2",children:[r("editor.controls.actions.move_tool"),Te(Gi,{shortcut:"V"})]})]}),ct(Br,{children:[Te(Fr,{asChild:!0,children:Te(Gr,{size:"small",variant:"ghost",color:"grey",className:R(d&&"bg-grey-400"),iconButton:!0,onClick:E,children:Te(M0,{})})}),ct(zr,{color:"black",className:"flex items-center gap-2",children:[r("editor.controls.actions.hand_tool")," ",Te(Gi,{shortcut:"H"})]})]})]}),Te($d,{}),s==="edit"&&ct(qd,{children:[ct(Br,{children:[Te(Fr,{asChild:!0,children:Te(Gr,{size:"small",variant:"ghost",color:"grey",iconButton:!0,onClick:h,children:Te(P0,{})})}),Te(zr,{color:"black",children:r("editor.controls.actions.check")})]}),Te(Wd,{disabled:e.length>0||t.length>0})]}),ct(Br,{children:[Te(Fr,{asChild:!0,children:Te(Gr,{size:"small",variant:"ghost",color:"grey",className:R(a&&"bg-grey-400"),iconButton:!0,onClick:()=>l(!a),children:Te(L0,{})})}),Te(zr,{color:"black",children:r(a?"editor.controls.actions.minimap.close":"editor.controls.actions.minimap.open")})]})]})};import{Button as Jd,Tooltip as Qd,TooltipContent as jd,TooltipTrigger as eu,useTranslation as R0}from"@produto-lecom/lecom-ui";import{RedoIcon as D0,UndoIcon as O0}from"lucide-react";import{jsx as Ct,jsxs as Wi}from"react/jsx-runtime";var tu=({undo:e,redo:t,canUndo:o,canRedo:n})=>{let{t:r}=R0();return Wi("div",{className:"flex items-center gap-2 px-3 py-2 bg-white rounded-sm shadow-md",children:[Wi(Qd,{children:[Ct(eu,{asChild:!0,children:Ct(Jd,{size:"small",variant:"ghost",color:"grey",iconButton:!0,disabled:!o,onClick:e,children:Ct(O0,{})})}),Ct(jd,{color:"black",children:r("editor.controls.history.undo")})]}),Wi(Qd,{children:[Ct(eu,{asChild:!0,children:Ct(Jd,{size:"small",variant:"ghost",color:"grey",iconButton:!0,disabled:!n,onClick:t,children:Ct(D0,{})})}),Ct(jd,{color:"black",children:r("editor.controls.history.redo")})]})]})};import{useEdges as V0,useNodes as H0,useReactFlow as G0}from"@xyflow/react";import{Button as Wr,Tooltip as Yr,TooltipContent as Ur,TooltipTrigger as $r,useTranslation as B0}from"@produto-lecom/lecom-ui";import{ScanIcon as z0,ZoomIn as F0,ZoomOut as W0}from"lucide-react";import{jsx as Ce,jsxs as mn}from"react/jsx-runtime";var ou=()=>{let{t:e}=B0(),t=H0(),o=V0(),{zoomIn:n,zoomOut:r,zoomTo:i,fitView:s}=G0(),a=t.length===0&&o.length===0;return mn("div",{className:"flex items-center gap-2 px-3 py-2 bg-white rounded-sm shadow-md",children:[mn(Yr,{children:[Ce($r,{asChild:!0,children:Ce(Wr,{iconButton:!0,size:"small",color:"grey",variant:"ghost",disabled:a,onClick:()=>s(),children:Ce(z0,{})})}),Ce(Ur,{color:"black",children:e("editor.controls.zoom.fit")})]}),mn(Yr,{children:[Ce($r,{asChild:!0,children:Ce(Wr,{iconButton:!0,size:"small",color:"grey",variant:"ghost",disabled:a,onClick:()=>r(),children:Ce(W0,{})})}),Ce(Ur,{color:"black",children:e("editor.controls.zoom.out")})]}),mn(Yr,{children:[Ce($r,{asChild:!0,children:Ce(Wr,{iconButton:!0,size:"small",color:"grey",variant:"ghost",disabled:a,onClick:()=>i(1),children:Ce(as,{})})}),Ce(Ur,{color:"black",children:e("editor.controls.zoom.reset")})]}),mn(Yr,{children:[Ce($r,{asChild:!0,children:Ce(Wr,{iconButton:!0,size:"small",color:"grey",variant:"ghost",disabled:a,onClick:()=>n(),children:Ce(F0,{})})}),Ce(Ur,{color:"black",children:e("editor.controls.zoom.in")})]})]})};import{useNodes as Y0}from"@xyflow/react";import{Button as U0,Tooltip as $0,TooltipContent as X0,TooltipTrigger as K0,useTranslation as q0}from"@produto-lecom/lecom-ui";import{useRef as Z0,useState as J0}from"react";import{jsx as Wt,jsxs as nu}from"react/jsx-runtime";var ru=()=>{let e=Z0(null),{t}=q0(),{setDraggableNode:o}=go(),n=Y0(),{setIsDragging:r}=q(),[i,s]=J0(void 0),a=[{type:"START_EVENT",icon:bn,label:t("bpmn.start_event.variant.default")},{type:"END_EVENT",icon:$t,label:t("bpmn.end_event.variant.default")},{type:"TASK",icon:wo,label:t("bpmn.task.variant.default")},{type:"TASK",variant:"SUBPROCESS",icon:ps,label:t("bpmn.task.variant.subprocess")},{type:"TASK",variant:"SCRIPT",icon:us,label:t("bpmn.task.variant.script")},{type:"TASK",attribute:"LOOP",icon:ds,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:ss,label:t("bpmn.lane.variant.default")},{type:"ANNOTATION",icon:xn,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 nu("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=!yt(c.type,n),p=u?t("editor.toolbar.start_event_already_exists"):c.label;return nu($0,{children:[Wt(K0,{asChild:!0,children:Wt(U0,{className:R("[&>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(X0,{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 Xr}from"react/jsx-runtime";var Yi=nx((e,t)=>{let o=ox("Space"),{instanceId:n,mode:r,isMinimapOpen:i,isMoveTool:s,isHandTool:a}=q(),{nodes:l,edges:c,actions:d,events:u,components:p,controls:f}=Id(),{t:y}=lx();rx(t,()=>({selectElements:d.selectElements,clearSelection:d.clearSelection}));let g=a||o||r!=="edit"?!0:Xc,m=r!=="readonly"&&s&&!o,E=r==="edit"&&s&&!o,T=r==="edit"&&s&&!o;return Xr("div",{className:"w-full h-full",children:[r==="edit"&&Ke(ru,{}),Ke(Sd,{}),Xr(ex,v(x({},u),{id:`modeler-${n}`,className:R({"is-hand-tool":a||o}),edges:c,nodes:l,nodeTypes:Vc,edgeTypes:Hc,minZoom:Yc,maxZoom:Uc,panOnDrag:g,panOnScroll:!0,selectionOnDrag:!0,elevateEdgesOnSelect:!0,elevateNodesOnSelect:!1,elementsSelectable:m,nodesConnectable:E,nodesDraggable:T,connectionLineComponent:kc,selectionMode:tx.Partial,multiSelectionKeyCode:["Control","Meta"],deleteKeyCode:"Delete",selectionKeyCode:null,defaultViewport:$c,connectOnClick:!1,connectionRadius:50,proOptions:{hideAttribution:!0},children:[Ke(Q0,{gap:Fc,size:zc,color:Bc,bgColor:Gc}),i&&Xr(ix,{children:[Ke(ax,{asChild:!0,children:Ke("div",{className:"absolute bottom-[0px] left-[0px] z-[5]",children:Ke(j0,{pannable:!0,zoomable:!0,position:Wc,className:"shadow-md rounded-md",ariaLabel:"",style:{pointerEvents:"all",position:"relative"}})})}),Ke(sx,{color:"black",children:y("editor.controls.actions.minimap.label")})]}),Xr("div",{className:"absolute z-10 bottom-4 left-1/2 -translate-x-1/2 flex gap-4",children:[r==="edit"&&Ke(tu,x({},f)),Ke(Zd,{nodes:l,edges:c,validateDiagram:d.validateDiagram,handleValidationComplete:d.handleValidationComplete}),Ke(ou,{})]}),Ke(p.HelperLines,{})]}))]})});Yi.displayName="Editor";import{useStore as cx}from"@xyflow/react";import{useEffect as dx,useRef as ux}from"react";import{jsx as fx}from"react/jsx-runtime";var px=e=>({width:e.width,height:e.height,transform:e.transform}),Ui="rgba(51, 103, 217, 0.4)",cl=({horizontal:e,vertical:t})=>{let{width:o,height:n,transform:r}=cx(px),i=ux(null);return dx(()=>{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=Ui,t&&(a.beginPath(),a.strokeStyle=t.color||Ui,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||Ui,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]),fx("canvas",{ref:i,className:"w-full h-full absolute z-10 pointer-events-none"})};import{i18n as mx,Notification as gx,TooltipProvider as hx}from"@produto-lecom/lecom-ui";import{createContext as yx,useContext as xx,useEffect as Ex,useState as bx}from"react";import{jsx as iu,jsxs as Tx}from"react/jsx-runtime";var tt=new Map,su=yx(null),$o=()=>{let e=xx(su);if(!e)throw new Error("useModeler must be used within an <ModelerProvider />");return e},_x=({locale:e,defaultMode:t="view",toast:o,children:n})=>{let[r,i]=bx(e||"pt_BR");Ex(()=>{e&&(i(e),mx.changeLanguage(e))},[e]);let s=y=>{let g=tt.size;if(g===0)throw new Error("No modeler instances found");if(g===1||!y){let[E]=tt.values();return E}let m=tt.get(y);if(!m)throw new Error(`Modeler instance with ID "${y}" not found`);return m},a=(y,g)=>{let m=s(g);return m==null?void 0:m.selectElements(y)},l=async y=>{let g=s(y);return g==null?void 0:g.clearSelection()},c=(y,g)=>{let m=s(g);return m==null?void 0:m.configureElement(y)},d=(y,g)=>{let m=s(g);return m==null?void 0:m.getConfigureElement(y)},u=async(y,g)=>{let m=s(g);await(m==null?void 0:m.importFromMxGraph(y))},p=y=>{let g=s(y);return g==null?void 0:g.exportToMxGraph()},f=y=>{let g=s(y);return(g==null?void 0:g.getElementsCount())||0};return iu(su.Provider,{value:{defaultMode:t,locale:r,selectElements:a,clearSelection:l,configureElement:c,getConfigureElement:d,importDiagram:u,exportDiagram:p,getElementsCount:f,toast:o},children:Tx(hx,{children:[!o&&iu(gx,{type:"toast",placement:"topRight",enableClose:!0,showProgress:!0,pauseOnHover:!0}),n]})})};import{useTranslation as Sx}from"@produto-lecom/lecom-ui";import{jsx as $i}from"react/jsx-runtime";var au=vx(null),q=()=>{let e=wx(au);if(!e)throw new Error("useModelerInstance must be used within an <Modeler />");return e},Mx=({selectorRef:e,initialDiagram:t,instanceId:o,mode:n,onElementChanges:r,onConfigureElement:i,onElementClick:s,onSubprocessValidationClick:a})=>{let{t:l}=Sx(),{defaultMode:c}=$o(),d=Ix(),[u]=qe(o||d),[p,f]=qe(n||c||"edit"),[y,g]=qe(on),[m,E]=qe(!1),[T,h]=qe(!0),[_,b]=qe(!1),[N,A]=qe(!1),[I,M]=qe(!1),[H,S]=qe(!1),[w,k]=qe(!1),[V,P]=qe(null);Ax(()=>{n&&f(n)},[n]);let L=Cx(()=>t||ec(l),[t,l]),W={instanceId:u,initialDiagram:L,mode:p,lastElementId:y,isInitialized:m,isMinimapOpen:N,isMoveTool:T,isHandTool:_,isDragging:I,isMultipleSelection:w,isConnecting:H,setLastElementId:g,setIsInitialized:E,reconnectingEdgeId:V,setIsMinimapOpen:A,setIsMoveTool:h,setIsHandTool:b,setIsDragging:M,setIsConnecting:S,setIsMultipleSelection:k,setReconnectingEdgeId:P,onElementChanges:r,onConfigureElement:i,onElementClick:s,onSubprocessValidationClick:a};return $i(Nx,{children:$i(au.Provider,{value:W,children:$i(Yi,{ref:e})})})};export{Pe as EditorMode,qr as ElementPosition,hn as ElementType,Zr as GatewayElementVariant,$e as GatewayVariant,Mx as Modeler,_x as ModelerProvider,Qe as NodeAttribute,ee as NodeType,Ue as NodeVariant,Jr as RoutingVariant,$o as useModeler};
|
|
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 Zd(){let{t:e}=C0(),{exportAsPng:t,exportAsHtml:o,printDiagram:n,isPrinting:r,isPrintingPng:i,isPrintingHtml:s}=qd(),[a,l]=k0(!1);return vo(w0,{modal:!1,open:a,onOpenChange:l,children:[be(I0,{asChild:!0,children:be("div",{children:vo(Or,{children:[be(Hr,{asChild:!0,children:be(v0,{size:"small",variant:"ghost",color:"grey",iconButton:!0,children:be(P0,{})})}),!a&&be(Vr,{color:"black",children:e("editor.controls.actions.export.title")})]})})}),vo(A0,{align:"center",side:"top",sideOffset:16,className:"min-w-0 flex flex-col gap-2 p-2 shadow-sm",children:[vo(Or,{children:[be(Hr,{asChild:!0,children:be(Yi,{className:"p-1.5",disabled:i,onClick:()=>t(),children:be(M0,{})})}),be(Vr,{side:"right",color:"black",children:e("editor.controls.actions.export.png")})]}),vo(Or,{children:[be(Hr,{asChild:!0,children:be(Yi,{className:"p-1.5",disabled:s,onClick:()=>o(),children:be(S0,{})})}),be(Vr,{side:"right",color:"black",children:e("editor.controls.actions.export.html")})]}),vo(Or,{children:[be(Hr,{asChild:!0,children:be(Yi,{className:"p-1.5",disabled:r,onClick:()=>n(),children:be(L0,{})})}),be(Vr,{side:"right",color:"black",children:e("editor.controls.actions.export.print")})]})]})]})}import{Fragment as jd,jsx as _e,jsxs as ct}from"react/jsx-runtime";var eu=({nodes:e,edges:t,validateDiagram:o,handleValidationComplete:n})=>{let{t:r}=D0(),{clearSelection:i}=xt(),{mode:s,isMinimapOpen:a,setIsMinimapOpen:l,isMoveTool:c,isHandTool:d,setIsMoveTool:u,setIsHandTool:p}=K(),{getNodes:f,getEdges:h}=R0(),g=Jd(["v","V"]),m=Jd(["h","H"]),b=Ui(()=>{i(),p(!0),u(!1)},[i,p,u]),T=Ui(()=>{u(!0),p(!1)},[u,p]),y=Ui(()=>{let E=f(),_=h(),N=o({nodes:E,edges:_});n(N)},[f,h,o,n]);return Qd(()=>{g&&!c&&s==="edit"&&T()},[g,T,c,s]),Qd(()=>{m&&!d&&s==="edit"&&b()},[m,b,d,s]),ct("div",{className:"flex items-center gap-2 px-3 py-2 bg-white rounded-sm shadow-md",children:[s==="edit"&&ct(jd,{children:[ct(Br,{children:[_e(Fr,{asChild:!0,children:_e(Gr,{size:"small",variant:"ghost",color:"grey",className:O(c&&"bg-grey-400"),iconButton:!0,onClick:T,children:_e(G0,{})})}),ct(zr,{color:"black",className:"flex items-center gap-2",children:[r("editor.controls.actions.move_tool"),_e(Fi,{shortcut:"V"})]})]}),ct(Br,{children:[_e(Fr,{asChild:!0,children:_e(Gr,{size:"small",variant:"ghost",color:"grey",className:O(d&&"bg-grey-400"),iconButton:!0,onClick:b,children:_e(O0,{})})}),ct(zr,{color:"black",className:"flex items-center gap-2",children:[r("editor.controls.actions.hand_tool")," ",_e(Fi,{shortcut:"H"})]})]})]}),_e(Zd,{}),s==="edit"&&ct(jd,{children:[ct(Br,{children:[_e(Fr,{asChild:!0,children:_e(Gr,{size:"small",variant:"ghost",color:"grey",iconButton:!0,onClick:y,children:_e(V0,{})})}),_e(zr,{color:"black",children:r("editor.controls.actions.check")})]}),_e(Xd,{disabled:e.length>0||t.length>0})]}),ct(Br,{children:[_e(Fr,{asChild:!0,children:_e(Gr,{size:"small",variant:"ghost",color:"grey",className:O(a&&"bg-grey-400"),iconButton:!0,onClick:()=>l(!a),children:_e(H0,{})})}),_e(zr,{color:"black",children:r(a?"editor.controls.actions.minimap.close":"editor.controls.actions.minimap.open")})]})]})};import{Button as tu,Tooltip as ou,TooltipContent as nu,TooltipTrigger as ru,useTranslation as B0}from"@produto-lecom/lecom-ui";import{RedoIcon as z0,UndoIcon as F0}from"lucide-react";import{jsx as Ct,jsxs as $i}from"react/jsx-runtime";var iu=({undo:e,redo:t,canUndo:o,canRedo:n})=>{let{t:r}=B0();return $i("div",{className:"flex items-center gap-2 px-3 py-2 bg-white rounded-sm shadow-md",children:[$i(ou,{children:[Ct(ru,{asChild:!0,children:Ct(tu,{size:"small",variant:"ghost",color:"grey",iconButton:!0,disabled:!o,onClick:e,children:Ct(F0,{})})}),Ct(nu,{color:"black",children:r("editor.controls.history.undo")})]}),$i(ou,{children:[Ct(ru,{asChild:!0,children:Ct(tu,{size:"small",variant:"ghost",color:"grey",iconButton:!0,disabled:!n,onClick:t,children:Ct(z0,{})})}),Ct(nu,{color:"black",children:r("editor.controls.history.redo")})]})]})};import{useEdges as W0,useNodes as Y0,useReactFlow as U0}from"@xyflow/react";import{Button as Wr,Tooltip as Yr,TooltipContent as Ur,TooltipTrigger as $r,useTranslation as $0}from"@produto-lecom/lecom-ui";import{ScanIcon as X0,ZoomIn as K0,ZoomOut as q0}from"lucide-react";import{jsx as Ce,jsxs as gn}from"react/jsx-runtime";var su=()=>{let{t:e}=$0(),t=Y0(),o=W0(),{zoomIn:n,zoomOut:r,zoomTo:i,fitView:s}=U0(),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(Yr,{children:[Ce($r,{asChild:!0,children:Ce(Wr,{iconButton:!0,size:"small",color:"grey",variant:"ghost",disabled:a,onClick:()=>s(),children:Ce(X0,{})})}),Ce(Ur,{color:"black",children:e("editor.controls.zoom.fit")})]}),gn(Yr,{children:[Ce($r,{asChild:!0,children:Ce(Wr,{iconButton:!0,size:"small",color:"grey",variant:"ghost",disabled:a,onClick:()=>r(),children:Ce(q0,{})})}),Ce(Ur,{color:"black",children:e("editor.controls.zoom.out")})]}),gn(Yr,{children:[Ce($r,{asChild:!0,children:Ce(Wr,{iconButton:!0,size:"small",color:"grey",variant:"ghost",disabled:a,onClick:()=>i(1),children:Ce(ds,{})})}),Ce(Ur,{color:"black",children:e("editor.controls.zoom.reset")})]}),gn(Yr,{children:[Ce($r,{asChild:!0,children:Ce(Wr,{iconButton:!0,size:"small",color:"grey",variant:"ghost",disabled:a,onClick:()=>n(),children:Ce(K0,{})})}),Ce(Ur,{color:"black",children:e("editor.controls.zoom.in")})]})]})};import{useNodes as Z0}from"@xyflow/react";import{Button as J0,Tooltip as Q0,TooltipContent as j0,TooltipTrigger as ex,useTranslation as tx}from"@produto-lecom/lecom-ui";import{useRef as ox,useState as nx}from"react";import{jsx as Wt,jsxs as au}from"react/jsx-runtime";var lu=()=>{let e=ox(null),{t}=tx(),{setDraggableNode:o}=ho(),n=Z0(),{setIsDragging:r}=K(),[i,s]=nx(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:gs,label:t("bpmn.task.variant.subprocess")},{type:"TASK",variant:"SCRIPT",icon:ms,label:t("bpmn.task.variant.script")},{type:"TASK",attribute:"LOOP",icon:fs,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:cs,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 au("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=!yt(c.type,n),p=u?t("editor.toolbar.start_event_already_exists"):c.label;return au(Q0,{children:[Wt(ex,{asChild:!0,children:Wt(J0,{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(j0,{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 Xr}from"react/jsx-runtime";var Xi=cx((e,t)=>{let o=lx("Space"),{instanceId:n,mode:r,isMinimapOpen:i,isMoveTool:s,isHandTool:a}=K(),{nodes:l,edges:c,actions:d,events:u,components:p,controls:f}=Pd(),{t:h}=mx();dx(t,()=>({selectElements:d.selectElements,clearSelection:d.clearSelection}));let g=a||o||r!=="edit"?!0:Jc,m=r!=="readonly"&&s&&!o,b=r==="edit"&&s&&!o,T=r==="edit"&&s&&!o;return Xr("div",{className:"w-full h-full",children:[r==="edit"&&Ke(lu,{}),Ke(kd,{}),Xr(sx,v(x({},u),{id:`modeler-${n}`,className:O({"is-hand-tool":a||o}),edges:c,nodes:l,nodeTypes:Fc,edgeTypes:Wc,minZoom:Gi,maxZoom:qc,panOnDrag:g,panOnScroll:!0,selectionOnDrag:!0,elevateEdgesOnSelect:!0,elevateNodesOnSelect:!1,elementsSelectable:m,nodesConnectable:b,nodesDraggable:T,connectionLineComponent:Hc,selectionMode:ax.Partial,multiSelectionKeyCode:["Control","Meta"],deleteKeyCode:"Delete",selectionKeyCode:null,defaultViewport:Zc,connectOnClick:!1,connectionRadius:50,proOptions:{hideAttribution:!0},children:[Ke(rx,{gap:Xc,size:$c,color:Uc,bgColor:Yc}),i&&Xr(ux,{children:[Ke(fx,{asChild:!0,children:Ke("div",{className:"absolute bottom-[0px] left-[0px] z-[5]",children:Ke(ix,{pannable:!0,zoomable:!0,position:Kc,className:"shadow-md rounded-md",ariaLabel:"",style:{pointerEvents:"all",position:"relative"}})})}),Ke(px,{color:"black",children:h("editor.controls.actions.minimap.label")})]}),Xr("div",{className:"absolute z-10 bottom-4 left-1/2 -translate-x-1/2 flex gap-4",children:[r==="edit"&&Ke(iu,x({},f)),Ke(eu,{nodes:l,edges:c,validateDiagram:d.validateDiagram,handleValidationComplete:d.handleValidationComplete}),Ke(su,{})]}),Ke(p.HelperLines,{})]}))]})});Xi.displayName="Editor";import{useStore as gx}from"@xyflow/react";import{useEffect as hx,useRef as yx}from"react";import{jsx as Ex}from"react/jsx-runtime";var xx=e=>({width:e.width,height:e.height,transform:e.transform}),Ki="rgba(51, 103, 217, 0.4)",pl=({horizontal:e,vertical:t})=>{let{width:o,height:n,transform:r}=gx(xx),i=yx(null);return hx(()=>{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=Ki,t&&(a.beginPath(),a.strokeStyle=t.color||Ki,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||Ki,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]),Ex("canvas",{ref:i,className:"w-full h-full absolute z-10 pointer-events-none"})};import{i18n as bx,Notification as _x,TooltipProvider as Tx}from"@produto-lecom/lecom-ui";import{createContext as Nx,useContext as vx,useEffect as wx,useState as Ax}from"react";import{jsx as cu,jsxs as Cx}from"react/jsx-runtime";var tt=new Map,du=Nx(null),Xo=()=>{let e=vx(du);if(!e)throw new Error("useModeler must be used within an <ModelerProvider />");return e},Ix=({locale:e,defaultMode:t="view",toast:o,children:n})=>{let[r,i]=Ax(e||"pt_BR");wx(()=>{e&&(i(e),bx.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[b]=tt.values();return b}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 cu(du.Provider,{value:{defaultMode:t,locale:r,selectElements:a,clearSelection:l,configureElement:c,getConfigureElement:d,importDiagram:u,exportDiagram:p,getElementsCount:f,toast:o},children:Cx(Tx,{children:[!o&&cu(_x,{type:"toast",placement:"topRight",enableClose:!0,showProgress:!0,pauseOnHover:!0}),n]})})};import{useTranslation as Dx}from"@produto-lecom/lecom-ui";import{jsx as qi}from"react/jsx-runtime";var uu=Mx(null),K=()=>{let e=Px(uu);if(!e)throw new Error("useModelerInstance must be used within an <Modeler />");return e},Ox=({selectorRef:e,initialDiagram:t,instanceId:o,mode:n,onElementChanges:r,onConfigureElement:i,onElementClick:s,onSubprocessValidationClick:a})=>{let{t:l}=Dx(),{defaultMode:c}=Xo(),d=kx(),[u]=qe(o||d),[p,f]=qe(n||c||"edit"),[h,g]=qe(nn),[m,b]=qe(!1),[T,y]=qe(!0),[E,_]=qe(!1),[N,w]=qe(!1),[A,P]=qe(!1),[B,S]=qe(!1),[D,Q]=qe(!1),[I,R]=qe(null);Lx(()=>{n&&f(n)},[n]);let L=Rx(()=>t||ic(l),[t,l]),M={instanceId:u,initialDiagram:L,mode:p,lastElementId:h,isInitialized:m,isMinimapOpen:N,isMoveTool:T,isHandTool:E,isDragging:A,isMultipleSelection:D,isConnecting:B,setLastElementId:g,setIsInitialized:b,reconnectingEdgeId:I,setIsMinimapOpen:w,setIsMoveTool:y,setIsHandTool:_,setIsDragging:P,setIsConnecting:S,setIsMultipleSelection:Q,setReconnectingEdgeId:R,onElementChanges:r,onConfigureElement:i,onElementClick:s,onSubprocessValidationClick:a};return qi(Sx,{children:qi(uu.Provider,{value:M,children:qi(Xi,{ref:e})})})};export{Le as EditorMode,Zr as ElementPosition,yn as ElementType,Jr as GatewayElementVariant,$e as GatewayVariant,Ox as Modeler,Ix as ModelerProvider,Qe as NodeAttribute,ee as NodeType,Ue as NodeVariant,Qr as RoutingVariant,Xo as useModeler};
|