lecom-modeler 0.7.1 → 0.7.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/lib/index.js CHANGED
@@ -1,7 +1,7 @@
1
- var sd=Object.defineProperty,ad=Object.defineProperties;var ld=Object.getOwnPropertyDescriptors;var co=Object.getOwnPropertySymbols;var Vr=Object.prototype.hasOwnProperty,Or=Object.prototype.propertyIsEnumerable;var Rr=(e,t,o)=>t in e?sd(e,t,{enumerable:!0,configurable:!0,writable:!0,value:o}):e[t]=o,_=(e,t)=>{for(var o in t||(t={}))Vr.call(t,o)&&Rr(e,o,t[o]);if(co)for(var o of co(t))Or.call(t,o)&&Rr(e,o,t[o]);return e},v=(e,t)=>ad(e,ld(t));var Ee=(e,t)=>{var o={};for(var n in e)Vr.call(e,n)&&t.indexOf(n)<0&&(o[n]=e[n]);if(e!=null&&co)for(var n of co(e))t.indexOf(n)<0&&Or.call(e,n)&&(o[n]=e[n]);return o};var Rn=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 cd,Translations as dd}from"lecom-ui";var Hr={translations:{general:{layout:{title:"Modeler"}},editor:{toolbar:{delete:"Delete",configure_node:"Configure activity",configure_edge:"Configure routing",initial_task:"Initial Activity",gateway_limit_reached:"Exclusive gateway cannot have more than 2 outgoing connections",task_limit_reached:"Task cannot have more than 2 outgoing connections",gateway_to_gateway_not_allowed:"Gateways cannot connect directly to other gateways",start_event_already_exists:"A start event already exists. Delete the current event to add another",script_to_end_not_allowed:"Script activities cannot connect directly to the end event",loop_to_end_not_allowed:"Loop activities cannot connect directly to the end event",initial_activity_to_end_not_allowed:"Initial activity cannot connect directly to the end event",final_activity_cannot_connect:"Final activity cannot connect to other elements",activity_has_outgoing_connections:"Activity with outgoing connections cannot connect to end event",end_event_cannot_connect_to_initial_activity:"End event cannot connect to an initial activity",initial_activity_cannot_connect_to_start_event:"Initial activity cannot connect to start event",connect_node:"Connect element",connecting:"Connecting..."},controls:{zoom:{fit:"Fit zoom",in:"Zoom in",out:"Zoom out",reset:"Reset zoom"},actions:{move_tool:"Select elements",hand_tool:"Navigate the diagram",check:"Check diagram",export:{title:"Export diagram",print:"Print",html:"Export as HTML",png:"Export as PNG",feedback:{error:"Error exporting diagram"}},import_governance:"Import diagram from Governance platform",minimap:{open:"Open minimap",close:"Hide minimap"}},history:{undo:"Undo",redo:"Redo"}},modals:{delete_elements:{title:"Delete elements",callout:"When deleting, the activity and routing settings will be deleted.",content:"Are you sure you want to delete?",confirm:"Delete",cancel:"Cancel"}},task_menu:{loop_not_allowed_when_connected_to_end:"Cannot create loop on activity connected to end event",script_not_allowed_when_connected_to_end:"Cannot transform to Script activity connected to end event",loop_not_allowed_when_subprocess:"Cannot create loop on subprocess"}},validation:{success:{title:"Validation Successful",message:"The diagram was validated successfully with no errors."},errors:{title:"The diagram contains errors",subtitle:"Please review the following:",task_label_length:"Task name exceeds the maximum character limit",multiple_start_event_not_allowed:"Multiple start events are not allowed",task_flows_limit_exceeds:"The number of output connections exceeds the limit of two",duplicate_task_name:"There are multiple activities with the same name",flows_on_end_tasks_not_allowed:"Activities connected to end events cannot have other connections",conditions_flows_limit_exceeds:"Exclusive gateway has too many output connections (maximum of two)",task_label_empty:"One or more activities have no name",activity_name_invalid:"Activity name is invalid",final_activity_has_loop:"Final activities cannot have loops",nested_gateway:"Connecting gateways directly is not allowed",concurrent_initial_and_final_event:"The same activity cannot have both initial and final events",gateway_flow_to_event:"Connecting a gateway to an output event is not allowed",gateway_missing_output_streams:"The gateway does not have the correct number of outputs",events_nested:"Connecting events directly is not allowed",event_to_condition:"Connecting an event directly to a gateway is not allowed",script_in_final_activity:"Final activity cannot be a script type",subprocess_referenced_not_configured:"The subprocess reference is not properly configured",start_event_not_found:"At least one start event is required",end_event_not_found:"At least one end event is required"}},bpmn:{start_event:{variant:{default:"Start event"}},end_event:{variant:{default:"End event"}},annotation:{variant:{default:"Annotation"}},gateway:{menu:{title:"Change gateway type"},variant:{default:"Gateway",exclusive:"Exclusive gateway",parallel:"Parallel gateway",complex:"Complex gateway"}},task:{menu:{title:"Change task type"},variant:{default:"Task",script:"Script task",subprocess:"Subprocess"},attribute:{loop:"Task with loop"},label:{prefix:"Activity"}},lane:{variant:{default:"Pool / Lane"}},unsupported:{variant:{default:"Unsupported element"}}},adapter:{governance:{error:{DEFAULT:"Error importing diagram",NO_FILE:"No file selected",EMPTY_FILE:"Empty file",INVALID_FILE:"Invalid file",CONTAIN_NO_CELLS:"No cells found to be imported",ALREADY_INITIALIZED:"It is not possible to import the diagram from the Governance platform, since the diagram has already been initialized"},success:{default:"The diagram was imported from the Governance platform successfully and without any incompatibility detected.",incompatible_cells:"The diagram was imported from the Governance platform with incompatibilities. To know more details, click on the button below."},report:{columns:{type:"Type",value:"Value",status:"Status"},status:{imported:"Imported",adapted:"Adapted",unsupported:"Unsupported"}},action:{download:"Download report"}}}}};var Gr={translations:{general:{layout:{title:"Modeler"}},editor:{toolbar:{delete:"Eliminar",configure_node:"Configurar actividad",configure_edge:"Configurar enrutamiento",initial_task:"Actividad Inicial",gateway_limit_reached:"Compuerta exclusiva no puede tener m\xE1s de 2 conexiones de salida",task_limit_reached:"Actividad no puede tener m\xE1s de 2 conexiones de salida",gateway_to_gateway_not_allowed:"Las compuertas no pueden conectarse directamente con otras compuertas",start_event_already_exists:"Ya existe un evento de inicio. Elimine el evento actual para agregar otro",script_to_end_not_allowed:"Las actividades Script no pueden conectarse directamente al evento final",loop_to_end_not_allowed:"Las actividades Loop no pueden conectarse directamente al evento final",initial_activity_to_end_not_allowed:"Actividad inicial no puede conectarse directamente al evento final",final_activity_cannot_connect:"Actividad final no puede conectarse a otros elementos",activity_has_outgoing_connections:"Actividad con conexiones de salida no puede conectarse al evento final",end_event_cannot_connect_to_initial_activity:"El evento final no puede conectarse a una actividad inicial",initial_activity_cannot_connect_to_start_event:"Actividad inicial no puede conectarse a evento de inicio",connect_node:"Conectar elemento",connecting:"Conectando..."},controls:{zoom:{fit:"Ajustar zoom",in:"Acercar",out:"Alejar",reset:"Restablecer zoom"},actions:{move_tool:"Seleccionar elementos",hand_tool:"Navegar por el diagrama",check:"Verificar diagrama",export:{title:"Exportar diagrama",print:"Imprimir",html:"Exportar como HTML",png:"Exportar como PNG",feedback:{error:"Error al exportar diagrama"}},import_governance:"Importar diagrama de la plataforma Governance",minimap:{open:"Abrir minimapa",close:"Ocultar minimapa"}},history:{undo:"Deshacer",redo:"Rehacer"}},modals:{delete_elements:{title:"Eliminar elementos",callout:"Al eliminar, las configuraciones de actividades y enrutamiento ser\xE1n eliminadas.",content:"\xBFEst\xE1s seguro de querer eliminar?",confirm:"Eliminar",cancel:"Cancelar"}},task_menu:{loop_not_allowed_when_connected_to_end:"No se puede crear bucle en actividad conectada al evento final",script_not_allowed_when_connected_to_end:"No se puede transformar a Script actividad conectada al evento final",loop_not_allowed_when_subprocess:"No se puede crear bucle en subproceso"}},validation:{success:{title:"Validaci\xF3n exitosa",message:"El diagrama ha sido validado correctamente sin errores."},errors:{title:"El diagrama contiene errores",subtitle:"Revise lo siguiente:",task_label_length:"El nombre de la actividad excede el l\xEDmite m\xE1ximo de caracteres",multiple_start_event_not_allowed:"No se permite tener m\xE1s de un evento de inicio",task_flows_limit_exceeds:"El n\xFAmero de conexiones de salida supera el l\xEDmite de dos",duplicate_task_name:"Hay varias actividades con el mismo nombre",flows_on_end_tasks_not_allowed:"Las actividades conectadas a eventos finales no pueden tener otras conexiones",conditions_flows_limit_exceeds:"Compuerta exclusiva con exceso de conexiones de salida (m\xE1ximo de dos)",task_label_empty:"El nombre de una o m\xE1s actividades no ha sido completado",activity_name_invalid:"El nombre de la actividad no es v\xE1lido",final_activity_has_loop:"Las actividades finales no pueden tener bucles",nested_gateway:"No se permite conectar compuertas directamente",concurrent_initial_and_final_event:"Una misma actividad no puede tener eventos iniciales y finales",gateway_flow_to_event:"No se permite conectar una compuerta a un evento de salida",gateway_missing_output_streams:"La compuerta no tiene el n\xFAmero correcto de salidas",events_nested:"No se permite conectar eventos directamente",event_to_condition:"No se permite conectar un evento directamente a una compuerta",script_in_final_activity:"La actividad final no puede ser de tipo script",subprocess_referenced_not_configured:"La referencia al subproceso no est\xE1 configurada correctamente",start_event_not_found:"Es necesario tener al menos un evento de inicio",end_event_not_found:"Es necesario tener al menos un evento final"}},bpmn:{start_event:{variant:{default:"Evento de inicio"}},end_event:{variant:{default:"Evento final"}},annotation:{variant:{default:"Anotaci\xF3n"}},gateway:{menu:{title:"Cambiar tipo de compuerta"},variant:{default:"Compuerta",exclusive:"Compuerta exclusiva",parallel:"Compuerta paralela",complex:"Compuerta compleja"}},task:{menu:{title:"Cambiar tipo de tarea"},variant:{default:"Tarea",script:"Tarea de script",subprocess:"Subproceso"},attribute:{loop:"Tarea con bucle"},label:{prefix:"Actividad"}},lane:{variant:{default:"Piscina / Raia"}},unsupported:{variant:{default:"Elemento no soportado"}}},adapter:{governance:{error:{DEFAULT:"Error al importar diagrama",NO_FILE:"No se ha seleccionado ning\xFAn archivo",EMPTY_FILE:"Archivo vac\xEDo",INVALID_FILE:"Archivo inv\xE1lido",CONTAIN_NO_CELLS:"No se encontraron c\xE9lulas para importar",ALREADY_INITIALIZED:"No es posible importar el diagrama de la plataforma Governance, ya que el diagrama ya ha sido iniciado"},success:{default:"El diagrama se ha importado de la plataforma Governance correctamente y sin ninguna incompatibilidad detectada.",incompatible_cells:"El diagrama se ha importado de la plataforma Governance con incompatibilidades. Para saber m\xE1s detalles, haz click en el bot\xF3n de abajo."},report:{columns:{type:"Tipo",value:"Valor",status:"Estado"},status:{imported:"Importado",adapted:"Adaptado",unsupported:"No soportado"}},action:{download:"Descargar informe"}}}}};var Br={translations:{general:{layout:{title:"Modeler"}},editor:{toolbar:{delete:"Excluir",configure_node:"Configurar atividade",configure_edge:"Configurar roteamento",initial_task:"Atividade Inicial",gateway_limit_reached:"Gateway exclusivo n\xE3o pode ter mais de 2 conex\xF5es de sa\xEDda",task_limit_reached:"Atividade n\xE3o pode ter mais de 2 conex\xF5es de sa\xEDda",gateway_to_gateway_not_allowed:"Gateways n\xE3o podem se conectar diretamente com outros gateways",start_event_already_exists:"J\xE1 existe um evento de in\xEDcio. Exclua o evento atual para adicionar outro",script_to_end_not_allowed:"Atividades Script n\xE3o podem se conectar diretamente ao evento final",loop_to_end_not_allowed:"Atividades Loop n\xE3o podem se conectar diretamente ao evento final",initial_activity_to_end_not_allowed:"Atividade inicial n\xE3o pode se conectar diretamente ao evento final",final_activity_cannot_connect:"Atividade final n\xE3o pode se conectar a outros elementos",activity_has_outgoing_connections:"Atividade com conex\xF5es de sa\xEDda n\xE3o pode se conectar a um evento final",end_event_cannot_connect_to_initial_activity:"O evento final n\xE3o pode ser conectado a uma atividade inicial",initial_activity_cannot_connect_to_start_event:"Atividade inicial n\xE3o pode se conectar a evento de in\xEDcio",connect_node:"Conectar elemento",connecting:"Conectando..."},controls:{zoom:{fit:"Ajustar o zoom",in:"Aumentar o zoom",out:"Diminuir o zoom",reset:"Resetar o zoom"},actions:{move_tool:"Selecionar elementos",hand_tool:"Navegar pelo diagrama",check:"Verificar diagrama",export:{title:"Exportar diagrama",print:"Imprimir",html:"Exportar como HTML",png:"Exportar como PNG",feedback:{error:"Erro ao exportar o diagrama"}},import_governance:"Importar diagrama da plataforma Governance",minimap:{open:"Abrir minimapa",close:"Ocultar minimapa"}},history:{undo:"Desfazer",redo:"Refazer"}},modals:{delete_elements:{title:"Excluir elementos",callout:"Ao excluir, as configura\xE7\xF5es de atividades e roteamento ser\xE3o exclu\xEDdas.",content:"Deseja realmente excluir?",confirm:"Excluir",cancel:"Cancelar"}},task_menu:{loop_not_allowed_when_connected_to_end:"N\xE3o \xE9 poss\xEDvel criar loop em atividade conectada ao evento final",script_not_allowed_when_connected_to_end:"N\xE3o \xE9 poss\xEDvel transformar em Script atividade conectada ao evento final",loop_not_allowed_when_subprocess:"N\xE3o \xE9 poss\xEDvel criar loop em subprocesso"}},validation:{success:{title:"Diagrama v\xE1lidado com sucesso!",message:"Nenhum erro encontrado."},errors:{title:"O diagrama cont\xE9m erros",subtitle:"Veja abaixo o que precisa ser corrigido:",task_label_length:"O nome da atividade excede o limite m\xE1ximo de caracteres",multiple_start_event_not_allowed:"N\xE3o \xE9 permitido ter mais de um evento de in\xEDcio",task_flows_limit_exceeds:"O n\xFAmero de conex\xF5es de sa\xEDda ultrapassa o limite de dois",duplicate_task_name:"H\xE1 v\xE1rias atividades com o mesmo nome",flows_on_end_tasks_not_allowed:"Atividades conectadas a eventos finais n\xE3o podem ter outras conex\xF5es",conditions_flows_limit_exceeds:"Gateway exclusivo com excesso de conex\xF5es de sa\xEDda (m\xE1ximo de dois)",task_label_empty:"O nome de uma ou mais atividades n\xE3o foi preenchido",activity_name_invalid:"O nome da atividade n\xE3o \xE9 v\xE1lido",final_activity_has_loop:"Atividades finais n\xE3o podem ter loops",nested_gateway:"N\xE3o \xE9 permitido conectar gateways",concurrent_initial_and_final_event:"Uma mesma atividade n\xE3o pode ter eventos iniciais e finais",gateway_flow_to_event:"N\xE3o \xE9 permitido conectar um gateway a um evento de sa\xEDda",gateway_missing_output_streams:"O gateway n\xE3o possui o n\xFAmero correto de sa\xEDdas",events_nested:"N\xE3o \xE9 permitido conectar eventos",event_to_condition:"N\xE3o \xE9 permitido conectar um evento diretamente em um gateway",script_in_final_activity:"Atividade final n\xE3o pode ser do tipo script",subprocess_referenced_not_configured:"A refer\xEAncia ao subprocesso n\xE3o est\xE1 configurada corretamente",start_event_not_found:"\xC9 necess\xE1rio ter ao menos um evento inicial",end_event_not_found:"\xC9 necess\xE1rio ter ao menos um evento final"}},bpmn:{start_event:{variant:{default:"Evento inicial"}},end_event:{variant:{default:"Evento final"}},annotation:{variant:{default:"Anota\xE7\xE3o"}},gateway:{menu:{title:"Alterar tipo de gateway"},variant:{default:"Gateway",exclusive:"Gateway exclusivo",parallel:"Gateway paralelo",complex:"Gateway complexo"}},task:{menu:{title:"Alterar tipo de tarefa"},variant:{default:"Tarefa",script:"Tarefa de script",subprocess:"Subprocesso"},attribute:{loop:"Tarefa com loop"},label:{prefix:"Atividade"}},lane:{variant:{default:"Piscina / Raia"}},unsupported:{variant:{default:"Elemento n\xE3o suportado"}}},adapter:{governance:{error:{DEFAULT:"Erro ao importar diagrama",NO_FILE:"Nenhum arquivo selecionado",EMPTY_FILE:"Arquivo vazio",INVALID_FILE:"Arquivo inv\xE1lido",CONTAIN_NO_CELLS:"N\xE3o foram encontradas c\xE9lulas para serem importadas",ALREADY_INITIALIZED:"N\xE3o \xE9 poss\xEDvel importar o diagrama da plataforma Governance, pois o diagrama j\xE1 foi iniciado"},success:{default:"O diagrama foi importado da plataforma Governance com sucesso e sem nenhuma incompatibilidade detectada.",incompatible_cells:"O diagrama foi importado da plataforma Governance com incompatibilidades. Para saber mais detalhes, clique no bot\xE3o abaixo."},report:{columns:{type:"Tipo do elemento",value:"Valor",status:"Status"},status:{imported:"Importado",adapted:"Adaptado",unsupported:"N\xE3o suportado"}},action:{download:"Baixar relat\xF3rio"}}}}};var zr={pt_BR:Br,en_US:Hr,es_ES:Gr};var Fr,Wr,ud=(Wr=(Fr=Rn("LecomUserLanguage"))!=null?Fr:Rn("org.springframework.web.servlet.i18n.CookieLocaleResolver.LOCALE"))!=null?Wr:dd.PT_BR;cd({lng:ud,resources:zr});var uo=(r=>(r.ACTIVITY="activity",r.ROUTING="routing",r.GATEWAY="gateway",r.SUB_PROCESS="sub_process",r))(uo||{}),Vn=(n=>(n.START="start",n.END="end",n.BETWEEN="between",n))(Vn||{}),On=(n=>(n.SCRIPT="script",n.LOOP="loop",n.SCRIPT_LOOP="script_loop",n))(On||{}),Hn=(c=>(c.SIMPLE="simple",c.LOOP="loop",c.SCRIPT="script",c.SCRIPT_LOOP="script_loop",c.COMPLEX="complex",c.EXCLUSIVE="exclusive",c.PARALLEL="parallel",c.FINAL="final",c.TO_SUB_PROCESS="to_sub_process",c))(Hn||{});import{RotateCcw as vd,ScrollText as Nd,SquarePlus as wd}from"lucide-react";import{jsx as po,jsxs as pd}from"react/jsx-runtime";var fo=({size:e=24,className:t})=>pd("svg",{width:e,height:e,viewBox:"0 0 24 24",xmlns:"http://www.w3.org/2000/svg",fill:"#6b7280",className:t,children:[po("path",{strokeWidth:"2",d:"M16 3V3.5085V11.9998V20.4915V21H16.5411H21.4592H22V19.123H21.4592H17.9974V11.9998V4.8773H21.4592H22V3H21.4592H16.5411H16Z"}),po("path",{d:"M4.41026 16.9999L2 18.7861L3.89693 21.1103L6.3072 19.324L4.41026 16.9999Z"}),po("path",{d:"M8.41026 13.9999L6 15.7861L7.89693 18.1103L10.3072 16.324L8.41026 13.9999Z"}),po("path",{d:"M12.4313 10.954L10.021 12.7402L11.9179 15.0644L14.3282 13.2781L12.4313 10.954Z"})]});import{jsx as Ur}from"react/jsx-runtime";var nt=({size:e=24,className:t})=>Ur("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:Ur("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 St,jsxs as fd}from"react/jsx-runtime";var rt=({size:e=24,className:t})=>fd("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:[St("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"}),St("path",{d:"M12 8V16",strokeLinecap:"round",strokeLinejoin:"round"}),St("path",{d:"M8 12H16",strokeLinecap:"round",strokeLinejoin:"round"}),St("path",{d:"M9.17139 9.17188L14.8282 14.8287",strokeLinecap:"round",strokeLinejoin:"round"}),St("path",{d:"M14.8281 9.17188L9.17127 14.8287",strokeLinecap:"round",strokeLinejoin:"round"})]});import{jsx as Gn,jsxs as md}from"react/jsx-runtime";var it=({size:e=24,className:t})=>md("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:[Gn("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"}),Gn("path",{d:"M14.8286 9.17188L9.17176 14.8287",strokeLinecap:"round",strokeLinejoin:"round"}),Gn("path",{d:"M9.17139 9.17188L14.8282 14.8287",strokeLinecap:"round",strokeLinejoin:"round"})]});import{jsx as Bn,jsxs as gd}from"react/jsx-runtime";var st=({size:e=24,className:t})=>gd("svg",{width:e,height:e,viewBox:"0 0 24 24",xmlns:"http://www.w3.org/2000/svg",fill:"white",stroke:"#6b7280",strokeWidth:2,className:t,children:[Bn("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"}),Bn("path",{d:"M12 8V16",strokeLinecap:"round",strokeLinejoin:"round"}),Bn("path",{d:"M8 12H16",strokeLinecap:"round",strokeLinejoin:"round"})]});import{jsx as zn,jsxs as hd}from"react/jsx-runtime";var Yr=({size:e=24,className:t})=>zn("svg",{width:e,height:e,viewBox:"0 0 34 24",xmlns:"http://www.w3.org/2000/svg",fill:"currentColor",className:t,children:hd("g",{children:[zn("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"}),zn("path",{d:"M24.5 4.5L28 1M28 1L31.5 4.5M28 1V8",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round"})]})});import{clsx as yd}from"clsx";import{twMerge as xd}from"tailwind-merge";function P(...e){return xd(yd(e))}var Pe=(e=0,t=0)=>e<t?t:e,$r=(e=1e3)=>new Promise(t=>{setTimeout(t,e)});import{jsx as Xr,jsxs as Ed}from"react/jsx-runtime";var Kr=({size:e=24,className:t})=>Ed("svg",{width:e,height:e,viewBox:"0 0 24 24",fill:"none",stroke:"#6b7280",strokeWidth:2,xmlns:"http://www.w3.org/2000/svg",className:P("stroke-2",t),children:[Xr("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"}),Xr("path",{d:"M9 3V21",strokeLinecap:"round",strokeLinejoin:"round"})]});import{jsx as Fn}from"react/jsx-runtime";var qr=({size:e=24,className:t})=>Fn("svg",{width:e,height:e,viewBox:"0 0 24 24",xmlns:"http://www.w3.org/2000/svg",stroke:"currentColor",className:t,children:Fn("g",{children:Fn("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 Zr}from"react/jsx-runtime";var mo=({size:e=24,className:t})=>Zr("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:Zr("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 Jr}from"react/jsx-runtime";var Mt=({size:e=24,className:t})=>Jr("svg",{width:e,height:e,viewBox:"0 0 24 24",xmlns:"http://www.w3.org/2000/svg",fill:"white",stroke:"#6b7280",className:P("stroke-2",t),children:Jr("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 Wn,jsxs as _d}from"react/jsx-runtime";var Qr=({size:e=24,className:t})=>_d("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:[Wn("path",{d:"M20 3H4C2.89543 3 2 4.34315 2 6V18C2 19.6569 2.89543 21 4 21H20C21.1046 21 22 19.6569 22 18V6C22 4.34315 21.1046 3 20 3Z",strokeLinecap:"round",strokeLinejoin:"round"}),Wn("path",{d:"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"}),Wn("path",{d:"M7.5 7.5V10H10",strokeWidth:"1.5",fill:"none",strokeLinecap:"round",strokeLinejoin:"round"})]});import{jsx as Pt,jsxs as bd}from"react/jsx-runtime";var jr=({size:e=24,className:t})=>bd("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:[Pt("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"}),Pt("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"}),Pt("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"}),Pt("path",{d:"M13.5 12H11",strokeWidth:"1",strokeLinecap:"round",strokeLinejoin:"round"}),Pt("path",{d:"M13.5 10H11",strokeWidth:"1",strokeLinecap:"round",strokeLinejoin:"round"})]});import{jsx as go,jsxs as Td}from"react/jsx-runtime";var ei=({size:e=24,className:t})=>Td("svg",{width:e,height:e,viewBox:"0 0 24 24",xmlns:"http://www.w3.org/2000/svg",fill:"white",stroke:"#6b7280",strokeWidth:2,className:t,children:[go("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"}),go("path",{d:"M8 21V14C8 13.4477 8.44772 13 9 13H15C15.5523 13 16 13.4477 16 14V21",strokeWidth:"1",fill:"none"}),go("path",{d:"M10.2222 17H13.7777",strokeWidth:"1",strokeLinecap:"round",strokeLinejoin:"round"}),go("path",{d:"M12 15.2227V18.7782",strokeWidth:"1",strokeLinecap:"round",strokeLinejoin:"round"})]});var k=(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))(k||{}),me=(o=>(o.SCRIPT="SCRIPT",o.SUBPROCESS="SUBPROCESS",o))(me||{}),ho={SCRIPT:{icon:Nd},SUBPROCESS:{icon:wd}},Le=(t=>(t.LOOP="LOOP",t))(Le||{}),yo={LOOP:{icon:vd}},ge=(n=>(n.EXCLUSIVE="EXCLUSIVE",n.PARALLEL="PARALLEL",n.COMPLEX="COMPLEX",n))(ge||{}),Un={EXCLUSIVE:{icon:it},PARALLEL:{icon:st},COMPLEX:{icon:rt}};import{ReactFlowProvider as ly}from"@xyflow/react";import{createContext as cy,useContext as dy,useEffect as Hc,useId as uy,useState as Se}from"react";import{applyNodeChanges as L0,Background as k0,MiniMap as D0,ReactFlow as R0,SelectionMode as V0,useEdgesState as O0,useNodesState as H0,useOnSelectionChange as G0,useReactFlow as B0}from"@xyflow/react";import{i18n as z0}from"lecom-ui";import{forwardRef as F0,useCallback as Dn,useEffect as Rc,useImperativeHandle as W0,useRef as U0,useState as Y0}from"react";import{useDebouncedCallback as $0}from"use-debounce";import{v7 as wr}from"uuid";import{create as Ad}from"zustand";import{useReactFlow as Cd}from"@xyflow/react";import{useCallback as Id}from"react";var xo=()=>{let{setEdges:e}=Cd();return Id(()=>{let o=Fe.getState().pathEdgeIds;e(n=>n.map(r=>v(_({},r),{selected:o.includes(r.id)})))},[e])},Fe=Ad((e,t)=>({statusByNodeId:{},statusData:{},pathEdgeIds:[],setTaskStatuses:o=>{o!=null&&o.length&&e(n=>{let r=_({},n.statusByNodeId),i=_({},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,f)=>{let u=[],p=new Set;for(u.push({node:d,path:[]}),p.add(d);u.length>0;){let{node:h,path:m}=u.shift();if(h===f)return m;let g=s[h]||[];for(let{targetId:T,edgeId:x}of g)p.has(T)||(p.add(T),u.push({node:T,path:[...m,x]}))}return[]};for(let d=0;d<r.length-1;d++){let f=r[d],u=r[d+1],p=c(f,u);p.length>0&&i.push(...p)}i.length>0&&e({pathEdgeIds:i})}}));import{useNodesInitialized as Wp,useReactFlow as Up,useStore as Yp}from"@xyflow/react";var Sd={value:()=>{}};function oi(){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 Eo(o)}function Eo(e){this._=e}function Md(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}})}Eo.prototype=oi.prototype={constructor:Eo,on:function(e,t){var o=this._,n=Md(e+"",o),r,i=-1,s=n.length;if(arguments.length<2){for(;++i<s;)if((r=(e=n[i]).type)&&(r=Pd(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]=ti(o[r],e.name,t);else if(t==null)for(r in o)o[r]=ti(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 Eo(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 Pd(e,t){for(var o=0,n=e.length,r;o<n;++o)if((r=e[o]).name===t)return r.value}function ti(e,t,o){for(var n=0,r=e.length;n<r;++n)if(e[n].name===t){e[n]=Sd,e=e.slice(0,n).concat(e.slice(n+1));break}return o!=null&&e.push({name:t,value:o}),e}var Yn=oi;var _o="http://www.w3.org/1999/xhtml",$n={svg:"http://www.w3.org/2000/svg",xhtml:_o,xlink:"http://www.w3.org/1999/xlink",xml:"http://www.w3.org/XML/1998/namespace",xmlns:"http://www.w3.org/2000/xmlns/"};function Ne(e){var t=e+="",o=t.indexOf(":");return o>=0&&(t=e.slice(0,o))!=="xmlns"&&(e=e.slice(o+1)),$n.hasOwnProperty(t)?{space:$n[t],local:e}:e}function Ld(e){return function(){var t=this.ownerDocument,o=this.namespaceURI;return o===_o&&t.documentElement.namespaceURI===_o?t.createElement(e):t.createElementNS(o,e)}}function kd(e){return function(){return this.ownerDocument.createElementNS(e.space,e.local)}}function bo(e){var t=Ne(e);return(t.local?kd:Ld)(t)}function Dd(){}function We(e){return e==null?Dd:function(){return this.querySelector(e)}}function ni(e){typeof e!="function"&&(e=We(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 Y(n,this._parents)}function Xn(e){return e==null?[]:Array.isArray(e)?e:Array.from(e)}function Rd(){return[]}function Lt(e){return e==null?Rd:function(){return this.querySelectorAll(e)}}function Vd(e){return function(){return Xn(e.apply(this,arguments))}}function ri(e){typeof e=="function"?e=Vd(e):e=Lt(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 Y(n,r)}function kt(e){return function(){return this.matches(e)}}function To(e){return function(t){return t.matches(e)}}var Od=Array.prototype.find;function Hd(e){return function(){return Od.call(this.children,e)}}function Gd(){return this.firstElementChild}function ii(e){return this.select(e==null?Gd:Hd(typeof e=="function"?e:To(e)))}var Bd=Array.prototype.filter;function zd(){return Array.from(this.children)}function Fd(e){return function(){return Bd.call(this.children,e)}}function si(e){return this.selectAll(e==null?zd:Fd(typeof e=="function"?e:To(e)))}function ai(e){typeof e!="function"&&(e=kt(e));for(var t=this._groups,o=t.length,n=new Array(o),r=0;r<o;++r)for(var i=t[r],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 Y(n,this._parents)}function vo(e){return new Array(e.length)}function li(){return new Y(this._enter||this._groups.map(vo),this._parents)}function Dt(e,t){this.ownerDocument=e.ownerDocument,this.namespaceURI=e.namespaceURI,this._next=null,this._parent=e,this.__data__=t}Dt.prototype={constructor:Dt,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 ci(e){return function(){return e}}function Wd(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 Dt(e,i[s]);for(;s<l;++s)(a=t[s])&&(r[s]=a)}function Ud(e,t,o,n,r,i,s){var a,l,c=new Map,d=t.length,f=i.length,u=new Array(d),p;for(a=0;a<d;++a)(l=t[a])&&(u[a]=p=s.call(l,l.__data__,a,t)+"",c.has(p)?r[a]=l:c.set(p,l));for(a=0;a<f;++a)p=s.call(e,i[a],a,i)+"",(l=c.get(p))?(n[a]=l,l.__data__=i[a],c.delete(p)):o[a]=new Dt(e,i[a]);for(a=0;a<d;++a)(l=t[a])&&c.get(u[a])===l&&(r[a]=l)}function Yd(e){return e.__data__}function di(e,t){if(!arguments.length)return Array.from(this,Yd);var o=t?Ud:Wd,n=this._parents,r=this._groups;typeof e!="function"&&(e=ci(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],f=r[c],u=f.length,p=$d(e.call(d,d&&d.__data__,c,n)),h=p.length,m=a[c]=new Array(h),g=s[c]=new Array(h),T=l[c]=new Array(u);o(d,f,m,g,T,p,t);for(var x=0,y=0,E,b;x<h;++x)if(E=m[x]){for(x>=y&&(y=x+1);!(b=g[y])&&++y<h;);E._next=b||null}}return s=new Y(s,n),s._enter=a,s._exit=l,s}function $d(e){return typeof e=="object"&&"length"in e?e:Array.from(e)}function ui(){return new Y(this._exit||this._groups.map(vo),this._parents)}function pi(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 fi(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],f=c.length,u=a[l]=new Array(f),p,h=0;h<f;++h)(p=c[h]||d[h])&&(u[h]=p);for(;l<r;++l)a[l]=o[l];return new Y(a,this._parents)}function mi(){for(var e=this._groups,t=-1,o=e.length;++t<o;)for(var n=e[t],r=n.length-1,i=n[r],s;--r>=0;)(s=n[r])&&(i&&s.compareDocumentPosition(i)^4&&i.parentNode.insertBefore(s,i),i=s);return this}function gi(e){e||(e=Xd);function t(f,u){return f&&u?e(f.__data__,u.__data__):!f-!u}for(var o=this._groups,n=o.length,r=new Array(n),i=0;i<n;++i){for(var s=o[i],a=s.length,l=r[i]=new Array(a),c,d=0;d<a;++d)(c=s[d])&&(l[d]=c);l.sort(t)}return new Y(r,this._parents).order()}function Xd(e,t){return e<t?-1:e>t?1:e>=t?0:NaN}function hi(){var e=arguments[0];return arguments[0]=this,e.apply(null,arguments),this}function yi(){return Array.from(this)}function xi(){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 Ei(){let e=0;for(let t of this)++e;return e}function _i(){return!this.node()}function bi(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 Kd(e){return function(){this.removeAttribute(e)}}function qd(e){return function(){this.removeAttributeNS(e.space,e.local)}}function Zd(e,t){return function(){this.setAttribute(e,t)}}function Jd(e,t){return function(){this.setAttributeNS(e.space,e.local,t)}}function Qd(e,t){return function(){var o=t.apply(this,arguments);o==null?this.removeAttribute(e):this.setAttribute(e,o)}}function jd(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 Ti(e,t){var o=Ne(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?qd:Kd:typeof t=="function"?o.local?jd:Qd:o.local?Jd:Zd)(o,t))}function No(e){return e.ownerDocument&&e.ownerDocument.defaultView||e.document&&e||e.defaultView}function eu(e){return function(){this.style.removeProperty(e)}}function tu(e,t,o){return function(){this.style.setProperty(e,t,o)}}function ou(e,t,o){return function(){var n=t.apply(this,arguments);n==null?this.style.removeProperty(e):this.style.setProperty(e,n,o)}}function vi(e,t,o){return arguments.length>1?this.each((t==null?eu:typeof t=="function"?ou:tu)(e,t,o==null?"":o)):ke(this.node(),e)}function ke(e,t){return e.style.getPropertyValue(t)||No(e).getComputedStyle(e,null).getPropertyValue(t)}function nu(e){return function(){delete this[e]}}function ru(e,t){return function(){this[e]=t}}function iu(e,t){return function(){var o=t.apply(this,arguments);o==null?delete this[e]:this[e]=o}}function Ni(e,t){return arguments.length>1?this.each((t==null?nu:typeof t=="function"?iu:ru)(e,t)):this.node()[e]}function wi(e){return e.trim().split(/^|\s+/)}function Kn(e){return e.classList||new Ai(e)}function Ai(e){this._node=e,this._names=wi(e.getAttribute("class")||"")}Ai.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 Ci(e,t){for(var o=Kn(e),n=-1,r=t.length;++n<r;)o.add(t[n])}function Ii(e,t){for(var o=Kn(e),n=-1,r=t.length;++n<r;)o.remove(t[n])}function su(e){return function(){Ci(this,e)}}function au(e){return function(){Ii(this,e)}}function lu(e,t){return function(){(t.apply(this,arguments)?Ci:Ii)(this,e)}}function Si(e,t){var o=wi(e+"");if(arguments.length<2){for(var n=Kn(this.node()),r=-1,i=o.length;++r<i;)if(!n.contains(o[r]))return!1;return!0}return this.each((typeof t=="function"?lu:t?su:au)(o,t))}function cu(){this.textContent=""}function du(e){return function(){this.textContent=e}}function uu(e){return function(){var t=e.apply(this,arguments);this.textContent=t==null?"":t}}function Mi(e){return arguments.length?this.each(e==null?cu:(typeof e=="function"?uu:du)(e)):this.node().textContent}function pu(){this.innerHTML=""}function fu(e){return function(){this.innerHTML=e}}function mu(e){return function(){var t=e.apply(this,arguments);this.innerHTML=t==null?"":t}}function Pi(e){return arguments.length?this.each(e==null?pu:(typeof e=="function"?mu:fu)(e)):this.node().innerHTML}function gu(){this.nextSibling&&this.parentNode.appendChild(this)}function Li(){return this.each(gu)}function hu(){this.previousSibling&&this.parentNode.insertBefore(this,this.parentNode.firstChild)}function ki(){return this.each(hu)}function Di(e){var t=typeof e=="function"?e:bo(e);return this.select(function(){return this.appendChild(t.apply(this,arguments))})}function yu(){return null}function Ri(e,t){var o=typeof e=="function"?e:bo(e),n=t==null?yu:typeof t=="function"?t:We(t);return this.select(function(){return this.insertBefore(o.apply(this,arguments),n.apply(this,arguments)||null)})}function xu(){var e=this.parentNode;e&&e.removeChild(this)}function Vi(){return this.each(xu)}function Eu(){var e=this.cloneNode(!1),t=this.parentNode;return t?t.insertBefore(e,this.nextSibling):e}function _u(){var e=this.cloneNode(!0),t=this.parentNode;return t?t.insertBefore(e,this.nextSibling):e}function Oi(e){return this.select(e?_u:Eu)}function Hi(e){return arguments.length?this.property("__data__",e):this.node().__data__}function bu(e){return function(t){e.call(this,t,this.__data__)}}function Tu(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 vu(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 Nu(e,t,o){return function(){var n=this.__on,r,i=bu(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 Gi(e,t,o){var n=Tu(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?Nu:vu,r=0;r<i;++r)this.each(a(n[r],t,o));return this}function Bi(e,t,o){var n=No(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 wu(e,t){return function(){return Bi(this,e,t)}}function Au(e,t){return function(){return Bi(this,e,t.apply(this,arguments))}}function zi(e,t){return this.each((typeof t=="function"?Au:wu)(e,t))}function*Fi(){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 Cu=[null];function Y(e,t){this._groups=e,this._parents=t}function Wi(){return new Y([[document.documentElement]],Cu)}function Iu(){return this}Y.prototype=Wi.prototype={constructor:Y,select:ni,selectAll:ri,selectChild:ii,selectChildren:si,filter:ai,data:di,enter:li,exit:ui,join:pi,merge:fi,selection:Iu,order:mi,sort:gi,call:hi,nodes:yi,node:xi,size:Ei,empty:_i,each:bi,attr:Ti,style:vi,property:Ni,classed:Si,text:Mi,html:Pi,raise:Li,lower:ki,append:Di,insert:Ri,remove:Vi,clone:Oi,datum:Hi,on:Gi,dispatch:zi,[Symbol.iterator]:Fi};var we=Wi;function wo(e,t,o){e.prototype=t.prototype=o,o.constructor=e}function qn(e,t){var o=Object.create(e.prototype);for(var n in t)o[n]=t[n];return o}function Ot(){}var Rt=.7,Io=1/Rt,at="\\s*([+-]?\\d+)\\s*",Vt="\\s*([+-]?(?:\\d*\\.)?\\d+(?:[eE][+-]?\\d+)?)\\s*",_e="\\s*([+-]?(?:\\d*\\.)?\\d+(?:[eE][+-]?\\d+)?)%\\s*",Su=/^#([0-9a-f]{3,8})$/,Mu=new RegExp(`^rgb\\(${at},${at},${at}\\)$`),Pu=new RegExp(`^rgb\\(${_e},${_e},${_e}\\)$`),Lu=new RegExp(`^rgba\\(${at},${at},${at},${Vt}\\)$`),ku=new RegExp(`^rgba\\(${_e},${_e},${_e},${Vt}\\)$`),Du=new RegExp(`^hsl\\(${Vt},${_e},${_e}\\)$`),Ru=new RegExp(`^hsla\\(${Vt},${_e},${_e},${Vt}\\)$`),Ui={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};wo(Ot,De,{copy(e){return Object.assign(new this.constructor,this,e)},displayable(){return this.rgb().displayable()},hex:Yi,formatHex:Yi,formatHex8:Vu,formatHsl:Ou,formatRgb:$i,toString:$i});function Yi(){return this.rgb().formatHex()}function Vu(){return this.rgb().formatHex8()}function Ou(){return Qi(this).formatHsl()}function $i(){return this.rgb().formatRgb()}function De(e){var t,o;return e=(e+"").trim().toLowerCase(),(t=Su.exec(e))?(o=t[1].length,t=parseInt(t[1],16),o===6?Xi(t):o===3?new ne(t>>8&15|t>>4&240,t>>4&15|t&240,(t&15)<<4|t&15,1):o===8?Ao(t>>24&255,t>>16&255,t>>8&255,(t&255)/255):o===4?Ao(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=Mu.exec(e))?new ne(t[1],t[2],t[3],1):(t=Pu.exec(e))?new ne(t[1]*255/100,t[2]*255/100,t[3]*255/100,1):(t=Lu.exec(e))?Ao(t[1],t[2],t[3],t[4]):(t=ku.exec(e))?Ao(t[1]*255/100,t[2]*255/100,t[3]*255/100,t[4]):(t=Du.exec(e))?Zi(t[1],t[2]/100,t[3]/100,1):(t=Ru.exec(e))?Zi(t[1],t[2]/100,t[3]/100,t[4]):Ui.hasOwnProperty(e)?Xi(Ui[e]):e==="transparent"?new ne(NaN,NaN,NaN,0):null}function Xi(e){return new ne(e>>16&255,e>>8&255,e&255,1)}function Ao(e,t,o,n){return n<=0&&(e=t=o=NaN),new ne(e,t,o,n)}function Hu(e){return e instanceof Ot||(e=De(e)),e?(e=e.rgb(),new ne(e.r,e.g,e.b,e.opacity)):new ne}function lt(e,t,o,n){return arguments.length===1?Hu(e):new ne(e,t,o,n==null?1:n)}function ne(e,t,o,n){this.r=+e,this.g=+t,this.b=+o,this.opacity=+n}wo(ne,lt,qn(Ot,{brighter(e){return e=e==null?Io:Math.pow(Io,e),new ne(this.r*e,this.g*e,this.b*e,this.opacity)},darker(e){return e=e==null?Rt:Math.pow(Rt,e),new ne(this.r*e,this.g*e,this.b*e,this.opacity)},rgb(){return this},clamp(){return new ne(Ye(this.r),Ye(this.g),Ye(this.b),So(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:Ki,formatHex:Ki,formatHex8:Gu,formatRgb:qi,toString:qi}));function Ki(){return`#${Ue(this.r)}${Ue(this.g)}${Ue(this.b)}`}function Gu(){return`#${Ue(this.r)}${Ue(this.g)}${Ue(this.b)}${Ue((isNaN(this.opacity)?1:this.opacity)*255)}`}function qi(){let e=So(this.opacity);return`${e===1?"rgb(":"rgba("}${Ye(this.r)}, ${Ye(this.g)}, ${Ye(this.b)}${e===1?")":`, ${e})`}`}function So(e){return isNaN(e)?1:Math.max(0,Math.min(1,e))}function Ye(e){return Math.max(0,Math.min(255,Math.round(e)||0))}function Ue(e){return e=Ye(e),(e<16?"0":"")+e.toString(16)}function Zi(e,t,o,n){return n<=0?e=t=o=NaN:o<=0||o>=1?e=t=NaN:t<=0&&(e=NaN),new he(e,t,o,n)}function Qi(e){if(e instanceof he)return new he(e.h,e.s,e.l,e.opacity);if(e instanceof Ot||(e=De(e)),!e)return new he;if(e instanceof he)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 he(s,a,l,e.opacity)}function ji(e,t,o,n){return arguments.length===1?Qi(e):new he(e,t,o,n==null?1:n)}function he(e,t,o,n){this.h=+e,this.s=+t,this.l=+o,this.opacity=+n}wo(he,ji,qn(Ot,{brighter(e){return e=e==null?Io:Math.pow(Io,e),new he(this.h,this.s,this.l*e,this.opacity)},darker(e){return e=e==null?Rt:Math.pow(Rt,e),new he(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 ne(Zn(e>=240?e-240:e+120,r,n),Zn(e,r,n),Zn(e<120?e+240:e-120,r,n),this.opacity)},clamp(){return new he(Ji(this.h),Co(this.s),Co(this.l),So(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=So(this.opacity);return`${e===1?"hsl(":"hsla("}${Ji(this.h)}, ${Co(this.s)*100}%, ${Co(this.l)*100}%${e===1?")":`, ${e})`}`}}));function Ji(e){return e=(e||0)%360,e<0?e+360:e}function Co(e){return Math.max(0,Math.min(1,e||0))}function Zn(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 Jn(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 es(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 Jn((o-n/t)*t,s,r,i,a)}}function ts(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 Jn((o-n/t)*t,r,i,s,a)}}var Qn=e=>()=>e;function Bu(e,t){return function(o){return e+o*t}}function zu(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 os(e){return(e=+e)==1?Mo:function(t,o){return o-t?zu(t,o,e):Qn(isNaN(t)?o:t)}}function Mo(e,t){var o=t-e;return o?Bu(e,o):Qn(isNaN(e)?t:e)}var Po=function e(t){var o=os(t);function n(r,i){var s=o((r=lt(r)).r,(i=lt(i)).r),a=o(r.g,i.g),l=o(r.b,i.b),c=Mo(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 ns(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=lt(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 Fu=ns(es),Wu=ns(ts);function pe(e,t){return e=+e,t=+t,function(o){return e*(1-o)+t*o}}var er=/[-+]?(?:\d+\.?\d*|\.?\d+)(?:[eE][-+]?\d+)?/g,jn=new RegExp(er.source,"g");function Uu(e){return function(){return e}}function Yu(e){return function(t){return e(t)+""}}function tr(e,t){var o=er.lastIndex=jn.lastIndex=0,n,r,i,s=-1,a=[],l=[];for(e=e+"",t=t+"";(n=er.exec(e))&&(r=jn.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:pe(n,r)})),o=jn.lastIndex;return o<t.length&&(i=t.slice(o),a[s]?a[s]+=i:a[++s]=i),a.length<2?l[0]?Yu(l[0].x):Uu(t):(t=l.length,function(c){for(var d=0,f;d<t;++d)a[(f=l[d]).i]=f.x(c);return a.join("")})}var rs=180/Math.PI,Lo={translateX:0,translateY:0,rotate:0,skewX:0,scaleX:1,scaleY:1};function or(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)*rs,skewX:Math.atan(l)*rs,scaleX:s,scaleY:a}}var ko;function is(e){let t=new(typeof DOMMatrix=="function"?DOMMatrix:WebKitCSSMatrix)(e+"");return t.isIdentity?Lo:or(t.a,t.b,t.c,t.d,t.e,t.f)}function ss(e){return e==null?Lo:(ko||(ko=document.createElementNS("http://www.w3.org/2000/svg","g")),ko.setAttribute("transform",e),(e=ko.transform.baseVal.consolidate())?(e=e.matrix,or(e.a,e.b,e.c,e.d,e.e,e.f)):Lo)}function as(e,t,o,n){function r(c){return c.length?c.pop()+" ":""}function i(c,d,f,u,p,h){if(c!==f||d!==u){var m=p.push("translate(",null,t,null,o);h.push({i:m-4,x:pe(c,f)},{i:m-2,x:pe(d,u)})}else(f||u)&&p.push("translate("+f+t+u+o)}function s(c,d,f,u){c!==d?(c-d>180?d+=360:d-c>180&&(c+=360),u.push({i:f.push(r(f)+"rotate(",null,n)-2,x:pe(c,d)})):d&&f.push(r(f)+"rotate("+d+n)}function a(c,d,f,u){c!==d?u.push({i:f.push(r(f)+"skewX(",null,n)-2,x:pe(c,d)}):d&&f.push(r(f)+"skewX("+d+n)}function l(c,d,f,u,p,h){if(c!==f||d!==u){var m=p.push(r(p)+"scale(",null,",",null,")");h.push({i:m-4,x:pe(c,f)},{i:m-2,x:pe(d,u)})}else(f!==1||u!==1)&&p.push(r(p)+"scale("+f+","+u+")")}return function(c,d){var f=[],u=[];return c=e(c),d=e(d),i(c.translateX,c.translateY,d.translateX,d.translateY,f,u),s(c.rotate,d.rotate,f,u),a(c.skewX,d.skewX,f,u),l(c.scaleX,c.scaleY,d.scaleX,d.scaleY,f,u),c=d=null,function(p){for(var h=-1,m=u.length,g;++h<m;)f[(g=u[h]).i]=g.x(p);return f.join("")}}}var nr=as(is,"px, ","px)","deg)"),rr=as(ss,", ",")",")");var ct=0,Gt=0,Ht=0,cs=1e3,Do,Bt,Ro=0,$e=0,Vo=0,zt=typeof performance=="object"&&performance.now?performance:Date,ds=typeof window=="object"&&window.requestAnimationFrame?window.requestAnimationFrame.bind(window):function(e){setTimeout(e,17)};function Wt(){return $e||(ds($u),$e=zt.now()+Vo)}function $u(){$e=0}function Ft(){this._call=this._time=this._next=null}Ft.prototype=Oo.prototype={constructor:Ft,restart:function(e,t,o){if(typeof e!="function")throw new TypeError("callback is not a function");o=(o==null?Wt():+o)+(t==null?0:+t),!this._next&&Bt!==this&&(Bt?Bt._next=this:Do=this,Bt=this),this._call=e,this._time=o,ir()},stop:function(){this._call&&(this._call=null,this._time=1/0,ir())}};function Oo(e,t,o){var n=new Ft;return n.restart(e,t,o),n}function us(){Wt(),++ct;for(var e=Do,t;e;)(t=$e-e._time)>=0&&e._call.call(void 0,t),e=e._next;--ct}function ls(){$e=(Ro=zt.now())+Vo,ct=Gt=0;try{us()}finally{ct=0,Ku(),$e=0}}function Xu(){var e=zt.now(),t=e-Ro;t>cs&&(Vo-=t,Ro=e)}function Ku(){for(var e,t=Do,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:Do=o);Bt=e,ir(n)}function ir(e){if(!ct){Gt&&(Gt=clearTimeout(Gt));var t=e-$e;t>24?(e<1/0&&(Gt=setTimeout(ls,e-zt.now()-Vo)),Ht&&(Ht=clearInterval(Ht))):(Ht||(Ro=zt.now(),Ht=setInterval(Xu,cs)),ct=1,ds(ls))}}function Ho(e,t,o){var n=new Ft;return t=t==null?0:+t,n.restart(r=>{n.stop(),e(r+t)},t,o),n}var qu=Yn("start","end","cancel","interrupt"),Zu=[],ms=0,ps=1,Bo=2,Go=3,fs=4,zo=5,Ut=6;function Re(e,t,o,n,r,i){var s=e.__transition;if(!s)e.__transition={};else if(o in s)return;Ju(e,o,{name:t,index:n,group:r,on:qu,tween:Zu,time:i.time,delay:i.delay,duration:i.duration,ease:i.ease,timer:null,state:ms})}function Yt(e,t){var o=$(e,t);if(o.state>ms)throw new Error("too late; already scheduled");return o}function q(e,t){var o=$(e,t);if(o.state>Go)throw new Error("too late; already running");return o}function $(e,t){var o=e.__transition;if(!o||!(o=o[t]))throw new Error("transition not found");return o}function Ju(e,t,o){var n=e.__transition,r;n[t]=o,o.timer=Oo(i,0,o.time);function i(c){o.state=ps,o.timer.restart(s,o.delay,o.time),o.delay<=c&&s(c-o.delay)}function s(c){var d,f,u,p;if(o.state!==ps)return l();for(d in n)if(p=n[d],p.name===o.name){if(p.state===Go)return Ho(s);p.state===fs?(p.state=Ut,p.timer.stop(),p.on.call("interrupt",e,e.__data__,p.index,p.group),delete n[d]):+d<t&&(p.state=Ut,p.timer.stop(),p.on.call("cancel",e,e.__data__,p.index,p.group),delete n[d])}if(Ho(function(){o.state===Go&&(o.state=fs,o.timer.restart(a,o.delay,o.time),a(c))}),o.state=Bo,o.on.call("start",e,e.__data__,o.index,o.group),o.state===Bo){for(o.state=Go,r=new Array(u=o.tween.length),d=0,f=-1;d<u;++d)(p=o.tween[d].value.call(e,e.__data__,o.index,o.group))&&(r[++f]=p);r.length=f+1}}function a(c){for(var d=c<o.duration?o.ease.call(null,c/o.duration):(o.timer.restart(l),o.state=zo,1),f=-1,u=r.length;++f<u;)r[f].call(e,d);o.state===zo&&(o.on.call("end",e,e.__data__,o.index,o.group),l())}function l(){o.state=Ut,o.timer.stop(),delete n[t];for(var c in n)return;delete e.__transition}}function sr(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>Bo&&n.state<zo,n.state=Ut,n.timer.stop(),n.on.call(r?"interrupt":"cancel",e,e.__data__,n.index,n.group),delete o[s]}i&&delete e.__transition}}function gs(e){return this.each(function(){sr(this,e)})}function Qu(e,t){var o,n;return function(){var r=q(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 ju(e,t,o){var n,r;if(typeof o!="function")throw new Error;return function(){var i=q(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 hs(e,t){var o=this._id;if(e+="",arguments.length<2){for(var n=$(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?Qu:ju)(o,e,t))}function dt(e,t,o){var n=e._id;return e.each(function(){var r=q(this,n);(r.value||(r.value={}))[t]=o.apply(this,arguments)}),function(r){return $(r,n).value[t]}}function Fo(e,t){var o;return(typeof t=="number"?pe:t instanceof De?Po:(o=De(t))?(t=o,Po):tr)(e,t)}function ep(e){return function(){this.removeAttribute(e)}}function tp(e){return function(){this.removeAttributeNS(e.space,e.local)}}function op(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 np(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 rp(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 ip(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 ys(e,t){var o=Ne(e),n=o==="transform"?rr:Fo;return this.attrTween(e,typeof t=="function"?(o.local?ip:rp)(o,n,dt(this,"attr."+e,t)):t==null?(o.local?tp:ep)(o):(o.local?np:op)(o,n,t))}function sp(e,t){return function(o){this.setAttribute(e,t.call(this,o))}}function ap(e,t){return function(o){this.setAttributeNS(e.space,e.local,t.call(this,o))}}function lp(e,t){var o,n;function r(){var i=t.apply(this,arguments);return i!==n&&(o=(n=i)&&ap(e,i)),o}return r._value=t,r}function cp(e,t){var o,n;function r(){var i=t.apply(this,arguments);return i!==n&&(o=(n=i)&&sp(e,i)),o}return r._value=t,r}function xs(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=Ne(e);return this.tween(o,(n.local?lp:cp)(n,t))}function dp(e,t){return function(){Yt(this,e).delay=+t.apply(this,arguments)}}function up(e,t){return t=+t,function(){Yt(this,e).delay=t}}function Es(e){var t=this._id;return arguments.length?this.each((typeof e=="function"?dp:up)(t,e)):$(this.node(),t).delay}function pp(e,t){return function(){q(this,e).duration=+t.apply(this,arguments)}}function fp(e,t){return t=+t,function(){q(this,e).duration=t}}function _s(e){var t=this._id;return arguments.length?this.each((typeof e=="function"?pp:fp)(t,e)):$(this.node(),t).duration}function mp(e,t){if(typeof t!="function")throw new Error;return function(){q(this,e).ease=t}}function bs(e){var t=this._id;return arguments.length?this.each(mp(t,e)):$(this.node(),t).ease}function gp(e,t){return function(){var o=t.apply(this,arguments);if(typeof o!="function")throw new Error;q(this,e).ease=o}}function Ts(e){if(typeof e!="function")throw new Error;return this.each(gp(this._id,e))}function vs(e){typeof e!="function"&&(e=kt(e));for(var t=this._groups,o=t.length,n=new Array(o),r=0;r<o;++r)for(var i=t[r],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 te(n,this._parents,this._name,this._id)}function Ns(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,f=s[a]=new Array(d),u,p=0;p<d;++p)(u=l[p]||c[p])&&(f[p]=u);for(;a<n;++a)s[a]=t[a];return new te(s,this._parents,this._name,this._id)}function hp(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 yp(e,t,o){var n,r,i=hp(t)?Yt:q;return function(){var s=i(this,e),a=s.on;a!==n&&(r=(n=a).copy()).on(t,o),s.on=r}}function ws(e,t){var o=this._id;return arguments.length<2?$(this.node(),o).on.on(e):this.each(yp(o,e,t))}function xp(e){return function(){var t=this.parentNode;for(var o in this.__transition)if(+o!==e)return;t&&t.removeChild(this)}}function As(){return this.on("end.remove",xp(this._id))}function Cs(e){var t=this._name,o=this._id;typeof e!="function"&&(e=We(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,f,u=0;u<l;++u)(d=a[u])&&(f=e.call(d,d.__data__,u,a))&&("__data__"in d&&(f.__data__=d.__data__),c[u]=f,Re(c[u],t,o,u,c,$(d,o)));return new te(i,this._parents,t,o)}function Is(e){var t=this._name,o=this._id;typeof e!="function"&&(e=Lt(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,f=0;f<c;++f)if(d=l[f]){for(var u=e.call(d,d.__data__,f,l),p,h=$(d,o),m=0,g=u.length;m<g;++m)(p=u[m])&&Re(p,t,o,m,u,h);i.push(u),s.push(d)}return new te(i,s,t,o)}var Ep=we.prototype.constructor;function Ss(){return new Ep(this._groups,this._parents)}function _p(e,t){var o,n,r;return function(){var i=ke(this,e),s=(this.style.removeProperty(e),ke(this,e));return i===s?null:i===o&&s===n?r:r=t(o=i,n=s)}}function Ms(e){return function(){this.style.removeProperty(e)}}function bp(e,t,o){var n,r=o+"",i;return function(){var s=ke(this,e);return s===r?null:s===n?i:i=t(n=s,o)}}function Tp(e,t,o){var n,r,i;return function(){var s=ke(this,e),a=o(this),l=a+"";return a==null&&(l=a=(this.style.removeProperty(e),ke(this,e))),s===l?null:s===n&&l===r?i:(r=l,i=t(n=s,a))}}function vp(e,t){var o,n,r,i="style."+t,s="end."+i,a;return function(){var l=q(this,e),c=l.on,d=l.value[i]==null?a||(a=Ms(t)):void 0;(c!==o||r!==d)&&(n=(o=c).copy()).on(s,r=d),l.on=n}}function Ps(e,t,o){var n=(e+="")=="transform"?nr:Fo;return t==null?this.styleTween(e,_p(e,n)).on("end.style."+e,Ms(e)):typeof t=="function"?this.styleTween(e,Tp(e,n,dt(this,"style."+e,t))).each(vp(this._id,e)):this.styleTween(e,bp(e,n,t),o).on("end.style."+e,null)}function Np(e,t,o){return function(n){this.style.setProperty(e,t.call(this,n),o)}}function wp(e,t,o){var n,r;function i(){var s=t.apply(this,arguments);return s!==r&&(n=(r=s)&&Np(e,s,o)),n}return i._value=t,i}function Ls(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,wp(e,t,o==null?"":o))}function Ap(e){return function(){this.textContent=e}}function Cp(e){return function(){var t=e(this);this.textContent=t==null?"":t}}function ks(e){return this.tween("text",typeof e=="function"?Cp(dt(this,"text",e)):Ap(e==null?"":e+""))}function Ip(e){return function(t){this.textContent=e.call(this,t)}}function Sp(e){var t,o;function n(){var r=e.apply(this,arguments);return r!==o&&(t=(o=r)&&Ip(r)),t}return n._value=e,n}function Ds(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,Sp(e))}function Rs(){for(var e=this._name,t=this._id,o=Wo(),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=$(l,t);Re(l,e,o,c,s,{time:d.time+d.delay+d.duration,delay:0,duration:d.duration,ease:d.ease})}return new te(n,this._parents,e,o)}function Vs(){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=q(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 Mp=0;function te(e,t,o,n){this._groups=e,this._parents=t,this._name=o,this._id=n}function Os(e){return we().transition(e)}function Wo(){return++Mp}var Ae=we.prototype;te.prototype=Os.prototype={constructor:te,select:Cs,selectAll:Is,selectChild:Ae.selectChild,selectChildren:Ae.selectChildren,filter:vs,merge:Ns,selection:Ss,transition:Rs,call:Ae.call,nodes:Ae.nodes,node:Ae.node,size:Ae.size,empty:Ae.empty,each:Ae.each,on:ws,attr:ys,attrTween:xs,style:Ps,styleTween:Ls,text:ks,textTween:Ds,remove:As,tween:hs,delay:Es,duration:_s,ease:bs,easeVarying:Ts,end:Vs,[Symbol.iterator]:Ae[Symbol.iterator]};function Uo(e){return((e*=2)<=1?e*e*e:(e-=2)*e*e+2)/2}var Pp={time:null,delay:0,duration:250,ease:Uo};function Lp(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 Hs(e){var t,o;e instanceof te?(t=e._id,e=e._name):(t=Wo(),(o=Pp).time=Wt(),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])&&Re(l,e,t,c,s,o||Lp(l,t));return new te(n,this._parents,e,t)}we.prototype.interrupt=gs;we.prototype.transition=Hs;function Ve(e,t,o){this.k=e,this.x=t,this.y=o}Ve.prototype={constructor:Ve,scale:function(e){return e===1?this:new Ve(this.k*e,this.x,this.y)},translate:function(e,t){return e===0&t===0?this:new Ve(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 Yo=new Ve(1,0,0);$o.prototype=Ve.prototype;function $o(e){for(;!e.__zoom;)if(!(e=e.parentNode))return Yo;return e.__zoom}var Dp=[[Number.NEGATIVE_INFINITY,Number.NEGATIVE_INFINITY],[Number.POSITIVE_INFINITY,Number.POSITIVE_INFINITY]];var Gs;(function(e){e.Strict="strict",e.Loose="loose"})(Gs||(Gs={}));var Bs;(function(e){e.Free="free",e.Vertical="vertical",e.Horizontal="horizontal"})(Bs||(Bs={}));var zs;(function(e){e.Partial="partial",e.Full="full"})(zs||(zs={}));var Fs;(function(e){e.Bezier="default",e.Straight="straight",e.Step="step",e.SmoothStep="smoothstep",e.SimpleBezier="simplebezier"})(Fs||(Fs={}));var Ws;(function(e){e.Arrow="arrow",e.ArrowClosed="arrowclosed"})(Ws||(Ws={}));var re;(function(e){e.Left="left",e.Top="top",e.Right="right",e.Bottom="bottom"})(re||(re={}));var HT={[re.Left]:re.Right,[re.Right]:re.Left,[re.Top]:re.Bottom,[re.Bottom]:re.Top};var Rp=e=>"id"in e&&"internals"in e&&!("source"in e)&&!("target"in e);var Vp=(e,t=[0,0])=>{var a;let{width:o,height:n}=Op(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 ae=(e,t=[0,0])=>{var r,i,s,a,l,c,d,f;let{x:o,y:n}=Rp(e)?e.internals.positionAbsolute:Vp(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+((f=(d=(c=(l=e.measured)==null?void 0:l.height)!=null?c:e.height)!=null?d:e.initialHeight)!=null?f:0)}};function Op(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 GT={[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 Hp={nodeOrigin:[0,0],nodeExtent:Dp,elevateNodesOnSelect:!0,defaults:{}},BT=v(_({},Hp),{checkEquality:!0});var Us;(function(e){e.Line="line",e.Handle="handle"})(Us||(Us={}));var Gp={width:0,height:0,x:0,y:0},zT=v(_({},Gp),{pointerX:0,pointerY:0,aspectRatio:1});import{useCallback as $t,useEffect as $p,useRef as Xp,useState as Ks}from"react";import{shallow as Kp}from"zustand/shallow";var Xo=10,Xe={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}};var Bp=(e,t)=>e.x<t.x2&&e.x2>t.x&&e.y<t.y2&&e.y2>t.y;function zp(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 Fp(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 Ko=class{constructor(){this.xLines=[];this.yLines=[]}initialize(t){this.xLines=t.filter(o=>o.orientation==="vertical"),this.yLines=t.filter(o=>o.orientation==="horizontal"),this.xLines.sort((o,n)=>o.position-n.position),this.yLines.sort((o,n)=>o.position-n.position),this.lastHorizontalLine=void 0,this.lastVerticalLine=void 0}search(t,o,n,r){let i=t==="horizontal"?this.yLines:this.xLines,[s,a]=t==="horizontal"?[r.y,r.y2]:[r.x,r.x2],l=[];for(let u of i){if(u.position<s)continue;if(u.position>a)break;if(u.node.id===n.id||u.node.parentId===n.id||!Bp(u.nodeBox,r))continue;let p=Math.abs(u.position-o);if(p>Xo)continue;let m=zp(u.nodeBox,ae(n))>0?0:Fp(u.nodeBox,ae(n));l.push({line:u,lineDist:p,nodeDist:m})}let c=.5,d=t==="horizontal"?this.lastHorizontalLine:this.lastVerticalLine;l.sort((u,p)=>{if(d){if(u.line===d&&p.line!==d)return-1;if(p.line===d&&u.line!==d)return 1}return Math.abs(u.lineDist-p.lineDist)<=c?u.nodeDist-p.nodeDist:u.lineDist-p.lineDist});let f=l.length>0?l[0].line:void 0;return f&&(t==="horizontal"?this.lastHorizontalLine=f:this.lastVerticalLine=f),f}};function Ys(e,t=Xe,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=ae(i);Object.entries(t).forEach(([a,l])=>{var c;n.push({nodeBox:s,node:r,orientation:l.orientation,position:l.resolve(r,s),color:(c=r.style)==null?void 0:c.backgroundColor,anchorName:a})})}),n}function $s(e,t,o,n,r=Object.keys(Xe)){let i=[];for(let a of r){let l=Xe[a],c=l.resolve(o,n),d=e.search(l.orientation,c,o,t);d&&i.push({anchorName:a,sourcePosition:c,anchor:l,line:d})}let s={horizontal:void 0,vertical:void 0};for(let a of i){let l=s[a.anchor.orientation],c=Math.abs(a.sourcePosition-a.line.position);(!l||c<Math.abs(l.sourcePosition-l.line.position))&&(s[a.anchor.orientation]=a)}return s}function Xs(e,t,o,n,r,i,s,a){var f,u,p,h,m,g,T,x;if(!(o!=null&&o.position))return{snappedX:!1,snappedY:!1};let l=!1,c=!1,d={x:o.position.x,y:o.position.y,x2:o.position.x+((u=(f=e.measured)==null?void 0:f.width)!=null?u:0),y2:o.position.y+((h=(p=e.measured)==null?void 0:p.height)!=null?h:0)};if(s){let E=s.anchor.resolve(e,d)-s.line.position;if(Math.abs(E)<=Xo){if(o.position.y-=E,r!=null&&r.dimensions)if(n){let b=t.internals.positionAbsolute.y+((g=(m=e.measured)==null?void 0:m.height)!=null?g:0);r.dimensions.height=b-s.line.position}else r.dimensions.height=s.line.position-t.internals.positionAbsolute.y;c=!0}}if(a){let E=a.anchor.resolve(e,d)-a.line.position;if(Math.abs(E)<=Xo){if(o.position.x-=E,r!=null&&r.dimensions)if(n){let b=t.internals.positionAbsolute.x+((x=(T=e.measured)==null?void 0:T.width)!=null?x:0);r.dimensions.width=b-a.line.position}else r.dimensions.width=a.line.position-t.internals.positionAbsolute.x;l=!0}}return i&&(l||c)&&(o.position.x-=i.position.x,o.position.y-=i.position.y),{snappedX:l,snappedY:c}}import{jsx as Zp}from"react/jsx-runtime";var qp=new Ko;function ut(){let[e,t]=Ks(void 0),[o,n]=Ks(void 0),{width:r,height:i}=Yp(g=>({width:g.width,height:g.height}),Kp),s=Wp(),a=Xp(qp),{screenToFlowPosition:l,getInternalNode:c,getNodes:d}=Up(),f=$t(()=>{t(void 0),n(void 0)},[]),u=$t(g=>{let T=g!=null?g:d();f();let x=Ys(T,Xe,c);a.current.initialize(x)},[c,f,d]),p=$t(()=>{setTimeout(()=>{u()},100)},[u]);$p(()=>{s&&u(d())},[s,u,d]);let h=$t((g,T)=>{var O,B,z,de,ee;if(!a.current||g.length===0||g.length>2)return g;f();let x,y,E=Object.keys(Xe);g.length===1?g[0].type==="position"?x=g[0]:g[0].type==="dimensions"&&(y=g[0],E=["right","bottom"]):g[0].type==="position"&&g[1].type==="dimensions"&&g[1].dimensions&&(x=g[0],y=g[1],E=["top","left"]);let b=T.find(ze=>ze.id===g[0].id);if(!b)return g;let A=c(b.id);if(!A)throw new Error(`Node with id ${b.id} not found in internal nodes`);let N=c((O=A.parentId)!=null?O:""),C=ae(A);y!=null&&y.dimensions&&(C.x2=C.x+y.dimensions.width,C.y2=C.y+y.dimensions.height);let{x:L,y:w}=l({x:0,y:0}),{x:S,y:M}=l({x:r,y:i}),I={x:L,y:w,x2:S,y2:M},{horizontal:V,vertical:F}=$s(a.current,I,b,C,E),G={id:b.id,type:"position",position:{x:A.internals.positionAbsolute.x,y:A.internals.positionAbsolute.y},dragging:!1};x!=null&&x.position&&G.position&&(N?(G.position.x=x.position.x+((z=(B=N==null?void 0:N.position)==null?void 0:B.x)!=null?z:0),G.position.y=x.position.y+((ee=(de=N==null?void 0:N.position)==null?void 0:de.y)!=null?ee:0)):(G.position.x=x.position.x,G.position.y=x.position.y));let{snappedX:U,snappedY:X}=Xs(b,A,G,x,y,N,V,F);if(U||X){if((y!=null&&y.resizing||x!=null&&x.dragging)&&(U&&n(F==null?void 0:F.line),X&&t(V==null?void 0:V.line)),y&&x)return[G,y];if(x)return[G];if(y)return[y]}return g},[l,c,r,i,t,n,f]),m=$t(()=>Zp(qs,{horizontal:e,vertical:o}),[e,o]);return{rebuildIndex:u,forceRebuildIndex:p,updateHelperLines:h,helperLineHorizontal:e,helperLineVertical:o,HelperLines:m}}import{addEdge as Hf,useReactFlow as Gf}from"@xyflow/react";import{useCallback as da}from"react";import{BaseEdge as vf,EdgeLabelRenderer as Nf,getStraightPath as wf,useInternalNode as Qs,useViewport as Af}from"@xyflow/react";import{Position as Xt}from"@xyflow/react";function Zs(e,t){var y,E,b,A;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,f=i.y+((A=(b=t==null?void 0:t.measured)==null?void 0:b.height)!=null?A:0)/2,u=(d-l)/(2*s)-(f-c)/(2*a),p=(d-l)/(2*s)+(f-c)/(2*a),h=1/(Math.abs(u)+Math.abs(p)||1),m=h*u,g=h*p,T=s*(m+g)+l,x=a*(-m+g)+c;return{x:T,y:x}}function Js(e,t){var c,d,f,u;let{positionAbsolute:o}=e.internals,n=(d=(c=e.measured)==null?void 0:c.width)!=null?d:0,r=(u=(f=e.measured)==null?void 0:f.height)!=null?u:0,i=Math.round(o.x),s=Math.round(o.y),a=Math.round(t.x),l=Math.round(t.y);return a<=i+1?Xt.Left:a>=i+n-1?Xt.Right:l<=s+1?Xt.Top:l>=s+r-1?Xt.Bottom:Xt.Top}function Oe(e,t){let o=Zs(e,t),n=Zs(t,e),r=Js(e,o),i=Js(t,n);return{sx:o.x,sy:o.y,tx:n.x,ty:n.y,sourcePos:r,targetPos:i}}import{Button as jp,Tooltip as ef,TooltipContent as tf,TooltipTrigger as of,useTranslation as nf}from"lecom-ui";import{Settings as rf}from"lucide-react";import{getIncomers as qo,getOutgoers as Zo,useReactFlow as Qp}from"@xyflow/react";import{useReactFlow as Jp}from"@xyflow/react";var He=()=>{let{getNodes:e,setNodes:t,getEdges:o,setEdges:n}=Jp();return{selectElements:s=>{let a=e().map(c=>v(_({},c),{selected:s.includes(c.id)})),l=o().map(c=>v(_({},c),{selected:s.includes(c.id)}));return t(a),n(l),!0},clearSelection:async()=>{let s=e().map(l=>v(_({},l),{selected:!1})),a=o().map(l=>v(_({},l),{selected:!1}));return t(s),n(a),await $r(),!0}}};var Jo=()=>{let{getNode:e,getEdge:t,getNodes:o,getEdges:n}=Qp(),{selectElements:r}=He(),i=g=>{let T=o(),x=n(),y=qo(g,T,x),E=Zo(g,T,x),b=y.some(N=>N.type==="START_EVENT"),A=E.some(N=>N.type==="END_EVENT");return b?"start":A?"end":"between"},s=(g,T,x)=>{var b,A,N,C;if(!g)return;let y={type:g.type,variant:(b=g.data)==null?void 0:b.variant,attribute:(A=g.data)==null?void 0:A.attribute},E={id:g.id,position:i(g),label:(N=g.data)==null?void 0:N.label,node:y};return g.type==="TASK"&&((C=g.data)==null?void 0:C.variant)==="SUBPROCESS"?v(_({},E),{type:"sub_process"}):g.type==="GATEWAY"?v(_({},E),{type:"gateway",variant:a(g,T,x)}):v(_({},E),{type:"activity"})},a=(g,T,x)=>{if(g.type!=="GATEWAY")return;let y=qo(g,T,x),E=!1,b=!1;if(y.forEach(A=>{var N,C;A.type==="TASK"&&(((N=A.data)==null?void 0:N.variant)==="SCRIPT"&&(E=!0),((C=A.data)==null?void 0:C.attribute)==="LOOP"&&(b=!0))}),E&&b)return"script_loop";if(E)return"script";if(b)return"loop"},l=(g,T,x)=>{var N,C,L,w;let y=e(g.source),E=e(g.target);if(!y||!E)return"simple";if(Zo(y,T,x).some(S=>S.type==="END_EVENT"))return"final";if(y.type==="GATEWAY")switch((N=y.data)==null?void 0:N.variant){case"PARALLEL":return"parallel";case"EXCLUSIVE":return"exclusive";case"COMPLEX":return"complex";default:return"simple"}if(y.type==="TASK"){let S=(C=y.data)==null?void 0:C.variant,M=(L=y.data)==null?void 0:L.attribute;if(E.type==="TASK"&&((w=E.data)==null?void 0:w.variant)==="SUBPROCESS")return"to_sub_process";let I=S==="SCRIPT",V=M==="LOOP";return I&&V?"script_loop":I?"script":V?"loop":"simple"}return"simple"},c=(g,T,x)=>{let y=[];function E(A,N,C=0){let L=s(A,T,x);if(L.depth=C,N.push(L),A.type==="TASK"){y.push([...N]),N.pop();return}let w=qo(A,T,x);if(w.length)for(let S of w)E(S,N,C+1);N.pop()}let b=qo(g,T,x);for(let A of b)E(A,[]);return y},d=(g,T,x)=>{let y=[];function E(A,N,C=0){let L=s(A,T,x);if(L.depth=C,N.push(L),A.type==="TASK"){y.push([...N]),N.pop();return}let w=Zo(A,T,x);if(w.length)for(let S of w)E(S,N,C+1);N.pop()}let b=Zo(g,T,x);for(let A of b)E(A,[]);return y},f=(g,T,x)=>(x=x.filter(E=>E.source===g.id),x.map(E=>{var b;return{id:E.id,type:"routing",variant:l(E,T,x),label:(b=E.data)==null?void 0:b.label,target:e(E.target)}})),u=g=>{let T=e(g);if(!T)return;let x=o(),y=n(),E=s(T,x,y);return E.sources=c(T,x,y),E.targets=d(T,x,y),E.edgeTargets=f(T,x,y),T.type==="GATEWAY"&&(E.variant=a(T,x,y)),E},p=g=>{let T=t(g);if(!T)return;let x=o(),y=n(),E=l(T,x,y),A={id:T.id,type:"routing",variant:E,gatewayVariant:void 0},N=e(T.source);if(N){let L=s(N,x,y),w=c(N,x,y),S=a(N,x,y);A.source=L,A.sources=w.length?w:[[L]],A.gatewayVariant=S}let C=e(T.target);if(C){let L=s(C,x,y),w=d(C,x,y);A.target=L,A.targets=w.length?w:[[L]]}return A},h=g=>{let T=e(g);if(T)return u(T.id);let x=t(g);if(x)return p(x.id)};return{configureElement:g=>{let T=h(g);if(T)return r([g]),T},getConfigureElement:h,getNodeConfigure:u,getEdgeConfigure:p}};import{jsx as Qo,jsxs as sf}from"react/jsx-runtime";var Kt=({elementId:e,elementType:t="node"})=>{let{t:o}=nf(),{onConfigureElement:n}=D(),{getConfigureElement:r}=Jo();return sf(ef,{children:[Qo(of,{asChild:!0,children:Qo(jp,{variant:"ghost",color:"grey",size:"small",iconButton:!0,onClick:()=>{let s=r(e);s&&(n==null||n(s))},children:Qo(rf,{size:16})})}),Qo(tf,{color:"black",children:o(t==="node"?"editor.toolbar.configure_node":"editor.toolbar.configure_edge")})]})};import{useReactFlow as af}from"@xyflow/react";import{Button as lf,Tooltip as cf,TooltipContent as df,TooltipTrigger as uf,useTranslation as pf}from"lecom-ui";import{TrashIcon as ff}from"lucide-react";import{jsx as jo,jsxs as mf}from"react/jsx-runtime";var en=({elementId:e,elementType:t="node"})=>{let{t:o}=pf(),{deleteElements:n}=af();return mf(cf,{children:[jo(uf,{asChild:!0,children:jo(lf,{variant:"ghost",color:"destructive",size:"small",iconButton:!0,onClick:()=>{n(t==="node"?{nodes:[{id:e}]}:{edges:[{id:e}]})},children:jo(ff,{size:16})})}),jo(df,{color:"black",children:o("editor.toolbar.delete")})]})};import{Button as gf,Tooltip as hf,TooltipContent as yf,TooltipTrigger as xf,useTranslation as Ef}from"lecom-ui";import{MoveUpRightIcon as _f}from"lucide-react";import{useCallback as bf}from"react";import{jsx as tn,jsxs as Tf}from"react/jsx-runtime";var qt=({nodeId:e})=>{let{t}=Ef(),o=bf(n=>{n.stopPropagation();let r=document.querySelector(`[data-id="${e}"]`);if(!r)return;let i=r.querySelector(".react-flow__handle.source");if(!i)return;let s=i.getBoundingClientRect(),a=s.left+s.width/2,l=s.top+s.height/2,c=new MouseEvent("mousedown",{clientX:a,clientY:l,bubbles:!0,cancelable:!0});i.dispatchEvent(c)},[e]);return Tf(hf,{children:[tn(xf,{asChild:!0,children:tn(gf,{variant:"ghost",color:"grey",size:"small",iconButton:!0,onMouseDown:o,children:tn(_f,{size:16})})}),tn(yf,{color:"black",children:t("editor.toolbar.connect_node")})]})};import{jsx as on}from"react/jsx-runtime";var pt=i=>{var s=i,{edgeId:e,edgeType:t,sourceNode:o,targetNode:n}=s,r=Ee(s,["edgeId","edgeType","sourceNode","targetNode"]);var h;let a=(o==null?void 0:o.type)==="START_EVENT",l=(n==null?void 0:n.type)==="END_EVENT",c=(o==null?void 0:o.type)==="GATEWAY"&&(n==null?void 0:n.type)==="GATEWAY",d=(o==null?void 0:o.type)==="TASK"&&(n==null?void 0:n.type)==="GATEWAY",f=!a&&!l&&!c&&!d,u=[{component:on(en,{elementId:e,elementType:"edge"})}],p={SEQUENCE_EDGE:[...f?[{component:on(Kt,{elementId:e,elementType:"edge"})}]:[],...u],MESSAGE_EDGE:[...u],ANNOTATION_EDGE:[...u]};return on("div",v(_({className:"flex items-center gap-1 w-fit px-3 py-2 bg-white rounded-sm shadow-md"},r),{children:(h=p[t])==null?void 0:h.map((m,g)=>on("div",{children:m.component},g))}))};import{jsx as nn,jsxs as Cf}from"react/jsx-runtime";var ft={type:"ANNOTATION_EDGE",reconnectable:!0},js=({id:e,source:t,target:o,selected:n,data:r})=>{let{zoom:i}=Af(),{isMultipleSelection:s}=D(),a=Qs(t),l=Qs(o);if(!a||!l)return null;let{sx:c,sy:d,tx:f,ty:u}=Oe(a,l),[p,h,m]=wf({sourceX:c,sourceY:d,targetX:f,targetY:u}),g=n||(a==null?void 0:a.selected)||(l==null?void 0:l.selected),T=1/i;return Cf("g",{className:P("text-grey-400 hover:text-grey-500",{"text-blue-500 hover:text-blue-600":g}),children:[nn(vf,{id:e,path:p,strokeDasharray:4,className:P("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)})}),nn(Nf,{children:nn("div",{className:"absolute z-[3000] pointer-events-auto flex flex-col items-center gap-1",style:{transform:`translate(-50%, -50%) translate(${h}px, ${m}px)`},children:n&&!s&&nn(pt,{edgeId:e,edgeType:"ANNOTATION_EDGE",style:{transform:`scale(${T})`}})})})]})};import{BaseEdge as Mf,EdgeLabelRenderer as Pf,getSmoothStepPath as Lf,MarkerType as oa,useInternalNode as na,useReactFlow as kf,useViewport as Df}from"@xyflow/react";import{useState as Rf}from"react";import{useEffect as ea,useRef as If,useState as Sf}from"react";import{jsx as ta}from"react/jsx-runtime";var J=({value:e,maxLength:t,style:o,className:n,contentClassName:r,isEditing:i,onChange:s,onBlur:a})=>{let l=If(null),[c,d]=Sf(!1);ea(()=>{d(i!=null?i:!1)},[i]),ea(()=>{if(c&&l.current){l.current.focus();let m=document.createRange();m.selectNodeContents(l.current);let g=window.getSelection();g&&(g.removeAllRanges(),g.addRange(m))}},[c]);let f=m=>{m.stopPropagation(),c||d(!0)},u=m=>{let g=m.currentTarget.innerText.trim(),T=t&&g.length>=t,x=["Backspace","Delete","ArrowLeft","ArrowRight","ArrowUp","ArrowDown","Home","End","Tab","Enter","Escape","Shift"],y=m.ctrlKey||m.metaKey,E=y&&m.key==="a",b=y&&m.key==="c",A=y&&m.key==="x",N=y&&m.key==="v";function C(w){return/\w/.test(w)}if(g.length===0&&!C(m.key)&&!x.includes(m.key)&&!y){m.preventDefault();return}T&&(x.includes(m.key)||E||b||A||N||m.preventDefault())},p=m=>{if(!t)return;m.preventDefault();let g=m.clipboardData.getData("text/plain"),T=m.currentTarget.innerText,x=window.getSelection();if(!x||x.rangeCount===0)return;let y=x.getRangeAt(0);if((T.substring(0,y.startOffset)+g+T.substring(y.endOffset)).length>t){let b=t-(T.length-(y.endOffset-y.startOffset)),A=g.substring(0,Math.max(0,b));A&&(y.deleteContents(),y.insertNode(document.createTextNode(A)),y.setStartAfter(y.endContainer),y.collapse(!0),x.removeAllRanges(),x.addRange(y))}else y.deleteContents(),y.insertNode(document.createTextNode(g)),y.setStartAfter(y.endContainer),y.collapse(!0),x.removeAllRanges(),x.addRange(y)},h=m=>{d(!1);let g=m.currentTarget.innerText.trim();t&&g.length>t&&(g=g.substring(0,t)),m.currentTarget.innerText=g,a==null||a(),g!==e&&(s==null||s(g))};return ta("div",{className:P("flex-1 p-2 self-stretch content-center border border-transparent overflow-hidden text-ellipsis text-sm text-center",n,{"border border-dashed border-grey-400":c}),style:o,onDoubleClick:f,children:ta("div",{ref:l,className:P("outline-none whitespace-pre-wrap overflow-hidden",r,{"nodrag nopan cursor-text":c}),contentEditable:!0,suppressContentEditableWarning:!0,onKeyDown:u,onPaste:p,onBlur:h,children:e})})};import{jsx as rn,jsxs as ra}from"react/jsx-runtime";var le={type:"SEQUENCE_EDGE",reconnectable:!0,markerStart:{type:oa.ArrowClosed},markerEnd:{type:oa.Arrow},data:{label:""}},ia=({id:e,source:t,target:o,data:n,selected:r})=>{let{zoom:i}=Df(),{updateEdgeData:s}=kf(),{isMultipleSelection:a}=D(),[l,c]=Rf(!1),d=na(t),f=na(o);if(!d||!f)return null;let{sx:u,sy:p,tx:h,ty:m,sourcePos:g,targetPos:T}=Oe(d,f),[x,y,E]=Lf({sourceX:u,sourceY:p,targetX:h,targetY:m,sourcePosition:g,targetPosition:T}),b=r||(d==null?void 0:d.selected)||(f==null?void 0:f.selected),A=b?"sequence-edge-marker-highlighted":"sequence-edge-marker",N=l||(n==null?void 0:n.label.trim().length)>0,C=1/i,L=()=>{c(!0)},w=()=>{c(!1)},S=M=>{s(e,{label:M.trim()})};return ra("g",{className:P("text-grey-400 hover:text-grey-500",{"text-blue-500 hover:text-blue-600":b}),onBlur:w,onDoubleClick:L,children:[rn(Mf,{id:e,path:x,markerEnd:`url(#${A})`,className:P("stroke-2 stroke-current transition-colors duration-75",{"stroke-red-500 hover:stroke-red-600":n==null?void 0:n.hasError,"stroke-blue-500 hover:stroke-blue-600 drop-shadow-[0_0_3px_rgba(59,130,246,0.5)]":b&&!(n!=null&&n.hasError)})}),rn(Pf,{children:ra("div",{className:"absolute z-[3000] pointer-events-auto flex flex-col items-center gap-1",style:{transform:`translate(-50%, -50%) translate(${y}px, ${E}px)`},children:[r&&!a&&rn(pt,{edgeId:e,edgeType:"SEQUENCE_EDGE",sourceNode:d,targetNode:f,style:{transform:`scale(${C})`}}),N&&rn(J,{value:n==null?void 0:n.label,className:"min-w-8 max-w-56 bg-white rounded-md px-2 py-1 text-xs",isEditing:l,onChange:S})]})})]})};var Jt=e=>new Map(e.map(t=>[t.id,t])),sn=e=>e.some(t=>t.type==="START_EVENT"),sa=(e,t,o,n)=>{let r=Jt(o),i=r.get(e);if(!i||i.type!=="START_EVENT")return!1;let s=r.get(t);return(s==null?void 0:s.type)==="ANNOTATION"?!1:n.filter(l=>{if(l.source!==e)return!1;let c=r.get(l.target);return(c==null?void 0:c.type)!=="ANNOTATION"}).length>=1},an=(e,t,o)=>{var i;let n=t.find(s=>s.id===e);return!n||n.type!=="GATEWAY"||((i=n.data)==null?void 0:i.variant)!=="EXCLUSIVE"?!1:o.filter(s=>s.source===e).length>=2},aa=(e,t,o)=>{var s,a,l,c;let n=Jt(o),r=n.get(e),i=n.get(t);return(r==null?void 0:r.type)!=="GATEWAY"||(i==null?void 0:i.type)!=="GATEWAY"||((s=r==null?void 0:r.data)==null?void 0:s.variant)==="EXCLUSIVE"&&((a=i==null?void 0:i.data)==null?void 0:a.variant)==="PARALLEL"||((l=r==null?void 0:r.data)==null?void 0:l.variant)==="COMPLEX"&&((c=i==null?void 0:i.data)==null?void 0:c.variant)==="PARALLEL"},ln=(e,t)=>{var n;let o=t.find(r=>r.id===e);return!o||o.type!=="TASK"?!1:((n=o.data)==null?void 0:n.variant)==="SCRIPT"},cn=(e,t)=>{var n;let o=t.find(r=>r.id===e);return!o||o.type!=="TASK"?!1:((n=o.data)==null?void 0:n.attribute)==="LOOP"},dn=(e,t,o)=>{let n=Jt(t),r=n.get(e);return!r||r.type!=="TASK"?!1:o.filter(s=>s.target===e).some(s=>{let a=n.get(s.source);return(a==null?void 0:a.type)==="START_EVENT"})},un=(e,t,o)=>{let n=Jt(t),r=n.get(e);return!r||r.type!=="TASK"?!1:o.filter(s=>s.source===e).some(s=>{let a=n.get(s.target);return(a==null?void 0:a.type)==="END_EVENT"})},pn=(e,t)=>t.filter(n=>n.source===e).length>0,fn=(e,t,o,n)=>{let r=Jt(o),i=r.get(e);if(!i||i.type!=="TASK")return!1;let s=t?r.get(t):null;return(s==null?void 0:s.type)==="ANNOTATION"?!1:n.filter(l=>{if(l.source!==e)return!1;let c=r.get(l.target);return(c==null?void 0:c.type)!=="ANNOTATION"}).length>=2};var Vf=[e=>({isValid:e.sourceNodeId!==e.targetNodeId,reason:"self_connection_not_allowed"}),e=>({isValid:!sa(e.sourceNodeId,e.targetNodeId,e.nodes,e.edges),reason:"start_event_limit_reached"}),e=>({isValid:!an(e.sourceNodeId,e.nodes,e.edges),reason:"gateway_limit_reached"}),e=>({isValid:!fn(e.sourceNodeId,e.targetNodeId,e.nodes,e.edges),reason:"task_limit_reached"}),e=>({isValid:aa(e.sourceNodeId,e.targetNodeId,e.nodes),reason:"gateway_to_gateway_not_allowed"}),e=>({isValid:!(e.sourceNodeType==="START_EVENT"&&e.targetNodeType==="END_EVENT"),reason:"start_to_end_not_allowed"}),e=>({isValid:!(e.sourceNodeType==="GATEWAY"&&e.targetNodeType==="END_EVENT"),reason:"gateway_to_end_not_allowed"}),e=>({isValid:!(e.sourceNodeType==="START_EVENT"&&e.targetNodeType==="GATEWAY"),reason:"start_to_gateway_not_allowed"}),e=>({isValid:!(ln(e.sourceNodeId,e.nodes)&&e.targetNodeType==="END_EVENT"),reason:"script_to_end_not_allowed"}),e=>({isValid:!(cn(e.sourceNodeId,e.nodes)&&e.targetNodeType==="END_EVENT"),reason:"loop_to_end_not_allowed"}),e=>({isValid:!(dn(e.sourceNodeId,e.nodes,e.edges)&&e.targetNodeType==="END_EVENT"),reason:"initial_activity_to_end_not_allowed"}),e=>({isValid:!(un(e.sourceNodeId,e.nodes,e.edges)&&e.targetNodeType!=="ANNOTATION"),reason:"final_activity_cannot_connect"}),e=>({isValid:!(pn(e.sourceNodeId,e.edges)&&e.targetNodeType==="END_EVENT"),reason:"activity_has_outgoing_connections"}),e=>({isValid:({START_EVENT:["TASK","ANNOTATION"],END_EVENT:["ANNOTATION"],TASK:["TASK","END_EVENT","GATEWAY","ANNOTATION"],GATEWAY:["TASK","END_EVENT","ANNOTATION","GATEWAY"],LANE:["ANNOTATION"],ANNOTATION:[],UNSUPPORTED:[]}[e.sourceNodeType]||[]).includes(e.targetNodeType),reason:"connection_type_not_allowed"})],la=e=>{for(let t of Vf){let o=t(e);if(!o.isValid)return o}return{isValid:!0}};var Of=[{sourceTypes:["GATEWAY"],targetTypes:["TASK","GATEWAY"],validate:e=>({shouldDisable:an(e.sourceNodeId,e.nodes,e.edges),reason:"gateway_limit_reached"})},{targetTypes:["START_EVENT"],validate:e=>({shouldDisable:sn(e.nodes),reason:"start_event_already_exists"})},{sourceTypes:["TASK"],targetTypes:["END_EVENT"],validate:e=>({shouldDisable:ln(e.sourceNodeId,e.nodes),reason:"script_to_end_not_allowed"})},{sourceTypes:["TASK"],targetTypes:["END_EVENT"],validate:e=>({shouldDisable:cn(e.sourceNodeId,e.nodes),reason:"loop_to_end_not_allowed"})},{sourceTypes:["TASK"],targetTypes:["END_EVENT"],validate:e=>({shouldDisable:dn(e.sourceNodeId,e.nodes,e.edges),reason:"initial_activity_to_end_not_allowed"})},{sourceTypes:["TASK"],validate:e=>({shouldDisable:un(e.sourceNodeId,e.nodes,e.edges)&&e.targetNodeType!=="ANNOTATION",reason:"final_activity_cannot_connect"})},{targetTypes:["END_EVENT"],validate:e=>({shouldDisable:pn(e.sourceNodeId,e.edges),reason:"activity_has_outgoing_connections"})},{sourceTypes:["TASK"],validate:e=>({shouldDisable:fn(e.sourceNodeId,null,e.nodes,e.edges)&&e.targetNodeType!=="ANNOTATION",reason:"task_limit_reached"})}],ca=e=>{let t=Of.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}};var ua=({setEdges:e})=>{let{getNode:t,getEdges:o,getNodes:n}=Gf(),r=da(s=>{let a=t(s.source),l=t(s.target);if(!a||!l)return!1;let c={sourceNodeId:a.id,targetNodeId:l.id,sourceNodeType:a.type,targetNodeType:l.type,nodes:n(),edges:o()};return la(c).isValid},[t,o,n]),i=da(s=>{e(a=>{let l=t(s.target),c=(l==null?void 0:l.type)==="ANNOTATION"?ft:le;return Hf(_(_({},s),c),a)})},[t,e]);return{isValidConnection:r,onConnect:i}};import{useState as _a}from"react";import{useTranslation as Bf}from"lecom-ui";import{useReactFlow as zf}from"@xyflow/react";var Qt=(e=[])=>e.filter(t=>t.type==="START_EVENT"),Ke=(e=[])=>e.filter(t=>t.type==="END_EVENT"),Ge=(e=[])=>e.filter(t=>t.type==="TASK")||[],pa=(e=[])=>e.filter(t=>{var o;return t.type==="TASK"&&((o=t.properties)==null?void 0:o.variant)==="SCRIPT"}),fa=(e=[])=>e.filter(t=>{var o;return t.type==="TASK"&&((o=t.properties)==null?void 0:o.variant)==="SUBPROCESS"}),mn=(e=[])=>e.filter(t=>t.type==="GATEWAY"),ma=(e=[])=>e.filter(t=>{var o;return t.type==="GATEWAY"&&((o=t.properties)==null?void 0:o.variant)==="EXCLUSIVE"}),ce=(e,t=[])=>t.filter(o=>o.source===e),jt=(e,t=[])=>t.filter(o=>o.target===e),ga=(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"},ha=(e,t)=>{let o=ce(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},ya=e=>e?/\w/g.test(e.trim()):!1,H=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:[]}},be=(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)}},xa=(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 eo=[{id:"start_event_not_found",validate:e=>{let t=Qt(e.nodes);return H({isValid:t.length>=1})}},{id:"end_event_not_found",validate:e=>{let t=Ke(e.nodes);return H({isValid:t.length>=1})}},{id:"multiple_start_event_not_allowed",validate:e=>{let t=Qt(e.nodes),o=t.length===1;if(t.length===0)return H({isValid:!0});if(!o)return H({isValid:!1,nodeIds:t.map(i=>i.id)});let n=ce(t[0].id,e.edges);if(!(n.length<=1)){let i=[...t.map(s=>s.id),...n.map(s=>s.target)];return H({isValid:!1,nodeIds:[...new Set(i)]})}return H({isValid:!0})}},{id:"task_flows_limit_exceeds",validate:e=>{let t=Ge(e.nodes),o=be(t,n=>ce(n.id,e.edges).length<=2);return H({isValid:o.isValid,nodeIds:o.invalidIds})}},{id:"task_label_empty",highlightRelatedEdges:!1,validate:e=>{let t=Ge(e.nodes),o=be(t,n=>!!n.label&&n.label.trim()!=="");return H({isValid:o.isValid,nodeIds:o.invalidIds})}},{id:"task_label_length",highlightRelatedEdges:!1,validate:e=>{let o=Ge(e.nodes),n=be(o,r=>!r.label||r.label.length<=60);return H({isValid:n.isValid,nodeIds:n.invalidIds})}},{id:"duplicate_task_name",highlightRelatedEdges:!1,validate:e=>{let t=Ge(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 H({isValid:n.length===0,nodeIds:n})}},{id:"nested_gateway",validate:e=>{let t=mn(e.nodes),o=[],n=[];for(let r of t){let i=ce(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 H({isValid:o.length===0,nodeIds:o.length>0?[...new Set(o)]:[],edgeIds:n})}},{id:"events_nested",validate:e=>{let t=[...Qt(e.nodes),...Ke(e.nodes)],o=[],n=[];for(let r of t){let i=ce(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 H({isValid:o.length===0,nodeIds:o.length>0?[...new Set(o)]:[],edgeIds:n})}},{id:"flows_on_end_tasks_not_allowed",validate:e=>{let t=Ke(e.nodes),o=[],n=[];for(let r of t){let i=jt(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=ce(a.id,e.edges);l.length>1&&(o.push(a.id),l.forEach(c=>n.push(c.id)))}}}return H({isValid:o.length===0,nodeIds:o,edgeIds:n})}},{id:"conditions_flows_limit_exceeds",validate:e=>{let t=ma(e.nodes),o=be(t,r=>ce(r.id,e.edges).length<=2),n=o.invalidIds.flatMap(r=>ce(r,e.edges).map(i=>i.id));return H({isValid:o.isValid,nodeIds:o.invalidIds,edgeIds:n})}},{id:"activity_name_invalid",validate:e=>{let t=Ge(e.nodes),o=be(t,n=>!n.label||ya(n.label));return H({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 H({isValid:!0});let t=Ke(e.nodes)[0];if(!t)return H({isValid:!0});let o=jt(t.id,e.edges);if(!o.length)return H({isValid:!0});let r=Ge(e.nodes).filter(l=>o.some(c=>c.source===l.id)),i=be(r,l=>!ga(l.id,e));return H({isValid:i.isValid,nodeIds:i.isValid?[]:[t.id,...i.invalidIds]})}},{id:"concurrent_initial_and_final_event",validate:e=>{let t=Ge(e.nodes),o=Ke(e.nodes)[0];if(!o)return H({isValid:!0});let n=t.filter(l=>{let c=jt(l.id,e.edges),d=ce(l.id,e.edges),f=c.some(p=>{var h;return((h=e.nodes.find(m=>m.id===p.source))==null?void 0:h.type)==="START_EVENT"}),u=d.some(p=>{var h;return((h=e.nodes.find(m=>m.id===p.target))==null?void 0:h.type)==="END_EVENT"});return f&&u}),r=jt(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 H(a)}},{id:"gateway_flow_to_event",validate:e=>{let t=mn(e.nodes),o=[],n=[];for(let r of t){let i=ce(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 H({isValid:o.length===0,nodeIds:o.length>0?[...new Set(o)]:[],edgeIds:n})}},{id:"gateway_missing_output_streams",validate:e=>{let t=mn(e.nodes),o=be(t,n=>ce(n.id,e.edges).length>=1);return H({isValid:o.isValid,nodeIds:o.invalidIds})}},{id:"event_to_condition",validate:e=>{let t=[...Qt(e.nodes),...Ke(e.nodes)],o=[],n=[];for(let r of t){let i=ce(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 H({isValid:o.length===0,nodeIds:o.length>0?[...new Set(o)]:[],edgeIds:n})}},{id:"script_in_final_activity",validate:e=>{let t=pa(e.nodes),o=be(t,n=>!ha(n.id,e));return H({isValid:o.isValid,nodeIds:o.invalidIds})}},{id:"subprocess_referenced_not_configured",validate:e=>{let t=fa(e.nodes),o=be(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 H({isValid:o.isValid,nodeIds:o.invalidIds})}}];var Ea=e=>{e=e||{nodes:[],edges:[]},e.nodes=e.nodes||[],e.edges=e.edges||[];let t=[];for(let n of eo){let r=n.validate(e);r.isValid||t.push({id:n.id,message:n.id,nodeIds:r.nodeIds||[],edgeIds:r.edgeIds||[]})}return{isValid:t.length===0,errors:t}};var ba=()=>{let{t:e}=Bf(),[t,o]=_a(null),{setNodes:n,setEdges:r,getNodes:i,getEdges:s}=zf(),[a,l]=_a(!1);return{validationResult:t,validateDiagram:u=>{let p=xa(u.nodes,u.edges),h=Ea(p),m=h.errors.map(g=>v(_({},g),{message:e(`validation.errors.${g.id}`)}));return a||l(!0),{isValid:h.isValid,errors:m}},handleValidationComplete:u=>{if(o(u),!u)return;let p=[],h=[];u.errors.forEach(N=>{N.nodeIds&&N.nodeIds.length>0&&N.nodeIds.forEach(C=>p.push(C)),N.edgeIds&&N.edgeIds.length>0&&N.edgeIds.forEach(C=>h.push(C))});let m=[...new Set(p)];n(N=>N.map(C=>v(_({},C),{data:v(_({},C.data),{hasError:!1})}))),r(N=>N.map(C=>v(_({},C),{data:v(_({},C.data),{hasError:!1})})));let g=i(),T=s(),x=new Set(m),y=new Set;u.errors.forEach(N=>{var w,S;let C=eo.find(M=>M.id===N.id);(C==null?void 0:C.highlightRelatedEdges)!==!1&&((w=N.edgeIds)==null||w.forEach(M=>y.add(M)),(S=N.nodeIds)==null||S.forEach(M=>{T.forEach(I=>{(I.source===M||I.target===M)&&y.add(I.id)})}))});let E=new Set,b=new Set,A=new Set;g.forEach(N=>{N.type==="START_EVENT"?E.add(N.id):N.type==="END_EVENT"&&b.add(N.id)}),T.forEach(N=>{E.has(N.source)&&A.add(N.target),b.has(N.target)&&A.add(N.source)}),A.forEach(N=>{var C,L;if(x.has(N)){let w=(C=u.errors.find(M=>{var I;return(I=M.nodeIds)==null?void 0:I.includes(N)}))==null?void 0:C.id;((L=eo.find(M=>M.id===w))==null?void 0:L.highlightRelatedEdges)!==!1&&T.forEach(M=>{M.source===N&&b.has(M.target)&&(x.add(M.target),y.add(M.id)),M.target===N&&E.has(M.source)&&(x.add(M.source),y.add(M.id))})}}),x.size>0&&n(N=>N.map(C=>v(_({},C),{data:v(_({},C.data),{hasError:x.has(C.id)})}))),y.size>0&&r(N=>N.map(C=>v(_({},C),{data:v(_({},C.data),{hasError:y.has(C.id)})})))},clearValidation:()=>{o(null),l(!1),n(u=>u.map(p=>v(_({},p),{data:v(_({},p.data),{hasError:!1})}))),r(u=>u.map(p=>v(_({},p),{data:v(_({},p.data),{hasError:!1})})))},isAutoValidationEnabled:a}};import{useReactFlow as Ff}from"@xyflow/react";import{useTranslation as Wf}from"lecom-ui";import{useEffect as Uf}from"react";import{v7 as Ta}from"uuid";var gn=(e,t)=>{let n=e.filter(i=>i.type==="TASK").map(i=>{var a;let s=(a=i.data)==null?void 0:a.label;if(s&&s.startsWith(`${t} `)){let l=s.match(new RegExp(`^${t} (\\d+)$`));return l?parseInt(l[1],10):0}return 0}).filter(i=>i>0),r=n.length>0?Math.max(...n)+1:1;return`${t} ${r}`},mt=(e,t)=>{let n=t.filter(a=>a.type==="TASK").map(a=>{var l;return(l=a.data)==null?void 0:l.label}).filter(Boolean);if(!n.includes(e))return e;let r=e.replace(/\s+\(\d+\)$/,""),i=n.filter(a=>a===r||a.startsWith(`${r} (`)).map(a=>{if(a===r)return 1;let l=a.match(/\s+\((\d+)\)$/);return l?parseInt(l[1],10):0}).filter(a=>a>0),s=2;for(;i.includes(s);)s++;return`${r} (${s})`};var Yf=15,va="bpmn:selection",$f=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},Na=e=>{if(!$f(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},wa=({offset:e=Yf}={})=>{let{getNodes:t,setNodes:o,getEdges:n,setEdges:r}=Ff(),{t:i}=Wf();Uf(()=>{let s=l=>{var m,g;if(!Na(l))return;let c=t(),d=n(),f=c.filter(T=>T.selected);if(!f.length)return;l.preventDefault(),l.stopPropagation();let u=d.filter(T=>f.some(x=>x.id===T.source)&&f.some(x=>x.id===T.target)),h=JSON.stringify({nodes:f,edges:u});(m=l.clipboardData)==null||m.setData(va,h),(g=l.clipboardData)==null||g.setData("text/plain",`BPMN Selection: ${f.length} nodes`)},a=l=>{var y,E;if(!Na(l))return;let c=(y=l.clipboardData)==null?void 0:y.getData(va);if(!c)return;l.preventDefault(),l.stopPropagation();let d;try{d=JSON.parse(c)}catch(b){return}if(!((E=d.nodes)!=null&&E.length))return;let f=new Map,u=t(),p=[],h=u.some(b=>b.type==="START_EVENT"),m=d.nodes.filter(b=>b.type==="START_EVENT"),g=d.nodes;if(h&&m.length>0&&(g=d.nodes.filter(b=>b.type!=="START_EVENT"),g.length===0))return;let T=g.map(b=>{var C;let A=Ta();f.set(b.id,A);let N=v(_({},b),{id:A,selected:!0,position:{x:b.position.x+e,y:b.position.y+e}});if(b.type==="TASK"){let L=(C=b.data)==null?void 0:C.label,w=mt(L||i("bpmn.task.label.prefix"),[...u,...p]);N.data=v(_({},b.data),{label:w})}return p.push(N),N}),x=d.edges.map(b=>v(_({},b),{id:Ta(),selected:!0,source:f.get(b.source)||b.source,target:f.get(b.target)||b.target}));o(b=>[...b.map(A=>v(_({},A),{selected:!1})),...T]),r(b=>[...b.map(A=>v(_({},A),{selected:!1})),...x])};return document.addEventListener("copy",s,!0),document.addEventListener("paste",a,!0),()=>{document.removeEventListener("copy",s,!0),document.removeEventListener("paste",a,!0)}},[t,o,n,r,e,i])};import{useReactFlow as fm,useStoreApi as mm}from"@xyflow/react";import{useTranslation as gm}from"lecom-ui";import{useState as hm}from"react";import{v7 as Ha}from"uuid";var Xf={MIN_WIDTH:36,MIN_HEIGHT:36},Kf={MIN_WIDTH:36,MIN_HEIGHT:36},qf={MIN_WIDTH:56,MIN_HEIGHT:56},hn={MIN_WIDTH:176,MIN_HEIGHT:96},yn={HEADER_WIDTH:40,MIN_WIDTH:840,MIN_HEIGHT:256},W={HEADER_WIDTH:40,MIN_WIDTH:800,MIN_HEIGHT:256},xn={MIN_WIDTH:176,MIN_HEIGHT:64},Zf={MIN_WIDTH:128,MIN_HEIGHT:64},R={START_EVENT:Xf,END_EVENT:Kf,GATEWAY:qf,TASK:hn,LANE:W,ANNOTATION:xn,UNSUPPORTED:Zf};import Ia from"@dagrejs/dagre";import{getNodesBounds as em}from"@xyflow/react";import{orderBy as tm}from"lodash";import{orderBy as Jf}from"lodash";var Ce=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}},Ie=e=>Jf(e,[o=>{let n=o.type==="LANE";return n&&!o.parentId?0:n?1:2}],["asc"]),Aa=(e,t)=>{let{x:o,y:n}=Ce(e),{x:r,y:i}=Ce(t);return{x:o-r,y:n-i}};var gt=({parentId:e,nodes:t,includeTypes:o=[...Object.values(k)],excludeTypes:n=[]})=>t.some(r=>r.parentId===e&&(!o.length||o.includes(r.type))&&!n.includes(r.type)),Qf=(e,t)=>{let{x:o,y:n}=Ce(e),{x:r,y:i}=Ce(t),s=o-r,a=n-i;return Math.sqrt(s*s+a*a)},jf=(e,t)=>{let{x:o,y:n,w:r,h:i}=Ce(e),{x:s,y:a,w:l,h:c}=Ce(t);return o<s+l&&s<o+r&&n<a+c&&a<n+i},to=(e,t)=>{let o=null,n=1/0;for(let r of t)if(r.id!==e.id&&jf(e,r)){let i=Qf(e,r);i<n&&(n=i,o=r)}return o},Ca=(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 Sa=(e=[],t=[],o="LR")=>{let n=new Ia.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)),Ia.layout(n),{nodes:e.map(i=>{let s=n.node(i.id);return v(_({},i),{position:{x:s.x-i.width/2,y:s.y-i.height/2}})}),edges:t}},oo=e=>{let t=e.filter(n=>n.type==="LANE"&&!n.parentId),o=[...e];return t.forEach(n=>{o=qe(n.id,o)}),o},qe=(e,t)=>{var p,h;let o=[...t],n=o.find(m=>m.id===e);if(!n)return o;let r=o.filter(m=>m.parentId===e&&m.type==="LANE");if(r.length===0)return o;let i=tm(r,["position.y"]),s=Math.max((h=(p=n.measured)==null?void 0:p.width)!=null?h:0,yn.MIN_WIDTH),a=Ca(e,i)||W.MIN_WIDTH,l=Math.max(s,a),c=s-W.HEADER_WIDTH>=a,d=0,f=0;i.forEach(m=>{var g,T,x,y;o=o.map(E=>E.id===m.id?v(_({},E),{width:c?l-W.HEADER_WIDTH:l,measured:v(_({},E.measured),{width:c?l-W.HEADER_WIDTH:l}),position:{x:W.HEADER_WIDTH,y:d}}):E),d+=(T=(g=m.measured)==null?void 0:g.height)!=null?T:0,f+=(y=(x=m.measured)==null?void 0:x.height)!=null?y:0}),o=o.map(m=>m.id===e?v(_({},m),{height:f,width:c?l:l+W.HEADER_WIDTH,measured:v(_({},m.measured),{height:f,width:c?l:l+W.HEADER_WIDTH})}):m);let u=o.find(m=>m.id===e);return u!=null&&u.parentId&&(o=qe(u.parentId,o)),o},Ma=(e,t,o)=>{if(e.type==="LANE")return o;let n=ae(t),r=ae(e);return r.y<n.y&&(e.position.y=0),r.x<n.x+W.HEADER_WIDTH&&(e.position.x=W.HEADER_WIDTH),r.y2>n.y2&&(t.height=r.y2-n.y,t.measured.height=r.y2-n.y),r.x2>n.x2&&(t.width=r.x2-n.x,t.measured.width=r.x2-n.x),o=o.map(i=>i.id===t.id?v(_({},i),{height:t.height,width:t.width,measured:t.measured}):i.id===e.id?v(_({},i),{position:e.position}):i),o},Pa=()=>{let e=document.querySelector(".react-flow__viewport");return e||(console.error("Flow element (.react-flow__viewport) not found."),null)},om=50,La=(e,t=om)=>{let o=em(e);return{x:o.x-t,y:o.y-t,width:o.width+t*2,height:o.height+t*2}};import{create as nm}from"zustand";var ht=nm(e=>({draggableNode:null,setDraggableNode:t=>{e({draggableNode:t})}}));import{BaseEdge as rm,EdgeLabelRenderer as im,getSmoothStepPath as sm,MarkerType as am,useInternalNode as ka,useReactFlow as lm,useViewport as cm}from"@xyflow/react";import{useState as dm}from"react";import{jsx as En,jsxs as Da}from"react/jsx-runtime";var Kw={type:"MESSAGE_EDGE",markerEnd:{type:am.Arrow},data:{label:""}},Ra=({id:e,source:t,target:o,data:n,selected:r})=>{let{zoom:i}=cm(),{updateEdgeData:s}=lm(),{isMultipleSelection:a}=D(),[l,c]=dm(!1),d=ka(t),f=ka(o);if(!d||!f)return null;let{sx:u,sy:p,tx:h,ty:m,sourcePos:g,targetPos:T}=Oe(d,f),[x,y,E]=sm({sourceX:u,sourceY:p,targetX:h,targetY:m,sourcePosition:g,targetPosition:T}),b=r||(d==null?void 0:d.selected)||(f==null?void 0:f.selected),A=b?"sequence-edge-marker-highlighted":"sequence-edge-marker",N=l||(n==null?void 0:n.label.trim().length)>0,C=1/i,L=()=>{c(!0)},w=()=>{c(!1)},S=M=>{s(e,{label:M.trim()})};return Da("g",{className:P("text-grey-400 hover:text-grey-500",{"text-blue-500 hover:text-blue-600":b}),onBlur:w,onDoubleClick:L,children:[En(rm,{id:e,path:x,markerEnd:`url(#${A})`,strokeDasharray:4,className:P("stroke-2 stroke-current transition-colors duration-75",{"stroke-red-500 hover:stroke-red-600":n==null?void 0:n.hasError,"stroke-blue-500 hover:stroke-blue-600 drop-shadow-[0_0_3px_rgba(59,130,246,0.5)]":b&&!(n!=null&&n.hasError)})}),En(im,{children:Da("div",{className:"absolute z-[3000] pointer-events-auto flex flex-col items-center gap-1",style:{transform:`translate(-50%, -50%) translate(${y}px, ${E}px)`},children:[r&&!a&&En(pt,{edgeId:e,edgeType:"MESSAGE_EDGE",style:{transform:`scale(${C})`}}),N&&En(J,{value:n==null?void 0:n.label,className:"min-w-8 max-w-56 bg-white rounded-md px-2 py-1 text-xs",isEditing:l,onChange:S})]})})]})};import{getBezierPath as um}from"@xyflow/react";import{jsx as Va,jsxs as pm}from"react/jsx-runtime";var Oa=({toX:e,toY:t,fromPosition:o,toPosition:n,fromNode:r})=>{if(!r)return null;let i={id:"connection-target",measured:{width:1,height:1},internals:{positionAbsolute:{x:e,y:t}}},{sx:s,sy:a,tx:l,ty:c,sourcePos:d,targetPos:f}=Oe(r,i),[u]=um({sourceX:s,sourceY:a,sourcePosition:d||o,targetPosition:f||n,targetX:l||e,targetY:c||t});return pm("g",{children:[Va("path",{fill:"none",className:"stroke-2 stroke-grey-400 animated",d:u}),Va("circle",{cx:l||e,cy:c||t,fill:"none",r:4,className:"stroke-2 stroke-grey-500"})]})};var Ga=({nodes:e,setNodes:t,setEdges:o})=>{let n=mm(),{getInternalNode:r,screenToFlowPosition:i}=fm(),{draggableNode:s,setDraggableNode:a}=ht(),{setIsDragging:l}=D(),{rebuildIndex:c,forceRebuildIndex:d}=ut(),{t:f}=gm(),[u,p]=hm(null),h=(w,S=!1)=>{let M=S?"[&>div]:bg-red-50 [&>div]:outline [&>div]:outline-[3px] [&>div]:outline-red-500":"[&>div]:bg-green-50/75 [&>div]:outline [&>div]:outline-[3px] [&>div]:outline-green-500";t(I=>I.map(V=>v(_({},V),{className:V.id===w?M:""})))},m=()=>{let{nodeLookup:w}=n.getState();return Array.from(w.values())},g=w=>{let S=r(w.id),M=m();if(w.type==="LANE"){if(gt({parentId:w.id,nodes:e,includeTypes:["LANE"]})){h();return}let X=M.filter(z=>z.id!==w.id&&z.type==="LANE"&&!z.parentId),O=to(S,X);if(!O){h();return}if(gt({parentId:O.id,nodes:e,excludeTypes:["LANE"]})){h(O.id,!0);return}h(O.id);return}let V=M.filter(U=>U.id!==w.id&&U.type==="LANE"),F=to(S,V);if(!F){h();return}if(gt({parentId:F.id,nodes:e,includeTypes:["LANE"]})){h();return}h(F.id)},T=w=>w.map(S=>v(_({},S),{className:void 0})),x=w=>w.some(M=>M.dragging)?w.map(M=>M.dragging?v(_({},M),{dragging:!1}):M):w,y=w=>{w.preventDefault(),w.dataTransfer.dropEffect="move"},E=(w,S)=>{w.preventDefault(),g(S)},b=(w,S,M)=>{var U,X;let I=[...M];if(w.parentId===S.id)return I=Ma(w,S,I),I=oo(I),T(I);if(w.type==="LANE"){if(gt({parentId:S.id,nodes:I,excludeTypes:["LANE"]})){let ee=ae(S),ze=50,tt=50;return I.map(ve=>{var It,ao;return ve.id===w.id?v(_({},ve),{position:{x:(It=u==null?void 0:u.x)!=null?It:ee.x+ze,y:(ao=u==null?void 0:u.y)!=null?ao:ee.y2+tt}}):ve})}let z=I.filter(ee=>ee.parentId===S.id).reduce((ee,ze)=>{var tt,ve;return ee+((ve=(tt=ze.measured)==null?void 0:tt.height)!=null?ve:0)},0),de={x:W.HEADER_WIDTH,y:z};return I=I.map(ee=>ee.id===w.id?v(_({},ee),{parentId:S.id,position:de,className:void 0}):v(_({},ee),{className:void 0})),I=qe(S.id,I),I}if(gt({parentId:S.id,nodes:I,includeTypes:["LANE"]})){let O;if(w.parentId){let B=r(w.parentId),{x:z,y:de}=Ce(B);O={x:z+((U=w.position.x)!=null?U:0),y:de+((X=w.position.y)!=null?X:0)}}return I=I.map(B=>B.id===w.id?v(_({},B),{position:O!=null?O:B.position,parentId:void 0,className:void 0}):v(_({},B),{className:void 0})),I}let G=Aa(w,S);return I=I.map(O=>{if(O.id===w.id){let B=ae(w),z=ae(S);return B.y<z.y&&(G.y=0),B.x<z.x+W.HEADER_WIDTH&&(G.x=W.HEADER_WIDTH),v(_({},O),{parentId:S.id,position:G,className:void 0})}return v(_({},O),{className:void 0})}),I=oo(I),I},A=w=>{if(w.preventDefault(),!(s!=null&&s.type))return;let S=i({x:w.clientX,y:w.clientY}),M={width:R[s.type].MIN_WIDTH,height:R[s.type].MIN_HEIGHT},I={id:Ha(),type:s.type,position:S,measured:M,data:{label:s.type==="TASK"?gn(e,f("bpmn.task.label.prefix")):"",variant:s.variant,attribute:s.attribute},selected:!0},V=v(_({},I),{internals:{positionAbsolute:S}}),F=m(),G=s.type==="LANE",U=F.filter(z=>G?z.type==="LANE"&&!z.parentId:z.type==="LANE"),X=to(V,U),O=[...e.map(z=>v(_({},z),{selected:!1})),I];X&&(O=b(V,X,O)),O=Ie(O),t(O),d();let B=w.dataTransfer.getData("sourceId");if(B){let z={id:Ha(),source:B,target:I.id};if(s.type==="ANNOTATION"){o(de=>de.concat(_(_({},z),ft)));return}o(de=>de.concat(_(_({},z),le)))}l(!1),a(null)},N=async(w,S,M)=>{let I=[...e];M.forEach(V=>{let F=m(),G=r(V.id),U=V.type==="LANE",X=F.filter(B=>B.id!==V.id&&(U?B.type==="LANE"&&!B.parentId:B.type==="LANE")),O=to(G,X);if(O){I=b(G,O,I);return}V.parentId&&(I=L(V,I))}),I=x(I),I=Ie(I),I=T(I),t(I),c(I),p(null)},C=(w,S)=>{p({x:S.position.x,y:S.position.y})},L=(w,S)=>{var G,U;let M=r(w.parentId),{x:I,y:V}=Ce(M),F={x:I+((G=w.position.x)!=null?G:0),y:V+((U=w.position.y)!=null?U:0)};return S=S.map(X=>X.id===w.id?v(_({},X),{position:F,parentId:void 0}):X),S=qe(w.parentId,S),S};return{onDragOver:y,onDrop:A,onNodeDrag:E,onNodeDragStart:C,onNodeDragStop:N}};import{useReactFlow as ym}from"@xyflow/react";import{useTranslation as xm}from"lecom-ui";import{useEffect as Em}from"react";import{v7 as Ba}from"uuid";var _m=30,bm=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},Tm=e=>!bm(e.target),za=({offset:e=_m}={})=>{let{getNodes:t,setNodes:o,getEdges:n,setEdges:r}=ym(),{t:i}=xm();Em(()=>{let s=a=>{if(a.ctrlKey&&a.key.toLowerCase()==="d"&&Tm(a)){a.preventDefault(),a.stopPropagation();let l=t(),c=n(),d=l.filter(y=>y.selected);if(!d.length)return;let f=new Map,u=[],p=l.some(y=>y.type==="START_EVENT"),h=d.filter(y=>y.type==="START_EVENT"),m=d;if(p&&h.length>0&&(m=d.filter(y=>y.type!=="START_EVENT"),m.length===0))return;let g=c.filter(y=>m.some(E=>E.id===y.source)&&m.some(E=>E.id===y.target)),T=m.map(y=>{var A;let E=Ba();f.set(y.id,E);let b=v(_({},y),{id:E,selected:!0,position:{x:y.position.x+e,y:y.position.y+e}});if(y.type==="TASK"){let N=(A=y.data)==null?void 0:A.label,C=mt(N||i("bpmn.task.label.prefix"),[...l,...u]);b.data=v(_({},y.data),{label:C})}return u.push(b),b}),x=g.map(y=>v(_({},y),{id:Ba(),selected:!0,source:f.get(y.source)||y.source,target:f.get(y.target)||y.target}));o(y=>[...y.map(E=>v(_({},E),{selected:!1})),...T]),r(y=>[...y.map(E=>v(_({},E),{selected:!1})),...x])}};return document.addEventListener("keydown",s,!0),()=>{document.removeEventListener("keydown",s,!0)}},[t,o,n,r,e,i])};import{useReactFlow as Mg}from"@xyflow/react";import{v7 as vn}from"uuid";var Wa={"start-event":"START_EVENT","end-event":"END_EVENT",task:"TASK","gateway-exclusive":"GATEWAY"},Ua={"start-event":"","end-event":"",task:"","gateway-exclusive":"EXCLUSIVE"},Fa=(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}},vm=e=>{e=e||"";let t=e.trim().split(`
2
- `),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=Fa(i[0],o),a=Fa(i[1],o);s&&a&&n.push({sourceId:s.step,targetId:a.step,label:s.edgeLabel||a.edgeLabel||""})}),{components:o,connections:n}},Ya=e=>{let{components:t,connections:o}=vm(e);return{nodes:t,edges:o}};import{Position as jm,useConnection as eg,useReactFlow as tg}from"@xyflow/react";import{Handle as $a,useReactFlow as Nm}from"@xyflow/react";import{jsx as Xa}from"react/jsx-runtime";var Z=i=>{var s=i,{type:e,position:t,className:o,nodeType:n}=s,r=Ee(s,["type","position","className","nodeType"]);let a=n==="TASK";return Xa($a,_({type:e,position:t,className:P("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))},_n=a=>{var l=a,{nodeId:e,nodeType:t,gatewayVariant:o,type:n,position:r,className:i}=l,s=Ee(l,["nodeId","nodeType","gatewayVariant","type","position","className"]);let{getEdges:c}=Nm(),f=(()=>{if(n!=="source")return!1;let u=c();return t==="TASK"?u.filter(h=>h.source===e).length>=2:t==="GATEWAY"&&o==="EXCLUSIVE"?u.filter(h=>h.source===e).length>=2:!1})();return Xa($a,_({type:n,position:r,className:P("size-2.5 border border-grey-400 bg-white transition-all duration-200 relative",{"before:content-[''] before:absolute before:inset-[-16px] before:bg-transparent":t==="TASK","before:content-[''] before:absolute before:inset-[-4px] before:bg-transparent":t!=="TASK","opacity-50 cursor-not-allowed pointer-events-none":f,"hover:border-grey-500":!f},i),style:{pointerEvents:f?"none":"auto"}},s))};import{NodeResizer as wm,useReactFlow as Am}from"@xyflow/react";import{orderBy as Cm}from"lodash";import{jsx as Im}from"react/jsx-runtime";var yt=n=>{var r=n,{nodeId:e,isVisible:t}=r,o=Ee(r,["nodeId","isVisible"]);let{getNode:i,getNodes:s,setNodes:a}=Am(),{isMultipleSelection:l}=D(),c=({width:f,height:u})=>{if(!e)return;let p=i(e);if((p==null?void 0:p.type)!=="LANE")return;let h=[...s()],m=!p.parentId,g=m?p.id:p.parentId,T=h.filter(E=>E.type==="LANE"&&E.parentId===g);if(!T.length)return;let x=Cm(T,["position.y"]),y=0;x.forEach((E,b)=>{var C,L;let A=b===x.length-1,N=(L=(C=E.measured)==null?void 0:C.height)!=null?L:0;h=h.map(w=>{if(w.id===E.id){let S=m?f-W.HEADER_WIDTH:f,M=v(_({},w),{width:S,measured:v(_({},w.measured),{width:S}),position:v(_({},w.position),{y})});return A&&m&&(M.height=u-y),M}return w}),y+=N}),h=h.map(E=>{if(E.id===g){let b=m?f:f+W.HEADER_WIDTH;return v(_({},E),{width:b,height:m?u:y,measured:{width:b,height:m?u:y}})}return E}),a(h)};return Im(wm,_({nodeId:e,handleClassName:"size-1.5 bg-blue-400",lineClassName:"border-blue-400/90 border-dashed",isVisible:!l&&t,onResizeEnd:(f,u)=>c(u)},o))};import{NodeToolbar as Ym,useReactFlow as $m}from"@xyflow/react";import{Button as Xm,Tooltip as Km,TooltipContent as qm,TooltipTrigger as Zm,useTranslation as Jm}from"lecom-ui";import{useRef as Qa,useState as Qm}from"react";import{useEffect as Sm,useState as Mm}from"react";var Ka=(e,t=!1)=>{let[o,n]=Mm({width:0,height:0});return Sm(()=>{if(e.current&&t){let r=e.current.getBoundingClientRect();n({width:r.width,height:r.height})}},[t,e]),{dimensions:o}};import{Position as no,useReactFlow as Pm}from"@xyflow/react";import{useMemo as Lm}from"react";var km=120,Dm=12,qa=(e,t=!1,o)=>{let{getNode:n,getViewport:r}=Pm(),{instanceId:i}=D();return Lm(()=>{var p,h;if(!t)return{position:no.Right,align:"start"};let s=n(e);if(!s)return{position:no.Right,align:"start"};let a=r(),l=s.position.x*a.zoom+a.x,c=(((p=s.measured)==null?void 0:p.width)||s.width||100)*a.zoom,d=(h=document.getElementById(`modeler-${i}`))==null?void 0:h.clientWidth;if(!d)return{position:no.Right,align:"start"};let f=(o==null?void 0:o.width)||km;return{position:l+c+f+Dm>d?no.Left:no.Right}},[i,e,t,o,n,r])};import{useNodesData as Rm,useReactFlow as Vm}from"@xyflow/react";import{Button as Za,DropdownMenu as Om,DropdownMenuContent as Hm,DropdownMenuGroup as Gm,DropdownMenuItem as Bm,DropdownMenuLabel as zm,DropdownMenuTrigger as Fm,Tooltip as ar,TooltipContent as lr,TooltipTrigger as cr,useTranslation as Wm}from"lecom-ui";import{WrenchIcon as Um}from"lucide-react";import{jsx as oe,jsxs as Ze}from"react/jsx-runtime";var Ja=({nodeId:e})=>{let{t}=Wm(),{updateNodeData:o,getEdges:n,getNode:r}=Vm(),i=Rm(e),a=n().filter(p=>p.source===e).some(p=>{let h=r(p.target);return(h==null?void 0:h.type)==="END_EVENT"}),l=(i==null?void 0:i.data.variant)==="SUBPROCESS",c=f=>{o(e,{variant:(i==null?void 0:i.data.variant)===f?"":f})},d=f=>{o(e,{attribute:(i==null?void 0:i.data.attribute)===f?"":f})};return Ze(Om,{children:[Ze(ar,{children:[oe(cr,{asChild:!0,children:oe(Fm,{asChild:!0,children:oe(Za,{variant:"ghost",color:"grey",size:"small",iconButton:!0,children:oe(Um,{})})})}),oe(lr,{color:"black",children:t("bpmn.task.menu.title")})]}),Ze(Hm,{align:"start",className:"w-60 bg-white text-grey-600",children:[Ze(zm,{className:"flex items-center gap-1",children:[oe("div",{className:"flex-1 text-sm font-semibold",children:t("bpmn.task.menu.title")}),oe("div",{className:"flex items-center gap-1",children:Object.entries(yo).map(([f,u])=>{let p=f==="LOOP"&&(a||l),m=(()=>{if(f==="LOOP"&&a)return t("editor.task_menu.loop_not_allowed_when_connected_to_end");if(f==="LOOP"&&l)return t("editor.task_menu.loop_not_allowed_when_subprocess")})();return Ze(ar,{children:[oe(cr,{asChild:!0,children:oe(Za,{variant:"ghost",color:"grey",size:"small",iconButton:!0,disabled:p,className:P({"bg-grey-100 text-blue-500":(i==null?void 0:i.data.attribute)===f,"opacity-50 cursor-not-allowed":p}),onClick:p?void 0:()=>d(f),children:oe(u.icon,{className:"stroke-inherit"})})}),m&&oe(lr,{color:"black",children:m})]},f)})})]}),oe(Gm,{children:Ze(ar,{children:[oe(cr,{asChild:!0,children:Ze(Bm,{className:P({"bg-grey-100 text-blue-500":(i==null?void 0:i.data.variant)==="SCRIPT","opacity-50 cursor-not-allowed":a}),disabled:a,onClick:a?void 0:()=>c("SCRIPT"),children:[oe(ho.SCRIPT.icon,{className:"stroke-current"}),t(`bpmn.task.variant.${"SCRIPT".toLowerCase()}`)]})}),a&&oe(lr,{color:"black",children:t("editor.task_menu.script_not_allowed_when_connected_to_end")})]})})]})]})};import{jsx as Q,jsxs as ja}from"react/jsx-runtime";var ie=({nodeId:e,nodeType:t,nodeVariant:o,isChild:n,isVisible:r})=>{var C;let i=Qa(null),s=Qa(null),{t:a}=Jm(),{setDraggableNode:l}=ht(),{getEdges:c,getNodes:d}=$m(),{setIsDragging:f}=D(),{dimensions:u}=Ka(i,r),{position:p}=qa(e,r,u),[h,m]=Qm(void 0),g=d(),T=c(),x=o==="SUBPROCESS",y=(L,w)=>{l({type:w.type,variant:w.variant,attribute:w.attribute,icon:w.icon}),w.icon&&m(Q(w.icon,{})),L.dataTransfer.effectAllowed="move",L.dataTransfer.setData("sourceId",e),s.current&&L.dataTransfer.setDragImage(s.current,10,10),setTimeout(()=>{f(!0)},100)},E={START_EVENT:{type:"START_EVENT",icon:Mt,label:a("bpmn.start_event.variant.default")},END_EVENT:{type:"END_EVENT",icon:nt,label:a("bpmn.end_event.variant.default")},TASK:{type:"TASK",icon:Mt,label:a("bpmn.task.variant.default")},ANNOTATION:{type:"ANNOTATION",icon:fo,label:a("bpmn.annotation.variant.default")}},b={EXCLUSIVE:{type:"GATEWAY",variant:"EXCLUSIVE",icon:it,label:a("bpmn.gateway.variant.exclusive")},PARALLEL:{type:"GATEWAY",variant:"PARALLEL",icon:st,label:a("bpmn.gateway.variant.parallel")},COMPLEX:{type:"GATEWAY",variant:"COMPLEX",icon:rt,label:a("bpmn.gateway.variant.complex")}},A=[{component:Q(en,{elementId:e})}],N={START_EVENT:[{component:Q(qt,{nodeId:e})},E.TASK,E.ANNOTATION,...A],TASK:[{component:Q(Kt,{elementId:e})},...x?[]:[{component:Q(Ja,{nodeId:e})}],{component:Q(qt,{nodeId:e})},E.TASK,...Object.values(b),...A],GATEWAY:[{component:Q(Kt,{elementId:e})},{component:Q(qt,{nodeId:e})},E.TASK,E.ANNOTATION,...A],END_EVENT:[{component:Q(qt,{nodeId:e})},E.ANNOTATION,...A],LANE:[...n?[]:[E.ANNOTATION],...A],ANNOTATION:[...A],UNSUPPORTED:[...A]};return ja(Ym,{position:p,align:"start",className:"-top-8",isVisible:r,children:[Q("div",{ref:i,className:"flex items-center gap-1 px-3 py-2 bg-white rounded-sm shadow-md",children:(C=N[t])==null?void 0:C.map((L,w)=>{if(L.component)return Q("div",{children:L.component},w);let S={sourceNodeType:t,targetNodeType:L.type,sourceNodeId:e,nodes:g,edges:T},M=ca(S),I={gateway_limit_reached:a("editor.toolbar.gateway_limit_reached"),start_event_already_exists:a("editor.toolbar.start_event_already_exists"),script_to_end_not_allowed:a("editor.toolbar.script_to_end_not_allowed"),loop_to_end_not_allowed:a("editor.toolbar.loop_to_end_not_allowed"),initial_activity_to_end_not_allowed:a("editor.toolbar.initial_activity_to_end_not_allowed"),final_activity_cannot_connect:a("editor.toolbar.final_activity_cannot_connect"),activity_has_outgoing_connections:a("editor.toolbar.activity_has_outgoing_connections"),task_limit_reached:a("editor.toolbar.task_limit_reached")},V=M.shouldDisable&&M.reason?I[M.reason]||L.label:L.label||"";return ja(Km,{children:[Q(Zm,{asChild:!0,children:Q(Xm,{variant:"ghost",color:"grey",size:"small",iconButton:!0,draggable:!M.shouldDisable,disabled:M.shouldDisable,className:M.shouldDisable?"opacity-50 cursor-not-allowed":"",onDragStart:M.shouldDisable?void 0:F=>y(F,L),children:L.icon&&Q(L.icon,{size:16})})}),Q(qm,{color:"black",children:V})]},w)})}),Q("div",{ref:s,className:"absolute w-0 h-0 top-0 left-0 z-[-1] bg-transparent",children:h})]})};import{jsx as bn,jsxs as og}from"react/jsx-runtime";var el=({id:e,data:t,selected:o,dragging:n})=>{let{updateNodeData:r}=tg(),{inProgress:i,fromNode:s}=eg(),{isConnecting:a,isDragging:l,isMultipleSelection:c}=D(),d=i&&(s==null?void 0:s.id)!==e,f=p=>{r(e,{label:p})},u=!a&&!l&&!c;return og("div",{className:P("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:[bn(J,{value:t.label,className:"m-1 text-grey-600",onChange:f}),u&&bn(ie,{nodeId:e,nodeType:"ANNOTATION",isVisible:!n&&o}),bn(yt,{minWidth:xn.MIN_WIDTH,minHeight:xn.MIN_HEIGHT,isVisible:!n&&o}),(!i||d)&&bn(Z,{type:"target",position:jm.Left,className:P({"annotation-handle":d})})]})};import{Position as tl,useConnection as ng,useReactFlow as rg}from"@xyflow/react";import{useState as ig}from"react";import{jsx as xt,jsxs as sg}from"react/jsx-runtime";var ol=({id:e,data:t,selected:o,dragging:n})=>{let{updateNodeData:r}=rg(),{inProgress:i,fromNode:s}=ng(),{isConnecting:a,isDragging:l,isMultipleSelection:c}=D(),[d,f]=ig(!1),u=i&&(s==null?void 0:s.id)!==e,p=T=>{r(e,{label:T})},h=()=>{f(!0)},m=()=>{f(!1)},g=!a&&!l&&!c;return sg("div",{className:"relative",onBlur:m,onDoubleClick:h,children:[xt(nt,{className:P("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})}),xt("div",{className:"absolute top-9 left-1/2 -translate-x-1/2 max-w-80 w-max",children:xt(J,{value:t.label,isEditing:d,onChange:p})}),g&&xt(ie,{nodeId:e,nodeType:"END_EVENT",isVisible:!n&&o}),(!i||u)&&xt(Z,{type:"target",position:tl.Left,className:P({"event-handle":u})}),!i&&xt(Z,{type:"source",position:tl.Right})]})};import{Position as nl,useConnection as ag,useReactFlow as lg}from"@xyflow/react";import{useState as cg}from"react";import{jsx as Et,jsxs as dg}from"react/jsx-runtime";var rl=({id:e,data:t,selected:o,dragging:n})=>{let r=Un[t.variant].icon,{updateNodeData:i}=lg(),{inProgress:s,fromNode:a}=ag(),{isConnecting:l,isDragging:c,isMultipleSelection:d}=D(),[f,u]=cg(!1),p=s&&(a==null?void 0:a.id)!==e,h=x=>{i(e,{label:x})},m=()=>{u(!0)},g=()=>{u(!1)},T=!l&&!c&&!d;return dg("div",{className:"relative",onBlur:g,onDoubleClick:m,children:[Et(r,{className:P("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})}),Et("div",{className:"absolute top-14 left-1/2 -translate-x-1/2 max-w-80 w-max",children:Et(J,{value:t.label,isEditing:f,onChange:h})}),T&&Et(ie,{nodeId:e,nodeType:"GATEWAY",isVisible:!n&&o}),(!s||p)&&Et(Z,{type:"target",position:nl.Left,className:P({"gateway-handle":p})}),!s&&Et(_n,{type:"source",position:nl.Right,nodeId:e,nodeType:"GATEWAY",gatewayVariant:t.variant})]})};import{useNodesData as vC,useReactFlow as NC}from"@xyflow/react";import{Button as AC,DropdownMenu as CC,DropdownMenuContent as IC,DropdownMenuGroup as SC,DropdownMenuItem as MC,DropdownMenuLabel as PC,DropdownMenuTrigger as LC,Tooltip as kC,TooltipContent as DC,TooltipTrigger as RC,useTranslation as VC}from"lecom-ui";import{WrenchIcon as HC}from"lucide-react";import{jsx as FC,jsxs as WC}from"react/jsx-runtime";import{Position as il,useConnection as ug,useReactFlow as pg}from"@xyflow/react";import{useState as fg}from"react";import{jsx as _t,jsxs as mg}from"react/jsx-runtime";var sl=({id:e,data:t,selected:o,dragging:n})=>{let{updateNodeData:r}=pg(),{inProgress:i,fromNode:s}=ug(),{isConnecting:a,isDragging:l,isMultipleSelection:c}=D(),[d,f]=fg(!1),u=i&&(s==null?void 0:s.id)!==e,p=T=>{r(e,{label:T})},h=()=>{f(!0)},m=()=>{f(!1)},g=!a&&!l&&!c;return mg("div",{className:"relative",onBlur:m,onDoubleClick:h,children:[_t(mo,{className:P("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})}),_t("div",{className:"absolute top-9 left-1/2 -translate-x-1/2 max-w-80 w-max",children:_t(J,{value:t.label,isEditing:d,onChange:p})}),g&&_t(ie,{nodeId:e,nodeType:"START_EVENT",isVisible:!n&&o}),(!i||u)&&_t(Z,{type:"target",position:il.Left,className:P({"event-handle":u})}),!i&&_t(Z,{type:"source",position:il.Right})]})};import{Position as fl,useConnection as yg,useReactFlow as xg}from"@xyflow/react";import{useTranslation as Eg}from"lecom-ui";import{jsx as al,jsxs as gg}from"react/jsx-runtime";var ll=e=>gg("svg",v(_({width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",xmlns:"http://www.w3.org/2000/svg"},e),{children:[al("circle",{cx:"12",cy:"12",r:"10",fill:"#10B981"}),al("path",{d:"M7 12L10 15L17 8",stroke:"white",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"})]}));import{jsx as cl}from"react/jsx-runtime";var dl=e=>cl("svg",v(_({width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",xmlns:"http://www.w3.org/2000/svg"},e),{children:cl("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 ul,jsxs as hg}from"react/jsx-runtime";var pl=e=>hg("svg",v(_({width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",xmlns:"http://www.w3.org/2000/svg"},e),{children:[ul("circle",{cx:"12",cy:"12",r:"10",fill:"#EF4444"}),ul("path",{d:"M8 8L16 16M8 16L16 8",stroke:"white",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"})]}));import{jsx as fe,jsxs as _g}from"react/jsx-runtime";var ml=({id:e,data:t,selected:o,dragging:n})=>{let{t:r}=Eg(),{updateNodeData:i,getNodes:s}=xg(),{inProgress:a,fromNode:l}=yg(),{isConnecting:c,isDragging:d,isMultipleSelection:f,onSubprocessValidationClick:u}=D(),{getTaskStatus:p}=Fe(),h=a&&(l==null?void 0:l.id)!==e,m=M=>{let I=M.trim(),V=t.label||"";if(I===V)return;let F=s(),G=I;I||(G=gn(F,r("bpmn.task.label.prefix")));let U=mt(G,F);U!==V&&i(e,{label:U})},g={APROVADO:ll,EM_ANDAMENTO:dl,REJEITADO:pl},T={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)]"},x=p(e),y=x?g[x]:null,E=t.variant?ho[t.variant].icon:null,b=t.attribute?yo[t.attribute].icon:null,A=t.variant==="SUBPROCESS",N=E&&!A,C=b||A,L=()=>t.hasError?T.error:x?T[x]:T.default,w=()=>{u==null||u({id:e,type:"sub_process",label:t.label})},S=!c&&!d&&!f;return _g("div",{className:P("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",L(),{"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(J,{value:t.label,maxLength:60,className:P("m-1",{"py-6":N||C}),onChange:m}),E&&fe("div",{className:P("absolute flex items-center p-1",A?"bottom-0":"top-0 left-0"),children:fe(E,{size:16,className:P(t.hasError?"text-red-500":"text-grey-500",A&&"cursor-pointer"),onClick:A?w:void 0})}),b&&fe("div",{className:"absolute bottom-0 left-0 w-full flex items-center justify-center",children:fe("div",{className:P("flex items-center w-16 p-1",A?"justify-between":"justify-center"),children:fe(b,{size:16,className:P(t.hasError?"text-red-500":"text-grey-500")})})}),y&&fe("div",{className:"absolute top-0 right-0 flex items-center p-1",children:fe(y,{})}),S&&fe(ie,{nodeId:e,nodeType:"TASK",nodeVariant:t.variant,isVisible:!n&&o}),fe(yt,{minWidth:hn.MIN_WIDTH,minHeight:hn.MIN_HEIGHT,isVisible:!n&&o}),(!a||h)&&fe(Z,{type:"target",position:fl.Left,className:P({"task-handle":h})}),!a&&fe(_n,{type:"source",position:fl.Right,nodeId:e,nodeType:"TASK"})]})};import{Position as gl}from"@xyflow/react";import{Fragment as bg,jsx as Tn,jsxs as Tg}from"react/jsx-runtime";var hl=({id:e,data:t,selected:o,dragging:n})=>{let{isConnecting:r,isDragging:i,isMultipleSelection:s}=D(),a=!r&&!i&&!s;return Tg(bg,{children:[Tn("div",{className:"relative w-full h-full min-w-32 min-h-16 flex items-center justify-center bg-white border-2 border-red-400 rounded-sm overflow-hidden",children:t.label}),a&&Tn(ie,{nodeId:e,nodeType:"UNSUPPORTED",isVisible:!n&&o}),Tn(Z,{type:"source",position:gl.Right}),Tn(Z,{type:"target",position:gl.Left})]})};import{Position as vg,useReactFlow as Ng}from"@xyflow/react";import{orderBy as wg}from"lodash";import{useMemo as yl,useState as Ag}from"react";import{Fragment as Cg,jsx as Je,jsxs as xl}from"react/jsx-runtime";var El=({id:e,data:t,selected:o,dragging:n,parentId:r})=>{let{updateNodeData:i,getNodes:s}=Ng(),{isConnecting:a,isDragging:l,isMultipleSelection:c}=D(),[d,f]=Ag(!1),u=s(),p=!r,h=yl(()=>wg([...u.filter(b=>b.parentId===e&&b.type==="LANE")],"position.y","asc"),[u,e]),m=p?yn.MIN_WIDTH:W.MIN_WIDTH,g=yl(()=>{if(p&&h.length>1){let b=[...h];return b.pop(),b.reduce((N,C)=>{var L,w;return N+((w=(L=C.measured)==null?void 0:L.height)!=null?w:0)},0)+W.MIN_HEIGHT}return W.MIN_HEIGHT},[p,h]),T=b=>{i(e,{label:b})},x=()=>{f(!0)},y=()=>{f(!1)},E=!a&&!l&&!c;return xl(Cg,{children:[xl("div",{className:P("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:[Je("div",{className:"flex align-items justify-center w-10 border-r-2 border-grey-400",onBlur:y,onDoubleClick:x,children:Je("div",{className:P("relative flex-1",{"[writing-mode:vertical-rl] [text-orientation:sideways] transform rotate-180":!d}),children:Je(J,{value:t.label,className:"w-full h-full pointer-events-none self-auto",contentClassName:P({"whitespace-nowrap":d}),isEditing:d,onChange:T})})}),Je("div",{className:"flex-1"})]}),E&&Je(ie,{nodeId:e,nodeType:"LANE",isChild:!p,isVisible:!n&&o}),Je(yt,{nodeId:e,minWidth:m,minHeight:g,isVisible:!n&&o}),p&&Je(Z,{type:"source",position:vg.Right})]})};var _l={START_EVENT:sl,END_EVENT:ol,TASK:ml,GATEWAY:rl,ANNOTATION:el,LANE:El,UNSUPPORTED:hl},bl={SEQUENCE_EDGE:ia,MESSAGE_EDGE:Ra,ANNOTATION_EDGE:js},Tl="#fafafa",vl="#bebebe",Nl=1,wl=10,Al="bottom-left",Cl=.2,Il=5,bt=.3,Sl={x:0,y:0,zoom:.75},Ig=1,Sg=2,Ml=[Ig,Sg];var Pl=()=>{let{setNodes:e,setEdges:t,fitView:o}=Mg();return{importFromLia:r=>{let i=typeof r=="string"?r:r.diagramXml||"",{nodes:s,edges:a}=Ya(i),l=[],c=new Map,d=!1;for(let[h,m]of Object.entries(s)){let g=vn(),T=Wa[m.type],x=Ua[m.type];T==="START_EVENT"&&(d=!0),c.set(h,g);let y=R[T].MIN_WIDTH,E=R[T].MIN_HEIGHT;l.push({id:g,type:T,data:{label:m.label||"",variant:x,attribute:""},position:{x:0,y:0},width:y,height:E,measured:{width:y,height:E}})}let f=[];for(let h of a){let m=v(_({},le),{id:vn(),source:c.get(h.sourceId)||h.sourceId,target:c.get(h.targetId)||h.targetId});f.push(m)}if(!d&&l.length>0){let h=vn(),m={id:h,type:"START_EVENT",data:{label:"",variant:"",attribute:""},position:{x:0,y:0},width:R.START_EVENT.MIN_WIDTH,height:R.START_EVENT.MIN_HEIGHT,measured:{width:R.START_EVENT.MIN_WIDTH,height:R.START_EVENT.MIN_HEIGHT}};l.unshift(m);let g=l[1];if(g){let T=v(_({},le),{id:vn(),source:h,target:g.id});f.unshift(T)}}let{nodes:u,edges:p}=Sa(l,f);e(u),t(p),o({padding:bt})}}};import{useReactFlow as qg}from"@xyflow/react";import{useCallback as Xl}from"react";var ro=(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))(ro||{});import{xml2json as Pg,json2xml as Lg}from"xml-js";var Ll={compact:!0,spaces:4},kg=e=>e.replaceAll(`
3
- `,"&#xA;");function Nn(e,t=Ll){if(e)return JSON.parse(Pg(e,v(_({},t),{attributeValueFn:kg})))}function kl(e,t=Ll){return e?Lg(e,t):""}import{v7 as Gl}from"uuid";var Dl={"attribute-loop":"LOOP"},Rl={"task-script":"SCRIPT","subprocess-collapsed":"SUBPROCESS"},Vl={"gateway-exclusive":"EXCLUSIVE","gateway-parallel":"PARALLEL","gateway-complex":"COMPLEX"},Ol={SCRIPT:"task-script",SUBPROCESS:"subprocess-collapsed"},Hl={EXCLUSIVE:"gateway-exclusive",PARALLEL:"gateway-parallel",COMPLEX:"gateway-complex"};var Tt=(e,t,o)=>{let n=e._attributes.width||0,r=e._attributes.height||0,i=Pe(Number(n),t),s=Pe(Number(r),o);return{width:i,height:s,measured:{width:i,height:s}}},vt=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},Rg=e=>{let{mxGeometry:t}=e,o=vt(e),n=Tt(t,R.START_EVENT.MIN_WIDTH,R.START_EVENT.MIN_HEIGHT);return v(_(_({},o),n),{type:"START_EVENT"})},Vg=e=>{let{mxGeometry:t}=e,o=vt(e),n=Tt(t,R.END_EVENT.MIN_WIDTH,R.END_EVENT.MIN_HEIGHT);return v(_(_({},o),n),{type:"END_EVENT"})},dr=(e,t)=>{let{_attributes:o,mxGeometry:n}=e,r=vt(e),i=Tt(n,R.TASK.MIN_WIDTH,R.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=Dl[l];c&&(r.data.attribute=c)}let a=Rl[o.style];return a&&(r.data.variant=a),v(_(_({},r),i),{type:"TASK"})},ur=e=>{let{_attributes:t,mxGeometry:o}=e,{style:n}=t,r=vt(e),i=Tt(o,R.GATEWAY.MIN_WIDTH,R.GATEWAY.MIN_HEIGHT);return r.data.variant=Vl[n],v(_(_({},r),i),{type:"GATEWAY"})},Og=e=>{let{mxGeometry:t}=e,o=vt(e),n=Tt(t,R.ANNOTATION.MIN_WIDTH,R.ANNOTATION.MIN_HEIGHT);return v(_(_({},o),n),{type:"ANNOTATION"})},Hg=e=>{let{mxGeometry:t}=e,o=vt(e),n=Tt(t,R.LANE.MIN_WIDTH,R.LANE.MIN_HEIGHT);return v(_(_({},o),n),{type:"LANE"})},Bl={task:dr,"task-script":dr,"subprocess-collapsed":dr,"start-event":Rg,"end-event-terminate":Vg,"gateway-parallel":ur,"gateway-exclusive":ur,"gateway-complex":ur,annotation:Og,lane:Hg},zl=e=>{let{_attributes:t}=e,{source:o,target:n,value:r,style:i}=t,s={id:Gl(),source:o,target:n,data:{label:r||""}};return i.includes("association")&&i.includes('endArrow=""')?_(_({},ft),s):_(_({},le),s)},Fl=(e,t)=>{let{id:o,type:n,source:r,target:i,data:s}=e,a=t==null?void 0:t.find(d=>d.id===r),l="";return n==="ANNOTATION_EDGE"&&(l='association;endArrow=""'),{_attributes:{id:o,parent:(a==null?void 0:a.parentId)||"1",edge:"1",style:l,source:r,target:i,value:(s==null?void 0:s.label)||""},mxGeometry:{_attributes:{as:"geometry",relative:"1"}}}},Nt=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}}}},Gg=e=>{let{variant:t}=e.data,o=Nt(e);return v(_({},o),{_attributes:v(_({},o._attributes),{style:Ol[t]||"task"})})},Bg=e=>{let t=Nt(e);return v(_({},t),{_attributes:v(_({},t._attributes),{style:"start-event"})})},zg=e=>{let t=Nt(e);return v(_({},t),{_attributes:v(_({},t._attributes),{style:"end-event-terminate"})})},Fg=e=>{let{variant:t}=e.data,o=Nt(e);return v(_({},o),{_attributes:v(_({},o._attributes),{style:Hl[t]})})},Wg=e=>{let t=Nt(e);return v(_({},t),{_attributes:v(_({},t._attributes),{style:"lane"})})},Ug=e=>{let t=Nt(e);return v(_({},t),{_attributes:v(_({},t._attributes),{style:"annotation"})})},Wl={TASK:Gg,START_EVENT:Bg,END_EVENT:zg,GATEWAY:Fg,ANNOTATION:Ug,LANE:Wg},Ul=e=>{var i,s;let n=((i=e.measured)==null?void 0:i.width)||0,r=((s=e.measured)==null?void 0:s.height)||0;return{_attributes:{id:Gl(),parent:e.id,style:"attribute-loop",connectable:"0"},mxGeometry:{_attributes:{as:"geometry",x:n/2-22/2,y:r-22,width:22,height:22}}}};var Yg=e=>{let t=Object.values(ro),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=Bl[s],l=a==null?void 0:a(i,n);if(!l){console.warn(`Node ${s} not supported`);continue}r.push(l)}return r},$g=(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=zl(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},Xg=e=>{let t=[];return e.forEach(o=>{var i,s;let n=(s=(i=Wl)[o.type])==null?void 0:s.call(i,o);if(!n){console.warn(`Node ${o.type} not supported`);return}if(t.push(n),o.type==="TASK"&&o.data.attribute==="LOOP"){let a=Ul(o);t.push(a)}}),t},Kg=(e,t)=>{let o=[];return e.forEach(n=>{let r=Fl(n,t);o.push(r)}),o},Yl=(e=[],t=[])=>{let o=Xg(e),n=Kg(t,e),r={mxGraphModel:{root:{_attributes:{version:"1.1"},mxCell:[{_attributes:{id:"0"}},{_attributes:{id:"1",parent:"0"}},...o,...n]}}};return kl(JSON.stringify(r))},$l=async e=>{var s,a;let t=await Nn(e),o=((a=(s=t==null?void 0:t.mxGraphModel)==null?void 0:s.root)==null?void 0:a.mxCell)||[],n=Yg(o),r=$g(o,n);return{nodes:Ie(oo(n)),edges:r}};var Kl=()=>{let{getNodes:e,getEdges:t,setNodes:o,setEdges:n,fitView:r}=qg(),i=Xl(async(a="")=>{let{nodes:l,edges:c}=await $l(a);o(l),n(c),r({padding:bt})},[o,n,r]),s=Xl((a,l)=>{let c=a||e()||[],d=l||t()||[];return Yl(c,d)},[e,t]);return{importFromMxGraph:i,exportToMxGraph:s}};import{useEffect as Zg,useCallback as Jg}from"react";var Qg={origin:"*",debug:!1};function ql(e,t=Qg){let{origin:o,debug:n}=t,r=Jg((i,s)=>{let a={event:i,data:[i,{event:i,data:s}]};window.parent.postMessage(a,o||"*")},[o]);return Zg(()=>{let i=s=>{let a=s.data;if(!(a!=null&&a.event)||!(a!=null&&a.data))return;let{event:l,data:c}=a,d;if(Array.isArray(c)){let[,f]=c;d=f.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{useCallback as Zl}from"react";import{useReactFlow as jg}from"@xyflow/react";function Jl(){let{setTaskStatuses:e,clearTaskStatuses:t,calculateFlowPath:o}=Fe(),{getEdges:n}=jg(),r=xo(),i=Zl(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=Zl(()=>{t(),setTimeout(()=>{r()},0)},[t,r]);return{handleTasksStatus:i,handleClearTaskStatus:s}}import{useReactFlow as eh}from"@xyflow/react";import{useCallback as wt,useState as Ql,useEffect as th}from"react";import{useDebouncedCallback as oh}from"use-debounce";var jl=[{nodes:[],edges:[]}],nh=500,ec=100,tc=(e=jl)=>{let{getNodes:t,getEdges:o,setNodes:n,setEdges:r}=eh(),[i,s]=Ql(e),[a,l]=Ql(0),c=i[a],d=a>0,f=a<i.length-1,u=wt(E=>{n(i[E].nodes),r(i[E].edges)},[i,n,r]),p=wt(()=>{if(a>0){let E=a-1;l(E),u(E)}},[a,u]),h=wt(()=>{if(a<i.length-1){let E=a+1;l(E),u(E)}},[i,a,u]),m=E=>{let A=[...i.slice(0,a+1),E],N=A.length>ec?A.slice(A.length-ec):A;s(N),l(N.length-1)},g=oh(()=>{let E=t(),b=o(),A=E.map(L=>v(_({},L),{selected:!1,className:""})),N={nodes:Ie(A),edges:b};JSON.stringify(c)!==JSON.stringify(N)&&m(N)},nh),T=wt(E=>{if(E==="forceSave"){g();return}E.some(N=>N.type==="select")||E.some(N=>N.type==="position"&&N.dragging)||g()},[g]),x=wt(E=>{s(E||jl),l(0)},[]),y=wt(()=>{s([]),l(0)},[]);return th(()=>{let E=b=>{(b.ctrlKey||b.metaKey)&&(b.shiftKey&&b.key.toLowerCase()==="z"?(b.preventDefault(),h()):b.key.toLowerCase()==="z"&&(b.preventDefault(),p()))};return document.addEventListener("keydown",E),()=>{document.removeEventListener("keydown",E)}},[p,h]),{history:i,undo:p,redo:h,canUndo:d,canRedo:f,saveHistory:T,resetHistory:x,clearHistory:y}};import{jsx as oc}from"react/jsx-runtime";var pr=({id:e,className:t})=>oc("marker",{id:e,className:P("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:oc("path",{d:"M 0 0 L 10 5 L 0 10 Z"})});import{jsx as fr,jsxs as rh}from"react/jsx-runtime";var nc=()=>fr("svg",{style:{position:"absolute",top:0,left:0},children:rh("defs",{children:[fr(pr,{id:"sequence-edge-marker",className:"text-grey-400"}),fr(pr,{id:"sequence-edge-marker-highlighted",className:"text-blue-500"})]})});import{useKeyPress as _c}from"@xyflow/react";import{Button as yr,Tooltip as xr,TooltipContent as Er,TooltipTrigger as _r,useTranslation as Jh}from"lecom-ui";import{HandIcon as Qh,MapIcon as jh,MousePointerIcon as e0}from"lucide-react";import{useCallback as bc,useEffect as Tc}from"react";import{Tooltip as Ih,TooltipContent as Sh,TooltipTrigger as Mh,useNotificationToast as Ph,useTranslation as Lh}from"lecom-ui";var io=(x=>(x.START_EVENT="START_EVENT",x.END_EVENT="END_EVENT",x.TASK="TASK",x.SUBPROCESS="SUBPROCESS",x.GATEWAY="GATEWAY",x.LANE="LANE",x.ANNOTATION="ANNOTATION",x.CONNECTION="CONNECTION",x.INTERMEDIATE_EVENT="INTERMEDIATE_EVENT",x.ACTIVITY="ACTIVITY",x.PROCESS_INTERFACE="PROCESS_INTERFACE",x.WORKFLOW_INTERFACE="WORKFLOW_INTERFACE",x.VARIANT_ACTIVITY="VARIANT_ACTIVITY",x.AUTO_ACTIVITY="AUTO_ACTIVITY",x.DATA_STORE="DATA_STORE",x.DATA_OBJECT="DATA_OBJECT",x.DATA_OUTPUT="DATA_OUTPUT",x.DATA_INPUT="DATA_INPUT",x))(io||{});import{useReactFlow as Eh}from"@xyflow/react";import{useNotificationToast as _h,useTranslation as bh,Button as Th}from"lecom-ui";var rc=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 ic({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(`
4
- `),i=encodeURI(r);wn(i,`${o}.csv`)}var wn=(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)};import{v7 as fh}from"uuid";function sc(e){return e==null?void 0:e.replaceAll("&#xA;"," ")}import{v7 as sh}from"uuid";var Q5={START_EVENT:"START_EVENT",END_EVENT:"END_EVENT",TASK:"TASK",GATEWAY:"GATEWAY",ANNOTATION:"ANNOTATION"},ac={script:"SCRIPT",subprocess:"SUBPROCESS"},lc={complex:"COMPLEX",none:"EXCLUSIVE",exclusive:"EXCLUSIVE",parallel:"PARALLEL"};var Qe=({cell:e,type:t,variant:o=""})=>{let{_attributes:n,mxGeometry:r}=e,{value:i,parent:s}=n,a=Number(r._attributes.width),l=Number(r._attributes.height),c=s==="1"?void 0:s;return{id:n.id,parentId:c,type:t,data:{label:i||"",variant:o,attribute:""},position:{x:Number(r._attributes.x)||0,y:Number(r._attributes.y)||0},width:a,height:l,measured:{width:a,height:l}}},ah=e=>{let{subType:t,style:o}=e._attributes,n="imported";return["none"].includes(t)||(n="adapted"),e.mxGeometry._attributes.width=R.START_EVENT.MIN_WIDTH,e.mxGeometry._attributes.height=R.START_EVENT.MIN_HEIGHT,{node:Qe({cell:e,type:"START_EVENT"}),status:n,originalType:o}},lh=e=>{let{subType:t,style:o}=e==null?void 0:e._attributes,n="imported";return["none"].includes(t)||(n="adapted"),e.mxGeometry._attributes.width=R.END_EVENT.MIN_WIDTH,e.mxGeometry._attributes.height=R.END_EVENT.MIN_HEIGHT,{node:Qe({cell:e,type:"END_EVENT"}),status:n,originalType:o}},ch=e=>{let{subType:t,style:o}=e==null?void 0:e._attributes,n=ac[t],r="imported";return["script","none"].includes(t)||(r="adapted"),e.mxGeometry._attributes.width=Pe(e.mxGeometry._attributes.width||0,R.TASK.MIN_WIDTH),e.mxGeometry._attributes.height=Pe(e.mxGeometry._attributes.height||0,R.TASK.MIN_HEIGHT),{node:Qe({cell:e,type:"TASK",variant:n}),status:r,originalType:o}},dh=e=>{let{style:t,subType:o}=e==null?void 0:e._attributes,n=lc[o],r=["none","inclusive","event-based"],i="imported";return r.includes(o)&&(i="adapted"),e.mxGeometry._attributes.width=R.GATEWAY.MIN_WIDTH,e.mxGeometry._attributes.height=R.GATEWAY.MIN_HEIGHT,{node:Qe({cell:e,type:"GATEWAY",variant:n}),status:i,originalType:t}},uh=e=>{let{style:t}=e==null?void 0:e._attributes;return{node:Qe({cell:e,type:"LANE"}),status:"imported",originalType:t}},ph=e=>{let{style:t}=e==null?void 0:e._attributes;return e.mxGeometry._attributes.width=Pe(e.mxGeometry._attributes.width||0,R.ANNOTATION.MIN_WIDTH),e.mxGeometry._attributes.height=Pe(e.mxGeometry._attributes.height||0,R.ANNOTATION.MIN_HEIGHT),{node:Qe({cell:e,type:"ANNOTATION"}),status:"imported",originalType:t}},cc=e=>{let{style:t}=e==null?void 0:e._attributes;return e.mxGeometry._attributes.width=R.UNSUPPORTED.MIN_WIDTH,e.mxGeometry._attributes.height=R.UNSUPPORTED.MIN_HEIGHT,{node:Qe({cell:e,type:"UNSUPPORTED"}),status:"unsupported",originalType:t}},dc=(e,t)=>{let{source:o,target:n,value:r}=e._attributes;return v(_({},le),{id:sh(),source:t.get(o)||o,target:t.get(n)||n,data:{label:r||""}})},uc={TASK:ch,GATEWAY:dh,START_EVENT:ah,END_EVENT:lh,LANE:uh,ANNOTATION:ph};var mh=(e,t)=>{let o=e.filter(n=>n.parentId);for(let n of o){let r=t.get(n.parentId);r&&(n.parentId=r)}return e},gh=e=>{var s;let t=new Map,o=Object.values(io),n=e.filter(a=>{var c;let l=(c=a._attributes)==null?void 0:c.type;return o.includes(l)}),r=[],i=[];for(let a of n){let l=fh(),{type:c}=a._attributes,d=uc[c]||cc;t.set((s=a._attributes)==null?void 0:s.id,l),a._attributes.id=l;let{node:f,status:u,originalType:p}=d(a);i.push(f),r.push({originalType:p,type:f.type,variant:f.data.variant,value:sc(f.data.label),status:u})}return i=mh(i,t),{nodes:i,governanceIdToNodeIdMap:t,summary:r}},hh=(e,t)=>e.filter(r=>{var i;return(i=r._attributes)==null?void 0:i.edge}).map(r=>dc(r,t)),yh=e=>{let{mxGraphModel:t}=e,{nodes:o,governanceIdToNodeIdMap:n,summary:r}=gh(t.root.mxCell),i=hh(t.root.mxCell,n);return{nodes:o,edges:i,summary:r}},xh=async e=>{let t=await rc(e),o=Nn(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}},pc=async e=>{try{let t=await xh(e),{nodes:o,edges:n,summary:r}=yh(t)||{};return{nodes:o,edges:n,summary:r}}catch(t){throw t}};import{jsx as vh}from"react/jsx-runtime";var fc=()=>{let{t:e}=bh(),{toast:t}=_h(),{setNodes:o,setEdges:n,fitView:r}=Eh(),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:vh(Th,{size:"small",variant:"ghost",onClick:()=>ic({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 pc(a);if(o(u=>u.concat(l)),n(u=>u.concat(c)),r({padding:bt}),d.some(u=>u.status==="unsupported")){i(d);return}t({variant:"success",content:e("adapter.governance.success.default")})}catch(l){let c=l instanceof Error?l.message:"DEFAULT";t({variant:"error",content:e(`adapter.governance.error.${c}`)})}}}};import{Button as Nh}from"lecom-ui";import{useRef as wh}from"react";import{Fragment as Ah,jsx as mc,jsxs as Ch}from"react/jsx-runtime";var gc=a=>{var l=a,{children:e,accept:t="*",multiple:o=!1,disabled:n=!1,onClick:r,onFilesSelected:i}=l,s=Ee(l,["children","accept","multiple","disabled","onClick","onFilesSelected"]);let c=wh(null),d=u=>{let p=u.target.files;p!=null&&p.length&&i(p),c.current&&(c.current.value="")};return Ch(Ah,{children:[mc(Nh,v(_({onClick:u=>{var p;(p=c.current)==null||p.click(),r==null||r(u)}},s),{children:e})),mc("input",{type:"file",ref:c,className:"sr-only",accept:t,multiple:o,disabled:n,onChange:d})]})};import{jsx as An,jsxs as kh}from"react/jsx-runtime";var hc=({disabled:e=!1})=>{let{t}=Lh(),{toast:o}=Ph(),{importFromGovernance:n}=fc(),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 kh(Ih,{children:[An(Mh,{asChild:!0,children:An(gc,{className:"[&>svg]:size-7 p-0",variant:"ghost",size:"small",color:"grey",iconButton:!0,accept:".mdr",disabled:e,onClick:r,onFilesSelected:i,children:An(Yr,{})})}),An(Sh,{color:"black",children:t("editor.controls.actions.import_governance")})]})};import{jsx as Dh}from"react/jsx-runtime";var mr=({shortcut:e})=>Dh("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 zh,DropdownMenu as Fh,DropdownMenuContent as Wh,DropdownMenuItem as hr,DropdownMenuTrigger as Uh,Tooltip as Cn,TooltipContent as In,TooltipTrigger as Sn,useTranslation as Yh}from"lecom-ui";import{FileCodeIcon as $h,FileImageIcon as Xh,FolderOutputIcon as Kh,PrinterIcon as qh}from"lucide-react";import{useState as Zh}from"react";import{useReactFlow as Rh}from"@xyflow/react";import{toPng as yc,toSvg as Vh}from"html-to-image";import{toast as Oh,useTranslation as Hh}from"lecom-ui";import{useState as Gh}from"react";var Bh=3,gr="diagram",xc=()=>{let{t:e}=Hh(),{getNodes:t}=Rh(),{clearSelection:o}=He(),[n,r]=Gh({png:!1,html:!1,print:!1}),i=()=>{let{x:d,y:f,width:u,height:p}=La(t());return{width:u,height:p,style:{width:`${u}px`,height:`${p}px`,transform:`translate(${-d}px, ${-f}px)`}}},s=async(d,f)=>{r(v(_({},n),{[f]:!0})),await o();try{let u=Pa();if(!u)throw new Error("Flow element not found");let p=i();return await d(u,p)}catch(u){Oh({content:e("editor.controls.actions.export.feedback.error"),variant:"error"})}finally{r(v(_({},n),{[f]:!1}))}};return{exportAsPng:async(d=gr)=>{await s(async(f,u)=>{let p=await yc(f,v(_({},u),{backgroundColor:"#fcfcfc"}));wn(p,`${d}.png`)},"png")},exportAsHtml:async(d=gr)=>{await s(async(f,u)=>{let p=await Vh(f,v(_({},u),{backgroundColor:"#fcfcfc"})),h=`
1
+ var sd=Object.defineProperty,ad=Object.defineProperties;var ld=Object.getOwnPropertyDescriptors;var co=Object.getOwnPropertySymbols;var Vr=Object.prototype.hasOwnProperty,Or=Object.prototype.propertyIsEnumerable;var Rr=(e,t,o)=>t in e?sd(e,t,{enumerable:!0,configurable:!0,writable:!0,value:o}):e[t]=o,_=(e,t)=>{for(var o in t||(t={}))Vr.call(t,o)&&Rr(e,o,t[o]);if(co)for(var o of co(t))Or.call(t,o)&&Rr(e,o,t[o]);return e},N=(e,t)=>ad(e,ld(t));var Ee=(e,t)=>{var o={};for(var n in e)Vr.call(e,n)&&t.indexOf(n)<0&&(o[n]=e[n]);if(e!=null&&co)for(var n of co(e))t.indexOf(n)<0&&Or.call(e,n)&&(o[n]=e[n]);return o};var Rn=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 cd,Translations as dd}from"lecom-ui";var Hr={translations:{general:{layout:{title:"Modeler"}},editor:{toolbar:{delete:"Delete",configure_node:"Configure activity",configure_edge:"Configure routing",initial_task:"Initial Activity",gateway_limit_reached:"Exclusive gateway cannot have more than 2 outgoing connections",task_limit_reached:"Task cannot have more than 2 outgoing connections",gateway_to_gateway_not_allowed:"Gateways cannot connect directly to other gateways",start_event_already_exists:"A start event already exists. Delete the current event to add another",script_to_end_not_allowed:"Script activities cannot connect directly to the end event",loop_to_end_not_allowed:"Loop activities cannot connect directly to the end event",initial_activity_to_end_not_allowed:"Initial activity cannot connect directly to the end event",final_activity_cannot_connect:"Final activity cannot connect to other elements",activity_has_outgoing_connections:"Activity with outgoing connections cannot connect to end event",end_event_cannot_connect_to_initial_activity:"End event cannot connect to an initial activity",initial_activity_cannot_connect_to_start_event:"Initial activity cannot connect to start event",connect_node:"Connect element",connecting:"Connecting..."},controls:{zoom:{fit:"Fit zoom",in:"Zoom in",out:"Zoom out",reset:"Reset zoom"},actions:{move_tool:"Select elements",hand_tool:"Navigate the diagram",check:"Check diagram",export:{title:"Export diagram",print:"Print",html:"Export as HTML",png:"Export as PNG",feedback:{error:"Error exporting diagram"}},import_governance:"Import diagram from Governance platform",minimap:{open:"Open minimap",close:"Hide minimap"}},history:{undo:"Undo",redo:"Redo"}},modals:{delete_elements:{title:"Delete elements",callout:"When deleting, the activity and routing settings will be deleted.",content:"Are you sure you want to delete?",confirm:"Delete",cancel:"Cancel"}},task_menu:{loop_not_allowed_when_connected_to_end:"Cannot create loop on activity connected to end event",script_not_allowed_when_connected_to_end:"Cannot transform to Script activity connected to end event",loop_not_allowed_when_subprocess:"Cannot create loop on subprocess"}},validation:{success:{title:"Validation Successful",message:"The diagram was validated successfully with no errors."},errors:{title:"The diagram contains errors",subtitle:"Please review the following:",task_label_length:"Task name exceeds the maximum character limit",multiple_start_event_not_allowed:"Multiple start events are not allowed",task_flows_limit_exceeds:"The number of output connections exceeds the limit of two",duplicate_task_name:"There are multiple activities with the same name",flows_on_end_tasks_not_allowed:"Activities connected to end events cannot have other connections",conditions_flows_limit_exceeds:"Exclusive gateway has too many output connections (maximum of two)",task_label_empty:"One or more activities have no name",activity_name_invalid:"Activity name is invalid",final_activity_has_loop:"Final activities cannot have loops",nested_gateway:"Connecting gateways directly is not allowed",concurrent_initial_and_final_event:"The same activity cannot have both initial and final events",gateway_flow_to_event:"Connecting a gateway to an output event is not allowed",gateway_missing_output_streams:"The gateway does not have the correct number of outputs",events_nested:"Connecting events directly is not allowed",event_to_condition:"Connecting an event directly to a gateway is not allowed",script_in_final_activity:"Final activity cannot be a script type",subprocess_referenced_not_configured:"The subprocess reference is not properly configured",start_event_not_found:"At least one start event is required",end_event_not_found:"At least one end event is required"}},bpmn:{start_event:{variant:{default:"Start event"}},end_event:{variant:{default:"End event"}},annotation:{variant:{default:"Annotation"}},gateway:{menu:{title:"Change gateway type"},variant:{default:"Gateway",exclusive:"Exclusive gateway",parallel:"Parallel gateway",complex:"Complex gateway"}},task:{menu:{title:"Change task type"},variant:{default:"Task",script:"Script task",subprocess:"Subprocess"},attribute:{loop:"Task with loop"},label:{prefix:"Activity"}},lane:{variant:{default:"Pool / Lane"}},unsupported:{variant:{default:"Unsupported element"}}},adapter:{governance:{error:{DEFAULT:"Error importing diagram",NO_FILE:"No file selected",EMPTY_FILE:"Empty file",INVALID_FILE:"Invalid file",CONTAIN_NO_CELLS:"No cells found to be imported",ALREADY_INITIALIZED:"It is not possible to import the diagram from the Governance platform, since the diagram has already been initialized"},success:{default:"The diagram was imported from the Governance platform successfully and without any incompatibility detected.",incompatible_cells:"The diagram was imported from the Governance platform with incompatibilities. To know more details, click on the button below."},report:{columns:{type:"Type",value:"Value",status:"Status"},status:{imported:"Imported",adapted:"Adapted",unsupported:"Unsupported"}},action:{download:"Download report"}}}}};var Gr={translations:{general:{layout:{title:"Modeler"}},editor:{toolbar:{delete:"Eliminar",configure_node:"Configurar actividad",configure_edge:"Configurar enrutamiento",initial_task:"Actividad Inicial",gateway_limit_reached:"Compuerta exclusiva no puede tener m\xE1s de 2 conexiones de salida",task_limit_reached:"Actividad no puede tener m\xE1s de 2 conexiones de salida",gateway_to_gateway_not_allowed:"Las compuertas no pueden conectarse directamente con otras compuertas",start_event_already_exists:"Ya existe un evento de inicio. Elimine el evento actual para agregar otro",script_to_end_not_allowed:"Las actividades Script no pueden conectarse directamente al evento final",loop_to_end_not_allowed:"Las actividades Loop no pueden conectarse directamente al evento final",initial_activity_to_end_not_allowed:"Actividad inicial no puede conectarse directamente al evento final",final_activity_cannot_connect:"Actividad final no puede conectarse a otros elementos",activity_has_outgoing_connections:"Actividad con conexiones de salida no puede conectarse al evento final",end_event_cannot_connect_to_initial_activity:"El evento final no puede conectarse a una actividad inicial",initial_activity_cannot_connect_to_start_event:"Actividad inicial no puede conectarse a evento de inicio",connect_node:"Conectar elemento",connecting:"Conectando..."},controls:{zoom:{fit:"Ajustar zoom",in:"Acercar",out:"Alejar",reset:"Restablecer zoom"},actions:{move_tool:"Seleccionar elementos",hand_tool:"Navegar por el diagrama",check:"Verificar diagrama",export:{title:"Exportar diagrama",print:"Imprimir",html:"Exportar como HTML",png:"Exportar como PNG",feedback:{error:"Error al exportar diagrama"}},import_governance:"Importar diagrama de la plataforma Governance",minimap:{open:"Abrir minimapa",close:"Ocultar minimapa"}},history:{undo:"Deshacer",redo:"Rehacer"}},modals:{delete_elements:{title:"Eliminar elementos",callout:"Al eliminar, las configuraciones de actividades y enrutamiento ser\xE1n eliminadas.",content:"\xBFEst\xE1s seguro de querer eliminar?",confirm:"Eliminar",cancel:"Cancelar"}},task_menu:{loop_not_allowed_when_connected_to_end:"No se puede crear bucle en actividad conectada al evento final",script_not_allowed_when_connected_to_end:"No se puede transformar a Script actividad conectada al evento final",loop_not_allowed_when_subprocess:"No se puede crear bucle en subproceso"}},validation:{success:{title:"Validaci\xF3n exitosa",message:"El diagrama ha sido validado correctamente sin errores."},errors:{title:"El diagrama contiene errores",subtitle:"Revise lo siguiente:",task_label_length:"El nombre de la actividad excede el l\xEDmite m\xE1ximo de caracteres",multiple_start_event_not_allowed:"No se permite tener m\xE1s de un evento de inicio",task_flows_limit_exceeds:"El n\xFAmero de conexiones de salida supera el l\xEDmite de dos",duplicate_task_name:"Hay varias actividades con el mismo nombre",flows_on_end_tasks_not_allowed:"Las actividades conectadas a eventos finales no pueden tener otras conexiones",conditions_flows_limit_exceeds:"Compuerta exclusiva con exceso de conexiones de salida (m\xE1ximo de dos)",task_label_empty:"El nombre de una o m\xE1s actividades no ha sido completado",activity_name_invalid:"El nombre de la actividad no es v\xE1lido",final_activity_has_loop:"Las actividades finales no pueden tener bucles",nested_gateway:"No se permite conectar compuertas directamente",concurrent_initial_and_final_event:"Una misma actividad no puede tener eventos iniciales y finales",gateway_flow_to_event:"No se permite conectar una compuerta a un evento de salida",gateway_missing_output_streams:"La compuerta no tiene el n\xFAmero correcto de salidas",events_nested:"No se permite conectar eventos directamente",event_to_condition:"No se permite conectar un evento directamente a una compuerta",script_in_final_activity:"La actividad final no puede ser de tipo script",subprocess_referenced_not_configured:"La referencia al subproceso no est\xE1 configurada correctamente",start_event_not_found:"Es necesario tener al menos un evento de inicio",end_event_not_found:"Es necesario tener al menos un evento final"}},bpmn:{start_event:{variant:{default:"Evento de inicio"}},end_event:{variant:{default:"Evento final"}},annotation:{variant:{default:"Anotaci\xF3n"}},gateway:{menu:{title:"Cambiar tipo de compuerta"},variant:{default:"Compuerta",exclusive:"Compuerta exclusiva",parallel:"Compuerta paralela",complex:"Compuerta compleja"}},task:{menu:{title:"Cambiar tipo de tarea"},variant:{default:"Tarea",script:"Tarea de script",subprocess:"Subproceso"},attribute:{loop:"Tarea con bucle"},label:{prefix:"Actividad"}},lane:{variant:{default:"Piscina / Raia"}},unsupported:{variant:{default:"Elemento no soportado"}}},adapter:{governance:{error:{DEFAULT:"Error al importar diagrama",NO_FILE:"No se ha seleccionado ning\xFAn archivo",EMPTY_FILE:"Archivo vac\xEDo",INVALID_FILE:"Archivo inv\xE1lido",CONTAIN_NO_CELLS:"No se encontraron c\xE9lulas para importar",ALREADY_INITIALIZED:"No es posible importar el diagrama de la plataforma Governance, ya que el diagrama ya ha sido iniciado"},success:{default:"El diagrama se ha importado de la plataforma Governance correctamente y sin ninguna incompatibilidad detectada.",incompatible_cells:"El diagrama se ha importado de la plataforma Governance con incompatibilidades. Para saber m\xE1s detalles, haz click en el bot\xF3n de abajo."},report:{columns:{type:"Tipo",value:"Valor",status:"Estado"},status:{imported:"Importado",adapted:"Adaptado",unsupported:"No soportado"}},action:{download:"Descargar informe"}}}}};var Br={translations:{general:{layout:{title:"Modeler"}},editor:{toolbar:{delete:"Excluir",configure_node:"Configurar atividade",configure_edge:"Configurar roteamento",initial_task:"Atividade Inicial",gateway_limit_reached:"Gateway exclusivo n\xE3o pode ter mais de 2 conex\xF5es de sa\xEDda",task_limit_reached:"Atividade n\xE3o pode ter mais de 2 conex\xF5es de sa\xEDda",gateway_to_gateway_not_allowed:"Gateways n\xE3o podem se conectar diretamente com outros gateways",start_event_already_exists:"J\xE1 existe um evento de in\xEDcio. Exclua o evento atual para adicionar outro",script_to_end_not_allowed:"Atividades Script n\xE3o podem se conectar diretamente ao evento final",loop_to_end_not_allowed:"Atividades Loop n\xE3o podem se conectar diretamente ao evento final",initial_activity_to_end_not_allowed:"Atividade inicial n\xE3o pode se conectar diretamente ao evento final",final_activity_cannot_connect:"Atividade final n\xE3o pode se conectar a outros elementos",activity_has_outgoing_connections:"Atividade com conex\xF5es de sa\xEDda n\xE3o pode se conectar a um evento final",end_event_cannot_connect_to_initial_activity:"O evento final n\xE3o pode ser conectado a uma atividade inicial",initial_activity_cannot_connect_to_start_event:"Atividade inicial n\xE3o pode se conectar a evento de in\xEDcio",connect_node:"Conectar elemento",connecting:"Conectando..."},controls:{zoom:{fit:"Ajustar o zoom",in:"Aumentar o zoom",out:"Diminuir o zoom",reset:"Resetar o zoom"},actions:{move_tool:"Selecionar elementos",hand_tool:"Navegar pelo diagrama",check:"Verificar diagrama",export:{title:"Exportar diagrama",print:"Imprimir",html:"Exportar como HTML",png:"Exportar como PNG",feedback:{error:"Erro ao exportar o diagrama"}},import_governance:"Importar diagrama da plataforma Governance",minimap:{open:"Abrir minimapa",close:"Ocultar minimapa"}},history:{undo:"Desfazer",redo:"Refazer"}},modals:{delete_elements:{title:"Excluir elementos",callout:"Ao excluir, as configura\xE7\xF5es de atividades e roteamento ser\xE3o exclu\xEDdas.",content:"Deseja realmente excluir?",confirm:"Excluir",cancel:"Cancelar"}},task_menu:{loop_not_allowed_when_connected_to_end:"N\xE3o \xE9 poss\xEDvel criar loop em atividade conectada ao evento final",script_not_allowed_when_connected_to_end:"N\xE3o \xE9 poss\xEDvel transformar em Script atividade conectada ao evento final",loop_not_allowed_when_subprocess:"N\xE3o \xE9 poss\xEDvel criar loop em subprocesso"}},validation:{success:{title:"Diagrama v\xE1lidado com sucesso!",message:"Nenhum erro encontrado."},errors:{title:"O diagrama cont\xE9m erros",subtitle:"Veja abaixo o que precisa ser corrigido:",task_label_length:"O nome da atividade excede o limite m\xE1ximo de caracteres",multiple_start_event_not_allowed:"N\xE3o \xE9 permitido ter mais de um evento de in\xEDcio",task_flows_limit_exceeds:"O n\xFAmero de conex\xF5es de sa\xEDda ultrapassa o limite de dois",duplicate_task_name:"H\xE1 v\xE1rias atividades com o mesmo nome",flows_on_end_tasks_not_allowed:"Atividades conectadas a eventos finais n\xE3o podem ter outras conex\xF5es",conditions_flows_limit_exceeds:"Gateway exclusivo com excesso de conex\xF5es de sa\xEDda (m\xE1ximo de dois)",task_label_empty:"O nome de uma ou mais atividades n\xE3o foi preenchido",activity_name_invalid:"O nome da atividade n\xE3o \xE9 v\xE1lido",final_activity_has_loop:"Atividades finais n\xE3o podem ter loops",nested_gateway:"N\xE3o \xE9 permitido conectar gateways",concurrent_initial_and_final_event:"Uma mesma atividade n\xE3o pode ter eventos iniciais e finais",gateway_flow_to_event:"N\xE3o \xE9 permitido conectar um gateway a um evento de sa\xEDda",gateway_missing_output_streams:"O gateway n\xE3o possui o n\xFAmero correto de sa\xEDdas",events_nested:"N\xE3o \xE9 permitido conectar eventos",event_to_condition:"N\xE3o \xE9 permitido conectar um evento diretamente em um gateway",script_in_final_activity:"Atividade final n\xE3o pode ser do tipo script",subprocess_referenced_not_configured:"A refer\xEAncia ao subprocesso n\xE3o est\xE1 configurada corretamente",start_event_not_found:"\xC9 necess\xE1rio ter ao menos um evento inicial",end_event_not_found:"\xC9 necess\xE1rio ter ao menos um evento final"}},bpmn:{start_event:{variant:{default:"Evento inicial"}},end_event:{variant:{default:"Evento final"}},annotation:{variant:{default:"Anota\xE7\xE3o"}},gateway:{menu:{title:"Alterar tipo de gateway"},variant:{default:"Gateway",exclusive:"Gateway exclusivo",parallel:"Gateway paralelo",complex:"Gateway complexo"}},task:{menu:{title:"Alterar tipo de tarefa"},variant:{default:"Tarefa",script:"Tarefa de script",subprocess:"Subprocesso"},attribute:{loop:"Tarefa com loop"},label:{prefix:"Atividade"}},lane:{variant:{default:"Piscina / Raia"}},unsupported:{variant:{default:"Elemento n\xE3o suportado"}}},adapter:{governance:{error:{DEFAULT:"Erro ao importar diagrama",NO_FILE:"Nenhum arquivo selecionado",EMPTY_FILE:"Arquivo vazio",INVALID_FILE:"Arquivo inv\xE1lido",CONTAIN_NO_CELLS:"N\xE3o foram encontradas c\xE9lulas para serem importadas",ALREADY_INITIALIZED:"N\xE3o \xE9 poss\xEDvel importar o diagrama da plataforma Governance, pois o diagrama j\xE1 foi iniciado"},success:{default:"O diagrama foi importado da plataforma Governance com sucesso e sem nenhuma incompatibilidade detectada.",incompatible_cells:"O diagrama foi importado da plataforma Governance com incompatibilidades. Para saber mais detalhes, clique no bot\xE3o abaixo."},report:{columns:{type:"Tipo do elemento",value:"Valor",status:"Status"},status:{imported:"Importado",adapted:"Adaptado",unsupported:"N\xE3o suportado"}},action:{download:"Baixar relat\xF3rio"}}}}};var zr={pt_BR:Br,en_US:Hr,es_ES:Gr};var Fr,Wr,ud=(Wr=(Fr=Rn("LecomUserLanguage"))!=null?Fr:Rn("org.springframework.web.servlet.i18n.CookieLocaleResolver.LOCALE"))!=null?Wr:dd.PT_BR;cd({lng:ud,resources:zr});var uo=(r=>(r.ACTIVITY="activity",r.ROUTING="routing",r.GATEWAY="gateway",r.SUB_PROCESS="sub_process",r))(uo||{}),Vn=(n=>(n.START="start",n.END="end",n.BETWEEN="between",n))(Vn||{}),On=(n=>(n.SCRIPT="script",n.LOOP="loop",n.SCRIPT_LOOP="script_loop",n))(On||{}),Hn=(c=>(c.SIMPLE="simple",c.LOOP="loop",c.SCRIPT="script",c.SCRIPT_LOOP="script_loop",c.COMPLEX="complex",c.EXCLUSIVE="exclusive",c.PARALLEL="parallel",c.FINAL="final",c.TO_SUB_PROCESS="to_sub_process",c))(Hn||{});import{RotateCcw as vd,ScrollText as Nd,SquarePlus as wd}from"lucide-react";import{jsx as po,jsxs as pd}from"react/jsx-runtime";var fo=({size:e=24,className:t})=>pd("svg",{width:e,height:e,viewBox:"0 0 24 24",xmlns:"http://www.w3.org/2000/svg",fill:"#6b7280",className:t,children:[po("path",{strokeWidth:"2",d:"M16 3V3.5085V11.9998V20.4915V21H16.5411H21.4592H22V19.123H21.4592H17.9974V11.9998V4.8773H21.4592H22V3H21.4592H16.5411H16Z"}),po("path",{d:"M4.41026 16.9999L2 18.7861L3.89693 21.1103L6.3072 19.324L4.41026 16.9999Z"}),po("path",{d:"M8.41026 13.9999L6 15.7861L7.89693 18.1103L10.3072 16.324L8.41026 13.9999Z"}),po("path",{d:"M12.4313 10.954L10.021 12.7402L11.9179 15.0644L14.3282 13.2781L12.4313 10.954Z"})]});import{jsx as Ur}from"react/jsx-runtime";var nt=({size:e=24,className:t})=>Ur("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:Ur("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 St,jsxs as fd}from"react/jsx-runtime";var rt=({size:e=24,className:t})=>fd("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:[St("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"}),St("path",{d:"M12 8V16",strokeLinecap:"round",strokeLinejoin:"round"}),St("path",{d:"M8 12H16",strokeLinecap:"round",strokeLinejoin:"round"}),St("path",{d:"M9.17139 9.17188L14.8282 14.8287",strokeLinecap:"round",strokeLinejoin:"round"}),St("path",{d:"M14.8281 9.17188L9.17127 14.8287",strokeLinecap:"round",strokeLinejoin:"round"})]});import{jsx as Gn,jsxs as md}from"react/jsx-runtime";var it=({size:e=24,className:t})=>md("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:[Gn("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"}),Gn("path",{d:"M14.8286 9.17188L9.17176 14.8287",strokeLinecap:"round",strokeLinejoin:"round"}),Gn("path",{d:"M9.17139 9.17188L14.8282 14.8287",strokeLinecap:"round",strokeLinejoin:"round"})]});import{jsx as Bn,jsxs as gd}from"react/jsx-runtime";var st=({size:e=24,className:t})=>gd("svg",{width:e,height:e,viewBox:"0 0 24 24",xmlns:"http://www.w3.org/2000/svg",fill:"white",stroke:"#6b7280",strokeWidth:2,className:t,children:[Bn("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"}),Bn("path",{d:"M12 8V16",strokeLinecap:"round",strokeLinejoin:"round"}),Bn("path",{d:"M8 12H16",strokeLinecap:"round",strokeLinejoin:"round"})]});import{jsx as zn,jsxs as hd}from"react/jsx-runtime";var Yr=({size:e=24,className:t})=>zn("svg",{width:e,height:e,viewBox:"0 0 34 24",xmlns:"http://www.w3.org/2000/svg",fill:"currentColor",className:t,children:hd("g",{children:[zn("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"}),zn("path",{d:"M24.5 4.5L28 1M28 1L31.5 4.5M28 1V8",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round"})]})});import{clsx as yd}from"clsx";import{twMerge as xd}from"tailwind-merge";function P(...e){return xd(yd(e))}var Pe=(e=0,t=0)=>e<t?t:e,$r=(e=1e3)=>new Promise(t=>{setTimeout(t,e)});import{jsx as Xr,jsxs as Ed}from"react/jsx-runtime";var Kr=({size:e=24,className:t})=>Ed("svg",{width:e,height:e,viewBox:"0 0 24 24",fill:"none",stroke:"#6b7280",strokeWidth:2,xmlns:"http://www.w3.org/2000/svg",className:P("stroke-2",t),children:[Xr("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"}),Xr("path",{d:"M9 3V21",strokeLinecap:"round",strokeLinejoin:"round"})]});import{jsx as Fn}from"react/jsx-runtime";var qr=({size:e=24,className:t})=>Fn("svg",{width:e,height:e,viewBox:"0 0 24 24",xmlns:"http://www.w3.org/2000/svg",stroke:"currentColor",className:t,children:Fn("g",{children:Fn("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 Zr}from"react/jsx-runtime";var mo=({size:e=24,className:t})=>Zr("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:Zr("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 Jr}from"react/jsx-runtime";var Mt=({size:e=24,className:t})=>Jr("svg",{width:e,height:e,viewBox:"0 0 24 24",xmlns:"http://www.w3.org/2000/svg",fill:"white",stroke:"#6b7280",className:P("stroke-2",t),children:Jr("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 Wn,jsxs as _d}from"react/jsx-runtime";var Qr=({size:e=24,className:t})=>_d("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:[Wn("path",{d:"M20 3H4C2.89543 3 2 4.34315 2 6V18C2 19.6569 2.89543 21 4 21H20C21.1046 21 22 19.6569 22 18V6C22 4.34315 21.1046 3 20 3Z",strokeLinecap:"round",strokeLinejoin:"round"}),Wn("path",{d:"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"}),Wn("path",{d:"M7.5 7.5V10H10",strokeWidth:"1.5",fill:"none",strokeLinecap:"round",strokeLinejoin:"round"})]});import{jsx as Pt,jsxs as bd}from"react/jsx-runtime";var jr=({size:e=24,className:t})=>bd("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:[Pt("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"}),Pt("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"}),Pt("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"}),Pt("path",{d:"M13.5 12H11",strokeWidth:"1",strokeLinecap:"round",strokeLinejoin:"round"}),Pt("path",{d:"M13.5 10H11",strokeWidth:"1",strokeLinecap:"round",strokeLinejoin:"round"})]});import{jsx as go,jsxs as Td}from"react/jsx-runtime";var ei=({size:e=24,className:t})=>Td("svg",{width:e,height:e,viewBox:"0 0 24 24",xmlns:"http://www.w3.org/2000/svg",fill:"white",stroke:"#6b7280",strokeWidth:2,className:t,children:[go("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"}),go("path",{d:"M8 21V14C8 13.4477 8.44772 13 9 13H15C15.5523 13 16 13.4477 16 14V21",strokeWidth:"1",fill:"none"}),go("path",{d:"M10.2222 17H13.7777",strokeWidth:"1",strokeLinecap:"round",strokeLinejoin:"round"}),go("path",{d:"M12 15.2227V18.7782",strokeWidth:"1",strokeLinecap:"round",strokeLinejoin:"round"})]});var k=(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))(k||{}),me=(o=>(o.SCRIPT="SCRIPT",o.SUBPROCESS="SUBPROCESS",o))(me||{}),ho={SCRIPT:{icon:Nd},SUBPROCESS:{icon:wd}},Le=(t=>(t.LOOP="LOOP",t))(Le||{}),yo={LOOP:{icon:vd}},ge=(n=>(n.EXCLUSIVE="EXCLUSIVE",n.PARALLEL="PARALLEL",n.COMPLEX="COMPLEX",n))(ge||{}),Un={EXCLUSIVE:{icon:it},PARALLEL:{icon:st},COMPLEX:{icon:rt}};import{ReactFlowProvider as ly}from"@xyflow/react";import{createContext as cy,useContext as dy,useEffect as Hc,useId as uy,useState as Se}from"react";import{applyNodeChanges as L0,Background as k0,MiniMap as D0,ReactFlow as R0,SelectionMode as V0,useEdgesState as O0,useNodesState as H0,useOnSelectionChange as G0,useReactFlow as B0}from"@xyflow/react";import{i18n as z0}from"lecom-ui";import{forwardRef as F0,useCallback as Dn,useEffect as Rc,useImperativeHandle as W0,useRef as U0,useState as Y0}from"react";import{useDebouncedCallback as $0}from"use-debounce";import{v7 as wr}from"uuid";import{create as Ad}from"zustand";import{useReactFlow as Cd}from"@xyflow/react";import{useCallback as Id}from"react";var xo=()=>{let{setEdges:e}=Cd();return Id(()=>{let o=Fe.getState().pathEdgeIds;e(n=>n.map(r=>N(_({},r),{selected:o.includes(r.id)})))},[e])},Fe=Ad((e,t)=>({statusByNodeId:{},statusData:{},pathEdgeIds:[],setTaskStatuses:o=>{o!=null&&o.length&&e(n=>{let r=_({},n.statusByNodeId),i=_({},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,f)=>{let u=[],p=new Set;for(u.push({node:d,path:[]}),p.add(d);u.length>0;){let{node:h,path:m}=u.shift();if(h===f)return m;let g=s[h]||[];for(let{targetId:T,edgeId:x}of g)p.has(T)||(p.add(T),u.push({node:T,path:[...m,x]}))}return[]};for(let d=0;d<r.length-1;d++){let f=r[d],u=r[d+1],p=c(f,u);p.length>0&&i.push(...p)}i.length>0&&e({pathEdgeIds:i})}}));import{useNodesInitialized as Wp,useReactFlow as Up,useStore as Yp}from"@xyflow/react";var Sd={value:()=>{}};function oi(){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 Eo(o)}function Eo(e){this._=e}function Md(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}})}Eo.prototype=oi.prototype={constructor:Eo,on:function(e,t){var o=this._,n=Md(e+"",o),r,i=-1,s=n.length;if(arguments.length<2){for(;++i<s;)if((r=(e=n[i]).type)&&(r=Pd(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]=ti(o[r],e.name,t);else if(t==null)for(r in o)o[r]=ti(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 Eo(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 Pd(e,t){for(var o=0,n=e.length,r;o<n;++o)if((r=e[o]).name===t)return r.value}function ti(e,t,o){for(var n=0,r=e.length;n<r;++n)if(e[n].name===t){e[n]=Sd,e=e.slice(0,n).concat(e.slice(n+1));break}return o!=null&&e.push({name:t,value:o}),e}var Yn=oi;var _o="http://www.w3.org/1999/xhtml",$n={svg:"http://www.w3.org/2000/svg",xhtml:_o,xlink:"http://www.w3.org/1999/xlink",xml:"http://www.w3.org/XML/1998/namespace",xmlns:"http://www.w3.org/2000/xmlns/"};function Ne(e){var t=e+="",o=t.indexOf(":");return o>=0&&(t=e.slice(0,o))!=="xmlns"&&(e=e.slice(o+1)),$n.hasOwnProperty(t)?{space:$n[t],local:e}:e}function Ld(e){return function(){var t=this.ownerDocument,o=this.namespaceURI;return o===_o&&t.documentElement.namespaceURI===_o?t.createElement(e):t.createElementNS(o,e)}}function kd(e){return function(){return this.ownerDocument.createElementNS(e.space,e.local)}}function bo(e){var t=Ne(e);return(t.local?kd:Ld)(t)}function Dd(){}function We(e){return e==null?Dd:function(){return this.querySelector(e)}}function ni(e){typeof e!="function"&&(e=We(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 Y(n,this._parents)}function Xn(e){return e==null?[]:Array.isArray(e)?e:Array.from(e)}function Rd(){return[]}function Lt(e){return e==null?Rd:function(){return this.querySelectorAll(e)}}function Vd(e){return function(){return Xn(e.apply(this,arguments))}}function ri(e){typeof e=="function"?e=Vd(e):e=Lt(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 Y(n,r)}function kt(e){return function(){return this.matches(e)}}function To(e){return function(t){return t.matches(e)}}var Od=Array.prototype.find;function Hd(e){return function(){return Od.call(this.children,e)}}function Gd(){return this.firstElementChild}function ii(e){return this.select(e==null?Gd:Hd(typeof e=="function"?e:To(e)))}var Bd=Array.prototype.filter;function zd(){return Array.from(this.children)}function Fd(e){return function(){return Bd.call(this.children,e)}}function si(e){return this.selectAll(e==null?zd:Fd(typeof e=="function"?e:To(e)))}function ai(e){typeof e!="function"&&(e=kt(e));for(var t=this._groups,o=t.length,n=new Array(o),r=0;r<o;++r)for(var i=t[r],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 Y(n,this._parents)}function vo(e){return new Array(e.length)}function li(){return new Y(this._enter||this._groups.map(vo),this._parents)}function Dt(e,t){this.ownerDocument=e.ownerDocument,this.namespaceURI=e.namespaceURI,this._next=null,this._parent=e,this.__data__=t}Dt.prototype={constructor:Dt,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 ci(e){return function(){return e}}function Wd(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 Dt(e,i[s]);for(;s<l;++s)(a=t[s])&&(r[s]=a)}function Ud(e,t,o,n,r,i,s){var a,l,c=new Map,d=t.length,f=i.length,u=new Array(d),p;for(a=0;a<d;++a)(l=t[a])&&(u[a]=p=s.call(l,l.__data__,a,t)+"",c.has(p)?r[a]=l:c.set(p,l));for(a=0;a<f;++a)p=s.call(e,i[a],a,i)+"",(l=c.get(p))?(n[a]=l,l.__data__=i[a],c.delete(p)):o[a]=new Dt(e,i[a]);for(a=0;a<d;++a)(l=t[a])&&c.get(u[a])===l&&(r[a]=l)}function Yd(e){return e.__data__}function di(e,t){if(!arguments.length)return Array.from(this,Yd);var o=t?Ud:Wd,n=this._parents,r=this._groups;typeof e!="function"&&(e=ci(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],f=r[c],u=f.length,p=$d(e.call(d,d&&d.__data__,c,n)),h=p.length,m=a[c]=new Array(h),g=s[c]=new Array(h),T=l[c]=new Array(u);o(d,f,m,g,T,p,t);for(var x=0,y=0,E,b;x<h;++x)if(E=m[x]){for(x>=y&&(y=x+1);!(b=g[y])&&++y<h;);E._next=b||null}}return s=new Y(s,n),s._enter=a,s._exit=l,s}function $d(e){return typeof e=="object"&&"length"in e?e:Array.from(e)}function ui(){return new Y(this._exit||this._groups.map(vo),this._parents)}function pi(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 fi(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],f=c.length,u=a[l]=new Array(f),p,h=0;h<f;++h)(p=c[h]||d[h])&&(u[h]=p);for(;l<r;++l)a[l]=o[l];return new Y(a,this._parents)}function mi(){for(var e=this._groups,t=-1,o=e.length;++t<o;)for(var n=e[t],r=n.length-1,i=n[r],s;--r>=0;)(s=n[r])&&(i&&s.compareDocumentPosition(i)^4&&i.parentNode.insertBefore(s,i),i=s);return this}function gi(e){e||(e=Xd);function t(f,u){return f&&u?e(f.__data__,u.__data__):!f-!u}for(var o=this._groups,n=o.length,r=new Array(n),i=0;i<n;++i){for(var s=o[i],a=s.length,l=r[i]=new Array(a),c,d=0;d<a;++d)(c=s[d])&&(l[d]=c);l.sort(t)}return new Y(r,this._parents).order()}function Xd(e,t){return e<t?-1:e>t?1:e>=t?0:NaN}function hi(){var e=arguments[0];return arguments[0]=this,e.apply(null,arguments),this}function yi(){return Array.from(this)}function xi(){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 Ei(){let e=0;for(let t of this)++e;return e}function _i(){return!this.node()}function bi(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 Kd(e){return function(){this.removeAttribute(e)}}function qd(e){return function(){this.removeAttributeNS(e.space,e.local)}}function Zd(e,t){return function(){this.setAttribute(e,t)}}function Jd(e,t){return function(){this.setAttributeNS(e.space,e.local,t)}}function Qd(e,t){return function(){var o=t.apply(this,arguments);o==null?this.removeAttribute(e):this.setAttribute(e,o)}}function jd(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 Ti(e,t){var o=Ne(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?qd:Kd:typeof t=="function"?o.local?jd:Qd:o.local?Jd:Zd)(o,t))}function No(e){return e.ownerDocument&&e.ownerDocument.defaultView||e.document&&e||e.defaultView}function eu(e){return function(){this.style.removeProperty(e)}}function tu(e,t,o){return function(){this.style.setProperty(e,t,o)}}function ou(e,t,o){return function(){var n=t.apply(this,arguments);n==null?this.style.removeProperty(e):this.style.setProperty(e,n,o)}}function vi(e,t,o){return arguments.length>1?this.each((t==null?eu:typeof t=="function"?ou:tu)(e,t,o==null?"":o)):ke(this.node(),e)}function ke(e,t){return e.style.getPropertyValue(t)||No(e).getComputedStyle(e,null).getPropertyValue(t)}function nu(e){return function(){delete this[e]}}function ru(e,t){return function(){this[e]=t}}function iu(e,t){return function(){var o=t.apply(this,arguments);o==null?delete this[e]:this[e]=o}}function Ni(e,t){return arguments.length>1?this.each((t==null?nu:typeof t=="function"?iu:ru)(e,t)):this.node()[e]}function wi(e){return e.trim().split(/^|\s+/)}function Kn(e){return e.classList||new Ai(e)}function Ai(e){this._node=e,this._names=wi(e.getAttribute("class")||"")}Ai.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 Ci(e,t){for(var o=Kn(e),n=-1,r=t.length;++n<r;)o.add(t[n])}function Ii(e,t){for(var o=Kn(e),n=-1,r=t.length;++n<r;)o.remove(t[n])}function su(e){return function(){Ci(this,e)}}function au(e){return function(){Ii(this,e)}}function lu(e,t){return function(){(t.apply(this,arguments)?Ci:Ii)(this,e)}}function Si(e,t){var o=wi(e+"");if(arguments.length<2){for(var n=Kn(this.node()),r=-1,i=o.length;++r<i;)if(!n.contains(o[r]))return!1;return!0}return this.each((typeof t=="function"?lu:t?su:au)(o,t))}function cu(){this.textContent=""}function du(e){return function(){this.textContent=e}}function uu(e){return function(){var t=e.apply(this,arguments);this.textContent=t==null?"":t}}function Mi(e){return arguments.length?this.each(e==null?cu:(typeof e=="function"?uu:du)(e)):this.node().textContent}function pu(){this.innerHTML=""}function fu(e){return function(){this.innerHTML=e}}function mu(e){return function(){var t=e.apply(this,arguments);this.innerHTML=t==null?"":t}}function Pi(e){return arguments.length?this.each(e==null?pu:(typeof e=="function"?mu:fu)(e)):this.node().innerHTML}function gu(){this.nextSibling&&this.parentNode.appendChild(this)}function Li(){return this.each(gu)}function hu(){this.previousSibling&&this.parentNode.insertBefore(this,this.parentNode.firstChild)}function ki(){return this.each(hu)}function Di(e){var t=typeof e=="function"?e:bo(e);return this.select(function(){return this.appendChild(t.apply(this,arguments))})}function yu(){return null}function Ri(e,t){var o=typeof e=="function"?e:bo(e),n=t==null?yu:typeof t=="function"?t:We(t);return this.select(function(){return this.insertBefore(o.apply(this,arguments),n.apply(this,arguments)||null)})}function xu(){var e=this.parentNode;e&&e.removeChild(this)}function Vi(){return this.each(xu)}function Eu(){var e=this.cloneNode(!1),t=this.parentNode;return t?t.insertBefore(e,this.nextSibling):e}function _u(){var e=this.cloneNode(!0),t=this.parentNode;return t?t.insertBefore(e,this.nextSibling):e}function Oi(e){return this.select(e?_u:Eu)}function Hi(e){return arguments.length?this.property("__data__",e):this.node().__data__}function bu(e){return function(t){e.call(this,t,this.__data__)}}function Tu(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 vu(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 Nu(e,t,o){return function(){var n=this.__on,r,i=bu(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 Gi(e,t,o){var n=Tu(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?Nu:vu,r=0;r<i;++r)this.each(a(n[r],t,o));return this}function Bi(e,t,o){var n=No(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 wu(e,t){return function(){return Bi(this,e,t)}}function Au(e,t){return function(){return Bi(this,e,t.apply(this,arguments))}}function zi(e,t){return this.each((typeof t=="function"?Au:wu)(e,t))}function*Fi(){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 Cu=[null];function Y(e,t){this._groups=e,this._parents=t}function Wi(){return new Y([[document.documentElement]],Cu)}function Iu(){return this}Y.prototype=Wi.prototype={constructor:Y,select:ni,selectAll:ri,selectChild:ii,selectChildren:si,filter:ai,data:di,enter:li,exit:ui,join:pi,merge:fi,selection:Iu,order:mi,sort:gi,call:hi,nodes:yi,node:xi,size:Ei,empty:_i,each:bi,attr:Ti,style:vi,property:Ni,classed:Si,text:Mi,html:Pi,raise:Li,lower:ki,append:Di,insert:Ri,remove:Vi,clone:Oi,datum:Hi,on:Gi,dispatch:zi,[Symbol.iterator]:Fi};var we=Wi;function wo(e,t,o){e.prototype=t.prototype=o,o.constructor=e}function qn(e,t){var o=Object.create(e.prototype);for(var n in t)o[n]=t[n];return o}function Ot(){}var Rt=.7,Io=1/Rt,at="\\s*([+-]?\\d+)\\s*",Vt="\\s*([+-]?(?:\\d*\\.)?\\d+(?:[eE][+-]?\\d+)?)\\s*",_e="\\s*([+-]?(?:\\d*\\.)?\\d+(?:[eE][+-]?\\d+)?)%\\s*",Su=/^#([0-9a-f]{3,8})$/,Mu=new RegExp(`^rgb\\(${at},${at},${at}\\)$`),Pu=new RegExp(`^rgb\\(${_e},${_e},${_e}\\)$`),Lu=new RegExp(`^rgba\\(${at},${at},${at},${Vt}\\)$`),ku=new RegExp(`^rgba\\(${_e},${_e},${_e},${Vt}\\)$`),Du=new RegExp(`^hsl\\(${Vt},${_e},${_e}\\)$`),Ru=new RegExp(`^hsla\\(${Vt},${_e},${_e},${Vt}\\)$`),Ui={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};wo(Ot,De,{copy(e){return Object.assign(new this.constructor,this,e)},displayable(){return this.rgb().displayable()},hex:Yi,formatHex:Yi,formatHex8:Vu,formatHsl:Ou,formatRgb:$i,toString:$i});function Yi(){return this.rgb().formatHex()}function Vu(){return this.rgb().formatHex8()}function Ou(){return Qi(this).formatHsl()}function $i(){return this.rgb().formatRgb()}function De(e){var t,o;return e=(e+"").trim().toLowerCase(),(t=Su.exec(e))?(o=t[1].length,t=parseInt(t[1],16),o===6?Xi(t):o===3?new ne(t>>8&15|t>>4&240,t>>4&15|t&240,(t&15)<<4|t&15,1):o===8?Ao(t>>24&255,t>>16&255,t>>8&255,(t&255)/255):o===4?Ao(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=Mu.exec(e))?new ne(t[1],t[2],t[3],1):(t=Pu.exec(e))?new ne(t[1]*255/100,t[2]*255/100,t[3]*255/100,1):(t=Lu.exec(e))?Ao(t[1],t[2],t[3],t[4]):(t=ku.exec(e))?Ao(t[1]*255/100,t[2]*255/100,t[3]*255/100,t[4]):(t=Du.exec(e))?Zi(t[1],t[2]/100,t[3]/100,1):(t=Ru.exec(e))?Zi(t[1],t[2]/100,t[3]/100,t[4]):Ui.hasOwnProperty(e)?Xi(Ui[e]):e==="transparent"?new ne(NaN,NaN,NaN,0):null}function Xi(e){return new ne(e>>16&255,e>>8&255,e&255,1)}function Ao(e,t,o,n){return n<=0&&(e=t=o=NaN),new ne(e,t,o,n)}function Hu(e){return e instanceof Ot||(e=De(e)),e?(e=e.rgb(),new ne(e.r,e.g,e.b,e.opacity)):new ne}function lt(e,t,o,n){return arguments.length===1?Hu(e):new ne(e,t,o,n==null?1:n)}function ne(e,t,o,n){this.r=+e,this.g=+t,this.b=+o,this.opacity=+n}wo(ne,lt,qn(Ot,{brighter(e){return e=e==null?Io:Math.pow(Io,e),new ne(this.r*e,this.g*e,this.b*e,this.opacity)},darker(e){return e=e==null?Rt:Math.pow(Rt,e),new ne(this.r*e,this.g*e,this.b*e,this.opacity)},rgb(){return this},clamp(){return new ne(Ye(this.r),Ye(this.g),Ye(this.b),So(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:Ki,formatHex:Ki,formatHex8:Gu,formatRgb:qi,toString:qi}));function Ki(){return`#${Ue(this.r)}${Ue(this.g)}${Ue(this.b)}`}function Gu(){return`#${Ue(this.r)}${Ue(this.g)}${Ue(this.b)}${Ue((isNaN(this.opacity)?1:this.opacity)*255)}`}function qi(){let e=So(this.opacity);return`${e===1?"rgb(":"rgba("}${Ye(this.r)}, ${Ye(this.g)}, ${Ye(this.b)}${e===1?")":`, ${e})`}`}function So(e){return isNaN(e)?1:Math.max(0,Math.min(1,e))}function Ye(e){return Math.max(0,Math.min(255,Math.round(e)||0))}function Ue(e){return e=Ye(e),(e<16?"0":"")+e.toString(16)}function Zi(e,t,o,n){return n<=0?e=t=o=NaN:o<=0||o>=1?e=t=NaN:t<=0&&(e=NaN),new he(e,t,o,n)}function Qi(e){if(e instanceof he)return new he(e.h,e.s,e.l,e.opacity);if(e instanceof Ot||(e=De(e)),!e)return new he;if(e instanceof he)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 he(s,a,l,e.opacity)}function ji(e,t,o,n){return arguments.length===1?Qi(e):new he(e,t,o,n==null?1:n)}function he(e,t,o,n){this.h=+e,this.s=+t,this.l=+o,this.opacity=+n}wo(he,ji,qn(Ot,{brighter(e){return e=e==null?Io:Math.pow(Io,e),new he(this.h,this.s,this.l*e,this.opacity)},darker(e){return e=e==null?Rt:Math.pow(Rt,e),new he(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 ne(Zn(e>=240?e-240:e+120,r,n),Zn(e,r,n),Zn(e<120?e+240:e-120,r,n),this.opacity)},clamp(){return new he(Ji(this.h),Co(this.s),Co(this.l),So(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=So(this.opacity);return`${e===1?"hsl(":"hsla("}${Ji(this.h)}, ${Co(this.s)*100}%, ${Co(this.l)*100}%${e===1?")":`, ${e})`}`}}));function Ji(e){return e=(e||0)%360,e<0?e+360:e}function Co(e){return Math.max(0,Math.min(1,e||0))}function Zn(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 Jn(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 es(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 Jn((o-n/t)*t,s,r,i,a)}}function ts(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 Jn((o-n/t)*t,r,i,s,a)}}var Qn=e=>()=>e;function Bu(e,t){return function(o){return e+o*t}}function zu(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 os(e){return(e=+e)==1?Mo:function(t,o){return o-t?zu(t,o,e):Qn(isNaN(t)?o:t)}}function Mo(e,t){var o=t-e;return o?Bu(e,o):Qn(isNaN(e)?t:e)}var Po=function e(t){var o=os(t);function n(r,i){var s=o((r=lt(r)).r,(i=lt(i)).r),a=o(r.g,i.g),l=o(r.b,i.b),c=Mo(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 ns(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=lt(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 Fu=ns(es),Wu=ns(ts);function pe(e,t){return e=+e,t=+t,function(o){return e*(1-o)+t*o}}var er=/[-+]?(?:\d+\.?\d*|\.?\d+)(?:[eE][-+]?\d+)?/g,jn=new RegExp(er.source,"g");function Uu(e){return function(){return e}}function Yu(e){return function(t){return e(t)+""}}function tr(e,t){var o=er.lastIndex=jn.lastIndex=0,n,r,i,s=-1,a=[],l=[];for(e=e+"",t=t+"";(n=er.exec(e))&&(r=jn.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:pe(n,r)})),o=jn.lastIndex;return o<t.length&&(i=t.slice(o),a[s]?a[s]+=i:a[++s]=i),a.length<2?l[0]?Yu(l[0].x):Uu(t):(t=l.length,function(c){for(var d=0,f;d<t;++d)a[(f=l[d]).i]=f.x(c);return a.join("")})}var rs=180/Math.PI,Lo={translateX:0,translateY:0,rotate:0,skewX:0,scaleX:1,scaleY:1};function or(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)*rs,skewX:Math.atan(l)*rs,scaleX:s,scaleY:a}}var ko;function is(e){let t=new(typeof DOMMatrix=="function"?DOMMatrix:WebKitCSSMatrix)(e+"");return t.isIdentity?Lo:or(t.a,t.b,t.c,t.d,t.e,t.f)}function ss(e){return e==null?Lo:(ko||(ko=document.createElementNS("http://www.w3.org/2000/svg","g")),ko.setAttribute("transform",e),(e=ko.transform.baseVal.consolidate())?(e=e.matrix,or(e.a,e.b,e.c,e.d,e.e,e.f)):Lo)}function as(e,t,o,n){function r(c){return c.length?c.pop()+" ":""}function i(c,d,f,u,p,h){if(c!==f||d!==u){var m=p.push("translate(",null,t,null,o);h.push({i:m-4,x:pe(c,f)},{i:m-2,x:pe(d,u)})}else(f||u)&&p.push("translate("+f+t+u+o)}function s(c,d,f,u){c!==d?(c-d>180?d+=360:d-c>180&&(c+=360),u.push({i:f.push(r(f)+"rotate(",null,n)-2,x:pe(c,d)})):d&&f.push(r(f)+"rotate("+d+n)}function a(c,d,f,u){c!==d?u.push({i:f.push(r(f)+"skewX(",null,n)-2,x:pe(c,d)}):d&&f.push(r(f)+"skewX("+d+n)}function l(c,d,f,u,p,h){if(c!==f||d!==u){var m=p.push(r(p)+"scale(",null,",",null,")");h.push({i:m-4,x:pe(c,f)},{i:m-2,x:pe(d,u)})}else(f!==1||u!==1)&&p.push(r(p)+"scale("+f+","+u+")")}return function(c,d){var f=[],u=[];return c=e(c),d=e(d),i(c.translateX,c.translateY,d.translateX,d.translateY,f,u),s(c.rotate,d.rotate,f,u),a(c.skewX,d.skewX,f,u),l(c.scaleX,c.scaleY,d.scaleX,d.scaleY,f,u),c=d=null,function(p){for(var h=-1,m=u.length,g;++h<m;)f[(g=u[h]).i]=g.x(p);return f.join("")}}}var nr=as(is,"px, ","px)","deg)"),rr=as(ss,", ",")",")");var ct=0,Gt=0,Ht=0,cs=1e3,Do,Bt,Ro=0,$e=0,Vo=0,zt=typeof performance=="object"&&performance.now?performance:Date,ds=typeof window=="object"&&window.requestAnimationFrame?window.requestAnimationFrame.bind(window):function(e){setTimeout(e,17)};function Wt(){return $e||(ds($u),$e=zt.now()+Vo)}function $u(){$e=0}function Ft(){this._call=this._time=this._next=null}Ft.prototype=Oo.prototype={constructor:Ft,restart:function(e,t,o){if(typeof e!="function")throw new TypeError("callback is not a function");o=(o==null?Wt():+o)+(t==null?0:+t),!this._next&&Bt!==this&&(Bt?Bt._next=this:Do=this,Bt=this),this._call=e,this._time=o,ir()},stop:function(){this._call&&(this._call=null,this._time=1/0,ir())}};function Oo(e,t,o){var n=new Ft;return n.restart(e,t,o),n}function us(){Wt(),++ct;for(var e=Do,t;e;)(t=$e-e._time)>=0&&e._call.call(void 0,t),e=e._next;--ct}function ls(){$e=(Ro=zt.now())+Vo,ct=Gt=0;try{us()}finally{ct=0,Ku(),$e=0}}function Xu(){var e=zt.now(),t=e-Ro;t>cs&&(Vo-=t,Ro=e)}function Ku(){for(var e,t=Do,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:Do=o);Bt=e,ir(n)}function ir(e){if(!ct){Gt&&(Gt=clearTimeout(Gt));var t=e-$e;t>24?(e<1/0&&(Gt=setTimeout(ls,e-zt.now()-Vo)),Ht&&(Ht=clearInterval(Ht))):(Ht||(Ro=zt.now(),Ht=setInterval(Xu,cs)),ct=1,ds(ls))}}function Ho(e,t,o){var n=new Ft;return t=t==null?0:+t,n.restart(r=>{n.stop(),e(r+t)},t,o),n}var qu=Yn("start","end","cancel","interrupt"),Zu=[],ms=0,ps=1,Bo=2,Go=3,fs=4,zo=5,Ut=6;function Re(e,t,o,n,r,i){var s=e.__transition;if(!s)e.__transition={};else if(o in s)return;Ju(e,o,{name:t,index:n,group:r,on:qu,tween:Zu,time:i.time,delay:i.delay,duration:i.duration,ease:i.ease,timer:null,state:ms})}function Yt(e,t){var o=$(e,t);if(o.state>ms)throw new Error("too late; already scheduled");return o}function q(e,t){var o=$(e,t);if(o.state>Go)throw new Error("too late; already running");return o}function $(e,t){var o=e.__transition;if(!o||!(o=o[t]))throw new Error("transition not found");return o}function Ju(e,t,o){var n=e.__transition,r;n[t]=o,o.timer=Oo(i,0,o.time);function i(c){o.state=ps,o.timer.restart(s,o.delay,o.time),o.delay<=c&&s(c-o.delay)}function s(c){var d,f,u,p;if(o.state!==ps)return l();for(d in n)if(p=n[d],p.name===o.name){if(p.state===Go)return Ho(s);p.state===fs?(p.state=Ut,p.timer.stop(),p.on.call("interrupt",e,e.__data__,p.index,p.group),delete n[d]):+d<t&&(p.state=Ut,p.timer.stop(),p.on.call("cancel",e,e.__data__,p.index,p.group),delete n[d])}if(Ho(function(){o.state===Go&&(o.state=fs,o.timer.restart(a,o.delay,o.time),a(c))}),o.state=Bo,o.on.call("start",e,e.__data__,o.index,o.group),o.state===Bo){for(o.state=Go,r=new Array(u=o.tween.length),d=0,f=-1;d<u;++d)(p=o.tween[d].value.call(e,e.__data__,o.index,o.group))&&(r[++f]=p);r.length=f+1}}function a(c){for(var d=c<o.duration?o.ease.call(null,c/o.duration):(o.timer.restart(l),o.state=zo,1),f=-1,u=r.length;++f<u;)r[f].call(e,d);o.state===zo&&(o.on.call("end",e,e.__data__,o.index,o.group),l())}function l(){o.state=Ut,o.timer.stop(),delete n[t];for(var c in n)return;delete e.__transition}}function sr(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>Bo&&n.state<zo,n.state=Ut,n.timer.stop(),n.on.call(r?"interrupt":"cancel",e,e.__data__,n.index,n.group),delete o[s]}i&&delete e.__transition}}function gs(e){return this.each(function(){sr(this,e)})}function Qu(e,t){var o,n;return function(){var r=q(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 ju(e,t,o){var n,r;if(typeof o!="function")throw new Error;return function(){var i=q(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 hs(e,t){var o=this._id;if(e+="",arguments.length<2){for(var n=$(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?Qu:ju)(o,e,t))}function dt(e,t,o){var n=e._id;return e.each(function(){var r=q(this,n);(r.value||(r.value={}))[t]=o.apply(this,arguments)}),function(r){return $(r,n).value[t]}}function Fo(e,t){var o;return(typeof t=="number"?pe:t instanceof De?Po:(o=De(t))?(t=o,Po):tr)(e,t)}function ep(e){return function(){this.removeAttribute(e)}}function tp(e){return function(){this.removeAttributeNS(e.space,e.local)}}function op(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 np(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 rp(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 ip(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 ys(e,t){var o=Ne(e),n=o==="transform"?rr:Fo;return this.attrTween(e,typeof t=="function"?(o.local?ip:rp)(o,n,dt(this,"attr."+e,t)):t==null?(o.local?tp:ep)(o):(o.local?np:op)(o,n,t))}function sp(e,t){return function(o){this.setAttribute(e,t.call(this,o))}}function ap(e,t){return function(o){this.setAttributeNS(e.space,e.local,t.call(this,o))}}function lp(e,t){var o,n;function r(){var i=t.apply(this,arguments);return i!==n&&(o=(n=i)&&ap(e,i)),o}return r._value=t,r}function cp(e,t){var o,n;function r(){var i=t.apply(this,arguments);return i!==n&&(o=(n=i)&&sp(e,i)),o}return r._value=t,r}function xs(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=Ne(e);return this.tween(o,(n.local?lp:cp)(n,t))}function dp(e,t){return function(){Yt(this,e).delay=+t.apply(this,arguments)}}function up(e,t){return t=+t,function(){Yt(this,e).delay=t}}function Es(e){var t=this._id;return arguments.length?this.each((typeof e=="function"?dp:up)(t,e)):$(this.node(),t).delay}function pp(e,t){return function(){q(this,e).duration=+t.apply(this,arguments)}}function fp(e,t){return t=+t,function(){q(this,e).duration=t}}function _s(e){var t=this._id;return arguments.length?this.each((typeof e=="function"?pp:fp)(t,e)):$(this.node(),t).duration}function mp(e,t){if(typeof t!="function")throw new Error;return function(){q(this,e).ease=t}}function bs(e){var t=this._id;return arguments.length?this.each(mp(t,e)):$(this.node(),t).ease}function gp(e,t){return function(){var o=t.apply(this,arguments);if(typeof o!="function")throw new Error;q(this,e).ease=o}}function Ts(e){if(typeof e!="function")throw new Error;return this.each(gp(this._id,e))}function vs(e){typeof e!="function"&&(e=kt(e));for(var t=this._groups,o=t.length,n=new Array(o),r=0;r<o;++r)for(var i=t[r],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 te(n,this._parents,this._name,this._id)}function Ns(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,f=s[a]=new Array(d),u,p=0;p<d;++p)(u=l[p]||c[p])&&(f[p]=u);for(;a<n;++a)s[a]=t[a];return new te(s,this._parents,this._name,this._id)}function hp(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 yp(e,t,o){var n,r,i=hp(t)?Yt:q;return function(){var s=i(this,e),a=s.on;a!==n&&(r=(n=a).copy()).on(t,o),s.on=r}}function ws(e,t){var o=this._id;return arguments.length<2?$(this.node(),o).on.on(e):this.each(yp(o,e,t))}function xp(e){return function(){var t=this.parentNode;for(var o in this.__transition)if(+o!==e)return;t&&t.removeChild(this)}}function As(){return this.on("end.remove",xp(this._id))}function Cs(e){var t=this._name,o=this._id;typeof e!="function"&&(e=We(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,f,u=0;u<l;++u)(d=a[u])&&(f=e.call(d,d.__data__,u,a))&&("__data__"in d&&(f.__data__=d.__data__),c[u]=f,Re(c[u],t,o,u,c,$(d,o)));return new te(i,this._parents,t,o)}function Is(e){var t=this._name,o=this._id;typeof e!="function"&&(e=Lt(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,f=0;f<c;++f)if(d=l[f]){for(var u=e.call(d,d.__data__,f,l),p,h=$(d,o),m=0,g=u.length;m<g;++m)(p=u[m])&&Re(p,t,o,m,u,h);i.push(u),s.push(d)}return new te(i,s,t,o)}var Ep=we.prototype.constructor;function Ss(){return new Ep(this._groups,this._parents)}function _p(e,t){var o,n,r;return function(){var i=ke(this,e),s=(this.style.removeProperty(e),ke(this,e));return i===s?null:i===o&&s===n?r:r=t(o=i,n=s)}}function Ms(e){return function(){this.style.removeProperty(e)}}function bp(e,t,o){var n,r=o+"",i;return function(){var s=ke(this,e);return s===r?null:s===n?i:i=t(n=s,o)}}function Tp(e,t,o){var n,r,i;return function(){var s=ke(this,e),a=o(this),l=a+"";return a==null&&(l=a=(this.style.removeProperty(e),ke(this,e))),s===l?null:s===n&&l===r?i:(r=l,i=t(n=s,a))}}function vp(e,t){var o,n,r,i="style."+t,s="end."+i,a;return function(){var l=q(this,e),c=l.on,d=l.value[i]==null?a||(a=Ms(t)):void 0;(c!==o||r!==d)&&(n=(o=c).copy()).on(s,r=d),l.on=n}}function Ps(e,t,o){var n=(e+="")=="transform"?nr:Fo;return t==null?this.styleTween(e,_p(e,n)).on("end.style."+e,Ms(e)):typeof t=="function"?this.styleTween(e,Tp(e,n,dt(this,"style."+e,t))).each(vp(this._id,e)):this.styleTween(e,bp(e,n,t),o).on("end.style."+e,null)}function Np(e,t,o){return function(n){this.style.setProperty(e,t.call(this,n),o)}}function wp(e,t,o){var n,r;function i(){var s=t.apply(this,arguments);return s!==r&&(n=(r=s)&&Np(e,s,o)),n}return i._value=t,i}function Ls(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,wp(e,t,o==null?"":o))}function Ap(e){return function(){this.textContent=e}}function Cp(e){return function(){var t=e(this);this.textContent=t==null?"":t}}function ks(e){return this.tween("text",typeof e=="function"?Cp(dt(this,"text",e)):Ap(e==null?"":e+""))}function Ip(e){return function(t){this.textContent=e.call(this,t)}}function Sp(e){var t,o;function n(){var r=e.apply(this,arguments);return r!==o&&(t=(o=r)&&Ip(r)),t}return n._value=e,n}function Ds(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,Sp(e))}function Rs(){for(var e=this._name,t=this._id,o=Wo(),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=$(l,t);Re(l,e,o,c,s,{time:d.time+d.delay+d.duration,delay:0,duration:d.duration,ease:d.ease})}return new te(n,this._parents,e,o)}function Vs(){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=q(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 Mp=0;function te(e,t,o,n){this._groups=e,this._parents=t,this._name=o,this._id=n}function Os(e){return we().transition(e)}function Wo(){return++Mp}var Ae=we.prototype;te.prototype=Os.prototype={constructor:te,select:Cs,selectAll:Is,selectChild:Ae.selectChild,selectChildren:Ae.selectChildren,filter:vs,merge:Ns,selection:Ss,transition:Rs,call:Ae.call,nodes:Ae.nodes,node:Ae.node,size:Ae.size,empty:Ae.empty,each:Ae.each,on:ws,attr:ys,attrTween:xs,style:Ps,styleTween:Ls,text:ks,textTween:Ds,remove:As,tween:hs,delay:Es,duration:_s,ease:bs,easeVarying:Ts,end:Vs,[Symbol.iterator]:Ae[Symbol.iterator]};function Uo(e){return((e*=2)<=1?e*e*e:(e-=2)*e*e+2)/2}var Pp={time:null,delay:0,duration:250,ease:Uo};function Lp(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 Hs(e){var t,o;e instanceof te?(t=e._id,e=e._name):(t=Wo(),(o=Pp).time=Wt(),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])&&Re(l,e,t,c,s,o||Lp(l,t));return new te(n,this._parents,e,t)}we.prototype.interrupt=gs;we.prototype.transition=Hs;function Ve(e,t,o){this.k=e,this.x=t,this.y=o}Ve.prototype={constructor:Ve,scale:function(e){return e===1?this:new Ve(this.k*e,this.x,this.y)},translate:function(e,t){return e===0&t===0?this:new Ve(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 Yo=new Ve(1,0,0);$o.prototype=Ve.prototype;function $o(e){for(;!e.__zoom;)if(!(e=e.parentNode))return Yo;return e.__zoom}var Dp=[[Number.NEGATIVE_INFINITY,Number.NEGATIVE_INFINITY],[Number.POSITIVE_INFINITY,Number.POSITIVE_INFINITY]];var Gs;(function(e){e.Strict="strict",e.Loose="loose"})(Gs||(Gs={}));var Bs;(function(e){e.Free="free",e.Vertical="vertical",e.Horizontal="horizontal"})(Bs||(Bs={}));var zs;(function(e){e.Partial="partial",e.Full="full"})(zs||(zs={}));var Fs;(function(e){e.Bezier="default",e.Straight="straight",e.Step="step",e.SmoothStep="smoothstep",e.SimpleBezier="simplebezier"})(Fs||(Fs={}));var Ws;(function(e){e.Arrow="arrow",e.ArrowClosed="arrowclosed"})(Ws||(Ws={}));var re;(function(e){e.Left="left",e.Top="top",e.Right="right",e.Bottom="bottom"})(re||(re={}));var HT={[re.Left]:re.Right,[re.Right]:re.Left,[re.Top]:re.Bottom,[re.Bottom]:re.Top};var Rp=e=>"id"in e&&"internals"in e&&!("source"in e)&&!("target"in e);var Vp=(e,t=[0,0])=>{var a;let{width:o,height:n}=Op(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 ae=(e,t=[0,0])=>{var r,i,s,a,l,c,d,f;let{x:o,y:n}=Rp(e)?e.internals.positionAbsolute:Vp(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+((f=(d=(c=(l=e.measured)==null?void 0:l.height)!=null?c:e.height)!=null?d:e.initialHeight)!=null?f:0)}};function Op(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 GT={[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 Hp={nodeOrigin:[0,0],nodeExtent:Dp,elevateNodesOnSelect:!0,defaults:{}},BT=N(_({},Hp),{checkEquality:!0});var Us;(function(e){e.Line="line",e.Handle="handle"})(Us||(Us={}));var Gp={width:0,height:0,x:0,y:0},zT=N(_({},Gp),{pointerX:0,pointerY:0,aspectRatio:1});import{useCallback as $t,useEffect as $p,useRef as Xp,useState as Ks}from"react";import{shallow as Kp}from"zustand/shallow";var Xo=10,Xe={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}};var Bp=(e,t)=>e.x<t.x2&&e.x2>t.x&&e.y<t.y2&&e.y2>t.y;function zp(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 Fp(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 Ko=class{constructor(){this.xLines=[];this.yLines=[]}initialize(t){this.xLines=t.filter(o=>o.orientation==="vertical"),this.yLines=t.filter(o=>o.orientation==="horizontal"),this.xLines.sort((o,n)=>o.position-n.position),this.yLines.sort((o,n)=>o.position-n.position),this.lastHorizontalLine=void 0,this.lastVerticalLine=void 0}search(t,o,n,r){let i=t==="horizontal"?this.yLines:this.xLines,[s,a]=t==="horizontal"?[r.y,r.y2]:[r.x,r.x2],l=[];for(let u of i){if(u.position<s)continue;if(u.position>a)break;if(u.node.id===n.id||u.node.parentId===n.id||!Bp(u.nodeBox,r))continue;let p=Math.abs(u.position-o);if(p>Xo)continue;let m=zp(u.nodeBox,ae(n))>0?0:Fp(u.nodeBox,ae(n));l.push({line:u,lineDist:p,nodeDist:m})}let c=.5,d=t==="horizontal"?this.lastHorizontalLine:this.lastVerticalLine;l.sort((u,p)=>{if(d){if(u.line===d&&p.line!==d)return-1;if(p.line===d&&u.line!==d)return 1}return Math.abs(u.lineDist-p.lineDist)<=c?u.nodeDist-p.nodeDist:u.lineDist-p.lineDist});let f=l.length>0?l[0].line:void 0;return f&&(t==="horizontal"?this.lastHorizontalLine=f:this.lastVerticalLine=f),f}};function Ys(e,t=Xe,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=ae(i);Object.entries(t).forEach(([a,l])=>{var c;n.push({nodeBox:s,node:r,orientation:l.orientation,position:l.resolve(r,s),color:(c=r.style)==null?void 0:c.backgroundColor,anchorName:a})})}),n}function $s(e,t,o,n,r=Object.keys(Xe)){let i=[];for(let a of r){let l=Xe[a],c=l.resolve(o,n),d=e.search(l.orientation,c,o,t);d&&i.push({anchorName:a,sourcePosition:c,anchor:l,line:d})}let s={horizontal:void 0,vertical:void 0};for(let a of i){let l=s[a.anchor.orientation],c=Math.abs(a.sourcePosition-a.line.position);(!l||c<Math.abs(l.sourcePosition-l.line.position))&&(s[a.anchor.orientation]=a)}return s}function Xs(e,t,o,n,r,i,s,a){var f,u,p,h,m,g,T,x;if(!(o!=null&&o.position))return{snappedX:!1,snappedY:!1};let l=!1,c=!1,d={x:o.position.x,y:o.position.y,x2:o.position.x+((u=(f=e.measured)==null?void 0:f.width)!=null?u:0),y2:o.position.y+((h=(p=e.measured)==null?void 0:p.height)!=null?h:0)};if(s){let E=s.anchor.resolve(e,d)-s.line.position;if(Math.abs(E)<=Xo){if(o.position.y-=E,r!=null&&r.dimensions)if(n){let b=t.internals.positionAbsolute.y+((g=(m=e.measured)==null?void 0:m.height)!=null?g:0);r.dimensions.height=b-s.line.position}else r.dimensions.height=s.line.position-t.internals.positionAbsolute.y;c=!0}}if(a){let E=a.anchor.resolve(e,d)-a.line.position;if(Math.abs(E)<=Xo){if(o.position.x-=E,r!=null&&r.dimensions)if(n){let b=t.internals.positionAbsolute.x+((x=(T=e.measured)==null?void 0:T.width)!=null?x:0);r.dimensions.width=b-a.line.position}else r.dimensions.width=a.line.position-t.internals.positionAbsolute.x;l=!0}}return i&&(l||c)&&(o.position.x-=i.position.x,o.position.y-=i.position.y),{snappedX:l,snappedY:c}}import{jsx as Zp}from"react/jsx-runtime";var qp=new Ko;function ut(){let[e,t]=Ks(void 0),[o,n]=Ks(void 0),{width:r,height:i}=Yp(g=>({width:g.width,height:g.height}),Kp),s=Wp(),a=Xp(qp),{screenToFlowPosition:l,getInternalNode:c,getNodes:d}=Up(),f=$t(()=>{t(void 0),n(void 0)},[]),u=$t(g=>{let T=g!=null?g:d();f();let x=Ys(T,Xe,c);a.current.initialize(x)},[c,f,d]),p=$t(()=>{setTimeout(()=>{u()},100)},[u]);$p(()=>{s&&u(d())},[s,u,d]);let h=$t((g,T)=>{var O,B,z,de,ee;if(!a.current||g.length===0||g.length>2)return g;f();let x,y,E=Object.keys(Xe);g.length===1?g[0].type==="position"?x=g[0]:g[0].type==="dimensions"&&(y=g[0],E=["right","bottom"]):g[0].type==="position"&&g[1].type==="dimensions"&&g[1].dimensions&&(x=g[0],y=g[1],E=["top","left"]);let b=T.find(ze=>ze.id===g[0].id);if(!b)return g;let A=c(b.id);if(!A)throw new Error(`Node with id ${b.id} not found in internal nodes`);let v=c((O=A.parentId)!=null?O:""),C=ae(A);y!=null&&y.dimensions&&(C.x2=C.x+y.dimensions.width,C.y2=C.y+y.dimensions.height);let{x:L,y:w}=l({x:0,y:0}),{x:S,y:M}=l({x:r,y:i}),I={x:L,y:w,x2:S,y2:M},{horizontal:V,vertical:F}=$s(a.current,I,b,C,E),G={id:b.id,type:"position",position:{x:A.internals.positionAbsolute.x,y:A.internals.positionAbsolute.y},dragging:!1};x!=null&&x.position&&G.position&&(v?(G.position.x=x.position.x+((z=(B=v==null?void 0:v.position)==null?void 0:B.x)!=null?z:0),G.position.y=x.position.y+((ee=(de=v==null?void 0:v.position)==null?void 0:de.y)!=null?ee:0)):(G.position.x=x.position.x,G.position.y=x.position.y));let{snappedX:U,snappedY:X}=Xs(b,A,G,x,y,v,V,F);if(U||X){if((y!=null&&y.resizing||x!=null&&x.dragging)&&(U&&n(F==null?void 0:F.line),X&&t(V==null?void 0:V.line)),y&&x)return[G,y];if(x)return[G];if(y)return[y]}return g},[l,c,r,i,t,n,f]),m=$t(()=>Zp(qs,{horizontal:e,vertical:o}),[e,o]);return{rebuildIndex:u,forceRebuildIndex:p,updateHelperLines:h,helperLineHorizontal:e,helperLineVertical:o,HelperLines:m}}import{addEdge as Hf,useReactFlow as Gf}from"@xyflow/react";import{useCallback as da}from"react";import{BaseEdge as vf,EdgeLabelRenderer as Nf,getStraightPath as wf,useInternalNode as Qs,useViewport as Af}from"@xyflow/react";import{Position as Xt}from"@xyflow/react";function Zs(e,t){var y,E,b,A;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,f=i.y+((A=(b=t==null?void 0:t.measured)==null?void 0:b.height)!=null?A:0)/2,u=(d-l)/(2*s)-(f-c)/(2*a),p=(d-l)/(2*s)+(f-c)/(2*a),h=1/(Math.abs(u)+Math.abs(p)||1),m=h*u,g=h*p,T=s*(m+g)+l,x=a*(-m+g)+c;return{x:T,y:x}}function Js(e,t){var c,d,f,u;let{positionAbsolute:o}=e.internals,n=(d=(c=e.measured)==null?void 0:c.width)!=null?d:0,r=(u=(f=e.measured)==null?void 0:f.height)!=null?u:0,i=Math.round(o.x),s=Math.round(o.y),a=Math.round(t.x),l=Math.round(t.y);return a<=i+1?Xt.Left:a>=i+n-1?Xt.Right:l<=s+1?Xt.Top:l>=s+r-1?Xt.Bottom:Xt.Top}function Oe(e,t){let o=Zs(e,t),n=Zs(t,e),r=Js(e,o),i=Js(t,n);return{sx:o.x,sy:o.y,tx:n.x,ty:n.y,sourcePos:r,targetPos:i}}import{Button as jp,Tooltip as ef,TooltipContent as tf,TooltipTrigger as of,useTranslation as nf}from"lecom-ui";import{Settings as rf}from"lucide-react";import{getIncomers as qo,getOutgoers as Zo,useReactFlow as Qp}from"@xyflow/react";import{useReactFlow as Jp}from"@xyflow/react";var He=()=>{let{getNodes:e,setNodes:t,getEdges:o,setEdges:n}=Jp();return{selectElements:s=>{let a=e().map(c=>N(_({},c),{selected:s.includes(c.id)})),l=o().map(c=>N(_({},c),{selected:s.includes(c.id)}));return t(a),n(l),!0},clearSelection:async()=>{let s=e().map(l=>N(_({},l),{selected:!1})),a=o().map(l=>N(_({},l),{selected:!1}));return t(s),n(a),await $r(),!0}}};var Jo=()=>{let{getNode:e,getEdge:t,getNodes:o,getEdges:n}=Qp(),{selectElements:r}=He(),i=g=>{let T=o(),x=n(),y=qo(g,T,x),E=Zo(g,T,x),b=y.some(v=>v.type==="START_EVENT"),A=E.some(v=>v.type==="END_EVENT");return b?"start":A?"end":"between"},s=(g,T,x)=>{var b,A,v,C;if(!g)return;let y={type:g.type,variant:(b=g.data)==null?void 0:b.variant,attribute:(A=g.data)==null?void 0:A.attribute},E={id:g.id,position:i(g),label:(v=g.data)==null?void 0:v.label,node:y};return g.type==="TASK"&&((C=g.data)==null?void 0:C.variant)==="SUBPROCESS"?N(_({},E),{type:"sub_process"}):g.type==="GATEWAY"?N(_({},E),{type:"gateway",variant:a(g,T,x)}):N(_({},E),{type:"activity"})},a=(g,T,x)=>{if(g.type!=="GATEWAY")return;let y=qo(g,T,x),E=!1,b=!1;if(y.forEach(A=>{var v,C;A.type==="TASK"&&(((v=A.data)==null?void 0:v.variant)==="SCRIPT"&&(E=!0),((C=A.data)==null?void 0:C.attribute)==="LOOP"&&(b=!0))}),E&&b)return"script_loop";if(E)return"script";if(b)return"loop"},l=(g,T,x)=>{var v,C,L,w;let y=e(g.source),E=e(g.target);if(!y||!E)return"simple";if(Zo(y,T,x).some(S=>S.type==="END_EVENT"))return"final";if(y.type==="GATEWAY")switch((v=y.data)==null?void 0:v.variant){case"PARALLEL":return"parallel";case"EXCLUSIVE":return"exclusive";case"COMPLEX":return"complex";default:return"simple"}if(y.type==="TASK"){let S=(C=y.data)==null?void 0:C.variant,M=(L=y.data)==null?void 0:L.attribute;if(E.type==="TASK"&&((w=E.data)==null?void 0:w.variant)==="SUBPROCESS")return"to_sub_process";let I=S==="SCRIPT",V=M==="LOOP";return I&&V?"script_loop":I?"script":V?"loop":"simple"}return"simple"},c=(g,T,x)=>{let y=[];function E(A,v,C=0){let L=s(A,T,x);if(L.depth=C,v.push(L),A.type==="TASK"){y.push([...v]),v.pop();return}let w=qo(A,T,x);if(w.length)for(let S of w)E(S,v,C+1);v.pop()}let b=qo(g,T,x);for(let A of b)E(A,[]);return y},d=(g,T,x)=>{let y=[];function E(A,v,C=0){let L=s(A,T,x);if(L.depth=C,v.push(L),A.type==="TASK"){y.push([...v]),v.pop();return}let w=Zo(A,T,x);if(w.length)for(let S of w)E(S,v,C+1);v.pop()}let b=Zo(g,T,x);for(let A of b)E(A,[]);return y},f=(g,T,x)=>{x=x.filter(E=>E.source===g.id);let y=x.map(E=>{var v;let b=e(E.target),A;return b&&(A=s(b,T,x)),{id:E.id,type:"routing",variant:l(E,T,x),label:(v=E.data)==null?void 0:v.label,target:A}});return console.log(y),y},u=g=>{let T=e(g);if(!T)return;let x=o(),y=n(),E=s(T,x,y);return E.sources=c(T,x,y),E.targets=d(T,x,y),E.edgeTargets=f(T,x,y),T.type==="GATEWAY"&&(E.variant=a(T,x,y)),E},p=g=>{let T=t(g);if(!T)return;let x=o(),y=n(),E=l(T,x,y),A={id:T.id,type:"routing",variant:E,gatewayVariant:void 0},v=e(T.source);if(v){let L=s(v,x,y),w=c(v,x,y),S=a(v,x,y);A.source=L,A.sources=w.length?w:[[L]],A.gatewayVariant=S}let C=e(T.target);if(C){let L=s(C,x,y),w=d(C,x,y);A.target=L,A.targets=w.length?w:[[L]]}return A},h=g=>{let T=e(g);if(T)return u(T.id);let x=t(g);if(x)return p(x.id)};return{configureElement:g=>{let T=h(g);if(T)return r([g]),T},getConfigureElement:h,getNodeConfigure:u,getEdgeConfigure:p}};import{jsx as Qo,jsxs as sf}from"react/jsx-runtime";var Kt=({elementId:e,elementType:t="node"})=>{let{t:o}=nf(),{onConfigureElement:n}=D(),{getConfigureElement:r}=Jo();return sf(ef,{children:[Qo(of,{asChild:!0,children:Qo(jp,{variant:"ghost",color:"grey",size:"small",iconButton:!0,onClick:()=>{let s=r(e);s&&(n==null||n(s))},children:Qo(rf,{size:16})})}),Qo(tf,{color:"black",children:o(t==="node"?"editor.toolbar.configure_node":"editor.toolbar.configure_edge")})]})};import{useReactFlow as af}from"@xyflow/react";import{Button as lf,Tooltip as cf,TooltipContent as df,TooltipTrigger as uf,useTranslation as pf}from"lecom-ui";import{TrashIcon as ff}from"lucide-react";import{jsx as jo,jsxs as mf}from"react/jsx-runtime";var en=({elementId:e,elementType:t="node"})=>{let{t:o}=pf(),{deleteElements:n}=af();return mf(cf,{children:[jo(uf,{asChild:!0,children:jo(lf,{variant:"ghost",color:"destructive",size:"small",iconButton:!0,onClick:()=>{n(t==="node"?{nodes:[{id:e}]}:{edges:[{id:e}]})},children:jo(ff,{size:16})})}),jo(df,{color:"black",children:o("editor.toolbar.delete")})]})};import{Button as gf,Tooltip as hf,TooltipContent as yf,TooltipTrigger as xf,useTranslation as Ef}from"lecom-ui";import{MoveUpRightIcon as _f}from"lucide-react";import{useCallback as bf}from"react";import{jsx as tn,jsxs as Tf}from"react/jsx-runtime";var qt=({nodeId:e})=>{let{t}=Ef(),o=bf(n=>{n.stopPropagation();let r=document.querySelector(`[data-id="${e}"]`);if(!r)return;let i=r.querySelector(".react-flow__handle.source");if(!i)return;let s=i.getBoundingClientRect(),a=s.left+s.width/2,l=s.top+s.height/2,c=new MouseEvent("mousedown",{clientX:a,clientY:l,bubbles:!0,cancelable:!0});i.dispatchEvent(c)},[e]);return Tf(hf,{children:[tn(xf,{asChild:!0,children:tn(gf,{variant:"ghost",color:"grey",size:"small",iconButton:!0,onMouseDown:o,children:tn(_f,{size:16})})}),tn(yf,{color:"black",children:t("editor.toolbar.connect_node")})]})};import{jsx as on}from"react/jsx-runtime";var pt=i=>{var s=i,{edgeId:e,edgeType:t,sourceNode:o,targetNode:n}=s,r=Ee(s,["edgeId","edgeType","sourceNode","targetNode"]);var h;let a=(o==null?void 0:o.type)==="START_EVENT",l=(n==null?void 0:n.type)==="END_EVENT",c=(o==null?void 0:o.type)==="GATEWAY"&&(n==null?void 0:n.type)==="GATEWAY",d=(o==null?void 0:o.type)==="TASK"&&(n==null?void 0:n.type)==="GATEWAY",f=!a&&!l&&!c&&!d,u=[{component:on(en,{elementId:e,elementType:"edge"})}],p={SEQUENCE_EDGE:[...f?[{component:on(Kt,{elementId:e,elementType:"edge"})}]:[],...u],MESSAGE_EDGE:[...u],ANNOTATION_EDGE:[...u]};return on("div",N(_({className:"flex items-center gap-1 w-fit px-3 py-2 bg-white rounded-sm shadow-md"},r),{children:(h=p[t])==null?void 0:h.map((m,g)=>on("div",{children:m.component},g))}))};import{jsx as nn,jsxs as Cf}from"react/jsx-runtime";var ft={type:"ANNOTATION_EDGE",reconnectable:!0},js=({id:e,source:t,target:o,selected:n,data:r})=>{let{zoom:i}=Af(),{isMultipleSelection:s}=D(),a=Qs(t),l=Qs(o);if(!a||!l)return null;let{sx:c,sy:d,tx:f,ty:u}=Oe(a,l),[p,h,m]=wf({sourceX:c,sourceY:d,targetX:f,targetY:u}),g=n||(a==null?void 0:a.selected)||(l==null?void 0:l.selected),T=1/i;return Cf("g",{className:P("text-grey-400 hover:text-grey-500",{"text-blue-500 hover:text-blue-600":g}),children:[nn(vf,{id:e,path:p,strokeDasharray:4,className:P("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)})}),nn(Nf,{children:nn("div",{className:"absolute z-[3000] pointer-events-auto flex flex-col items-center gap-1",style:{transform:`translate(-50%, -50%) translate(${h}px, ${m}px)`},children:n&&!s&&nn(pt,{edgeId:e,edgeType:"ANNOTATION_EDGE",style:{transform:`scale(${T})`}})})})]})};import{BaseEdge as Mf,EdgeLabelRenderer as Pf,getSmoothStepPath as Lf,MarkerType as oa,useInternalNode as na,useReactFlow as kf,useViewport as Df}from"@xyflow/react";import{useState as Rf}from"react";import{useEffect as ea,useRef as If,useState as Sf}from"react";import{jsx as ta}from"react/jsx-runtime";var J=({value:e,maxLength:t,style:o,className:n,contentClassName:r,isEditing:i,onChange:s,onBlur:a})=>{let l=If(null),[c,d]=Sf(!1);ea(()=>{d(i!=null?i:!1)},[i]),ea(()=>{if(c&&l.current){l.current.focus();let m=document.createRange();m.selectNodeContents(l.current);let g=window.getSelection();g&&(g.removeAllRanges(),g.addRange(m))}},[c]);let f=m=>{m.stopPropagation(),c||d(!0)},u=m=>{let g=m.currentTarget.innerText.trim(),T=t&&g.length>=t,x=["Backspace","Delete","ArrowLeft","ArrowRight","ArrowUp","ArrowDown","Home","End","Tab","Enter","Escape","Shift"],y=m.ctrlKey||m.metaKey,E=y&&m.key==="a",b=y&&m.key==="c",A=y&&m.key==="x",v=y&&m.key==="v";function C(w){return/\w/.test(w)}if(g.length===0&&!C(m.key)&&!x.includes(m.key)&&!y){m.preventDefault();return}T&&(x.includes(m.key)||E||b||A||v||m.preventDefault())},p=m=>{if(!t)return;m.preventDefault();let g=m.clipboardData.getData("text/plain"),T=m.currentTarget.innerText,x=window.getSelection();if(!x||x.rangeCount===0)return;let y=x.getRangeAt(0);if((T.substring(0,y.startOffset)+g+T.substring(y.endOffset)).length>t){let b=t-(T.length-(y.endOffset-y.startOffset)),A=g.substring(0,Math.max(0,b));A&&(y.deleteContents(),y.insertNode(document.createTextNode(A)),y.setStartAfter(y.endContainer),y.collapse(!0),x.removeAllRanges(),x.addRange(y))}else y.deleteContents(),y.insertNode(document.createTextNode(g)),y.setStartAfter(y.endContainer),y.collapse(!0),x.removeAllRanges(),x.addRange(y)},h=m=>{d(!1);let g=m.currentTarget.innerText.trim();t&&g.length>t&&(g=g.substring(0,t)),m.currentTarget.innerText=g,a==null||a(),g!==e&&(s==null||s(g))};return ta("div",{className:P("flex-1 p-2 self-stretch content-center border border-transparent overflow-hidden text-ellipsis text-sm text-center",n,{"border border-dashed border-grey-400":c}),style:o,onDoubleClick:f,children:ta("div",{ref:l,className:P("outline-none whitespace-pre-wrap overflow-hidden",r,{"nodrag nopan cursor-text":c}),contentEditable:!0,suppressContentEditableWarning:!0,onKeyDown:u,onPaste:p,onBlur:h,children:e})})};import{jsx as rn,jsxs as ra}from"react/jsx-runtime";var le={type:"SEQUENCE_EDGE",reconnectable:!0,markerStart:{type:oa.ArrowClosed},markerEnd:{type:oa.Arrow},data:{label:""}},ia=({id:e,source:t,target:o,data:n,selected:r})=>{let{zoom:i}=Df(),{updateEdgeData:s}=kf(),{isMultipleSelection:a}=D(),[l,c]=Rf(!1),d=na(t),f=na(o);if(!d||!f)return null;let{sx:u,sy:p,tx:h,ty:m,sourcePos:g,targetPos:T}=Oe(d,f),[x,y,E]=Lf({sourceX:u,sourceY:p,targetX:h,targetY:m,sourcePosition:g,targetPosition:T}),b=r||(d==null?void 0:d.selected)||(f==null?void 0:f.selected),A=b?"sequence-edge-marker-highlighted":"sequence-edge-marker",v=l||(n==null?void 0:n.label.trim().length)>0,C=1/i,L=()=>{c(!0)},w=()=>{c(!1)},S=M=>{s(e,{label:M.trim()})};return ra("g",{className:P("text-grey-400 hover:text-grey-500",{"text-blue-500 hover:text-blue-600":b}),onBlur:w,onDoubleClick:L,children:[rn(Mf,{id:e,path:x,markerEnd:`url(#${A})`,className:P("stroke-2 stroke-current transition-colors duration-75",{"stroke-red-500 hover:stroke-red-600":n==null?void 0:n.hasError,"stroke-blue-500 hover:stroke-blue-600 drop-shadow-[0_0_3px_rgba(59,130,246,0.5)]":b&&!(n!=null&&n.hasError)})}),rn(Pf,{children:ra("div",{className:"absolute z-[3000] pointer-events-auto flex flex-col items-center gap-1",style:{transform:`translate(-50%, -50%) translate(${y}px, ${E}px)`},children:[r&&!a&&rn(pt,{edgeId:e,edgeType:"SEQUENCE_EDGE",sourceNode:d,targetNode:f,style:{transform:`scale(${C})`}}),v&&rn(J,{value:n==null?void 0:n.label,className:"min-w-8 max-w-56 bg-white rounded-md px-2 py-1 text-xs",isEditing:l,onChange:S})]})})]})};var Jt=e=>new Map(e.map(t=>[t.id,t])),sn=e=>e.some(t=>t.type==="START_EVENT"),sa=(e,t,o,n)=>{let r=Jt(o),i=r.get(e);if(!i||i.type!=="START_EVENT")return!1;let s=r.get(t);return(s==null?void 0:s.type)==="ANNOTATION"?!1:n.filter(l=>{if(l.source!==e)return!1;let c=r.get(l.target);return(c==null?void 0:c.type)!=="ANNOTATION"}).length>=1},an=(e,t,o)=>{var i;let n=t.find(s=>s.id===e);return!n||n.type!=="GATEWAY"||((i=n.data)==null?void 0:i.variant)!=="EXCLUSIVE"?!1:o.filter(s=>s.source===e).length>=2},aa=(e,t,o)=>{var s,a,l,c;let n=Jt(o),r=n.get(e),i=n.get(t);return(r==null?void 0:r.type)!=="GATEWAY"||(i==null?void 0:i.type)!=="GATEWAY"||((s=r==null?void 0:r.data)==null?void 0:s.variant)==="EXCLUSIVE"&&((a=i==null?void 0:i.data)==null?void 0:a.variant)==="PARALLEL"||((l=r==null?void 0:r.data)==null?void 0:l.variant)==="COMPLEX"&&((c=i==null?void 0:i.data)==null?void 0:c.variant)==="PARALLEL"},ln=(e,t)=>{var n;let o=t.find(r=>r.id===e);return!o||o.type!=="TASK"?!1:((n=o.data)==null?void 0:n.variant)==="SCRIPT"},cn=(e,t)=>{var n;let o=t.find(r=>r.id===e);return!o||o.type!=="TASK"?!1:((n=o.data)==null?void 0:n.attribute)==="LOOP"},dn=(e,t,o)=>{let n=Jt(t),r=n.get(e);return!r||r.type!=="TASK"?!1:o.filter(s=>s.target===e).some(s=>{let a=n.get(s.source);return(a==null?void 0:a.type)==="START_EVENT"})},un=(e,t,o)=>{let n=Jt(t),r=n.get(e);return!r||r.type!=="TASK"?!1:o.filter(s=>s.source===e).some(s=>{let a=n.get(s.target);return(a==null?void 0:a.type)==="END_EVENT"})},pn=(e,t)=>t.filter(n=>n.source===e).length>0,fn=(e,t,o,n)=>{let r=Jt(o),i=r.get(e);if(!i||i.type!=="TASK")return!1;let s=t?r.get(t):null;return(s==null?void 0:s.type)==="ANNOTATION"?!1:n.filter(l=>{if(l.source!==e)return!1;let c=r.get(l.target);return(c==null?void 0:c.type)!=="ANNOTATION"}).length>=2};var Vf=[e=>({isValid:e.sourceNodeId!==e.targetNodeId,reason:"self_connection_not_allowed"}),e=>({isValid:!sa(e.sourceNodeId,e.targetNodeId,e.nodes,e.edges),reason:"start_event_limit_reached"}),e=>({isValid:!an(e.sourceNodeId,e.nodes,e.edges),reason:"gateway_limit_reached"}),e=>({isValid:!fn(e.sourceNodeId,e.targetNodeId,e.nodes,e.edges),reason:"task_limit_reached"}),e=>({isValid:aa(e.sourceNodeId,e.targetNodeId,e.nodes),reason:"gateway_to_gateway_not_allowed"}),e=>({isValid:!(e.sourceNodeType==="START_EVENT"&&e.targetNodeType==="END_EVENT"),reason:"start_to_end_not_allowed"}),e=>({isValid:!(e.sourceNodeType==="GATEWAY"&&e.targetNodeType==="END_EVENT"),reason:"gateway_to_end_not_allowed"}),e=>({isValid:!(e.sourceNodeType==="START_EVENT"&&e.targetNodeType==="GATEWAY"),reason:"start_to_gateway_not_allowed"}),e=>({isValid:!(ln(e.sourceNodeId,e.nodes)&&e.targetNodeType==="END_EVENT"),reason:"script_to_end_not_allowed"}),e=>({isValid:!(cn(e.sourceNodeId,e.nodes)&&e.targetNodeType==="END_EVENT"),reason:"loop_to_end_not_allowed"}),e=>({isValid:!(dn(e.sourceNodeId,e.nodes,e.edges)&&e.targetNodeType==="END_EVENT"),reason:"initial_activity_to_end_not_allowed"}),e=>({isValid:!(un(e.sourceNodeId,e.nodes,e.edges)&&e.targetNodeType!=="ANNOTATION"),reason:"final_activity_cannot_connect"}),e=>({isValid:!(pn(e.sourceNodeId,e.edges)&&e.targetNodeType==="END_EVENT"),reason:"activity_has_outgoing_connections"}),e=>({isValid:({START_EVENT:["TASK","ANNOTATION"],END_EVENT:["ANNOTATION"],TASK:["TASK","END_EVENT","GATEWAY","ANNOTATION"],GATEWAY:["TASK","END_EVENT","ANNOTATION","GATEWAY"],LANE:["ANNOTATION"],ANNOTATION:[],UNSUPPORTED:[]}[e.sourceNodeType]||[]).includes(e.targetNodeType),reason:"connection_type_not_allowed"})],la=e=>{for(let t of Vf){let o=t(e);if(!o.isValid)return o}return{isValid:!0}};var Of=[{sourceTypes:["GATEWAY"],targetTypes:["TASK","GATEWAY"],validate:e=>({shouldDisable:an(e.sourceNodeId,e.nodes,e.edges),reason:"gateway_limit_reached"})},{targetTypes:["START_EVENT"],validate:e=>({shouldDisable:sn(e.nodes),reason:"start_event_already_exists"})},{sourceTypes:["TASK"],targetTypes:["END_EVENT"],validate:e=>({shouldDisable:ln(e.sourceNodeId,e.nodes),reason:"script_to_end_not_allowed"})},{sourceTypes:["TASK"],targetTypes:["END_EVENT"],validate:e=>({shouldDisable:cn(e.sourceNodeId,e.nodes),reason:"loop_to_end_not_allowed"})},{sourceTypes:["TASK"],targetTypes:["END_EVENT"],validate:e=>({shouldDisable:dn(e.sourceNodeId,e.nodes,e.edges),reason:"initial_activity_to_end_not_allowed"})},{sourceTypes:["TASK"],validate:e=>({shouldDisable:un(e.sourceNodeId,e.nodes,e.edges)&&e.targetNodeType!=="ANNOTATION",reason:"final_activity_cannot_connect"})},{targetTypes:["END_EVENT"],validate:e=>({shouldDisable:pn(e.sourceNodeId,e.edges),reason:"activity_has_outgoing_connections"})},{sourceTypes:["TASK"],validate:e=>({shouldDisable:fn(e.sourceNodeId,null,e.nodes,e.edges)&&e.targetNodeType!=="ANNOTATION",reason:"task_limit_reached"})}],ca=e=>{let t=Of.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}};var ua=({setEdges:e})=>{let{getNode:t,getEdges:o,getNodes:n}=Gf(),r=da(s=>{let a=t(s.source),l=t(s.target);if(!a||!l)return!1;let c={sourceNodeId:a.id,targetNodeId:l.id,sourceNodeType:a.type,targetNodeType:l.type,nodes:n(),edges:o()};return la(c).isValid},[t,o,n]),i=da(s=>{e(a=>{let l=t(s.target),c=(l==null?void 0:l.type)==="ANNOTATION"?ft:le;return Hf(_(_({},s),c),a)})},[t,e]);return{isValidConnection:r,onConnect:i}};import{useState as _a}from"react";import{useTranslation as Bf}from"lecom-ui";import{useReactFlow as zf}from"@xyflow/react";var Qt=(e=[])=>e.filter(t=>t.type==="START_EVENT"),Ke=(e=[])=>e.filter(t=>t.type==="END_EVENT"),Ge=(e=[])=>e.filter(t=>t.type==="TASK")||[],pa=(e=[])=>e.filter(t=>{var o;return t.type==="TASK"&&((o=t.properties)==null?void 0:o.variant)==="SCRIPT"}),fa=(e=[])=>e.filter(t=>{var o;return t.type==="TASK"&&((o=t.properties)==null?void 0:o.variant)==="SUBPROCESS"}),mn=(e=[])=>e.filter(t=>t.type==="GATEWAY"),ma=(e=[])=>e.filter(t=>{var o;return t.type==="GATEWAY"&&((o=t.properties)==null?void 0:o.variant)==="EXCLUSIVE"}),ce=(e,t=[])=>t.filter(o=>o.source===e),jt=(e,t=[])=>t.filter(o=>o.target===e),ga=(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"},ha=(e,t)=>{let o=ce(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},ya=e=>e?/\w/g.test(e.trim()):!1,H=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:[]}},be=(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)}},xa=(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 eo=[{id:"start_event_not_found",validate:e=>{let t=Qt(e.nodes);return H({isValid:t.length>=1})}},{id:"end_event_not_found",validate:e=>{let t=Ke(e.nodes);return H({isValid:t.length>=1})}},{id:"multiple_start_event_not_allowed",validate:e=>{let t=Qt(e.nodes),o=t.length===1;if(t.length===0)return H({isValid:!0});if(!o)return H({isValid:!1,nodeIds:t.map(i=>i.id)});let n=ce(t[0].id,e.edges);if(!(n.length<=1)){let i=[...t.map(s=>s.id),...n.map(s=>s.target)];return H({isValid:!1,nodeIds:[...new Set(i)]})}return H({isValid:!0})}},{id:"task_flows_limit_exceeds",validate:e=>{let t=Ge(e.nodes),o=be(t,n=>ce(n.id,e.edges).length<=2);return H({isValid:o.isValid,nodeIds:o.invalidIds})}},{id:"task_label_empty",highlightRelatedEdges:!1,validate:e=>{let t=Ge(e.nodes),o=be(t,n=>!!n.label&&n.label.trim()!=="");return H({isValid:o.isValid,nodeIds:o.invalidIds})}},{id:"task_label_length",highlightRelatedEdges:!1,validate:e=>{let o=Ge(e.nodes),n=be(o,r=>!r.label||r.label.length<=60);return H({isValid:n.isValid,nodeIds:n.invalidIds})}},{id:"duplicate_task_name",highlightRelatedEdges:!1,validate:e=>{let t=Ge(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 H({isValid:n.length===0,nodeIds:n})}},{id:"nested_gateway",validate:e=>{let t=mn(e.nodes),o=[],n=[];for(let r of t){let i=ce(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 H({isValid:o.length===0,nodeIds:o.length>0?[...new Set(o)]:[],edgeIds:n})}},{id:"events_nested",validate:e=>{let t=[...Qt(e.nodes),...Ke(e.nodes)],o=[],n=[];for(let r of t){let i=ce(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 H({isValid:o.length===0,nodeIds:o.length>0?[...new Set(o)]:[],edgeIds:n})}},{id:"flows_on_end_tasks_not_allowed",validate:e=>{let t=Ke(e.nodes),o=[],n=[];for(let r of t){let i=jt(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=ce(a.id,e.edges);l.length>1&&(o.push(a.id),l.forEach(c=>n.push(c.id)))}}}return H({isValid:o.length===0,nodeIds:o,edgeIds:n})}},{id:"conditions_flows_limit_exceeds",validate:e=>{let t=ma(e.nodes),o=be(t,r=>ce(r.id,e.edges).length<=2),n=o.invalidIds.flatMap(r=>ce(r,e.edges).map(i=>i.id));return H({isValid:o.isValid,nodeIds:o.invalidIds,edgeIds:n})}},{id:"activity_name_invalid",validate:e=>{let t=Ge(e.nodes),o=be(t,n=>!n.label||ya(n.label));return H({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 H({isValid:!0});let t=Ke(e.nodes)[0];if(!t)return H({isValid:!0});let o=jt(t.id,e.edges);if(!o.length)return H({isValid:!0});let r=Ge(e.nodes).filter(l=>o.some(c=>c.source===l.id)),i=be(r,l=>!ga(l.id,e));return H({isValid:i.isValid,nodeIds:i.isValid?[]:[t.id,...i.invalidIds]})}},{id:"concurrent_initial_and_final_event",validate:e=>{let t=Ge(e.nodes),o=Ke(e.nodes)[0];if(!o)return H({isValid:!0});let n=t.filter(l=>{let c=jt(l.id,e.edges),d=ce(l.id,e.edges),f=c.some(p=>{var h;return((h=e.nodes.find(m=>m.id===p.source))==null?void 0:h.type)==="START_EVENT"}),u=d.some(p=>{var h;return((h=e.nodes.find(m=>m.id===p.target))==null?void 0:h.type)==="END_EVENT"});return f&&u}),r=jt(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 H(a)}},{id:"gateway_flow_to_event",validate:e=>{let t=mn(e.nodes),o=[],n=[];for(let r of t){let i=ce(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 H({isValid:o.length===0,nodeIds:o.length>0?[...new Set(o)]:[],edgeIds:n})}},{id:"gateway_missing_output_streams",validate:e=>{let t=mn(e.nodes),o=be(t,n=>ce(n.id,e.edges).length>=1);return H({isValid:o.isValid,nodeIds:o.invalidIds})}},{id:"event_to_condition",validate:e=>{let t=[...Qt(e.nodes),...Ke(e.nodes)],o=[],n=[];for(let r of t){let i=ce(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 H({isValid:o.length===0,nodeIds:o.length>0?[...new Set(o)]:[],edgeIds:n})}},{id:"script_in_final_activity",validate:e=>{let t=pa(e.nodes),o=be(t,n=>!ha(n.id,e));return H({isValid:o.isValid,nodeIds:o.invalidIds})}},{id:"subprocess_referenced_not_configured",validate:e=>{let t=fa(e.nodes),o=be(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 H({isValid:o.isValid,nodeIds:o.invalidIds})}}];var Ea=e=>{e=e||{nodes:[],edges:[]},e.nodes=e.nodes||[],e.edges=e.edges||[];let t=[];for(let n of eo){let r=n.validate(e);r.isValid||t.push({id:n.id,message:n.id,nodeIds:r.nodeIds||[],edgeIds:r.edgeIds||[]})}return{isValid:t.length===0,errors:t}};var ba=()=>{let{t:e}=Bf(),[t,o]=_a(null),{setNodes:n,setEdges:r,getNodes:i,getEdges:s}=zf(),[a,l]=_a(!1);return{validationResult:t,validateDiagram:u=>{let p=xa(u.nodes,u.edges),h=Ea(p),m=h.errors.map(g=>N(_({},g),{message:e(`validation.errors.${g.id}`)}));return a||l(!0),{isValid:h.isValid,errors:m}},handleValidationComplete:u=>{if(o(u),!u)return;let p=[],h=[];u.errors.forEach(v=>{v.nodeIds&&v.nodeIds.length>0&&v.nodeIds.forEach(C=>p.push(C)),v.edgeIds&&v.edgeIds.length>0&&v.edgeIds.forEach(C=>h.push(C))});let m=[...new Set(p)];n(v=>v.map(C=>N(_({},C),{data:N(_({},C.data),{hasError:!1})}))),r(v=>v.map(C=>N(_({},C),{data:N(_({},C.data),{hasError:!1})})));let g=i(),T=s(),x=new Set(m),y=new Set;u.errors.forEach(v=>{var w,S;let C=eo.find(M=>M.id===v.id);(C==null?void 0:C.highlightRelatedEdges)!==!1&&((w=v.edgeIds)==null||w.forEach(M=>y.add(M)),(S=v.nodeIds)==null||S.forEach(M=>{T.forEach(I=>{(I.source===M||I.target===M)&&y.add(I.id)})}))});let E=new Set,b=new Set,A=new Set;g.forEach(v=>{v.type==="START_EVENT"?E.add(v.id):v.type==="END_EVENT"&&b.add(v.id)}),T.forEach(v=>{E.has(v.source)&&A.add(v.target),b.has(v.target)&&A.add(v.source)}),A.forEach(v=>{var C,L;if(x.has(v)){let w=(C=u.errors.find(M=>{var I;return(I=M.nodeIds)==null?void 0:I.includes(v)}))==null?void 0:C.id;((L=eo.find(M=>M.id===w))==null?void 0:L.highlightRelatedEdges)!==!1&&T.forEach(M=>{M.source===v&&b.has(M.target)&&(x.add(M.target),y.add(M.id)),M.target===v&&E.has(M.source)&&(x.add(M.source),y.add(M.id))})}}),x.size>0&&n(v=>v.map(C=>N(_({},C),{data:N(_({},C.data),{hasError:x.has(C.id)})}))),y.size>0&&r(v=>v.map(C=>N(_({},C),{data:N(_({},C.data),{hasError:y.has(C.id)})})))},clearValidation:()=>{o(null),l(!1),n(u=>u.map(p=>N(_({},p),{data:N(_({},p.data),{hasError:!1})}))),r(u=>u.map(p=>N(_({},p),{data:N(_({},p.data),{hasError:!1})})))},isAutoValidationEnabled:a}};import{useReactFlow as Ff}from"@xyflow/react";import{useTranslation as Wf}from"lecom-ui";import{useEffect as Uf}from"react";import{v7 as Ta}from"uuid";var gn=(e,t)=>{let n=e.filter(i=>i.type==="TASK").map(i=>{var a;let s=(a=i.data)==null?void 0:a.label;if(s&&s.startsWith(`${t} `)){let l=s.match(new RegExp(`^${t} (\\d+)$`));return l?parseInt(l[1],10):0}return 0}).filter(i=>i>0),r=n.length>0?Math.max(...n)+1:1;return`${t} ${r}`},mt=(e,t)=>{let n=t.filter(a=>a.type==="TASK").map(a=>{var l;return(l=a.data)==null?void 0:l.label}).filter(Boolean);if(!n.includes(e))return e;let r=e.replace(/\s+\(\d+\)$/,""),i=n.filter(a=>a===r||a.startsWith(`${r} (`)).map(a=>{if(a===r)return 1;let l=a.match(/\s+\((\d+)\)$/);return l?parseInt(l[1],10):0}).filter(a=>a>0),s=2;for(;i.includes(s);)s++;return`${r} (${s})`};var Yf=15,va="bpmn:selection",$f=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},Na=e=>{if(!$f(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},wa=({offset:e=Yf}={})=>{let{getNodes:t,setNodes:o,getEdges:n,setEdges:r}=Ff(),{t:i}=Wf();Uf(()=>{let s=l=>{var m,g;if(!Na(l))return;let c=t(),d=n(),f=c.filter(T=>T.selected);if(!f.length)return;l.preventDefault(),l.stopPropagation();let u=d.filter(T=>f.some(x=>x.id===T.source)&&f.some(x=>x.id===T.target)),h=JSON.stringify({nodes:f,edges:u});(m=l.clipboardData)==null||m.setData(va,h),(g=l.clipboardData)==null||g.setData("text/plain",`BPMN Selection: ${f.length} nodes`)},a=l=>{var y,E;if(!Na(l))return;let c=(y=l.clipboardData)==null?void 0:y.getData(va);if(!c)return;l.preventDefault(),l.stopPropagation();let d;try{d=JSON.parse(c)}catch(b){return}if(!((E=d.nodes)!=null&&E.length))return;let f=new Map,u=t(),p=[],h=u.some(b=>b.type==="START_EVENT"),m=d.nodes.filter(b=>b.type==="START_EVENT"),g=d.nodes;if(h&&m.length>0&&(g=d.nodes.filter(b=>b.type!=="START_EVENT"),g.length===0))return;let T=g.map(b=>{var C;let A=Ta();f.set(b.id,A);let v=N(_({},b),{id:A,selected:!0,position:{x:b.position.x+e,y:b.position.y+e}});if(b.type==="TASK"){let L=(C=b.data)==null?void 0:C.label,w=mt(L||i("bpmn.task.label.prefix"),[...u,...p]);v.data=N(_({},b.data),{label:w})}return p.push(v),v}),x=d.edges.map(b=>N(_({},b),{id:Ta(),selected:!0,source:f.get(b.source)||b.source,target:f.get(b.target)||b.target}));o(b=>[...b.map(A=>N(_({},A),{selected:!1})),...T]),r(b=>[...b.map(A=>N(_({},A),{selected:!1})),...x])};return document.addEventListener("copy",s,!0),document.addEventListener("paste",a,!0),()=>{document.removeEventListener("copy",s,!0),document.removeEventListener("paste",a,!0)}},[t,o,n,r,e,i])};import{useReactFlow as fm,useStoreApi as mm}from"@xyflow/react";import{useTranslation as gm}from"lecom-ui";import{useState as hm}from"react";import{v7 as Ha}from"uuid";var Xf={MIN_WIDTH:36,MIN_HEIGHT:36},Kf={MIN_WIDTH:36,MIN_HEIGHT:36},qf={MIN_WIDTH:56,MIN_HEIGHT:56},hn={MIN_WIDTH:176,MIN_HEIGHT:96},yn={HEADER_WIDTH:40,MIN_WIDTH:840,MIN_HEIGHT:256},W={HEADER_WIDTH:40,MIN_WIDTH:800,MIN_HEIGHT:256},xn={MIN_WIDTH:176,MIN_HEIGHT:64},Zf={MIN_WIDTH:128,MIN_HEIGHT:64},R={START_EVENT:Xf,END_EVENT:Kf,GATEWAY:qf,TASK:hn,LANE:W,ANNOTATION:xn,UNSUPPORTED:Zf};import Ia from"@dagrejs/dagre";import{getNodesBounds as em}from"@xyflow/react";import{orderBy as tm}from"lodash";import{orderBy as Jf}from"lodash";var Ce=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}},Ie=e=>Jf(e,[o=>{let n=o.type==="LANE";return n&&!o.parentId?0:n?1:2}],["asc"]),Aa=(e,t)=>{let{x:o,y:n}=Ce(e),{x:r,y:i}=Ce(t);return{x:o-r,y:n-i}};var gt=({parentId:e,nodes:t,includeTypes:o=[...Object.values(k)],excludeTypes:n=[]})=>t.some(r=>r.parentId===e&&(!o.length||o.includes(r.type))&&!n.includes(r.type)),Qf=(e,t)=>{let{x:o,y:n}=Ce(e),{x:r,y:i}=Ce(t),s=o-r,a=n-i;return Math.sqrt(s*s+a*a)},jf=(e,t)=>{let{x:o,y:n,w:r,h:i}=Ce(e),{x:s,y:a,w:l,h:c}=Ce(t);return o<s+l&&s<o+r&&n<a+c&&a<n+i},to=(e,t)=>{let o=null,n=1/0;for(let r of t)if(r.id!==e.id&&jf(e,r)){let i=Qf(e,r);i<n&&(n=i,o=r)}return o},Ca=(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 Sa=(e=[],t=[],o="LR")=>{let n=new Ia.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)),Ia.layout(n),{nodes:e.map(i=>{let s=n.node(i.id);return N(_({},i),{position:{x:s.x-i.width/2,y:s.y-i.height/2}})}),edges:t}},oo=e=>{let t=e.filter(n=>n.type==="LANE"&&!n.parentId),o=[...e];return t.forEach(n=>{o=qe(n.id,o)}),o},qe=(e,t)=>{var p,h;let o=[...t],n=o.find(m=>m.id===e);if(!n)return o;let r=o.filter(m=>m.parentId===e&&m.type==="LANE");if(r.length===0)return o;let i=tm(r,["position.y"]),s=Math.max((h=(p=n.measured)==null?void 0:p.width)!=null?h:0,yn.MIN_WIDTH),a=Ca(e,i)||W.MIN_WIDTH,l=Math.max(s,a),c=s-W.HEADER_WIDTH>=a,d=0,f=0;i.forEach(m=>{var g,T,x,y;o=o.map(E=>E.id===m.id?N(_({},E),{width:c?l-W.HEADER_WIDTH:l,measured:N(_({},E.measured),{width:c?l-W.HEADER_WIDTH:l}),position:{x:W.HEADER_WIDTH,y:d}}):E),d+=(T=(g=m.measured)==null?void 0:g.height)!=null?T:0,f+=(y=(x=m.measured)==null?void 0:x.height)!=null?y:0}),o=o.map(m=>m.id===e?N(_({},m),{height:f,width:c?l:l+W.HEADER_WIDTH,measured:N(_({},m.measured),{height:f,width:c?l:l+W.HEADER_WIDTH})}):m);let u=o.find(m=>m.id===e);return u!=null&&u.parentId&&(o=qe(u.parentId,o)),o},Ma=(e,t,o)=>{if(e.type==="LANE")return o;let n=ae(t),r=ae(e);return r.y<n.y&&(e.position.y=0),r.x<n.x+W.HEADER_WIDTH&&(e.position.x=W.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?N(_({},i),{height:t.height,width:t.width,measured:t.measured}):i.id===e.id?N(_({},i),{position:e.position}):i),o},Pa=()=>{let e=document.querySelector(".react-flow__viewport");return e||(console.error("Flow element (.react-flow__viewport) not found."),null)},om=50,La=(e,t=om)=>{let o=em(e);return{x:o.x-t,y:o.y-t,width:o.width+t*2,height:o.height+t*2}};import{create as nm}from"zustand";var ht=nm(e=>({draggableNode:null,setDraggableNode:t=>{e({draggableNode:t})}}));import{BaseEdge as rm,EdgeLabelRenderer as im,getSmoothStepPath as sm,MarkerType as am,useInternalNode as ka,useReactFlow as lm,useViewport as cm}from"@xyflow/react";import{useState as dm}from"react";import{jsx as En,jsxs as Da}from"react/jsx-runtime";var Kw={type:"MESSAGE_EDGE",markerEnd:{type:am.Arrow},data:{label:""}},Ra=({id:e,source:t,target:o,data:n,selected:r})=>{let{zoom:i}=cm(),{updateEdgeData:s}=lm(),{isMultipleSelection:a}=D(),[l,c]=dm(!1),d=ka(t),f=ka(o);if(!d||!f)return null;let{sx:u,sy:p,tx:h,ty:m,sourcePos:g,targetPos:T}=Oe(d,f),[x,y,E]=sm({sourceX:u,sourceY:p,targetX:h,targetY:m,sourcePosition:g,targetPosition:T}),b=r||(d==null?void 0:d.selected)||(f==null?void 0:f.selected),A=b?"sequence-edge-marker-highlighted":"sequence-edge-marker",v=l||(n==null?void 0:n.label.trim().length)>0,C=1/i,L=()=>{c(!0)},w=()=>{c(!1)},S=M=>{s(e,{label:M.trim()})};return Da("g",{className:P("text-grey-400 hover:text-grey-500",{"text-blue-500 hover:text-blue-600":b}),onBlur:w,onDoubleClick:L,children:[En(rm,{id:e,path:x,markerEnd:`url(#${A})`,strokeDasharray:4,className:P("stroke-2 stroke-current transition-colors duration-75",{"stroke-red-500 hover:stroke-red-600":n==null?void 0:n.hasError,"stroke-blue-500 hover:stroke-blue-600 drop-shadow-[0_0_3px_rgba(59,130,246,0.5)]":b&&!(n!=null&&n.hasError)})}),En(im,{children:Da("div",{className:"absolute z-[3000] pointer-events-auto flex flex-col items-center gap-1",style:{transform:`translate(-50%, -50%) translate(${y}px, ${E}px)`},children:[r&&!a&&En(pt,{edgeId:e,edgeType:"MESSAGE_EDGE",style:{transform:`scale(${C})`}}),v&&En(J,{value:n==null?void 0:n.label,className:"min-w-8 max-w-56 bg-white rounded-md px-2 py-1 text-xs",isEditing:l,onChange:S})]})})]})};import{getBezierPath as um}from"@xyflow/react";import{jsx as Va,jsxs as pm}from"react/jsx-runtime";var Oa=({toX:e,toY:t,fromPosition:o,toPosition:n,fromNode:r})=>{if(!r)return null;let i={id:"connection-target",measured:{width:1,height:1},internals:{positionAbsolute:{x:e,y:t}}},{sx:s,sy:a,tx:l,ty:c,sourcePos:d,targetPos:f}=Oe(r,i),[u]=um({sourceX:s,sourceY:a,sourcePosition:d||o,targetPosition:f||n,targetX:l||e,targetY:c||t});return pm("g",{children:[Va("path",{fill:"none",className:"stroke-2 stroke-grey-400 animated",d:u}),Va("circle",{cx:l||e,cy:c||t,fill:"none",r:4,className:"stroke-2 stroke-grey-500"})]})};var Ga=({nodes:e,setNodes:t,setEdges:o})=>{let n=mm(),{getInternalNode:r,screenToFlowPosition:i}=fm(),{draggableNode:s,setDraggableNode:a}=ht(),{setIsDragging:l}=D(),{rebuildIndex:c,forceRebuildIndex:d}=ut(),{t:f}=gm(),[u,p]=hm(null),h=(w,S=!1)=>{let M=S?"[&>div]:bg-red-50 [&>div]:outline [&>div]:outline-[3px] [&>div]:outline-red-500":"[&>div]:bg-green-50/75 [&>div]:outline [&>div]:outline-[3px] [&>div]:outline-green-500";t(I=>I.map(V=>N(_({},V),{className:V.id===w?M:""})))},m=()=>{let{nodeLookup:w}=n.getState();return Array.from(w.values())},g=w=>{let S=r(w.id),M=m();if(w.type==="LANE"){if(gt({parentId:w.id,nodes:e,includeTypes:["LANE"]})){h();return}let X=M.filter(z=>z.id!==w.id&&z.type==="LANE"&&!z.parentId),O=to(S,X);if(!O){h();return}if(gt({parentId:O.id,nodes:e,excludeTypes:["LANE"]})){h(O.id,!0);return}h(O.id);return}let V=M.filter(U=>U.id!==w.id&&U.type==="LANE"),F=to(S,V);if(!F){h();return}if(gt({parentId:F.id,nodes:e,includeTypes:["LANE"]})){h();return}h(F.id)},T=w=>w.map(S=>N(_({},S),{className:void 0})),x=w=>w.some(M=>M.dragging)?w.map(M=>M.dragging?N(_({},M),{dragging:!1}):M):w,y=w=>{w.preventDefault(),w.dataTransfer.dropEffect="move"},E=(w,S)=>{w.preventDefault(),g(S)},b=(w,S,M)=>{var U,X;let I=[...M];if(w.parentId===S.id)return I=Ma(w,S,I),I=oo(I),T(I);if(w.type==="LANE"){if(gt({parentId:S.id,nodes:I,excludeTypes:["LANE"]})){let ee=ae(S),ze=50,tt=50;return I.map(ve=>{var It,ao;return ve.id===w.id?N(_({},ve),{position:{x:(It=u==null?void 0:u.x)!=null?It:ee.x+ze,y:(ao=u==null?void 0:u.y)!=null?ao:ee.y2+tt}}):ve})}let z=I.filter(ee=>ee.parentId===S.id).reduce((ee,ze)=>{var tt,ve;return ee+((ve=(tt=ze.measured)==null?void 0:tt.height)!=null?ve:0)},0),de={x:W.HEADER_WIDTH,y:z};return I=I.map(ee=>ee.id===w.id?N(_({},ee),{parentId:S.id,position:de,className:void 0}):N(_({},ee),{className:void 0})),I=qe(S.id,I),I}if(gt({parentId:S.id,nodes:I,includeTypes:["LANE"]})){let O;if(w.parentId){let B=r(w.parentId),{x:z,y:de}=Ce(B);O={x:z+((U=w.position.x)!=null?U:0),y:de+((X=w.position.y)!=null?X:0)}}return I=I.map(B=>B.id===w.id?N(_({},B),{position:O!=null?O:B.position,parentId:void 0,className:void 0}):N(_({},B),{className:void 0})),I}let G=Aa(w,S);return I=I.map(O=>{if(O.id===w.id){let B=ae(w),z=ae(S);return B.y<z.y&&(G.y=0),B.x<z.x+W.HEADER_WIDTH&&(G.x=W.HEADER_WIDTH),N(_({},O),{parentId:S.id,position:G,className:void 0})}return N(_({},O),{className:void 0})}),I=oo(I),I},A=w=>{if(w.preventDefault(),!(s!=null&&s.type))return;let S=i({x:w.clientX,y:w.clientY}),M={width:R[s.type].MIN_WIDTH,height:R[s.type].MIN_HEIGHT},I={id:Ha(),type:s.type,position:S,measured:M,data:{label:s.type==="TASK"?gn(e,f("bpmn.task.label.prefix")):"",variant:s.variant,attribute:s.attribute},selected:!0},V=N(_({},I),{internals:{positionAbsolute:S}}),F=m(),G=s.type==="LANE",U=F.filter(z=>G?z.type==="LANE"&&!z.parentId:z.type==="LANE"),X=to(V,U),O=[...e.map(z=>N(_({},z),{selected:!1})),I];X&&(O=b(V,X,O)),O=Ie(O),t(O),d();let B=w.dataTransfer.getData("sourceId");if(B){let z={id:Ha(),source:B,target:I.id};if(s.type==="ANNOTATION"){o(de=>de.concat(_(_({},z),ft)));return}o(de=>de.concat(_(_({},z),le)))}l(!1),a(null)},v=async(w,S,M)=>{let I=[...e];M.forEach(V=>{let F=m(),G=r(V.id),U=V.type==="LANE",X=F.filter(B=>B.id!==V.id&&(U?B.type==="LANE"&&!B.parentId:B.type==="LANE")),O=to(G,X);if(O){I=b(G,O,I);return}V.parentId&&(I=L(V,I))}),I=x(I),I=Ie(I),I=T(I),t(I),c(I),p(null)},C=(w,S)=>{p({x:S.position.x,y:S.position.y})},L=(w,S)=>{var G,U;let M=r(w.parentId),{x:I,y:V}=Ce(M),F={x:I+((G=w.position.x)!=null?G:0),y:V+((U=w.position.y)!=null?U:0)};return S=S.map(X=>X.id===w.id?N(_({},X),{position:F,parentId:void 0}):X),S=qe(w.parentId,S),S};return{onDragOver:y,onDrop:A,onNodeDrag:E,onNodeDragStart:C,onNodeDragStop:v}};import{useReactFlow as ym}from"@xyflow/react";import{useTranslation as xm}from"lecom-ui";import{useEffect as Em}from"react";import{v7 as Ba}from"uuid";var _m=30,bm=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},Tm=e=>!bm(e.target),za=({offset:e=_m}={})=>{let{getNodes:t,setNodes:o,getEdges:n,setEdges:r}=ym(),{t:i}=xm();Em(()=>{let s=a=>{if(a.ctrlKey&&a.key.toLowerCase()==="d"&&Tm(a)){a.preventDefault(),a.stopPropagation();let l=t(),c=n(),d=l.filter(y=>y.selected);if(!d.length)return;let f=new Map,u=[],p=l.some(y=>y.type==="START_EVENT"),h=d.filter(y=>y.type==="START_EVENT"),m=d;if(p&&h.length>0&&(m=d.filter(y=>y.type!=="START_EVENT"),m.length===0))return;let g=c.filter(y=>m.some(E=>E.id===y.source)&&m.some(E=>E.id===y.target)),T=m.map(y=>{var A;let E=Ba();f.set(y.id,E);let b=N(_({},y),{id:E,selected:!0,position:{x:y.position.x+e,y:y.position.y+e}});if(y.type==="TASK"){let v=(A=y.data)==null?void 0:A.label,C=mt(v||i("bpmn.task.label.prefix"),[...l,...u]);b.data=N(_({},y.data),{label:C})}return u.push(b),b}),x=g.map(y=>N(_({},y),{id:Ba(),selected:!0,source:f.get(y.source)||y.source,target:f.get(y.target)||y.target}));o(y=>[...y.map(E=>N(_({},E),{selected:!1})),...T]),r(y=>[...y.map(E=>N(_({},E),{selected:!1})),...x])}};return document.addEventListener("keydown",s,!0),()=>{document.removeEventListener("keydown",s,!0)}},[t,o,n,r,e,i])};import{useReactFlow as Mg}from"@xyflow/react";import{v7 as vn}from"uuid";var Wa={"start-event":"START_EVENT","end-event":"END_EVENT",task:"TASK","gateway-exclusive":"GATEWAY"},Ua={"start-event":"","end-event":"",task:"","gateway-exclusive":"EXCLUSIVE"},Fa=(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}},vm=e=>{e=e||"";let t=e.trim().split(`
2
+ `),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=Fa(i[0],o),a=Fa(i[1],o);s&&a&&n.push({sourceId:s.step,targetId:a.step,label:s.edgeLabel||a.edgeLabel||""})}),{components:o,connections:n}},Ya=e=>{let{components:t,connections:o}=vm(e);return{nodes:t,edges:o}};import{Position as jm,useConnection as eg,useReactFlow as tg}from"@xyflow/react";import{Handle as $a,useReactFlow as Nm}from"@xyflow/react";import{jsx as Xa}from"react/jsx-runtime";var Z=i=>{var s=i,{type:e,position:t,className:o,nodeType:n}=s,r=Ee(s,["type","position","className","nodeType"]);let a=n==="TASK";return Xa($a,_({type:e,position:t,className:P("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))},_n=a=>{var l=a,{nodeId:e,nodeType:t,gatewayVariant:o,type:n,position:r,className:i}=l,s=Ee(l,["nodeId","nodeType","gatewayVariant","type","position","className"]);let{getEdges:c}=Nm(),f=(()=>{if(n!=="source")return!1;let u=c();return t==="TASK"?u.filter(h=>h.source===e).length>=2:t==="GATEWAY"&&o==="EXCLUSIVE"?u.filter(h=>h.source===e).length>=2:!1})();return Xa($a,_({type:n,position:r,className:P("size-2.5 border border-grey-400 bg-white transition-all duration-200 relative",{"before:content-[''] before:absolute before:inset-[-16px] before:bg-transparent":t==="TASK","before:content-[''] before:absolute before:inset-[-4px] before:bg-transparent":t!=="TASK","opacity-50 cursor-not-allowed pointer-events-none":f,"hover:border-grey-500":!f},i),style:{pointerEvents:f?"none":"auto"}},s))};import{NodeResizer as wm,useReactFlow as Am}from"@xyflow/react";import{orderBy as Cm}from"lodash";import{jsx as Im}from"react/jsx-runtime";var yt=n=>{var r=n,{nodeId:e,isVisible:t}=r,o=Ee(r,["nodeId","isVisible"]);let{getNode:i,getNodes:s,setNodes:a}=Am(),{isMultipleSelection:l}=D(),c=({width:f,height:u})=>{if(!e)return;let p=i(e);if((p==null?void 0:p.type)!=="LANE")return;let h=[...s()],m=!p.parentId,g=m?p.id:p.parentId,T=h.filter(E=>E.type==="LANE"&&E.parentId===g);if(!T.length)return;let x=Cm(T,["position.y"]),y=0;x.forEach((E,b)=>{var C,L;let A=b===x.length-1,v=(L=(C=E.measured)==null?void 0:C.height)!=null?L:0;h=h.map(w=>{if(w.id===E.id){let S=m?f-W.HEADER_WIDTH:f,M=N(_({},w),{width:S,measured:N(_({},w.measured),{width:S}),position:N(_({},w.position),{y})});return A&&m&&(M.height=u-y),M}return w}),y+=v}),h=h.map(E=>{if(E.id===g){let b=m?f:f+W.HEADER_WIDTH;return N(_({},E),{width:b,height:m?u:y,measured:{width:b,height:m?u:y}})}return E}),a(h)};return Im(wm,_({nodeId:e,handleClassName:"size-1.5 bg-blue-400",lineClassName:"border-blue-400/90 border-dashed",isVisible:!l&&t,onResizeEnd:(f,u)=>c(u)},o))};import{NodeToolbar as Ym,useReactFlow as $m}from"@xyflow/react";import{Button as Xm,Tooltip as Km,TooltipContent as qm,TooltipTrigger as Zm,useTranslation as Jm}from"lecom-ui";import{useRef as Qa,useState as Qm}from"react";import{useEffect as Sm,useState as Mm}from"react";var Ka=(e,t=!1)=>{let[o,n]=Mm({width:0,height:0});return Sm(()=>{if(e.current&&t){let r=e.current.getBoundingClientRect();n({width:r.width,height:r.height})}},[t,e]),{dimensions:o}};import{Position as no,useReactFlow as Pm}from"@xyflow/react";import{useMemo as Lm}from"react";var km=120,Dm=12,qa=(e,t=!1,o)=>{let{getNode:n,getViewport:r}=Pm(),{instanceId:i}=D();return Lm(()=>{var p,h;if(!t)return{position:no.Right,align:"start"};let s=n(e);if(!s)return{position:no.Right,align:"start"};let a=r(),l=s.position.x*a.zoom+a.x,c=(((p=s.measured)==null?void 0:p.width)||s.width||100)*a.zoom,d=(h=document.getElementById(`modeler-${i}`))==null?void 0:h.clientWidth;if(!d)return{position:no.Right,align:"start"};let f=(o==null?void 0:o.width)||km;return{position:l+c+f+Dm>d?no.Left:no.Right}},[i,e,t,o,n,r])};import{useNodesData as Rm,useReactFlow as Vm}from"@xyflow/react";import{Button as Za,DropdownMenu as Om,DropdownMenuContent as Hm,DropdownMenuGroup as Gm,DropdownMenuItem as Bm,DropdownMenuLabel as zm,DropdownMenuTrigger as Fm,Tooltip as ar,TooltipContent as lr,TooltipTrigger as cr,useTranslation as Wm}from"lecom-ui";import{WrenchIcon as Um}from"lucide-react";import{jsx as oe,jsxs as Ze}from"react/jsx-runtime";var Ja=({nodeId:e})=>{let{t}=Wm(),{updateNodeData:o,getEdges:n,getNode:r}=Vm(),i=Rm(e),a=n().filter(p=>p.source===e).some(p=>{let h=r(p.target);return(h==null?void 0:h.type)==="END_EVENT"}),l=(i==null?void 0:i.data.variant)==="SUBPROCESS",c=f=>{o(e,{variant:(i==null?void 0:i.data.variant)===f?"":f})},d=f=>{o(e,{attribute:(i==null?void 0:i.data.attribute)===f?"":f})};return Ze(Om,{children:[Ze(ar,{children:[oe(cr,{asChild:!0,children:oe(Fm,{asChild:!0,children:oe(Za,{variant:"ghost",color:"grey",size:"small",iconButton:!0,children:oe(Um,{})})})}),oe(lr,{color:"black",children:t("bpmn.task.menu.title")})]}),Ze(Hm,{align:"start",className:"w-60 bg-white text-grey-600",children:[Ze(zm,{className:"flex items-center gap-1",children:[oe("div",{className:"flex-1 text-sm font-semibold",children:t("bpmn.task.menu.title")}),oe("div",{className:"flex items-center gap-1",children:Object.entries(yo).map(([f,u])=>{let p=f==="LOOP"&&(a||l),m=(()=>{if(f==="LOOP"&&a)return t("editor.task_menu.loop_not_allowed_when_connected_to_end");if(f==="LOOP"&&l)return t("editor.task_menu.loop_not_allowed_when_subprocess")})();return Ze(ar,{children:[oe(cr,{asChild:!0,children:oe(Za,{variant:"ghost",color:"grey",size:"small",iconButton:!0,disabled:p,className:P({"bg-grey-100 text-blue-500":(i==null?void 0:i.data.attribute)===f,"opacity-50 cursor-not-allowed":p}),onClick:p?void 0:()=>d(f),children:oe(u.icon,{className:"stroke-inherit"})})}),m&&oe(lr,{color:"black",children:m})]},f)})})]}),oe(Gm,{children:Ze(ar,{children:[oe(cr,{asChild:!0,children:Ze(Bm,{className:P({"bg-grey-100 text-blue-500":(i==null?void 0:i.data.variant)==="SCRIPT","opacity-50 cursor-not-allowed":a}),disabled:a,onClick:a?void 0:()=>c("SCRIPT"),children:[oe(ho.SCRIPT.icon,{className:"stroke-current"}),t(`bpmn.task.variant.${"SCRIPT".toLowerCase()}`)]})}),a&&oe(lr,{color:"black",children:t("editor.task_menu.script_not_allowed_when_connected_to_end")})]})})]})]})};import{jsx as Q,jsxs as ja}from"react/jsx-runtime";var ie=({nodeId:e,nodeType:t,nodeVariant:o,isChild:n,isVisible:r})=>{var C;let i=Qa(null),s=Qa(null),{t:a}=Jm(),{setDraggableNode:l}=ht(),{getEdges:c,getNodes:d}=$m(),{setIsDragging:f}=D(),{dimensions:u}=Ka(i,r),{position:p}=qa(e,r,u),[h,m]=Qm(void 0),g=d(),T=c(),x=o==="SUBPROCESS",y=(L,w)=>{l({type:w.type,variant:w.variant,attribute:w.attribute,icon:w.icon}),w.icon&&m(Q(w.icon,{})),L.dataTransfer.effectAllowed="move",L.dataTransfer.setData("sourceId",e),s.current&&L.dataTransfer.setDragImage(s.current,10,10),setTimeout(()=>{f(!0)},100)},E={START_EVENT:{type:"START_EVENT",icon:Mt,label:a("bpmn.start_event.variant.default")},END_EVENT:{type:"END_EVENT",icon:nt,label:a("bpmn.end_event.variant.default")},TASK:{type:"TASK",icon:Mt,label:a("bpmn.task.variant.default")},ANNOTATION:{type:"ANNOTATION",icon:fo,label:a("bpmn.annotation.variant.default")}},b={EXCLUSIVE:{type:"GATEWAY",variant:"EXCLUSIVE",icon:it,label:a("bpmn.gateway.variant.exclusive")},PARALLEL:{type:"GATEWAY",variant:"PARALLEL",icon:st,label:a("bpmn.gateway.variant.parallel")},COMPLEX:{type:"GATEWAY",variant:"COMPLEX",icon:rt,label:a("bpmn.gateway.variant.complex")}},A=[{component:Q(en,{elementId:e})}],v={START_EVENT:[{component:Q(qt,{nodeId:e})},E.TASK,E.ANNOTATION,...A],TASK:[{component:Q(Kt,{elementId:e})},...x?[]:[{component:Q(Ja,{nodeId:e})}],{component:Q(qt,{nodeId:e})},E.TASK,...Object.values(b),...A],GATEWAY:[{component:Q(Kt,{elementId:e})},{component:Q(qt,{nodeId:e})},E.TASK,E.ANNOTATION,...A],END_EVENT:[{component:Q(qt,{nodeId:e})},E.ANNOTATION,...A],LANE:[...n?[]:[E.ANNOTATION],...A],ANNOTATION:[...A],UNSUPPORTED:[...A]};return ja(Ym,{position:p,align:"start",className:"-top-8",isVisible:r,children:[Q("div",{ref:i,className:"flex items-center gap-1 px-3 py-2 bg-white rounded-sm shadow-md",children:(C=v[t])==null?void 0:C.map((L,w)=>{if(L.component)return Q("div",{children:L.component},w);let S={sourceNodeType:t,targetNodeType:L.type,sourceNodeId:e,nodes:g,edges:T},M=ca(S),I={gateway_limit_reached:a("editor.toolbar.gateway_limit_reached"),start_event_already_exists:a("editor.toolbar.start_event_already_exists"),script_to_end_not_allowed:a("editor.toolbar.script_to_end_not_allowed"),loop_to_end_not_allowed:a("editor.toolbar.loop_to_end_not_allowed"),initial_activity_to_end_not_allowed:a("editor.toolbar.initial_activity_to_end_not_allowed"),final_activity_cannot_connect:a("editor.toolbar.final_activity_cannot_connect"),activity_has_outgoing_connections:a("editor.toolbar.activity_has_outgoing_connections"),task_limit_reached:a("editor.toolbar.task_limit_reached")},V=M.shouldDisable&&M.reason?I[M.reason]||L.label:L.label||"";return ja(Km,{children:[Q(Zm,{asChild:!0,children:Q(Xm,{variant:"ghost",color:"grey",size:"small",iconButton:!0,draggable:!M.shouldDisable,disabled:M.shouldDisable,className:M.shouldDisable?"opacity-50 cursor-not-allowed":"",onDragStart:M.shouldDisable?void 0:F=>y(F,L),children:L.icon&&Q(L.icon,{size:16})})}),Q(qm,{color:"black",children:V})]},w)})}),Q("div",{ref:s,className:"absolute w-0 h-0 top-0 left-0 z-[-1] bg-transparent",children:h})]})};import{jsx as bn,jsxs as og}from"react/jsx-runtime";var el=({id:e,data:t,selected:o,dragging:n})=>{let{updateNodeData:r}=tg(),{inProgress:i,fromNode:s}=eg(),{isConnecting:a,isDragging:l,isMultipleSelection:c}=D(),d=i&&(s==null?void 0:s.id)!==e,f=p=>{r(e,{label:p})},u=!a&&!l&&!c;return og("div",{className:P("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:[bn(J,{value:t.label,className:"m-1 text-grey-600",onChange:f}),u&&bn(ie,{nodeId:e,nodeType:"ANNOTATION",isVisible:!n&&o}),bn(yt,{minWidth:xn.MIN_WIDTH,minHeight:xn.MIN_HEIGHT,isVisible:!n&&o}),(!i||d)&&bn(Z,{type:"target",position:jm.Left,className:P({"annotation-handle":d})})]})};import{Position as tl,useConnection as ng,useReactFlow as rg}from"@xyflow/react";import{useState as ig}from"react";import{jsx as xt,jsxs as sg}from"react/jsx-runtime";var ol=({id:e,data:t,selected:o,dragging:n})=>{let{updateNodeData:r}=rg(),{inProgress:i,fromNode:s}=ng(),{isConnecting:a,isDragging:l,isMultipleSelection:c}=D(),[d,f]=ig(!1),u=i&&(s==null?void 0:s.id)!==e,p=T=>{r(e,{label:T})},h=()=>{f(!0)},m=()=>{f(!1)},g=!a&&!l&&!c;return sg("div",{className:"relative",onBlur:m,onDoubleClick:h,children:[xt(nt,{className:P("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})}),xt("div",{className:"absolute top-9 left-1/2 -translate-x-1/2 max-w-80 w-max",children:xt(J,{value:t.label,isEditing:d,onChange:p})}),g&&xt(ie,{nodeId:e,nodeType:"END_EVENT",isVisible:!n&&o}),(!i||u)&&xt(Z,{type:"target",position:tl.Left,className:P({"event-handle":u})}),!i&&xt(Z,{type:"source",position:tl.Right})]})};import{Position as nl,useConnection as ag,useReactFlow as lg}from"@xyflow/react";import{useState as cg}from"react";import{jsx as Et,jsxs as dg}from"react/jsx-runtime";var rl=({id:e,data:t,selected:o,dragging:n})=>{let r=Un[t.variant].icon,{updateNodeData:i}=lg(),{inProgress:s,fromNode:a}=ag(),{isConnecting:l,isDragging:c,isMultipleSelection:d}=D(),[f,u]=cg(!1),p=s&&(a==null?void 0:a.id)!==e,h=x=>{i(e,{label:x})},m=()=>{u(!0)},g=()=>{u(!1)},T=!l&&!c&&!d;return dg("div",{className:"relative",onBlur:g,onDoubleClick:m,children:[Et(r,{className:P("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})}),Et("div",{className:"absolute top-14 left-1/2 -translate-x-1/2 max-w-80 w-max",children:Et(J,{value:t.label,isEditing:f,onChange:h})}),T&&Et(ie,{nodeId:e,nodeType:"GATEWAY",isVisible:!n&&o}),(!s||p)&&Et(Z,{type:"target",position:nl.Left,className:P({"gateway-handle":p})}),!s&&Et(_n,{type:"source",position:nl.Right,nodeId:e,nodeType:"GATEWAY",gatewayVariant:t.variant})]})};import{useNodesData as vC,useReactFlow as NC}from"@xyflow/react";import{Button as AC,DropdownMenu as CC,DropdownMenuContent as IC,DropdownMenuGroup as SC,DropdownMenuItem as MC,DropdownMenuLabel as PC,DropdownMenuTrigger as LC,Tooltip as kC,TooltipContent as DC,TooltipTrigger as RC,useTranslation as VC}from"lecom-ui";import{WrenchIcon as HC}from"lucide-react";import{jsx as FC,jsxs as WC}from"react/jsx-runtime";import{Position as il,useConnection as ug,useReactFlow as pg}from"@xyflow/react";import{useState as fg}from"react";import{jsx as _t,jsxs as mg}from"react/jsx-runtime";var sl=({id:e,data:t,selected:o,dragging:n})=>{let{updateNodeData:r}=pg(),{inProgress:i,fromNode:s}=ug(),{isConnecting:a,isDragging:l,isMultipleSelection:c}=D(),[d,f]=fg(!1),u=i&&(s==null?void 0:s.id)!==e,p=T=>{r(e,{label:T})},h=()=>{f(!0)},m=()=>{f(!1)},g=!a&&!l&&!c;return mg("div",{className:"relative",onBlur:m,onDoubleClick:h,children:[_t(mo,{className:P("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})}),_t("div",{className:"absolute top-9 left-1/2 -translate-x-1/2 max-w-80 w-max",children:_t(J,{value:t.label,isEditing:d,onChange:p})}),g&&_t(ie,{nodeId:e,nodeType:"START_EVENT",isVisible:!n&&o}),(!i||u)&&_t(Z,{type:"target",position:il.Left,className:P({"event-handle":u})}),!i&&_t(Z,{type:"source",position:il.Right})]})};import{Position as fl,useConnection as yg,useReactFlow as xg}from"@xyflow/react";import{useTranslation as Eg}from"lecom-ui";import{jsx as al,jsxs as gg}from"react/jsx-runtime";var ll=e=>gg("svg",N(_({width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",xmlns:"http://www.w3.org/2000/svg"},e),{children:[al("circle",{cx:"12",cy:"12",r:"10",fill:"#10B981"}),al("path",{d:"M7 12L10 15L17 8",stroke:"white",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"})]}));import{jsx as cl}from"react/jsx-runtime";var dl=e=>cl("svg",N(_({width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",xmlns:"http://www.w3.org/2000/svg"},e),{children:cl("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 ul,jsxs as hg}from"react/jsx-runtime";var pl=e=>hg("svg",N(_({width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",xmlns:"http://www.w3.org/2000/svg"},e),{children:[ul("circle",{cx:"12",cy:"12",r:"10",fill:"#EF4444"}),ul("path",{d:"M8 8L16 16M8 16L16 8",stroke:"white",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"})]}));import{jsx as fe,jsxs as _g}from"react/jsx-runtime";var ml=({id:e,data:t,selected:o,dragging:n})=>{let{t:r}=Eg(),{updateNodeData:i,getNodes:s}=xg(),{inProgress:a,fromNode:l}=yg(),{isConnecting:c,isDragging:d,isMultipleSelection:f,onSubprocessValidationClick:u}=D(),{getTaskStatus:p}=Fe(),h=a&&(l==null?void 0:l.id)!==e,m=M=>{let I=M.trim(),V=t.label||"";if(I===V)return;let F=s(),G=I;I||(G=gn(F,r("bpmn.task.label.prefix")));let U=mt(G,F);U!==V&&i(e,{label:U})},g={APROVADO:ll,EM_ANDAMENTO:dl,REJEITADO:pl},T={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)]"},x=p(e),y=x?g[x]:null,E=t.variant?ho[t.variant].icon:null,b=t.attribute?yo[t.attribute].icon:null,A=t.variant==="SUBPROCESS",v=E&&!A,C=b||A,L=()=>t.hasError?T.error:x?T[x]:T.default,w=()=>{u==null||u({id:e,type:"sub_process",label:t.label})},S=!c&&!d&&!f;return _g("div",{className:P("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",L(),{"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(J,{value:t.label,maxLength:60,className:P("m-1",{"py-6":v||C}),onChange:m}),E&&fe("div",{className:P("absolute flex items-center p-1",A?"bottom-0":"top-0 left-0"),children:fe(E,{size:16,className:P(t.hasError?"text-red-500":"text-grey-500",A&&"cursor-pointer"),onClick:A?w:void 0})}),b&&fe("div",{className:"absolute bottom-0 left-0 w-full flex items-center justify-center",children:fe("div",{className:P("flex items-center w-16 p-1",A?"justify-between":"justify-center"),children:fe(b,{size:16,className:P(t.hasError?"text-red-500":"text-grey-500")})})}),y&&fe("div",{className:"absolute top-0 right-0 flex items-center p-1",children:fe(y,{})}),S&&fe(ie,{nodeId:e,nodeType:"TASK",nodeVariant:t.variant,isVisible:!n&&o}),fe(yt,{minWidth:hn.MIN_WIDTH,minHeight:hn.MIN_HEIGHT,isVisible:!n&&o}),(!a||h)&&fe(Z,{type:"target",position:fl.Left,className:P({"task-handle":h})}),!a&&fe(_n,{type:"source",position:fl.Right,nodeId:e,nodeType:"TASK"})]})};import{Position as gl}from"@xyflow/react";import{Fragment as bg,jsx as Tn,jsxs as Tg}from"react/jsx-runtime";var hl=({id:e,data:t,selected:o,dragging:n})=>{let{isConnecting:r,isDragging:i,isMultipleSelection:s}=D(),a=!r&&!i&&!s;return Tg(bg,{children:[Tn("div",{className:"relative w-full h-full min-w-32 min-h-16 flex items-center justify-center bg-white border-2 border-red-400 rounded-sm overflow-hidden",children:t.label}),a&&Tn(ie,{nodeId:e,nodeType:"UNSUPPORTED",isVisible:!n&&o}),Tn(Z,{type:"source",position:gl.Right}),Tn(Z,{type:"target",position:gl.Left})]})};import{Position as vg,useReactFlow as Ng}from"@xyflow/react";import{orderBy as wg}from"lodash";import{useMemo as yl,useState as Ag}from"react";import{Fragment as Cg,jsx as Je,jsxs as xl}from"react/jsx-runtime";var El=({id:e,data:t,selected:o,dragging:n,parentId:r})=>{let{updateNodeData:i,getNodes:s}=Ng(),{isConnecting:a,isDragging:l,isMultipleSelection:c}=D(),[d,f]=Ag(!1),u=s(),p=!r,h=yl(()=>wg([...u.filter(b=>b.parentId===e&&b.type==="LANE")],"position.y","asc"),[u,e]),m=p?yn.MIN_WIDTH:W.MIN_WIDTH,g=yl(()=>{if(p&&h.length>1){let b=[...h];return b.pop(),b.reduce((v,C)=>{var L,w;return v+((w=(L=C.measured)==null?void 0:L.height)!=null?w:0)},0)+W.MIN_HEIGHT}return W.MIN_HEIGHT},[p,h]),T=b=>{i(e,{label:b})},x=()=>{f(!0)},y=()=>{f(!1)},E=!a&&!l&&!c;return xl(Cg,{children:[xl("div",{className:P("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:[Je("div",{className:"flex align-items justify-center w-10 border-r-2 border-grey-400",onBlur:y,onDoubleClick:x,children:Je("div",{className:P("relative flex-1",{"[writing-mode:vertical-rl] [text-orientation:sideways] transform rotate-180":!d}),children:Je(J,{value:t.label,className:"w-full h-full pointer-events-none self-auto",contentClassName:P({"whitespace-nowrap":d}),isEditing:d,onChange:T})})}),Je("div",{className:"flex-1"})]}),E&&Je(ie,{nodeId:e,nodeType:"LANE",isChild:!p,isVisible:!n&&o}),Je(yt,{nodeId:e,minWidth:m,minHeight:g,isVisible:!n&&o}),p&&Je(Z,{type:"source",position:vg.Right})]})};var _l={START_EVENT:sl,END_EVENT:ol,TASK:ml,GATEWAY:rl,ANNOTATION:el,LANE:El,UNSUPPORTED:hl},bl={SEQUENCE_EDGE:ia,MESSAGE_EDGE:Ra,ANNOTATION_EDGE:js},Tl="#fafafa",vl="#bebebe",Nl=1,wl=10,Al="bottom-left",Cl=.2,Il=5,bt=.3,Sl={x:0,y:0,zoom:.75},Ig=1,Sg=2,Ml=[Ig,Sg];var Pl=()=>{let{setNodes:e,setEdges:t,fitView:o}=Mg();return{importFromLia:r=>{let i=typeof r=="string"?r:r.diagramXml||"",{nodes:s,edges:a}=Ya(i),l=[],c=new Map,d=!1;for(let[h,m]of Object.entries(s)){let g=vn(),T=Wa[m.type],x=Ua[m.type];T==="START_EVENT"&&(d=!0),c.set(h,g);let y=R[T].MIN_WIDTH,E=R[T].MIN_HEIGHT;l.push({id:g,type:T,data:{label:m.label||"",variant:x,attribute:""},position:{x:0,y:0},width:y,height:E,measured:{width:y,height:E}})}let f=[];for(let h of a){let m=N(_({},le),{id:vn(),source:c.get(h.sourceId)||h.sourceId,target:c.get(h.targetId)||h.targetId});f.push(m)}if(!d&&l.length>0){let h=vn(),m={id:h,type:"START_EVENT",data:{label:"",variant:"",attribute:""},position:{x:0,y:0},width:R.START_EVENT.MIN_WIDTH,height:R.START_EVENT.MIN_HEIGHT,measured:{width:R.START_EVENT.MIN_WIDTH,height:R.START_EVENT.MIN_HEIGHT}};l.unshift(m);let g=l[1];if(g){let T=N(_({},le),{id:vn(),source:h,target:g.id});f.unshift(T)}}let{nodes:u,edges:p}=Sa(l,f);e(u),t(p),o({padding:bt})}}};import{useReactFlow as qg}from"@xyflow/react";import{useCallback as Xl}from"react";var ro=(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))(ro||{});import{xml2json as Pg,json2xml as Lg}from"xml-js";var Ll={compact:!0,spaces:4},kg=e=>e.replaceAll(`
3
+ `,"&#xA;");function Nn(e,t=Ll){if(e)return JSON.parse(Pg(e,N(_({},t),{attributeValueFn:kg})))}function kl(e,t=Ll){return e?Lg(e,t):""}import{v7 as Gl}from"uuid";var Dl={"attribute-loop":"LOOP"},Rl={"task-script":"SCRIPT","subprocess-collapsed":"SUBPROCESS"},Vl={"gateway-exclusive":"EXCLUSIVE","gateway-parallel":"PARALLEL","gateway-complex":"COMPLEX"},Ol={SCRIPT:"task-script",SUBPROCESS:"subprocess-collapsed"},Hl={EXCLUSIVE:"gateway-exclusive",PARALLEL:"gateway-parallel",COMPLEX:"gateway-complex"};var Tt=(e,t,o)=>{let n=e._attributes.width||0,r=e._attributes.height||0,i=Pe(Number(n),t),s=Pe(Number(r),o);return{width:i,height:s,measured:{width:i,height:s}}},vt=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},Rg=e=>{let{mxGeometry:t}=e,o=vt(e),n=Tt(t,R.START_EVENT.MIN_WIDTH,R.START_EVENT.MIN_HEIGHT);return N(_(_({},o),n),{type:"START_EVENT"})},Vg=e=>{let{mxGeometry:t}=e,o=vt(e),n=Tt(t,R.END_EVENT.MIN_WIDTH,R.END_EVENT.MIN_HEIGHT);return N(_(_({},o),n),{type:"END_EVENT"})},dr=(e,t)=>{let{_attributes:o,mxGeometry:n}=e,r=vt(e),i=Tt(n,R.TASK.MIN_WIDTH,R.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=Dl[l];c&&(r.data.attribute=c)}let a=Rl[o.style];return a&&(r.data.variant=a),N(_(_({},r),i),{type:"TASK"})},ur=e=>{let{_attributes:t,mxGeometry:o}=e,{style:n}=t,r=vt(e),i=Tt(o,R.GATEWAY.MIN_WIDTH,R.GATEWAY.MIN_HEIGHT);return r.data.variant=Vl[n],N(_(_({},r),i),{type:"GATEWAY"})},Og=e=>{let{mxGeometry:t}=e,o=vt(e),n=Tt(t,R.ANNOTATION.MIN_WIDTH,R.ANNOTATION.MIN_HEIGHT);return N(_(_({},o),n),{type:"ANNOTATION"})},Hg=e=>{let{mxGeometry:t}=e,o=vt(e),n=Tt(t,R.LANE.MIN_WIDTH,R.LANE.MIN_HEIGHT);return N(_(_({},o),n),{type:"LANE"})},Bl={task:dr,"task-script":dr,"subprocess-collapsed":dr,"start-event":Rg,"end-event-terminate":Vg,"gateway-parallel":ur,"gateway-exclusive":ur,"gateway-complex":ur,annotation:Og,lane:Hg},zl=e=>{let{_attributes:t}=e,{source:o,target:n,value:r,style:i}=t,s={id:Gl(),source:o,target:n,data:{label:r||""}};return i.includes("association")&&i.includes('endArrow=""')?_(_({},ft),s):_(_({},le),s)},Fl=(e,t)=>{let{id:o,type:n,source:r,target:i,data:s}=e,a=t==null?void 0:t.find(d=>d.id===r),l="";return n==="ANNOTATION_EDGE"&&(l='association;endArrow=""'),{_attributes:{id:o,parent:(a==null?void 0:a.parentId)||"1",edge:"1",style:l,source:r,target:i,value:(s==null?void 0:s.label)||""},mxGeometry:{_attributes:{as:"geometry",relative:"1"}}}},Nt=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}}}},Gg=e=>{let{variant:t}=e.data,o=Nt(e);return N(_({},o),{_attributes:N(_({},o._attributes),{style:Ol[t]||"task"})})},Bg=e=>{let t=Nt(e);return N(_({},t),{_attributes:N(_({},t._attributes),{style:"start-event"})})},zg=e=>{let t=Nt(e);return N(_({},t),{_attributes:N(_({},t._attributes),{style:"end-event-terminate"})})},Fg=e=>{let{variant:t}=e.data,o=Nt(e);return N(_({},o),{_attributes:N(_({},o._attributes),{style:Hl[t]})})},Wg=e=>{let t=Nt(e);return N(_({},t),{_attributes:N(_({},t._attributes),{style:"lane"})})},Ug=e=>{let t=Nt(e);return N(_({},t),{_attributes:N(_({},t._attributes),{style:"annotation"})})},Wl={TASK:Gg,START_EVENT:Bg,END_EVENT:zg,GATEWAY:Fg,ANNOTATION:Ug,LANE:Wg},Ul=e=>{var i,s;let n=((i=e.measured)==null?void 0:i.width)||0,r=((s=e.measured)==null?void 0:s.height)||0;return{_attributes:{id:Gl(),parent:e.id,style:"attribute-loop",connectable:"0"},mxGeometry:{_attributes:{as:"geometry",x:n/2-22/2,y:r-22,width:22,height:22}}}};var Yg=e=>{let t=Object.values(ro),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=Bl[s],l=a==null?void 0:a(i,n);if(!l){console.warn(`Node ${s} not supported`);continue}r.push(l)}return r},$g=(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=zl(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},Xg=e=>{let t=[];return e.forEach(o=>{var i,s;let n=(s=(i=Wl)[o.type])==null?void 0:s.call(i,o);if(!n){console.warn(`Node ${o.type} not supported`);return}if(t.push(n),o.type==="TASK"&&o.data.attribute==="LOOP"){let a=Ul(o);t.push(a)}}),t},Kg=(e,t)=>{let o=[];return e.forEach(n=>{let r=Fl(n,t);o.push(r)}),o},Yl=(e=[],t=[])=>{let o=Xg(e),n=Kg(t,e),r={mxGraphModel:{root:{_attributes:{version:"1.1"},mxCell:[{_attributes:{id:"0"}},{_attributes:{id:"1",parent:"0"}},...o,...n]}}};return kl(JSON.stringify(r))},$l=async e=>{var s,a;let t=await Nn(e),o=((a=(s=t==null?void 0:t.mxGraphModel)==null?void 0:s.root)==null?void 0:a.mxCell)||[],n=Yg(o),r=$g(o,n);return{nodes:Ie(oo(n)),edges:r}};var Kl=()=>{let{getNodes:e,getEdges:t,setNodes:o,setEdges:n,fitView:r}=qg(),i=Xl(async(a="")=>{let{nodes:l,edges:c}=await $l(a);o(l),n(c),r({padding:bt})},[o,n,r]),s=Xl((a,l)=>{let c=a||e()||[],d=l||t()||[];return Yl(c,d)},[e,t]);return{importFromMxGraph:i,exportToMxGraph:s}};import{useEffect as Zg,useCallback as Jg}from"react";var Qg={origin:"*",debug:!1};function ql(e,t=Qg){let{origin:o,debug:n}=t,r=Jg((i,s)=>{let a={event:i,data:[i,{event:i,data:s}]};window.parent.postMessage(a,o||"*")},[o]);return Zg(()=>{let i=s=>{let a=s.data;if(!(a!=null&&a.event)||!(a!=null&&a.data))return;let{event:l,data:c}=a,d;if(Array.isArray(c)){let[,f]=c;d=f.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{useCallback as Zl}from"react";import{useReactFlow as jg}from"@xyflow/react";function Jl(){let{setTaskStatuses:e,clearTaskStatuses:t,calculateFlowPath:o}=Fe(),{getEdges:n}=jg(),r=xo(),i=Zl(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=Zl(()=>{t(),setTimeout(()=>{r()},0)},[t,r]);return{handleTasksStatus:i,handleClearTaskStatus:s}}import{useReactFlow as eh}from"@xyflow/react";import{useCallback as wt,useState as Ql,useEffect as th}from"react";import{useDebouncedCallback as oh}from"use-debounce";var jl=[{nodes:[],edges:[]}],nh=500,ec=100,tc=(e=jl)=>{let{getNodes:t,getEdges:o,setNodes:n,setEdges:r}=eh(),[i,s]=Ql(e),[a,l]=Ql(0),c=i[a],d=a>0,f=a<i.length-1,u=wt(E=>{n(i[E].nodes),r(i[E].edges)},[i,n,r]),p=wt(()=>{if(a>0){let E=a-1;l(E),u(E)}},[a,u]),h=wt(()=>{if(a<i.length-1){let E=a+1;l(E),u(E)}},[i,a,u]),m=E=>{let A=[...i.slice(0,a+1),E],v=A.length>ec?A.slice(A.length-ec):A;s(v),l(v.length-1)},g=oh(()=>{let E=t(),b=o(),A=E.map(L=>N(_({},L),{selected:!1,className:""})),v={nodes:Ie(A),edges:b};JSON.stringify(c)!==JSON.stringify(v)&&m(v)},nh),T=wt(E=>{if(E==="forceSave"){g();return}E.some(v=>v.type==="select")||E.some(v=>v.type==="position"&&v.dragging)||g()},[g]),x=wt(E=>{s(E||jl),l(0)},[]),y=wt(()=>{s([]),l(0)},[]);return th(()=>{let E=b=>{(b.ctrlKey||b.metaKey)&&(b.shiftKey&&b.key.toLowerCase()==="z"?(b.preventDefault(),h()):b.key.toLowerCase()==="z"&&(b.preventDefault(),p()))};return document.addEventListener("keydown",E),()=>{document.removeEventListener("keydown",E)}},[p,h]),{history:i,undo:p,redo:h,canUndo:d,canRedo:f,saveHistory:T,resetHistory:x,clearHistory:y}};import{jsx as oc}from"react/jsx-runtime";var pr=({id:e,className:t})=>oc("marker",{id:e,className:P("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:oc("path",{d:"M 0 0 L 10 5 L 0 10 Z"})});import{jsx as fr,jsxs as rh}from"react/jsx-runtime";var nc=()=>fr("svg",{style:{position:"absolute",top:0,left:0},children:rh("defs",{children:[fr(pr,{id:"sequence-edge-marker",className:"text-grey-400"}),fr(pr,{id:"sequence-edge-marker-highlighted",className:"text-blue-500"})]})});import{useKeyPress as _c}from"@xyflow/react";import{Button as yr,Tooltip as xr,TooltipContent as Er,TooltipTrigger as _r,useTranslation as Jh}from"lecom-ui";import{HandIcon as Qh,MapIcon as jh,MousePointerIcon as e0}from"lucide-react";import{useCallback as bc,useEffect as Tc}from"react";import{Tooltip as Ih,TooltipContent as Sh,TooltipTrigger as Mh,useNotificationToast as Ph,useTranslation as Lh}from"lecom-ui";var io=(x=>(x.START_EVENT="START_EVENT",x.END_EVENT="END_EVENT",x.TASK="TASK",x.SUBPROCESS="SUBPROCESS",x.GATEWAY="GATEWAY",x.LANE="LANE",x.ANNOTATION="ANNOTATION",x.CONNECTION="CONNECTION",x.INTERMEDIATE_EVENT="INTERMEDIATE_EVENT",x.ACTIVITY="ACTIVITY",x.PROCESS_INTERFACE="PROCESS_INTERFACE",x.WORKFLOW_INTERFACE="WORKFLOW_INTERFACE",x.VARIANT_ACTIVITY="VARIANT_ACTIVITY",x.AUTO_ACTIVITY="AUTO_ACTIVITY",x.DATA_STORE="DATA_STORE",x.DATA_OBJECT="DATA_OBJECT",x.DATA_OUTPUT="DATA_OUTPUT",x.DATA_INPUT="DATA_INPUT",x))(io||{});import{useReactFlow as Eh}from"@xyflow/react";import{useNotificationToast as _h,useTranslation as bh,Button as Th}from"lecom-ui";var rc=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 ic({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(`
4
+ `),i=encodeURI(r);wn(i,`${o}.csv`)}var wn=(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)};import{v7 as fh}from"uuid";function sc(e){return e==null?void 0:e.replaceAll("&#xA;"," ")}import{v7 as sh}from"uuid";var Q5={START_EVENT:"START_EVENT",END_EVENT:"END_EVENT",TASK:"TASK",GATEWAY:"GATEWAY",ANNOTATION:"ANNOTATION"},ac={script:"SCRIPT",subprocess:"SUBPROCESS"},lc={complex:"COMPLEX",none:"EXCLUSIVE",exclusive:"EXCLUSIVE",parallel:"PARALLEL"};var Qe=({cell:e,type:t,variant:o=""})=>{let{_attributes:n,mxGeometry:r}=e,{value:i,parent:s}=n,a=Number(r._attributes.width),l=Number(r._attributes.height),c=s==="1"?void 0:s;return{id:n.id,parentId:c,type:t,data:{label:i||"",variant:o,attribute:""},position:{x:Number(r._attributes.x)||0,y:Number(r._attributes.y)||0},width:a,height:l,measured:{width:a,height:l}}},ah=e=>{let{subType:t,style:o}=e._attributes,n="imported";return["none"].includes(t)||(n="adapted"),e.mxGeometry._attributes.width=R.START_EVENT.MIN_WIDTH,e.mxGeometry._attributes.height=R.START_EVENT.MIN_HEIGHT,{node:Qe({cell:e,type:"START_EVENT"}),status:n,originalType:o}},lh=e=>{let{subType:t,style:o}=e==null?void 0:e._attributes,n="imported";return["none"].includes(t)||(n="adapted"),e.mxGeometry._attributes.width=R.END_EVENT.MIN_WIDTH,e.mxGeometry._attributes.height=R.END_EVENT.MIN_HEIGHT,{node:Qe({cell:e,type:"END_EVENT"}),status:n,originalType:o}},ch=e=>{let{subType:t,style:o}=e==null?void 0:e._attributes,n=ac[t],r="imported";return["script","none"].includes(t)||(r="adapted"),e.mxGeometry._attributes.width=Pe(e.mxGeometry._attributes.width||0,R.TASK.MIN_WIDTH),e.mxGeometry._attributes.height=Pe(e.mxGeometry._attributes.height||0,R.TASK.MIN_HEIGHT),{node:Qe({cell:e,type:"TASK",variant:n}),status:r,originalType:o}},dh=e=>{let{style:t,subType:o}=e==null?void 0:e._attributes,n=lc[o],r=["none","inclusive","event-based"],i="imported";return r.includes(o)&&(i="adapted"),e.mxGeometry._attributes.width=R.GATEWAY.MIN_WIDTH,e.mxGeometry._attributes.height=R.GATEWAY.MIN_HEIGHT,{node:Qe({cell:e,type:"GATEWAY",variant:n}),status:i,originalType:t}},uh=e=>{let{style:t}=e==null?void 0:e._attributes;return{node:Qe({cell:e,type:"LANE"}),status:"imported",originalType:t}},ph=e=>{let{style:t}=e==null?void 0:e._attributes;return e.mxGeometry._attributes.width=Pe(e.mxGeometry._attributes.width||0,R.ANNOTATION.MIN_WIDTH),e.mxGeometry._attributes.height=Pe(e.mxGeometry._attributes.height||0,R.ANNOTATION.MIN_HEIGHT),{node:Qe({cell:e,type:"ANNOTATION"}),status:"imported",originalType:t}},cc=e=>{let{style:t}=e==null?void 0:e._attributes;return e.mxGeometry._attributes.width=R.UNSUPPORTED.MIN_WIDTH,e.mxGeometry._attributes.height=R.UNSUPPORTED.MIN_HEIGHT,{node:Qe({cell:e,type:"UNSUPPORTED"}),status:"unsupported",originalType:t}},dc=(e,t)=>{let{source:o,target:n,value:r}=e._attributes;return N(_({},le),{id:sh(),source:t.get(o)||o,target:t.get(n)||n,data:{label:r||""}})},uc={TASK:ch,GATEWAY:dh,START_EVENT:ah,END_EVENT:lh,LANE:uh,ANNOTATION:ph};var mh=(e,t)=>{let o=e.filter(n=>n.parentId);for(let n of o){let r=t.get(n.parentId);r&&(n.parentId=r)}return e},gh=e=>{var s;let t=new Map,o=Object.values(io),n=e.filter(a=>{var c;let l=(c=a._attributes)==null?void 0:c.type;return o.includes(l)}),r=[],i=[];for(let a of n){let l=fh(),{type:c}=a._attributes,d=uc[c]||cc;t.set((s=a._attributes)==null?void 0:s.id,l),a._attributes.id=l;let{node:f,status:u,originalType:p}=d(a);i.push(f),r.push({originalType:p,type:f.type,variant:f.data.variant,value:sc(f.data.label),status:u})}return i=mh(i,t),{nodes:i,governanceIdToNodeIdMap:t,summary:r}},hh=(e,t)=>e.filter(r=>{var i;return(i=r._attributes)==null?void 0:i.edge}).map(r=>dc(r,t)),yh=e=>{let{mxGraphModel:t}=e,{nodes:o,governanceIdToNodeIdMap:n,summary:r}=gh(t.root.mxCell),i=hh(t.root.mxCell,n);return{nodes:o,edges:i,summary:r}},xh=async e=>{let t=await rc(e),o=Nn(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}},pc=async e=>{try{let t=await xh(e),{nodes:o,edges:n,summary:r}=yh(t)||{};return{nodes:o,edges:n,summary:r}}catch(t){throw t}};import{jsx as vh}from"react/jsx-runtime";var fc=()=>{let{t:e}=bh(),{toast:t}=_h(),{setNodes:o,setEdges:n,fitView:r}=Eh(),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:vh(Th,{size:"small",variant:"ghost",onClick:()=>ic({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 pc(a);if(o(u=>u.concat(l)),n(u=>u.concat(c)),r({padding:bt}),d.some(u=>u.status==="unsupported")){i(d);return}t({variant:"success",content:e("adapter.governance.success.default")})}catch(l){let c=l instanceof Error?l.message:"DEFAULT";t({variant:"error",content:e(`adapter.governance.error.${c}`)})}}}};import{Button as Nh}from"lecom-ui";import{useRef as wh}from"react";import{Fragment as Ah,jsx as mc,jsxs as Ch}from"react/jsx-runtime";var gc=a=>{var l=a,{children:e,accept:t="*",multiple:o=!1,disabled:n=!1,onClick:r,onFilesSelected:i}=l,s=Ee(l,["children","accept","multiple","disabled","onClick","onFilesSelected"]);let c=wh(null),d=u=>{let p=u.target.files;p!=null&&p.length&&i(p),c.current&&(c.current.value="")};return Ch(Ah,{children:[mc(Nh,N(_({onClick:u=>{var p;(p=c.current)==null||p.click(),r==null||r(u)}},s),{children:e})),mc("input",{type:"file",ref:c,className:"sr-only",accept:t,multiple:o,disabled:n,onChange:d})]})};import{jsx as An,jsxs as kh}from"react/jsx-runtime";var hc=({disabled:e=!1})=>{let{t}=Lh(),{toast:o}=Ph(),{importFromGovernance:n}=fc(),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 kh(Ih,{children:[An(Mh,{asChild:!0,children:An(gc,{className:"[&>svg]:size-7 p-0",variant:"ghost",size:"small",color:"grey",iconButton:!0,accept:".mdr",disabled:e,onClick:r,onFilesSelected:i,children:An(Yr,{})})}),An(Sh,{color:"black",children:t("editor.controls.actions.import_governance")})]})};import{jsx as Dh}from"react/jsx-runtime";var mr=({shortcut:e})=>Dh("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 zh,DropdownMenu as Fh,DropdownMenuContent as Wh,DropdownMenuItem as hr,DropdownMenuTrigger as Uh,Tooltip as Cn,TooltipContent as In,TooltipTrigger as Sn,useTranslation as Yh}from"lecom-ui";import{FileCodeIcon as $h,FileImageIcon as Xh,FolderOutputIcon as Kh,PrinterIcon as qh}from"lucide-react";import{useState as Zh}from"react";import{useReactFlow as Rh}from"@xyflow/react";import{toPng as yc,toSvg as Vh}from"html-to-image";import{toast as Oh,useTranslation as Hh}from"lecom-ui";import{useState as Gh}from"react";var Bh=3,gr="diagram",xc=()=>{let{t:e}=Hh(),{getNodes:t}=Rh(),{clearSelection:o}=He(),[n,r]=Gh({png:!1,html:!1,print:!1}),i=()=>{let{x:d,y:f,width:u,height:p}=La(t());return{width:u,height:p,style:{width:`${u}px`,height:`${p}px`,transform:`translate(${-d}px, ${-f}px)`}}},s=async(d,f)=>{r(N(_({},n),{[f]:!0})),await o();try{let u=Pa();if(!u)throw new Error("Flow element not found");let p=i();return await d(u,p)}catch(u){Oh({content:e("editor.controls.actions.export.feedback.error"),variant:"error"})}finally{r(N(_({},n),{[f]:!1}))}};return{exportAsPng:async(d=gr)=>{await s(async(f,u)=>{let p=await yc(f,N(_({},u),{backgroundColor:"#fcfcfc"}));wn(p,`${d}.png`)},"png")},exportAsHtml:async(d=gr)=>{await s(async(f,u)=>{let p=await Vh(f,N(_({},u),{backgroundColor:"#fcfcfc"})),h=`
5
5
  <!DOCTYPE html>
6
6
  <html>
7
7
  <head>
@@ -15,7 +15,7 @@ var sd=Object.defineProperty,ad=Object.defineProperties;var ld=Object.getOwnProp
15
15
  <img src="${p}" alt="Diagram" />
16
16
  </body>
17
17
  </html>
18
- `,m=new Blob([h],{type:"text/html"}),g=URL.createObjectURL(m);wn(g,`${d}.html`),setTimeout(()=>URL.revokeObjectURL(g),100)},"html")},printDiagram:async(d=gr)=>{await s(async(f,u)=>{let p=await yc(f,v(_({},u),{pixelRatio:Bh})),h=window.open("","_blank");if(!h)throw new Error("Failed to open print window.");let m=h.document;m.open(),m.write(`
18
+ `,m=new Blob([h],{type:"text/html"}),g=URL.createObjectURL(m);wn(g,`${d}.html`),setTimeout(()=>URL.revokeObjectURL(g),100)},"html")},printDiagram:async(d=gr)=>{await s(async(f,u)=>{let p=await yc(f,N(_({},u),{pixelRatio:Bh})),h=window.open("","_blank");if(!h)throw new Error("Failed to open print window.");let m=h.document;m.open(),m.write(`
19
19
  <!DOCTYPE html>
20
20
  <html>
21
21
  <head>
@@ -31,4 +31,4 @@ var sd=Object.defineProperty,ad=Object.defineProperties;var ld=Object.getOwnProp
31
31
  <img src="${p}" alt="Diagram" onload="window.print(); window.close();" />
32
32
  </body>
33
33
  </html>
34
- `),m.close()},"print")},isPrintingPng:n.png,isPrintingHtml:n.html,isPrinting:n.print}};import{jsx as K,jsxs as At}from"react/jsx-runtime";function Ec(){let{t:e}=Yh(),{exportAsPng:t,exportAsHtml:o,printDiagram:n,isPrinting:r,isPrintingPng:i,isPrintingHtml:s}=xc(),[a,l]=Zh(!1);return At(Fh,{modal:!1,open:a,onOpenChange:l,children:[K(Uh,{asChild:!0,children:K("div",{children:At(Cn,{children:[K(Sn,{asChild:!0,children:K(zh,{size:"small",variant:"ghost",color:"grey",iconButton:!0,children:K(Kh,{})})}),!a&&K(In,{color:"black",children:e("editor.controls.actions.export.title")})]})})}),At(Wh,{align:"center",side:"top",sideOffset:16,className:"min-w-0 flex flex-col gap-2 p-2 shadow-sm",children:[At(Cn,{children:[K(Sn,{asChild:!0,children:K(hr,{className:"p-1.5",disabled:i,onClick:()=>t(),children:K(Xh,{})})}),K(In,{side:"right",color:"black",children:e("editor.controls.actions.export.png")})]}),At(Cn,{children:[K(Sn,{asChild:!0,children:K(hr,{className:"p-1.5",disabled:s,onClick:()=>o(),children:K($h,{})})}),K(In,{side:"right",color:"black",children:e("editor.controls.actions.export.html")})]}),At(Cn,{children:[K(Sn,{asChild:!0,children:K(hr,{className:"p-1.5",disabled:r,onClick:()=>n(),children:K(qh,{})})}),K(In,{side:"right",color:"black",children:e("editor.controls.actions.export.print")})]})]})]})}import{Fragment as t0,jsx as se,jsxs as je}from"react/jsx-runtime";var vc=({nodes:e,isReadOnly:t})=>{let{t:o}=Jh(),{clearSelection:n}=He(),{isMinimapOpen:r,setIsMinimapOpen:i,isMoveTool:s,isHandTool:a,setIsMoveTool:l,setIsHandTool:c}=D(),d=_c(["v","V"]),f=_c(["h","H"]),u=bc(()=>{n(),c(!0),l(!1)},[n,c,l]),p=bc(()=>{l(!0),c(!1)},[l,c]);return Tc(()=>{d&&!s&&!t&&p()},[d,p,s,t]),Tc(()=>{f&&!a&&!t&&u()},[f,u,a,t]),je("div",{className:"flex items-center gap-2 px-3 py-2 bg-white rounded-sm shadow-md",children:[!t&&je(t0,{children:[je(xr,{children:[se(_r,{asChild:!0,children:se(yr,{size:"small",variant:"ghost",color:"grey",className:P(s&&"bg-grey-400"),iconButton:!0,onClick:p,children:se(e0,{})})}),je(Er,{color:"black",className:"flex items-center gap-2",children:[o("editor.controls.actions.move_tool"),se(mr,{shortcut:"V"})]})]}),je(xr,{children:[se(_r,{asChild:!0,children:se(yr,{size:"small",variant:"ghost",color:"grey",className:P(a&&"bg-grey-400"),iconButton:!0,onClick:u,children:se(Qh,{})})}),je(Er,{color:"black",className:"flex items-center gap-2",children:[o("editor.controls.actions.hand_tool")," ",se(mr,{shortcut:"H"})]})]})]}),se(Ec,{}),!t&&se(hc,{disabled:e.length>0}),je(xr,{children:[se(_r,{asChild:!0,children:se(yr,{size:"small",variant:"ghost",color:"grey",className:P(r&&"bg-grey-400"),iconButton:!0,onClick:()=>i(!r),children:se(jh,{})})}),se(Er,{color:"black",children:o(r?"editor.controls.actions.minimap.close":"editor.controls.actions.minimap.open")})]})]})};import{Button as Nc,Tooltip as wc,TooltipContent as Ac,TooltipTrigger as Cc,useTranslation as o0}from"lecom-ui";import{RedoIcon as n0,UndoIcon as r0}from"lucide-react";import{jsx as Be,jsxs as br}from"react/jsx-runtime";var Ic=({undo:e,redo:t,canUndo:o,canRedo:n})=>{let{t:r}=o0();return br("div",{className:"flex items-center gap-2 px-3 py-2 bg-white rounded-sm shadow-md",children:[br(wc,{children:[Be(Cc,{asChild:!0,children:Be(Nc,{size:"small",variant:"ghost",color:"grey",iconButton:!0,disabled:!o,onClick:e,children:Be(r0,{})})}),Be(Ac,{color:"black",children:r("editor.controls.history.undo")})]}),br(wc,{children:[Be(Cc,{asChild:!0,children:Be(Nc,{size:"small",variant:"ghost",color:"grey",iconButton:!0,disabled:!n,onClick:t,children:Be(n0,{})})}),Be(Ac,{color:"black",children:r("editor.controls.history.redo")})]})]})};import{useReactFlow as i0}from"@xyflow/react";import{Button as Mn,Tooltip as Pn,TooltipContent as Ln,TooltipTrigger as kn,useTranslation as s0}from"lecom-ui";import{ScanIcon as a0,ZoomIn as l0,ZoomOut as c0}from"lucide-react";import{jsx as j,jsxs as so}from"react/jsx-runtime";var Sc=()=>{let{t:e}=s0(),{zoomIn:t,zoomOut:o,zoomTo:n,fitView:r}=i0();return so("div",{className:"flex items-center gap-2 px-3 py-2 bg-white rounded-sm shadow-md",children:[so(Pn,{children:[j(kn,{asChild:!0,children:j(Mn,{size:"small",variant:"ghost",color:"grey",iconButton:!0,onClick:()=>r(),children:j(a0,{})})}),j(Ln,{color:"black",children:e("editor.controls.zoom.fit")})]}),so(Pn,{children:[j(kn,{asChild:!0,children:j(Mn,{size:"small",variant:"ghost",color:"grey",iconButton:!0,onClick:()=>o(),children:j(c0,{})})}),j(Ln,{color:"black",children:e("editor.controls.zoom.out")})]}),so(Pn,{children:[j(kn,{asChild:!0,children:j(Mn,{size:"small",variant:"ghost",color:"grey",iconButton:!0,onClick:()=>n(1),children:j(qr,{})})}),j(Ln,{color:"black",children:e("editor.controls.zoom.reset")})]}),so(Pn,{children:[j(kn,{asChild:!0,children:j(Mn,{size:"small",variant:"ghost",color:"grey",iconButton:!0,onClick:()=>t(),children:j(l0,{})})}),j(Ln,{color:"black",children:e("editor.controls.zoom.in")})]})]})};import{Button as Mc,Dialog as d0,DialogContent as u0,DialogFooter as p0,DialogHeader as f0,DialogTitle as m0,Notification as g0,Typography as Tr,useTranslation as h0}from"lecom-ui";import{jsx as Te,jsxs as vr}from"react/jsx-runtime";var Pc=({pendingDelete:e,setPendingDelete:t,nodes:o,setNodes:n,setEdges:r,saveHistory:i})=>{let{t:s}=h0(),{forceRebuildIndex:a}=ut(),l=!!e,c=()=>{let{nodes:p}=e||{};if(p!=null&&p.length){let h=o.filter(m=>!p.some(g=>g.id===m.id));p.forEach(m=>{(m==null?void 0:m.type)==="LANE"&&(m!=null&&m.parentId)&&(h=qe(m.parentId,h))}),n(Ie(h))}},d=()=>{let{edges:p}=e||{};p!=null&&p.length&&r(h=>h.filter(m=>!p.some(g=>g.id===m.id)))},f=()=>{c(),d(),i("forceSave"),a(),t(null)},u=()=>{t(null)};return Te(d0,{open:l,onOpenChange:u,children:vr(u0,{className:"w-[488px] max-w-fit gap-2",children:[Te(f0,{children:Te(m0,{children:Te(Tr,{variant:"heading-small-600",textColor:"text-grey-950",children:s("editor.modals.delete_elements.title")})})}),vr("div",{className:"flex flex-col gap-2",children:[Te("div",{className:"py-2",children:Te(g0,{type:"callout",variant:"warning",content:s("editor.modals.delete_elements.callout")})}),Te(Tr,{variant:"body-large-400",textColor:"text-grey-800",className:"py-2",children:s("editor.modals.delete_elements.content")})]}),vr(p0,{className:"flex items-center flex-row justify-end w-full gap-2",children:[Te(Mc,{variant:"outlined",color:"grey",disabled:!1,size:"small",onClick:u,children:Te(Tr,{variant:"body-medium-500",textColor:"text-grey-800",children:s("editor.modals.delete_elements.cancel")})}),Te(Mc,{size:"small",variant:"filled",color:"destructive",autoFocus:!0,onClick:f,children:s("editor.modals.delete_elements.confirm")})]})]})})};import{useReactFlow as y0}from"@xyflow/react";import{Button as x0,Tooltip as E0,TooltipContent as _0,TooltipTrigger as b0,useTranslation as T0}from"lecom-ui";import{useRef as v0,useState as N0}from"react";import{jsx as et,jsxs as Lc}from"react/jsx-runtime";var kc=()=>{let e=v0(null),{t}=T0(),{setDraggableNode:o}=ht(),{getNodes:n}=y0(),{setIsDragging:r}=D(),[i,s]=N0(void 0),a=n(),l=sn(a),c=[{type:"START_EVENT",icon:mo,label:t("bpmn.start_event.variant.default")},{type:"END_EVENT",icon:nt,label:t("bpmn.end_event.variant.default")},{type:"TASK",icon:Mt,label:t("bpmn.task.variant.default")},{type:"TASK",variant:"SUBPROCESS",icon:ei,label:t("bpmn.task.variant.subprocess")},{type:"TASK",variant:"SCRIPT",icon:jr,label:t("bpmn.task.variant.script")},{type:"TASK",attribute:"LOOP",icon:Qr,label:t("bpmn.task.attribute.loop")},{type:"GATEWAY",variant:"EXCLUSIVE",icon:it,label:t("bpmn.gateway.variant.exclusive")},{type:"GATEWAY",variant:"PARALLEL",icon:st,label:t("bpmn.gateway.variant.parallel")},{type:"GATEWAY",variant:"COMPLEX",icon:rt,label:t("bpmn.gateway.variant.complex")},{type:"LANE",icon:Kr,label:t("bpmn.lane.variant.default")},{type:"ANNOTATION",icon:fo,label:t("bpmn.annotation.variant.default")}],d=(f,u)=>{o({type:u.type,variant:u.variant,attribute:u.attribute,icon:u.icon}),s(et(u.icon,{})),f.dataTransfer.effectAllowed="move",e.current&&f.dataTransfer.setDragImage(e.current,10,10),setTimeout(()=>{r(!0)},100)};return Lc("aside",{className:"sidebar absolute z-[1] top-4 left-4",children:[et("div",{className:"grid grid-cols-1 gap-2 p-2 bg-white rounded-md shadow-md",children:c.map((f,u)=>{let p=l&&f.type==="START_EVENT",h=p?t("editor.toolbar.start_event_already_exists"):f.label;return Lc(E0,{children:[et(b0,{asChild:!0,children:et(x0,{className:P("[&>svg]:size-6",{"opacity-50 cursor-not-allowed":p}),size:"small",variant:"ghost",color:"grey",draggable:!p,disabled:p,iconButton:!0,onDragStart:p?void 0:m=>d(m,f),children:et(f.icon,{})},u)}),et(_0,{color:"black",side:"right",children:h})]},u)})}),et("div",{ref:e,className:"absolute w-0 h-0 top-0 left-0 z-[-1] bg-transparent",children:i})]})};import{Button as w0,useTranslation as A0}from"lecom-ui";import{AlertCircleIcon as C0,CircleCheckIcon as I0,XIcon as S0}from"lucide-react";import{useEffect as M0,useState as P0}from"react";import{jsx as ye,jsxs as Nr}from"react/jsx-runtime";var Dc=({validationResult:e,onClose:t})=>{let{t:o}=A0(),[n,r]=P0(!1);if(M0(()=>{e&&r(!0)},[e]),!n||!e)return null;let{isValid:i,errors:s}=e;return Nr("div",{className:P("w-72 max-w-[95vw] rounded-lg border px-4 py-2",{"bg-green-100":i,"bg-red-100":!i}),children:[Nr("div",{className:"flex flex-row items-start gap-4",children:[ye("div",{className:"flex-shrink-0",children:i?ye(I0,{className:"text-green-500 size-5"}):ye(C0,{className:"text-red-500 size-5"})}),Nr("div",{className:"body-medium-500 text-grey-800",children:[ye("div",{children:o(i?"validation.success.title":"validation.errors.title")}),!i&&ye("div",{children:o("validation.errors.subtitle")})]}),ye(w0,{variant:"ghost",size:"small",color:"grey",className:"size-5 hover:bg-transparent",iconButton:!0,onClick:()=>{r(!1),t()},children:ye(S0,{})})]}),ye("div",{className:"max-h-80 overflow-y-auto mt-2 px-9 body-medium-400 text-grey-800",children:i?ye("p",{children:o("validation.success.message")}):ye("div",{className:"list-disc list-inside",children:s.map(a=>ye("li",{className:"mb-1",children:a.message},a.id))})})]})};import{jsx as xe,jsxs as Ar}from"react/jsx-runtime";var Cr=F0((e,t)=>{let o=U0(!1),[n,r]=H0([]),[i,s,a]=O0([]),[l,c]=Y0(null),{getNodes:d,getEdges:f}=B0(),{instanceId:u,isReadOnly:p,isMinimapOpen:h,isMoveTool:m,isHandTool:g,setIsConnecting:T,setIsMultipleSelection:x}=D(),{selectElements:y,clearSelection:E}=He(),{importFromMxGraph:b,exportToMxGraph:A}=Kl(),{configureElement:N,getConfigureElement:C}=Jo();Rc(()=>(Ct.set(u,{importFromMxGraph:b,exportToMxGraph:A,selectElements:y,clearSelection:E,configureElement:N,getConfigureElement:C}),()=>{Ct.delete(u)}),[u,b,A,y,E,N,C]);let{validationResult:L,handleValidationComplete:w,clearValidation:S,isAutoValidationEnabled:M,validateDiagram:I}=ba();W0(t,()=>({selectElements:y,clearSelection:E}));let{updateHelperLines:V,HelperLines:F}=ut(),{onNodeDrag:G,onDrop:U,onDragOver:X,onNodeDragStop:O,onNodeDragStart:B}=Ga({nodes:n,setNodes:r,setEdges:s}),{isValidConnection:z,onConnect:de}=ua({setEdges:s});wa(),za();let{importFromLia:ee}=Pl(),{handleTasksStatus:ze,handleClearTaskStatus:tt}=Jl(),{clearPathEdges:ve}=Fe(),It=xo(),ao=Dn(()=>{r([]),s([]),ve(),setTimeout(()=>{It()},0)},[r,s,ve,It]),{undo:Bc,redo:zc,canUndo:Fc,canRedo:Wc,saveHistory:lo}=tc();ql({LIA_CREATE_DIAGRAM:ee,CLEAR_DIAGRAM:ao,TASKS_STATUS:ze,CLEAR_TASKS_STATUS:tt}),Rc(()=>{if(n.length===0&&i.length===0&&!p){let kr=wr(),ed={id:kr,type:"START_EVENT",position:{x:200,y:300},data:{}},Dr=wr(),td={id:Dr,type:"TASK",position:{x:400,y:270},data:{label:z0.t("editor.toolbar.initial_task")}},od=wr(),nd=v(_({},le),{id:od,source:kr,target:Dr}),rd=[ed,td],id=[nd];r(rd),s(id)}},[n.length,i.length,p,r,s]);let Uc=()=>{S()},Yc=Dn(({nodes:ue,edges:Me})=>{let ot=ue.length+Me.length>1;x(ot)},[x]);G0({onChange:Yc});let $c=Dn(()=>{if(!M){o.current=!1;return}let ue=d(),Me=f(),ot=I({nodes:ue,edges:Me});w(ot),o.current=!1},[M,d,f,I,w]),Pr=$0($c,300),Lr=Dn(()=>{M&&!o.current&&(o.current=!0,Pr())},[M,Pr]),Xc=ue=>{let Me=V(ue,n);r(ot=>L0(Me,ot)),lo(ue),Lr()},Kc=ue=>{a(ue),lo(ue),Lr()},qc=()=>{lo("forceSave")},Zc=async({nodes:ue,edges:Me})=>(c({nodes:ue,edges:Me}),!1),Jc=()=>{T(!0)},Qc=()=>{T(!1)},jc={nodes:n,edges:i};return Ar("div",{className:"w-full h-full",children:[!p&&xe(kc,{}),xe(nc,{}),Ar(R0,{id:`modeler-${u}`,edges:i,nodes:n,nodeTypes:_l,edgeTypes:bl,minZoom:Cl,maxZoom:Il,panOnDrag:g||p?!0:Ml,panOnScroll:!0,selectionOnDrag:!0,elevateEdgesOnSelect:!0,elevateNodesOnSelect:!0,elementsSelectable:!p&&m,nodesConnectable:!p&&m,nodesDraggable:!p&&m,isValidConnection:z,connectionLineComponent:Oa,selectionMode:V0.Partial,multiSelectionKeyCode:"Shift",deleteKeyCode:"Delete",selectionKeyCode:null,snapToGrid:!0,snapGrid:[5,5],defaultViewport:Sl,connectOnClick:!1,proOptions:{hideAttribution:!0},onNodesChange:Xc,onEdgesChange:Kc,onConnect:de,onDrop:U,onDropCapture:qc,onDragOver:X,onNodeDrag:G,onNodeDragStart:B,onNodeDragStop:O,onBeforeDelete:Zc,onConnectEnd:Qc,onConnectStart:Jc,children:[xe(k0,{gap:wl,size:Nl,color:vl,bgColor:Tl}),h&&xe(D0,{pannable:!0,zoomable:!0,position:Al,className:"shadow-md rounded-md"}),Ar("div",{className:"absolute z-10 bottom-4 left-1/2 -translate-x-1/2 flex gap-4",children:[!p&&xe(Ic,{canUndo:Fc,canRedo:Wc,undo:Bc,redo:zc}),xe(vc,{nodes:n,isReadOnly:p,diagram:jc,onValidationComplete:w,onValidateDiagram:I}),xe(Sc,{})]}),xe(F,{}),L&&xe("div",{className:"absolute top-6 right-6 z-[1000]",children:xe(Dc,{validationResult:L,onClose:Uc})})]}),xe(Pc,{pendingDelete:l,setPendingDelete:c,nodes:n,setNodes:r,setEdges:s,saveHistory:lo})]})});Cr.displayName="Editor";import{useStore as X0}from"@xyflow/react";import{useEffect as K0,useRef as q0}from"react";import{jsx as J0}from"react/jsx-runtime";var Z0=e=>({width:e.width,height:e.height,transform:e.transform}),Ir="rgba(51, 103, 217, 0.4)",qs=({horizontal:e,vertical:t})=>{let{width:o,height:n,transform:r}=X0(Z0),i=q0(null);return K0(()=>{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=Ir,t&&(a.beginPath(),a.strokeStyle=t.color||Ir,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||Ir,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]),J0("canvas",{ref:i,className:"w-full h-full absolute z-10 pointer-events-none"})};import{i18n as j0,Notification as ey,TooltipProvider as ty}from"lecom-ui";import{createContext as oy,useContext as ny,useEffect as ry,useState as iy}from"react";import{jsx as Vc,jsxs as ay}from"react/jsx-runtime";var Ct=new Map,Oc=oy(null),Sr=()=>{let e=ny(Oc);if(!e)throw new Error("useModeler must be used within an <ModelerProvider />");return e},sy=({locale:e,defaultMode:t="edit",children:o})=>{let[n,r]=iy(e||"pt_BR");ry(()=>{e&&(r(e),j0.changeLanguage(e))},[e]);let i=u=>{let p=Ct.size;if(p===0)throw new Error("No modeler instances found");if(p===1||!u){let[m]=Ct.values();return m}let h=Ct.get(u);if(!h)throw new Error(`Modeler instance with ID "${u}" not found`);return h},s=(u,p)=>{let h=i(p);return h==null?void 0:h.selectElements(u)},a=async u=>{let p=i(u);return p==null?void 0:p.clearSelection()},l=(u,p)=>{let h=i(p);return h==null?void 0:h.configureElement(u)},c=(u,p)=>{let h=i(p);return h==null?void 0:h.getConfigureElement(u)},d=async(u,p)=>{let h=i(p);await(h==null?void 0:h.importFromMxGraph(u))},f=u=>{let p=i(u);return p==null?void 0:p.exportToMxGraph()};return Vc(Oc.Provider,{value:{defaultMode:t,locale:n,selectElements:s,clearSelection:a,configureElement:l,getConfigureElement:c,importDiagram:d,exportDiagram:f},children:ay(ty,{children:[Vc(ey,{type:"toast",placement:"topRight",enableClose:!0,showProgress:!0,pauseOnHover:!0}),o]})})};import{jsx as Mr}from"react/jsx-runtime";var Gc=cy(null),D=()=>{let e=dy(Gc);if(!e)throw new Error("useModelerInstance must be used within an <Modeler />");return e},py=({selectorRef:e,instanceId:t,mode:o,onConfigureElement:n,onSubprocessValidationClick:r})=>{let{defaultMode:i}=Sr(),s=uy(),[a]=Se(t||s),[l,c]=Se(o||i||"edit"),[d,f]=Se(!0),[u,p]=Se(!1),[h,m]=Se(!1),[g,T]=Se(!1),[x,y]=Se(!1),[E,b]=Se(!1),[A,N]=Se(!1);return Hc(()=>{o&&c(o)},[o]),Hc(()=>{m(l==="readonly")},[l]),Mr(ly,{children:Mr(Gc.Provider,{value:{instanceId:a,isReadOnly:h,isMinimapOpen:g,isMoveTool:d,isHandTool:u,isDragging:x,isMultipleSelection:A,isConnecting:E,setIsMinimapOpen:T,setIsMoveTool:f,setIsHandTool:p,setIsDragging:y,setIsConnecting:b,setIsMultipleSelection:N,onConfigureElement:n,onSubprocessValidationClick:r},children:Mr(Cr,{ref:e})})})};export{Vn as ElementPosition,uo as ElementType,On as GatewayElementVariant,ge as GatewayVariant,py as Modeler,sy as ModelerProvider,Le as NodeAttribute,k as NodeType,me as NodeVariant,Hn as RoutingVariant,Sr as useModeler};
34
+ `),m.close()},"print")},isPrintingPng:n.png,isPrintingHtml:n.html,isPrinting:n.print}};import{jsx as K,jsxs as At}from"react/jsx-runtime";function Ec(){let{t:e}=Yh(),{exportAsPng:t,exportAsHtml:o,printDiagram:n,isPrinting:r,isPrintingPng:i,isPrintingHtml:s}=xc(),[a,l]=Zh(!1);return At(Fh,{modal:!1,open:a,onOpenChange:l,children:[K(Uh,{asChild:!0,children:K("div",{children:At(Cn,{children:[K(Sn,{asChild:!0,children:K(zh,{size:"small",variant:"ghost",color:"grey",iconButton:!0,children:K(Kh,{})})}),!a&&K(In,{color:"black",children:e("editor.controls.actions.export.title")})]})})}),At(Wh,{align:"center",side:"top",sideOffset:16,className:"min-w-0 flex flex-col gap-2 p-2 shadow-sm",children:[At(Cn,{children:[K(Sn,{asChild:!0,children:K(hr,{className:"p-1.5",disabled:i,onClick:()=>t(),children:K(Xh,{})})}),K(In,{side:"right",color:"black",children:e("editor.controls.actions.export.png")})]}),At(Cn,{children:[K(Sn,{asChild:!0,children:K(hr,{className:"p-1.5",disabled:s,onClick:()=>o(),children:K($h,{})})}),K(In,{side:"right",color:"black",children:e("editor.controls.actions.export.html")})]}),At(Cn,{children:[K(Sn,{asChild:!0,children:K(hr,{className:"p-1.5",disabled:r,onClick:()=>n(),children:K(qh,{})})}),K(In,{side:"right",color:"black",children:e("editor.controls.actions.export.print")})]})]})]})}import{Fragment as t0,jsx as se,jsxs as je}from"react/jsx-runtime";var vc=({nodes:e,isReadOnly:t})=>{let{t:o}=Jh(),{clearSelection:n}=He(),{isMinimapOpen:r,setIsMinimapOpen:i,isMoveTool:s,isHandTool:a,setIsMoveTool:l,setIsHandTool:c}=D(),d=_c(["v","V"]),f=_c(["h","H"]),u=bc(()=>{n(),c(!0),l(!1)},[n,c,l]),p=bc(()=>{l(!0),c(!1)},[l,c]);return Tc(()=>{d&&!s&&!t&&p()},[d,p,s,t]),Tc(()=>{f&&!a&&!t&&u()},[f,u,a,t]),je("div",{className:"flex items-center gap-2 px-3 py-2 bg-white rounded-sm shadow-md",children:[!t&&je(t0,{children:[je(xr,{children:[se(_r,{asChild:!0,children:se(yr,{size:"small",variant:"ghost",color:"grey",className:P(s&&"bg-grey-400"),iconButton:!0,onClick:p,children:se(e0,{})})}),je(Er,{color:"black",className:"flex items-center gap-2",children:[o("editor.controls.actions.move_tool"),se(mr,{shortcut:"V"})]})]}),je(xr,{children:[se(_r,{asChild:!0,children:se(yr,{size:"small",variant:"ghost",color:"grey",className:P(a&&"bg-grey-400"),iconButton:!0,onClick:u,children:se(Qh,{})})}),je(Er,{color:"black",className:"flex items-center gap-2",children:[o("editor.controls.actions.hand_tool")," ",se(mr,{shortcut:"H"})]})]})]}),se(Ec,{}),!t&&se(hc,{disabled:e.length>0}),je(xr,{children:[se(_r,{asChild:!0,children:se(yr,{size:"small",variant:"ghost",color:"grey",className:P(r&&"bg-grey-400"),iconButton:!0,onClick:()=>i(!r),children:se(jh,{})})}),se(Er,{color:"black",children:o(r?"editor.controls.actions.minimap.close":"editor.controls.actions.minimap.open")})]})]})};import{Button as Nc,Tooltip as wc,TooltipContent as Ac,TooltipTrigger as Cc,useTranslation as o0}from"lecom-ui";import{RedoIcon as n0,UndoIcon as r0}from"lucide-react";import{jsx as Be,jsxs as br}from"react/jsx-runtime";var Ic=({undo:e,redo:t,canUndo:o,canRedo:n})=>{let{t:r}=o0();return br("div",{className:"flex items-center gap-2 px-3 py-2 bg-white rounded-sm shadow-md",children:[br(wc,{children:[Be(Cc,{asChild:!0,children:Be(Nc,{size:"small",variant:"ghost",color:"grey",iconButton:!0,disabled:!o,onClick:e,children:Be(r0,{})})}),Be(Ac,{color:"black",children:r("editor.controls.history.undo")})]}),br(wc,{children:[Be(Cc,{asChild:!0,children:Be(Nc,{size:"small",variant:"ghost",color:"grey",iconButton:!0,disabled:!n,onClick:t,children:Be(n0,{})})}),Be(Ac,{color:"black",children:r("editor.controls.history.redo")})]})]})};import{useReactFlow as i0}from"@xyflow/react";import{Button as Mn,Tooltip as Pn,TooltipContent as Ln,TooltipTrigger as kn,useTranslation as s0}from"lecom-ui";import{ScanIcon as a0,ZoomIn as l0,ZoomOut as c0}from"lucide-react";import{jsx as j,jsxs as so}from"react/jsx-runtime";var Sc=()=>{let{t:e}=s0(),{zoomIn:t,zoomOut:o,zoomTo:n,fitView:r}=i0();return so("div",{className:"flex items-center gap-2 px-3 py-2 bg-white rounded-sm shadow-md",children:[so(Pn,{children:[j(kn,{asChild:!0,children:j(Mn,{size:"small",variant:"ghost",color:"grey",iconButton:!0,onClick:()=>r(),children:j(a0,{})})}),j(Ln,{color:"black",children:e("editor.controls.zoom.fit")})]}),so(Pn,{children:[j(kn,{asChild:!0,children:j(Mn,{size:"small",variant:"ghost",color:"grey",iconButton:!0,onClick:()=>o(),children:j(c0,{})})}),j(Ln,{color:"black",children:e("editor.controls.zoom.out")})]}),so(Pn,{children:[j(kn,{asChild:!0,children:j(Mn,{size:"small",variant:"ghost",color:"grey",iconButton:!0,onClick:()=>n(1),children:j(qr,{})})}),j(Ln,{color:"black",children:e("editor.controls.zoom.reset")})]}),so(Pn,{children:[j(kn,{asChild:!0,children:j(Mn,{size:"small",variant:"ghost",color:"grey",iconButton:!0,onClick:()=>t(),children:j(l0,{})})}),j(Ln,{color:"black",children:e("editor.controls.zoom.in")})]})]})};import{Button as Mc,Dialog as d0,DialogContent as u0,DialogFooter as p0,DialogHeader as f0,DialogTitle as m0,Notification as g0,Typography as Tr,useTranslation as h0}from"lecom-ui";import{jsx as Te,jsxs as vr}from"react/jsx-runtime";var Pc=({pendingDelete:e,setPendingDelete:t,nodes:o,setNodes:n,setEdges:r,saveHistory:i})=>{let{t:s}=h0(),{forceRebuildIndex:a}=ut(),l=!!e,c=()=>{let{nodes:p}=e||{};if(p!=null&&p.length){let h=o.filter(m=>!p.some(g=>g.id===m.id));p.forEach(m=>{(m==null?void 0:m.type)==="LANE"&&(m!=null&&m.parentId)&&(h=qe(m.parentId,h))}),n(Ie(h))}},d=()=>{let{edges:p}=e||{};p!=null&&p.length&&r(h=>h.filter(m=>!p.some(g=>g.id===m.id)))},f=()=>{c(),d(),i("forceSave"),a(),t(null)},u=()=>{t(null)};return Te(d0,{open:l,onOpenChange:u,children:vr(u0,{className:"w-[488px] max-w-fit gap-2",children:[Te(f0,{children:Te(m0,{children:Te(Tr,{variant:"heading-small-600",textColor:"text-grey-950",children:s("editor.modals.delete_elements.title")})})}),vr("div",{className:"flex flex-col gap-2",children:[Te("div",{className:"py-2",children:Te(g0,{type:"callout",variant:"warning",content:s("editor.modals.delete_elements.callout")})}),Te(Tr,{variant:"body-large-400",textColor:"text-grey-800",className:"py-2",children:s("editor.modals.delete_elements.content")})]}),vr(p0,{className:"flex items-center flex-row justify-end w-full gap-2",children:[Te(Mc,{variant:"outlined",color:"grey",disabled:!1,size:"small",onClick:u,children:Te(Tr,{variant:"body-medium-500",textColor:"text-grey-800",children:s("editor.modals.delete_elements.cancel")})}),Te(Mc,{size:"small",variant:"filled",color:"destructive",autoFocus:!0,onClick:f,children:s("editor.modals.delete_elements.confirm")})]})]})})};import{useReactFlow as y0}from"@xyflow/react";import{Button as x0,Tooltip as E0,TooltipContent as _0,TooltipTrigger as b0,useTranslation as T0}from"lecom-ui";import{useRef as v0,useState as N0}from"react";import{jsx as et,jsxs as Lc}from"react/jsx-runtime";var kc=()=>{let e=v0(null),{t}=T0(),{setDraggableNode:o}=ht(),{getNodes:n}=y0(),{setIsDragging:r}=D(),[i,s]=N0(void 0),a=n(),l=sn(a),c=[{type:"START_EVENT",icon:mo,label:t("bpmn.start_event.variant.default")},{type:"END_EVENT",icon:nt,label:t("bpmn.end_event.variant.default")},{type:"TASK",icon:Mt,label:t("bpmn.task.variant.default")},{type:"TASK",variant:"SUBPROCESS",icon:ei,label:t("bpmn.task.variant.subprocess")},{type:"TASK",variant:"SCRIPT",icon:jr,label:t("bpmn.task.variant.script")},{type:"TASK",attribute:"LOOP",icon:Qr,label:t("bpmn.task.attribute.loop")},{type:"GATEWAY",variant:"EXCLUSIVE",icon:it,label:t("bpmn.gateway.variant.exclusive")},{type:"GATEWAY",variant:"PARALLEL",icon:st,label:t("bpmn.gateway.variant.parallel")},{type:"GATEWAY",variant:"COMPLEX",icon:rt,label:t("bpmn.gateway.variant.complex")},{type:"LANE",icon:Kr,label:t("bpmn.lane.variant.default")},{type:"ANNOTATION",icon:fo,label:t("bpmn.annotation.variant.default")}],d=(f,u)=>{o({type:u.type,variant:u.variant,attribute:u.attribute,icon:u.icon}),s(et(u.icon,{})),f.dataTransfer.effectAllowed="move",e.current&&f.dataTransfer.setDragImage(e.current,10,10),setTimeout(()=>{r(!0)},100)};return Lc("aside",{className:"sidebar absolute z-[1] top-4 left-4",children:[et("div",{className:"grid grid-cols-1 gap-2 p-2 bg-white rounded-md shadow-md",children:c.map((f,u)=>{let p=l&&f.type==="START_EVENT",h=p?t("editor.toolbar.start_event_already_exists"):f.label;return Lc(E0,{children:[et(b0,{asChild:!0,children:et(x0,{className:P("[&>svg]:size-6",{"opacity-50 cursor-not-allowed":p}),size:"small",variant:"ghost",color:"grey",draggable:!p,disabled:p,iconButton:!0,onDragStart:p?void 0:m=>d(m,f),children:et(f.icon,{})},u)}),et(_0,{color:"black",side:"right",children:h})]},u)})}),et("div",{ref:e,className:"absolute w-0 h-0 top-0 left-0 z-[-1] bg-transparent",children:i})]})};import{Button as w0,useTranslation as A0}from"lecom-ui";import{AlertCircleIcon as C0,CircleCheckIcon as I0,XIcon as S0}from"lucide-react";import{useEffect as M0,useState as P0}from"react";import{jsx as ye,jsxs as Nr}from"react/jsx-runtime";var Dc=({validationResult:e,onClose:t})=>{let{t:o}=A0(),[n,r]=P0(!1);if(M0(()=>{e&&r(!0)},[e]),!n||!e)return null;let{isValid:i,errors:s}=e;return Nr("div",{className:P("w-72 max-w-[95vw] rounded-lg border px-4 py-2",{"bg-green-100":i,"bg-red-100":!i}),children:[Nr("div",{className:"flex flex-row items-start gap-4",children:[ye("div",{className:"flex-shrink-0",children:i?ye(I0,{className:"text-green-500 size-5"}):ye(C0,{className:"text-red-500 size-5"})}),Nr("div",{className:"body-medium-500 text-grey-800",children:[ye("div",{children:o(i?"validation.success.title":"validation.errors.title")}),!i&&ye("div",{children:o("validation.errors.subtitle")})]}),ye(w0,{variant:"ghost",size:"small",color:"grey",className:"size-5 hover:bg-transparent",iconButton:!0,onClick:()=>{r(!1),t()},children:ye(S0,{})})]}),ye("div",{className:"max-h-80 overflow-y-auto mt-2 px-9 body-medium-400 text-grey-800",children:i?ye("p",{children:o("validation.success.message")}):ye("div",{className:"list-disc list-inside",children:s.map(a=>ye("li",{className:"mb-1",children:a.message},a.id))})})]})};import{jsx as xe,jsxs as Ar}from"react/jsx-runtime";var Cr=F0((e,t)=>{let o=U0(!1),[n,r]=H0([]),[i,s,a]=O0([]),[l,c]=Y0(null),{getNodes:d,getEdges:f}=B0(),{instanceId:u,isReadOnly:p,isMinimapOpen:h,isMoveTool:m,isHandTool:g,setIsConnecting:T,setIsMultipleSelection:x}=D(),{selectElements:y,clearSelection:E}=He(),{importFromMxGraph:b,exportToMxGraph:A}=Kl(),{configureElement:v,getConfigureElement:C}=Jo();Rc(()=>(Ct.set(u,{importFromMxGraph:b,exportToMxGraph:A,selectElements:y,clearSelection:E,configureElement:v,getConfigureElement:C}),()=>{Ct.delete(u)}),[u,b,A,y,E,v,C]);let{validationResult:L,handleValidationComplete:w,clearValidation:S,isAutoValidationEnabled:M,validateDiagram:I}=ba();W0(t,()=>({selectElements:y,clearSelection:E}));let{updateHelperLines:V,HelperLines:F}=ut(),{onNodeDrag:G,onDrop:U,onDragOver:X,onNodeDragStop:O,onNodeDragStart:B}=Ga({nodes:n,setNodes:r,setEdges:s}),{isValidConnection:z,onConnect:de}=ua({setEdges:s});wa(),za();let{importFromLia:ee}=Pl(),{handleTasksStatus:ze,handleClearTaskStatus:tt}=Jl(),{clearPathEdges:ve}=Fe(),It=xo(),ao=Dn(()=>{r([]),s([]),ve(),setTimeout(()=>{It()},0)},[r,s,ve,It]),{undo:Bc,redo:zc,canUndo:Fc,canRedo:Wc,saveHistory:lo}=tc();ql({LIA_CREATE_DIAGRAM:ee,CLEAR_DIAGRAM:ao,TASKS_STATUS:ze,CLEAR_TASKS_STATUS:tt}),Rc(()=>{if(n.length===0&&i.length===0&&!p){let kr=wr(),ed={id:kr,type:"START_EVENT",position:{x:200,y:300},data:{}},Dr=wr(),td={id:Dr,type:"TASK",position:{x:400,y:270},data:{label:z0.t("editor.toolbar.initial_task")}},od=wr(),nd=N(_({},le),{id:od,source:kr,target:Dr}),rd=[ed,td],id=[nd];r(rd),s(id)}},[n.length,i.length,p,r,s]);let Uc=()=>{S()},Yc=Dn(({nodes:ue,edges:Me})=>{let ot=ue.length+Me.length>1;x(ot)},[x]);G0({onChange:Yc});let $c=Dn(()=>{if(!M){o.current=!1;return}let ue=d(),Me=f(),ot=I({nodes:ue,edges:Me});w(ot),o.current=!1},[M,d,f,I,w]),Pr=$0($c,300),Lr=Dn(()=>{M&&!o.current&&(o.current=!0,Pr())},[M,Pr]),Xc=ue=>{let Me=V(ue,n);r(ot=>L0(Me,ot)),lo(ue),Lr()},Kc=ue=>{a(ue),lo(ue),Lr()},qc=()=>{lo("forceSave")},Zc=async({nodes:ue,edges:Me})=>(c({nodes:ue,edges:Me}),!1),Jc=()=>{T(!0)},Qc=()=>{T(!1)},jc={nodes:n,edges:i};return Ar("div",{className:"w-full h-full",children:[!p&&xe(kc,{}),xe(nc,{}),Ar(R0,{id:`modeler-${u}`,edges:i,nodes:n,nodeTypes:_l,edgeTypes:bl,minZoom:Cl,maxZoom:Il,panOnDrag:g||p?!0:Ml,panOnScroll:!0,selectionOnDrag:!0,elevateEdgesOnSelect:!0,elevateNodesOnSelect:!0,elementsSelectable:!p&&m,nodesConnectable:!p&&m,nodesDraggable:!p&&m,isValidConnection:z,connectionLineComponent:Oa,selectionMode:V0.Partial,multiSelectionKeyCode:"Shift",deleteKeyCode:"Delete",selectionKeyCode:null,snapToGrid:!0,snapGrid:[5,5],defaultViewport:Sl,connectOnClick:!1,proOptions:{hideAttribution:!0},onNodesChange:Xc,onEdgesChange:Kc,onConnect:de,onDrop:U,onDropCapture:qc,onDragOver:X,onNodeDrag:G,onNodeDragStart:B,onNodeDragStop:O,onBeforeDelete:Zc,onConnectEnd:Qc,onConnectStart:Jc,children:[xe(k0,{gap:wl,size:Nl,color:vl,bgColor:Tl}),h&&xe(D0,{pannable:!0,zoomable:!0,position:Al,className:"shadow-md rounded-md"}),Ar("div",{className:"absolute z-10 bottom-4 left-1/2 -translate-x-1/2 flex gap-4",children:[!p&&xe(Ic,{canUndo:Fc,canRedo:Wc,undo:Bc,redo:zc}),xe(vc,{nodes:n,isReadOnly:p,diagram:jc,onValidationComplete:w,onValidateDiagram:I}),xe(Sc,{})]}),xe(F,{}),L&&xe("div",{className:"absolute top-6 right-6 z-[1000]",children:xe(Dc,{validationResult:L,onClose:Uc})})]}),xe(Pc,{pendingDelete:l,setPendingDelete:c,nodes:n,setNodes:r,setEdges:s,saveHistory:lo})]})});Cr.displayName="Editor";import{useStore as X0}from"@xyflow/react";import{useEffect as K0,useRef as q0}from"react";import{jsx as J0}from"react/jsx-runtime";var Z0=e=>({width:e.width,height:e.height,transform:e.transform}),Ir="rgba(51, 103, 217, 0.4)",qs=({horizontal:e,vertical:t})=>{let{width:o,height:n,transform:r}=X0(Z0),i=q0(null);return K0(()=>{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=Ir,t&&(a.beginPath(),a.strokeStyle=t.color||Ir,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||Ir,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]),J0("canvas",{ref:i,className:"w-full h-full absolute z-10 pointer-events-none"})};import{i18n as j0,Notification as ey,TooltipProvider as ty}from"lecom-ui";import{createContext as oy,useContext as ny,useEffect as ry,useState as iy}from"react";import{jsx as Vc,jsxs as ay}from"react/jsx-runtime";var Ct=new Map,Oc=oy(null),Sr=()=>{let e=ny(Oc);if(!e)throw new Error("useModeler must be used within an <ModelerProvider />");return e},sy=({locale:e,defaultMode:t="edit",children:o})=>{let[n,r]=iy(e||"pt_BR");ry(()=>{e&&(r(e),j0.changeLanguage(e))},[e]);let i=u=>{let p=Ct.size;if(p===0)throw new Error("No modeler instances found");if(p===1||!u){let[m]=Ct.values();return m}let h=Ct.get(u);if(!h)throw new Error(`Modeler instance with ID "${u}" not found`);return h},s=(u,p)=>{let h=i(p);return h==null?void 0:h.selectElements(u)},a=async u=>{let p=i(u);return p==null?void 0:p.clearSelection()},l=(u,p)=>{let h=i(p);return h==null?void 0:h.configureElement(u)},c=(u,p)=>{let h=i(p);return h==null?void 0:h.getConfigureElement(u)},d=async(u,p)=>{let h=i(p);await(h==null?void 0:h.importFromMxGraph(u))},f=u=>{let p=i(u);return p==null?void 0:p.exportToMxGraph()};return Vc(Oc.Provider,{value:{defaultMode:t,locale:n,selectElements:s,clearSelection:a,configureElement:l,getConfigureElement:c,importDiagram:d,exportDiagram:f},children:ay(ty,{children:[Vc(ey,{type:"toast",placement:"topRight",enableClose:!0,showProgress:!0,pauseOnHover:!0}),o]})})};import{jsx as Mr}from"react/jsx-runtime";var Gc=cy(null),D=()=>{let e=dy(Gc);if(!e)throw new Error("useModelerInstance must be used within an <Modeler />");return e},py=({selectorRef:e,instanceId:t,mode:o,onConfigureElement:n,onSubprocessValidationClick:r})=>{let{defaultMode:i}=Sr(),s=uy(),[a]=Se(t||s),[l,c]=Se(o||i||"edit"),[d,f]=Se(!0),[u,p]=Se(!1),[h,m]=Se(!1),[g,T]=Se(!1),[x,y]=Se(!1),[E,b]=Se(!1),[A,v]=Se(!1);return Hc(()=>{o&&c(o)},[o]),Hc(()=>{m(l==="readonly")},[l]),Mr(ly,{children:Mr(Gc.Provider,{value:{instanceId:a,isReadOnly:h,isMinimapOpen:g,isMoveTool:d,isHandTool:u,isDragging:x,isMultipleSelection:A,isConnecting:E,setIsMinimapOpen:T,setIsMoveTool:f,setIsHandTool:p,setIsDragging:y,setIsConnecting:b,setIsMultipleSelection:v,onConfigureElement:n,onSubprocessValidationClick:r},children:Mr(Cr,{ref:e})})})};export{Vn as ElementPosition,uo as ElementType,On as GatewayElementVariant,ge as GatewayVariant,py as Modeler,sy as ModelerProvider,Le as NodeAttribute,k as NodeType,me as NodeVariant,Hn as RoutingVariant,Sr as useModeler};