lecom-modeler 0.2.0 → 0.2.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/index.cjs +10 -10
- package/lib/index.js +10 -10
- package/lib/style.min.css +1 -1
- package/package.json +1 -1
package/lib/index.js
CHANGED
|
@@ -1,25 +1,25 @@
|
|
|
1
|
-
var pa=Object.defineProperty,ua=Object.defineProperties;var ma=Object.getOwnPropertyDescriptors;var Je=Object.getOwnPropertySymbols;var yo=Object.prototype.hasOwnProperty,To=Object.prototype.propertyIsEnumerable;var vo=(e,t,o)=>t in e?pa(e,t,{enumerable:!0,configurable:!0,writable:!0,value:o}):e[t]=o,_=(e,t)=>{for(var o in t||(t={}))yo.call(t,o)&&vo(e,o,t[o]);if(Je)for(var o of Je(t))To.call(t,o)&&vo(e,o,t[o]);return e},I=(e,t)=>ua(e,ma(t));var le=(e,t)=>{var o={};for(var n in e)yo.call(e,n)&&t.indexOf(n)<0&&(o[n]=e[n]);if(e!=null&&Je)for(var n of Je(e))t.indexOf(n)<0&&To.call(e,n)&&(o[n]=e[n]);return o};import{TooltipProvider as ga,Notification as fa}from"lecom-ui";import{jsx as Ea,jsxs as ba}from"react/jsx-runtime";function No({children:e}){return ba(ga,{children:[Ea(fa,{type:"toast",placement:"topRight",enableClose:!0,showProgress:!0,pauseOnHover:!0}),e]})}import{Background as Wd,MiniMap as Yd,ReactFlow as Kd,ReactFlowProvider as $d,SelectionMode as Xd,useEdgesState as Zd,useNodesState as qd,useOnSelectionChange as jd,useReactFlow as Jd}from"@xyflow/react";import{i18n as Ur}from"lecom-ui";import{forwardRef as Qd,useCallback as co,useEffect as mo,useImperativeHandle as ec,useRef as tc,useState as oc}from"react";import{useDebouncedCallback as nc}from"use-debounce";import{v7 as po}from"uuid";var zt=(a=>(a.ACTIVITY="activity",a.ROUTING="routing",a.GATEWAY="gateway",a.SUB_PROCESS="sub_process",a))(zt||{}),Ft=(n=>(n.START="start",n.END="end",n.BETWEEN="between",n))(Ft||{}),Ut=(l=>(l.SIMPLE="simple",l.LOOP="loop",l.SCRIPT="script",l.COMPLEX="complex",l.EXCLUSIVE="exclusive",l.PARALLEL="parallel",l.FINAL="final",l.TO_SUB_PROCESS="to_sub_process",l))(Ut||{}),Wt=(n=>(n.SCRIPT="script",n.LOOP="loop",n.SCRIPT_LOOP="script_loop",n))(Wt||{}),Yt=(o=>(o.SCRIPT="script",o.LOOP="loop",o))(Yt||{});import{RotateCcw as Sa,ScrollText as ka,SquarePlus as La}from"lucide-react";import{jsx as Qe,jsxs as ha}from"react/jsx-runtime";var et=({size:e=24,className:t})=>ha("svg",{width:e,height:e,viewBox:"0 0 24 24",xmlns:"http://www.w3.org/2000/svg",fill:"#6b7280",className:t,children:[Qe("path",{strokeWidth:"2",d:"M16 3V3.5085V11.9998V20.4915V21H16.5411H21.4592H22V19.123H21.4592H17.9974V11.9998V4.8773H21.4592H22V3H21.4592H16.5411H16Z"}),Qe("path",{d:"M4.41026 16.9999L2 18.7861L3.89693 21.1103L6.3072 19.324L4.41026 16.9999Z"}),Qe("path",{d:"M8.41026 13.9999L6 15.7861L7.89693 18.1103L10.3072 16.324L8.41026 13.9999Z"}),Qe("path",{d:"M12.4313 10.954L10.021 12.7402L11.9179 15.0644L14.3282 13.2781L12.4313 10.954Z"})]});import{jsx as _o}from"react/jsx-runtime";var Ne=({size:e=24,className:t})=>_o("svg",{width:e,height:e,viewBox:"0 0 24 24",xmlns:"http://www.w3.org/2000/svg",fill:"#f87171",stroke:"#ef4444",strokeWidth:3,className:t,children:_o("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 De,jsxs as va}from"react/jsx-runtime";var tt=({size:e=24,className:t})=>va("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:[De("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"}),De("path",{d:"M12 8V16",strokeLinecap:"round",strokeLinejoin:"round"}),De("path",{d:"M8 12H16",strokeLinecap:"round",strokeLinejoin:"round"}),De("path",{d:"M9.17139 9.17188L14.8282 14.8287",strokeLinecap:"round",strokeLinejoin:"round"}),De("path",{d:"M14.8281 9.17188L9.17127 14.8287",strokeLinecap:"round",strokeLinejoin:"round"})]});import{jsx as Kt,jsxs as ya}from"react/jsx-runtime";var _e=({size:e=24,className:t})=>ya("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:[Kt("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"}),Kt("path",{d:"M14.8286 9.17188L9.17176 14.8287",strokeLinecap:"round",strokeLinejoin:"round"}),Kt("path",{d:"M9.17139 9.17188L14.8282 14.8287",strokeLinecap:"round",strokeLinejoin:"round"})]});import{jsx as $t,jsxs as Ta}from"react/jsx-runtime";var ot=({size:e=24,className:t})=>Ta("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:[$t("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"}),$t("path",{d:"M12 8V16",strokeLinecap:"round",strokeLinejoin:"round"}),$t("path",{d:"M8 12H16",strokeLinecap:"round",strokeLinejoin:"round"})]});import{jsx as Xt,jsxs as Na}from"react/jsx-runtime";var xo=({size:e=24,className:t})=>Xt("svg",{width:e,height:e,viewBox:"0 0 34 24",xmlns:"http://www.w3.org/2000/svg",fill:"currentColor",className:t,children:Na("g",{children:[Xt("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"}),Xt("path",{d:"M24.5 4.5L28 1M28 1L31.5 4.5M28 1V8",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round"})]})});import{clsx as _a}from"clsx";import{twMerge as xa}from"tailwind-merge";function L(...e){return xa(_a(e))}var Re=(e,t)=>e<t?t:e;import{jsx as wo,jsxs as wa}from"react/jsx-runtime";var Co=({size:e=24,className:t})=>wa("svg",{width:e,height:e,viewBox:"0 0 24 24",fill:"none",stroke:"#6b7280",strokeWidth:2,xmlns:"http://www.w3.org/2000/svg",className:L("stroke-2",t),children:[wo("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"}),wo("path",{d:"M9 3V21",strokeLinecap:"round",strokeLinejoin:"round"})]});import{jsx as Zt}from"react/jsx-runtime";var Ao=({size:e=24,className:t})=>Zt("svg",{width:e,height:e,viewBox:"0 0 24 24",xmlns:"http://www.w3.org/2000/svg",stroke:"currentColor",className:t,children:Zt("g",{children:Zt("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 Io}from"react/jsx-runtime";var nt=({size:e=24,className:t})=>Io("svg",{width:e,height:e,viewBox:"0 0 24 24",xmlns:"http://www.w3.org/2000/svg",fill:"#84cc16",stroke:"#65a30d",strokeWidth:"2",className:t,children:Io("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 So}from"react/jsx-runtime";var Ve=({size:e=24,className:t})=>So("svg",{width:e,height:e,viewBox:"0 0 24 24",xmlns:"http://www.w3.org/2000/svg",fill:"white",stroke:"#6b7280",className:L("stroke-2",t),children:So("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 qt,jsxs as Ca}from"react/jsx-runtime";var ko=({size:e=24,className:t})=>Ca("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:[qt("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"}),qt("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"}),qt("path",{d:"M7.5 7.5V10H10",strokeWidth:"1.5",fill:"none",strokeLinecap:"round",strokeLinejoin:"round"})]});import{jsx as Me,jsxs as Aa}from"react/jsx-runtime";var Lo=({size:e=24,className:t})=>Aa("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:[Me("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"}),Me("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"}),Me("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"}),Me("path",{d:"M13.5 12H11",strokeWidth:"1",strokeLinecap:"round",strokeLinejoin:"round"}),Me("path",{d:"M13.5 10H11",strokeWidth:"1",strokeLinecap:"round",strokeLinejoin:"round"})]});import{jsx as rt,jsxs as Ia}from"react/jsx-runtime";var Po=({size:e=24,className:t})=>Ia("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:[rt("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"}),rt("path",{d:"M8 21V14C8 13.4477 8.44772 13 9 13H15C15.5523 13 16 13.4477 16 14V21",strokeWidth:"1",fill:"none"}),rt("path",{d:"M10.2222 17H13.7777",strokeWidth:"1",strokeLinecap:"round",strokeLinejoin:"round"}),rt("path",{d:"M12 15.2227V18.7782",strokeWidth:"1",strokeLinecap:"round",strokeLinejoin:"round"})]});var V=(r=>(r.START_EVENT="START_EVENT",r.END_EVENT="END_EVENT",r.TASK="TASK",r.LANE="LANE",r.GATEWAY="GATEWAY",r.ANNOTATION="ANNOTATION",r.UNSUPPORTED="UNSUPPORTED",r))(V||{});var at={SCRIPT:{icon:ka},SUBPROCESS:{icon:La}};var it={LOOP:{icon:Sa}},te=(n=>(n.EXCLUSIVE="EXCLUSIVE",n.PARALLEL="PARALLEL",n.COMPLEX="COMPLEX",n))(te||{}),st={EXCLUSIVE:{icon:_e},PARALLEL:{icon:ot},COMPLEX:{icon:tt}};import Vo from"@dagrejs/dagre";import{getNodesBounds as Ha}from"@xyflow/react";import{orderBy as Ba}from"lodash";var Pa={MIN_WIDTH:36,MIN_HEIGHT:36},Da={MIN_WIDTH:36,MIN_HEIGHT:36},Ra={MIN_WIDTH:56,MIN_HEIGHT:56},lt={MIN_WIDTH:176,MIN_HEIGHT:96},dt={HEADER_WIDTH:40,MIN_WIDTH:840,MIN_HEIGHT:256},$={HEADER_WIDTH:40,MIN_WIDTH:800,MIN_HEIGHT:256},ct={MIN_WIDTH:176,MIN_HEIGHT:64},Va={MIN_WIDTH:128,MIN_HEIGHT:64},H={START_EVENT:Pa,END_EVENT:Da,GATEWAY:Ra,TASK:lt,LANE:$,ANNOTATION:ct,UNSUPPORTED:Va};import{orderBy as Ma}from"lodash";var de=e=>{var t,o,n,a,i,s,r,l;return{x:(o=(t=e.internals)==null?void 0:t.positionAbsolute.x)!=null?o:0,y:(a=(n=e.internals)==null?void 0:n.positionAbsolute.y)!=null?a:0,w:(s=(i=e.measured)==null?void 0:i.width)!=null?s:0,h:(l=(r=e.measured)==null?void 0:r.height)!=null?l:0}},ce=e=>Ma(e,[t=>t.parentId?1:t.type!=="LANE"?2:0],["asc"]),Do=(e,t)=>{let{x:o,y:n}=de(e),{x:a,y:i}=de(t);return{x:o-a,y:n-i}};var xe=({parentId:e,nodes:t,includeTypes:o=[...Object.values(V)],excludeTypes:n=[]})=>t.some(a=>a.parentId===e&&(!o.length||o.includes(a.type))&&!n.includes(a.type)),Oa=(e,t)=>{let{x:o,y:n}=de(e),{x:a,y:i}=de(t),s=o-a,r=n-i;return Math.sqrt(s*s+r*r)},Ga=(e,t)=>{let{x:o,y:n,w:a,h:i}=de(e),{x:s,y:r,w:l,h:c}=de(t);return o<s+l&&s<o+a&&n<r+c&&r<n+i},Oe=(e,t)=>{let o=null,n=1/0;for(let a of t)if(a.id!==e.id&&Ga(e,a)){let i=Oa(e,a);i<n&&(n=i,o=a)}return o},Ro=(e,t)=>t.filter(o=>o.parentId===e).reduce((o,n)=>{var a,i;return Math.max(o,(i=(a=n.measured)==null?void 0:a.width)!=null?i:0)},0);var Mo=(e=[],t=[],o="LR")=>{let n=new Vo.graphlib.Graph;return n.setDefaultEdgeLabel(()=>({})),n.setGraph({rankdir:o}),e.forEach(({id:i,width:s,height:r})=>n.setNode(i,{width:s,height:r})),t.forEach(i=>n.setEdge(i.source,i.target)),Vo.layout(n),{nodes:e.map(i=>{let s=n.node(i.id);return I(_({},i),{position:{x:s.x-i.width/2,y:s.y-i.height/2}})}),edges:t}},fe=(e,t)=>{var f,b;let o=[...t],n=o.find(g=>g.id===e);if(!n)return o;let a=o.filter(g=>g.parentId===e&&g.type==="LANE");if(a.length===0)return o;let i=Ba(a,["position.y"]),s=Math.max((b=(f=n.measured)==null?void 0:f.width)!=null?b:0,dt.MIN_WIDTH),r=Ro(e,i)||$.MIN_WIDTH,l=Math.max(s,r),c=0,u=0;i.forEach(g=>{var T,N,m,d;o=o.map(w=>w.id===g.id?I(_({},w),{width:l-$.HEADER_WIDTH,measured:I(_({},w.measured),{width:l-$.HEADER_WIDTH}),position:{x:$.HEADER_WIDTH,y:c}}):w),c+=(N=(T=g.measured)==null?void 0:T.height)!=null?N:0,u+=(d=(m=g.measured)==null?void 0:m.height)!=null?d:0}),o=o.map(g=>g.id===e?I(_({},g),{height:u,width:l,measured:I(_({},g.measured),{height:u,width:l})}):g);let E=o.find(g=>g.id===e);return E!=null&&E.parentId&&(o=fe(E.parentId,o)),o},Oo=()=>{let e=document.querySelector(".react-flow__viewport");return e||(console.error("Flow element (.react-flow__viewport) not found."),null)},za=50,Go=(e,t=za)=>{let o=Ha(e);return{x:o.x-t,y:o.y-t,width:o.width+t*2,height:o.height+t*2}};import{create as Fa}from"zustand";var O=Fa(e=>({isMoveTool:!0,isHandTool:!1,isReadOnly:!1,isMultipleSelection:!1,isMinimapOpen:!1,activeMoveTool:()=>{e({isMoveTool:!0,isHandTool:!1})},activeHandTool:()=>{e({isHandTool:!0,isMoveTool:!1})},setIsReadOnly:t=>{e({isReadOnly:t})},setIsMultipleSelection:t=>{e({isMultipleSelection:t})},setIsMinimapOpen:t=>{e({isMinimapOpen:t})}}));import{addEdge as Zo,useReactFlow as Ni}from"@xyflow/react";import{BaseEdge as si,EdgeLabelRenderer as li,getStraightPath as di,useNodes as ci,useViewport as pi}from"@xyflow/react";import{getIncomers as Ge,getOutgoers as jt,useReactFlow as Ya}from"@xyflow/react";import{Button as Ka,Tooltip as $a,TooltipContent as Xa,TooltipTrigger as Za,useTranslation as qa}from"lecom-ui";import{PencilIcon as ja}from"lucide-react";import{createContext as Ua,useContext as Wa}from"react";var Ho=Ua(null),Bo=Ho.Provider,zo=()=>{let e=Wa(Ho);if(!e)throw new Error("useEditor must be used within an <EditorProvider />");return e};import{jsx as pt,jsxs as Ja}from"react/jsx-runtime";var He=({elementId:e,elementType:t="node"})=>{let{t:o}=qa(),{getNode:n,getEdge:a,getNodes:i,getEdges:s}=Ya(),{onConfigureElement:r}=zo(),l=p=>{var x,S,h,y,k;return p?p.type==="TASK"&&((x=p.data)==null?void 0:x.variant)==="SUBPROCESS"?{id:p.id,type:"sub_process",variant:u(p),label:(S=p.data)==null?void 0:S.label}:p.type==="GATEWAY"?{id:p.id,type:"gateway",variant:((h=p.data)==null?void 0:h.variant)||"EXCLUSIVE",label:(y=p.data)==null?void 0:y.label}:{id:p.id,type:"activity",variant:u(p),label:(k=p.data)==null?void 0:k.label}:null},c=p=>{let x=i(),S=s(),h=Ge(p,x,S);if(h.length===0)return;let y=h[0];return l(y)||void 0},u=p=>{let x=i(),S=s(),h=Ge(p,x,S),y=jt(p,x,S),k=h.some(C=>C.type==="START_EVENT"),P=y.some(C=>C.type==="END_EVENT");return k?"start":P?"end":"between"},E=p=>{var C,v,A,D;let x=i(),S=s(),h=n(p.source),y=n(p.target);if(!h||!y)return"simple";if(jt(h,x,S).some(R=>R.type==="END_EVENT"))return"final";if(h.type==="GATEWAY")switch((C=h.data)==null?void 0:C.variant){case"PARALLEL":return"parallel";case"EXCLUSIVE":return"exclusive";case"COMPLEX":return"complex";default:return"simple"}if(h.type==="TASK"){let R=(v=h.data)==null?void 0:v.variant,G=(A=h.data)==null?void 0:A.attribute;return y.type==="TASK"&&((D=y.data)==null?void 0:D.variant)==="SUBPROCESS"?"to_sub_process":R==="SCRIPT"?"script":G==="LOOP"?"loop":"simple"}return"simple"},f=p=>{var C;let x=n(p.source);if(!x||x.type!=="GATEWAY"||((C=x.data)==null?void 0:C.variant)!=="COMPLEX")return;let S=i(),h=s(),y=Ge(x,S,h),k=!1,P=!1;if(y.forEach(v=>{var A,D;v.type==="TASK"&&(((A=v.data)==null?void 0:A.variant)==="SCRIPT"&&(k=!0),((D=v.data)==null?void 0:D.attribute)==="LOOP"&&(P=!0))}),k&&P)return"script_loop";if(k)return"script";if(P)return"loop"},b=p=>{var C;let x=n(p.source);if(!x||x.type!=="GATEWAY"||((C=x.data)==null?void 0:C.variant)!=="EXCLUSIVE")return;let S=i(),h=s(),y=Ge(x,S,h),k=!1,P=!1;if(y.forEach(v=>{var A,D;v.type==="TASK"&&(((A=v.data)==null?void 0:A.variant)==="SCRIPT"&&(k=!0),((D=v.data)==null?void 0:D.attribute)==="LOOP"&&(P=!0))}),k)return"script";if(P)return"loop"},g=p=>{var P,C;if(p.type!=="GATEWAY")return;let x=i(),S=s(),h=Ge(p,x,S),y=!1,k=!1;if(h.forEach(v=>{var A,D;v.type==="TASK"&&(((A=v.data)==null?void 0:A.variant)==="SCRIPT"&&(y=!0),((D=v.data)==null?void 0:D.attribute)==="LOOP"&&(k=!0))}),((P=p.data)==null?void 0:P.variant)==="COMPLEX"){if(y&&k)return"script_loop";if(y)return"script";if(k)return"loop"}else if(((C=p.data)==null?void 0:C.variant)==="EXCLUSIVE"){if(y)return"script";if(k)return"loop"}},T=p=>jt(p,i(),s()).map(h=>{var y,k;return{id:h.id,type:h.type,variant:(y=h.data)==null?void 0:y.variant,label:(k=h.data)==null?void 0:k.label}}),N=p=>s().filter(h=>h.source===p.id).map(h=>{var y;return{id:h.id,type:"routing",variant:E(h),label:(y=h.data)==null?void 0:y.label,target:n(h.target)}}),m=()=>{var S,h,y,k,P,C,v,A,D;let p=n(e);if(!p)return;let x=c(p);if(p.type==="TASK"&&((S=p.data)==null?void 0:S.variant)==="SUBPROCESS"){r==null||r({id:p.id,type:"sub_process",variant:u(p),label:(h=p.data)==null?void 0:h.label,origin:x,targets:T(p),edgeTargets:N(p)}),console.log({id:p.id,type:"sub_process",variant:u(p),label:(y=p.data)==null?void 0:y.label,origin:x,targets:T(p),edgeTargets:N(p)});return}if(p.type!=="GATEWAY"){r==null||r({id:p.id,type:"activity",variant:u(p),label:(k=p.data)==null?void 0:k.label,origin:x,targets:T(p),edgeTargets:N(p)}),console.log({id:p.id,type:"activity",variant:u(p),label:(P=p.data)==null?void 0:P.label,origin:x,targets:T(p),edgeTargets:N(p)});return}console.log({id:p.id,type:"gateway",variant:((C=p.data)==null?void 0:C.variant)||"EXCLUSIVE",label:(v=p.data)==null?void 0:v.label,origin:x,subVariant:g(p),targets:T(p)}),r==null||r({id:p.id,type:"gateway",variant:((A=p.data)==null?void 0:A.variant)||"EXCLUSIVE",label:(D=p.data)==null?void 0:D.label,origin:x,subVariant:g(p),targets:T(p)})},d=()=>{let p=a(e);if(p){let x=E(p),S;x==="complex"?S=f(p):x==="exclusive"&&(S=b(p));let h=n(p.source),y=h&&l(h)||void 0;r==null||r({id:p.id,type:"routing",variant:x,subVariant:S,origin:y,target:n(p.target)}),console.log({id:p.id,type:"routing",variant:x,subVariant:S,origin:y,target:n(p.target)})}};return Ja($a,{children:[pt(Za,{asChild:!0,children:pt(Ka,{variant:"ghost",color:"grey",size:"small",iconButton:!0,onClick:()=>{switch(t){case"node":m();break;case"edge":d();break}},children:pt(ja,{size:16})})}),pt(Xa,{color:"black",children:o(t==="node"?"editor.toolbar.configure_node":"editor.toolbar.configure_edge")})]})};import{useReactFlow as Qa}from"@xyflow/react";import{Button as ei,Tooltip as ti,TooltipContent as oi,TooltipTrigger as ni,useTranslation as ri}from"lecom-ui";import{TrashIcon as ai}from"lucide-react";import{jsx as ut,jsxs as ii}from"react/jsx-runtime";var mt=({elementId:e,elementType:t="node"})=>{let{t:o}=ri(),{deleteElements:n}=Qa();return ii(ti,{children:[ut(ni,{asChild:!0,children:ut(ei,{variant:"ghost",color:"destructive",size:"small",iconButton:!0,onClick:()=>{n(t==="node"?{nodes:[{id:e}]}:{edges:[{id:e}]})},children:ut(ai,{size:16})})}),ut(oi,{color:"black",children:o("editor.toolbar.delete")})]})};import{jsx as gt}from"react/jsx-runtime";var we=n=>{var a=n,{edgeId:e,edgeType:t}=a,o=le(a,["edgeId","edgeType"]);var r;let i=[{component:gt(mt,{elementId:e,elementType:"edge"})}],s={SEQUENCE_EDGE:[{component:gt(He,{elementId:e,elementType:"edge"})},...i],MESSAGE_EDGE:[...i],ANNOTATION_EDGE:[...i]};return gt("div",I(_({className:"flex items-center gap-1 w-fit px-3 py-2 bg-white rounded-sm shadow-md"},o),{children:(r=s[t])==null?void 0:r.map((l,c)=>gt("div",{children:l.component},c))}))};import{jsx as Et,jsxs as ui}from"react/jsx-runtime";var bt={type:"ANNOTATION_EDGE",zIndex:2e3},Uo=({id:e,source:t,target:o,sourceX:n,sourceY:a,targetX:i,targetY:s,selected:r,data:l})=>{let c=ci(),{zoom:u}=pi(),{isMultipleSelection:E}=O(),f=c.find(w=>w.id===t),b=c.find(w=>w.id===o),[g,T,N]=di({sourceX:n,sourceY:a,targetX:i,targetY:s}),m=r||(f==null?void 0:f.selected)||(b==null?void 0:b.selected),d=1/u;return ui("g",{className:L("text-grey-400 hover:text-grey-500",{"text-blue-500 hover:text-blue-600":m}),children:[Et(si,{id:e,path:g,strokeDasharray:4,className:L("stroke-2 stroke-current transition-colors duration-75",{"stroke-red-500 hover:stroke-red-600":l==null?void 0:l.hasError,"stroke-blue-500 hover:stroke-blue-600 drop-shadow-[0_0_3px_rgba(59,130,246,0.5)]":m&&!(l!=null&&l.hasError)})}),Et(li,{children:Et("div",{className:"absolute z-[3000] pointer-events-auto flex flex-col items-center gap-1",style:{transform:`translate(-50%, -50%) translate(${T}px, ${N}px)`},children:r&&!E&&Et(we,{edgeId:e,edgeType:"ANNOTATION_EDGE",style:{transform:`scale(${d})`}})})})]})};import{BaseEdge as fi,EdgeLabelRenderer as Ei,getSmoothStepPath as bi,MarkerType as Ko,useNodes as hi,useReactFlow as vi,useViewport as yi}from"@xyflow/react";import{useState as Ti}from"react";import{useEffect as Wo,useRef as mi,useState as gi}from"react";import{jsx as Yo}from"react/jsx-runtime";var W=({value:e,maxLength:t,onChange:o,isEditing:n,onBlur:a,className:i,style:s})=>{let r=mi(null),[l,c]=gi(!1);Wo(()=>{c(n!=null?n:!1)},[n]),Wo(()=>{if(l&&r.current){r.current.focus();let g=document.createRange();g.selectNodeContents(r.current),g.collapse(!1);let T=window.getSelection();T&&(T.removeAllRanges(),T.addRange(g))}},[l]);let u=g=>{if(g.stopPropagation(),l&&r.current){let T=document.createRange();T.selectNodeContents(r.current);let N=window.getSelection();N&&(N.removeAllRanges(),N.addRange(T))}else c(!0)},E=g=>{let T=g.currentTarget.innerText.trim(),N=t&&T.length>=t,m=["Backspace","Delete","ArrowLeft","ArrowRight","ArrowUp","ArrowDown","Home","End","Tab","Enter","Escape","Shift"],d=g.ctrlKey||g.metaKey,w=d&&g.key==="a",p=d&&g.key==="c",x=d&&g.key==="x",S=d&&g.key==="v";function h(k){return/\w/.test(k)}if(T.length===0&&!h(g.key)&&!m.includes(g.key)&&!d){g.preventDefault();return}N&&(m.includes(g.key)||w||p||x||S||g.preventDefault())},f=g=>{if(!t)return;g.preventDefault();let T=g.clipboardData.getData("text/plain"),N=g.currentTarget.innerText,m=window.getSelection();if(!m||m.rangeCount===0)return;let d=m.getRangeAt(0);if((N.substring(0,d.startOffset)+T+N.substring(d.endOffset)).length>t){let p=t-(N.length-(d.endOffset-d.startOffset)),x=T.substring(0,Math.max(0,p));x&&(d.deleteContents(),d.insertNode(document.createTextNode(x)),d.setStartAfter(d.endContainer),d.collapse(!0),m.removeAllRanges(),m.addRange(d))}else d.deleteContents(),d.insertNode(document.createTextNode(T)),d.setStartAfter(d.endContainer),d.collapse(!0),m.removeAllRanges(),m.addRange(d)},b=g=>{c(!1);let T=g.currentTarget.innerText.trim();t&&T.length>t&&(T=T.substring(0,t)),g.currentTarget.innerText=T,a==null||a(),T!==e&&(o==null||o(T))};return Yo("div",{className:L("flex-1 p-2 self-stretch content-center border border-transparent overflow-hidden text-ellipsis text-sm text-center",i,{"border border-dashed border-grey-400":l}),style:s,onDoubleClick:u,children:Yo("div",{ref:r,className:"outline-none whitespace-pre-wrap overflow-hidden",contentEditable:l,suppressContentEditableWarning:!0,onKeyDown:E,onPaste:f,onBlur:b,children:e})})};import{jsx as ht,jsxs as $o}from"react/jsx-runtime";var oe={type:"SEQUENCE_EDGE",zIndex:2e3,markerStart:{type:Ko.ArrowClosed},markerEnd:{type:Ko.Arrow},data:{label:""}},Xo=({id:e,source:t,target:o,sourceX:n,sourceY:a,targetX:i,targetY:s,sourcePosition:r,targetPosition:l,data:c,selected:u})=>{let E=hi(),{zoom:f}=yi(),{updateEdgeData:b}=vi(),{isMultipleSelection:g}=O(),[T,N]=Ti(!1),m=E.find(A=>A.id===t),d=E.find(A=>A.id===o),[w,p,x]=bi({sourceX:n,sourceY:a,sourcePosition:r,targetX:i,targetY:s,targetPosition:l}),S=u||(m==null?void 0:m.selected)||(d==null?void 0:d.selected),h=S?"sequence-edge-marker-highlighted":"sequence-edge-marker",y=T||(c==null?void 0:c.label.trim().length)>0,k=1/f,P=()=>{N(!0)},C=()=>{N(!1)},v=A=>{b(e,{label:A.trim()})};return $o("g",{className:L("text-grey-400 hover:text-grey-500",{"text-blue-500 hover:text-blue-600":S}),onBlur:C,onDoubleClick:P,children:[ht(fi,{id:e,path:w,markerEnd:`url(#${h})`,className:L("stroke-2 stroke-current transition-colors duration-75",{"stroke-red-500 hover:stroke-red-600":c==null?void 0:c.hasError,"stroke-blue-500 hover:stroke-blue-600 drop-shadow-[0_0_3px_rgba(59,130,246,0.5)]":S&&!(c!=null&&c.hasError)})}),ht(Ei,{children:$o("div",{className:"absolute z-[3000] pointer-events-auto flex flex-col items-center gap-1",style:{transform:`translate(-50%, -50%) translate(${p}px, ${x}px)`},children:[u&&!g&&ht(we,{edgeId:e,edgeType:"SEQUENCE_EDGE",style:{transform:`scale(${k})`}}),y&&ht(W,{value:c==null?void 0:c.label,className:"min-w-8 max-w-56 bg-white rounded-md px-2 py-1 text-xs",isEditing:T,onChange:v})]})})]})};var qo=({setEdges:e})=>{let{getNode:t,getEdges:o}=Ni();return{isValidConnection:i=>{var l,c;let s=t(i.source),r=t(i.target);if((s==null?void 0:s.id)===(r==null?void 0:r.id)||(s==null?void 0:s.type)==="GATEWAY"&&((l=s==null?void 0:s.data)==null?void 0:l.variant)==="EXCLUSIVE"&&o().filter(f=>f.source===s.id).length>=2||(s==null?void 0:s.type)==="TASK"&&o().filter(f=>f.source===s.id).length>=2||(s==null?void 0:s.type)==="GATEWAY"&&(r==null?void 0:r.type)==="GATEWAY"||(s==null?void 0:s.type)==="START_EVENT"&&(r==null?void 0:r.type)==="END_EVENT"||(s==null?void 0:s.type)==="GATEWAY"&&(r==null?void 0:r.type)==="END_EVENT"||(s==null?void 0:s.type)==="START_EVENT"&&(r==null?void 0:r.type)==="GATEWAY"||(s==null?void 0:s.type)==="START_EVENT"&&(r==null?void 0:r.type)==="TASK"&&o().filter(b=>b.source===r.id).some(b=>{let g=t(b.target);return(g==null?void 0:g.type)==="END_EVENT"})||(s==null?void 0:s.type)==="TASK"&&((c=s==null?void 0:s.data)==null?void 0:c.variant)==="SCRIPT"&&(r==null?void 0:r.type)==="END_EVENT")return!1;if((s==null?void 0:s.type)==="TASK"&&(r==null?void 0:r.type)==="END_EVENT"){let u=o();if(u.filter(g=>g.target===s.id).some(g=>{let T=t(g.source);return(T==null?void 0:T.type)==="START_EVENT"})||u.filter(g=>g.source===s.id).length>0)return!1}if((s==null?void 0:s.type)==="TASK"&&o().filter(b=>b.source===s.id).some(b=>{let g=t(b.target);return(g==null?void 0:g.type)==="END_EVENT"}))return!1;switch(s==null?void 0:s.type){case"START_EVENT":return(r==null?void 0:r.type)==="TASK"||(r==null?void 0:r.type)==="END_EVENT"||(r==null?void 0:r.type)==="GATEWAY"||(r==null?void 0:r.type)==="ANNOTATION";case"END_EVENT":return(r==null?void 0:r.type)==="ANNOTATION";case"TASK":return(r==null?void 0:r.type)==="TASK"||(r==null?void 0:r.type)==="END_EVENT"||(r==null?void 0:r.type)==="GATEWAY"||(r==null?void 0:r.type)==="ANNOTATION";case"GATEWAY":return(r==null?void 0:r.type)==="TASK"||(r==null?void 0:r.type)==="END_EVENT"||(r==null?void 0:r.type)==="GATEWAY"||(r==null?void 0:r.type)==="ANNOTATION";case"LANE":return(r==null?void 0:r.type)==="ANNOTATION";default:return!1}},onConnect:i=>{e(s=>{let r=t(i.target);return(r==null?void 0:r.type)==="ANNOTATION"?Zo(_(_({},i),bt),s):Zo(_(_({},i),oe),s)})}}};import{useState as an}from"react";import{useTranslation as _i}from"lecom-ui";import{useReactFlow as xi}from"@xyflow/react";var Be=(e=[])=>e.filter(t=>t.type==="START_EVENT"),be=(e=[])=>e.filter(t=>t.type==="END_EVENT"),ue=(e=[])=>e.filter(t=>t.type==="TASK")||[],jo=(e=[])=>e.filter(t=>{var o;return t.type==="TASK"&&((o=t.properties)==null?void 0:o.variant)==="SCRIPT"}),Jo=(e=[])=>e.filter(t=>{var o;return t.type==="TASK"&&((o=t.properties)==null?void 0:o.variant)==="SUBPROCESS"}),vt=(e=[])=>e.filter(t=>t.type==="GATEWAY"),Qo=(e=[])=>e.filter(t=>{var o;return t.type==="GATEWAY"&&((o=t.properties)==null?void 0:o.variant)==="EXCLUSIVE"}),j=(e,t=[])=>t.filter(o=>o.source===e),ze=(e,t=[])=>t.filter(o=>o.target===e),en=(e,t)=>{var n,a;let o=(n=t.nodes)==null?void 0:n.find(i=>i.id===e);return((a=o==null?void 0:o.properties)==null?void 0:a.attribute)==="LOOP"},tn=(e,t)=>{let o=j(e,t.edges||[]);for(let n of o){let a=(t.nodes||[]).find(i=>i.id===n.target);if(a&&a.type==="END_EVENT")return!0}return!1},on=e=>e?/\w/g.test(e.trim()):!1,M=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:[]}},ne=(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)}},nn=(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 Fe=[{id:"start_event_not_found",validate:e=>{let t=Be(e.nodes);return M({isValid:t.length>=1})}},{id:"end_event_not_found",validate:e=>{let t=be(e.nodes);return M({isValid:t.length>=1})}},{id:"multiple_start_event_not_allowed",validate:e=>{let t=Be(e.nodes),o=t.length===1;if(t.length===0)return M({isValid:!0});if(!o)return M({isValid:!1,nodeIds:t.map(i=>i.id)});let n=j(t[0].id,e.edges);if(!(n.length<=1)){let i=[...t.map(s=>s.id),...n.map(s=>s.target)];return M({isValid:!1,nodeIds:[...new Set(i)]})}return M({isValid:!0})}},{id:"task_flows_limit_exceeds",validate:e=>{let t=ue(e.nodes),o=ne(t,n=>j(n.id,e.edges).length<=2);return M({isValid:o.isValid,nodeIds:o.invalidIds})}},{id:"task_label_empty",highlightRelatedEdges:!1,validate:e=>{let t=ue(e.nodes),o=ne(t,n=>!!n.label&&n.label.trim()!=="");return M({isValid:o.isValid,nodeIds:o.invalidIds})}},{id:"task_label_length",highlightRelatedEdges:!1,validate:e=>{let o=ue(e.nodes),n=ne(o,a=>!a.label||a.label.length<=60);return M({isValid:n.isValid,nodeIds:n.invalidIds})}},{id:"duplicate_task_name",highlightRelatedEdges:!1,validate:e=>{let t=ue(e.nodes),o=new Map;for(let a of t){if(!a.label)continue;let i=a.label.trim();i&&(o.has(i)||o.set(i,[]),o.get(i).push(a))}let n=[];for(let[,a]of o.entries())a.length>1&&a.forEach(i=>n.push(i.id));return M({isValid:n.length===0,nodeIds:n})}},{id:"nested_gateway",validate:e=>{let t=vt(e.nodes),o=[],n=[];for(let a of t){let i=j(a.id,e.edges);for(let s of i){let r=e.nodes.find(l=>l.id===s.target);r&&r.type==="GATEWAY"&&(o.push(a.id,r.id),n.push(s.id))}}return M({isValid:o.length===0,nodeIds:o.length>0?[...new Set(o)]:[],edgeIds:n})}},{id:"events_nested",validate:e=>{let t=[...Be(e.nodes),...be(e.nodes)],o=[],n=[];for(let a of t){let i=j(a.id,e.edges);for(let s of i){let r=e.nodes.find(l=>l.id===s.target);r&&(r.type==="START_EVENT"||r.type==="END_EVENT")&&(o.push(a.id,r.id),n.push(s.id))}}return M({isValid:o.length===0,nodeIds:o.length>0?[...new Set(o)]:[],edgeIds:n})}},{id:"flows_on_end_tasks_not_allowed",validate:e=>{let t=be(e.nodes),o=[],n=[];for(let a of t){let i=ze(a.id,e.edges);for(let s of i){let r=e.nodes.find(l=>l.id===s.source);if(r&&r.type==="TASK"){let l=j(r.id,e.edges);l.length>1&&(o.push(r.id),l.forEach(c=>n.push(c.id)))}}}return M({isValid:o.length===0,nodeIds:o,edgeIds:n})}},{id:"conditions_flows_limit_exceeds",validate:e=>{let t=Qo(e.nodes),o=ne(t,a=>j(a.id,e.edges).length<=2),n=o.invalidIds.flatMap(a=>j(a,e.edges).map(i=>i.id));return M({isValid:o.isValid,nodeIds:o.invalidIds,edgeIds:n})}},{id:"activity_name_invalid",validate:e=>{let t=ue(e.nodes),o=ne(t,n=>!n.label||on(n.label));return M({isValid:o.isValid,nodeIds:o.invalidIds})}},{id:"final_activity_has_loop",validate:e=>{var s,r;if(!((s=e==null?void 0:e.nodes)!=null&&s.length)||!((r=e==null?void 0:e.edges)!=null&&r.length))return M({isValid:!0});let t=be(e.nodes)[0];if(!t)return M({isValid:!0});let o=ze(t.id,e.edges);if(!o.length)return M({isValid:!0});let a=ue(e.nodes).filter(l=>o.some(c=>c.source===l.id)),i=ne(a,l=>!en(l.id,e));return M({isValid:i.isValid,nodeIds:i.isValid?[]:[t.id,...i.invalidIds]})}},{id:"concurrent_initial_and_final_event",validate:e=>{let t=ue(e.nodes),o=be(e.nodes)[0];if(!o)return M({isValid:!0});let n=t.filter(l=>{let c=ze(l.id,e.edges),u=j(l.id,e.edges),E=c.some(b=>{var g;return((g=e.nodes.find(T=>T.id===b.source))==null?void 0:g.type)==="START_EVENT"}),f=u.some(b=>{var g;return((g=e.nodes.find(T=>T.id===b.target))==null?void 0:g.type)==="END_EVENT"});return E&&f}),a=ze(o.id,e.edges),i=a.length>1,s=a.map(l=>l.source),r={isValid:n.length===0&&!i,nodeIds:[...n.map(l=>l.id),...i?s:[]]};return M(r)}},{id:"gateway_flow_to_event",validate:e=>{let t=vt(e.nodes),o=[],n=[];for(let a of t){let i=j(a.id,e.edges);for(let s of i){let r=e.nodes.find(l=>l.id===s.target);r&&r.type==="END_EVENT"&&(o.push(a.id,r.id),n.push(s.id))}}return M({isValid:o.length===0,nodeIds:o.length>0?[...new Set(o)]:[],edgeIds:n})}},{id:"gateway_missing_output_streams",validate:e=>{let t=vt(e.nodes),o=ne(t,n=>j(n.id,e.edges).length>=1);return M({isValid:o.isValid,nodeIds:o.invalidIds})}},{id:"event_to_condition",validate:e=>{let t=[...Be(e.nodes),...be(e.nodes)],o=[],n=[];for(let a of t){let i=j(a.id,e.edges);for(let s of i){let r=e.nodes.find(l=>l.id===s.target);r&&r.type==="GATEWAY"&&(o.push(a.id,r.id),n.push(s.id))}}return M({isValid:o.length===0,nodeIds:o.length>0?[...new Set(o)]:[],edgeIds:n})}},{id:"script_in_final_activity",validate:e=>{let t=jo(e.nodes),o=ne(t,n=>!tn(n.id,e));return M({isValid:o.isValid,nodeIds:o.invalidIds})}},{id:"subprocess_referenced_not_configured",validate:e=>{let t=Jo(e.nodes),o=ne(t,n=>{var a,i;return((a=n.properties)==null?void 0:a.subprocessRef)!==void 0&&((i=n.properties)==null?void 0:i.subprocessRef)!==""});return M({isValid:o.isValid,nodeIds:o.invalidIds})}}];var rn=e=>{e=e||{nodes:[],edges:[]},e.nodes=e.nodes||[],e.edges=e.edges||[];let t=[];for(let n of Fe){let a=n.validate(e);a.isValid||t.push({id:n.id,message:n.id,nodeIds:a.nodeIds||[],edgeIds:a.edgeIds||[]})}return{isValid:t.length===0,errors:t}};var sn=()=>{let{t:e}=_i(),[t,o]=an(null),{setNodes:n,setEdges:a,getNodes:i,getEdges:s}=xi(),[r,l]=an(!1);return{validationResult:t,validateDiagram:f=>{let b=nn(f.nodes,f.edges),g=rn(b),T=g.errors.map(N=>I(_({},N),{message:e(`validation.errors.${N.id}`)}));return r||l(!0),{isValid:g.isValid,errors:T}},handleValidationComplete:f=>{if(o(f),!f)return;let b=[],g=[];f.errors.forEach(h=>{h.nodeIds&&h.nodeIds.length>0&&h.nodeIds.forEach(y=>b.push(y)),h.edgeIds&&h.edgeIds.length>0&&h.edgeIds.forEach(y=>g.push(y))});let T=[...new Set(b)];n(h=>h.map(y=>I(_({},y),{data:I(_({},y.data),{hasError:!1})}))),a(h=>h.map(y=>I(_({},y),{data:I(_({},y.data),{hasError:!1})})));let N=i(),m=s(),d=new Set(T),w=new Set;f.errors.forEach(h=>{var P,C;let y=Fe.find(v=>v.id===h.id);(y==null?void 0:y.highlightRelatedEdges)!==!1&&((P=h.edgeIds)==null||P.forEach(v=>w.add(v)),(C=h.nodeIds)==null||C.forEach(v=>{m.forEach(A=>{(A.source===v||A.target===v)&&w.add(A.id)})}))});let p=new Set,x=new Set,S=new Set;N.forEach(h=>{h.type==="START_EVENT"?p.add(h.id):h.type==="END_EVENT"&&x.add(h.id)}),m.forEach(h=>{p.has(h.source)&&S.add(h.target),x.has(h.target)&&S.add(h.source)}),S.forEach(h=>{var y,k;if(d.has(h)){let P=(y=f.errors.find(v=>{var A;return(A=v.nodeIds)==null?void 0:A.includes(h)}))==null?void 0:y.id;((k=Fe.find(v=>v.id===P))==null?void 0:k.highlightRelatedEdges)!==!1&&m.forEach(v=>{v.source===h&&x.has(v.target)&&(d.add(v.target),w.add(v.id)),v.target===h&&p.has(v.source)&&(d.add(v.source),w.add(v.id))})}}),d.size>0&&n(h=>h.map(y=>I(_({},y),{data:I(_({},y.data),{hasError:d.has(y.id)})}))),w.size>0&&a(h=>h.map(y=>I(_({},y),{data:I(_({},y.data),{hasError:w.has(y.id)})})))},clearValidation:()=>{o(null),l(!1),n(f=>f.map(b=>I(_({},b),{data:I(_({},b.data),{hasError:!1})}))),a(f=>f.map(b=>I(_({},b),{data:I(_({},b.data),{hasError:!1})})))},isAutoValidationEnabled:r}};import{useReactFlow as wi}from"@xyflow/react";import{useTranslation as Ci}from"lecom-ui";import{useEffect as Ai}from"react";import{v7 as ln}from"uuid";var yt=(e,t)=>{let n=e.filter(i=>i.type==="TASK").map(i=>{var r;let s=(r=i.data)==null?void 0:r.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),a=n.length>0?Math.max(...n)+1:1;return`${t} ${a}`},Tt=(e,t)=>{let n=t.filter(r=>r.type==="TASK").map(r=>{var l;return(l=r.data)==null?void 0:l.label}).filter(Boolean);if(!n.includes(e))return e;let a=e.replace(/\s+\(\d+\)$/,""),i=n.filter(r=>r===a||r.startsWith(`${a} (`)).map(r=>{if(r===a)return 1;let l=r.match(/\s+\((\d+)\)$/);return l?parseInt(l[1],10):0}).filter(r=>r>0),s=2;for(;i.includes(s);)s++;return`${a} (${s})`};var Ii=15,dn="bpmn:selection",Si=e=>{if(!e||!(e instanceof HTMLElement))return!1;let t=e.tagName.toLowerCase(),o=t==="input"||t==="textarea",n=e.isContentEditable,a=t==="select",i=e.closest('[contenteditable="true"], input, textarea, select')!==null;return o||n||a||i},cn=e=>{if(!Si(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},pn=({offset:e=Ii}={})=>{let{getNodes:t,setNodes:o,getEdges:n,setEdges:a}=wi(),{t:i}=Ci();Ai(()=>{let s=l=>{var T,N;if(!cn(l))return;let c=t(),u=n(),E=c.filter(m=>m.selected);if(!E.length)return;l.preventDefault(),l.stopPropagation();let f=u.filter(m=>E.some(d=>d.id===m.source)&&E.some(d=>d.id===m.target)),g=JSON.stringify({nodes:E,edges:f});(T=l.clipboardData)==null||T.setData(dn,g),(N=l.clipboardData)==null||N.setData("text/plain",`BPMN Selection: ${E.length} nodes`)},r=l=>{var N,m;if(!cn(l))return;let c=(N=l.clipboardData)==null?void 0:N.getData(dn);if(!c)return;l.preventDefault(),l.stopPropagation();let u;try{u=JSON.parse(c)}catch(d){return}if(!((m=u.nodes)!=null&&m.length))return;let E=new Map,f=t(),b=[],g=u.nodes.map(d=>{var x;let w=ln();E.set(d.id,w);let p=I(_({},d),{id:w,selected:!0,position:{x:d.position.x+e,y:d.position.y+e}});if(d.type==="TASK"){let S=(x=d.data)==null?void 0:x.label,h=Tt(S||i("bpmn.task.label.prefix"),[...f,...b]);p.data=I(_({},d.data),{label:h})}return b.push(p),p}),T=u.edges.map(d=>I(_({},d),{id:ln(),selected:!0,source:E.get(d.source)||d.source,target:E.get(d.target)||d.target}));o(d=>[...d.map(w=>I(_({},w),{selected:!1})),...g]),a(d=>[...d.map(w=>I(_({},w),{selected:!1})),...T])};return document.addEventListener("copy",s,!0),document.addEventListener("paste",r,!0),()=>{document.removeEventListener("copy",s,!0),document.removeEventListener("paste",r,!0)}},[t,o,n,a,e,i])};import{useReactFlow as Bi,useStoreApi as zi}from"@xyflow/react";import{useTranslation as Fi}from"lecom-ui";import{v7 as En}from"uuid";import{create as ki}from"zustand";var Ce=ki(e=>({draggableNode:null,setDraggableNode:t=>{e({draggableNode:t})}}));import{BaseEdge as Li,EdgeLabelRenderer as Pi,getSmoothStepPath as Di,MarkerType as Ri,useNodes as Vi,useReactFlow as Mi,useViewport as Oi}from"@xyflow/react";import{useState as Gi}from"react";import{jsx as Nt,jsxs as un}from"react/jsx-runtime";var mm={type:"MESSAGE_EDGE",zIndex:2e3,markerEnd:{type:Ri.Arrow},data:{label:""}},mn=({id:e,source:t,target:o,sourceX:n,sourceY:a,targetX:i,targetY:s,sourcePosition:r,targetPosition:l,data:c,selected:u})=>{let E=Vi(),{zoom:f}=Oi(),{updateEdgeData:b}=Mi(),{isMultipleSelection:g}=O(),[T,N]=Gi(!1),m=E.find(A=>A.id===t),d=E.find(A=>A.id===o),[w,p,x]=Di({sourceX:n,sourceY:a,sourcePosition:r,targetX:i,targetY:s,targetPosition:l}),S=u||(m==null?void 0:m.selected)||(d==null?void 0:d.selected),h=S?"sequence-edge-marker-highlighted":"sequence-edge-marker",y=T||(c==null?void 0:c.label.trim().length)>0,k=1/f,P=()=>{N(!0)},C=()=>{N(!1)},v=A=>{b(e,{label:A.trim()})};return un("g",{className:L("text-grey-400 hover:text-grey-500",{"text-blue-500 hover:text-blue-600":S}),onBlur:C,onDoubleClick:P,children:[Nt(Li,{id:e,path:w,markerEnd:`url(#${h})`,strokeDasharray:4,className:L("stroke-2 stroke-current transition-colors duration-75",{"stroke-red-500 hover:stroke-red-600":c==null?void 0:c.hasError,"stroke-blue-500 hover:stroke-blue-600 drop-shadow-[0_0_3px_rgba(59,130,246,0.5)]":S&&!(c!=null&&c.hasError)})}),Nt(Pi,{children:un("div",{className:"absolute z-[3000] pointer-events-auto flex flex-col items-center gap-1",style:{transform:`translate(-50%, -50%) translate(${p}px, ${x}px)`},children:[u&&!g&&Nt(we,{edgeId:e,edgeType:"MESSAGE_EDGE",style:{transform:`scale(${k})`}}),y&&Nt(W,{value:c==null?void 0:c.label,className:"min-w-8 max-w-56 bg-white rounded-md px-2 py-1 text-xs",isEditing:T,onChange:v})]})})]})};import{jsx as gn,jsxs as Hi}from"react/jsx-runtime";var fn=({fromX:e,fromY:t,toX:o,toY:n})=>Hi("g",{children:[gn("path",{fill:"none",className:"stroke-2 stroke-grey-400 animated",d:`M${e},${t} C${e} ${n} ${e} ${n} ${o},${n}`}),gn("circle",{cx:o,cy:n,fill:"none",r:4,className:"stroke-2 stroke-grey-500"})]});var bn=({nodes:e,setNodes:t,setEdges:o})=>{let n=zi(),{draggableNode:a,setDraggableNode:i}=Ce(),{getInternalNode:s,screenToFlowPosition:r}=Bi(),{t:l}=Fi(),c=m=>{let d="[&>div]:bg-blue-50 [&>div]:outline [&>div]:outline-2 [&>div]:outline-blue-500";t(w=>w.map(p=>I(_({},p),{className:p.id===m?d:""})))},u=()=>{let{nodeLookup:m}=n.getState();return Array.from(m.values())},E=m=>{let d=s(m.id),w=u();if(m.type==="LANE"){if(xe({parentId:m.id,nodes:e,includeTypes:["LANE"]})){c();return}let k=w.filter(v=>v.id!==m.id&&v.type==="LANE"&&!v.parentId),P=Oe(d,k);if(!P){c();return}if(xe({parentId:P.id,nodes:e,excludeTypes:["LANE"]})){c();return}c(P.id);return}let x=w.filter(y=>y.id!==m.id&&y.type==="LANE"),S=Oe(d,x);if(!S){c();return}if(xe({parentId:S.id,nodes:e,includeTypes:["LANE"]})){c();return}c(S.id)},f=m=>{m.preventDefault(),m.dataTransfer.dropEffect="move"},b=(m,d)=>{m.preventDefault(),E(d)},g=(m,d,w)=>{var k,P;let p=C=>C.map(v=>I(_({},v),{className:void 0}));if(m.parentId===d.id){let C=fe(d.id,w);t(ce(p(C)));return}if(m.type==="LANE"){if(xe({parentId:d.id,nodes:w,excludeTypes:["LANE"]}))return;let A=w.filter(G=>G.parentId===d.id).reduce((G,ie)=>{var ee,se;return G+((se=(ee=ie.measured)==null?void 0:ee.height)!=null?se:0)},0),D={x:$.HEADER_WIDTH,y:A},R=w.map(G=>G.id===m.id?I(_({},G),{parentId:d.id,position:D,className:void 0}):I(_({},G),{className:void 0}));R=fe(d.id,R),t(ce(R));return}if(xe({parentId:d.id,nodes:w,includeTypes:["LANE"]})){let C;if(m.parentId){let A=s(m.parentId),{x:D,y:R}=de(A);C={x:D+((k=m.position.x)!=null?k:0),y:R+((P=m.position.y)!=null?P:0)}}let v=w.map(A=>A.id===m.id?I(_({},A),{position:C!=null?C:A.position,parentId:void 0,className:void 0}):I(_({},A),{className:void 0}));t(ce(v));return}let h=Do(m,d),y=w.map(C=>C.id===m.id?I(_({},C),{parentId:d.id,position:h,className:void 0}):I(_({},C),{className:void 0}));t(ce(y))};return{onDragOver:f,onDrop:m=>{if(m.preventDefault(),!(a!=null&&a.type))return;let d=r({x:m.clientX,y:m.clientY}),w={width:H[a.type].MIN_WIDTH,height:H[a.type].MIN_HEIGHT},p={id:En(),type:a.type,position:d,measured:w,data:{label:a.type==="TASK"?yt(e,l("bpmn.task.label.prefix")):"",variant:a.variant,attribute:a.attribute}},x=I(_({},p),{internals:{positionAbsolute:d}}),S=u(),h=a.type==="LANE",y=S.filter(C=>h?C.type==="LANE"&&!C.parentId:C.type==="LANE"),k=Oe(x,y);k?g(x,k,[...S,x]):t(C=>{let v=C.concat(p);return ce(v)});let P=m.dataTransfer.getData("sourceId");if(P){let C={id:En(),source:P,target:p.id};if(a.type==="ANNOTATION"){o(v=>v.concat(_(_({},C),bt)));return}o(v=>v.concat(_(_({},C),oe)))}i(null)},onNodeDrag:b,onNodeDragStop:async(m,d)=>{var k,P;let{nodeLookup:w}=n.getState(),p=s(d.id),x=Array.from(w.values()),S=d.type==="LANE",h=x.filter(C=>C.id!==d.id&&(S?C.type==="LANE"&&!C.parentId:C.type==="LANE")),y=Oe(p,h);if(y){g(p,y,x);return}if(d.parentId){let C=s(d.parentId),{x:v,y:A}=de(C),D={x:v+((k=d.position.x)!=null?k:0),y:A+((P=d.position.y)!=null?P:0)},R=e.map(G=>G.id===d.id?I(_({},G),{position:D,parentId:void 0}):G);R=fe(d.parentId,R),t(ce(R))}}}};import{applyNodeChanges as Ui}from"@xyflow/react";import{useCallback as Wi,useState as vn}from"react";function hn(e,t,o=5){var l,c,u,E,f,b,g,T;let n={horizontal:void 0,vertical:void 0,snapPosition:{x:void 0,y:void 0}},a=t.find(N=>N.id===e.id);if(!a||!e.position)return n;let i={left:e.position.x,right:e.position.x+((c=(l=a.measured)==null?void 0:l.width)!=null?c:0),top:e.position.y,bottom:e.position.y+((E=(u=a.measured)==null?void 0:u.height)!=null?E:0),width:(b=(f=a.measured)==null?void 0:f.width)!=null?b:0,height:(T=(g=a.measured)==null?void 0:g.height)!=null?T:0},s=o,r=o;return t.filter(N=>N.id!==a.id).reduce((N,m)=>{var C,v,A,D,R,G,ie,ee;let d={left:m.position.x,right:m.position.x+((v=(C=m.measured)==null?void 0:C.width)!=null?v:0),top:m.position.y,bottom:m.position.y+((D=(A=m.measured)==null?void 0:A.height)!=null?D:0),width:(G=(R=m.measured)==null?void 0:R.width)!=null?G:0,height:(ee=(ie=m.measured)==null?void 0:ie.height)!=null?ee:0},w=Math.abs(i.left-d.left);w<r&&(N.snapPosition.x=d.left,N.vertical=d.left,r=w);let p=Math.abs(i.right-d.right);p<r&&(N.snapPosition.x=d.right-i.width,N.vertical=d.right,r=p);let x=Math.abs(i.left-d.right);x<r&&(N.snapPosition.x=d.right,N.vertical=d.right,r=x);let S=Math.abs(i.right-d.left);S<r&&(N.snapPosition.x=d.left-i.width,N.vertical=d.left,r=S);let h=Math.abs(i.top-d.top);h<s&&(N.snapPosition.y=d.top,N.horizontal=d.top,s=h);let y=Math.abs(i.bottom-d.top);y<s&&(N.snapPosition.y=d.top-i.height,N.horizontal=d.top,s=y);let k=Math.abs(i.bottom-d.bottom);k<s&&(N.snapPosition.y=d.bottom-i.height,N.horizontal=d.bottom,s=k);let P=Math.abs(i.top-d.bottom);return P<s&&(N.snapPosition.y=d.bottom,N.horizontal=d.bottom,s=P),N},n)}var yn=()=>{let[e,t]=vn(void 0),[o,n]=vn(void 0),a=Wi((i,s)=>{var r,l;if(t(void 0),n(void 0),i.length===1&&i[0].type==="position"&&i[0].dragging&&i[0].position){let c=hn(i[0],s);i[0].position.x=(r=c.snapPosition.x)!=null?r:i[0].position.x,i[0].position.y=(l=c.snapPosition.y)!=null?l:i[0].position.y,t(c.horizontal),n(c.vertical)}return Ui(i,s)},[]);return{helperLineHorizontal:e,helperLineVertical:o,customApplyNodeChanges:a}};import{useReactFlow as Ki}from"@xyflow/react";import{v7 as wn}from"uuid";var Nn={"start-event":"START_EVENT","end-event":"END_EVENT",task:"TASK","gateway-exclusive":"GATEWAY"},_n={"start-event":"","end-event":"",task:"","gateway-exclusive":"EXCLUSIVE"},Tn=(e,t)=>{if(!e){console.warn("Step not found");return}e=e.trim();let o=e.match(/(\<.*?\>)/)||[],n=e.match(/(\[.*?\])/)||[],a=e.match(/(\{.*?\})/)||[],i=e.match(/(--.*|\|.*?\|)/i)||[],s="",r="",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",r=n[1].replace(/\[|\]/g,""),e=e.replace(n[1],"")),a.length&&(s="gateway-exclusive",r=a[1].replace(/\{|\}/g,""),e=e.replace(a[1],"")),i.length&&(l=i[1].replace(/(\||--)/g,""),e=e.replace(i[1],"")),e=e.trim(),t[e]||(t[e]={type:s,label:r}),{step:e,type:s,label:r,edgeLabel:l}},Yi=e=>{e=e||"";let t=e.trim().split(`
|
|
2
|
-
`),o={},n=[];return t.forEach(
|
|
3
|
-
`),
|
|
4
|
-
`,"
");function
|
|
1
|
+
var Na=Object.defineProperty,Ta=Object.defineProperties;var _a=Object.getOwnPropertyDescriptors;var Xe=Object.getOwnPropertySymbols;var _o=Object.prototype.hasOwnProperty,xo=Object.prototype.propertyIsEnumerable;var To=(e,t,o)=>t in e?Na(e,t,{enumerable:!0,configurable:!0,writable:!0,value:o}):e[t]=o,T=(e,t)=>{for(var o in t||(t={}))_o.call(t,o)&&To(e,o,t[o]);if(Xe)for(var o of Xe(t))xo.call(t,o)&&To(e,o,t[o]);return e},w=(e,t)=>Ta(e,_a(t));var ae=(e,t)=>{var o={};for(var n in e)_o.call(e,n)&&t.indexOf(n)<0&&(o[n]=e[n]);if(e!=null&&Xe)for(var n of Xe(e))t.indexOf(n)<0&&xo.call(e,n)&&(o[n]=e[n]);return o};import{TooltipProvider as xa,Notification as wa}from"lecom-ui";import{jsx as Ca,jsxs as Aa}from"react/jsx-runtime";function wo({children:e}){return Aa(xa,{children:[Ca(wa,{type:"toast",placement:"topRight",enableClose:!0,showProgress:!0,pauseOnHover:!0}),e]})}import{Background as oc,MiniMap as nc,ReactFlow as rc,ReactFlowProvider as ac,SelectionMode as ic,useEdgesState as sc,useNodesState as lc,useOnSelectionChange as dc,useReactFlow as cc}from"@xyflow/react";import{i18n as Zr}from"lecom-ui";import{forwardRef as pc,useCallback as mo,useEffect as Eo,useImperativeHandle as uc,useRef as mc,useState as gc}from"react";import{useDebouncedCallback as fc}from"use-debounce";import{v7 as go}from"uuid";var Ht=(r=>(r.ACTIVITY="activity",r.ROUTING="routing",r.GATEWAY="gateway",r.SUB_PROCESS="sub_process",r))(Ht||{}),Bt=(n=>(n.START="start",n.END="end",n.BETWEEN="between",n))(Bt||{}),zt=(l=>(l.SIMPLE="simple",l.LOOP="loop",l.SCRIPT="script",l.COMPLEX="complex",l.EXCLUSIVE="exclusive",l.PARALLEL="parallel",l.FINAL="final",l.TO_SUB_PROCESS="to_sub_process",l))(zt||{}),Ut=(n=>(n.SCRIPT="script",n.LOOP="loop",n.SCRIPT_LOOP="script_loop",n))(Ut||{}),Ft=(o=>(o.SCRIPT="script",o.LOOP="loop",o))(Ft||{});import{RotateCcw as Ha,ScrollText as Ba,SquarePlus as za}from"lucide-react";import{jsx as qe,jsxs as Ia}from"react/jsx-runtime";var je=({size:e=24,className:t})=>Ia("svg",{width:e,height:e,viewBox:"0 0 24 24",xmlns:"http://www.w3.org/2000/svg",fill:"#6b7280",className:t,children:[qe("path",{strokeWidth:"2",d:"M16 3V3.5085V11.9998V20.4915V21H16.5411H21.4592H22V19.123H21.4592H17.9974V11.9998V4.8773H21.4592H22V3H21.4592H16.5411H16Z"}),qe("path",{d:"M4.41026 16.9999L2 18.7861L3.89693 21.1103L6.3072 19.324L4.41026 16.9999Z"}),qe("path",{d:"M8.41026 13.9999L6 15.7861L7.89693 18.1103L10.3072 16.324L8.41026 13.9999Z"}),qe("path",{d:"M12.4313 10.954L10.021 12.7402L11.9179 15.0644L14.3282 13.2781L12.4313 10.954Z"})]});import{jsx as Co}from"react/jsx-runtime";var ve=({size:e=24,className:t})=>Co("svg",{width:e,height:e,viewBox:"0 0 24 24",xmlns:"http://www.w3.org/2000/svg",fill:"#f87171",stroke:"#ef4444",strokeWidth:3,className:t,children:Co("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 Pe,jsxs as Sa}from"react/jsx-runtime";var Je=({size:e=24,className:t})=>Sa("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:[Pe("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"}),Pe("path",{d:"M12 8V16",strokeLinecap:"round",strokeLinejoin:"round"}),Pe("path",{d:"M8 12H16",strokeLinecap:"round",strokeLinejoin:"round"}),Pe("path",{d:"M9.17139 9.17188L14.8282 14.8287",strokeLinecap:"round",strokeLinejoin:"round"}),Pe("path",{d:"M14.8281 9.17188L9.17127 14.8287",strokeLinecap:"round",strokeLinejoin:"round"})]});import{jsx as Wt,jsxs as ka}from"react/jsx-runtime";var Ne=({size:e=24,className:t})=>ka("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:[Wt("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"}),Wt("path",{d:"M14.8286 9.17188L9.17176 14.8287",strokeLinecap:"round",strokeLinejoin:"round"}),Wt("path",{d:"M9.17139 9.17188L14.8282 14.8287",strokeLinecap:"round",strokeLinejoin:"round"})]});import{jsx as Yt,jsxs as La}from"react/jsx-runtime";var Qe=({size:e=24,className:t})=>La("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:[Yt("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"}),Yt("path",{d:"M12 8V16",strokeLinecap:"round",strokeLinejoin:"round"}),Yt("path",{d:"M8 12H16",strokeLinecap:"round",strokeLinejoin:"round"})]});import{jsx as Kt,jsxs as Pa}from"react/jsx-runtime";var Ao=({size:e=24,className:t})=>Kt("svg",{width:e,height:e,viewBox:"0 0 34 24",xmlns:"http://www.w3.org/2000/svg",fill:"currentColor",className:t,children:Pa("g",{children:[Kt("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"}),Kt("path",{d:"M24.5 4.5L28 1M28 1L31.5 4.5M28 1V8",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round"})]})});import{clsx as Da}from"clsx";import{twMerge as Ra}from"tailwind-merge";function k(...e){return Ra(Da(e))}var De=(e,t)=>e<t?t:e;import{jsx as Io,jsxs as Va}from"react/jsx-runtime";var So=({size:e=24,className:t})=>Va("svg",{width:e,height:e,viewBox:"0 0 24 24",fill:"none",stroke:"#6b7280",strokeWidth:2,xmlns:"http://www.w3.org/2000/svg",className:k("stroke-2",t),children:[Io("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"}),Io("path",{d:"M9 3V21",strokeLinecap:"round",strokeLinejoin:"round"})]});import{jsx as $t}from"react/jsx-runtime";var ko=({size:e=24,className:t})=>$t("svg",{width:e,height:e,viewBox:"0 0 24 24",xmlns:"http://www.w3.org/2000/svg",stroke:"currentColor",className:t,children:$t("g",{children:$t("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 Lo}from"react/jsx-runtime";var et=({size:e=24,className:t})=>Lo("svg",{width:e,height:e,viewBox:"0 0 24 24",xmlns:"http://www.w3.org/2000/svg",fill:"#84cc16",stroke:"#65a30d",strokeWidth:"2",className:t,children:Lo("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 Po}from"react/jsx-runtime";var Re=({size:e=24,className:t})=>Po("svg",{width:e,height:e,viewBox:"0 0 24 24",xmlns:"http://www.w3.org/2000/svg",fill:"white",stroke:"#6b7280",className:k("stroke-2",t),children:Po("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 Zt,jsxs as Ma}from"react/jsx-runtime";var Do=({size:e=24,className:t})=>Ma("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:[Zt("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"}),Zt("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"}),Zt("path",{d:"M7.5 7.5V10H10",strokeWidth:"1.5",fill:"none",strokeLinecap:"round",strokeLinejoin:"round"})]});import{jsx as Ve,jsxs as Oa}from"react/jsx-runtime";var Ro=({size:e=24,className:t})=>Oa("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:[Ve("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"}),Ve("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"}),Ve("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"}),Ve("path",{d:"M13.5 12H11",strokeWidth:"1",strokeLinecap:"round",strokeLinejoin:"round"}),Ve("path",{d:"M13.5 10H11",strokeWidth:"1",strokeLinecap:"round",strokeLinejoin:"round"})]});import{jsx as tt,jsxs as Ga}from"react/jsx-runtime";var Vo=({size:e=24,className:t})=>Ga("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:[tt("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"}),tt("path",{d:"M8 21V14C8 13.4477 8.44772 13 9 13H15C15.5523 13 16 13.4477 16 14V21",strokeWidth:"1",fill:"none"}),tt("path",{d:"M10.2222 17H13.7777",strokeWidth:"1",strokeLinecap:"round",strokeLinejoin:"round"}),tt("path",{d:"M12 15.2227V18.7782",strokeWidth:"1",strokeLinecap:"round",strokeLinejoin:"round"})]});var D=(i=>(i.START_EVENT="START_EVENT",i.END_EVENT="END_EVENT",i.TASK="TASK",i.LANE="LANE",i.GATEWAY="GATEWAY",i.ANNOTATION="ANNOTATION",i.UNSUPPORTED="UNSUPPORTED",i))(D||{});var ot={SCRIPT:{icon:Ba},SUBPROCESS:{icon:za}};var nt={LOOP:{icon:Ha}},ee=(n=>(n.EXCLUSIVE="EXCLUSIVE",n.PARALLEL="PARALLEL",n.COMPLEX="COMPLEX",n))(ee||{}),rt={EXCLUSIVE:{icon:Ne},PARALLEL:{icon:Qe},COMPLEX:{icon:Je}};import Go from"@dagrejs/dagre";import{getNodesBounds as Xa}from"@xyflow/react";import{orderBy as qa}from"lodash";var Ua={MIN_WIDTH:36,MIN_HEIGHT:36},Fa={MIN_WIDTH:36,MIN_HEIGHT:36},Wa={MIN_WIDTH:56,MIN_HEIGHT:56},at={MIN_WIDTH:176,MIN_HEIGHT:96},it={HEADER_WIDTH:40,MIN_WIDTH:840,MIN_HEIGHT:256},K={HEADER_WIDTH:40,MIN_WIDTH:800,MIN_HEIGHT:256},st={MIN_WIDTH:176,MIN_HEIGHT:64},Ya={MIN_WIDTH:128,MIN_HEIGHT:64},G={START_EVENT:Ua,END_EVENT:Fa,GATEWAY:Wa,TASK:at,LANE:K,ANNOTATION:st,UNSUPPORTED:Ya};import{orderBy as Ka}from"lodash";var ie=e=>{var t,o,n,r,a,s,i,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=(a=e.measured)==null?void 0:a.width)!=null?s:0,h:(l=(i=e.measured)==null?void 0:i.height)!=null?l:0}},se=e=>Ka(e,[t=>t.parentId?1:t.type!=="LANE"?2:0],["asc"]),Mo=(e,t)=>{let{x:o,y:n}=ie(e),{x:r,y:a}=ie(t);return{x:o-r,y:n-a}};var Te=({parentId:e,nodes:t,includeTypes:o=[...Object.values(D)],excludeTypes:n=[]})=>t.some(r=>r.parentId===e&&(!o.length||o.includes(r.type))&&!n.includes(r.type)),$a=(e,t)=>{let{x:o,y:n}=ie(e),{x:r,y:a}=ie(t),s=o-r,i=n-a;return Math.sqrt(s*s+i*i)},Za=(e,t)=>{let{x:o,y:n,w:r,h:a}=ie(e),{x:s,y:i,w:l,h:c}=ie(t);return o<s+l&&s<o+r&&n<i+c&&i<n+a},Me=(e,t)=>{let o=null,n=1/0;for(let r of t)if(r.id!==e.id&&Za(e,r)){let a=$a(e,r);a<n&&(n=a,o=r)}return o},Oo=(e,t)=>t.filter(o=>o.parentId===e).reduce((o,n)=>{var r,a;return Math.max(o,(a=(r=n.measured)==null?void 0:r.width)!=null?a:0)},0);var Ho=(e=[],t=[],o="LR")=>{let n=new Go.graphlib.Graph;return n.setDefaultEdgeLabel(()=>({})),n.setGraph({rankdir:o}),e.forEach(({id:a,width:s,height:i})=>n.setNode(a,{width:s,height:i})),t.forEach(a=>n.setEdge(a.source,a.target)),Go.layout(n),{nodes:e.map(a=>{let s=n.node(a.id);return w(T({},a),{position:{x:s.x-a.width/2,y:s.y-a.height/2}})}),edges:t}},ue=(e,t)=>{var m,h;let o=[...t],n=o.find(E=>E.id===e);if(!n)return o;let r=o.filter(E=>E.parentId===e&&E.type==="LANE");if(r.length===0)return o;let a=qa(r,["position.y"]),s=Math.max((h=(m=n.measured)==null?void 0:m.width)!=null?h:0,it.MIN_WIDTH),i=Oo(e,a)||K.MIN_WIDTH,l=Math.max(s,i),c=0,g=0;a.forEach(E=>{var y,v,p,d;o=o.map(x=>x.id===E.id?w(T({},x),{width:l-K.HEADER_WIDTH,measured:w(T({},x.measured),{width:l-K.HEADER_WIDTH}),position:{x:K.HEADER_WIDTH,y:c}}):x),c+=(v=(y=E.measured)==null?void 0:y.height)!=null?v:0,g+=(d=(p=E.measured)==null?void 0:p.height)!=null?d:0}),o=o.map(E=>E.id===e?w(T({},E),{height:g,width:l,measured:w(T({},E.measured),{height:g,width:l})}):E);let f=o.find(E=>E.id===e);return f!=null&&f.parentId&&(o=ue(f.parentId,o)),o},Bo=()=>{let e=document.querySelector(".react-flow__viewport");return e||(console.error("Flow element (.react-flow__viewport) not found."),null)},ja=50,zo=(e,t=ja)=>{let o=Xa(e);return{x:o.x-t,y:o.y-t,width:o.width+t*2,height:o.height+t*2}};import{create as Ja}from"zustand";var V=Ja(e=>({isMoveTool:!0,isHandTool:!1,isReadOnly:!1,isMultipleSelection:!1,isMinimapOpen:!1,activeMoveTool:()=>{e({isMoveTool:!0,isHandTool:!1})},activeHandTool:()=>{e({isHandTool:!0,isMoveTool:!1})},setIsReadOnly:t=>{e({isReadOnly:t})},setIsMultipleSelection:t=>{e({isMultipleSelection:t})},setIsMinimapOpen:t=>{e({isMinimapOpen:t})}}));import{addEdge as en,useReactFlow as Ri}from"@xyflow/react";import{BaseEdge as bi,EdgeLabelRenderer as hi,getStraightPath as yi,useNodes as vi,useViewport as Ni}from"@xyflow/react";import{getIncomers as Oe,getOutgoers as Xt,useReactFlow as ti}from"@xyflow/react";import{Button as oi,Tooltip as ni,TooltipContent as ri,TooltipTrigger as ai,useTranslation as ii}from"lecom-ui";import{PencilIcon as si}from"lucide-react";import{createContext as Qa,useContext as ei}from"react";var Uo=Qa(null),Fo=Uo.Provider,Wo=()=>{let e=ei(Uo);if(!e)throw new Error("useEditor must be used within an <EditorProvider />");return e};import{jsx as lt,jsxs as li}from"react/jsx-runtime";var Ge=({elementId:e,elementType:t="node"})=>{let{t:o}=ii(),{getNode:n,getEdge:r,getNodes:a,getEdges:s}=ti(),{onConfigureElement:i}=Wo(),l=u=>{var _,I,b,N,S;return u?u.type==="TASK"&&((_=u.data)==null?void 0:_.variant)==="SUBPROCESS"?{id:u.id,type:"sub_process",variant:g(u),label:(I=u.data)==null?void 0:I.label}:u.type==="GATEWAY"?{id:u.id,type:"gateway",variant:((b=u.data)==null?void 0:b.variant)||"EXCLUSIVE",label:(N=u.data)==null?void 0:N.label}:{id:u.id,type:"activity",variant:g(u),label:(S=u.data)==null?void 0:S.label}:null},c=u=>{let _=a(),I=s(),b=Oe(u,_,I);if(b.length===0)return;let N=b[0];return l(N)||void 0},g=u=>{let _=a(),I=s(),b=Oe(u,_,I),N=Xt(u,_,I),S=b.some(C=>C.type==="START_EVENT"),P=N.some(C=>C.type==="END_EVENT");return S?"start":P?"end":"between"},f=u=>{var C,A,L,M;let _=a(),I=s(),b=n(u.source),N=n(u.target);if(!b||!N)return"simple";if(Xt(b,_,I).some(O=>O.type==="END_EVENT"))return"final";if(b.type==="GATEWAY")switch((C=b.data)==null?void 0:C.variant){case"PARALLEL":return"parallel";case"EXCLUSIVE":return"exclusive";case"COMPLEX":return"complex";default:return"simple"}if(b.type==="TASK"){let O=(A=b.data)==null?void 0:A.variant,H=(L=b.data)==null?void 0:L.attribute;return N.type==="TASK"&&((M=N.data)==null?void 0:M.variant)==="SUBPROCESS"?"to_sub_process":O==="SCRIPT"?"script":H==="LOOP"?"loop":"simple"}return"simple"},m=u=>{var C;let _=n(u.source);if(!_||_.type!=="GATEWAY"||((C=_.data)==null?void 0:C.variant)!=="COMPLEX")return;let I=a(),b=s(),N=Oe(_,I,b),S=!1,P=!1;if(N.forEach(A=>{var L,M;A.type==="TASK"&&(((L=A.data)==null?void 0:L.variant)==="SCRIPT"&&(S=!0),((M=A.data)==null?void 0:M.attribute)==="LOOP"&&(P=!0))}),S&&P)return"script_loop";if(S)return"script";if(P)return"loop"},h=u=>{var C;let _=n(u.source);if(!_||_.type!=="GATEWAY"||((C=_.data)==null?void 0:C.variant)!=="EXCLUSIVE")return;let I=a(),b=s(),N=Oe(_,I,b),S=!1,P=!1;if(N.forEach(A=>{var L,M;A.type==="TASK"&&(((L=A.data)==null?void 0:L.variant)==="SCRIPT"&&(S=!0),((M=A.data)==null?void 0:M.attribute)==="LOOP"&&(P=!0))}),S)return"script";if(P)return"loop"},E=u=>{var P,C;if(u.type!=="GATEWAY")return;let _=a(),I=s(),b=Oe(u,_,I),N=!1,S=!1;if(b.forEach(A=>{var L,M;A.type==="TASK"&&(((L=A.data)==null?void 0:L.variant)==="SCRIPT"&&(N=!0),((M=A.data)==null?void 0:M.attribute)==="LOOP"&&(S=!0))}),((P=u.data)==null?void 0:P.variant)==="COMPLEX"){if(N&&S)return"script_loop";if(N)return"script";if(S)return"loop"}else if(((C=u.data)==null?void 0:C.variant)==="EXCLUSIVE"){if(N)return"script";if(S)return"loop"}},y=u=>Xt(u,a(),s()).map(b=>{var N,S;return{id:b.id,type:b.type,variant:(N=b.data)==null?void 0:N.variant,label:(S=b.data)==null?void 0:S.label}}),v=u=>s().filter(b=>b.source===u.id).map(b=>{var N;return{id:b.id,type:"routing",variant:f(b),label:(N=b.data)==null?void 0:N.label,target:n(b.target)}}),p=()=>{var I,b,N,S,P,C;let u=n(e);if(!u)return;let _=c(u);if(u.type==="TASK"&&((I=u.data)==null?void 0:I.variant)==="SUBPROCESS"){i==null||i({id:u.id,type:"sub_process",variant:g(u),label:(b=u.data)==null?void 0:b.label,origin:_,targets:y(u),edgeTargets:v(u)}),console.log({id:u.id,type:"sub_process",variant:g(u),label:(N=u.data)==null?void 0:N.label,origin:_,targets:y(u),edgeTargets:v(u)});return}if(u.type!=="GATEWAY"){i==null||i({id:u.id,type:"activity",variant:g(u),label:(S=u.data)==null?void 0:S.label,origin:_,targets:y(u),edgeTargets:v(u)});return}i==null||i({id:u.id,type:"gateway",variant:((P=u.data)==null?void 0:P.variant)||"EXCLUSIVE",label:(C=u.data)==null?void 0:C.label,origin:_,subVariant:E(u),targets:y(u)})},d=()=>{let u=r(e);if(u){let _=f(u),I;_==="complex"?I=m(u):_==="exclusive"&&(I=h(u));let b=n(u.source),N=b&&l(b)||void 0;i==null||i({id:u.id,type:"routing",variant:_,subVariant:I,origin:N,target:n(u.target)}),console.log({id:u.id,type:"routing",variant:_,subVariant:I,origin:N,target:n(u.target)})}};return li(ni,{children:[lt(ai,{asChild:!0,children:lt(oi,{variant:"ghost",color:"grey",size:"small",iconButton:!0,onClick:()=>{switch(t){case"node":p();break;case"edge":d();break}},children:lt(si,{size:16})})}),lt(ri,{color:"black",children:o(t==="node"?"editor.toolbar.configure_node":"editor.toolbar.configure_edge")})]})};import{useReactFlow as di}from"@xyflow/react";import{Button as ci,Tooltip as pi,TooltipContent as ui,TooltipTrigger as mi,useTranslation as gi}from"lecom-ui";import{TrashIcon as fi}from"lucide-react";import{jsx as dt,jsxs as Ei}from"react/jsx-runtime";var ct=({elementId:e,elementType:t="node"})=>{let{t:o}=gi(),{deleteElements:n}=di();return Ei(pi,{children:[dt(mi,{asChild:!0,children:dt(ci,{variant:"ghost",color:"destructive",size:"small",iconButton:!0,onClick:()=>{n(t==="node"?{nodes:[{id:e}]}:{edges:[{id:e}]})},children:dt(fi,{size:16})})}),dt(ui,{color:"black",children:o("editor.toolbar.delete")})]})};import{jsx as pt}from"react/jsx-runtime";var xe=n=>{var r=n,{edgeId:e,edgeType:t}=r,o=ae(r,["edgeId","edgeType"]);var i;let a=[{component:pt(ct,{elementId:e,elementType:"edge"})}],s={SEQUENCE_EDGE:[{component:pt(Ge,{elementId:e,elementType:"edge"})},...a],MESSAGE_EDGE:[...a],ANNOTATION_EDGE:[...a]};return pt("div",w(T({className:"flex items-center gap-1 w-fit px-3 py-2 bg-white rounded-sm shadow-md"},o),{children:(i=s[t])==null?void 0:i.map((l,c)=>pt("div",{children:l.component},c))}))};import{jsx as mt,jsxs as Ti}from"react/jsx-runtime";var gt={type:"ANNOTATION_EDGE",zIndex:2e3},Ko=({id:e,source:t,target:o,sourceX:n,sourceY:r,targetX:a,targetY:s,selected:i,data:l})=>{let c=vi(),{zoom:g}=Ni(),{isMultipleSelection:f}=V(),m=c.find(x=>x.id===t),h=c.find(x=>x.id===o),[E,y,v]=yi({sourceX:n,sourceY:r,targetX:a,targetY:s}),p=i||(m==null?void 0:m.selected)||(h==null?void 0:h.selected),d=1/g;return Ti("g",{className:k("text-grey-400 hover:text-grey-500",{"text-blue-500 hover:text-blue-600":p}),children:[mt(bi,{id:e,path:E,strokeDasharray:4,className:k("stroke-2 stroke-current transition-colors duration-75",{"stroke-red-500 hover:stroke-red-600":l==null?void 0:l.hasError,"stroke-blue-500 hover:stroke-blue-600 drop-shadow-[0_0_3px_rgba(59,130,246,0.5)]":p&&!(l!=null&&l.hasError)})}),mt(hi,{children:mt("div",{className:"absolute z-[3000] pointer-events-auto flex flex-col items-center gap-1",style:{transform:`translate(-50%, -50%) translate(${y}px, ${v}px)`},children:i&&!f&&mt(xe,{edgeId:e,edgeType:"ANNOTATION_EDGE",style:{transform:`scale(${d})`}})})})]})};import{BaseEdge as wi,EdgeLabelRenderer as Ci,getSmoothStepPath as Ai,MarkerType as Xo,useNodes as Ii,useReactFlow as Si,useViewport as ki}from"@xyflow/react";import{useState as Li}from"react";import{useEffect as $o,useRef as _i,useState as xi}from"react";import{jsx as Zo}from"react/jsx-runtime";var F=({value:e,maxLength:t,onChange:o,isEditing:n,onBlur:r,className:a,style:s})=>{let i=_i(null),[l,c]=xi(!1);$o(()=>{c(n!=null?n:!1)},[n]),$o(()=>{if(l&&i.current){i.current.focus();let E=document.createRange();E.selectNodeContents(i.current),E.collapse(!1);let y=window.getSelection();y&&(y.removeAllRanges(),y.addRange(E))}},[l]);let g=E=>{if(E.stopPropagation(),!l){c(!0);return}if(!i.current)return;let y=document.createRange();y.selectNodeContents(i.current);let v=window.getSelection();v&&(v.removeAllRanges(),v.addRange(y))},f=E=>{let y=E.currentTarget.innerText.trim(),v=t&&y.length>=t,p=["Backspace","Delete","ArrowLeft","ArrowRight","ArrowUp","ArrowDown","Home","End","Tab","Enter","Escape","Shift"],d=E.ctrlKey||E.metaKey,x=d&&E.key==="a",u=d&&E.key==="c",_=d&&E.key==="x",I=d&&E.key==="v";function b(S){return/\w/.test(S)}if(y.length===0&&!b(E.key)&&!p.includes(E.key)&&!d){E.preventDefault();return}v&&(p.includes(E.key)||x||u||_||I||E.preventDefault())},m=E=>{if(!t)return;E.preventDefault();let y=E.clipboardData.getData("text/plain"),v=E.currentTarget.innerText,p=window.getSelection();if(!p||p.rangeCount===0)return;let d=p.getRangeAt(0);if((v.substring(0,d.startOffset)+y+v.substring(d.endOffset)).length>t){let u=t-(v.length-(d.endOffset-d.startOffset)),_=y.substring(0,Math.max(0,u));_&&(d.deleteContents(),d.insertNode(document.createTextNode(_)),d.setStartAfter(d.endContainer),d.collapse(!0),p.removeAllRanges(),p.addRange(d))}else d.deleteContents(),d.insertNode(document.createTextNode(y)),d.setStartAfter(d.endContainer),d.collapse(!0),p.removeAllRanges(),p.addRange(d)},h=E=>{c(!1);let y=E.currentTarget.innerText.trim();t&&y.length>t&&(y=y.substring(0,t)),E.currentTarget.innerText=y,r==null||r(),y!==e&&(o==null||o(y))};return Zo("div",{className:k("flex-1 p-2 self-stretch content-center border border-transparent overflow-hidden text-ellipsis text-sm text-center",a,{"border border-dashed border-grey-400":l}),style:s,onDoubleClick:g,children:Zo("div",{ref:i,className:"outline-none whitespace-pre-wrap overflow-hidden",contentEditable:l,suppressContentEditableWarning:!0,onKeyDown:f,onPaste:m,onBlur:h,children:e})})};import{jsx as ft,jsxs as qo}from"react/jsx-runtime";var te={type:"SEQUENCE_EDGE",zIndex:2e3,markerStart:{type:Xo.ArrowClosed},markerEnd:{type:Xo.Arrow},data:{label:""}},jo=({id:e,source:t,target:o,sourceX:n,sourceY:r,targetX:a,targetY:s,sourcePosition:i,targetPosition:l,data:c,selected:g})=>{let f=Ii(),{zoom:m}=ki(),{updateEdgeData:h}=Si(),{isMultipleSelection:E}=V(),[y,v]=Li(!1),p=f.find(L=>L.id===t),d=f.find(L=>L.id===o),[x,u,_]=Ai({sourceX:n,sourceY:r,sourcePosition:i,targetX:a,targetY:s,targetPosition:l}),I=g||(p==null?void 0:p.selected)||(d==null?void 0:d.selected),b=I?"sequence-edge-marker-highlighted":"sequence-edge-marker",N=y||(c==null?void 0:c.label.trim().length)>0,S=1/m,P=()=>{v(!0)},C=()=>{v(!1)},A=L=>{h(e,{label:L.trim()})};return qo("g",{className:k("text-grey-400 hover:text-grey-500",{"text-blue-500 hover:text-blue-600":I}),onBlur:C,onDoubleClick:P,children:[ft(wi,{id:e,path:x,markerEnd:`url(#${b})`,className:k("stroke-2 stroke-current transition-colors duration-75",{"stroke-red-500 hover:stroke-red-600":c==null?void 0:c.hasError,"stroke-blue-500 hover:stroke-blue-600 drop-shadow-[0_0_3px_rgba(59,130,246,0.5)]":I&&!(c!=null&&c.hasError)})}),ft(Ci,{children:qo("div",{className:"absolute z-[3000] pointer-events-auto flex flex-col items-center gap-1",style:{transform:`translate(-50%, -50%) translate(${u}px, ${_}px)`},children:[g&&!E&&ft(xe,{edgeId:e,edgeType:"SEQUENCE_EDGE",style:{transform:`scale(${S})`}}),N&&ft(F,{value:c==null?void 0:c.label,className:"min-w-8 max-w-56 bg-white rounded-md px-2 py-1 text-xs",isEditing:y,onChange:A})]})})]})};var Et=e=>e.some(t=>t.type==="START_EVENT"),bt=(e,t,o)=>{var a;let n=t.find(s=>s.id===e);return!n||n.type!=="GATEWAY"||((a=n.data)==null?void 0:a.variant)!=="EXCLUSIVE"?!1:o.filter(s=>s.source===e).length>=2},ht=(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"},yt=(e,t,o)=>{let n=t.find(a=>a.id===e);return!n||n.type!=="TASK"?!1:o.filter(a=>a.target===e).some(a=>{let s=t.find(i=>i.id===a.source);return(s==null?void 0:s.type)==="START_EVENT"})},vt=(e,t,o)=>{let n=t.find(a=>a.id===e);return!n||n.type!=="TASK"?!1:o.filter(a=>a.source===e).some(a=>{let s=t.find(i=>i.id===a.target);return(s==null?void 0:s.type)==="END_EVENT"})},Nt=(e,t)=>t.filter(n=>n.source===e).length>0,Tt=(e,t,o)=>{let n=t.find(a=>a.id===e);return!n||n.type!=="TASK"?!1:o.filter(a=>a.source===e).length>=2};var Pi=[e=>({isValid:e.sourceNodeId!==e.targetNodeId,reason:"self_connection_not_allowed"}),e=>({isValid:!bt(e.sourceNodeId,e.nodes,e.edges),reason:"gateway_limit_reached"}),e=>({isValid:!Tt(e.sourceNodeId,e.nodes,e.edges),reason:"task_limit_reached"}),e=>({isValid:!(e.sourceNodeType==="GATEWAY"&&e.targetNodeType==="GATEWAY"),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:!(ht(e.sourceNodeId,e.nodes)&&e.targetNodeType==="END_EVENT"),reason:"script_to_end_not_allowed"}),e=>({isValid:!(yt(e.sourceNodeId,e.nodes,e.edges)&&e.targetNodeType==="END_EVENT"),reason:"initial_activity_to_end_not_allowed"}),e=>({isValid:!(vt(e.sourceNodeId,e.nodes,e.edges)&&e.targetNodeType!=="ANNOTATION"),reason:"final_activity_cannot_connect"}),e=>({isValid:!(Nt(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"],LANE:["ANNOTATION"],ANNOTATION:[],UNSUPPORTED:[]}[e.sourceNodeType]||[]).includes(e.targetNodeType),reason:"connection_type_not_allowed"})],Jo=e=>{for(let t of Pi){let o=t(e);if(!o.isValid)return o}return{isValid:!0}};var Di=[{sourceTypes:["GATEWAY"],targetTypes:["TASK","GATEWAY"],validate:e=>({shouldDisable:bt(e.sourceNodeId,e.nodes,e.edges),reason:"gateway_limit_reached"})},{targetTypes:["START_EVENT"],validate:e=>({shouldDisable:Et(e.nodes),reason:"start_event_already_exists"})},{sourceTypes:["TASK"],targetTypes:["END_EVENT"],validate:e=>({shouldDisable:ht(e.sourceNodeId,e.nodes),reason:"script_to_end_not_allowed"})},{sourceTypes:["TASK"],targetTypes:["END_EVENT"],validate:e=>({shouldDisable:yt(e.sourceNodeId,e.nodes,e.edges),reason:"initial_activity_to_end_not_allowed"})},{sourceTypes:["TASK"],validate:e=>({shouldDisable:vt(e.sourceNodeId,e.nodes,e.edges)&&e.targetNodeType!=="ANNOTATION",reason:"final_activity_cannot_connect"})},{targetTypes:["END_EVENT"],validate:e=>({shouldDisable:Nt(e.sourceNodeId,e.edges),reason:"activity_has_outgoing_connections"})},{sourceTypes:["TASK"],validate:e=>({shouldDisable:Tt(e.sourceNodeId,e.nodes,e.edges)&&e.targetNodeType!=="ANNOTATION",reason:"task_limit_reached"})}],Qo=e=>{let t=Di.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 tn=({setEdges:e})=>{let{getNode:t,getEdges:o,getNodes:n}=Ri();return{isValidConnection:s=>{let i=t(s.source),l=t(s.target);if(!i||!l)return!1;let c={sourceNodeId:i.id,targetNodeId:l.id,sourceNodeType:i.type,targetNodeType:l.type,nodes:n(),edges:o()};return Jo(c).isValid},onConnect:s=>{e(i=>{let l=t(s.target);return(l==null?void 0:l.type)==="ANNOTATION"?en(T(T({},s),gt),i):en(T(T({},s),te),i)})}}};import{useState as pn}from"react";import{useTranslation as Vi}from"lecom-ui";import{useReactFlow as Mi}from"@xyflow/react";var He=(e=[])=>e.filter(t=>t.type==="START_EVENT"),me=(e=[])=>e.filter(t=>t.type==="END_EVENT"),de=(e=[])=>e.filter(t=>t.type==="TASK")||[],on=(e=[])=>e.filter(t=>{var o;return t.type==="TASK"&&((o=t.properties)==null?void 0:o.variant)==="SCRIPT"}),nn=(e=[])=>e.filter(t=>{var o;return t.type==="TASK"&&((o=t.properties)==null?void 0:o.variant)==="SUBPROCESS"}),_t=(e=[])=>e.filter(t=>t.type==="GATEWAY"),rn=(e=[])=>e.filter(t=>{var o;return t.type==="GATEWAY"&&((o=t.properties)==null?void 0:o.variant)==="EXCLUSIVE"}),j=(e,t=[])=>t.filter(o=>o.source===e),Be=(e,t=[])=>t.filter(o=>o.target===e),an=(e,t)=>{var n,r;let o=(n=t.nodes)==null?void 0:n.find(a=>a.id===e);return((r=o==null?void 0:o.properties)==null?void 0:r.attribute)==="LOOP"},sn=(e,t)=>{let o=j(e,t.edges||[]);for(let n of o){let r=(t.nodes||[]).find(a=>a.id===n.target);if(r&&r.type==="END_EVENT")return!0}return!1},ln=e=>e?/\w/g.test(e.trim()):!1,R=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:[]}},oe=(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)}},dn=(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 ze=[{id:"start_event_not_found",validate:e=>{let t=He(e.nodes);return R({isValid:t.length>=1})}},{id:"end_event_not_found",validate:e=>{let t=me(e.nodes);return R({isValid:t.length>=1})}},{id:"multiple_start_event_not_allowed",validate:e=>{let t=He(e.nodes),o=t.length===1;if(t.length===0)return R({isValid:!0});if(!o)return R({isValid:!1,nodeIds:t.map(a=>a.id)});let n=j(t[0].id,e.edges);if(!(n.length<=1)){let a=[...t.map(s=>s.id),...n.map(s=>s.target)];return R({isValid:!1,nodeIds:[...new Set(a)]})}return R({isValid:!0})}},{id:"task_flows_limit_exceeds",validate:e=>{let t=de(e.nodes),o=oe(t,n=>j(n.id,e.edges).length<=2);return R({isValid:o.isValid,nodeIds:o.invalidIds})}},{id:"task_label_empty",highlightRelatedEdges:!1,validate:e=>{let t=de(e.nodes),o=oe(t,n=>!!n.label&&n.label.trim()!=="");return R({isValid:o.isValid,nodeIds:o.invalidIds})}},{id:"task_label_length",highlightRelatedEdges:!1,validate:e=>{let o=de(e.nodes),n=oe(o,r=>!r.label||r.label.length<=60);return R({isValid:n.isValid,nodeIds:n.invalidIds})}},{id:"duplicate_task_name",highlightRelatedEdges:!1,validate:e=>{let t=de(e.nodes),o=new Map;for(let r of t){if(!r.label)continue;let a=r.label.trim();a&&(o.has(a)||o.set(a,[]),o.get(a).push(r))}let n=[];for(let[,r]of o.entries())r.length>1&&r.forEach(a=>n.push(a.id));return R({isValid:n.length===0,nodeIds:n})}},{id:"nested_gateway",validate:e=>{let t=_t(e.nodes),o=[],n=[];for(let r of t){let a=j(r.id,e.edges);for(let s of a){let i=e.nodes.find(l=>l.id===s.target);i&&i.type==="GATEWAY"&&(o.push(r.id,i.id),n.push(s.id))}}return R({isValid:o.length===0,nodeIds:o.length>0?[...new Set(o)]:[],edgeIds:n})}},{id:"events_nested",validate:e=>{let t=[...He(e.nodes),...me(e.nodes)],o=[],n=[];for(let r of t){let a=j(r.id,e.edges);for(let s of a){let i=e.nodes.find(l=>l.id===s.target);i&&(i.type==="START_EVENT"||i.type==="END_EVENT")&&(o.push(r.id,i.id),n.push(s.id))}}return R({isValid:o.length===0,nodeIds:o.length>0?[...new Set(o)]:[],edgeIds:n})}},{id:"flows_on_end_tasks_not_allowed",validate:e=>{let t=me(e.nodes),o=[],n=[];for(let r of t){let a=Be(r.id,e.edges);for(let s of a){let i=e.nodes.find(l=>l.id===s.source);if(i&&i.type==="TASK"){let l=j(i.id,e.edges);l.length>1&&(o.push(i.id),l.forEach(c=>n.push(c.id)))}}}return R({isValid:o.length===0,nodeIds:o,edgeIds:n})}},{id:"conditions_flows_limit_exceeds",validate:e=>{let t=rn(e.nodes),o=oe(t,r=>j(r.id,e.edges).length<=2),n=o.invalidIds.flatMap(r=>j(r,e.edges).map(a=>a.id));return R({isValid:o.isValid,nodeIds:o.invalidIds,edgeIds:n})}},{id:"activity_name_invalid",validate:e=>{let t=de(e.nodes),o=oe(t,n=>!n.label||ln(n.label));return R({isValid:o.isValid,nodeIds:o.invalidIds})}},{id:"final_activity_has_loop",validate:e=>{var s,i;if(!((s=e==null?void 0:e.nodes)!=null&&s.length)||!((i=e==null?void 0:e.edges)!=null&&i.length))return R({isValid:!0});let t=me(e.nodes)[0];if(!t)return R({isValid:!0});let o=Be(t.id,e.edges);if(!o.length)return R({isValid:!0});let r=de(e.nodes).filter(l=>o.some(c=>c.source===l.id)),a=oe(r,l=>!an(l.id,e));return R({isValid:a.isValid,nodeIds:a.isValid?[]:[t.id,...a.invalidIds]})}},{id:"concurrent_initial_and_final_event",validate:e=>{let t=de(e.nodes),o=me(e.nodes)[0];if(!o)return R({isValid:!0});let n=t.filter(l=>{let c=Be(l.id,e.edges),g=j(l.id,e.edges),f=c.some(h=>{var E;return((E=e.nodes.find(y=>y.id===h.source))==null?void 0:E.type)==="START_EVENT"}),m=g.some(h=>{var E;return((E=e.nodes.find(y=>y.id===h.target))==null?void 0:E.type)==="END_EVENT"});return f&&m}),r=Be(o.id,e.edges),a=r.length>1,s=r.map(l=>l.source),i={isValid:n.length===0&&!a,nodeIds:[...n.map(l=>l.id),...a?s:[]]};return R(i)}},{id:"gateway_flow_to_event",validate:e=>{let t=_t(e.nodes),o=[],n=[];for(let r of t){let a=j(r.id,e.edges);for(let s of a){let i=e.nodes.find(l=>l.id===s.target);i&&i.type==="END_EVENT"&&(o.push(r.id,i.id),n.push(s.id))}}return R({isValid:o.length===0,nodeIds:o.length>0?[...new Set(o)]:[],edgeIds:n})}},{id:"gateway_missing_output_streams",validate:e=>{let t=_t(e.nodes),o=oe(t,n=>j(n.id,e.edges).length>=1);return R({isValid:o.isValid,nodeIds:o.invalidIds})}},{id:"event_to_condition",validate:e=>{let t=[...He(e.nodes),...me(e.nodes)],o=[],n=[];for(let r of t){let a=j(r.id,e.edges);for(let s of a){let i=e.nodes.find(l=>l.id===s.target);i&&i.type==="GATEWAY"&&(o.push(r.id,i.id),n.push(s.id))}}return R({isValid:o.length===0,nodeIds:o.length>0?[...new Set(o)]:[],edgeIds:n})}},{id:"script_in_final_activity",validate:e=>{let t=on(e.nodes),o=oe(t,n=>!sn(n.id,e));return R({isValid:o.isValid,nodeIds:o.invalidIds})}},{id:"subprocess_referenced_not_configured",validate:e=>{let t=nn(e.nodes),o=oe(t,n=>{var r,a;return((r=n.properties)==null?void 0:r.subprocessRef)!==void 0&&((a=n.properties)==null?void 0:a.subprocessRef)!==""});return R({isValid:o.isValid,nodeIds:o.invalidIds})}}];var cn=e=>{e=e||{nodes:[],edges:[]},e.nodes=e.nodes||[],e.edges=e.edges||[];let t=[];for(let n of ze){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 un=()=>{let{t:e}=Vi(),[t,o]=pn(null),{setNodes:n,setEdges:r,getNodes:a,getEdges:s}=Mi(),[i,l]=pn(!1);return{validationResult:t,validateDiagram:m=>{let h=dn(m.nodes,m.edges),E=cn(h),y=E.errors.map(v=>w(T({},v),{message:e(`validation.errors.${v.id}`)}));return i||l(!0),{isValid:E.isValid,errors:y}},handleValidationComplete:m=>{if(o(m),!m)return;let h=[],E=[];m.errors.forEach(b=>{b.nodeIds&&b.nodeIds.length>0&&b.nodeIds.forEach(N=>h.push(N)),b.edgeIds&&b.edgeIds.length>0&&b.edgeIds.forEach(N=>E.push(N))});let y=[...new Set(h)];n(b=>b.map(N=>w(T({},N),{data:w(T({},N.data),{hasError:!1})}))),r(b=>b.map(N=>w(T({},N),{data:w(T({},N.data),{hasError:!1})})));let v=a(),p=s(),d=new Set(y),x=new Set;m.errors.forEach(b=>{var P,C;let N=ze.find(A=>A.id===b.id);(N==null?void 0:N.highlightRelatedEdges)!==!1&&((P=b.edgeIds)==null||P.forEach(A=>x.add(A)),(C=b.nodeIds)==null||C.forEach(A=>{p.forEach(L=>{(L.source===A||L.target===A)&&x.add(L.id)})}))});let u=new Set,_=new Set,I=new Set;v.forEach(b=>{b.type==="START_EVENT"?u.add(b.id):b.type==="END_EVENT"&&_.add(b.id)}),p.forEach(b=>{u.has(b.source)&&I.add(b.target),_.has(b.target)&&I.add(b.source)}),I.forEach(b=>{var N,S;if(d.has(b)){let P=(N=m.errors.find(A=>{var L;return(L=A.nodeIds)==null?void 0:L.includes(b)}))==null?void 0:N.id;((S=ze.find(A=>A.id===P))==null?void 0:S.highlightRelatedEdges)!==!1&&p.forEach(A=>{A.source===b&&_.has(A.target)&&(d.add(A.target),x.add(A.id)),A.target===b&&u.has(A.source)&&(d.add(A.source),x.add(A.id))})}}),d.size>0&&n(b=>b.map(N=>w(T({},N),{data:w(T({},N.data),{hasError:d.has(N.id)})}))),x.size>0&&r(b=>b.map(N=>w(T({},N),{data:w(T({},N.data),{hasError:x.has(N.id)})})))},clearValidation:()=>{o(null),l(!1),n(m=>m.map(h=>w(T({},h),{data:w(T({},h.data),{hasError:!1})}))),r(m=>m.map(h=>w(T({},h),{data:w(T({},h.data),{hasError:!1})})))},isAutoValidationEnabled:i}};import{useReactFlow as Oi}from"@xyflow/react";import{useTranslation as Gi}from"lecom-ui";import{useEffect as Hi}from"react";import{v7 as mn}from"uuid";var xt=(e,t)=>{let n=e.filter(a=>a.type==="TASK").map(a=>{var i;let s=(i=a.data)==null?void 0:i.label;if(s&&s.startsWith(`${t} `)){let l=s.match(new RegExp(`^${t} (\\d+)$`));return l?parseInt(l[1],10):0}return 0}).filter(a=>a>0),r=n.length>0?Math.max(...n)+1:1;return`${t} ${r}`},wt=(e,t)=>{let n=t.filter(i=>i.type==="TASK").map(i=>{var l;return(l=i.data)==null?void 0:l.label}).filter(Boolean);if(!n.includes(e))return e;let r=e.replace(/\s+\(\d+\)$/,""),a=n.filter(i=>i===r||i.startsWith(`${r} (`)).map(i=>{if(i===r)return 1;let l=i.match(/\s+\((\d+)\)$/);return l?parseInt(l[1],10):0}).filter(i=>i>0),s=2;for(;a.includes(s);)s++;return`${r} (${s})`};var Bi=15,gn="bpmn:selection",zi=e=>{if(!e||!(e instanceof HTMLElement))return!1;let t=e.tagName.toLowerCase(),o=t==="input"||t==="textarea",n=e.isContentEditable,r=t==="select",a=e.closest('[contenteditable="true"], input, textarea, select')!==null;return o||n||r||a},fn=e=>{if(!zi(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},En=({offset:e=Bi}={})=>{let{getNodes:t,setNodes:o,getEdges:n,setEdges:r}=Oi(),{t:a}=Gi();Hi(()=>{let s=l=>{var y,v;if(!fn(l))return;let c=t(),g=n(),f=c.filter(p=>p.selected);if(!f.length)return;l.preventDefault(),l.stopPropagation();let m=g.filter(p=>f.some(d=>d.id===p.source)&&f.some(d=>d.id===p.target)),E=JSON.stringify({nodes:f,edges:m});(y=l.clipboardData)==null||y.setData(gn,E),(v=l.clipboardData)==null||v.setData("text/plain",`BPMN Selection: ${f.length} nodes`)},i=l=>{var v,p;if(!fn(l))return;let c=(v=l.clipboardData)==null?void 0:v.getData(gn);if(!c)return;l.preventDefault(),l.stopPropagation();let g;try{g=JSON.parse(c)}catch(d){return}if(!((p=g.nodes)!=null&&p.length))return;let f=new Map,m=t(),h=[],E=g.nodes.map(d=>{var _;let x=mn();f.set(d.id,x);let u=w(T({},d),{id:x,selected:!0,position:{x:d.position.x+e,y:d.position.y+e}});if(d.type==="TASK"){let I=(_=d.data)==null?void 0:_.label,b=wt(I||a("bpmn.task.label.prefix"),[...m,...h]);u.data=w(T({},d.data),{label:b})}return h.push(u),u}),y=g.edges.map(d=>w(T({},d),{id:mn(),selected:!0,source:f.get(d.source)||d.source,target:f.get(d.target)||d.target}));o(d=>[...d.map(x=>w(T({},x),{selected:!1})),...E]),r(d=>[...d.map(x=>w(T({},x),{selected:!1})),...y])};return document.addEventListener("copy",s,!0),document.addEventListener("paste",i,!0),()=>{document.removeEventListener("copy",s,!0),document.removeEventListener("paste",i,!0)}},[t,o,n,r,e,a])};import{useReactFlow as Ji,useStoreApi as Qi}from"@xyflow/react";import{useTranslation as es}from"lecom-ui";import{v7 as Nn}from"uuid";import{create as Ui}from"zustand";var we=Ui(e=>({draggableNode:null,setDraggableNode:t=>{e({draggableNode:t})}}));import{BaseEdge as Fi,EdgeLabelRenderer as Wi,getSmoothStepPath as Yi,MarkerType as Ki,useNodes as $i,useReactFlow as Zi,useViewport as Xi}from"@xyflow/react";import{useState as qi}from"react";import{jsx as Ct,jsxs as bn}from"react/jsx-runtime";var Hm={type:"MESSAGE_EDGE",zIndex:2e3,markerEnd:{type:Ki.Arrow},data:{label:""}},hn=({id:e,source:t,target:o,sourceX:n,sourceY:r,targetX:a,targetY:s,sourcePosition:i,targetPosition:l,data:c,selected:g})=>{let f=$i(),{zoom:m}=Xi(),{updateEdgeData:h}=Zi(),{isMultipleSelection:E}=V(),[y,v]=qi(!1),p=f.find(L=>L.id===t),d=f.find(L=>L.id===o),[x,u,_]=Yi({sourceX:n,sourceY:r,sourcePosition:i,targetX:a,targetY:s,targetPosition:l}),I=g||(p==null?void 0:p.selected)||(d==null?void 0:d.selected),b=I?"sequence-edge-marker-highlighted":"sequence-edge-marker",N=y||(c==null?void 0:c.label.trim().length)>0,S=1/m,P=()=>{v(!0)},C=()=>{v(!1)},A=L=>{h(e,{label:L.trim()})};return bn("g",{className:k("text-grey-400 hover:text-grey-500",{"text-blue-500 hover:text-blue-600":I}),onBlur:C,onDoubleClick:P,children:[Ct(Fi,{id:e,path:x,markerEnd:`url(#${b})`,strokeDasharray:4,className:k("stroke-2 stroke-current transition-colors duration-75",{"stroke-red-500 hover:stroke-red-600":c==null?void 0:c.hasError,"stroke-blue-500 hover:stroke-blue-600 drop-shadow-[0_0_3px_rgba(59,130,246,0.5)]":I&&!(c!=null&&c.hasError)})}),Ct(Wi,{children:bn("div",{className:"absolute z-[3000] pointer-events-auto flex flex-col items-center gap-1",style:{transform:`translate(-50%, -50%) translate(${u}px, ${_}px)`},children:[g&&!E&&Ct(xe,{edgeId:e,edgeType:"MESSAGE_EDGE",style:{transform:`scale(${S})`}}),N&&Ct(F,{value:c==null?void 0:c.label,className:"min-w-8 max-w-56 bg-white rounded-md px-2 py-1 text-xs",isEditing:y,onChange:A})]})})]})};import{jsx as yn,jsxs as ji}from"react/jsx-runtime";var vn=({fromX:e,fromY:t,toX:o,toY:n})=>ji("g",{children:[yn("path",{fill:"none",className:"stroke-2 stroke-grey-400 animated",d:`M${e},${t} C${e} ${n} ${e} ${n} ${o},${n}`}),yn("circle",{cx:o,cy:n,fill:"none",r:4,className:"stroke-2 stroke-grey-500"})]});var Tn=({nodes:e,setNodes:t,setEdges:o})=>{let n=Qi(),{draggableNode:r,setDraggableNode:a}=we(),{getInternalNode:s,screenToFlowPosition:i}=Ji(),{t:l}=es(),c=p=>{let d="[&>div]:bg-blue-50 [&>div]:outline [&>div]:outline-2 [&>div]:outline-blue-500";t(x=>x.map(u=>w(T({},u),{className:u.id===p?d:""})))},g=()=>{let{nodeLookup:p}=n.getState();return Array.from(p.values())},f=p=>{let d=s(p.id),x=g();if(p.type==="LANE"){if(Te({parentId:p.id,nodes:e,includeTypes:["LANE"]})){c();return}let S=x.filter(A=>A.id!==p.id&&A.type==="LANE"&&!A.parentId),P=Me(d,S);if(!P){c();return}if(Te({parentId:P.id,nodes:e,excludeTypes:["LANE"]})){c();return}c(P.id);return}let _=x.filter(N=>N.id!==p.id&&N.type==="LANE"),I=Me(d,_);if(!I){c();return}if(Te({parentId:I.id,nodes:e,includeTypes:["LANE"]})){c();return}c(I.id)},m=p=>{p.preventDefault(),p.dataTransfer.dropEffect="move"},h=(p,d)=>{p.preventDefault(),f(d)},E=(p,d,x)=>{var S,P;let u=C=>C.map(A=>w(T({},A),{className:void 0}));if(p.parentId===d.id){let C=ue(d.id,x);t(se(u(C)));return}if(p.type==="LANE"){if(Te({parentId:d.id,nodes:x,excludeTypes:["LANE"]}))return;let L=x.filter(H=>H.parentId===d.id).reduce((H,be)=>{var pe,he;return H+((he=(pe=be.measured)==null?void 0:pe.height)!=null?he:0)},0),M={x:K.HEADER_WIDTH,y:L},O=x.map(H=>H.id===p.id?w(T({},H),{parentId:d.id,position:M,className:void 0}):w(T({},H),{className:void 0}));O=ue(d.id,O),t(se(O));return}if(Te({parentId:d.id,nodes:x,includeTypes:["LANE"]})){let C;if(p.parentId){let L=s(p.parentId),{x:M,y:O}=ie(L);C={x:M+((S=p.position.x)!=null?S:0),y:O+((P=p.position.y)!=null?P:0)}}let A=x.map(L=>L.id===p.id?w(T({},L),{position:C!=null?C:L.position,parentId:void 0,className:void 0}):w(T({},L),{className:void 0}));t(se(A));return}let b=Mo(p,d),N=x.map(C=>C.id===p.id?w(T({},C),{parentId:d.id,position:b,className:void 0}):w(T({},C),{className:void 0}));t(se(N))};return{onDragOver:m,onDrop:p=>{if(p.preventDefault(),!(r!=null&&r.type))return;let d=i({x:p.clientX,y:p.clientY}),x={width:G[r.type].MIN_WIDTH,height:G[r.type].MIN_HEIGHT},u={id:Nn(),type:r.type,position:d,measured:x,data:{label:r.type==="TASK"?xt(e,l("bpmn.task.label.prefix")):"",variant:r.variant,attribute:r.attribute}},_=w(T({},u),{internals:{positionAbsolute:d}}),I=g(),b=r.type==="LANE",N=I.filter(C=>b?C.type==="LANE"&&!C.parentId:C.type==="LANE"),S=Me(_,N);S?E(_,S,[...I,_]):t(C=>{let A=C.concat(u);return se(A)});let P=p.dataTransfer.getData("sourceId");if(P){let C={id:Nn(),source:P,target:u.id};if(r.type==="ANNOTATION"){o(A=>A.concat(T(T({},C),gt)));return}o(A=>A.concat(T(T({},C),te)))}a(null)},onNodeDrag:h,onNodeDragStop:async(p,d)=>{var S,P;let{nodeLookup:x}=n.getState(),u=s(d.id),_=Array.from(x.values()),I=d.type==="LANE",b=_.filter(C=>C.id!==d.id&&(I?C.type==="LANE"&&!C.parentId:C.type==="LANE")),N=Me(u,b);if(N){E(u,N,_);return}if(d.parentId){let C=s(d.parentId),{x:A,y:L}=ie(C),M={x:A+((S=d.position.x)!=null?S:0),y:L+((P=d.position.y)!=null?P:0)},O=e.map(H=>H.id===d.id?w(T({},H),{position:M,parentId:void 0}):H);O=ue(d.parentId,O),t(se(O))}}}};import{applyNodeChanges as ts}from"@xyflow/react";import{useCallback as os,useState as xn}from"react";function _n(e,t,o=5){var l,c,g,f,m,h,E,y;let n={horizontal:void 0,vertical:void 0,snapPosition:{x:void 0,y:void 0}},r=t.find(v=>v.id===e.id);if(!r||!e.position)return n;let a={left:e.position.x,right:e.position.x+((c=(l=r.measured)==null?void 0:l.width)!=null?c:0),top:e.position.y,bottom:e.position.y+((f=(g=r.measured)==null?void 0:g.height)!=null?f:0),width:(h=(m=r.measured)==null?void 0:m.width)!=null?h:0,height:(y=(E=r.measured)==null?void 0:E.height)!=null?y:0},s=o,i=o;return t.filter(v=>v.id!==r.id).reduce((v,p)=>{var C,A,L,M,O,H,be,pe;let d={left:p.position.x,right:p.position.x+((A=(C=p.measured)==null?void 0:C.width)!=null?A:0),top:p.position.y,bottom:p.position.y+((M=(L=p.measured)==null?void 0:L.height)!=null?M:0),width:(H=(O=p.measured)==null?void 0:O.width)!=null?H:0,height:(pe=(be=p.measured)==null?void 0:be.height)!=null?pe:0},x=Math.abs(a.left-d.left);x<i&&(v.snapPosition.x=d.left,v.vertical=d.left,i=x);let u=Math.abs(a.right-d.right);u<i&&(v.snapPosition.x=d.right-a.width,v.vertical=d.right,i=u);let _=Math.abs(a.left-d.right);_<i&&(v.snapPosition.x=d.right,v.vertical=d.right,i=_);let I=Math.abs(a.right-d.left);I<i&&(v.snapPosition.x=d.left-a.width,v.vertical=d.left,i=I);let b=Math.abs(a.top-d.top);b<s&&(v.snapPosition.y=d.top,v.horizontal=d.top,s=b);let N=Math.abs(a.bottom-d.top);N<s&&(v.snapPosition.y=d.top-a.height,v.horizontal=d.top,s=N);let S=Math.abs(a.bottom-d.bottom);S<s&&(v.snapPosition.y=d.bottom-a.height,v.horizontal=d.bottom,s=S);let P=Math.abs(a.top-d.bottom);return P<s&&(v.snapPosition.y=d.bottom,v.horizontal=d.bottom,s=P),v},n)}var wn=()=>{let[e,t]=xn(void 0),[o,n]=xn(void 0),r=os((a,s)=>{var i,l;if(t(void 0),n(void 0),a.length===1&&a[0].type==="position"&&a[0].dragging&&a[0].position){let c=_n(a[0],s);a[0].position.x=(i=c.snapPosition.x)!=null?i:a[0].position.x,a[0].position.y=(l=c.snapPosition.y)!=null?l:a[0].position.y,t(c.horizontal),n(c.vertical)}return ts(a,s)},[]);return{helperLineHorizontal:e,helperLineVertical:o,customApplyNodeChanges:r}};import{useReactFlow as rs}from"@xyflow/react";import{v7 as kn}from"uuid";var An={"start-event":"START_EVENT","end-event":"END_EVENT",task:"TASK","gateway-exclusive":"GATEWAY"},In={"start-event":"","end-event":"",task:"","gateway-exclusive":"EXCLUSIVE"},Cn=(e,t)=>{if(!e){console.warn("Step not found");return}e=e.trim();let o=e.match(/(\<.*?\>)/)||[],n=e.match(/(\[.*?\])/)||[],r=e.match(/(\{.*?\})/)||[],a=e.match(/(--.*|\|.*?\|)/i)||[],s="",i="",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",i=n[1].replace(/\[|\]/g,""),e=e.replace(n[1],"")),r.length&&(s="gateway-exclusive",i=r[1].replace(/\{|\}/g,""),e=e.replace(r[1],"")),a.length&&(l=a[1].replace(/(\||--)/g,""),e=e.replace(a[1],"")),e=e.trim(),t[e]||(t[e]={type:s,label:i}),{step:e,type:s,label:i,edgeLabel:l}},ns=e=>{e=e||"";let t=e.trim().split(`
|
|
2
|
+
`),o={},n=[];return t.forEach(r=>{r=r||"";let a=r.trim().split("-->");if(a.length!==2){console.warn("Invalid number of steps");return}let s=Cn(a[0],o),i=Cn(a[1],o);s&&i&&n.push({sourceId:s.step,targetId:i.step,label:s.edgeLabel||i.edgeLabel||""})}),{components:o,connections:n}},Sn=e=>{let{components:t,connections:o}=ns(e);return{nodes:t,edges:o}};var Ln=()=>{let{setNodes:e,setEdges:t,fitView:o}=rs();return{createDiagram:r=>{let{nodes:a,edges:s}=Sn(r),i=[],l=new Map;for(let[m,h]of Object.entries(a)){let E=kn(),y=An[h.type],v=In[h.type];l.set(m,E);let p=G[y].MIN_WIDTH,d=G[y].MIN_HEIGHT;i.push({id:E,type:y,data:{label:h.label||"",variant:v,attribute:""},position:{x:0,y:0},width:p,height:d,measured:{width:p,height:d}})}let c=[];for(let m of s){let h=w(T({},te),{id:kn(),source:l.get(m.sourceId)||m.sourceId,target:l.get(m.targetId)||m.targetId});c.push(h)}let{nodes:g,edges:f}=Ho(i,c);e(g),t(f),o()}}};import{useEffect as as,useCallback as is}from"react";var ss={origin:"*",debug:!1};function Pn(e,t=ss){let{origin:o,debug:n}=t,r=is((a,s)=>{n&&console.debug("[postMessage] sending:",{type:a,payload:s}),window.parent.postMessage({type:a,payload:s},o||"*")},[o,n]);return as(()=>{let a=s=>{let{type:i,data:l}=s.data||{};n&&console.debug("[postMessage] received:",s.data),i&&e[i]&&e[i](l)};return window.addEventListener("message",a),()=>window.removeEventListener("message",a)},[e,n]),{sendMessage:r}}import{useReactFlow as ls}from"@xyflow/react";var Dn=(e,t)=>{let{getNodes:o,getEdges:n}=ls();return{selectElement:s=>{let i=o().map(c=>w(T({},c),{selected:c.id===s})),l=n().map(c=>w(T({},c),{selected:c.id===s}));return e(i),t(l),!0},isReady:()=>!0}};import{useReactFlow as ds}from"@xyflow/react";import{useCallback as Ue,useState as Rn}from"react";import{useDebouncedCallback as cs}from"use-debounce";var ps={nodes:[],edges:[]},us=500,Vn=10,Mn=()=>{let{getNodes:e,getEdges:t,setNodes:o,setEdges:n}=ds(),[r,a]=Rn([ps]),[s,i]=Rn(0),l=r[s],c=s>0,g=s<r.length-1,f=Ue(d=>{o(r[d].nodes),n(r[d].edges)},[r,o,n]),m=Ue(()=>{if(s>0){let d=s-1;i(d),f(d)}},[s,f]),h=Ue(()=>{if(s<r.length-1){let d=s+1;i(d),f(d)}},[r,s,f]),E=d=>{let u=[...r.slice(0,s+1),d],_=u.length>Vn?u.slice(u.length-Vn):u;a(_),i(_.length-1)},y=cs(()=>{let d=e(),x=t(),u={nodes:d,edges:x};JSON.stringify(l)!==JSON.stringify(u)&&E(u)},us),v=Ue(d=>{if(d==="forceSave"){y();return}d.some(u=>u.type!=="select")&&y()},[y]),p=Ue(()=>{a([]),i(0)},[]);return{undo:m,redo:h,saveHistory:v,canUndo:c,canRedo:g,clearHistory:p}};import{jsx as On}from"react/jsx-runtime";var qt=({id:e,className:t})=>On("marker",{id:e,className:k("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:On("path",{d:"M 0 0 L 10 5 L 0 10 Z"})});import{jsx as jt,jsxs as ms}from"react/jsx-runtime";var Gn=()=>jt("svg",{style:{position:"absolute",top:0,left:0},children:ms("defs",{children:[jt(qt,{id:"sequence-edge-marker",className:"text-grey-400"}),jt(qt,{id:"sequence-edge-marker-highlighted",className:"text-blue-500"})]})});import{useKeyPress as or}from"@xyflow/react";import{Button as to,Tooltip as oo,TooltipContent as no,TooltipTrigger as ro,useTranslation as dl}from"lecom-ui";import{HandIcon as cl,MapIcon as pl,MousePointerIcon as ul}from"lucide-react";import{useCallback as ml,useEffect as nr}from"react";import{useStore as gs}from"@xyflow/react";var fs=e=>({unselectAll:e.unselectNodesAndEdges}),Fe=()=>{let{unselectAll:e}=gs(fs);return{deselectAll:async()=>(e(),new Promise(o=>{setTimeout(o,1e3)}))}};import{Tooltip as Bs,TooltipContent as zs,TooltipTrigger as Us,useNotificationToast as Fs,useTranslation as Ws}from"lecom-ui";var We=(p=>(p.START_EVENT="START_EVENT",p.END_EVENT="END_EVENT",p.TASK="TASK",p.SUBPROCESS="SUBPROCESS",p.GATEWAY="GATEWAY",p.ANNOTATION="ANNOTATION",p.CONNECTION="CONNECTION",p.INTERMEDIATE_EVENT="INTERMEDIATE_EVENT",p.ACTIVITY="ACTIVITY",p.PROCESS_INTERFACE="PROCESS_INTERFACE",p.WORKFLOW_INTERFACE="WORKFLOW_INTERFACE",p.VARIANT_ACTIVITY="VARIANT_ACTIVITY",p.AUTO_ACTIVITY="AUTO_ACTIVITY",p.DATA_STORE="DATA_STORE",p.DATA_OBJECT="DATA_OBJECT",p.DATA_OUTPUT="DATA_OUTPUT",p.DATA_INPUT="DATA_INPUT",p))(We||{});import{useReactFlow as Ls}from"@xyflow/react";import{useNotificationToast as Ps,useTranslation as Ds,Button as Rs}from"lecom-ui";var Hn=async e=>new Promise((t,o)=>{let n=new FileReader;n.onload=r=>{var a;t((a=r.target)==null?void 0:a.result)},n.onerror=r=>{var a;o((a=r.target)==null?void 0:a.error)},n.readAsText(e)});function Bn({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(`
|
|
3
|
+
`),a=encodeURI(r);At(a,`${o}.csv`)}var At=(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 Cs}from"uuid";import{xml2json as Es,json2xml as jg}from"xml-js";var bs={compact:!0,spaces:4},hs=e=>e.replaceAll(`
|
|
4
|
+
`,"
");function zn(e,t=bs){if(e)return JSON.parse(Es(e,w(T({},t),{attributeValueFn:hs})))}function Un(e){return e==null?void 0:e.replaceAll("
"," ")}import{v7 as vs}from"uuid";var nf={START_EVENT:"START_EVENT",END_EVENT:"END_EVENT",TASK:"TASK",GATEWAY:"GATEWAY",ANNOTATION:"ANNOTATION"},Fn={script:"SCRIPT",subprocess:"SUBPROCESS"},Wn={complex:"COMPLEX",none:"EXCLUSIVE",exclusive:"EXCLUSIVE",parallel:"PARALLEL"};var Ce=({cell:e,type:t,variant:o=""})=>{let{_attributes:n,mxGeometry:r}=e,{value:a}=n,s=Number(r._attributes.width),i=Number(r._attributes.height);return{id:n.id,type:t,data:{label:a||"",variant:o,attribute:""},position:{x:Number(r._attributes.x),y:Number(r._attributes.y)},width:s,height:i,measured:{width:s,height:i}}},Ns=e=>{let{subType:t,style:o}=e._attributes,n="imported";return["none"].includes(t)||(n="adapted"),e.mxGeometry._attributes.width=G.START_EVENT.MIN_WIDTH,e.mxGeometry._attributes.height=G.START_EVENT.MIN_HEIGHT,{node:Ce({cell:e,type:"START_EVENT"}),status:n,originalType:o}},Ts=e=>{let{subType:t,style:o}=e==null?void 0:e._attributes,n="imported";return["none"].includes(t)||(n="adapted"),e.mxGeometry._attributes.width=G.END_EVENT.MIN_WIDTH,e.mxGeometry._attributes.height=G.END_EVENT.MIN_HEIGHT,{node:Ce({cell:e,type:"END_EVENT"}),status:n,originalType:o}},_s=e=>{let{subType:t,style:o}=e==null?void 0:e._attributes,n=Fn[t],r="imported";return["script","none"].includes(t)||(r="adapted"),e.mxGeometry._attributes.width=De(e.mxGeometry._attributes.width,G.TASK.MIN_WIDTH),e.mxGeometry._attributes.height=De(e.mxGeometry._attributes.height,G.TASK.MIN_HEIGHT),{node:Ce({cell:e,type:"TASK",variant:n}),status:r,originalType:o}},xs=e=>{let{style:t,subType:o}=e==null?void 0:e._attributes,n=Wn[o],r=["none","inclusive","event-based"],a="imported";return r.includes(o)&&(a="adapted"),e.mxGeometry._attributes.width=G.GATEWAY.MIN_WIDTH,e.mxGeometry._attributes.height=G.GATEWAY.MIN_HEIGHT,{node:Ce({cell:e,type:"GATEWAY",variant:n}),status:a,originalType:t}},ws=e=>{let{style:t}=e==null?void 0:e._attributes;return e.mxGeometry._attributes.width=De(e.mxGeometry._attributes.width,G.ANNOTATION.MIN_WIDTH),e.mxGeometry._attributes.height=De(e.mxGeometry._attributes.height,G.ANNOTATION.MIN_HEIGHT),{node:Ce({cell:e,type:"ANNOTATION"}),status:"imported",originalType:t}},Yn=e=>{let{style:t}=e==null?void 0:e._attributes;return e.mxGeometry._attributes.width=G.UNSUPPORTED.MIN_WIDTH,e.mxGeometry._attributes.height=G.UNSUPPORTED.MIN_HEIGHT,{node:Ce({cell:e,type:"UNSUPPORTED"}),status:"unsupported",originalType:t}},Kn=(e,t)=>{let{source:o,target:n}=e._attributes;return w(T({},te),{id:vs(),source:t.get(o)||o,target:t.get(n)||n})},$n={TASK:_s,GATEWAY:xs,START_EVENT:Ns,END_EVENT:Ts,ANNOTATION:ws};var As=e=>{var s;let t=new Map,o=Object.values(We),n=e.filter(i=>{var l;return o.includes((l=i._attributes)==null?void 0:l.type)}),r=[],a=[];for(let i of n){let l=Cs(),{type:c}=i._attributes,g=$n[c]||Yn;t.set((s=i._attributes)==null?void 0:s.id,l),i._attributes.id=l;let{node:f,status:m,originalType:h}=g(i);r.push(f),a.push({originalType:h,type:f.type,variant:f.data.variant,value:Un(f.data.label),status:m})}return{nodes:r,governanceIdToNodeIdMap:t,summary:a}},Is=(e,t)=>e.filter(r=>{var a;return(a=r._attributes)==null?void 0:a.edge}).map(r=>Kn(r,t)),Ss=e=>{let{mxGraphModel:t}=e,{nodes:o,governanceIdToNodeIdMap:n,summary:r}=As(t.root.mxCell),a=Is(t.root.mxCell,n);return{nodes:o,edges:a,summary:r}},ks=async e=>{let t=await Hn(e),o=zn(t);if(!o)throw new Error("EMPTY_FILE");let{metadata:n,mxGraphModel:r}=o.modeler||{},a=(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(!a||!s)throw new Error("INVALID_FILE");if(!Object.keys(r.root.mxCell||{}).length)throw new Error("CONTAIN_NO_CELLS");return{metadata:n,mxGraphModel:r}},Zn=async e=>{try{let t=await ks(e),{nodes:o,edges:n,summary:r}=Ss(t)||{};return{nodes:o,edges:n,summary:r}}catch(t){throw t}};import{jsx as Vs}from"react/jsx-runtime";var Xn=()=>{let{t:e}=Ds(),{toast:t}=Ps(),{setNodes:o,setEdges:n,fitView:r}=Ls(),a=i=>{let l=[e("adapter.governance.report.columns.type"),e("adapter.governance.report.columns.value"),e("adapter.governance.report.columns.status")],c=i.map(g=>[g.originalType,g.value,e(`adapter.governance.report.status.${g.status.toLowerCase()}`)]);t({variant:"warning",content:e("adapter.governance.success.incompatible_cells"),duration:1e3*60*1,action:Vs(Rs,{size:"small",variant:"ghost",onClick:()=>Bn({columns:l,rows:c,fileName:"governance-imported-cells"}),children:e("adapter.governance.action.download")})})};return{createDiagram:async i=>{try{let{nodes:l,edges:c,summary:g}=await Zn(i);if(o(m=>m.concat(l)),n(m=>m.concat(c)),r(),g.some(m=>m.status==="unsupported")){a(g);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 Ms}from"lecom-ui";import{useRef as Os}from"react";import{Fragment as Gs,jsx as qn,jsxs as Hs}from"react/jsx-runtime";var jn=i=>{var l=i,{children:e,accept:t="*",multiple:o=!1,disabled:n=!1,onClick:r,onFilesSelected:a}=l,s=ae(l,["children","accept","multiple","disabled","onClick","onFilesSelected"]);let c=Os(null),g=m=>{let h=m.target.files;h!=null&&h.length&&a(h),c.current&&(c.current.value="")};return Hs(Gs,{children:[qn(Ms,w(T({onClick:m=>{var h;(h=c.current)==null||h.click(),r==null||r(m)}},s),{children:e})),qn("input",{type:"file",ref:c,className:"sr-only",accept:t,multiple:o,disabled:n,onChange:g})]})};import{jsx as It,jsxs as Ys}from"react/jsx-runtime";var Jn=({disabled:e=!1})=>{let{t}=Ws(),{toast:o}=Fs(),{createDiagram:n}=Xn(),r=()=>{if(e){o({variant:"error",content:t("adapter.governance.error.ALREADY_INITIALIZED")});return}},a=s=>{let i=s[0];if(!i){o({variant:"error",content:t("adapter.governance.error.NO_FILE")});return}n(i)};return Ys(Bs,{children:[It(Us,{asChild:!0,children:It(jn,{className:"[&>svg]:size-7 p-0",variant:"ghost",size:"small",color:"grey",iconButton:!0,accept:".mdr",disabled:e,onClick:r,onFilesSelected:a,children:It(Ao,{})})}),It(zs,{color:"black",children:t("editor.controls.actions.import_governance")})]})};import{jsx as Ks}from"react/jsx-runtime";var Jt=({shortcut:e})=>Ks("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 Qs,DropdownMenu as el,DropdownMenuContent as tl,DropdownMenuItem as eo,DropdownMenuTrigger as ol,Tooltip as St,TooltipContent as kt,TooltipTrigger as Lt,useTranslation as nl}from"lecom-ui";import{FileCodeIcon as rl,FileImageIcon as al,FolderOutputIcon as il,PrinterIcon as sl}from"lucide-react";import{useState as ll}from"react";import{useReactFlow as $s}from"@xyflow/react";import{toPng as Qn,toSvg as Zs}from"html-to-image";import{toast as Xs,useTranslation as qs}from"lecom-ui";import{useState as js}from"react";var Js=3,Qt="diagram",er=()=>{let{t:e}=qs(),{getNodes:t}=$s(),{deselectAll:o}=Fe(),[n,r]=js({png:!1,html:!1,print:!1}),a=()=>{let{x:g,y:f,width:m,height:h}=zo(t());return{width:m,height:h,style:{width:`${m}px`,height:`${h}px`,transform:`translate(${-g}px, ${-f}px)`}}},s=async(g,f)=>{r(w(T({},n),{[f]:!0})),await o();try{let m=Bo();if(!m)throw new Error("Flow element not found");let h=a();return await g(m,h)}catch(m){Xs({content:e("editor.controls.actions.export.feedback.error"),variant:"error"})}finally{r(w(T({},n),{[f]:!1}))}};return{exportAsPng:async(g=Qt)=>{await s(async(f,m)=>{let h=await Qn(f,w(T({},m),{backgroundColor:"#fcfcfc"}));At(h,`${g}.png`)},"png")},exportAsHtml:async(g=Qt)=>{await s(async(f,m)=>{let h=await Zs(f,w(T({},m),{backgroundColor:"#fcfcfc"})),E=`
|
|
5
5
|
<!DOCTYPE html>
|
|
6
6
|
<html>
|
|
7
7
|
<head>
|
|
8
|
-
<title>${
|
|
8
|
+
<title>${g}</title>
|
|
9
9
|
<style>
|
|
10
10
|
body { margin: 0; display: flex; justify-content: center; align-items: center; min-height: 100vh; background: #eee; }
|
|
11
11
|
img { max-width: 95%; max-height: 95vh; background: white; box-shadow: 0 2px 10px rgba(0,0,0,0.1); }
|
|
12
12
|
</style>
|
|
13
13
|
</head>
|
|
14
14
|
<body>
|
|
15
|
-
<img src="${
|
|
15
|
+
<img src="${h}" alt="Diagram" />
|
|
16
16
|
</body>
|
|
17
17
|
</html>
|
|
18
|
-
`,
|
|
18
|
+
`,y=new Blob([E],{type:"text/html"}),v=URL.createObjectURL(y);At(v,`${g}.html`),setTimeout(()=>URL.revokeObjectURL(v),100)},"html")},printDiagram:async(g=Qt)=>{await s(async(f,m)=>{let h=await Qn(f,w(T({},m),{pixelRatio:Js})),E=window.open("","_blank");if(!E)throw new Error("Failed to open print window.");let y=E.document;y.open(),y.write(`
|
|
19
19
|
<!DOCTYPE html>
|
|
20
20
|
<html>
|
|
21
21
|
<head>
|
|
22
|
-
<title>${
|
|
22
|
+
<title>${g}</title>
|
|
23
23
|
<style>
|
|
24
24
|
@page { size: auto; margin: 0mm; }
|
|
25
25
|
@media print { body { margin: 0; } img { width: 100%; height: auto; vertical-align: middle; } }
|
|
@@ -28,7 +28,7 @@ var pa=Object.defineProperty,ua=Object.defineProperties;var ma=Object.getOwnProp
|
|
|
28
28
|
</style>
|
|
29
29
|
</head>
|
|
30
30
|
<body>
|
|
31
|
-
<img src="${
|
|
31
|
+
<img src="${h}" alt="Diagram" onload="window.print(); window.close();" />
|
|
32
32
|
</body>
|
|
33
33
|
</html>
|
|
34
|
-
`),T.close()},"print")},isPrintingPng:n.png,isPrintingHtml:n.html,isPrinting:n.print}};import{jsx as z,jsxs as Ie}from"react/jsx-runtime";function qn(){let{t:e}=Ws(),{exportAsPng:t,exportAsHtml:o,printDiagram:n,isPrinting:a,isPrintingPng:i,isPrintingHtml:s}=Zn(),[r,l]=Zs(!1);return Ie(zs,{modal:!1,open:r,onOpenChange:l,children:[z(Us,{asChild:!0,children:z("div",{children:Ie(wt,{children:[z(At,{asChild:!0,children:z(Bs,{size:"small",variant:"ghost",color:"grey",iconButton:!0,children:z($s,{})})}),!r&&z(Ct,{color:"black",children:e("editor.controls.actions.export.title")})]})})}),Ie(Fs,{align:"center",side:"top",sideOffset:16,className:"min-w-0 flex flex-col gap-2 p-2 shadow-sm",children:[Ie(wt,{children:[z(At,{asChild:!0,children:z(to,{className:"p-1.5",disabled:i,onClick:()=>t(),children:z(Ks,{})})}),z(Ct,{side:"right",color:"black",children:e("editor.controls.actions.export.png")})]}),Ie(wt,{children:[z(At,{asChild:!0,children:z(to,{className:"p-1.5",disabled:s,onClick:()=>o(),children:z(Ys,{})})}),z(Ct,{side:"right",color:"black",children:e("editor.controls.actions.export.html")})]}),Ie(wt,{children:[z(At,{asChild:!0,children:z(to,{className:"p-1.5",disabled:a,onClick:()=>n(),children:z(Xs,{})})}),z(Ct,{side:"right",color:"black",children:e("editor.controls.actions.export.print")})]})]})]})}import{Fragment as ol,jsx as F,jsxs as me}from"react/jsx-runtime";var Qn=({nodes:e,isReadOnly:t,diagram:o,onValidationComplete:n,onValidateDiagram:a})=>{let{t:i}=qs(),{deselectAll:s}=We(),{isMoveTool:r,isHandTool:l,activeMoveTool:c,activeHandTool:u,isMinimapOpen:E,setIsMinimapOpen:f}=O(),b=jn(["v","V"]),g=jn(["h","H"]),T=tl(()=>{s(),u()},[s,u]),N=()=>{s();let m=a(o);n&&n(m)};return Jn(()=>{b&&!r&&!t&&c()},[b,c,r,t]),Jn(()=>{g&&!l&&!t&&T()},[g,T,l,t]),me("div",{className:"flex items-center gap-2 px-3 py-2 bg-white rounded-sm shadow-md",children:[!t&&me(ol,{children:[me(St,{children:[F(Lt,{asChild:!0,children:F(It,{size:"small",variant:"ghost",color:"grey",className:L(r&&"bg-grey-400"),iconButton:!0,onClick:c,children:F(el,{})})}),me(kt,{color:"black",children:[i("editor.controls.actions.move_tool"),F("span",{className:"ml-1 text-grey-400",children:"V"})]})]}),me(St,{children:[F(Lt,{asChild:!0,children:F(It,{size:"small",variant:"ghost",color:"grey",className:L(l&&"bg-grey-400"),iconButton:!0,onClick:T,children:F(js,{})})}),me(kt,{color:"black",children:[i("editor.controls.actions.hand_tool")," ",F("span",{className:"ml-2 text-grey-400",children:"H"})]})]}),me(St,{children:[F(Lt,{asChild:!0,children:F(It,{size:"small",variant:"ghost",color:"grey",iconButton:!0,onClick:N,children:F(Js,{})})}),F(kt,{color:"black",children:i("editor.controls.actions.check")})]})]}),F(qn,{}),!t&&F($n,{disabled:e.length>0}),me(St,{children:[F(Lt,{asChild:!0,children:F(It,{size:"small",variant:"ghost",color:"grey",className:L(E&&"bg-grey-400"),iconButton:!0,onClick:()=>f(!E),children:F(Qs,{})})}),F(kt,{color:"black",children:i(E?"editor.controls.actions.minimap.close":"editor.controls.actions.minimap.open")})]})]})};import{Button as er,Tooltip as tr,TooltipContent as or,TooltipTrigger as nr,useTranslation as nl}from"lecom-ui";import{RedoIcon as rl,UndoIcon as al}from"lucide-react";import{jsx as ge,jsxs as oo}from"react/jsx-runtime";var rr=({undo:e,redo:t,canUndo:o,canRedo:n})=>{let{t:a}=nl();return oo("div",{className:"flex items-center gap-2 px-3 py-2 bg-white rounded-sm shadow-md",children:[oo(tr,{children:[ge(nr,{asChild:!0,children:ge(er,{size:"small",variant:"ghost",color:"grey",iconButton:!0,disabled:!o,onClick:e,children:ge(al,{})})}),ge(or,{color:"black",children:a("editor.controls.history.undo")})]}),oo(tr,{children:[ge(nr,{asChild:!0,children:ge(er,{size:"small",variant:"ghost",color:"grey",iconButton:!0,disabled:!n,onClick:t,children:ge(rl,{})})}),ge(or,{color:"black",children:a("editor.controls.history.redo")})]})]})};import{useReactFlow as il}from"@xyflow/react";import{Button as Pt,Tooltip as Dt,TooltipContent as Rt,TooltipTrigger as Vt,useTranslation as sl}from"lecom-ui";import{ScanIcon as ll,ZoomIn as dl,ZoomOut as cl}from"lucide-react";import{jsx as Y,jsxs as Ke}from"react/jsx-runtime";var ar=()=>{let{t:e}=sl(),{zoomIn:t,zoomOut:o,zoomTo:n,fitView:a}=il();return Ke("div",{className:"flex items-center gap-2 px-3 py-2 bg-white rounded-sm shadow-md",children:[Ke(Dt,{children:[Y(Vt,{asChild:!0,children:Y(Pt,{size:"small",variant:"ghost",color:"grey",iconButton:!0,onClick:()=>a(),children:Y(ll,{})})}),Y(Rt,{color:"black",children:e("editor.controls.zoom.fit")})]}),Ke(Dt,{children:[Y(Vt,{asChild:!0,children:Y(Pt,{size:"small",variant:"ghost",color:"grey",iconButton:!0,onClick:()=>o(),children:Y(cl,{})})}),Y(Rt,{color:"black",children:e("editor.controls.zoom.out")})]}),Ke(Dt,{children:[Y(Vt,{asChild:!0,children:Y(Pt,{size:"small",variant:"ghost",color:"grey",iconButton:!0,onClick:()=>n(1),children:Y(Ao,{})})}),Y(Rt,{color:"black",children:e("editor.controls.zoom.reset")})]}),Ke(Dt,{children:[Y(Vt,{asChild:!0,children:Y(Pt,{size:"small",variant:"ghost",color:"grey",iconButton:!0,onClick:()=>t(),children:Y(dl,{})})}),Y(Rt,{color:"black",children:e("editor.controls.zoom.in")})]})]})};import{Position as Zl,useReactFlow as ql}from"@xyflow/react";import{Handle as ir,useReactFlow as pl}from"@xyflow/react";import{jsx as sr}from"react/jsx-runtime";var K=a=>{var i=a,{type:e,position:t,className:o}=i,n=le(i,["type","position","className"]);return sr(ir,_({type:e,position:t,className:L("size-2.5 border border-grey-400 bg-white",o)},n))},Mt=r=>{var l=r,{nodeId:e,nodeType:t,gatewayVariant:o,type:n,position:a,className:i}=l,s=le(l,["nodeId","nodeType","gatewayVariant","type","position","className"]);let{getEdges:c}=pl(),E=n!=="source"?!1:t==="TASK"?c().filter(g=>g.source===e).length>=2:t==="GATEWAY"&&o==="EXCLUSIVE"?c().filter(g=>g.source===e).length>=2:!1;return sr(ir,_({type:n,position:a,className:L("size-2.5 border border-grey-400 bg-white transition-all duration-200",{"opacity-50 cursor-not-allowed pointer-events-none":E,"hover:border-grey-500":!E},i),style:{pointerEvents:E?"none":"auto"}},s))};import{NodeResizer as ul,useReactFlow as ml}from"@xyflow/react";import{orderBy as gl}from"lodash";import{jsx as fl}from"react/jsx-runtime";var Se=o=>{var n=o,{nodeId:e}=n,t=le(n,["nodeId"]);let{getNode:a,getNodes:i,setNodes:s}=ml(),r=({width:l,height:c})=>{if(!e)return;let u=a(e);if((u==null?void 0:u.type)!=="LANE")return;let E=[...i()],f=!u.parentId,b=f?u.id:u.parentId,g=E.filter(m=>m.type==="LANE"&&m.parentId===b);if(!g.length)return;let T=gl(g,["position.y"]),N=0;T.forEach((m,d)=>{var x,S;let w=d===T.length-1,p=(S=(x=m.measured)==null?void 0:x.height)!=null?S:0;E=E.map(h=>{if(h.id===m.id){let y=f?l-$.HEADER_WIDTH:l,k=I(_({},h),{width:y,measured:I(_({},h.measured),{width:y}),position:I(_({},h.position),{y:N})});return w&&f&&(k.height=c-N),k}return h}),N+=p}),E=E.map(m=>{if(m.id===b){let d=f?l:l+$.HEADER_WIDTH;return I(_({},m),{width:d,height:f?c:N,measured:{width:d,height:f?c:N}})}return m}),s(E)};return fl(ul,_({nodeId:e,handleClassName:"size-1.5 bg-blue-400",lineClassName:"border-blue-400/90 border-dashed",onResizeEnd:(l,c)=>r(c)},t))};import{Position as Bl,NodeToolbar as zl,useReactFlow as Fl}from"@xyflow/react";import{Button as Ul,Tooltip as Wl,TooltipContent as Yl,TooltipTrigger as Kl,useTranslation as $l}from"lecom-ui";import{useNodesData as El,useReactFlow as bl}from"@xyflow/react";import{Button as hl,DropdownMenu as vl,DropdownMenuContent as yl,DropdownMenuGroup as Tl,DropdownMenuItem as Nl,DropdownMenuLabel as _l,DropdownMenuTrigger as xl,Tooltip as wl,TooltipContent as Cl,TooltipTrigger as Al,useTranslation as Il}from"lecom-ui";import{WrenchIcon as Sl}from"lucide-react";import{jsx as pe,jsxs as Ot}from"react/jsx-runtime";var lr=({nodeId:e})=>{let{t}=Il(),{updateNodeData:o}=bl(),n=El(e),a=i=>{(n==null?void 0:n.data.variant)!==i&&o(e,{variant:i})};return Ot(vl,{children:[Ot(wl,{children:[pe(Al,{asChild:!0,children:pe(xl,{asChild:!0,children:pe(hl,{variant:"ghost",color:"grey",size:"small",iconButton:!0,children:pe(Sl,{})})})}),pe(Cl,{color:"black",children:t("bpmn.gateway.menu.title")})]}),Ot(yl,{align:"start",className:"w-60 bg-white text-grey-600",children:[pe(_l,{className:"flex items-center",children:pe("div",{className:"flex-1 text-sm font-semibold",children:t("bpmn.gateway.menu.title")})}),pe(Tl,{children:Object.entries(st).map(([i,s])=>Ot(Nl,{className:L({"bg-grey-100 text-blue-500":(n==null?void 0:n.data.variant)===i}),onClick:()=>a(i),children:[pe(s.icon,{className:"stroke-current"}),t(`bpmn.gateway.variant.${i.toLowerCase()}`)]},i))})]})]})};import{useNodesData as kl,useReactFlow as Ll}from"@xyflow/react";import{Button as dr,DropdownMenu as Pl,DropdownMenuContent as Dl,DropdownMenuGroup as Rl,DropdownMenuItem as Vl,DropdownMenuLabel as Ml,DropdownMenuTrigger as Ol,Tooltip as no,TooltipContent as ro,TooltipTrigger as ao,useTranslation as Gl}from"lecom-ui";import{WrenchIcon as Hl}from"lucide-react";import{jsx as X,jsxs as he}from"react/jsx-runtime";var cr=({nodeId:e})=>{let{t}=Gl(),{updateNodeData:o,getEdges:n,getNode:a}=Ll(),i=kl(e),r=n().filter(f=>f.source===e).some(f=>{let b=a(f.target);return(b==null?void 0:b.type)==="END_EVENT"}),l=u=>{o(e,{variant:(i==null?void 0:i.data.variant)===u?"":u})},c=u=>{o(e,{attribute:(i==null?void 0:i.data.attribute)===u?"":u})};return he(Pl,{children:[he(no,{children:[X(ao,{asChild:!0,children:X(Ol,{asChild:!0,children:X(dr,{variant:"ghost",color:"grey",size:"small",iconButton:!0,children:X(Hl,{})})})}),X(ro,{color:"black",children:t("bpmn.task.menu.title")})]}),he(Dl,{align:"start",className:"w-60 bg-white text-grey-600",children:[he(Ml,{className:"flex items-center gap-1",children:[X("div",{className:"flex-1 text-sm font-semibold",children:t("bpmn.task.menu.title")}),X("div",{className:"flex items-center gap-1",children:Object.entries(it).map(([u,E])=>{let f=u==="LOOP"&&r,b=f?t("editor.task_menu.loop_not_allowed_when_connected_to_end"):void 0;return he(no,{children:[X(ao,{asChild:!0,children:X(dr,{variant:"ghost",color:"grey",size:"small",iconButton:!0,disabled:f,className:L({"bg-grey-100 text-blue-500":(i==null?void 0:i.data.attribute)===u,"opacity-50 cursor-not-allowed":f}),onClick:f?void 0:()=>c(u),children:X(E.icon,{className:"stroke-inherit"})})}),b&&X(ro,{color:"black",children:b})]},u)})})]}),X(Rl,{children:Object.entries(at).map(([u,E])=>{let f=u==="SCRIPT"&&r;return he(no,{children:[X(ao,{asChild:!0,children:he(Vl,{className:L({"bg-grey-100 text-blue-500":(i==null?void 0:i.data.variant)===u,"opacity-50 cursor-not-allowed":f}),disabled:f,onClick:f?void 0:()=>l(u),children:[X(E.icon,{className:"stroke-current"}),t(`bpmn.task.variant.${u.toLowerCase()}`)]})}),f&&X(ro,{color:"black",children:t("editor.task_menu.script_not_allowed_when_connected_to_end")})]},u)})})]})]})};import{jsx as J,jsxs as Xl}from"react/jsx-runtime";var Z=({nodeId:e,nodeType:t,isChild:o,isVisible:n})=>{var C;let{t:a}=$l(),{setDraggableNode:i}=Ce(),{getNode:s,getEdges:r,getNodes:l}=Fl(),c=()=>{var R;if(t!=="GATEWAY")return!1;let v=s(e);return((R=v==null?void 0:v.data)==null?void 0:R.variant)!=="EXCLUSIVE"?!1:r().filter(G=>G.source===e).length>=2},u=()=>l().some(A=>A.type==="START_EVENT"),E=()=>{var A;if(t!=="TASK")return!1;let v=s(e);return((A=v==null?void 0:v.data)==null?void 0:A.variant)==="SCRIPT"},f=()=>t!=="TASK"?!1:r().filter(D=>D.target===e).some(D=>{let R=s(D.source);return(R==null?void 0:R.type)==="START_EVENT"}),b=()=>t!=="TASK"?!1:r().filter(D=>D.source===e).some(D=>{let R=s(D.target);return(R==null?void 0:R.type)==="END_EVENT"}),g=()=>t!=="TASK"?!1:r().filter(D=>D.source===e).length>0,T=()=>t!=="TASK"?!1:r().filter(D=>D.source===e).length>=2,N=c(),m=u(),d=E(),w=f(),p=b(),x=g(),S=T(),h=({event:v,type:A,variant:D})=>{i({type:A,variant:D}),v.dataTransfer.effectAllowed="move",v.dataTransfer.setData("sourceId",e)},y={START_EVENT:{type:"START_EVENT",icon:Ve,label:a("bpmn.start_event.variant.default")},END_EVENT:{type:"END_EVENT",icon:Ne,label:a("bpmn.end_event.variant.default")},TASK:{type:"TASK",icon:Ve,label:a("bpmn.task.variant.default")},GATEWAY:{type:"GATEWAY",variant:"EXCLUSIVE",icon:_e,label:a("bpmn.gateway.variant.exclusive")},ANNOTATION:{type:"ANNOTATION",icon:et,label:a("bpmn.annotation.variant.default")}},k=[{component:J(mt,{elementId:e})}],P={START_EVENT:[y.TASK,y.ANNOTATION,...k],TASK:[{component:J(He,{elementId:e})},{component:J(cr,{nodeId:e})},y.TASK,y.GATEWAY,y.END_EVENT,y.ANNOTATION,...k],GATEWAY:[{component:J(He,{elementId:e})},{component:J(lr,{nodeId:e})},y.TASK,y.GATEWAY,y.ANNOTATION,...k],END_EVENT:[y.ANNOTATION,...k],LANE:[...o?[]:[y.ANNOTATION],...k],ANNOTATION:[...k],UNSUPPORTED:[...k]};return J(zl,{className:"-top-6 flex items-center gap-1 px-3 py-2 bg-white rounded-sm shadow-md",position:Bl.Right,align:"start",isVisible:n,children:(C=P[t])==null?void 0:C.map((v,A)=>{if(v.component)return J("div",{children:v.component},A);let D=N&&(v.type==="TASK"||v.type==="GATEWAY"),R=t==="GATEWAY"&&v.type==="GATEWAY",G=m&&v.type==="START_EVENT",ie=d&&v.type==="END_EVENT",ee=w&&v.type==="END_EVENT",se=p&&v.type!=="ANNOTATION",qe=x&&v.type==="END_EVENT",je=S&&v.type!=="ANNOTATION",ye=D||R||G||ie||ee||se||qe||je,Ht=D?a("editor.toolbar.gateway_limit_reached"):R?a("editor.toolbar.gateway_to_gateway_not_allowed"):G?a("editor.toolbar.start_event_already_exists"):ie?a("editor.toolbar.script_to_end_not_allowed"):ee?a("editor.toolbar.initial_activity_to_end_not_allowed"):se?a("editor.toolbar.final_activity_cannot_connect"):qe?a("editor.toolbar.activity_has_outgoing_connections"):je?a("editor.toolbar.task_limit_reached"):v.label;return Xl(Wl,{children:[J(Kl,{asChild:!0,children:J(Ul,{variant:"ghost",color:"grey",size:"small",iconButton:!0,draggable:!ye,disabled:ye,className:ye?"opacity-50 cursor-not-allowed":"",onDragStart:ye?void 0:Bt=>h({event:Bt,type:v.type,variant:v.variant}),children:v.icon&&J(v.icon,{size:16})})}),J(Yl,{color:"black",children:Ht})]},A)})})};import{Fragment as jl,jsx as $e,jsxs as Jl}from"react/jsx-runtime";var pr=({id:e,data:t,selected:o,dragging:n})=>{let{updateNodeData:a}=ql(),{isMultipleSelection:i}=O(),s=r=>{a(e,{label:r})};return Jl(jl,{children:[$e("div",{className:L("relative w-full h-full min-w-44 min-h-16 flex text-grey-400 hover:text-grey-500 bg-white rounded-sm overflow-hidden 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:$e(W,{value:t.label,className:"m-1 text-grey-600",onChange:s})}),$e(Z,{nodeId:e,nodeType:"ANNOTATION",isVisible:!n&&!i&&o}),$e(Se,{isVisible:!n&&!i&&o,minWidth:ct.MIN_WIDTH,minHeight:ct.MIN_HEIGHT}),$e(K,{type:"target",position:Zl.Left})]})};import{Position as ur,useReactFlow as Ql}from"@xyflow/react";import{useState as ed}from"react";import{Fragment as td,jsx as ke,jsxs as mr}from"react/jsx-runtime";var gr=({id:e,data:t,selected:o,dragging:n})=>{let{updateNodeData:a}=Ql(),{isMultipleSelection:i}=O(),[s,r]=ed(!1),l=E=>{a(e,{label:E})};return mr(td,{children:[mr("div",{className:"relative",onBlur:()=>{r(!1)},onDoubleClick:()=>{r(!0)},children:[ke(Ne,{className:L("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})}),ke("div",{className:"absolute top-9 left-1/2 -translate-x-1/2 max-w-80 w-max",children:ke(W,{value:t.label,isEditing:s,onChange:l})})]}),ke(Z,{nodeId:e,nodeType:"END_EVENT",isVisible:!n&&!i&&o}),ke(K,{type:"source",position:ur.Right}),ke(K,{type:"target",position:ur.Left})]})};import{Position as fr,useReactFlow as od}from"@xyflow/react";import{useState as nd}from"react";import{Fragment as rd,jsx as Le,jsxs as Er}from"react/jsx-runtime";var br=({id:e,data:t,selected:o,dragging:n})=>{let a=st[t.variant].icon,{updateNodeData:i}=od(),{isMultipleSelection:s}=O(),[r,l]=nd(!1),c=f=>{i(e,{label:f})};return Er(rd,{children:[Er("div",{className:"relative",onBlur:()=>{l(!1)},onDoubleClick:()=>{l(!0)},children:[Le(a,{className:L("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})}),Le("div",{className:"absolute top-14 left-1/2 -translate-x-1/2 max-w-80 w-max",children:Le(W,{value:t.label,isEditing:r,onChange:c})})]}),Le(Z,{nodeId:e,nodeType:"GATEWAY",isVisible:!n&&!s&&o}),Le(K,{type:"target",position:fr.Left}),Le(Mt,{type:"source",position:fr.Right,nodeId:e,nodeType:"GATEWAY",gatewayVariant:t.variant})]})};import{Position as ad,useReactFlow as id}from"@xyflow/react";import{useState as sd}from"react";import{Fragment as ld,jsx as Xe,jsxs as hr}from"react/jsx-runtime";var vr=({id:e,data:t,selected:o,dragging:n})=>{let{updateNodeData:a}=id(),{isMultipleSelection:i}=O(),[s,r]=sd(!1),l=E=>{a(e,{label:E})};return hr(ld,{children:[hr("div",{className:"relative",onBlur:()=>{r(!1)},onDoubleClick:()=>{r(!0)},children:[Xe(nt,{className:L("size-9 hover:stroke-[#54890b] transition-colors duration-75",{"stroke-blue-500 hover:stroke-blue-600":o,"stroke-red-500 hover:stroke-red-600 drop-shadow-[0_0_3px_rgba(255,0,0,0.5)] fill-red-100":t.hasError})}),Xe("div",{className:"absolute top-9 left-1/2 -translate-x-1/2 max-w-80 w-max",children:Xe(W,{value:t.label,isEditing:s,onChange:l})})]}),Xe(Z,{nodeId:e,nodeType:"START_EVENT",isVisible:!n&&!i&&o}),Xe(K,{type:"source",position:ad.Right})]})};import{Position as yr,useReactFlow as dd}from"@xyflow/react";import{useTranslation as cd}from"lecom-ui";import{Fragment as pd,jsx as re,jsxs as Tr}from"react/jsx-runtime";var Nr=({id:e,data:t,selected:o,dragging:n})=>{let{updateNodeData:a,getNodes:i}=dd(),{isMultipleSelection:s}=O(),{t:r}=cd(),l=g=>{let T=g.trim(),N=t.label||"";if(T===N)return;let m=i(),d=T;T||(d=yt(m,r("bpmn.task.label.prefix")));let w=Tt(d,m);w!==N&&a(e,{label:w})},c=t.variant?at[t.variant].icon:null,u=t.attribute?it[t.attribute].icon:null,E=t.variant==="SUBPROCESS",f=c&&!E,b=u||E;return Tr(pd,{children:[Tr("div",{className:L("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 overflow-hidden hover:shadow-md transition-colors duration-75",{"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:[re(W,{value:t.label,maxLength:60,className:L("m-1",{"py-6":f||b}),onChange:l}),c&&re("div",{className:L("absolute flex items-center p-1",E?"bottom-0":"top-0 left-0"),children:re(c,{size:16,className:L(t.hasError?"text-red-500":"text-grey-500")})}),u&&re("div",{className:"absolute bottom-0 left-0 w-full flex items-center justify-center",children:re("div",{className:L("flex items-center w-16 p-1",E?"justify-between":"justify-center"),children:re(u,{size:16,className:L(t.hasError?"text-red-500":"text-grey-500")})})})]}),re(Z,{nodeId:e,nodeType:"TASK",isVisible:!n&&!s&&o}),re(Se,{isVisible:!n&&!s&&o,minWidth:lt.MIN_WIDTH,minHeight:lt.MIN_HEIGHT}),re(Mt,{type:"source",position:yr.Right,nodeId:e,nodeType:"TASK"}),re(K,{type:"target",position:yr.Left})]})};import{Position as _r}from"@xyflow/react";import{Fragment as ud,jsx as Gt,jsxs as md}from"react/jsx-runtime";var xr=({id:e,data:t,selected:o,dragging:n})=>{let{isMultipleSelection:a}=O();return md(ud,{children:[Gt("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}),Gt(Z,{nodeId:e,nodeType:"UNSUPPORTED",isVisible:!n&&!a&&o}),Gt(K,{type:"source",position:_r.Right}),Gt(K,{type:"target",position:_r.Left})]})};import{Position as gd,useReactFlow as fd}from"@xyflow/react";import{orderBy as Ed}from"lodash";import{useMemo as wr}from"react";import{Fragment as bd,jsx as ve,jsxs as Cr}from"react/jsx-runtime";var Ar=({id:e,data:t,selected:o,dragging:n,parentId:a})=>{let{updateNodeData:i,getNodes:s}=fd(),{isMultipleSelection:r}=O(),l=s(),c=!a,u=wr(()=>Ed([...l.filter(g=>g.parentId===e&&g.type==="LANE")],"position.y","asc"),[l,e]),E=c?dt.MIN_WIDTH:$.MIN_WIDTH,f=wr(()=>{if(c&&u.length>1){let g=[...u];return g.pop(),g.reduce((N,m)=>{var d,w;return N+((w=(d=m.measured)==null?void 0:d.height)!=null?w:0)},0)+$.MIN_HEIGHT}return $.MIN_HEIGHT},[c,u]),b=g=>{i(e,{label:g})};return Cr(bd,{children:[Cr("div",{className:L("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:[ve("div",{className:"flex align-items justify-center w-10 border-r-2 border-grey-400 bg-white",children:ve("div",{className:"relative flex-1 [writing-mode:vertical-rl] [text-orientation:sideways] transform rotate-180",children:ve(W,{value:t.label,className:"w-full h-full",onChange:b})})}),ve("div",{className:"flex-1"})]}),ve(Z,{nodeId:e,nodeType:"LANE",isChild:!c,isVisible:!n&&!r&&o}),ve(Se,{nodeId:e,minWidth:E,minHeight:f,isVisible:!n&&!r&&o}),c&&ve(K,{type:"source",position:gd.Right})]})};var Ir={START_EVENT:vr,END_EVENT:gr,TASK:Nr,GATEWAY:br,ANNOTATION:pr,LANE:Ar,UNSUPPORTED:xr},Sr={SEQUENCE_EDGE:Xo,MESSAGE_EDGE:mn,ANNOTATION_EDGE:Uo},kr="#fafafa",Lr="#bebebe",Pr=1,Dr=10,Rr="bottom-left",Vr=.5,Mr=4,Or={x:0,y:0,zoom:.75};import{useStore as hd}from"@xyflow/react";import{useEffect as vd,useRef as yd}from"react";import{jsx as Nd}from"react/jsx-runtime";var Td=e=>({width:e.width,height:e.height,transform:e.transform}),Gr=({horizontal:e,vertical:t,color:o="#3367d9",dashArray:n=[6,6]})=>{let{width:a,height:i,transform:s}=hd(Td),r=yd(null);return vd(()=>{let l=r.current,c=l==null?void 0:l.getContext("2d");if(!c||!l)return;let u=window.devicePixelRatio;l.width=a*u,l.height=i*u,c.scale(u,u),c.clearRect(0,0,a,i),c.strokeStyle=o,c.setLineDash(n),typeof t=="number"&&(c.moveTo(t*s[2]+s[0],0),c.lineTo(t*s[2]+s[0],i),c.stroke()),typeof e=="number"&&(c.moveTo(0,e*s[2]+s[1]),c.lineTo(a,e*s[2]+s[1]),c.stroke())},[a,i,s,e,t,o,n]),Nd("canvas",{ref:r,className:"react-flow__canvas w-full h-full absolute z-10 pointer-events-none"})};import{Button as Hr,Dialog as _d,DialogContent as xd,DialogFooter as wd,DialogHeader as Cd,DialogTitle as Ad,Notification as Id,Typography as io,useTranslation as Sd}from"lecom-ui";import{jsx as ae,jsxs as so}from"react/jsx-runtime";var Br=({pendingDelete:e,setPendingDelete:t,setNodes:o,setEdges:n})=>{let{t:a}=Sd(),i=!!e,s=()=>{let{nodes:l,edges:c}=e||{};l!=null&&l.length&&o(u=>u.filter(E=>!l.some(f=>f.id===E.id))),c!=null&&c.length&&n(u=>u.filter(E=>!c.some(f=>f.id===E.id))),t(null)},r=()=>{t(null)};return ae(_d,{open:i,onOpenChange:r,children:so(xd,{className:"w-[488px] max-w-fit gap-2",children:[ae(Cd,{children:ae(Ad,{children:ae(io,{variant:"heading-small-600",textColor:"text-grey-950",children:a("editor.modals.delete_elements.title")})})}),so("div",{className:"flex flex-col gap-2",children:[ae("div",{className:"py-2",children:ae(Id,{type:"callout",variant:"warning",content:a("editor.modals.delete_elements.callout")})}),ae(io,{variant:"body-large-400",textColor:"text-grey-800",className:"py-2",children:a("editor.modals.delete_elements.content")})]}),so(wd,{className:"flex items-center flex-row justify-end w-full gap-2",children:[ae(Hr,{variant:"outlined",color:"grey",disabled:!1,size:"small",onClick:r,children:ae(io,{variant:"body-medium-500",textColor:"text-grey-800",children:a("editor.modals.delete_elements.cancel")})}),ae(Hr,{size:"small",variant:"filled",color:"destructive",autoFocus:!0,onClick:s,children:a("editor.modals.delete_elements.confirm")})]})]})})};import{useReactFlow as kd}from"@xyflow/react";import{Button as Ld,Tooltip as Pd,TooltipContent as Dd,TooltipTrigger as Rd,useTranslation as Vd}from"lecom-ui";import{jsx as Ze,jsxs as Md}from"react/jsx-runtime";var zr=()=>{let{t:e}=Vd(),{setDraggableNode:t}=Ce(),{getNodes:o}=kd(),a=o().some(l=>l.type==="START_EVENT"),i=[{type:"START_EVENT",icon:nt,label:e("bpmn.start_event.variant.default")},{type:"END_EVENT",icon:Ne,label:e("bpmn.end_event.variant.default")},{type:"TASK",icon:Ve,label:e("bpmn.task.variant.default")},{type:"TASK",variant:"SUBPROCESS",icon:Po,label:e("bpmn.task.variant.subprocess")},{type:"TASK",variant:"SCRIPT",icon:Lo,label:e("bpmn.task.variant.script")},{type:"TASK",attribute:"LOOP",icon:ko,label:e("bpmn.task.attribute.loop")},{type:"GATEWAY",variant:"EXCLUSIVE",icon:_e,label:e("bpmn.gateway.variant.exclusive")},{type:"GATEWAY",variant:"PARALLEL",icon:ot,label:e("bpmn.gateway.variant.parallel")},{type:"GATEWAY",variant:"COMPLEX",icon:tt,label:e("bpmn.gateway.variant.complex")},{type:"LANE",icon:Co,label:e("bpmn.lane.variant.default")},{type:"ANNOTATION",icon:et,label:e("bpmn.annotation.variant.default")}],s=(r,l)=>{t({type:l.type,variant:l.variant,attribute:l.attribute}),r.dataTransfer.effectAllowed="move"};return Ze("aside",{className:"sidebar absolute z-[1] top-4 left-4 grid grid-cols-1 gap-2 p-2 bg-white rounded-md shadow-md",children:i.map((r,l)=>{let c=a&&r.type==="START_EVENT",u=c?e("editor.toolbar.start_event_already_exists"):r.label;return Md(Pd,{children:[Ze(Rd,{asChild:!0,children:Ze(Ld,{className:`[&>svg]:size-6 ${c?"opacity-50 cursor-not-allowed":""}`,size:"small",variant:"ghost",color:"grey",draggable:!c,disabled:c,iconButton:!0,onDragStart:c?void 0:E=>s(E,r),children:Ze(r.icon,{})},l)}),Ze(Dd,{color:"black",side:"right",children:u})]},l)})})};import{Button as Od,useTranslation as Gd}from"lecom-ui";import{AlertCircleIcon as Hd,CircleCheckIcon as Bd,XIcon as zd}from"lucide-react";import{useEffect as Fd,useState as Ud}from"react";import{jsx as Q,jsxs as lo}from"react/jsx-runtime";var Fr=({validationResult:e,onClose:t})=>{let{t:o}=Gd(),[n,a]=Ud(!1);if(Fd(()=>{e&&a(!0)},[e]),!n||!e)return null;let{isValid:i,errors:s}=e;return lo("div",{className:L("w-72 max-w-[95vw] rounded-lg border px-4 py-2",{"bg-green-100":i,"bg-red-100":!i}),children:[lo("div",{className:"flex flex-row items-start gap-4",children:[Q("div",{className:"flex-shrink-0",children:i?Q(Bd,{className:"text-green-500 size-5"}):Q(Hd,{className:"text-red-500 size-5"})}),lo("div",{className:"body-medium-500 text-grey-800",children:[Q("div",{children:o(i?"validation.success.title":"validation.errors.title")}),!i&&Q("div",{children:o("validation.errors.subtitle")})]}),Q(Od,{variant:"ghost",size:"small",color:"grey",className:"size-5 hover:bg-transparent",iconButton:!0,onClick:()=>{a(!1),t()},children:Q(zd,{})})]}),Q("div",{className:"max-h-80 overflow-y-auto mt-2 px-9 body-medium-400 text-grey-800",children:i?Q("p",{children:o("validation.success.message")}):Q("div",{className:"list-disc list-inside",children:s.map(r=>Q("li",{className:"mb-1",children:r.message},r.id))})})]})};import{jsx as q,jsxs as uo}from"react/jsx-runtime";var rc=[],Wr=Qd(({mode:e="edit"},t)=>{let o=tc(!1),[n,a,i]=qd([]),[s,r,l]=Zd([]),[c,u]=oc(null),{isMoveTool:E,isHandTool:f,isReadOnly:b,setIsReadOnly:g,setIsMultipleSelection:T,isMinimapOpen:N}=O(),{validationResult:m,handleValidationComplete:d,clearValidation:w,isAutoValidationEnabled:p,validateDiagram:x}=sn(),{getNode:S,getNodes:h,getEdges:y}=Jd(),k=In(a,r);ec(t,()=>k);let{onNodeDrag:P,onDrop:C,onDragOver:v,onNodeDragStop:A}=bn({nodes:n,setNodes:a,setEdges:r}),{isValidConnection:D,onConnect:R}=qo({setEdges:r});pn();let{createDiagram:G}=Cn(),{undo:ie,redo:ee,saveHistory:se,canUndo:qe,canRedo:je}=Ln(),{helperLineHorizontal:ye,helperLineVertical:Ht}=yn();An({LIA_CREATE_DIAGRAM:G,CLEAR_DIAGRAM:()=>{a([]),r([])}}),mo(()=>{g(e==="readonly")},[e,g]),mo(()=>{if(n.length===0&&s.length===0&&e!=="readonly"){let Pe=po(),sa={id:Pe,type:"START_EVENT",position:{x:200,y:300},data:{}},ho=po(),la={id:ho,type:"TASK",position:{x:400,y:270},data:{label:Ur.t("editor.toolbar.initial_task")}},da=po(),ca=I(_({},oe),{id:da,source:Pe,target:ho});a([sa,la]),r([ca])}},[n.length,s.length,e,a,r]);let Bt=()=>{w()},Jr=co(({nodes:U,edges:B})=>{let Te=U.length+B.length>1;T(Te)},[T]);jd({onChange:Jr});let Qr=U=>{let B=S(U.id);if(B!=null&&B.parentId&&(B==null?void 0:B.type)==="LANE"){let Te=fe(B.parentId,n.filter(Pe=>Pe.id!==B.id&&Pe.type==="LANE"));a(ce(Te))}},ea=U=>{U.forEach(B=>{switch(B.type){case"remove":Qr(B);break}})},ta=co(()=>{if(!p){o.current=!1;return}let U=h(),B=y(),Te=x({nodes:U,edges:B});d(Te),o.current=!1},[p,h,y,x,d]),Eo=nc(ta,300),bo=co(()=>{p&&!o.current&&(o.current=!0,Eo())},[p,Eo]),oa=U=>{i(U),se(U),bo(),ea(U)},na=U=>{l(U),se(U),bo()},ra=()=>{se("forceSave")},aa=async({nodes:U,edges:B})=>(u({nodes:U,edges:B}),!1),ia={nodes:n,edges:s};return uo("div",{className:"w-full h-full",children:[!b&&q(zr,{}),q(Dn,{}),uo(Kd,{edges:s,nodes:n,nodeTypes:Ir,edgeTypes:Sr,minZoom:Vr,maxZoom:Mr,panOnDrag:f||b?!0:rc,panOnScroll:!0,selectionOnDrag:!0,elevateEdgesOnSelect:!0,elevateNodesOnSelect:!0,elementsSelectable:!b&&E,nodesConnectable:!b&&E,nodesDraggable:!b&&E,isValidConnection:D,connectionLineComponent:fn,onConnect:R,onDrop:C,onDropCapture:ra,onDragOver:v,onNodesChange:oa,onEdgesChange:na,onNodeDrag:P,onNodeDragStop:A,onBeforeDelete:aa,selectionMode:Xd.Partial,proOptions:{hideAttribution:!0},multiSelectionKeyCode:"Shift",deleteKeyCode:"Delete",selectionKeyCode:null,snapToGrid:!0,snapGrid:[10,10],defaultViewport:Or,connectOnClick:!0,children:[N&&q(Yd,{pannable:!0,zoomable:!0,position:Rr,className:"shadow-md rounded-md"}),uo("div",{className:"absolute z-10 bottom-4 left-1/2 -translate-x-1/2 flex gap-4",children:[!b&&q(rr,{canUndo:qe,canRedo:je,undo:ie,redo:ee}),q(Qn,{nodes:n,isReadOnly:b,diagram:ia,onValidationComplete:d,onValidateDiagram:x}),q(ar,{})]}),q(Gr,{horizontal:ye,vertical:Ht}),q(Wd,{gap:Dr,size:Pr,color:Lr,bgColor:kr}),m&&q("div",{className:"absolute top-6 right-6 z-[1000]",children:q(Fr,{validationResult:m,onClose:Bt})})]}),q(Br,{pendingDelete:c,setPendingDelete:u,setNodes:a,setEdges:r})]})});Wr.displayName="Editor";var ac=({mode:e,locale:t="pt_BR",onConfigureElement:o,selectorRef:n})=>(mo(()=>{t&&Ur.changeLanguage(t)},[t]),q($d,{children:q(Bo,{value:{onConfigureElement:o},children:q(Wr,{mode:e,ref:n})})})),go=ac;var fo=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 ic,Translations as sc}from"lecom-ui";var Yr={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",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"},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"}},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:"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 Kr={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",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"},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"}},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:"Lane"}},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 $r={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",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"},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"}},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:"Lane"}},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 Xr={pt_BR:$r,en_US:Yr,es_ES:Kr};var Zr,qr,lc=(qr=(Zr=fo("LecomUserLanguage"))!=null?Zr:fo("org.springframework.web.servlet.i18n.CookieLocaleResolver.LOCALE"))!=null?qr:sc.PT_BR;ic({lng:lc,resources:Xr});import{jsx as jr}from"react/jsx-runtime";var W2=e=>jr(No,{children:jr(go,_({},e))});export{Ft as ActivityVariant,Wt as ComplexVariant,zt as ElementType,Yt as ExclusiveVariant,te as GatewayVariant,W2 as Modeler,Ut as RoutingVariant,We as useSelectionUtils};
|
|
34
|
+
`),y.close()},"print")},isPrintingPng:n.png,isPrintingHtml:n.html,isPrinting:n.print}};import{jsx as z,jsxs as Ae}from"react/jsx-runtime";function tr(){let{t:e}=nl(),{exportAsPng:t,exportAsHtml:o,printDiagram:n,isPrinting:r,isPrintingPng:a,isPrintingHtml:s}=er(),[i,l]=ll(!1);return Ae(el,{modal:!1,open:i,onOpenChange:l,children:[z(ol,{asChild:!0,children:z("div",{children:Ae(St,{children:[z(Lt,{asChild:!0,children:z(Qs,{size:"small",variant:"ghost",color:"grey",iconButton:!0,children:z(il,{})})}),!i&&z(kt,{color:"black",children:e("editor.controls.actions.export.title")})]})})}),Ae(tl,{align:"center",side:"top",sideOffset:16,className:"min-w-0 flex flex-col gap-2 p-2 shadow-sm",children:[Ae(St,{children:[z(Lt,{asChild:!0,children:z(eo,{className:"p-1.5",disabled:a,onClick:()=>t(),children:z(al,{})})}),z(kt,{side:"right",color:"black",children:e("editor.controls.actions.export.png")})]}),Ae(St,{children:[z(Lt,{asChild:!0,children:z(eo,{className:"p-1.5",disabled:s,onClick:()=>o(),children:z(rl,{})})}),z(kt,{side:"right",color:"black",children:e("editor.controls.actions.export.html")})]}),Ae(St,{children:[z(Lt,{asChild:!0,children:z(eo,{className:"p-1.5",disabled:r,onClick:()=>n(),children:z(sl,{})})}),z(kt,{side:"right",color:"black",children:e("editor.controls.actions.export.print")})]})]})]})}import{Fragment as gl,jsx as Z,jsxs as ge}from"react/jsx-runtime";var rr=({nodes:e,isReadOnly:t})=>{let{t:o}=dl(),{deselectAll:n}=Fe(),{isMoveTool:r,isHandTool:a,activeMoveTool:s,activeHandTool:i,isMinimapOpen:l,setIsMinimapOpen:c}=V(),g=or(["v","V"]),f=or(["h","H"]),m=ml(()=>{n(),i()},[n,i]);return nr(()=>{g&&!r&&!t&&s()},[g,s,r,t]),nr(()=>{f&&!a&&!t&&m()},[f,m,a,t]),ge("div",{className:"flex items-center gap-2 px-3 py-2 bg-white rounded-sm shadow-md",children:[!t&&ge(gl,{children:[ge(oo,{children:[Z(ro,{asChild:!0,children:Z(to,{size:"small",variant:"ghost",color:"grey",className:k(r&&"bg-grey-400"),iconButton:!0,onClick:s,children:Z(ul,{})})}),ge(no,{color:"black",className:"flex items-center gap-2",children:[o("editor.controls.actions.move_tool"),Z(Jt,{shortcut:"V"})]})]}),ge(oo,{children:[Z(ro,{asChild:!0,children:Z(to,{size:"small",variant:"ghost",color:"grey",className:k(a&&"bg-grey-400"),iconButton:!0,onClick:m,children:Z(cl,{})})}),ge(no,{color:"black",className:"flex items-center gap-2",children:[o("editor.controls.actions.hand_tool")," ",Z(Jt,{shortcut:"H"})]})]})]}),Z(tr,{}),!t&&Z(Jn,{disabled:e.length>0}),ge(oo,{children:[Z(ro,{asChild:!0,children:Z(to,{size:"small",variant:"ghost",color:"grey",className:k(l&&"bg-grey-400"),iconButton:!0,onClick:()=>c(!l),children:Z(pl,{})})}),Z(no,{color:"black",children:o(l?"editor.controls.actions.minimap.close":"editor.controls.actions.minimap.open")})]})]})};import{Button as ar,Tooltip as ir,TooltipContent as sr,TooltipTrigger as lr,useTranslation as fl}from"lecom-ui";import{RedoIcon as El,UndoIcon as bl}from"lucide-react";import{jsx as ce,jsxs as ao}from"react/jsx-runtime";var dr=({undo:e,redo:t,canUndo:o,canRedo:n})=>{let{t:r}=fl();return ao("div",{className:"flex items-center gap-2 px-3 py-2 bg-white rounded-sm shadow-md",children:[ao(ir,{children:[ce(lr,{asChild:!0,children:ce(ar,{size:"small",variant:"ghost",color:"grey",iconButton:!0,disabled:!o,onClick:e,children:ce(bl,{})})}),ce(sr,{color:"black",children:r("editor.controls.history.undo")})]}),ao(ir,{children:[ce(lr,{asChild:!0,children:ce(ar,{size:"small",variant:"ghost",color:"grey",iconButton:!0,disabled:!n,onClick:t,children:ce(El,{})})}),ce(sr,{color:"black",children:r("editor.controls.history.redo")})]})]})};import{useReactFlow as hl}from"@xyflow/react";import{Button as Pt,Tooltip as Dt,TooltipContent as Rt,TooltipTrigger as Vt,useTranslation as yl}from"lecom-ui";import{ScanIcon as vl,ZoomIn as Nl,ZoomOut as Tl}from"lucide-react";import{jsx as W,jsxs as Ye}from"react/jsx-runtime";var cr=()=>{let{t:e}=yl(),{zoomIn:t,zoomOut:o,zoomTo:n,fitView:r}=hl();return Ye("div",{className:"flex items-center gap-2 px-3 py-2 bg-white rounded-sm shadow-md",children:[Ye(Dt,{children:[W(Vt,{asChild:!0,children:W(Pt,{size:"small",variant:"ghost",color:"grey",iconButton:!0,onClick:()=>r(),children:W(vl,{})})}),W(Rt,{color:"black",children:e("editor.controls.zoom.fit")})]}),Ye(Dt,{children:[W(Vt,{asChild:!0,children:W(Pt,{size:"small",variant:"ghost",color:"grey",iconButton:!0,onClick:()=>o(),children:W(Tl,{})})}),W(Rt,{color:"black",children:e("editor.controls.zoom.out")})]}),Ye(Dt,{children:[W(Vt,{asChild:!0,children:W(Pt,{size:"small",variant:"ghost",color:"grey",iconButton:!0,onClick:()=>n(1),children:W(ko,{})})}),W(Rt,{color:"black",children:e("editor.controls.zoom.reset")})]}),Ye(Dt,{children:[W(Vt,{asChild:!0,children:W(Pt,{size:"small",variant:"ghost",color:"grey",iconButton:!0,onClick:()=>t(),children:W(Nl,{})})}),W(Rt,{color:"black",children:e("editor.controls.zoom.in")})]})]})};import{Position as sd,useReactFlow as ld}from"@xyflow/react";import{Handle as pr,useReactFlow as _l}from"@xyflow/react";import{jsx as ur}from"react/jsx-runtime";var Y=r=>{var a=r,{type:e,position:t,className:o}=a,n=ae(a,["type","position","className"]);return ur(pr,T({type:e,position:t,className:k("size-2.5 border border-grey-400 bg-white",o)},n))},Mt=i=>{var l=i,{nodeId:e,nodeType:t,gatewayVariant:o,type:n,position:r,className:a}=l,s=ae(l,["nodeId","nodeType","gatewayVariant","type","position","className"]);let{getEdges:c}=_l(),f=(()=>{if(n!=="source")return!1;let m=c();return t==="TASK"?m.filter(E=>E.source===e).length>=2:t==="GATEWAY"&&o==="EXCLUSIVE"?m.filter(E=>E.source===e).length>=2:!1})();return ur(pr,T({type:n,position:r,className:k("size-2.5 border border-grey-400 bg-white transition-all duration-200",{"opacity-50 cursor-not-allowed pointer-events-none":f,"hover:border-grey-500":!f},a),style:{pointerEvents:f?"none":"auto"}},s))};import{NodeResizer as xl,useReactFlow as wl}from"@xyflow/react";import{orderBy as Cl}from"lodash";import{jsx as Al}from"react/jsx-runtime";var Ie=o=>{var n=o,{nodeId:e}=n,t=ae(n,["nodeId"]);let{getNode:r,getNodes:a,setNodes:s}=wl(),i=({width:l,height:c})=>{if(!e)return;let g=r(e);if((g==null?void 0:g.type)!=="LANE")return;let f=[...a()],m=!g.parentId,h=m?g.id:g.parentId,E=f.filter(p=>p.type==="LANE"&&p.parentId===h);if(!E.length)return;let y=Cl(E,["position.y"]),v=0;y.forEach((p,d)=>{var _,I;let x=d===y.length-1,u=(I=(_=p.measured)==null?void 0:_.height)!=null?I:0;f=f.map(b=>{if(b.id===p.id){let N=m?l-K.HEADER_WIDTH:l,S=w(T({},b),{width:N,measured:w(T({},b.measured),{width:N}),position:w(T({},b.position),{y:v})});return x&&m&&(S.height=c-v),S}return b}),v+=u}),f=f.map(p=>{if(p.id===h){let d=m?l:l+K.HEADER_WIDTH;return w(T({},p),{width:d,height:m?c:v,measured:{width:d,height:m?c:v}})}return p}),s(f)};return Al(xl,T({nodeId:e,handleClassName:"size-1.5 bg-blue-400",lineClassName:"border-blue-400/90 border-dashed",onResizeEnd:(l,c)=>i(c)},t))};import{Position as Jl,NodeToolbar as Ql,useReactFlow as ed}from"@xyflow/react";import{Button as td,Tooltip as od,TooltipContent as nd,TooltipTrigger as rd,useTranslation as ad}from"lecom-ui";import{useNodesData as Il,useReactFlow as Sl}from"@xyflow/react";import{Button as kl,DropdownMenu as Ll,DropdownMenuContent as Pl,DropdownMenuGroup as Dl,DropdownMenuItem as Rl,DropdownMenuLabel as Vl,DropdownMenuTrigger as Ml,Tooltip as Ol,TooltipContent as Gl,TooltipTrigger as Hl,useTranslation as Bl}from"lecom-ui";import{WrenchIcon as zl}from"lucide-react";import{jsx as le,jsxs as Ot}from"react/jsx-runtime";var mr=({nodeId:e})=>{let{t}=Bl(),{updateNodeData:o}=Sl(),n=Il(e),r=a=>{(n==null?void 0:n.data.variant)!==a&&o(e,{variant:a})};return Ot(Ll,{children:[Ot(Ol,{children:[le(Hl,{asChild:!0,children:le(Ml,{asChild:!0,children:le(kl,{variant:"ghost",color:"grey",size:"small",iconButton:!0,children:le(zl,{})})})}),le(Gl,{color:"black",children:t("bpmn.gateway.menu.title")})]}),Ot(Pl,{align:"start",className:"w-60 bg-white text-grey-600",children:[le(Vl,{className:"flex items-center",children:le("div",{className:"flex-1 text-sm font-semibold",children:t("bpmn.gateway.menu.title")})}),le(Dl,{children:Object.entries(rt).map(([a,s])=>Ot(Rl,{className:k({"bg-grey-100 text-blue-500":(n==null?void 0:n.data.variant)===a}),onClick:()=>r(a),children:[le(s.icon,{className:"stroke-current"}),t(`bpmn.gateway.variant.${a.toLowerCase()}`)]},a))})]})]})};import{useNodesData as Ul,useReactFlow as Fl}from"@xyflow/react";import{Button as gr,DropdownMenu as Wl,DropdownMenuContent as Yl,DropdownMenuGroup as Kl,DropdownMenuItem as $l,DropdownMenuLabel as Zl,DropdownMenuTrigger as Xl,Tooltip as io,TooltipContent as so,TooltipTrigger as lo,useTranslation as ql}from"lecom-ui";import{WrenchIcon as jl}from"lucide-react";import{jsx as $,jsxs as fe}from"react/jsx-runtime";var fr=({nodeId:e})=>{let{t}=ql(),{updateNodeData:o,getEdges:n,getNode:r}=Fl(),a=Ul(e),i=n().filter(m=>m.source===e).some(m=>{let h=r(m.target);return(h==null?void 0:h.type)==="END_EVENT"}),l=g=>{o(e,{variant:(a==null?void 0:a.data.variant)===g?"":g})},c=g=>{o(e,{attribute:(a==null?void 0:a.data.attribute)===g?"":g})};return fe(Wl,{children:[fe(io,{children:[$(lo,{asChild:!0,children:$(Xl,{asChild:!0,children:$(gr,{variant:"ghost",color:"grey",size:"small",iconButton:!0,children:$(jl,{})})})}),$(so,{color:"black",children:t("bpmn.task.menu.title")})]}),fe(Yl,{align:"start",className:"w-60 bg-white text-grey-600",children:[fe(Zl,{className:"flex items-center gap-1",children:[$("div",{className:"flex-1 text-sm font-semibold",children:t("bpmn.task.menu.title")}),$("div",{className:"flex items-center gap-1",children:Object.entries(nt).map(([g,f])=>{let m=g==="LOOP"&&i,h=m?t("editor.task_menu.loop_not_allowed_when_connected_to_end"):void 0;return fe(io,{children:[$(lo,{asChild:!0,children:$(gr,{variant:"ghost",color:"grey",size:"small",iconButton:!0,disabled:m,className:k({"bg-grey-100 text-blue-500":(a==null?void 0:a.data.attribute)===g,"opacity-50 cursor-not-allowed":m}),onClick:m?void 0:()=>c(g),children:$(f.icon,{className:"stroke-inherit"})})}),h&&$(so,{color:"black",children:h})]},g)})})]}),$(Kl,{children:Object.entries(ot).map(([g,f])=>{let m=g==="SCRIPT"&&i;return fe(io,{children:[$(lo,{asChild:!0,children:fe($l,{className:k({"bg-grey-100 text-blue-500":(a==null?void 0:a.data.variant)===g,"opacity-50 cursor-not-allowed":m}),disabled:m,onClick:m?void 0:()=>l(g),children:[$(f.icon,{className:"stroke-current"}),t(`bpmn.task.variant.${g.toLowerCase()}`)]})}),m&&$(so,{color:"black",children:t("editor.task_menu.script_not_allowed_when_connected_to_end")})]},g)})})]})]})};import{jsx as J,jsxs as id}from"react/jsx-runtime";var X=({nodeId:e,nodeType:t,isChild:o,isVisible:n})=>{var E;let{t:r}=ad(),{setDraggableNode:a}=we(),{getEdges:s,getNodes:i}=ed(),l=i(),c=s(),g=({event:y,type:v,variant:p})=>{a({type:v,variant:p}),y.dataTransfer.effectAllowed="move",y.dataTransfer.setData("sourceId",e)},f={START_EVENT:{type:"START_EVENT",icon:Re,label:r("bpmn.start_event.variant.default")},END_EVENT:{type:"END_EVENT",icon:ve,label:r("bpmn.end_event.variant.default")},TASK:{type:"TASK",icon:Re,label:r("bpmn.task.variant.default")},GATEWAY:{type:"GATEWAY",variant:"EXCLUSIVE",icon:Ne,label:r("bpmn.gateway.variant.exclusive")},ANNOTATION:{type:"ANNOTATION",icon:je,label:r("bpmn.annotation.variant.default")}},m=[{component:J(ct,{elementId:e})}],h={START_EVENT:[f.TASK,f.ANNOTATION,...m],TASK:[{component:J(Ge,{elementId:e})},{component:J(fr,{nodeId:e})},f.TASK,f.GATEWAY,f.END_EVENT,f.ANNOTATION,...m],GATEWAY:[{component:J(Ge,{elementId:e})},{component:J(mr,{nodeId:e})},f.TASK,f.ANNOTATION,...m],END_EVENT:[f.ANNOTATION,...m],LANE:[...o?[]:[f.ANNOTATION],...m],ANNOTATION:[...m],UNSUPPORTED:[...m]};return J(Ql,{className:"-top-6 flex items-center gap-1 px-3 py-2 bg-white rounded-sm shadow-md",position:Jl.Right,align:"start",isVisible:n,children:(E=h[t])==null?void 0:E.map((y,v)=>{if(y.component)return J("div",{children:y.component},v);let p={sourceNodeType:t,targetNodeType:y.type,sourceNodeId:e,nodes:l,edges:c},d=Qo(p),x={gateway_limit_reached:r("editor.toolbar.gateway_limit_reached"),start_event_already_exists:r("editor.toolbar.start_event_already_exists"),script_to_end_not_allowed:r("editor.toolbar.script_to_end_not_allowed"),initial_activity_to_end_not_allowed:r("editor.toolbar.initial_activity_to_end_not_allowed"),final_activity_cannot_connect:r("editor.toolbar.final_activity_cannot_connect"),activity_has_outgoing_connections:r("editor.toolbar.activity_has_outgoing_connections"),task_limit_reached:r("editor.toolbar.task_limit_reached")},u=d.shouldDisable&&d.reason?x[d.reason]||y.label:y.label||"";return id(od,{children:[J(rd,{asChild:!0,children:J(td,{variant:"ghost",color:"grey",size:"small",iconButton:!0,draggable:!d.shouldDisable,disabled:d.shouldDisable,className:d.shouldDisable?"opacity-50 cursor-not-allowed":"",onDragStart:d.shouldDisable?void 0:_=>g({event:_,type:y.type,variant:y.variant}),children:y.icon&&J(y.icon,{size:16})})}),J(nd,{color:"black",children:u})]},v)})})};import{Fragment as dd,jsx as Ke,jsxs as cd}from"react/jsx-runtime";var Er=({id:e,data:t,selected:o,dragging:n})=>{let{updateNodeData:r}=ld(),{isMultipleSelection:a}=V(),s=i=>{r(e,{label:i})};return cd(dd,{children:[Ke("div",{className:k("relative w-full h-full min-w-44 min-h-16 flex text-grey-400 hover:text-grey-500 bg-white rounded-sm overflow-hidden 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:Ke(F,{value:t.label,className:"m-1 text-grey-600",onChange:s})}),Ke(X,{nodeId:e,nodeType:"ANNOTATION",isVisible:!n&&!a&&o}),Ke(Ie,{isVisible:!n&&!a&&o,minWidth:st.MIN_WIDTH,minHeight:st.MIN_HEIGHT}),Ke(Y,{type:"target",position:sd.Left})]})};import{Position as br,useReactFlow as pd}from"@xyflow/react";import{useState as ud}from"react";import{Fragment as md,jsx as Se,jsxs as hr}from"react/jsx-runtime";var yr=({id:e,data:t,selected:o,dragging:n})=>{let{updateNodeData:r}=pd(),{isMultipleSelection:a}=V(),[s,i]=ud(!1),l=f=>{r(e,{label:f})};return hr(md,{children:[hr("div",{className:"relative",onBlur:()=>{i(!1)},onDoubleClick:()=>{i(!0)},children:[Se(ve,{className:k("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})}),Se("div",{className:"absolute top-9 left-1/2 -translate-x-1/2 max-w-80 w-max",children:Se(F,{value:t.label,isEditing:s,onChange:l})})]}),Se(X,{nodeId:e,nodeType:"END_EVENT",isVisible:!n&&!a&&o}),Se(Y,{type:"source",position:br.Right}),Se(Y,{type:"target",position:br.Left})]})};import{Position as vr,useReactFlow as gd}from"@xyflow/react";import{useState as fd}from"react";import{Fragment as Ed,jsx as ke,jsxs as Nr}from"react/jsx-runtime";var Tr=({id:e,data:t,selected:o,dragging:n})=>{let r=rt[t.variant].icon,{updateNodeData:a}=gd(),{isMultipleSelection:s}=V(),[i,l]=fd(!1),c=m=>{a(e,{label:m})};return Nr(Ed,{children:[Nr("div",{className:"relative",onBlur:()=>{l(!1)},onDoubleClick:()=>{l(!0)},children:[ke(r,{className:k("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})}),ke("div",{className:"absolute top-14 left-1/2 -translate-x-1/2 max-w-80 w-max",children:ke(F,{value:t.label,isEditing:i,onChange:c})})]}),ke(X,{nodeId:e,nodeType:"GATEWAY",isVisible:!n&&!s&&o}),ke(Y,{type:"target",position:vr.Left}),ke(Mt,{type:"source",position:vr.Right,nodeId:e,nodeType:"GATEWAY",gatewayVariant:t.variant})]})};import{Position as bd,useReactFlow as hd}from"@xyflow/react";import{useState as yd}from"react";import{Fragment as vd,jsx as $e,jsxs as _r}from"react/jsx-runtime";var xr=({id:e,data:t,selected:o,dragging:n})=>{let{updateNodeData:r}=hd(),{isMultipleSelection:a}=V(),[s,i]=yd(!1),l=f=>{r(e,{label:f})};return _r(vd,{children:[_r("div",{className:"relative",onBlur:()=>{i(!1)},onDoubleClick:()=>{i(!0)},children:[$e(et,{className:k("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})}),$e("div",{className:"absolute top-9 left-1/2 -translate-x-1/2 max-w-80 w-max",children:$e(F,{value:t.label,isEditing:s,onChange:l})})]}),$e(X,{nodeId:e,nodeType:"START_EVENT",isVisible:!n&&!a&&o}),$e(Y,{type:"source",position:bd.Right})]})};import{Position as wr,useReactFlow as Nd}from"@xyflow/react";import{useTranslation as Td}from"lecom-ui";import{Fragment as _d,jsx as ne,jsxs as Cr}from"react/jsx-runtime";var Ar=({id:e,data:t,selected:o,dragging:n})=>{let{updateNodeData:r,getNodes:a}=Nd(),{isMultipleSelection:s}=V(),{t:i}=Td(),l=E=>{let y=E.trim(),v=t.label||"";if(y===v)return;let p=a(),d=y;y||(d=xt(p,i("bpmn.task.label.prefix")));let x=wt(d,p);x!==v&&r(e,{label:x})},c=t.variant?ot[t.variant].icon:null,g=t.attribute?nt[t.attribute].icon:null,f=t.variant==="SUBPROCESS",m=c&&!f,h=g||f;return Cr(_d,{children:[Cr("div",{className:k("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 overflow-hidden hover:shadow-md transition-colors duration-75",{"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:[ne(F,{value:t.label,maxLength:60,className:k("m-1",{"py-6":m||h}),onChange:l}),c&&ne("div",{className:k("absolute flex items-center p-1",f?"bottom-0":"top-0 left-0"),children:ne(c,{size:16,className:k(t.hasError?"text-red-500":"text-grey-500")})}),g&&ne("div",{className:"absolute bottom-0 left-0 w-full flex items-center justify-center",children:ne("div",{className:k("flex items-center w-16 p-1",f?"justify-between":"justify-center"),children:ne(g,{size:16,className:k(t.hasError?"text-red-500":"text-grey-500")})})})]}),ne(X,{nodeId:e,nodeType:"TASK",isVisible:!n&&!s&&o}),ne(Ie,{isVisible:!n&&!s&&o,minWidth:at.MIN_WIDTH,minHeight:at.MIN_HEIGHT}),ne(Mt,{type:"source",position:wr.Right,nodeId:e,nodeType:"TASK"}),ne(Y,{type:"target",position:wr.Left})]})};import{Position as Ir}from"@xyflow/react";import{Fragment as xd,jsx as Gt,jsxs as wd}from"react/jsx-runtime";var Sr=({id:e,data:t,selected:o,dragging:n})=>{let{isMultipleSelection:r}=V();return wd(xd,{children:[Gt("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}),Gt(X,{nodeId:e,nodeType:"UNSUPPORTED",isVisible:!n&&!r&&o}),Gt(Y,{type:"source",position:Ir.Right}),Gt(Y,{type:"target",position:Ir.Left})]})};import{Position as Cd,useReactFlow as Ad}from"@xyflow/react";import{orderBy as Id}from"lodash";import{useMemo as kr}from"react";import{Fragment as Sd,jsx as Ee,jsxs as Lr}from"react/jsx-runtime";var Pr=({id:e,data:t,selected:o,dragging:n,parentId:r})=>{let{updateNodeData:a,getNodes:s}=Ad(),{isMultipleSelection:i}=V(),l=s(),c=!r,g=kr(()=>Id([...l.filter(E=>E.parentId===e&&E.type==="LANE")],"position.y","asc"),[l,e]),f=c?it.MIN_WIDTH:K.MIN_WIDTH,m=kr(()=>{if(c&&g.length>1){let E=[...g];return E.pop(),E.reduce((v,p)=>{var d,x;return v+((x=(d=p.measured)==null?void 0:d.height)!=null?x:0)},0)+K.MIN_HEIGHT}return K.MIN_HEIGHT},[c,g]),h=E=>{a(e,{label:E})};return Lr(Sd,{children:[Lr("div",{className:k("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:[Ee("div",{className:"flex align-items justify-center w-10 border-r-2 border-grey-400 bg-white",children:Ee("div",{className:"relative flex-1 [writing-mode:vertical-rl] [text-orientation:sideways] transform rotate-180",children:Ee(F,{value:t.label,className:"w-full h-full",onChange:h})})}),Ee("div",{className:"flex-1"})]}),Ee(X,{nodeId:e,nodeType:"LANE",isChild:!c,isVisible:!n&&!i&&o}),Ee(Ie,{nodeId:e,minWidth:f,minHeight:m,isVisible:!n&&!i&&o}),c&&Ee(Y,{type:"source",position:Cd.Right})]})};var Dr={START_EVENT:xr,END_EVENT:yr,TASK:Ar,GATEWAY:Tr,ANNOTATION:Er,LANE:Pr,UNSUPPORTED:Sr},Rr={SEQUENCE_EDGE:jo,MESSAGE_EDGE:hn,ANNOTATION_EDGE:Ko},Vr="#fafafa",Mr="#bebebe",Or=1,Gr=10,Hr="bottom-left",Br=.5,zr=4,Ur={x:0,y:0,zoom:.75};import{useStore as kd}from"@xyflow/react";import{useEffect as Ld,useRef as Pd}from"react";import{jsx as Rd}from"react/jsx-runtime";var Dd=e=>({width:e.width,height:e.height,transform:e.transform}),Fr=({horizontal:e,vertical:t,color:o="#3367d9",dashArray:n=[6,6]})=>{let{width:r,height:a,transform:s}=kd(Dd),i=Pd(null);return Ld(()=>{let l=i.current,c=l==null?void 0:l.getContext("2d");if(!c||!l)return;let g=window.devicePixelRatio;l.width=r*g,l.height=a*g,c.scale(g,g),c.clearRect(0,0,r,a),c.strokeStyle=o,c.setLineDash(n),typeof t=="number"&&(c.moveTo(t*s[2]+s[0],0),c.lineTo(t*s[2]+s[0],a),c.stroke()),typeof e=="number"&&(c.moveTo(0,e*s[2]+s[1]),c.lineTo(r,e*s[2]+s[1]),c.stroke())},[r,a,s,e,t,o,n]),Rd("canvas",{ref:i,className:"react-flow__canvas w-full h-full absolute z-10 pointer-events-none"})};import{Button as Wr,Dialog as Vd,DialogContent as Md,DialogFooter as Od,DialogHeader as Gd,DialogTitle as Hd,Notification as Bd,Typography as co,useTranslation as zd}from"lecom-ui";import{jsx as re,jsxs as po}from"react/jsx-runtime";var Yr=({pendingDelete:e,setPendingDelete:t,setNodes:o,setEdges:n})=>{let{t:r}=zd(),a=!!e,s=()=>{let{nodes:l,edges:c}=e||{};l!=null&&l.length&&o(g=>g.filter(f=>!l.some(m=>m.id===f.id))),c!=null&&c.length&&n(g=>g.filter(f=>!c.some(m=>m.id===f.id))),t(null)},i=()=>{t(null)};return re(Vd,{open:a,onOpenChange:i,children:po(Md,{className:"w-[488px] max-w-fit gap-2",children:[re(Gd,{children:re(Hd,{children:re(co,{variant:"heading-small-600",textColor:"text-grey-950",children:r("editor.modals.delete_elements.title")})})}),po("div",{className:"flex flex-col gap-2",children:[re("div",{className:"py-2",children:re(Bd,{type:"callout",variant:"warning",content:r("editor.modals.delete_elements.callout")})}),re(co,{variant:"body-large-400",textColor:"text-grey-800",className:"py-2",children:r("editor.modals.delete_elements.content")})]}),po(Od,{className:"flex items-center flex-row justify-end w-full gap-2",children:[re(Wr,{variant:"outlined",color:"grey",disabled:!1,size:"small",onClick:i,children:re(co,{variant:"body-medium-500",textColor:"text-grey-800",children:r("editor.modals.delete_elements.cancel")})}),re(Wr,{size:"small",variant:"filled",color:"destructive",autoFocus:!0,onClick:s,children:r("editor.modals.delete_elements.confirm")})]})]})})};import{useReactFlow as Ud}from"@xyflow/react";import{Button as Fd,Tooltip as Wd,TooltipContent as Yd,TooltipTrigger as Kd,useTranslation as $d}from"lecom-ui";import{jsx as Ze,jsxs as Zd}from"react/jsx-runtime";var Kr=()=>{let{t:e}=$d(),{setDraggableNode:t}=we(),{getNodes:o}=Ud(),n=o(),r=Et(n),a=[{type:"START_EVENT",icon:et,label:e("bpmn.start_event.variant.default")},{type:"END_EVENT",icon:ve,label:e("bpmn.end_event.variant.default")},{type:"TASK",icon:Re,label:e("bpmn.task.variant.default")},{type:"TASK",variant:"SUBPROCESS",icon:Vo,label:e("bpmn.task.variant.subprocess")},{type:"TASK",variant:"SCRIPT",icon:Ro,label:e("bpmn.task.variant.script")},{type:"TASK",attribute:"LOOP",icon:Do,label:e("bpmn.task.attribute.loop")},{type:"GATEWAY",variant:"EXCLUSIVE",icon:Ne,label:e("bpmn.gateway.variant.exclusive")},{type:"GATEWAY",variant:"PARALLEL",icon:Qe,label:e("bpmn.gateway.variant.parallel")},{type:"GATEWAY",variant:"COMPLEX",icon:Je,label:e("bpmn.gateway.variant.complex")},{type:"LANE",icon:So,label:e("bpmn.lane.variant.default")},{type:"ANNOTATION",icon:je,label:e("bpmn.annotation.variant.default")}],s=(i,l)=>{t({type:l.type,variant:l.variant,attribute:l.attribute}),i.dataTransfer.effectAllowed="move"};return Ze("aside",{className:"sidebar absolute z-[1] top-4 left-4 grid grid-cols-1 gap-2 p-2 bg-white rounded-md shadow-md",children:a.map((i,l)=>{let c=r&&i.type==="START_EVENT",g=c?e("editor.toolbar.start_event_already_exists"):i.label;return Zd(Wd,{children:[Ze(Kd,{asChild:!0,children:Ze(Fd,{className:`[&>svg]:size-6 ${c?"opacity-50 cursor-not-allowed":""}`,size:"small",variant:"ghost",color:"grey",draggable:!c,disabled:c,iconButton:!0,onDragStart:c?void 0:f=>s(f,i),children:Ze(i.icon,{})},l)}),Ze(Yd,{color:"black",side:"right",children:g})]},l)})})};import{Button as Xd,useTranslation as qd}from"lecom-ui";import{AlertCircleIcon as jd,CircleCheckIcon as Jd,XIcon as Qd}from"lucide-react";import{useEffect as ec,useState as tc}from"react";import{jsx as Q,jsxs as uo}from"react/jsx-runtime";var $r=({validationResult:e,onClose:t})=>{let{t:o}=qd(),[n,r]=tc(!1);if(ec(()=>{e&&r(!0)},[e]),!n||!e)return null;let{isValid:a,errors:s}=e;return uo("div",{className:k("w-72 max-w-[95vw] rounded-lg border px-4 py-2",{"bg-green-100":a,"bg-red-100":!a}),children:[uo("div",{className:"flex flex-row items-start gap-4",children:[Q("div",{className:"flex-shrink-0",children:a?Q(Jd,{className:"text-green-500 size-5"}):Q(jd,{className:"text-red-500 size-5"})}),uo("div",{className:"body-medium-500 text-grey-800",children:[Q("div",{children:o(a?"validation.success.title":"validation.errors.title")}),!a&&Q("div",{children:o("validation.errors.subtitle")})]}),Q(Xd,{variant:"ghost",size:"small",color:"grey",className:"size-5 hover:bg-transparent",iconButton:!0,onClick:()=>{r(!1),t()},children:Q(Qd,{})})]}),Q("div",{className:"max-h-80 overflow-y-auto mt-2 px-9 body-medium-400 text-grey-800",children:a?Q("p",{children:o("validation.success.message")}):Q("div",{className:"list-disc list-inside",children:s.map(i=>Q("li",{className:"mb-1",children:i.message},i.id))})})]})};import{jsx as q,jsxs as fo}from"react/jsx-runtime";var Ec=[],Xr=pc(({mode:e="edit"},t)=>{let o=mc(!1),[n,r,a]=lc([]),[s,i,l]=sc([]),[c,g]=gc(null),{isMoveTool:f,isHandTool:m,isReadOnly:h,setIsReadOnly:E,setIsMultipleSelection:y,isMinimapOpen:v}=V(),{validationResult:p,handleValidationComplete:d,clearValidation:x,isAutoValidationEnabled:u,validateDiagram:_}=un(),{getNode:I,getNodes:b,getEdges:N}=cc(),S=Dn(r,i);uc(t,()=>S);let{onNodeDrag:P,onDrop:C,onDragOver:A,onNodeDragStop:L}=Tn({nodes:n,setNodes:r,setEdges:i}),{isValidConnection:M,onConnect:O}=tn({setEdges:i});En();let{createDiagram:H}=Ln(),{undo:be,redo:pe,saveHistory:he,canUndo:na,canRedo:ra}=Mn(),{helperLineHorizontal:aa,helperLineVertical:ia}=wn();Pn({LIA_CREATE_DIAGRAM:H,CLEAR_DIAGRAM:()=>{r([]),i([])}}),Eo(()=>{E(e==="readonly")},[e,E]),Eo(()=>{if(n.length===0&&s.length===0&&e!=="readonly"){let Le=go(),ba={id:Le,type:"START_EVENT",position:{x:200,y:300},data:{}},No=go(),ha={id:No,type:"TASK",position:{x:400,y:270},data:{label:Zr.t("editor.toolbar.initial_task")}},ya=go(),va=w(T({},te),{id:ya,source:Le,target:No});r([ba,ha]),i([va])}},[n.length,s.length,e,r,i]);let sa=()=>{x()},la=mo(({nodes:U,edges:B})=>{let ye=U.length+B.length>1;y(ye)},[y]);dc({onChange:la});let da=U=>{let B=I(U.id);if(B!=null&&B.parentId&&(B==null?void 0:B.type)==="LANE"){let ye=ue(B.parentId,n.filter(Le=>Le.id!==B.id&&Le.type==="LANE"));r(se(ye))}},ca=U=>{U.forEach(B=>{switch(B.type){case"remove":da(B);break}})},pa=mo(()=>{if(!u){o.current=!1;return}let U=b(),B=N(),ye=_({nodes:U,edges:B});d(ye),o.current=!1},[u,b,N,_,d]),yo=fc(pa,300),vo=mo(()=>{u&&!o.current&&(o.current=!0,yo())},[u,yo]),ua=U=>{a(U),he(U),vo(),ca(U)},ma=U=>{l(U),he(U),vo()},ga=()=>{he("forceSave")},fa=async({nodes:U,edges:B})=>(g({nodes:U,edges:B}),!1),Ea={nodes:n,edges:s};return fo("div",{className:"w-full h-full",children:[!h&&q(Kr,{}),q(Gn,{}),fo(rc,{edges:s,nodes:n,nodeTypes:Dr,edgeTypes:Rr,minZoom:Br,maxZoom:zr,panOnDrag:m||h?!0:Ec,panOnScroll:!0,selectionOnDrag:!0,elevateEdgesOnSelect:!0,elevateNodesOnSelect:!0,elementsSelectable:!h&&f,nodesConnectable:!h&&f,nodesDraggable:!h&&f,isValidConnection:M,connectionLineComponent:vn,onConnect:O,onDrop:C,onDropCapture:ga,onDragOver:A,onNodesChange:ua,onEdgesChange:ma,onNodeDrag:P,onNodeDragStop:L,onBeforeDelete:fa,selectionMode:ic.Partial,proOptions:{hideAttribution:!0},multiSelectionKeyCode:"Shift",deleteKeyCode:"Delete",selectionKeyCode:null,snapToGrid:!0,snapGrid:[10,10],defaultViewport:Ur,connectOnClick:!1,children:[v&&q(nc,{pannable:!0,zoomable:!0,position:Hr,className:"shadow-md rounded-md"}),fo("div",{className:"absolute z-10 bottom-4 left-1/2 -translate-x-1/2 flex gap-4",children:[!h&&q(dr,{canUndo:na,canRedo:ra,undo:be,redo:pe}),q(rr,{nodes:n,isReadOnly:h,diagram:Ea,onValidationComplete:d,onValidateDiagram:_}),q(cr,{})]}),q(Fr,{horizontal:aa,vertical:ia}),q(oc,{gap:Gr,size:Or,color:Mr,bgColor:Vr}),p&&q("div",{className:"absolute top-6 right-6 z-[1000]",children:q($r,{validationResult:p,onClose:sa})})]}),q(Yr,{pendingDelete:c,setPendingDelete:g,setNodes:r,setEdges:i})]})});Xr.displayName="Editor";var bc=({mode:e,locale:t="pt_BR",onConfigureElement:o,selectorRef:n})=>(Eo(()=>{t&&Zr.changeLanguage(t)},[t]),q(ac,{children:q(Fo,{value:{onConfigureElement:o},children:q(Xr,{mode:e,ref:n})})})),bo=bc;var ho=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 hc,Translations as yc}from"lecom-ui";var qr={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",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"},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"}},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:"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 jr={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",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"},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"}},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:"Lane"}},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 Jr={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",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"},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"}},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:"Lane"}},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 Qr={pt_BR:Jr,en_US:qr,es_ES:jr};var ea,ta,vc=(ta=(ea=ho("LecomUserLanguage"))!=null?ea:ho("org.springframework.web.servlet.i18n.CookieLocaleResolver.LOCALE"))!=null?ta:yc.PT_BR;hc({lng:vc,resources:Qr});import{jsx as oa}from"react/jsx-runtime";var _y=e=>oa(wo,{children:oa(bo,T({},e))});export{Bt as ActivityVariant,Ut as ComplexVariant,Ht as ElementType,Ft as ExclusiveVariant,ee as GatewayVariant,_y as Modeler,zt as RoutingVariant,Fe as useSelectionUtils};
|