1(globalThis.TURBOPACK||(globalThis.TURBOPACK=[])).push(["object"==typeof document?document.currentScript:void 0,755838,(e,t,n)=>{"use strict";var o=e.r(271645),r="function"==typeof Object.is?Object.is:function(e,t){return e===t&&(0!==e||1/e==1/t)||e!=e&&t!=t},i=o.useState,a=o.useEffect,s=o.useLayoutEffect,l=o.useDebugValue;function d(e){var t=e.getSnapshot;e=e.value;try{var n=t();return!r(e,n)}catch(e){return!0}}var u="u"<typeof window||void 0===window.document||void 0===window.document.createElement?function(e,t){return t()}:function(e,t){var n=t(),o=i({inst:{value:n,getSnapshot:t}}),r=o[0].inst,u=o[1];return s(function(){r.value=n,r.getSnapshot=t,d(r)&&u({inst:r})},[e,n,t]),a(function(){return d(r)&&u({inst:r}),e(function(){d(r)&&u({inst:r})})},[e]),l(n),n};n.useSyncExternalStore=void 0!==o.useSyncExternalStore?o.useSyncExternalStore:u},802239,(e,t,n)=>{"use strict";t.exports=e.r(755838)},752822,(e,t,n)=>{"use strict";var o=e.r(271645),r=e.r(802239),i="function"==typeof Object.is?Object.is:function(e,t){return e===t&&(0!==e||1/e==1/t)||e!=e&&t!=t},a=r.useSyncExternalStore,s=o.useRef,l=o.useEffect,d=o.useMemo,u=o.useDebugValue;n.useSyncExternalStoreWithSelector=function(e,t,n,o,r){var c=s(null);if(null===c.current){var h={hasValue:!1,value:null};c.current=h}else h=c.current;var f=a(e,(c=d(function(){function e(e){if(!l){if(l=!0,a=e,e=o(e),void 0!==r&&h.hasValue){var t=h.value;if(r(t,e))return s=t}return s=e}if(t=s,i(a,e))return t;var n=o(e);return void 0!==r&&r(t,n)?(a=e,t):(a=e,s=n)}var a,s,l=!1,d=void 0===n?null:n;return[function(){return e(t())},null===d?void 0:function(){return e(d())}]},[t,n,o,r]))[0],c[1]);return l(function(){h.hasValue=!0,h.value=f},[f]),u(f),f}},430224,(e,t,n)=>{"use strict";t.exports=e.r(752822)},754500,30590,154548,567716,284958,98637,158829,348200,61333,49124,697131,481190,e=>{"use strict";e.s(["useCanvasStore",()=>aJ,"useHasPendingMutations",()=>a0],754500),e.i(247167);var t,n,o,r,i,a,s,l,d,u,c,h,f,g,p,m,y=e.i(768834),v=e.i(997098),b=e.i(843476),w=e.i(271645);function x(e){if("string"==typeof e||"number"==typeof e)return""+e;let t="";if(Array.isArray(e))for(let n=0,o;n<e.length;n++)""!==(o=x(e[n]))&&(t+=(t&&" ")+o);else for(let n in e)e[n]&&(t+=(t&&" ")+n);return t}var E=e.i(391889),_=e.i(723685),S=e.i(100561),C=e.i(990273),M=e.i(36377);let k=e=>()=>e;function N(e,{sourceEvent:t,subject:n,target:o,identifier:r,active:i,x:a,y:s,dx:l,dy:d,dispatch:u}){Object.defineProperties(this,{type:{value:e,enumerable:!0,configurable:!0},sourceEvent:{value:t,enumerable:!0,configurable:!0},subject:{value:n,enumerable:!0,configurable:!0},target:{value:o,enumerable:!0,configurable:!0},identifier:{value:r,enumerable:!0,configurable:!0},active:{value:i,enumerable:!0,configurable:!0},x:{value:a,enumerable:!0,configurable:!0},y:{value:s,enumerable:!0,configurable:!0},dx:{value:l,enumerable:!0,configurable:!0},dy:{value:d,enumerable:!0,configurable:!0},_:{value:u}})}function L(e){return!e.ctrlKey&&!e.button}function A(){return this.parentNode}function O(e,t){return null==t?{x:e.x,y:e.y}:t}function I(){return navigator.maxTouchPoints||"ontouchstart"in this}function P(){var e,t,n,o,r=L,i=A,a=O,s=I,l={},d=(0,E.dispatch)("start","drag","end"),u=0,c=0;function h(e){e.on("mousedown.drag",f).filter(s).on("touchstart.drag",m).on("touchmove.drag",y,M.nonpassive).on("touchend.drag touchcancel.drag",v).style("touch-action","none").style("-webkit-tap-highlight-color","rgba(0,0,0,0)")}function f(a,s){if(!o&&r.call(this,a,s)){var l=b(this,i.call(this,a,s),a,s,"mouse");l&&((0,_.select)(a.view).on("mousemove.drag",g,M.nonpassivecapture).on("mouseup.drag",p,M.nonpassivecapture),(0,C.default)(a.view),(0,M.nopropagation)(a),n=!1,e=a.clientX,t=a.clientY,l("start",a))}}function g(o){if((0,M.default)(o),!n){var r=o.clientX-e,i=o.clientY-t;n=r*r+i*i>c}l.mouse("drag",o)}
1function p(e){(0,_.select)(e.view).on("mousemove.drag mouseup.drag",null),(0,C.yesdrag)(e.view,n),(0,M.default)(e),l.mouse("end",e)}function m(e,t){if(r.call(this,e,t)){var n,o,a=e.changedTouches,s=i.call(this,e,t),l=a.length;for(n=0;n<l;++n)(o=b(this,s,e,t,a[n].identifier,a[n]))&&((0,M.nopropagation)(e),o("start",e,a[n]))}}function y(e){var t,n,o=e.changedTouches,r=o.length;for(t=0;t<r;++t)(n=l[o[t].identifier])&&((0,M.default)(e),n("drag",e,o[t]))}function v(e){var t,n,r=e.changedTouches,i=r.length;for(o&&clearTimeout(o),o=setTimeout(function(){o=null},500),t=0;t<i;++t)(n=l[r[t].identifier])&&((0,M.nopropagation)(e),n("end",e,r[t]))}function b(e,t,n,o,r,i){var s,c,f,g=d.copy(),p=(0,S.pointer)(i||n,t);if(null!=(f=a.call(e,new N("beforestart",{sourceEvent:n,target:h,identifier:r,active:u,x:p[0],y:p[1],dx:0,dy:0,dispatch:g}),o)))return s=f.x-p[0]||0,c=f.y-p[1]||0,function n(i,a,d){var m,y=p;switch(i){case"start":l[r]=n,m=u++;break;case"end":delete l[r],--u;case"drag":p=(0,S.pointer)(d||a,t),m=u}g.call(i,e,new N(i,{sourceEvent:a,subject:f,target:h,identifier:r,active:m,x:p[0]+s,y:p[1]+c,dx:p[0]-y[0],dy:p[1]-y[1],dispatch:g}),o)}}return h.filter=function(e){return arguments.length?(r="function"==typeof e?e:k(!!e),h):r},h.container=function(e){return arguments.length?(i="function"==typeof e?e:k(e),h):i},h.subject=function(e){return arguments.length?(a="function"==typeof e?e:k(e),h):a},h.touchable=function(e){return arguments.length?(s="function"==typeof e?e:k(!!e),h):s},h.on=function(){var e=d.on.apply(d,arguments);return e===d?h:e},h.clickDistance=function(e){return arguments.length?(c=(e*=1)*e,h):Math.sqrt(c)},h}N.prototype.on=function(){var e=this._.on.apply(this._,arguments);return e===this._?this:e},e.i(185664);var T=e.i(936755),T=T,R=e.i(7394),R=R,D=R,j=e.i(820713),$=e.i(944307);let B={error001:(e="react")=>`Seems like you have not used ${"svelte"===e?"SvelteFlowProvider":"ReactFlowProvider"} as an ancestor. Help: https://${e}flow.dev/error#001`,error002:()=>"It looks like you've created a new nodeTypes or edgeTypes object. If this wasn't on purpose please define the nodeTypes/edgeTypes outside of the component or memoize them.",error003:e=>`Node type "${e}" not found. Using fallback type "default".`,error004:()=>"The parent container needs a width and a height to render the graph.",error005:()=>"Only child nodes can use a parent extent.",error006:()=>"Can't create edge. An edge needs a source and a target.",error007:e=>`The old edge with id=${e} does not exist.`,error009:e=>`Marker type "${e}" doesn't exist.`,error008:(e,{id:t,sourceHandle:n,targetHandle:o})=>`Couldn't create edge for ${e} handle id: "${"source"===e?n:o}", edge id: ${t}.`,error010:()=>"Handle: No node id found. Make sure to only use a Handle inside a custom Node.",error011:e=>`Edge type "${e}" not found. Using fallback type "default".`,error012:e=>`Node with id "${e}" does not exist, it may have been removed. This can happen when a node is deleted before the "onNodeClick" handler is called.`,error013:(e="react")=>`It seems that you haven't loaded the styles. Please import '@xyflow/${e}/dist/style.css' or base.css to make sure everything is working properly.`,error014:()=>"useNodeConnections: No node ID found. Call useNodeConnections inside a custom Node or provide a node ID.",error015:()=>"It seems that you are trying to drag a node that is not initialized. Please use onNodesChange as explained in the docs.",error016:e=>`Edge with id "${e}" does not exist, it may have been removed. This can happen when an edge is deleted before the "onEdgeClick" handler is called.`},F=[[-1/0,-1/0],[1/0,1/0]],H=["Enter"," ","Escape"],z={"node.a11yDescription.default":"Press enter or space to select a node. Press delete to remove it and escape to cancel.","node.a11yDescription.keyboardDisabled":"Press enter or space to select a node. You can then use the arrow keys to move the node around. Press delete to remove it and escape to cancel.","node.a11yDescription.ariaLiveMessage":({direction:e,x:t,y:n})=>`Moved selected node ${e}. New position, x: ${t}, y: ${n}`,"edge.a11yDescription.default":"Press enter or space to select an edge. You can then press delete to remove it or escape to cancel.","controls.ariaLabel":"Control Panel","controls.zoomIn.ariaLabel":"Zoom In","controls.zoomOut.ariaLabel":"Zoom Out","controls.fitView.ariaLabel":"Fit View","controls.interactive.ariaLabel":"Toggle Interactivity","minimap.ariaLabel":"Mini Map","handle.ariaLabel":"Handle"};(t=d||(d={})).Strict="strict",t.Loose="loose",(n=u||(u={})).Free="free",n.Vertical="vertical",n.Horizontal="horizontal",(o=c||(c={}
1)).Partial="partial",o.Full="full";let V={inProgress:!1,isValid:null,from:null,fromHandle:null,fromPosition:null,fromNode:null,to:null,toHandle:null,toPosition:null,toNode:null,pointer:null};(r=h||(h={})).Bezier="default",r.Straight="straight",r.Step="step",r.SmoothStep="smoothstep",r.SimpleBezier="simplebezier",(i=f||(f={})).Arrow="arrow",i.ArrowClosed="arrowclosed",(a=g||(g={})).Left="left",a.Top="top",a.Right="right",a.Bottom="bottom";let K={[g.Left]:g.Right,[g.Right]:g.Left,[g.Top]:g.Bottom,[g.Bottom]:g.Top},X=e=>!!e&&"object"==typeof e&&"id"in e&&"source"in e&&"target"in e,Y=e=>!!e&&"object"==typeof e&&"id"in e&&"position"in e&&!("source"in e)&&!("target"in e),G=e=>!!e&&"object"==typeof e&&"id"in e&&"internals"in e&&!("source"in e)&&!("target"in e),W=(e,t=[0,0])=>{let{width:n,height:o}=eS(e),r=e.origin??t,i=n*r[0],a=o*r[1];return{x:e.position.x-i,y:e.position.y-a}},U=(e,t={nodeOrigin:[0,0]})=>{if(0===e.length)return{x:0,y:0,width:0,height:0};let n=!1,o=e.reduce((e,o)=>{let r="string"==typeof o,i=t.nodeLookup||r?void 0:o;return(t.nodeLookup&&(i=r?t.nodeLookup.get(o):G(o)?o:t.nodeLookup.get(o.id)),i)?(n=!0,ea(e,eu(i,t.nodeOrigin))):e},{x:1/0,y:1/0,x2:-1/0,y2:-1/0});return n?el(o):{x:0,y:0,width:0,height:0}},Z=(e,t={})=>{let n={x:1/0,y:1/0,x2:-1/0,y2:-1/0},o=!1;return e.forEach(e=>{(void 0===t.filter||t.filter(e))&&(n=ea(n,eu(e)),o=!0)}),o?el(n):{x:0,y:0,width:0,height:0}},q=(e,t,[n,o,r]=[0,0,1],i=!1,a=!1)=>{let s=(t.x-n)/r,l=(t.y-o)/r,d=t.width/r,u=t.height/r,c=[];for(let t of e.values()){let{measured:e,selectable:n=!0,hidden:o=!1}=t;if(a&&!n||o)continue;let r=e.width??t.width??t.initialWidth??0,h=e.height??t.height??t.initialHeight??0,{x:f,y:g}=t.internals.positionAbsolute,p=eh(s,l,d,u,f,g,r,h),m=r*h,y=i&&p>0;(!t.internals.handleBounds||y||p>=m||t.dragging)&&c.push(t)}return c};
1async function Q({nodes:e,width:t,height:n,panZoom:o,minZoom:r,maxZoom:i},a){let s,l;if(0===e.size)return!0;let d=ex(Z((s=new Map,l=a?.nodes?new Set(a.nodes.map(e=>e.id)):null,e.forEach(e=>{let t;if(a?.includeHiddenNodes){let{width:n,height:o}=eS(e);t=n>0&&o>0}else t=!!(e.measured.width&&e.measured.height&&!e.hidden);t&&(!l||l.has(e.id))&&s.set(e.id,e)}),s)),t,n,a?.minZoom??r,a?.maxZoom??i,a?.padding??.1);return await o.setViewport(d,{duration:a?.duration,ease:a?.ease,interpolate:a?.interpolate}),!0}function J({nodeId:e,nextPosition:t,nodeLookup:n,nodeOrigin:o=[0,0],nodeExtent:r,onError:i}){let a=n.get(e),s=a.parentId?n.get(a.parentId):void 0,{x:l,y:d}=s?s.internals.positionAbsolute:{x:0,y:0},u=a.origin??o,c=a.extent||r;if("parent"!==a.extent||a.expandParent)s&&e_(a.extent)&&(c=[[a.extent[0][0]+l,a.extent[0][1]+d],[a.extent[1][0]+l,a.extent[1][1]+d]]);else if(s){let{width:e,height:t}=eS(s);e&&t&&(c=[[l,d],[l+e,d+t]])}else i?.("005",B.error005());let h=e_(c)?en(t,c,a.measured):t;return(void 0===a.measured.width||void 0===a.measured.height)&&i?.("015",B.error015()),{position:{x:h.x-l+(a.measured.width??0)*u[0],y:h.y-d+(a.measured.height??0)*u[1]},positionAbsolute:h}}async function ee({nodesToRemove:e=[],edgesToRemove:t=[],nodes:n,edges:o,onBeforeDelete:r}){let i,a=new Set(e.map(e=>e.id)),s=[];for(let e of n){if(!1===e.deletable)continue;let t=a.has(e.id),n=!t&&e.parentId&&s.find(t=>t.id===e.parentId);(t||n)&&s.push(e)}let l=new Set(t.map(e=>e.id)),d=o.filter(e=>!1!==e.deletable),u=(i=new Set,s.forEach(e=>{i.add(e.id)}),d.filter(e=>i.has(e.source)||i.has(e.target)));for(let e of d)l.has(e.id)&&!u.find(t=>t.id===e.id)&&u.push(e);if(!r)return{edges:u,nodes:s};let c=await r({nodes:s,edges:u});return"boolean"==typeof c?c?{edges:u,nodes:s}:{edges:[],nodes:[]}:c}let et=(e,t=0,n=1)=>Math.min(Math.max(e,t),n),en=(e={x:0,y:0},t,n)=>({x:et(e.x,t[0][0],t[1][0]-(n?.width??0)),y:et(e.y,t[0][1],t[1][1]-(n?.height??0))});function eo(e,t,n){let{width:o,height:r}=eS(n),{x:i,y:a}=n.internals.positionAbsolute;return en(e,[[i,a],[i+o,a+r]],t)}let er=(e,t,n)=>e<t?et(Math.abs(e-t),1,t)/t:e>n?-et(Math.abs(e-n),1,t)/t:0,ei=(e,t,n=15,o=40)=>[er(e.x,o,t.width-o)*n,er(e.y,o,t.height-o)*n],ea=(e,t)=>({x:Math.min(e.x,t.x),y:Math.min(e.y,t.y),x2:Math.max(e.x2,t.x2),y2:Math.max(e.y2,t.y2)}),es=({x:e,y:t,width:n,height:o})=>({x:e,y:t,x2:e+n,y2:t+o}),el=({x:e,y:t,x2:n,y2:o})=>({x:e,y:t,width:n-e,height:o-t}),ed=(e,t=[0,0])=>{let{x:n,y:o}=G(e)?e.internals.positionAbsolute:W(e,t);return{x:n,y:o,width:e.measured?.width??e.width??e.initialWidth??0,height:e.measured?.height??e.height??e.initialHeight??0}},eu=(e,t=[0,0])=>{let{x:n,y:o}=G(e)?e.internals.positionAbsolute:W(e,t);return{x:n,y:o,x2:n+(e.measured?.width??e.width??e.initialWidth??0),y2:o+(e.measured?.height??e.height??e.initialHeight??0)}},ec=(e,t)=>el(ea(es(e),es(t))),eh=(e,t,n,o,r,i,a,s)=>Math.ceil(Math.max(0,Math.min(e+n,r+a)-Math.max(e,r))*Math.max(0,Math.min(t+o,i+s)-Math.max(t,i))),ef=(e,t)=>eh(e.x,e.y,e.width,e.height,t.x,t.y,t.width,t.height),eg=e=>ep(e.width)&&ep(e.height)&&ep(e.x)&&ep(e.y),ep=e=>!isNaN(e)&&isFinite(e),em=(e,t)=>(e,t)=>{},ey=(e,t=[1,1])=>({x:t[0]*Math.round(e.x/t[0]),y:t[1]*Math.round(e.y/t[1])}),ev=({x:e,y:t},[n,o,r],i=!1,a=[1,1])=>{let s={x:(e-n)/r,y:(t-o)/r};return i?ey(s,a):s},eb=({x:e,y:t},[n,o,r])=>({x:e*r+n,y:t*r+o});function ew(e,t){if("number"==typeof e)return Math.floor((t-t/(1+e))*.5);if("string"==typeof e&&e.endsWith("px")){let t=parseFloat(e);if(!Number.isNaN(t))return Math.floor(t)}if("string"==typeof e&&e.endsWith("%")){let n=parseFloat(e);if(!Number.isNaN(n))return Math.floor(t*n*.01)}return console.error(`The padding value "${e}" is invalid. Please provide a number or a string with a valid unit (px or %).`),0}let ex=(e,t,n,o,r,i)=>{let a=function(e,t,n){if("string"==typeof e||"number"==typeof e){let o=ew(e,n),r=ew(e,t);return{top:o,right:r,bottom:o,left:r,x:2*r,y:2*o}}if("object"==typeof e){let o=ew(e.top??e.y??0,n),r=ew(e.bottom??e.y??0,n),i=ew(e.left??e.x??0,t),a=ew(e.right??e.x??0,t);return{top:o,right:a,bottom:r,left:i,x:i+a,y:o+r}}return{top:0,right:0,bottom:0,left:0,x:0,y:0}}
1(i,t,n),s=et(Math.min((t-a.x)/e.width,(n-a.y)/e.height),o,r),l=e.x+e.width/2,d=e.y+e.height/2,u=t/2-l*s,c=n/2-d*s,h=function(e,t,n,o,r,i){let{x:a,y:s}=eb(e,[t,n,o]),{x:l,y:d}=eb({x:e.x+e.width,y:e.y+e.height},[t,n,o]);return{left:Math.floor(a),top:Math.floor(s),right:Math.floor(r-l),bottom:Math.floor(i-d)}}(e,u,c,s,t,n),f={left:Math.min(h.left-a.left,0),top:Math.min(h.top-a.top,0),right:Math.min(h.right-a.right,0),bottom:Math.min(h.bottom-a.bottom,0)};return{x:u-f.left+f.right,y:c-f.top+f.bottom,zoom:s}},eE=()=>"u">typeof navigator&&navigator?.userAgent?.indexOf("Mac")>=0;function e_(e){return null!=e&&"parent"!==e}function eS(e){return{width:e.measured?.width??e.width??e.initialWidth??0,height:e.measured?.height??e.height??e.initialHeight??0}}function eC(e){return(e.measured?.width??e.width??e.initialWidth)!==void 0&&(e.measured?.height??e.height??e.initialHeight)!==void 0}function eM(e,t={width:0,height:0},n,o,r){let i={...e},a=o.get(n);if(a){let e=a.origin||r;i.x+=a.internals.positionAbsolute.x-(t.width??0)*e[0],i.y+=a.internals.positionAbsolute.y-(t.height??0)*e[1]}return i}function ek(e,t){if(e.size!==t.size)return!1;for(let n of e)if(!t.has(n))return!1;return!0}function eN(){let e,t;return{promise:new Promise((n,o)=>{e=n,t=o}),resolve:e,reject:t}}function eL(e){return{...z,...e||{}}}function eA(e,t){if(!e&&!t)return!0;if(!e||!t||e.size!==t.size)return!1;if(!e.size&&!t.size)return!0;for(let n of e.keys())if(!t.has(n))return!1;return!0}function eO(e,t,n){if(!n)return;let o=[];e.forEach((e,n)=>{t?.has(n)||o.push(e)}),o.length&&n(o)}function eI(e){return null===e?null:e?"valid":"invalid"}function eP(e,{snapGrid:t=[0,0],snapToGrid:n=!1,transform:o,containerBounds:r}){let{x:i,y:a}=eB(e),s=ev({x:i-(r?.left??0),y:a-(r?.top??0)},o),{x:l,y:d}=n?ey(s,t):s;return{xSnapped:l,ySnapped:d,...s}}let eT=e=>({width:e.offsetWidth,height:e.offsetHeight}),eR=e=>e?.getRootNode?.()||window?.document,eD=["INPUT","SELECT","TEXTAREA"];function ej(e){let t=e.composedPath?.()?.[0]||e.target;return t?.nodeType===1&&(eD.includes(t.nodeName)||t.hasAttribute("contenteditable")||!!t.closest(".
1nokey"))}let e$=e=>"clientX"in e,eB=(e,t)=>{let n=e$(e),o=n?e.clientX:e.touches?.[0].clientX,r=n?e.clientY:e.touches?.[0].clientY;return{x:o-(t?.left??0),y:r-(t?.top??0)}},eF=(e,t,n,o,r)=>{let i=t.querySelectorAll(`.${e}`);return i&&i.length?Array.from(i).map(t=>{let i=t.getBoundingClientRect();return{id:t.getAttribute("data-handleid"),type:e,nodeId:r,position:t.getAttribute("data-handlepos"),x:(i.left-n.left)/o,y:(i.top-n.top)/o,...eT(t)}}):null};function eH({sourceX:e,sourceY:t,targetX:n,targetY:o,sourceControlX:r,sourceControlY:i,targetControlX:a,targetControlY:s}){let l=.125*e+.375*r+.375*a+.125*n,d=.125*t+.375*i+.375*s+.125*o,u=Math.abs(l-e),c=Math.abs(d-t);return[l,d,u,c]}function ez(e,t){return e>=0?.5*e:25*t*Math.sqrt(-e)}function eV({pos:e,x1:t,y1:n,x2:o,y2:r,c:i}){switch(e){case g.Left:return[t-ez(t-o,i),n];case g.Right:return[t+ez(o-t,i),n];case g.Top:return[t,n-ez(n-r,i)];case g.Bottom:return[t,n+ez(r-n,i)]}}function eK({sourceX:e,sourceY:t,sourcePosition:n=g.Bottom,targetX:o,targetY:r,targetPosition:i=g.Top,curvature:a=.25}){let[s,l]=eV({pos:n,x1:e,y1:t,x2:o,y2:r,c:a}),[d,u]=eV({pos:i,x1:o,y1:r,x2:e,y2:t,c:a}),[c,h,f,p]=eH({sourceX:e,sourceY:t,targetX:o,targetY:r,sourceControlX:s,sourceControlY:l,targetControlX:d,targetControlY:u});return[`M${e},${t} C${s},${l} ${d},${u} ${o},${r}`,c,h,f,p]}function eX({sourceX:e,sourceY:t,targetX:n,targetY:o}){let r=Math.abs(n-e)/2,i=Math.abs(o-t)/2;return[n<e?n+r:n-r,o<t?o+i:o-i,r,i]}function eY({sourceNode:e,targetNode:t,selected:n=!1,zIndex:o=0,elevateOnSelect:r=!1,zIndexMode:i="basic"}){if("manual"===i)return o;let a=Math.max(e.parentId||r&&e.selected?e.internals.z:0,t.parentId||r&&t.selected?t.internals.z:0);return(r&&n?o+1e3:o)+a}function eG({sourceNode:e,targetNode:t,width:n,height:o,transform:r}){let i=ea(eu(e),eu(t));return i.x===i.x2&&(i.x2+=1),i.y===i.y2&&(i.y2+=1),ef({x:-r[0]/r[2],y:-r[1]/r[2],width:n/r[2],height:o/r[2]},el(i))>0}let eW=({source:e,sourceHandle:t,target:n,targetHandle:o})=>`xy-edge__${e}${t||""}-${n}${o||""}`,eU=(e,t,n={})=>{let o,r;if(!e.source||!e.target)return n.onError?.("006",B.error006()),t;let i=n.getEdgeId||eW;return(r=o=X(e)?{...e}:{...e,id:i(e)},t.some(e=>e.source===r.source&&e.target===r.target&&(e.sourceHandle===r.sourceHandle||!e.sourceHandle&&!r.sourceHandle)&&(e.targetHandle===r.targetHandle||!e.targetHandle&&!r.targetHandle)))?t:(null===o.sourceHandle&&delete o.sourceHandle,null===o.targetHandle&&delete o.targetHandle,t.concat(o))},eZ=(e,t,n,o={shouldReplaceId:!0})=>{let{id:r,...i}=e;if(!t.source||!t.target)return o.onError?.("006",B.error006()),n;if(!n.find(t=>t.id===e.id))return o.onError?.("007",B.error007(r)),n;let a=o.getEdgeId||eW,s={...i,id:o.shouldReplaceId?a(t):r,source:t.source,target:t.target,sourceHandle:t.sourceHandle,targetHandle:t.targetHandle};return n.filter(e=>e.id!==r).concat(s)};function eq({sourceX:e,sourceY:t,targetX:n,targetY:o}){let[r,i,a,s]=eX({sourceX:e,sourceY:t,targetX:n,targetY:o});return[`M ${e},${t}L ${n},${o}`,r,i,a,s]}let eQ={[g.Left]:{x:-1,y:0},[g.Right]:{x:1,y:0},[g.Top]:{x:0,y:-1},[g.Bottom]:{x:0,y:1}},eJ=({source:e,sourcePosition:t=g.Bottom,target:n})=>t===g.Left||t===g.Right?e.x<n.x?{x:1,y:0}:{x:-1,y:0}:e.y<n.y?{x:0,y:1}:{x:0,y:-1},e0=(e,t)=>Math.sqrt(Math.pow(t.x-e.x,2)+Math.pow(t.y-e.y,2));function e1({sourceX:e,sourceY:t,sourcePosition:n=g.Bottom,targetX:o,targetY:r,targetPosition:i=g.Top,borderRadius:a=5,centerX:s,centerY:l,offset:d=20,stepPosition:u=.5}){let[c,h,f,p,m]=function({source:e,sourcePosition:t=g.Bottom,target:n,targetPosition:o=g.Top,center:r,offset:i,stepPosition:a}){let s,l,d=eQ[t],u=eQ[o],c={x:e.x+d.x*i,y:e.y+d.y*i},h={x:n.x+u.x*i,y:n.y+u.y*i},f=eJ({source:c,sourcePosition:t,target:h}),p=0!==f.x?"x":"y",m=f[p],y=[],v={x:0,y:0},b={x:0,y:0},[,,w,x]=eX({sourceX:e.x,sourceY:e.y,targetX:n.x,targetY:n.y});if(d[p]*u[p]==-1){"x"===p?(s=r.x??c.x+(h.x-c.x)*a,l=r.y??(c.y+h.y)/2):(s=r.x??(c.x+h.x)/2,l=r.y??c.y+(h.y-c.y)*a);let e=[{x:s,y:c.y},{x:s,y:h.y}],t=[{x:c.x,y:l},{x:h.x,y:l}];y=d[p]===m?"x"===p?e:t:"x"===p?t:e}else{let r=[{x:c.x,y:h.y}],a=[{x:h.x,y:c.y}];if(y="x"===p?d.x===m?a:r:d.y===m?r:a,t===o){let t=Math.abs(e[p]-n[p]);if(t<=i){let o=Math.min(i-1,i-t);d[p]===m?v[p]=(c[p]>e[p]?-1:1)*o:b[p]=(h[p]>n[p]?-1:1)*o}}if(t!==o){let e="x"===p?"y":"x",t=d[p]===u[e],n=c[e]>h[e],o=c[e]<h[e];(1===d[p]&&(!t&&n||t&&o)||1!==d[p]&&(!t&&o||t&&n))&&(y="x"===p?r:a)}let f={x:c.x+v.x,y:c.y+v.y},g={x:h.x+b.x,y:h.y+b.y};Math.max(Math.abs(f.x-y[0].x),Math.abs(g.x-y[0].x))>=Math.max(Math.abs(f.y-y[0].y),Math.abs(g.y-y[0].y))?(s=(f.x+g.x)/2,l=y[0].y):(s=y[0].x,l=(f.y+g.y)/2)}let E={x:c.x+v.x,y:c.y+v.y},_={x:h.x+b.x,y:h.y+b.y};return[[e,...E.x!==y[0].x||E.y!==y[0].y?[E]:[],...y,..._.x!==y[y.length-1].x||_.y!==y[y.length-1].y?[_]:[],n],s,l,w,x]}({source:{x:e,y:t},sourcePosition:n,target:{x:o,y:r},targetPosition:i,center:{x:s,y:l},offset:d,stepPosition:u}),y=`M${c[0].x} ${c[0].y}`;for(let e=1;e<c.length-1;e++)y+=function(e,t,n,o){let r=Math.min(e0(e,t)/2,e0(t,n)/2,o),{x:i,y:a}=t;if(e.x===i&&i===n.x||e.y===a&&a===n.y)return`L${i} ${a}`;if(e.y===a){let t=e.x<n.x?-1:1,o=e.y<n.y?1:-1;return`L ${i+r*t},${a}Q ${i},${a} ${i},${a+r*o}`}let s=e.x<n.x?1:-1,l=e.y<n.y?-1:1;return`L ${i},${a+r*l}Q ${i},${a} ${i+r*s},${a}`}(c[e-1],c[e],c[e+1],a);return[y+=`L${c[c.length-1].x} ${c[c.length-1].y}`,h,f,p,m]}function e2(e){return e&&!!(e.internals.handleBounds||e.handles?.length)&&!!(e.measured.width||e.width||e.initialWidth)}function e3(e){let{sourceNode:t,targetNode:n}=e;if(!e2(t)||!e2(n))return null;let o=t.internals.handleBounds||e5(t.handles),r=n.internals.handleBounds||e5(n.handles),i=e8(o?.source??[],e.sourceHandle),a=e8(e.connectionMode===d.Strict?r?.target??[]:(r?.target??[]).concat(r?.source??[]),e.targetHandle);if(!i||!a)return e.onError?.("008",B.error008(!i?"source":"target",{id:e.id,sourceHandle:e.sourceHandle,targetHandle:e.targetHandle})),null;let s=i?.position||g.Bottom,l=a?.position||g.Top,u=e4(t,i,s),c=e4(n,a,l);return{sourceX:u.x,sourceY:u.y,targetX:c.x,targetY:c.y,sourcePosition:s,targetPosition:l}}function e5(e){if(!e)return null;let t=[],n=[];for(let o of e)o.width=o.width??1,o.height=o.height??1,"source"===o.type?t.push(o):"target"===o.type&&n.push(o);return{source:t,target:n}}function e4(e,t,n=g.Left,o=!1){let r=(t?.x??0)+e.internals.positionAbsolute.x,i=(t?.y??0)+e.internals.positionAbsolute.y,{width:a,height:s}=t??eS(e);if(o)return{x:r+a/2,y:i+s/2};switch(t?.position??n){case g.Top:return{x:r+a/2,y:i};case g.Right:return{x:r+a,y:i+s/2};case g.Bottom:return{x:r+a/2,y:i+s};case g.Left:return{x:r,y:i+s/2}}}function e8(e,t){return e&&(t?e.find(e=>e.id===t):e[0])||null}function e6(e,t){if(!e)return"";if("string"==typeof e)return e;let n=t?`${t}__`:"";return`${n}${Object.keys(e).sort().map(t=>`${t}=${e[t]}`).join("&")}`}function e7(e,{id:t,defaultColor:n,defaultMarkerStart:o,defaultMarkerEnd:r}){let i=new Set;return e.reduce((e,a)=>([a.markerStart||o,a.markerEnd||r].forEach(o=>{if(o&&"object"==typeof o){let r=e6(o,t);i.has(r)||(e.push({id:r,color:o.color||n,...o}),i.add(r))}}),e),[]).sort((e,t)=>
1e.id.localeCompare(t.id))}function e9(e,t,n,o,r){let i=.5;"start"===r?i=0:"end"===r&&(i=1);let a=[(e.x+e.width*i)*t.zoom+t.x,e.y*t.zoom+t.y-o],s=[-100*i,-100];switch(n){case g.Right:a=[(e.x+e.width)*t.zoom+t.x+o,(e.y+e.height*i)*t.zoom+t.y],s=[0,-100*i];break;case g.Bottom:a[1]=(e.y+e.height)*t.zoom+t.y+o,s[1]=0;break;case g.Left:a=[e.x*t.zoom+t.x-o,(e.y+e.height*i)*t.zoom+t.y],s=[-100,-100*i]}return`translate(${a[0]}px, ${a[1]}px) translate(${s[0]}%, ${s[1]}%)`}let te={left:0,center:50,right:100},tt={top:0,center:50,bottom:100};function tn(e,t,n,o="center",r="center"){return`translate(${e}px, ${t}px) scale(${1/n}) translate(${-(te[o]??50)}%, ${-(tt[r]??50)}%)`}let to={nodeOrigin:[0,0],nodeExtent:F,elevateNodesOnSelect:!0,zIndexMode:"basic",defaults:{}},tr={...to,checkEquality:!0};function ti(e,t){let n={...e};for(let e in t)void 0!==t[e]&&(n[e]=t[e]);return n}function ta(e,t,n){let o=ti(to,n);for(let n of e.values())if(n.parentId)td(n,e,t,o);else{let e=en(W(n,o.nodeOrigin),e_(n.extent)?n.extent:o.nodeExtent,eS(n));n.internals.positionAbsolute=e}}function ts(e){return"manual"===e}function tl(e,t,n,o={}){let r=ti(tr,o),i={i:0},a=new Map(t),s=r?.elevateNodesOnSelect&&!ts(r.zIndexMode)?1e3:0,l=e.length>0,d=!1;for(let u of(t.clear(),n.clear(),e)){let e=a.get(u.id);if(r.checkEquality&&u===e?.internals.userNode)t.set(u.id,e);else{let n=en(W(u,r.nodeOrigin),e_(u.extent)?u.extent:r.nodeExtent,eS(u));e={...r.defaults,...u,measured:{width:u.measured?.width,height:u.measured?.height},internals:{positionAbsolute:n,handleBounds:function(e,t){if(!e.handles)return e.measured?t?.internals.handleBounds:void 0;let n=[],o=[];for(let t of e.handles){let r={id:t.id,width:t.width??1,height:t.height??1,nodeId:e.id,x:t.x,y:t.y,position:t.position,type:t.type};"source"===t.type?n.push(r):"target"===t.type&&o.push(r)}return{source:n,target:o}}(u,e),z:tu(u,s,r.zIndexMode),userNode:u}},t.set(u.id,e)}void 0!==e.measured&&void 0!==e.measured.width&&void 0!==e.measured.height||e.hidden||(l=!1),u.parentId&&td(e,t,n,o,i),d||=u.selected??!1}return{nodesInitialized:l,hasSelectedNodes:d}}function td(e,t,n,o,r){let{elevateNodesOnSelect:i,nodeOrigin:a,nodeExtent:s,zIndexMode:l}=ti(to,o),d=e.parentId,u=t.get(d);if(!u)return void console.warn(`Parent node ${d} not found. Please make sure that parent nodes are in front of their child nodes in the nodes array.`);!function(e,t){if(!e.parentId)return;let n=t.get(e.parentId);n?n.set(e.id,e):t.set(e.parentId,new Map([[e.id,e]]))}(e,n),r&&!u.parentId&&void 0===u.internals.rootParentIndex&&"auto"===l&&(u.internals.rootParentIndex=++r.i,u.internals.z=u.internals.z+10*r.i),r&&void 0!==u.internals.rootParentIndex&&(r.i=u.internals.rootParentIndex);let{x:c,y:h,z:f}=function(e,t,n,o,r,i){let{x:a,y:s}=t.internals.positionAbsolute,l=eS(e),d=W(e,n),u=e_(e.extent)?en(d,e.extent,l):d,c=en({x:a+u.x,y:s+u.y},o,l);"parent"===e.extent&&(c=eo(c,l,t));let h=tu(e,r,i),f=t.internals.z??0;return{x:c.x,y:c.y,z:f>=h?f+1:h}}(e,u,a,s,i&&!ts(l)?1e3:0,l),{positionAbsolute:g}=e.internals,p=c!==g.x||h!==g.y;(p||f!==e.internals.z)&&t.set(e.id,{...e,internals:{...e.internals,positionAbsolute:p?{x:c,y:h}:g,z:f}})}function tu(e,t,n){let o=ep(e.zIndex)?e.zIndex:0;return ts(n)?o:o+(e.selected?t:0)}function tc(e,t,n,o=[0,0]){let r=[],i=new Map;for(let n of e){let e=t.get(n.parentId);if(!e)continue;let o=ec(i.get(n.parentId)?.expandedRect??ed(e),n.rect);i.set(n.parentId,{expandedRect:o,parent:e})}return i.size>0&&i.forEach(({expandedRect:t,parent:i},a)=>{let s=i.internals.positionAbsolute,l=eS(i),d=i.origin??o,u=t.x<s.x?Math.round(Math.abs(s.x-t.x)):0,c=t.y<s.y?Math.round(Math.abs(s.y-t.y)):0,h=Math.max(l.width,Math.round(t.width)),f=Math.max(l.height,Math.round(t.height)),g=(h-l.width)*d[0],p=(f-l.height)*d[1];(u>0||c>0||g||p)&&(r.push({id:a,type:"position",position:{x:i.position.x-u+g,y:i.position.y-c+p}}),n.get(a)?.forEach(t=>{e.some(e=>e.id===t.id)||r.push({id:t.id,type:"position",position:{x:t.position.x+u,y:t.position.y+c}})})),(l.width<t.width||l.height<t.height||u||c)&&r.push({id:a,type:"dimensions",setAttributes:!0,dimensions:{width:h+(u?d[0]*u-g:0),height:f+(c?d[1]*c-p:0)}})}),r}function th(e,t,n,o,r,i,a){let s=o?.querySelector(".xyflow__viewport"),l=!1;if(!s)return{changes:[],updatedInternals:l};let d=[],u=window.getComputedStyle(s),{m22:c}=new window.DOMMatrixReadOnly(u.transform),h=[];for(let o of e.values()){let e=t.get(o.id);if(!e)continue;if(e.hidden){t.set(e.id,{...e,internals:{...e.internals,handleBounds:void 0}}),l=!0;continue}let s=eT(o.nodeElement),u=e.measured.width!==s.width||e.measured.height!==s.height;if(s.width&&s.height&&(u||!e.internals.handleBounds||o.force)){let f=o.nodeElement.getBoundingClientRect(),g=e_(e.extent)?e.extent:i,{positionAbsolute:p}=e.internals;if(e.parentId&&"parent"===e.extent){let n=t.get(e.parentId);n&&(p=eo(p,s,n))}else g&&(p=en(p,g,s));let m={...e,measured:s,internals:{...e.internals,positionAbsolute:p,handleBounds:{source:eF("source",o.nodeElement,f,c,e.id),target:eF("target",o.nodeElement,f,c,e.id)}}};t.set(e.id,m),e.parentId&&td(m,t,n,{nodeOrigin:r,zIndexMode:a}),l=!0,u&&(d.push({id:e.id,type:"dimensions",dimensions:s}),e.expandParent&&e.parentId&&h.push({id:e.id,parentId:e.parentId,rect:ed(m,r)}))}}if(h.length>0){let e=tc(h,t,n,r);d.push(...e)}return{changes:d,updatedInternals:l}}async function tf({delta:e,panZoom:t,transform:n,translateExtent:o,width:r,height:i}){if(!t||!e.x&&!e.y)return!1;let a=await t.setViewportConstrained({x:n[0]+e.x,y:n[1]+e.y,zoom:n[2]},[[0,0],[r,i]],o);return!!a&&(a.x!==n[0]||a.y!==n[1]||a.k!==n[2])}function tg(e,t,n,o,r,i){let a=r,s=o.get(a)||new Map;o.set(a,s.set(n,t)),a=`${r}-${e}`;let l=o.get(a)||new Map;if(o.set(a,l.set(n,t)),i){a=`${r}-${e}-${i}`;let s=o.get(a)||new Map;o.set(a,s.set(n,t))}}function tp(e,t,n){for(let o of(e.clear(),t.clear(),n)){let{source:n,target:r,sourceHandle:i=null,targetHandle:a=null}=o,s={edgeId:o.id,source:n,target:r,sourceHandle:i,targetHandle:a},l=`${n}-${i}--${r}-${a}`;tg("source",s,`${r}-${a}--${n}-${i}`,e,n,i),tg("target",s,l,e,r,a),t.set(o.id,o)}}function tm(e,t){if(null===e||null===t)return!1;let n=Array.isArray(e)?e:[e],o=Array.isArray(t)?t:[t];if(n.length!==o.length)return!1;for(let e=0;e<n.length;e++)if(n[e].id!==o[e].id||n[e].type!==o[e].type||!Object.is(n[e].data,o[e].data))return!1;return!0}function ty(e,t,n){let o=e;do{if(o?.matches?.(t))return!0;
1if(o===n)break;o=o?.parentElement}while(o)return!1}function tv({nodeId:e,dragItems:t,nodeLookup:n,dragging:o=!0}){let r=[];for(let[e,i]of t){let t=n.get(e)?.internals.userNode;t&&r.push({...t,position:i.position,dragging:o})}if(!e)return[r[0],r];let i=n.get(e)?.internals.userNode;return[i?{...i,position:t.get(e)?.position||i.position,dragging:o}:r[0],r]}function tb({onNodeMouseDown:e,getStoreItems:t,onDragStart:n,onDrag:o,onDragStop:r}){let i={x:null,y:null},a=0,s=new Map,l=!1,d={x:0,y:0},u=null,c=!1,h=null,f=!1,g=!1,p=null;return{update:function({noDragClassName:m,handleSelector:y,domNode:v,isSelectable:b,nodeId:w,nodeClickDistance:x=0}){function E({x:e,y:n}){let{nodeLookup:r,nodeExtent:a,snapGrid:l,snapToGrid:d,nodeOrigin:u,onNodeDrag:c,onSelectionDrag:h,onError:f,updateNodePositions:m}=t();i={x:e,y:n};let y=!1,v=s.size>1,b=v&&a?es(Z(s)):null,x=v&&d?function({dragItems:e,snapGrid:t,x:n,y:o}){let r=e.values().next().value;if(!r)return null;let i={x:n-r.distance.x,y:o-r.distance.y},a=ey(i,t);return{x:a.x-i.x,y:a.y-i.y}}({dragItems:s,snapGrid:l,x:e,y:n}):null;for(let[t,o]of s){if(!r.has(t))continue;let i={x:e-o.distance.x,y:n-o.distance.y};d&&(i=x?{x:Math.round(i.x+x.x),y:Math.round(i.y+x.y)}:ey(i,l));let s=null;if(v&&a&&!o.extent&&b){let{positionAbsolute:e}=o.internals,t=e.x-b.x+a[0][0],n=e.x+o.measured.width-b.x2+a[1][0];s=[[t,e.y-b.y+a[0][1]],[n,e.y+o.measured.height-b.y2+a[1][1]]]}let{position:c,positionAbsolute:h}=J({nodeId:t,nextPosition:i,nodeLookup:r,nodeExtent:s||a,nodeOrigin:u,onError:f});y=y||o.position.x!==c.x||o.position.y!==c.y,o.position=c,o.internals.positionAbsolute=h}if(g=g||y,y&&(m(s,!0),p&&(o||c||!w&&h))){let[e,t]=tv({nodeId:w,dragItems:s,nodeLookup:r});o?.(p,s,e,t),c?.(p,e,t),w||h?.(p,t)}}async function S(){if(!u)return;let{transform:e,panBy:n,autoPanSpeed:o,autoPanOnNodeDrag:r}=t();if(!r){l=!1,cancelAnimationFrame(a);return}let[s,c]=ei(d,u,o);(0!==s||0!==c)&&(i.x=(i.x??0)-s/e[2],i.y=(i.y??0)-c/e[2],await n({x:s,y:c})&&E(i)),a=requestAnimationFrame(S)}function C(o){let{nodeLookup:r,multiSelectionActive:a,nodesDraggable:l,transform:d,snapGrid:h,snapToGrid:f,selectNodesOnDrag:g,onNodeDragStart:p,onSelectionDragStart:m,unselectNodesAndEdges:y}=t();c=!0,g&&b||a||!w||r.get(w)?.selected||y(),b&&g&&w&&e?.(w);let v=eP(o.sourceEvent,{transform:d,snapGrid:h,snapToGrid:f,containerBounds:u});if(i=v,(s=function(e,t,n,o){let r=new Map;for(let[i,a]of e)if((a.selected||a.id===o)&&(!a.parentId||!function e(t,n){if(!t.parentId)return!1;let o=n.get(t.parentId);return!!o&&(!!o.selected||e(o,n))}(a,e))&&(a.draggable||t&&void 0===a.draggable)){let t=e.get(i);t&&r.set(i,{id:i,position:t.position||{x:0,y:0},distance:{x:n.x-t.internals.positionAbsolute.x,y:n.y-t.internals.positionAbsolute.y},extent:t.extent,parentId:t.parentId,origin:t.origin,expandParent:t.expandParent,internals:{positionAbsolute:t.internals.positionAbsolute||{x:0,y:0}},measured:{width:t.measured.width??0,height:t.measured.height??0}})}return r}(r,l,v,w)).size>0&&(n||p||!w&&m)){let[e,t]=tv({nodeId:w,dragItems:s,nodeLookup:r});n?.(o.sourceEvent,s,e,t),p?.(o.sourceEvent,e,t),w||m?.(o.sourceEvent,t)}}h=(0,_.select)(v);let M=P().clickDistance(x).on("start",e=>{let{domNode:n,nodeDragThreshold:o,transform:r,snapGrid:a,snapToGrid:s}=t();u=n?.getBoundingClientRect()||null,f=!1,g=!1,p=e.sourceEvent,0===o&&C(e),i=eP(e.sourceEvent,{transform:r,snapGrid:a,snapToGrid:s,containerBounds:u}),d=eB(e.sourceEvent,u)}).on("drag",e=>{let{autoPanOnNodeDrag:n,transform:o,snapGrid:r,snapToGrid:a,nodeDragThreshold:h,nodeLookup:g}=t(),m=eP(e.sourceEvent,{transform:o,snapGrid:r,snapToGrid:a,containerBounds:u});if(p=e.sourceEvent,("touchmove"===e.sourceEvent.type&&e.sourceEvent.touches.length>1||w&&!g.has(w))&&(f=!0),!f){if(!l&&n&&c&&(l=!0,S()),!c){let t=eB(e.sourceEvent,u),n=t.x-d.x,o=t.y-d.y;Math.sqrt(n*n+o*o)>h&&C(e)}(i.x!==m.xSnapped||i.y!==m.ySnapped)&&s&&c&&(d=eB(e.sourceEvent,u),E(m))}}).on("end",e=>{if(!c||f){f&&s.size>0&&t().updateNodePositions(s,!1);return}if(l=!1,c=!1,cancelAnimationFrame(a),s.size>0){let{nodeLookup:n,updateNodePositions:o,onNodeDragStop:i,onSelectionDragStop:a}=t();if(g&&(o(s,!1),g=!1),r||i||!w&&a){let[t,o]=tv({nodeId:w,dragItems:s,nodeLookup:n,dragging:!1});r?.(e.sourceEvent,s,t,o),i?.(e.sourceEvent,t,o),w||a?.(e.sourceEvent,o)}}}).filter(e=>{let t=e.target;return!e.button&&(!m||!ty(t,`.${m}`,v))&&(!y||ty(t,y,v))});h.call(M)},destroy:function(){h?.on(".drag",null)}}}function tw(e,t,n,o,r,i=!1){let a=o.get(e);if(!a)return null;let s="strict"===r?a.internals.handleBounds?.[t]:[...a.internals.handleBounds?.source??[],...a.internals.handleBounds?.target??[]],l=(n?s?.find(e=>e.id===n):s?.[0])??null;return l&&i?{...l,...e4(a,l,l.position,!0)}:l}function tx(e,t){return e?e:t?.classList.contains("target")?"target":t?.classList.contains("source")?"
1source":null}let tE=()=>!0;function t_(e,{handle:t,connectionMode:n,fromNodeId:o,fromHandleId:r,fromType:i,doc:a,lib:s,flowId:l,isValidConnection:u=tE,nodeLookup:c}){let h="target"===i,f=t?a.querySelector(`.${s}-flow__handle[data-id="${l}-${t?.nodeId}-${t?.id}-${t?.type}"]`):null,{x:g,y:p}=eB(e),m=a.elementFromPoint(g,p),y=m?.classList.contains(`${s}-flow__handle`)?m:f,v={handleDomNode:y,isValid:!1,connection:null,toHandle:null};if(y){let e=tx(void 0,y),t=y.getAttribute("data-nodeid"),i=y.getAttribute("data-handleid"),a=y.classList.contains("connectable"),s=y.classList.contains("connectableend");if(!t||!e)return v;let l={source:h?t:o,sourceHandle:h?i:r,target:h?o:t,targetHandle:h?r:i};v.connection=l,v.isValid=a&&s&&(n===d.Strict?h&&"source"===e||!h&&"target"===e:t!==o||i!==r)&&u(l),v.toHandle=tw(t,e,i,c,n,!0)}return v}let tS={onPointerDown:function(e,{connectionMode:t,connectionRadius:n,handleId:o,nodeId:r,edgeUpdaterType:i,isTarget:a,domNode:s,nodeLookup:l,lib:d,autoPanOnConnect:u,flowId:c,panBy:h,cancelConnection:f,onConnectStart:p,onConnect:m,onConnectEnd:y,isValidConnection:v=tE,onReconnectEnd:b,updateConnection:w,getTransform:x,getFromHandle:E,autoPanSpeed:_,dragThreshold:S=1,handleDomNode:C}){let M,k=eR(e.target),N=0,{x:L,y:A}=eB(e),O=tx(i,C),I=s?.getBoundingClientRect(),P=!1;if(!I||!O)return;let T=tw(r,O,o,l,t);if(!T)return;let R=eB(e,I),D=!1,j=null,$=!1,B=null,F={...T,nodeId:r,type:O,position:T.position},H=l.get(r),z={inProgress:!0,isValid:null,from:e4(H,F,g.Left,!0),fromHandle:F,fromPosition:F.position,fromNode:H,to:R,toHandle:null,toPosition:K[F.position],toNode:null,pointer:R};function V(){P=!0,w(z),p?.(e,{nodeId:r,handleId:o,handleType:O})}function X(e){var i,s;let f;if(!P){let{x:t,y:n}=eB(e),o=t-L,r=n-A;if(!(o*o+r*r>S*S))return;V()}if(!E()||!F)return void Y(e);let p=x();M=function(e,t,n,o){let r=[],i=1/0;for(let a of function(e,t,n){let o=[],r={x:e.x-n,y:e.y-n,width:2*n,height:2*n};for(let e of t.values())ef(r,ed(e))>0&&o.push(e);return o}(e,n,t+250))for(let n of[...a.internals.handleBounds?.source??[],...a.internals.handleBounds?.target??[]]){if(o.nodeId===n.nodeId&&o.type===n.type&&o.id===n.id)continue;let{x:s,y:l}=e4(a,n,n.position,!0),d=Math.sqrt(Math.pow(s-e.x,2)+Math.pow(l-e.y,2));d>t||(d<i?(r=[{...n,x:s,y:l}],i=d):d===i&&r.push({...n,x:s,y:l}))}if(!r.length)return null;if(r.length>1){let e="source"===o.type?"target":"source";return r.find(t=>t.type===e)??r[0]}return r[0]}(ev(R=eB(e,I),p,!1,[1,1]),n,l,F),D||(!function e(){if(!u||!I)return;let[t,n]=ei(R,I,_);h({x:t,y:n}),N=requestAnimationFrame(e)}(),D=!0);let m=t_(e,{handle:M,connectionMode:t,fromNodeId:r,fromHandleId:o,fromType:a?"target":"source",isValidConnection:v,doc:k,lib:d,flowId:c,nodeLookup:l});B=m.handleDomNode,j=m.connection,i=!!M,s=m.isValid,f=null,s?f=!0:i&&!s&&(f=!1),$=f;let y=l.get(r),b=y?e4(y,F,g.Left,!0):z.from,C={...z,from:b,isValid:$,to:m.toHandle&&$?eb({x:m.toHandle.x,y:m.toHandle.y},p):R,toHandle:m.toHandle,toPosition:$&&m.toHandle?m.toHandle.position:K[F.position],toNode:m.toHandle?l.get(m.toHandle.nodeId):null,pointer:R};w(C),z=C}function Y(e){if(!("touches"in e)||!(e.touches.length>0)){if(P){(M||B)&&j&&$&&m?.(j);let{inProgress:t,...n}=z,o={...n,toPosition:z.toHandle?z.toPosition:null};y?.(e,o),i&&b?.(e,o)}f(),cancelAnimationFrame(N),D=!1,$=!1,j=null,B=null,k.removeEventListener("mousemove",X),k.removeEventListener("mouseup",Y),k.removeEventListener("touchmove",X),k.removeEventListener("touchend",Y)}}0===S&&V(),k.addEventListener("mousemove",X),k.addEventListener("mouseup",Y),k.addEventListener("touchmove",X),k.addEventListener("touchend",Y)},isValid:t_};function tC({domNode:e,panZoom:t,getTransform:n,getViewScale:o}){let r=(0,_.select)(e);return{update:function({translateExtent:e,width:i,height:a,zoomStep:s=1,pannable:l=!0,zoomable:d=!0,inversePan:u=!1}){let c=[0,0],h=(0,T.default)().on("start",e=>{("mousedown"===e.sourceEvent.type||"touchstart"===e.sourceEvent.type)&&(c=[e.sourceEvent.clientX??e.sourceEvent.touches[0].clientX,e.sourceEvent.clientY??e.sourceEvent.touches[0].clientY])}).on("zoom",l?r=>{let s=n();if("mousemove"!==r.sourceEvent.type&&"touchmove"!==r.sourceEvent.type||!t)return;let l=[r.sourceEvent.clientX??r.sourceEvent.touches[0].clientX,r.sourceEvent.clientY??r.sourceEvent.touches[0].clientY],d=[l[0]-c[0],l[1]-c[1]];c=l;let h=o()*Math.max(s[2],Math.log(s[2]))*(u?-1:1),f={x:s[0]-d[0]*h,y:s[1]-d[1]*h};t.setViewportConstrained({x:f.x,y:f.y,zoom:s[2]},[[0,0],[i,a]],e)}:null).on("zoom.wheel",d?e=>{if("wheel"!==e.sourceEvent.type||!t)return;let o=n(),r=e.sourceEvent.ctrlKey&&eE()?10:1,i=-e.sourceEvent.deltaY*(1===e.sourceEvent.deltaMode?.05:e.sourceEvent.deltaMode?
11:.002)*s,a=o[2]*Math.pow(2,i*r);t.scaleTo(a)}:null);r.call(h,{})},destroy:function(){r.on("zoom",null)},pointer:S.pointer}}let tM=e=>({x:e.x,y:e.y,zoom:e.k}),tk=({x:e,y:t,zoom:n})=>R.identity.translate(e,t).scale(n),tN=(e,t)=>e.target.closest(`.${t}`),tL=(e,t)=>2===t&&Array.isArray(e)&&e.includes(2),tA=e=>((e*=2)<=1?e*e*e:(e-=2)*e*e+2)/2,tO=(e,t=0,n=tA,o=()=>{})=>{let r="number"==typeof t&&t>0;return r||o(),r?e.transition().duration(t).ease(n).on("end",o):e},tI=e=>{let t=e.ctrlKey&&eE()?10:1;return-e.deltaY*(1===e.deltaMode?.05:e.deltaMode?1:.002)*t};function tP({domNode:e,minZoom:t,maxZoom:n,translateExtent:o,viewport:r,onPanZoom:i,onPanZoomStart:a,onPanZoomEnd:s,onDraggingChange:l}){let d={isZoomingOrPanning:!1,usedRightMouseButton:!1,prevViewport:{},mouseButton:0,timerId:void 0,panScrollTimeout:void 0,isPanScrolling:!1},c=e.getBoundingClientRect(),h=[[0,0],[c.width,c.height]],f="u">typeof ResizeObserver?new ResizeObserver(e=>{let t=e[0];t&&(h=[[0,0],[t.contentRect.width,t.contentRect.height]])}):null;f?.observe(e);let g=(0,T.default)().extent(()=>h).scaleExtent([t,n]).translateExtent(o),p=(0,_.select)(e).call(g);w({x:r.x,y:r.y,zoom:et(r.zoom,t,n)},[[0,0],[c.width,c.height]],o);let m=p.on("wheel.zoom"),y=p.on("dblclick.zoom");async function v(e,t){return!!p&&new Promise(n=>{g?.interpolate(t?.interpolate==="linear"?$.interpolate:j.interpolateZoom).transform(tO(p,t?.duration,t?.ease,()=>n(!0)),e)})}function b(){g.on("zoom",null)}async function w(e,t,n){let o=tk(e),r=g?.constrain()(o,t,n);return r&&await v(r),r}return g.wheelDelta(tI),{update:function({noWheelClassName:e,noPanClassName:t,onPaneContextMenu:n,userSelectionActive:o,panOnScroll:r,panOnDrag:c,panOnScrollMode:h,panOnScrollSpeed:f,preventScrolling:v,zoomOnPinch:w,zoomOnScroll:x,zoomOnDoubleClick:E,panActivationKeyPressed:_=!1,zoomActivationKeyPressed:C,lib:M,onTransformChange:k,connectionInProgress:N,paneClickDistance:L,selectionOnDrag:A}){o&&!d.isZoomingOrPanning&&b();let O=r&&!C&&!o;g.clickDistance(A?1/0:!ep(L)||L<0?0:L);let I=O?function({zoomPanValues:e,noWheelClassName:t,d3Selection:n,d3Zoom:o,panOnScrollMode:r,panOnScrollSpeed:i,zoomOnPinch:a,onPanZoomStart:s,onPanZoom:l,onPanZoomEnd:d}){return c=>{if(tN(c,t))return c.ctrlKey&&c.preventDefault(),!1;c.preventDefault(),c.stopImmediatePropagation();let h=n.property("__zoom").k||1;if(c.ctrlKey&&a){let e=(0,S.pointer)(c),t=h*Math.pow(2,tI(c));o.scaleTo(n,t,e,c);return}let f=1===c.deltaMode?20:1,g=r===u.Vertical?0:c.deltaX*f,p=r===u.Horizontal?0:c.deltaY*f;!eE()&&c.shiftKey&&r!==u.Vertical&&(g=c.deltaY*f,p=0),o.translateBy(n,-(g/h)*i,-(p/h)*i,{internal:!0});let m=tM(n.property("__zoom"));clearTimeout(e.panScrollTimeout),e.isPanScrolling?l?.(c,m):(e.isPanScrolling=!0,s?.(c,m)),e.panScrollTimeout=setTimeout(()=>{d?.(c,m),e.isPanScrolling=!1},150)}}({zoomPanValues:d,noWheelClassName:e,d3Selection:p,d3Zoom:g,panOnScrollMode:h,panOnScrollSpeed:f,zoomOnPinch:w,onPanZoomStart:a,onPanZoom:i,onPanZoomEnd:s}):function({noWheelClassName:e,preventScrolling:t,d3ZoomHandler:n}){return function(o,r){let i="wheel"===o.type,a=!t&&i&&!o.ctrlKey,s=tN(o,e);if(o.ctrlKey&&i&&s&&o.preventDefault(),a||s)return null;o.preventDefault(),n.call(this,o,r)}}({noWheelClassName:e,preventScrolling:v,d3ZoomHandler:m});p.on("wheel.zoom",I,{passive:!1});let P=function({zoomPanValues:e,onDraggingChange:t,onPanZoomStart:n}){return o=>{if(o.sourceEvent?.internal)return;let r=tM(o.transform);e.mouseButton=o.sourceEvent?.button||0,e.isZoomingOrPanning=!0,e.prevViewport=r,o.sourceEvent?.type==="mousedown"&&t(!0),n&&n?.(o.sourceEvent,r)}}({zoomPanValues:d,onDraggingChange:l,onPanZoomStart:a});g.on("start",P);let T=function({zoomPanValues:e,panOnDrag:t,onPaneContextMenu:n,onTransformChange:o,onPanZoom:r}){return i=>{e.usedRightMouseButton=!!(n&&tL(t,e.mouseButton??0)),i.sourceEvent?.sync||o([i.transform.x,i.transform.y,i.transform.k]),r&&!i.sourceEvent?.internal&&r?.(i.sourceEvent,tM(i.transform))}}({zoomPanValues:d,panOnDrag:c,onPaneContextMenu:!!n,onPanZoom:i,onTransformChange:k});g.on("zoom",T);let R=function({zoomPanValues:e,panOnDrag:t,panOnScroll:n,onDraggingChange:o,onPanZoomEnd:r,onPaneContextMenu:i}){return a=>{if(!a.sourceEvent?.internal&&(e.isZoomingOrPanning=!1,i&&tL(t,e.mouseButton??0)&&!e.usedRightMouseButton&&a.sourceEvent&&i(a.sourceEvent),e.usedRightMouseButton=!1,o(!1),r)){let t=tM(a.transform);e.prevViewport=t,clearTimeout(e.timerId),e.timerId=setTimeout(()=>{r?.(a.sourceEvent,t)},150*!!n)}}}({zoomPanValues:d,panOnDrag:c,panOnScroll:r,onPaneContextMenu:n,onPanZoomEnd:s,onDraggingChange:l});g.on("end",R);let D=function({panActivationKeyPressed:e,zoomActivationKeyPressed:t,zoomOnScroll:n,zoomOnPinch:o,panOnDrag:r,panOnScroll:i,zoomOnDoubleClick:a,userSelectionActive:s,noWheelClassName:l,noPanClassName:d,lib:u,connectionInProgress:c}){return h=>{let f=t||n,g=o&&h.ctrlKey,p="wheel"===h.type;if(1===h.button&&"mousedown"===h.type&&(tN(h,`${u}-flow__node`)||tN(h,`${u}-flow__edge`)||tN(h,`${u}-flow__selection`)||tN(h,`${u}-flow__nodesselection`)))return!0;
1if(!r&&!f&&!i&&!a&&!o||s||c&&!p||tN(h,l)&&p||tN(h,d)&&(!p||i&&p&&!t)||!o&&h.ctrlKey&&p)return!1;if(!o&&"touchstart"===h.type&&h.touches?.length>1)return h.preventDefault(),!1;if(!f&&!i&&!g&&p||!r&&("mousedown"===h.type||"touchstart"===h.type)||Array.isArray(r)&&!r.includes(h.button)&&"mousedown"===h.type)return!1;let m=Array.isArray(r)&&r.includes(h.button)||!h.button||h.button<=1;return(!h.ctrlKey||p||e)&&m}}({panActivationKeyPressed:_,zoomActivationKeyPressed:C,panOnDrag:c,zoomOnScroll:x,panOnScroll:r,zoomOnDoubleClick:E,zoomOnPinch:w,userSelectionActive:o,noPanClassName:t,noWheelClassName:e,lib:M,connectionInProgress:N});g.filter(D),E?p.on("dblclick.zoom",y):p.on("dblclick.zoom",null)},destroy:b,setViewport:async function e(e,t){let n=tk(e);return await v(n,t),n},setViewportConstrained:w,getViewport:function(){let e=p?(0,D.default)(p.node()):{x:0,y:0,k:1};return{x:e.x,y:e.y,zoom:e.k}},scaleTo:async function e(e,t){return!!p&&new Promise(n=>{g?.interpolate(t?.interpolate==="linear"?$.interpolate:j.interpolateZoom).scaleTo(tO(p,t?.duration,t?.ease,()=>n(!0)),e)})},scaleBy:async function e(e,t){return!!p&&new Promise(n=>{g?.interpolate(t?.interpolate==="linear"?$.interpolate:j.interpolateZoom).scaleBy(tO(p,t?.duration,t?.ease,()=>n(!0)),e)})},setScaleExtent:function(e){g?.scaleExtent(e)},setTranslateExtent:function(e){g?.translateExtent(e)},syncViewport:function(e){if(p){let t=tk(e),n=p.property("__zoom");(n.k!==e.zoom||n.x!==e.x||n.y!==e.y)&&g?.transform(p,t,null,{sync:!0})}},setClickDistance:function(e){let t=!ep(e)||e<0?0:e;g?.clickDistance(t)}}}(s=p||(p={})).Line="line",s.Handle="handle";let tT=["top-left","top-right","bottom-left","bottom-right"],tR=["top","right","bottom","left"];function tD(e){let t=e.includes("right")||e.includes("left"),n=e.includes("bottom")||e.includes("top");return{isHorizontal:t,isVertical:n,affectsX:e.includes("left"),affectsY:e.includes("top")}}function tj(e,t){return Math.max(0,t-e)}function t$(e,t){return Math.max(0,e-t)}function tB(e,t,n){return Math.max(0,t-e,e-n)}let tF={width:0,height:0,x:0,y:0},tH={...tF,pointerX:0,pointerY:0,aspectRatio:1};function tz({domNode:e,nodeId:t,getStoreItems:n,onChange:o,onEnd:r}){let i=(0,_.select)(e),a={controlDirection:tD("bottom-right"),boundaries:{minWidth:0,minHeight:0,maxWidth:Number.MAX_VALUE,maxHeight:Number.MAX_VALUE},resizeDirection:void 0,keepAspectRatio:!1};return{update:function({controlPosition:e,boundaries:s,keepAspectRatio:l,resizeDirection:d,onResizeStart:u,onResize:c,onResizeEnd:h,shouldResize:f}){let g,p,m,y,v={...tF},b={...tH};a={boundaries:s,resizeDirection:d,keepAspectRatio:l,controlDirection:tD(e)};let w=null,x=[],E=P().on("start",e=>
1{let{nodeLookup:o,transform:r,snapGrid:i,snapToGrid:a,nodeOrigin:s,paneDomNode:l}=n();if(!(g=o.get(t)))return;w=l?.getBoundingClientRect()??null;let{xSnapped:d,ySnapped:c}=eP(e.sourceEvent,{transform:r,snapGrid:i,snapToGrid:a,containerBounds:w});for(let[e,n]of(b={...v={width:g.measured.width??0,height:g.measured.height??0,x:g.position.x??0,y:g.position.y??0},pointerX:d,pointerY:c,aspectRatio:v.width/v.height},p=void 0,m=e_(g.extent)?g.extent:void 0,g.parentId&&("parent"===g.extent||g.expandParent)&&(p=o.get(g.parentId)),p&&"parent"===g.extent&&(m=[[0,0],[p.measured.width,p.measured.height]]),x=[],y=void 0,o))if(n.parentId===t&&(x.push({id:e,position:{...n.position},extent:n.extent}),"parent"===n.extent||n.expandParent)){let e=function(e,t,n){let o=t.position.x+e.position.x,r=t.position.y+e.position.y,i=e.measured.width??0,a=e.measured.height??0,s=n[0]*i,l=n[1]*a;return[[o-s,r-l],[o+i-s,r+a-l]]}(n,g,n.origin??s);y=y?[[Math.min(e[0][0],y[0][0]),Math.min(e[0][1],y[0][1])],[Math.max(e[1][0],y[1][0]),Math.max(e[1][1],y[1][1])]]:e}u?.(e,{...v})}).on("drag",e=>{let{transform:t,snapGrid:r,snapToGrid:i,nodeOrigin:s}=n(),l=eP(e.sourceEvent,{transform:t,snapGrid:r,snapToGrid:i,containerBounds:w}),d=[];if(!g)return;let{x:u,y:h,width:E,height:_}=v,S={},C=g.origin??s,{width:M,height:k,x:N,y:L}=function(e,t,n,o,r,i,a,s){var l,d,u,c;let{affectsX:h,affectsY:f}=t,{isHorizontal:g,isVertical:p}=t,m=g&&p,{xSnapped:y,ySnapped:v}=n,{minWidth:b,maxWidth:w,minHeight:x,maxHeight:E}=o,{x:_,y:S,width:C,height:M,aspectRatio:k}=e,N=Math.floor(g?y-e.pointerX:0),L=Math.floor(p?v-e.pointerY:0),A=C+(h?-N:N),O=M+(f?-L:L),I=-i[0]*C,P=-i[1]*M,T=tB(A,b,w),R=tB(O,x,E);if(a){let e=0,t=0;h&&N<0?e=tj(_+N+I,a[0][0]):!h&&N>0&&(e=t$(_+A+I,a[1][0])),f&&L<0?t=tj(S+L+P,a[0][1]):!f&&L>0&&(t=t$(S+O+P,a[1][1])),T=Math.max(T,e),R=Math.max(R,t)}if(s){let e=0,t=0;h&&N>0?e=t$(_+N,s[0][0]):!h&&N<0&&(e=tj(_+A,s[1][0])),f&&L>0?t=t$(S+L,s[0][1]):!f&&L<0&&(t=tj(S+O,s[1][1])),T=Math.max(T,e),R=Math.max(R,t)}if(r){if(g){(T=Math.max(T,tB(A/k,x,E)*k),a)&&(T=Math.max(T,(h||f)&&(!h||f||!m)?tj(S+P+(h?N:-N)/k,a[0][1])*k:t$(S+P+A/k,a[1][1])*k));s&&(T=Math.max(T,(h||f)&&(!h||f||!m)?t$(S+(h?N:-N)/k,s[0][1])*k:tj(S+A/k,s[1][1])*k))}if(p){(R=Math.max(R,tB(O*k,b,w)/k),a)&&(R=Math.max(R,(h||f)&&(!f||h||!m)?tj(_+(f?L:-L)*k+I,a[0][0])/k:t$(_+O*k+I,a[1][0])/k));s&&(R=Math.max(R,(h||f)&&(!f||h||!m)?t$(_+(f?L:-L)*k,s[0][0])/k:tj(_+O*k,s[1][0])/k))}}L+=L<0?R:-R,N+=N<0?T:-T,r&&(m?A>O*k?L=((l=h,d=f,l?!d:d)?-N:N)/k:N=((u=h,c=f,u?!c:c)?-L:L)*k:g?(L=N/k,f=h):(N=L*k,h=f));let D=h?_+N:_,j=f?S+L:S;return{width:C+(h?-N:N),height:M+(f?-L:L),x:i[0]*N*(h?-1:1)+D,y:i[1]*L*(f?-1:1)+j}}(b,a.controlDirection,l,a.boundaries,a.keepAspectRatio,C,m,y),A=M!==E,O=k!==_,I=N!==u&&A,P=L!==h&&O;if(!I&&!P&&!A&&!O)return;let T={prevValues:{...v},startX:b.x,startY:b.y,childNodes:x.map(e=>({...e,position:{...e.position}}))};if((I||P||1===C[0]||1===C[1])&&(S.x=I?N:v.x,S.y=P?L:v.y,v.x=S.x,v.y=S.y,x.length>0)){let e=N-u,t=L-h;for(let n of x)n.position={x:n.position.x-e+C[0]*(M-E),y:n.position.y-t+C[1]*(k-_)},d.push(n)}if((A||O)&&(S.width=A&&(!a.resizeDirection||"horizontal"===a.resizeDirection)?M:v.width,S.height=O&&(!a.resizeDirection||"vertical"===a.resizeDirection)?k:v.height,v.width=S.width,v.height=S.height),p&&g.expandParent){let e=C[0]*(S.width??0);S.x&&S.x<e&&(v.x=e,b.x=b.x-(S.x-e));let t=C[1]*(S.height??0);S.y&&S.y<t&&(v.y=t,b.y=b.y-(S.y-t))}let R=function({width:e,prevWidth:t,height:n,prevHeight:o,affectsX:r,affectsY:i}){let a=e-t,s=n-o,l=[a>0?1:a<0?-1:0,s>0?1:s<0?-1:0];return a&&r&&(l[0]=-1*l[0]),s&&i&&(l[1]=-1*l[1]),l}({width:v.width,prevWidth:E,height:v.height,prevHeight:_,affectsX:a.controlDirection.affectsX,affectsY:a.controlDirection.affectsY}),D={...v,direction:R};if(!1===f?.(e,D)){v=T.prevValues,b.x=T.startX,b.y=T.startY,x.forEach((e,t)=>{e.position=T.childNodes[t].position});return}c?.(e,D),o(S,d)}).on("end",e=>{h?.(e,{...v}),r?.({...v})});i.call(E)},destroy:function(){i.on(".drag",null)}}}e.s(["ConnectionLineType",()=>h,"ConnectionMode",()=>d,"MarkerType",()=>f,"PanOnScrollMode",()=>u,"Position",()=>g,"ResizeControlVariant",()=>p,"SelectionMode",()=>c,"XYDrag",()=>tb,"XYHandle",()=>tS,"XYMinimap",()=>tC,"XYPanZoom",()=>tP,"XYResizer",()=>tz,"XY_RESIZER_HANDLE_POSITIONS",()=>tT,"XY_RESIZER_LINE_POSITIONS",()=>tR,"addEdge",()=>eU,"adoptUserNodes",()=>tl,"areConnectionMapsEqual",()=>eA,"areSetsEqual",()=>ek,"calcAutoPan",()=>ei,"calculateNodePosition",()=>J,"createDevWarn",()=>em,"createMarkerIds",()=>
1e7,"defaultAriaLabelConfig",()=>z,"elementSelectionKeys",()=>H,"errorMessages",()=>B,"evaluateAbsolutePosition",()=>eM,"fitViewport",()=>Q,"getBezierEdgeCenter",()=>eH,"getBezierPath",()=>eK,"getBoundsOfRects",()=>ec,"getConnectionStatus",()=>eI,"getDimensions",()=>eT,"getEdgePosition",()=>e3,"getEdgeToolbarTransform",()=>tn,"getElementsToRemove",()=>ee,"getElevatedEdgeZIndex",()=>eY,"getEventPosition",()=>eB,"getHandlePosition",()=>e4,"getHostForElement",()=>eR,"getInternalNodesBounds",()=>Z,"getMarkerId",()=>e6,"getNodeDimensions",()=>eS,"getNodeToolbarTransform",()=>e9,"getNodesBounds",()=>U,"getNodesInside",()=>q,"getOverlappingArea",()=>ef,"getSmoothStepPath",()=>e1,"getStraightPath",()=>eq,"getViewportForBounds",()=>ex,"handleConnectionChange",()=>eO,"handleExpandParent",()=>tc,"infiniteExtent",()=>F,"initialConnection",()=>V,"isEdgeBase",()=>X,"isEdgeVisible",()=>eG,"isInputDOMNode",()=>ej,"isMacOs",()=>eE,"isMouseEvent",()=>e$,"isNodeBase",()=>Y,"isNumeric",()=>ep,"isRectObject",()=>eg,"mergeAriaLabelConfig",()=>eL,"nodeHasDimensions",()=>eC,"nodeToRect",()=>ed,"panBy",()=>tf,"pointToRendererPoint",()=>ev,"reconnectEdge",()=>eZ,"rendererPointToPoint",()=>eb,"shallowNodeData",()=>tm,"snapPosition",()=>ey,"updateAbsolutePositions",()=>ta,"updateConnectionLookup",()=>tp,"updateNodeInternals",()=>th,"withResolvers",()=>eN],30590);var tV=e.i(430224);let tK={get url(){return`file://${e.P("node_modules/@xyflow/react/node_modules/zustand/esm/vanilla.mjs")}`}},tX=e=>{let t,n=new Set,o=(e,o)=>{let r="function"==typeof e?e(t):e;if(!Object.is(r,t)){let e=t;t=(null!=o?o:"object"!=typeof r||null===r)?r:Object.assign({},t,r),n.forEach(n=>n(t,e))}},r=()=>t,i={setState:o,getState:r,getInitialState:()=>a,subscribe:e=>(n.add(e),()=>n.delete(e)),destroy:()=>{(tK.env?tK.env.MODE:void 0)!=="production"&&console.warn("[DEPRECATED] The `destroy` method will be unsupported in a future version. Instead use unsubscribe function returned by subscribe. Everything will be garbage-collected if store is garbage-collected."),n.clear()}},a=t=e(o,r,i);return i},{useDebugValue:tY}=w.default,{useSyncExternalStoreWithSelector:tG}=tV.default,tW=e=>e;function tU(e,t=tW,n){let o=tG(e.subscribe,e.getState,e.getServerState||e.getInitialState,t,n);return tY(o),o}let tZ=(e,t)=>{let n=e?tX(e):tX,o=(e,o=t)=>tU(n,e,o);return Object.assign(o,n),o};function tq(e,t){if(Object.is(e,t))return!0;if("object"!=typeof e||null===e||"object"!=typeof t||null===t)return!1;if(e instanceof Map&&t instanceof Map){if(e.size!==t.size)return!1;for(let[n,o]of e)if(!Object.is(o,t.get(n)))return!1;return!0}if(e instanceof Set&&t instanceof Set){if(e.size!==t.size)return!1;for(let n of e)if(!t.has(n))return!1;return!0}let n=Object.keys(e);if(n.length!==Object.keys(t).length)return!1;for(let o of n)if(!Object.prototype.hasOwnProperty.call(t,o)||!Object.is(e[o],t[o]))return!1;return!0}var tQ=e.i(174080);let tJ=(0,w.createContext)(null),t0=tJ.Provider,t1=B.error001("react");function t2(e,t){let n=(0,w.useContext)(tJ);if(null===n)throw Error(t1);return tU(n,e,t)}function t3(){let e=(0,w.useContext)(tJ);if(null===e)throw Error(t1);return(0,w.useMemo)(()=>({getState:e.getState,setState:e.setState,subscribe:e.subscribe}),[e])}let t5={display:"none"},t4={position:"absolute",width:1,height:1,margin:-1,border:0,padding:0,overflow:"hidden",clip:"rect(0px, 0px, 0px, 0px)",clipPath:"inset(100%)"},t8="react-flow__node-desc",t6="react-flow__edge-desc",t7=e=>e.ariaLiveMessage,t9=e=>e.ariaLabelConfig;function ne({rfId:e}){let t=t2(t7);return(0,b.jsx)("div",{id:`react-flow__aria-live-${e}`,"aria-live":"assertive","aria-atomic":"true",style:t4,children:t})}function nt({rfId:e,disableKeyboardA11y:t}){let n=t2(t9);return(0,b.jsxs)(b.Fragment,{children:[(0,b.jsx)("div",{id:`${t8}-${e}`,style:t5,children:t?n["node.a11yDescription.default"]:n["node.a11yDescription.keyboardDisabled"]}),(0,b.jsx)("div",{id:`${t6}-${e}`,style:t5,children:n["edge.a11yDescription.default"]}),!t&&(0,b.jsx)(ne,{rfId:e})]})}let nn=(0,w.forwardRef)(({position:e="top-left",children:t,className:n,style:o,...r},i)=>{let a=`${e}`.split("-");return(0,b.jsx)("div",{className:x(["react-flow__panel",n,...a]),style:o,ref:i,...r,children:t})});nn.displayName="Panel";let no="https://reactflow.dev?utm_source=attribution";function nr({proOptions:e,position:t="bottom-right"}){return((0,w.useEffect)(()=>{},[]),e?.hideAttribution)?null:(0,b.jsx)(nn,{position:t,className:"react-flow__attribution","data-message":`Please only hide this attribution when you are subscribed to React Flow Pro: ${no}`,children:(0,b.jsx)("a",{href:no,target:"_blank",rel:"noopener noreferrer","aria-label":"React Flow attribution",children:"React Flow"})})}let ni=e=>{let t=[],n=[];for(let[,n]of e.nodeLookup)n.selected&&t.push(n.internals.userNode);for(let[,t]of e.edgeLookup)t.selected&&n.push(t);return{selectedNodes:t,selectedEdges:n}},na=e=>e.id;function ns(e,t){return tq(e.selectedNodes.map(na),t.selectedNodes.map(na))&&tq(e.selectedEdges.map(na),t.selectedEdges.map(na))}function nl({onSelectionChange:e}){let t=t3(),{selectedNodes:n,selectedEdges:o}=t2(ni,ns);return(0,w.useEffect)(()=>{let r={nodes:n,edges:o};
1e?.(r),t.getState().onSelectionChangeHandlers.forEach(e=>e(r))},[n,o,e]),null}let nd=e=>!!e.onSelectionChangeHandlers;function nu({onSelectionChange:e}){let t=t2(nd);return e||t?(0,b.jsx)(nl,{onSelectionChange:e}):null}let nc=[0,0],nh={x:0,y:0,zoom:1},nf=["nodes","edges","defaultNodes","defaultEdges","onConnect","onConnectStart","onConnectEnd","onClickConnectStart","onClickConnectEnd","nodesDraggable","autoPanOnNodeFocus","nodesConnectable","nodesFocusable","edgesFocusable","edgesReconnectable","elevateNodesOnSelect","elevateEdgesOnSelect","minZoom","maxZoom","nodeExtent","onNodesChange","onEdgesChange","elementsSelectable","connectionMode","snapGrid","snapToGrid","translateExtent","connectOnClick","defaultEdgeOptions","fitView","fitViewOptions","onNodesDelete","onEdgesDelete","onDelete","onNodeDrag","onNodeDragStart","onNodeDragStop","onSelectionDrag","onSelectionDragStart","onSelectionDragStop","onMoveStart","onMove","onMoveEnd","noPanClassName","nodeOrigin","autoPanOnConnect","autoPanOnNodeDrag","onError","connectionRadius","isValidConnection","selectNodesOnDrag","nodeDragThreshold","connectionDragThreshold","onBeforeDelete","debug","autoPanSpeed","ariaLabelConfig","zIndexMode","rfId"],ng=e=>({setNodes:e.setNodes,setEdges:e.setEdges,setMinZoom:e.setMinZoom,setMaxZoom:e.setMaxZoom,setTranslateExtent:e.setTranslateExtent,setNodeExtent:e.setNodeExtent,reset:e.reset,setDefaultNodesAndEdges:e.setDefaultNodesAndEdges}),np={translateExtent:F,nodeOrigin:nc,minZoom:.5,maxZoom:2,elementsSelectable:!0,noPanClassName:"nopan",rfId:"1"};function nm(e){let{setNodes:t,setEdges:n,setMinZoom:o,setMaxZoom:r,setTranslateExtent:i,setNodeExtent:a,reset:s,setDefaultNodesAndEdges:l}=t2(ng,tq),d=t3();(0,w.useEffect)(()=>(l(e.defaultNodes,e.defaultEdges),()=>{u.current=np,s()}),[]);let u=(0,w.useRef)(np);return(0,w.useEffect)(()=>{for(let s of nf){let l=e[s];l!==u.current[s]&&void 0!==e[s]&&("nodes"===s?t(l):"edges"===s?n(l):"minZoom"===s?o(l):"maxZoom"===s?r(l):"translateExtent"===s?i(l):"nodeExtent"===s?a(l):"ariaLabelConfig"===s?d.setState({ariaLabelConfig:eL(l)}):"fitView"===s?d.setState({fitViewQueued:l}):"fitViewOptions"===s?d.setState({fitViewOptions:l}):d.setState({[s]:l}))}u.current=e},nf.map(t=>e[t])),null}function ny(){return"u"<typeof window||!window.matchMedia?null:window.matchMedia("(prefers-color-scheme: dark)")}let nv="u">typeof document?document:null;function nb(e=null,t={target:nv,actInsideInputWithModifier:!0}){let[n,o]=(0,w.useState)(!1),r=(0,w.useRef)(!1),i=(0,w.useRef)(new Set([])),[a,s]=(0,w.useMemo)(()=>{if(null!==e){let t=(Array.isArray(e)?e:[e]).filter(e=>"string"==typeof e).map(e=>e.replace(/\+/g,"\n").replace("\n\n","\n+").split("\n")),n=t.reduce((e,t)=>e.concat(...t),[]);return[t,n]}return[[],[]]},[e]);return(0,w.useEffect)(()=>{let n=t?.target??nv,l=t?.actInsideInputWithModifier??!0;if(null!==e){let e=e=>{if(r.current=e.ctrlKey||e.metaKey||e.shiftKey||e.altKey,(!r.current||r.current&&!l)&&ej(e))return!1;let n=nx(e.code,s);if(i.current.add(e[n]),nw(a,i.current,!1)){let n=e.composedPath?.()?.[0]||e.target,i=n?.nodeName==="BUTTON"||n?.nodeName==="A";!1!==t.preventDefault&&(r.current||!i)&&e.preventDefault(),o(!0)}},d=e=>{let t=nx(e.code,s);nw(a,i.current,!0)?(o(!1),i.current.clear()):i.current.delete(e[t]),"Meta"===e.key&&i.current.clear(),r.current=!1},u=()=>{i.current.clear(),o(!1)};return n?.addEventListener("keydown",e),n?.addEventListener("keyup",d),window.addEventListener("blur",u),window.addEventListener("contextmenu",u),()=>{n?.removeEventListener("keydown",e),n?.removeEventListener("keyup",d),window.removeEventListener("blur",u),window.removeEventListener("contextmenu",u)}}},[e,o]),n}function nw(e,t,n){return e.filter(e=>n||e.length===t.size).some(e=>e.every(e=>t.has(e)))}function nx(e,t){return t.includes(e)?"code":"key"}function nE(e,t){let n=[],o=new Map,r=[];for(let t of e)if("add"===t.type){r.push(t);continue}else if("remove"===t.type||"replace"===t.type)o.set(t.id,[t]);else{let e=o.get(t.id);e?e.push(t):o.set(t.id,[t])}for(let e of t){let t=o.get(e.id);if(!t){n.push(e);continue}if("remove"===t[0].type)continue;if("replace"===t[0].type){n.push({...t[0].item});continue}let r={...e};for(let e of t){var i=e,a=r;switch(i.type){case"select":a.selected=i.selected;break;case"position":void 0!==i.position&&(a.position=i.position),void 0!==i.dragging&&(a.dragging=i.dragging);break;case"dimensions":void 0!==i.dimensions&&(a.measured={...i.dimensions},i.setAttributes&&((!0===i.setAttributes||"width"===i.setAttributes)&&(a.width=i.dimensions.width),(!0===i.setAttributes||"height"===i.setAttributes)&&(a.height=i.dimensions.height))),"boolean"==typeof i.resizing&&(
1a.resizing=i.resizing)}}n.push(r)}return r.length&&r.forEach(e=>{void 0!==e.index?n.splice(e.index,0,{...e.item}):n.push({...e.item})}),n}function n_(e,t){return nE(e,t)}function nS(e,t){return nE(e,t)}function nC(e,t){return{id:e,type:"select",selected:t}}function nM(e,t=new Set,n=!1){let o=[];for(let[r,i]of e){let e=t.has(r);(void 0!==i.selected||e)&&i.selected!==e&&(n&&(i.selected=e),o.push(nC(i.id,e)))}return o}function nk({items:e=[],lookup:t}){let n=[],o=new Map(e.map(e=>[e.id,e]));for(let[o,r]of e.entries()){let e=t.get(r.id),i=e?.internals?.userNode??e;void 0!==i&&i!==r&&n.push({id:r.id,item:r,type:"replace"}),void 0===i&&n.push({item:r,type:"add",index:o})}for(let[e]of t)void 0===o.get(e)&&n.push({id:e,type:"remove"});return n}function nN(e){return{id:e.id,type:"remove"}}let nL=em("React Flow","https://reactflow.dev/");function nA(e,t,n={}){return eU(e,t,{...n,onError:n.onError??nL})}function nO(e){return(0,w.forwardRef)(e)}let nI="u">typeof window?w.useLayoutEffect:w.useEffect;function nP(e){let[t,n]=(0,w.useState)(BigInt(0)),[o]=(0,w.useState)(()=>{var e;let t;return e=()=>n(e=>e+BigInt(1)),t=[],{get:()=>t,reset:()=>{t=[]},push:n=>{t.push(n),e()}}});return nI(()=>
1{let t=o.get();t.length&&(e(t),o.reset())},[t]),o}let nT=(0,w.createContext)(null);function nR({children:e}){let t=t3(),n=nP((0,w.useCallback)(e=>{let{nodes:n=[],setNodes:o,hasDefaultNodes:r,onNodesChange:i,nodeLookup:a,fitViewQueued:s,onNodesChangeMiddlewareMap:l}=t.getState(),d=n;for(let t of e)d="function"==typeof t?t(d):t;let u=nk({items:d,lookup:a});for(let e of l.values())u=e(u);r&&o(d),u.length>0?i?.(u):s&&window.requestAnimationFrame(()=>{let{fitViewQueued:e,nodes:n,setNodes:o}=t.getState();e&&o(n)})},[])),o=nP((0,w.useCallback)(e=>{let{edges:n=[],setEdges:o,hasDefaultEdges:r,onEdgesChange:i,edgeLookup:a}=t.getState(),s=n;for(let t of e)s="function"==typeof t?t(s):t;r?o(s):i&&i(nk({items:s,lookup:a}))},[])),r=(0,w.useMemo)(()=>({nodeQueue:n,edgeQueue:o}),[]);return(0,b.jsx)(nT.Provider,{value:r,children:e})}let nD=e=>!!e.panZoom;function nj(){let e,t=(e=t3(),(0,w.useMemo)(()=>({zoomIn:async t=>{let{panZoom:n}=e.getState();return!!n&&n.scaleBy(1.2,t)},zoomOut:async t=>{let{panZoom:n}=e.getState();return!!n&&n.scaleBy(1/1.2,t)},zoomTo:async(t,n)=>{let{panZoom:o}=e.getState();return!!o&&o.scaleTo(t,n)},getZoom:()=>e.getState().transform[2],setViewport:async(t,n)=>{let{transform:[o,r,i],panZoom:a}=e.getState();return!!a&&(await a.setViewport({x:t.x??o,y:t.y??r,zoom:t.zoom??i},n),!0)},getViewport:()=>{let[t,n,o]=e.getState().transform;return{x:t,y:n,zoom:o}},setCenter:async(t,n,o)=>e.getState().setCenter(t,n,o),fitBounds:async(t,n)=>{let{width:o,height:r,minZoom:i,maxZoom:a,panZoom:s}=e.getState(),l=ex(t,o,r,i,a,n?.padding??.1);return!!s&&(await s.setViewport(l,{duration:n?.duration,ease:n?.ease,interpolate:n?.interpolate}),!0)},screenToFlowPosition:(t,n={})=>{let{transform:o,snapGrid:r,snapToGrid:i,domNode:a}=e.getState();if(!a)return t;let{x:s,y:l}=a.getBoundingClientRect(),d={x:t.x-s,y:t.y-l},u=n.snapGrid??r;return ev(d,o,n.snapToGrid??i,u)},flowToScreenPosition:t=>{let{transform:n,domNode:o}=e.getState();if(!o)return t;let{x:r,y:i}=o.getBoundingClientRect(),a=eb(t,n);return{x:a.x+r,y:a.y+i}}}),[])),n=t3(),o=function(){let e=(0,w.useContext)(nT);if(!e)throw Error("useBatchContext must be used within a BatchProvider");return e}(),r=t2(nD),i=(0,w.useMemo)(()=>{let e=e=>n.getState().nodeLookup.get(e),t=e=>{o.nodeQueue.push(e)}
1,r=e=>{o.edgeQueue.push(e)},i=e=>{let{nodeLookup:t,nodeOrigin:o}=n.getState(),r=Y(e)?e:t.get(e.id),i=r.parentId?eM(r.position,r.measured,r.parentId,t,o):r.position;return ed({...r,position:i,width:r.measured?.width??r.width,height:r.measured?.height??r.height})},a=(e,n,o={replace:!1})=>{t(t=>t.map(t=>{if(t.id===e){let e="function"==typeof n?n(t):n;return o.replace&&Y(e)?e:{...t,...e}}return t}))},s=(e,t,n={replace:!1})=>{r(o=>o.map(o=>{if(o.id===e){let e="function"==typeof t?t(o):t;return n.replace&&X(e)?e:{...o,...e}}return o}))};return{getNodes:()=>n.getState().nodes.map(e=>({...e})),getNode:t=>e(t)?.internals.userNode,getInternalNode:e,getEdges:()=>{let{edges:e=[]}=n.getState();return e.map(e=>({...e}))},getEdge:e=>n.getState().edgeLookup.get(e),setNodes:t,setEdges:r,addNodes:e=>{let t=Array.isArray(e)?e:[e];o.nodeQueue.push(e=>[...e,...t])},addEdges:e=>{let t=Array.isArray(e)?e:[e];o.edgeQueue.push(e=>[...e,...t])},toObject:()=>{let{nodes:e=[],edges:t=[],transform:o}=n.getState(),[r,i,a]=o;return{nodes:e.map(e=>({...e})),edges:t.map(e=>({...e})),viewport:{x:r,y:i,zoom:a}}},deleteElements:async({nodes:e=[],edges:t=[]})=>{let{nodes:o,edges:r,onNodesDelete:i,onEdgesDelete:a,triggerNodeChanges:s,triggerEdgeChanges:l,onDelete:d,onBeforeDelete:u}=n.getState(),{nodes:c,edges:h}=await ee({nodesToRemove:e,edgesToRemove:t,nodes:o,edges:r,onBeforeDelete:u}),f=h.length>0,g=c.length>0;if(f){let e=h.map(nN);a?.(h),l(e)}if(g){let e=c.map(nN);i?.(c),s(e)}return(g||f)&&d?.({nodes:c,edges:h}),{deletedNodes:c,deletedEdges:h}},getIntersectingNodes:(e,t=!0,o)=>{let r=eg(e),a=r?e:i(e),s=void 0!==o;return a?(o||n.getState().nodes).filter(o=>{let i=n.getState().nodeLookup.get(o.id);if(i&&!r&&(o.id===e.id||!i.internals.positionAbsolute))return!1;let l=ed(s?o:i),d=ef(l,a);return t&&d>0||d>=l.width*l.height||d>=a.width*a.height}):[]},isNodeIntersecting:(e,t,n=!0)=>{let o=eg(e)?e:i(e);if(!o)return!1;let r=ef(o,t);return n&&r>0||r>=t.width*t.height||r>=o.width*o.height},updateNode:a,updateNodeData:(e,t,n={replace:!1})=>{a(e,e=>{let o="function"==typeof t?t(e):t;return n.replace?{...e,data:o}:{...e,data:{...e.data,...o}}},n)},updateEdge:s,updateEdgeData:(e,t,n={replace:!1})=>{s(e,e=>{let o="function"==typeof t?t(e):t;return n.replace?{...e,data:o}:{...e,data:{...e.data,...o}}},n)},getNodesBounds:e=>{let{nodeLookup:t,nodeOrigin:o}=n.getState();return U(e,{nodeLookup:t,nodeOrigin:o})},getHandleConnections:({type:e,id:t,nodeId:o})=>Array.from(n.getState().connectionLookup.get(`${o}-${e}${t?`-${t}`:""}`)?.values()??[]),getNodeConnections:({type:e,handleId:t,nodeId:o})=>Array.from(n.getState().connectionLookup.get(`${o}${e?t?`-${e}-${t}`:`-${e}`:""}`)?.values()??[]),fitView:async e=>{let t=n.getState().fitViewResolver??eN();return n.setState({fitViewQueued:!0,fitViewOptions:e,fitViewResolver:t}),o.nodeQueue.push(e=>[...e]),t.promise}}},[]);return(0,w.useMemo)(()=>({...i,...t,viewportInitialized:r}),[r])}let n$=e=>e.selected,nB="u">typeof window?window:void 0,nF={position:"absolute",width:"100%",height:"100%",top:0,left:0},nH=e=>({userSelectionActive:e.userSelectionActive,lib:e.lib,connectionInProgress:e.connection.inProgress});function nz({onPaneContextMenu:e,zoomOnScroll:t=!0,zoomOnPinch:n=!0,panOnScroll:o=!1,panActivationKeyPressed:r,panOnScrollSpeed:i=.5,panOnScrollMode:a=u.Free,zoomOnDoubleClick:s=!0,panOnDrag:l=!0,defaultViewport:d,translateExtent:c,minZoom:h,maxZoom:f,zoomActivationKeyCode:g,preventScrolling:p=!0,children:m,noWheelClassName:y,noPanClassName:v,onViewportChange:x,isControlledViewport:E,paneClickDistance:_,selectionOnDrag:S}){let C,M=t3(),k=(0,w.useRef)(null),{userSelectionActive:N,lib:L,connectionInProgress:A}=t2(nH,tq),O=nb(g),I=(0,w.useRef)();C=t3(),(0,w.useEffect)(()=>{let e=()=>{if(!k.current||!(k.current.checkVisibility?.()??!0))return!1;let e=eT(k.current);(0===e.height||0===e.width)&&C.getState().onError?.("004",B.error004()),C.setState({width:e.width||500,height:e.height||500})};if(k.current){e(),window.addEventListener("resize",e);let t=new ResizeObserver(()=>e());return t.observe(k.current),()=>{window.removeEventListener("resize",e),t&&k.current&&t.unobserve(k.current)}}},[]);let P=(0,w.useCallback)(e=>{x?.({x:e[0],y:e[1],zoom:e[2]}),E||M.setState({transform:e})},[x,E]);return(0,w.useEffect)(()=>
1{if(k.current){I.current=tP({domNode:k.current,minZoom:h,maxZoom:f,translateExtent:c,viewport:d,onDraggingChange:e=>M.setState(t=>t.paneDragging===e?t:{paneDragging:e}),onPanZoomStart:(e,t)=>{let{onViewportChangeStart:n,onMoveStart:o}=M.getState();o?.(e,t),n?.(t)},onPanZoom:(e,t)=>{let{onViewportChange:n,onMove:o}=M.getState();o?.(e,t),n?.(t)},onPanZoomEnd:(e,t)=>{let{onViewportChangeEnd:n,onMoveEnd:o}=M.getState();o?.(e,t),n?.(t)}});let{x:e,y:t,zoom:n}=I.current.getViewport();return M.setState({panZoom:I.current,transform:[e,t,n],domNode:k.current.closest(".react-flow")}),()=>{I.current?.destroy()}}},[]),(0,w.useEffect)(()=>{I.current?.update({onPaneContextMenu:e,zoomOnScroll:t,zoomOnPinch:n,panOnScroll:o,panActivationKeyPressed:r,panOnScrollSpeed:i,panOnScrollMode:a,zoomOnDoubleClick:s,panOnDrag:l,zoomActivationKeyPressed:O,preventScrolling:p,noPanClassName:v,userSelectionActive:N,noWheelClassName:y,lib:L,onTransformChange:P,connectionInProgress:A,selectionOnDrag:S,paneClickDistance:_})},[e,t,n,o,r,i,a,s,l,O,p,v,N,y,L,P,A,S,_]),(0,b.jsx)("div",{className:"react-flow__renderer",ref:k,style:nF,children:m})}let nV=e=>({userSelectionActive:e.userSelectionActive,userSelectionRect:e.userSelectionRect});function nK(){let{userSelectionActive:e,userSelectionRect:t}=t2(nV,tq);return e&&t?(0,b.jsx)("div",{className:"react-flow__selection react-flow__container",style:{width:t.width,height:t.height,transform:`translate(${t.x}px, ${t.y}px)`}}):null}let nX=(e,t)=>n=>{n.target===t.current&&e?.(n)},nY=e=>({userSelectionActive:e.userSelectionActive,elementsSelectable:e.elementsSelectable,dragging:e.paneDragging,panBy:e.panBy,autoPanSpeed:e.autoPanSpeed});function nG({isSelecting:e,selectionKeyPressed:t,selectionMode:n=c.Full,panOnDrag:o,autoPanOnSelection:r,paneClickDistance:i,selectionOnDrag:a,onSelectionStart:s,onSelectionEnd:l,onPaneClick:d,onPaneContextMenu:u,onPaneScroll:h,onPaneMouseEnter:f,onPaneMouseMove:g,onPaneMouseLeave:p,children:m}){let y=(0,w.useRef)(0),v=t3(),{userSelectionActive:E,elementsSelectable:_,dragging:S,panBy:C,autoPanSpeed:M}=t2(nY,tq),k=_&&(e||E),N=(0,w.useRef)(null),L=(0,w.useRef)(),A=(0,w.useRef)(new Set),O=(0,w.useRef)(new Set),I=(0,w.useRef)(!1),P=(0,w.useRef)(!1),T=(0,w.useRef)({x:0,y:0}),R=(0,w.useRef)(!1),D=e=>{if(P.current||I.current||v.getState().connection.inProgress){P.current=!1,I.current=!1;return}d?.(e),v.getState().resetSelectedElements(),v.setState({nodesSelectionActive:!1})};function j(e,t){let{userSelectionRect:o}=v.getState();if(!o)return;let{transform:r,nodeLookup:i,edgeLookup:a,connectionLookup:s,triggerNodeChanges:l,triggerEdgeChanges:d,defaultEdgeOptions:u}=v.getState(),h={x:o.startX,y:o.startY},{x:f,y:g}=eb(h,r),p={startX:h.x,startY:h.y,x:e<f?e:f,y:t<g?t:g,width:Math.abs(e-f),height:Math.abs(t-g)},m=A.current,y=O.current;A.current=new Set(q(i,p,r,n===c.Partial,!0).map(e=>e.id)),O.current=new Set;let b=u?.selectable??!0;for(let e of A.current){let t=s.get(e);if(t)for(let{edgeId:e}of t.values()){let t=a.get(e);t&&(t.selectable??b)&&O.current.add(e)}}ek(m,A.current)||l(nM(i,A.current,!0)),ek(y,O.current)||d(nM(a,O.current)),v.setState({userSelectionRect:p,userSelectionActive:!0,nodesSelectionActive:!1})}let $=()=>{cancelAnimationFrame(y.current),y.current=0,R.current=!1};(0,w.useEffect)(()=>()=>$(),[]);let B=!0===o||Array.isArray(o)&&o.includes(0);return(0,b.jsxs)("div",{className:x(["react-flow__pane",{draggable:B,dragging:S,selection:e}]),onClick:k?void 0:nX(D,N),onContextMenu:nX(e=>{Array.isArray(o)&&o?.includes(2)?e.preventDefault():u?.(e)},N),onWheel:nX(h?e=>h(e):void 0,N),onPointerEnter:k?void 0:f,onPointerMove:k?e=>{let{userSelectionRect:n,transform:o,resetSelectedElements:a}=v.getState();if(!L.current||!n)return;let{x:l,y:d}=eB(e.nativeEvent,L.current);T.current={x:l,y:d};let u=eb({x:n.startX,y:n.startY},o);if(!P.current){if(Math.hypot(l-u.x,d-u.y)<=(t?0:i))return;a(),s?.(e)}P.current=!0,R.current||(!function e(){if(!r||!L.current)return;let[t,n]=ei(T.current,L.current,M);C({x:t,y:n}).then(t=>{if(!P.current||!t){y.current=requestAnimationFrame(e);return}let{x:n,y:o}=T.current;j(n,o),y.current=requestAnimationFrame(e)})}(),R.current=!0),j(l,d)}:g,onPointerUp:e=>{if(!k){e.target===N.current&&v.getState().connection.inProgress&&(I.current=!0);return}0===e.button&&(e.target?.releasePointerCapture?.(e.pointerId),!E&&e.target===N.current&&v.getState().userSelectionRect&&D?.(e),v.setState({userSelectionActive:!1,userSelectionRect:null}),P.current&&(l?.(e),v.setState({nodesSelectionActive:A.current.size>0})),$())},onPointerCancel:k?e=>{e.target?.releasePointerCapture?.(e.pointerId),$()}:void 0,onPointerDownCapture:k?n=>{if("touch"===n.pointerType&&!1!==o&&!t)return;
1let{domNode:r,transform:i}=v.getState();if(L.current=r?.getBoundingClientRect(),!L.current)return;let s=n.target===N.current;if(!s&&n.target.closest(".nokey")||!e||!(a&&s||t)||0!==n.button||!n.isPrimary)return;n.target?.setPointerCapture?.(n.pointerId),P.current=!1;let{x:l,y:d}=eB(n.nativeEvent,L.current),u=ev({x:l,y:d},i);v.setState({userSelectionRect:{width:0,height:0,startX:u.x,startY:u.y,x:l,y:d}}),s||(n.stopPropagation(),n.preventDefault())}:void 0,onClickCapture:k?e=>{P.current&&(e.stopPropagation(),P.current=!1)}:void 0,onPointerLeave:p,ref:N,style:nF,children:[m,(0,b.jsx)(nK,{})]})}function nW({id:e,store:t,unselect:n=!1,nodeRef:o}){let{addSelectedNodes:r,unselectNodesAndEdges:i,multiSelectionActive:a,nodeLookup:s,onError:l}=t.getState(),d=s.get(e);d?(t.setState({nodesSelectionActive:!1}),d.selected?(n||d.selected&&a)&&(i({nodes:[d],edges:[]}),requestAnimationFrame(()=>o?.current?.blur())):r([e])):l?.("012",B.error012(e))}function nU({nodeRef:e,disabled:t=!1,noDragClassName:n,handleSelector:o,nodeId:r,isSelectable:i,nodeClickDistance:a}){let s=t3(),[l,d]=(0,w.useState)(!1),u=(0,w.useRef)();return(0,w.useEffect)(()=>{if(!t)return u.current=tb({getStoreItems:()=>s.getState(),onNodeMouseDown:t=>{nW({id:t,store:s,nodeRef:e})},onDragStart:()=>{d(!0)},onDragStop:()=>{d(!1)}}),()=>{u.current?.destroy(),u.current=void 0}},[t,s,e]),(0,w.useEffect)(()=>{!t&&e.current&&u.current&&u.current.update({noDragClassName:n,handleSelector:o,domNode:e.current,isSelectable:i,nodeId:r,nodeClickDistance:a})},[n,o,t,i,e,r,a]),l}function nZ(){let e=t3();return(0,w.useCallback)(t=>{let{nodeExtent:n,snapToGrid:o,snapGrid:r,nodesDraggable:i,onError:a,updateNodePositions:s,nodeLookup:l,nodeOrigin:d}=e.getState(),u=new Map,c=e=>e.selected&&(e.draggable||i&&void 0===e.draggable),h=o?r[0]:5,f=o?r[1]:5,g=t.direction.x*h*t.factor,p=t.direction.y*f*t.factor;for(let[,e]of l){if(!c(e))continue;let t={x:e.internals.positionAbsolute.x+g,y:e.internals.positionAbsolute.y+p};o&&(t=ey(t,r));let{position:i,positionAbsolute:s}=J({nodeId:e.id,nextPosition:t,nodeLookup:l,nodeExtent:n,nodeOrigin:d,onError:a});e.position=i,e.internals.positionAbsolute=s,u.set(e.id,e)}s(u)},[])}let nq=(0,w.createContext)(null),nQ=nq.Provider;nq.Consumer;let nJ=()=>(0,w.useContext)(nq),n0=e=>({connectOnClick:e.connectOnClick,noPanClassName:e.noPanClassName,rfId:e.rfId}),n1=(0,w.createContext)(null);function n2({children:e}){let t=t2(n0,tq);return(0,b.jsx)(n1.Provider,{value:t,children:e})}let n3={connectingFrom:!1,connectingTo:!1,clickConnecting:!1,isPossibleEndHandle:!0,connectionInProcess:!1,clickConnectionInProcess:!1,valid:!1},n5=(0,w.memo)(nO(function({type:e="source",position:t=g.Top,isValidConnection:n,isConnectable:o=!0,isConnectableStart:r=!0,isConnectableEnd:i=!0,id:a,onConnect:s,children:l,className:u,onMouseDown:c,onTouchStart:h,...f},p){let m=a||null,y="target"===e,v=t3(),E=nJ(),{connectOnClick:_,noPanClassName:S,rfId:C}=function(){let e=(0,w.useContext)(n1);if(!e)throw Error("useHandleConfig must be used within a HandleConfigProvider");return e}(),{connectingFrom:M,connectingTo:k,clickConnecting:N,isPossibleEndHandle:L,connectionInProcess:A,clickConnectionInProcess:O,valid:I}=t2(t=>{let{connectionClickStartHandle:n,connectionMode:o,connection:r}=t,{fromHandle:i,toHandle:a,isValid:s}=r;if(!i&&!n)return n3;let l=a?.nodeId===E&&a?.id===m&&a?.type===e;return{connectingFrom:i?.nodeId===E&&i?.id===m&&i?.type===e,connectingTo:l,clickConnecting:n?.nodeId===E&&n?.id===m&&n?.type===e,isPossibleEndHandle:o===d.Strict?i?.type!==e:E!==i?.nodeId||m!==i?.id,connectionInProcess:!!i,clickConnectionInProcess:!!n,valid:l&&s}},tq);E||v.getState().onError?.("010",B.error010());let P=e=>{let{defaultEdgeOptions:t,onConnect:n,hasDefaultEdges:o}=v.getState(),r={...t,...e};if(o){let{edges:e,setEdges:t,onError:n}=v.getState();t(nA(r,e,{onError:n}))}n?.(r),s?.(r)},T=e=>{if(!E)return;let t=e$(e.nativeEvent);if(r&&(t&&0===e.button||!t)){let t=v.getState();tS.onPointerDown(e.nativeEvent,{handleDomNode:e.currentTarget,autoPanOnConnect:t.autoPanOnConnect,connectionMode:t.connectionMode,connectionRadius:t.connectionRadius,domNo
1de:t.domNode,nodeLookup:t.nodeLookup,lib:t.lib,isTarget:y,handleId:m,nodeId:E,flowId:t.rfId,panBy:t.panBy,cancelConnection:t.cancelConnection,onConnectStart:t.onConnectStart,onConnectEnd:(...e)=>v.getState().onConnectEnd?.(...e),updateConnection:t.updateConnection,onConnect:P,isValidConnection:n||((...e)=>v.getState().isValidConnection?.(...e)??!0),getTransform:()=>v.getState().transform,getFromHandle:()=>v.getState().connection.fromHandle,autoPanSpeed:t.autoPanSpeed,dragThreshold:t.connectionDragThreshold})}t?c?.(e):h?.(e)};return(0,b.jsx)("div",{"data-handleid":m,"data-nodeid":E,"data-handlepos":t,"data-id":`${C}-${E}-${m}-${e}`,className:x(["react-flow__handle",`react-flow__handle-${t}`,"nodrag",S,u,{source:!y,target:y,connectable:o,connectablestart:r,connectableend:i,clickconnecting:N,connectingfrom:M,connectingto:k,valid:I,connectionindicator:o&&(!A||L)&&(A||O?i:r)}]),onMouseDown:T,onTouchStart:T,onClick:_?t=>{let{onClickConnectStart:o,onClickConnectEnd:i,connectionClickStartHandle:a,connectionMode:s,isValidConnection:l,lib:d,rfId:u,nodeLookup:c,connection:h}=v.getState();if(!E||!a&&!r)return;if(!a){o?.(t.nativeEvent,{nodeId:E,handleId:m,handleType:e}),v.setState({connectionClickStartHandle:{nodeId:E,type:e,id:m}});return}let f=eR(t.target),g=n||l,{connection:p,isValid:y}=tS.isValid(t.nativeEvent,{handle:{nodeId:E,id:m,type:e},connectionMode:s,fromNodeId:a.nodeId,fromHandleId:a.id||null,fromType:a.type,isValidConnection:g,flowId:u,doc:f,lib:d,nodeLookup:c});y&&p&&P(p);let b=structuredClone(h);delete b.inProgress,b.toPosition=b.toHandle?b.toHandle.position:null,i?.(t,b),v.setState({connectionClickStartHandle:null})}:void 0,ref:p,...f,children:l})})),n4={ArrowUp:{x:0,y:-1},ArrowDown:{x:0,y:1},ArrowLeft:{x:-1,y:0},ArrowRight:{x:1,y:0}},n8={input:function({data:e,isConnectable:t,sourcePosition:n=g.Bottom}){return(0,b.jsxs)(b.Fragment,{children:[e?.label,(0,b.jsx)(n5,{type:"source",position:n,isConnectable:t})]})},default:function({data:e,isConnectable:t,targetPosition:n=g.Top,sourcePosition:o=g.Bottom}){return(0,b.jsxs)(b.Fragment,{children:[(0,b.jsx)(n5,{type:"target",position:n,isConnectable:t}),e?.label,(0,b.jsx)(n5,{type:"source",position:o,isConnectable:t})]})},output:function({data:e,isConnectable:t,targetPosition:n=g.Top}){return(0,b.jsxs)(b.Fragment,{children:[(0,b.jsx)(n5,{type:"target",position:n,isConnectable:t}),e?.label]})},group:function(){return null}},n6=e=>{let{width:t,height:n,x:o,y:r}=Z(e.nodeLookup,{filter:e=>!!e.selected});return{width:ep(t)?t:null,height:ep(n)?n:null,userSelectionActive:e.userSelectionActive,transformString:`translate(${e.transform[0]}px,${e.transform[1]}px) scale(${e.transform[2]}) translate(${o}px,${r}px)`}};function n7({onSelectionContextMenu:e,noPanClassName:t,disableKeyboardA11y:n}){let o=t3(),{width:r,height:i,transformString:a,userSelectionActive:s}=t2(n6,tq),l=nZ(),d=(0,w.useRef)(null);(0,w.useEffect)(()=>{n||d.current?.focus({preventScroll:!0})},[n]);let u=!s&&null!==r&&null!==i;if(nU({nodeRef:d,disabled:!u}),!u)return null;let c=e?t=>{e(t,o.getState().nodes.filter(e=>e.selected))}:void 0;return(0,b.jsx)("div",{className:x(["react-flow__nodesselection","react-flow__container",t]),style:{transform:a},children:(0,b.jsx)("div",{ref:d,className:"react-flow__nodesselection-rect",onContextMenu:c,tabIndex:n?void 0:-1,onKeyDown:n?void 0:e=>{Object.prototype.hasOwnProperty.call(n4,e.key)&&(e.preventDefault(),l({direction:n4[e.key],factor:e.shiftKey?4:1}))},style:{width:r,height:i}})})}let n9="u">typeof window?window:void 0,oe=e=>({nodesSelectionActive:e.nodesSelectionActive,userSelectionActive:e.userSelectionActive});function ot({children:e,onPaneClick:t,onPaneMouseEnter:n,onPaneMouseMove:o,onPaneMouseLeave:r,onPaneContextMenu:i,onPaneScroll:a,paneClickDistance:s,deleteKeyCode:l,selectionKeyCode:d,selectionOnDrag:u,selectionMode:c,onSelectionStart:h,onSelectionEnd:f,multiSelectionKeyCode:g,panActivationKeyCode:p,zoomActivationKeyCode:m,elementsSelectable:y,zoomOnScroll:v,zoomOnPinch:x,panOnScroll:E,panOnScrollSpeed:_,panOnScrollMode:S,zoomOnDoubleClick:C,panOnDrag:M,autoPanOnSelection:k,defaultViewport:N,translateExtent:L,minZoom:A,maxZoom:O,preventScrolling:I,onSelectionContextMenu:P,noWheelClassName:T,noPanClassName:R,disableKeyboardA11y:D,onViewportChange:j,isControlledViewport:$}){let{nodesSelectionActive:B,userSelectionActive:F}=t2(oe,tq),H=nb(d,{target:n9}),z=nb(p,{target:n9}),V=z||M,K=z||E,X=u&&!0!==V,Y=H||F||X;return!function({deleteKeyCode:e,multiSelectionKeyCode:t}){let n=t3(),{deleteElements:o}=nj(),r=nb(e,{actInsideInputWithModifier:!1}),i=nb(t,{target:nB});(0,w.useEffect)(()=>
1{if(r){let{edges:e,nodes:t}=n.getState();o({nodes:t.filter(n$),edges:e.filter(n$)}),n.setState({nodesSelectionActive:!1})}},[r]),(0,w.useEffect)(()=>{n.setState({multiSelectionActive:i})},[i])}({deleteKeyCode:l,multiSelectionKeyCode:g}),(0,b.jsx)(nz,{onPaneContextMenu:i,elementsSelectable:y,zoomOnScroll:v,zoomOnPinch:x,panOnScroll:K,panActivationKeyPressed:z,panOnScrollSpeed:_,panOnScrollMode:S,zoomOnDoubleClick:C,panOnDrag:!H&&V,defaultViewport:N,translateExtent:L,minZoom:A,maxZoom:O,zoomActivationKeyCode:m,preventScrolling:I,noWheelClassName:T,noPanClassName:R,onViewportChange:j,isControlledViewport:$,paneClickDistance:s,selectionOnDrag:X,children:(0,b.jsxs)(nG,{onSelectionStart:h,onSelectionEnd:f,onPaneClick:t,onPaneMouseEnter:n,onPaneMouseMove:o,onPaneMouseLeave:r,onPaneContextMenu:i,onPaneScroll:a,panOnDrag:V,autoPanOnSelection:k,isSelecting:!!Y,selectionMode:c,selectionKeyPressed:H,paneClickDistance:s,selectionOnDrag:X,children:[e,B&&(0,b.jsx)(n7,{onSelectionContextMenu:P,noPanClassName:R,disableKeyboardA11y:D})]})})}ot.displayName="FlowRenderer";let on=(0,w.memo)(ot),oo=e=>e.updateNodeInternals;var or=(0,w.memo)(function({id:e,onClick:t,onMouseEnter:n,onMouseMove:o,onMouseLeave:r,onContextMenu:i,onDoubleClick:a,nodesDraggable:s,elementsSelectable:l,nodesConnectable:d,nodesFocusable:u,resizeObserver:c,noDragClassName:h,noPanClassName:f,disableKeyboardA11y:g,rfId:p,nodeTypes:m,nodeClickDistance:y,onError:v}){let{node:E,internals:_,isParent:S}=t2(t=>{let n=t.nodeLookup.get(e),o=t.parentLookup.has(e);return{node:n,internals:n.internals,isParent:o}},tq),C=E.type||"default",M=m?.[C]||n8[C];void 0===M&&(v?.("003",B.error003(C)),C="default",M=m?.default||n8.default);let k=!!(E.draggable||s&&void 0===E.draggable),N=!!(E.selectable||l&&void 0===E.selectable),L=!!(E.connectable||d&&void 0===E.connectable),A=!!(E.focusable||u&&void 0===E.focusable),O=t3(),I=eC(E),P=function({node:e,nodeType:t,hasDimensions:n,resizeObserver:o}){let r=t3(),i=(0,w.useRef)(null),a=(0,w.useRef)(null),s=(0,w.useRef)(e.sourcePosition),l=(0,w.useRef)(e.targetPosition),d=(0,w.useRef)(t),u=n&&!!e.internals.handleBounds;return(0,w.useEffect)(()=>{!i.current||e.hidden||u&&a.current===i.current||(a.current&&o?.unobserve(a.current),o?.observe(i.current),a.current=i.current)},[u,e.hidden]),(0,w.useEffect)(()=>()=>{a.current&&(o?.unobserve(a.current),a.current=null)},[]),(0,w.useEffect)(()=>{if(i.current){let n=d.current!==t,o=s.current!==e.sourcePosition,a=l.current!==e.targetPosition;(n||o||a)&&(d.current=t,s.current=e.sourcePosition,l.current=e.targetPosition,r.getState().updateNodeInternals(new Map([[e.id,{id:e.id,nodeElement:i.current,force:!0}]])))}},[e.id,t,e.sourcePosition,e.targetPosition]),i}({node:E,nodeType:C,hasDimensions:I,resizeObserver:c}),T=nU({nodeRef:P,disabled:E.hidden||!k,noDragClassName:h,handleSelector:E.dragHandle,nodeId:e,isSelectable:N,nodeClickDistance:y}),R=nZ();if(E.hidden)return null;let D=eS(E),j=void 0===E.internals.handleBounds?{width:E.width??E.initialWidth??E.style?.width,height:E.height??E.initialHeight??E.style?.height}:{width:E.width??E.style?.width,height:E.height??E.style?.height},$=N||k||t||n||o||r,F=n?e=>n(e,{..._.userNode}):void 0,z=o?e=>o(e,{..._.userNode}):void 0,V=r?e=>r(e,{..._.userNode}):void 0,K=i?e=>i(e,{..._.userNode}):void 0,X=a?e=>a(e,{..._.userNode}):void 0;return(0,b.jsx)("div",{className:x(["react-flow__node",`react-flow__node-${C}`,{[f]:k},E.className,{selected:E.selected,selectable:N,parent:S,draggable:k,dragging:T}]),ref:P,style:{zIndex:_.z,transform:`translate(${_.positionAbsolute.x}px,${_.positionAbsolute.y}px)`,pointerEvents:$?"all":"none",visibility:I?"visible":"hidden",...E.style,...j},"data-id":e,"data-testid":`rf__node-${e}`,onMouseEnter:F,onMouseMove:z,onMouseLeave:V,onContextMenu:K,onClick:n=>{let{selectNodesOnDrag:o,nodeDragThreshold:r}=O.getState();N&&(!o||!k||r>0)&&nW({id:e,store:O,nodeRef:P}),t&&t(n,{..._.userNode})},onDoubleClick:X,onKeyDown:A?t=>{if(!ej(t.nativeEvent)&&!g){if(H.includes(t.key)&&N)nW({id:e,store:O,unselect:"Escape"===t.key,nodeRef:P});else if(k&&E.selected&&Object.prototype.hasOwnProperty.call(n4,t.key)){t.preventDefault();let{ariaLabelConfig:e}=O.getState();
1O.setState({ariaLiveMessage:e["node.a11yDescription.ariaLiveMessage"]({direction:t.key.replace("Arrow","").toLowerCase(),x:~~_.positionAbsolute.x,y:~~_.positionAbsolute.y})}),R({direction:n4[t.key],factor:t.shiftKey?4:1})}}}:void 0,tabIndex:A?0:void 0,onFocus:A?()=>{if(g||!P.current?.matches(":focus-visible"))return;let{transform:t,width:n,height:o,autoPanOnNodeFocus:r,setCenter:i}=O.getState();!r||q(new Map([[e,E]]),{x:0,y:0,width:n,height:o},t,!0).length>0||i(E.position.x+D.width/2,E.position.y+D.height/2,{zoom:t[2]})}:void 0,role:E.ariaRole??(A?"group":void 0),"aria-roledescription":"node","aria-describedby":g?void 0:`${t8}-${p}`,"aria-label":E.ariaLabel,...E.domAttributes,children:(0,b.jsx)(nQ,{value:e,children:(0,b.jsx)(M,{id:e,data:E.data,type:C,positionAbsoluteX:_.positionAbsolute.x,positionAbsoluteY:_.positionAbsolute.y,selected:E.selected??!1,selectable:N,draggable:k,deletable:E.deletable??!0,isConnectable:L,sourcePosition:E.sourcePosition,targetPosition:E.targetPosition,dragging:T,dragHandle:E.dragHandle,zIndex:_.z,parentId:E.parentId,...D})})})});let oi=e=>({nodesConnectable:e.nodesConnectable,nodesFocusable:e.nodesFocusable,elementsSelectable:e.elementsSelectable,onError:e.onError});function oa(e){var t;let{nodesConnectable:n,nodesFocusable:o,elementsSelectable:r,onError:i}=t2(oi,tq),a=(t=e.onlyRenderVisibleElements,t2((0,w.useCallback)(e=>t?q(e.nodeLookup,{x:0,y:0,width:e.width,height:e.height},e.transform,!0).map(e=>e.id):Array.from(e.nodeLookup.keys()),[t]),tq)),s=function(){let e=t2(oo),[t]=(0,w.useState)(()=>"u"<typeof ResizeObserver?null:new ResizeObserver(t=>{let n=new Map;t.forEach(e=>{let t=e.target.getAttribute("data-id");n.set(t,{id:t,nodeElement:e.target,force:!0})}),e(n)}));return(0,w.useEffect)(()=>()=>{t?.disconnect()},[t]),t}();return(0,b.jsx)("div",{className:"react-flow__nodes",style:nF,children:a.map(t=>(0,b.jsx)(or,{id:t,nodeTypes:e.nodeTypes,nodeExtent:e.nodeExtent,onClick:e.onNodeClick,onMouseEnter:e.onNodeMouseEnter,onMouseMove:e.onNodeMouseMove,onMouseLeave:e.onNodeMouseLeave,onContextMenu:e.onNodeContextMenu,onDoubleClick:e.onNodeDoubleClick,noDragClassName:e.noDragClassName,noPanClassName:e.noPanClassName,rfId:e.rfId,disableKeyboardA11y:e.disableKeyboardA11y,resizeObserver:s,nodesDraggable:e.nodesDraggable??!0,nodesConnectable:n,nodesFocusable:o,elementsSelectable:r,nodeClickDistance:e.nodeClickDistance,onError:i},t))})}oa.displayName="NodeRenderer";let os=(0,w.memo)(oa),ol={[f.Arrow]:({color:e="none",strokeWidth:t=1})=>{let n={strokeWidth:t,...e&&{stroke:e}};return(0,b.jsx)("polyline",{className:"arrow",style:n,strokeLinecap:"round",fill:"none",strokeLinejoin:"round",points:"-5,-4 0,0 -5,4"})},[f.ArrowClosed]:({color:e="none",strokeWidth:t=1})=>{let n={strokeWidth:t,...e&&{stroke:e,fill:e}};return(0,b.jsx)("polyline",{className:"arrowclosed",style:n,strokeLinecap:"round",strokeLinejoin:"round",points:"-5,-4 0,0 -5,4 -5,-4"})}},od=({id:e,type:t,color:n,width:o=12.5,height:r=12.5,markerUnits:i="strokeWidth",strokeWidth:a,orient:s="auto-start-reverse"})=>{let l,d=(l=t3(),(0,w.useMemo)(()=>Object.prototype.hasOwnProperty.call(ol,t)?ol[t]:(l.getState().onError?.("009",B.error009(t)),null),[t]));return d?(0,b.jsx)("marker",{className:"react-flow__arrowhead",id:e,markerWidth:`${o}`,markerHeight:`${r}`,viewBox:"-10 -10 20 20",markerUnits:i,orient:s,refX:"0",refY:"0",children:(0,b.jsx)(d,{color:n,strokeWidth:a})}):null},ou=({defaultColor:e,rfId:t})=>{let n=t2(e=>e.edges),o=t2(e=>e.defaultEdgeOptions),r=(0,w.useMemo)(()=>e7(n,{id:t,defaultColor:e,defaultMarkerStart:o?.markerStart,defaultMarkerEnd:o?.markerEnd}),[n,o,t,e]);return r.length?(0,b.jsx)("svg",{className:"react-flow__marker","aria-hidden":"true",children:(0,b.jsx)("defs",{children:r.map(e=>(0,b.jsx)(od,{id:e.id,type:e.type,color:e.color,width:e.width,height:e.height,markerUnits:e.markerUnits,strokeWidth:e.strokeWidth,orient:e.orient},e.id))})}):null};ou.displayName="MarkerDefinitions";var oc=(0,w.memo)(ou);function oh({x:e,y:t,label:n,labelStyle:o,labelShowBg:r=!0,labelBgStyle:i,labelBgPadding:a=[2,4],labelBgBorderRadius:s=2,children:l,className:d,...u}){let[c,h]=(0,w.useState)({x:1,y:0,width:0,height:0}),f=x(["react-flow__edge-textwrapper",d]),g=(0,w.useRef)(null);return((0,w.useEffect)(()=>
1{if(g.current){let e=g.current.getBBox();h({x:e.x,y:e.y,width:e.width,height:e.height})}},[n]),n)?(0,b.jsxs)("g",{transform:`translate(${e-c.width/2} ${t-c.height/2})`,className:f,visibility:c.width?"visible":"hidden",...u,children:[r&&(0,b.jsx)("rect",{width:c.width+2*a[0],x:-a[0],y:-a[1],height:c.height+2*a[1],className:"react-flow__edge-textbg",style:i,rx:s,ry:s}),(0,b.jsx)("text",{className:"react-flow__edge-text",y:c.height/2,dy:"0.3em",ref:g,style:o,children:n}),l]}):null}oh.displayName="EdgeText";let of=(0,w.memo)(oh);function og({path:e,labelX:t,labelY:n,label:o,labelStyle:r,labelShowBg:i,labelBgStyle:a,labelBgPadding:s,labelBgBorderRadius:l,interactionWidth:d=20,...u}){return(0,b.jsxs)(b.Fragment,{children:[(0,b.jsx)("path",{...u,d:e,fill:"none",className:x(["react-flow__edge-path",u.className])}),d?(0,b.jsx)("path",{d:e,fill:"none",strokeOpacity:0,strokeWidth:d,className:"react-flow__edge-interaction"}):null,o&&ep(t)&&ep(n)?(0,b.jsx)(of,{x:t,y:n,label:o,labelStyle:r,labelShowBg:i,labelBgStyle:a,labelBgPadding:s,labelBgBorderRadius:l}):null]})}function op({pos:e,x1:t,y1:n,x2:o,y2:r}){return e===g.Left||e===g.Right?[.5*(t+o),n]:[t,.5*(n+r)]}function om({sourceX:e,sourceY:t,sourcePosition:n=g.Bottom,targetX:o,targetY:r,targetPosition:i=g.Top}){let[a,s]=op({pos:n,x1:e,y1:t,x2:o,y2:r}),[l,d]=op({pos:i,x1:o,y1:r,x2:e,y2:t}),[u,c,h,f]=eH({sourceX:e,sourceY:t,targetX:o,targetY:r,sourceControlX:a,sourceControlY:s,targetControlX:l,targetControlY:d});return[`M${e},${t} C${a},${s} ${l},${d} ${o},${r}`,u,c,h,f]}function oy(e){return(0,w.memo)(({id:t,sourceX:n,sourceY:o,targetX:r,targetY:i,sourcePosition:a,targetPosition:s,label:l,labelStyle:d,labelShowBg:u,labelBgStyle:c,labelBgPadding:h,labelBgBorderRadius:f,style:g,markerEnd:p,markerStart:m,interactionWidth:y})=>{let[v,w,x]=om({sourceX:n,sourceY:o,sourcePosition:a,targetX:r,targetY:i,targetPosition:s}),E=e.isInternal?void 0:t;return(0,b.jsx)(og,{id:E,path:v,labelX:w,labelY:x,label:l,labelStyle:d,labelShowBg:u,labelBgStyle:c,labelBgPadding:h,labelBgBorderRadius:f,style:g,markerEnd:p,markerStart:m,interactionWidth:y})})}let ov=oy({isInternal:!1}),ob=oy({isInternal:!0});function ow(e){return(0,w.memo)(({id:t,sourceX:n,sourceY:o,targetX:r,targetY:i,label:a,labelStyle:s,labelShowBg:l,labelBgStyle:d,labelBgPadding:u,labelBgBorderRadius:c,style:h,sourcePosition:f=g.Bottom,targetPosition:p=g.Top,markerEnd:m,markerStart:y,pathOptions:v,interactionWidth:w})=>{let[x,E,_]=e1({sourceX:n,sourceY:o,sourcePosition:f,targetX:r,targetY:i,targetPosition:p,borderRadius:v?.borderRadius,offset:v?.offset,stepPosition:v?.stepPosition}),S=e.isInternal?void 0:t;return(0,b.jsx)(og,{id:S,path:x,labelX:E,labelY:_,label:a,labelStyle:s,labelShowBg:l,labelBgStyle:d,labelBgPadding:u,labelBgBorderRadius:c,style:h,markerEnd:m,markerStart:y,interactionWidth:w})})}ov.displayName="SimpleBezierEdge",ob.displayName="SimpleBezierEdgeInternal";let ox=ow({isInternal:!1}),oE=ow({isInternal:!0});function o_(e){return(0,w.memo)(({id:t,...n})=>{let o=e.isInternal?void 0:t;return(0,b.jsx)(ox,{...n,id:o,pathOptions:(0,w.useMemo)(()=>({borderRadius:0,offset:n.pathOptions?.offset}),[n.pathOptions?.offset])})})}ox.displayName="SmoothStepEdge",oE.displayName="SmoothStepEdgeInternal";let oS=o_({isInternal:!1}),oC=o_({isInternal:!0});function oM(e){return(0,w.memo)(({id:t,sourceX:n,sourceY:o,targetX:r,targetY:i,label:a,labelStyle:s,labelShowBg:l,labelBgStyle:d,labelBgPadding:u,labelBgBorderRadius:c,style:h,markerEnd:f,markerStart:g,interactionWidth:p})=>{let[m,y,v]=eq({sourceX:n,sourceY:o,targetX:r,targetY:i}),w=e.isInternal?void 0:t;return(0,b.jsx)(og,{id:w,path:m,labelX:y,labelY:v,label:a,labelStyle:s,labelShowBg:l,labelBgStyle:d,labelBgPadding:u,labelBgBorderRadius:c,style:h,markerEnd:f,markerStart:g,interactionWidth:p})})}oS.displayName="StepEdge",oC.displayName="StepEdgeInternal";let ok=oM({isInternal:!1}),oN=oM({isInternal:!0});function oL(e){return(0,w.memo)(({id:t,sourceX:n,sourceY:o,targetX:r,targetY:i,sourcePosition:a=g.Bottom,targetPosition:s=g.Top,label:l,labelStyle:d,labelShowBg:u,labelBgStyle:c,labelBgPadding:h,labelBgBorderRadius:f,style:p,markerEnd:m,markerStart:y,pathOptions:v,interactionWidth:w})=>{let[x,E,_]=eK({sourceX:n,sourceY:o,sourcePosition:a,targetX:r,targetY:i,targetPosition:s,curvature:v?.curvature}),S=e.isInternal?void 0:t;return(0,b.jsx)(og,{id:S,path:x,labelX:E,labelY:_,label:l,labelStyle:d,labelShowBg:u,labelBgStyle:c,labelBgPadding:h,labelBgBorderRadius:f,style:p,markerEnd:m,markerStart:y,interactionWidth:w})})}ok.displayName="StraightEdge",oN.displayName="StraightEdgeInternal";let oA=oL({isInternal:!1}),oO=oL({isInternal:!0});oA.displayName="BezierEdge",oO.displayName="BezierEdgeInternal";
1let oI={default:oO,straight:oN,step:oC,smoothstep:oE,simplebezier:ob},oP={sourceX:null,sourceY:null,targetX:null,targetY:null,sourcePosition:null,targetPosition:null,zIndex:void 0},oT="react-flow__edgeupdater";function oR({position:e,centerX:t,centerY:n,radius:o=10,onMouseDown:r,onMouseEnter:i,onMouseOut:a,type:s}){return(0,b.jsx)("circle",{onMouseDown:r,onMouseEnter:i,onMouseOut:a,className:x([oT,`${oT}-${s}`]),cx:e===g.Left?t-o:e===g.Right?t+o:t,cy:e===g.Top?n-o:e===g.Bottom?n+o:n,r:o,stroke:"transparent",fill:"transparent"})}function oD({isReconnectable:e,reconnectRadius:t,edge:n,sourceX:o,sourceY:r,targetX:i,targetY:a,sourcePosition:s,targetPosition:l,onReconnect:d,onReconnectStart:u,onReconnectEnd:c,setReconnecting:h,setUpdateHover:f}){let g=t3(),p=(e,t)=>{if(0!==e.button)return;let{autoPanOnConnect:o,domNode:r,connectionMode:i,connectionRadius:a,lib:s,onConnectStart:l,cancelConnection:f,nodeLookup:p,rfId:m,panBy:y,updateConnection:v}=g.getState(),b="target"===t.type;tS.onPointerDown(e.nativeEvent,{autoPanOnConnect:o,connectionMode:i,connectionRadius:a,domNode:r,handleId:t.id,nodeId:t.nodeId,nodeLookup:p,isTarget:b,edgeUpdaterType:t.type,lib:s,flowId:m,cancelConnection:f,panBy:y,isValidConnection:(...e)=>g.getState().isValidConnection?.(...e)??!0,onConnect:e=>d?.(n,e),onConnectStart:(o,r)=>{h(!0),u?.(e,n,t.type),l?.(o,r)},onConnectEnd:(...e)=>g.getState().onConnectEnd?.(...e),onReconnectEnd:(e,o)=>{h(!1),c?.(e,n,t.type,o)},updateConnection:v,getTransform:()=>g.getState().transform,getFromHandle:()=>g.getState().connection.fromHandle,dragThreshold:g.getState().connectionDragThreshold,handleDomNode:e.currentTarget})},m=()=>f(!0),y=()=>f(!1);return(0,b.jsxs)(b.Fragment,{children:[(!0===e||"source"===e)&&(0,b.jsx)(oR,{position:s,centerX:o,centerY:r,radius:t,onMouseDown:e=>p(e,{nodeId:n.target,id:n.targetHandle??null,type:"target"}),onMouseEnter:m,onMouseOut:y,type:"source"}),(!0===e||"target"===e)&&(0,b.jsx)(oR,{position:l,centerX:i,centerY:a,radius:t,onMouseDown:e=>p(e,{nodeId:n.source,id:n.sourceHandle??null,type:"source"}),onMouseEnter:m,onMouseOut:y,type:"target"})]})}var oj=(0,w.memo)(function({id:e,edgesFocusable:t,edgesReconnectable:n,elementsSelectable:o,onClick:r,onDoubleClick:i,onContextMenu:a,onMouseEnter:s,onMouseMove:l,onMouseLeave:d,reconnectRadius:u,onReconnect:c,onReconnectStart:h,onReconnectEnd:f,rfId:g,edgeTypes:p,noPanClassName:m,onError:y,disableKeyboardA11y:v}){let E=t2(t=>t.edgeLookup.get(e)),_=t2(e=>e.defaultEdgeOptions),S=(E=_?{..._,...E}:E).type||"default",C=p?.[S]||oI[S];void 0===C&&(y?.("011",B.error011(S)),S="default",C=p?.default||oI.default);let M=!!(E.focusable||t&&void 0===E.focusable),k=void 0!==c&&(E.reconnectable||n&&void 0===E.reconnectable),N=!!(E.selectable||o&&void 0===E.selectable),L=(0,w.useRef)(null),[A,O]=(0,w.useState)(!1),[I,P]=(0,w.useState)(!1),T=t3(),{zIndex:R=E.zIndex,sourceX:D,sourceY:j,targetX:$,targetY:F,sourcePosition:z,targetPosition:V}=t2((0,w.useCallback)(t=>{let n=t.nodeLookup.get(E.source),o=t.nodeLookup.get(E.target);if(!n||!o)return oP;let r=e3({id:e,sourceNode:n,targetNode:o,sourceHandle:E.sourceHandle||null,targetHandle:E.targetHandle||null,connectionMode:t.connectionMode,onError:y}),i=eY({selected:E.selected,zIndex:E.zIndex,sourceNode:n,targetNode:o,elevateOnSelect:t.elevateEdgesOnSelect,zIndexMode:t.zIndexMode});return{...r||oP,zIndex:i}},[E.source,E.target,E.sourceHandle,E.targetHandle,E.selected,E.zIndex,y]),tq),K=(0,w.useMemo)(()=>E.markerStart?`url('#${e6(E.markerStart,g)}')`:void 0,[E.markerStart,g]),X=(0,w.useMemo)(()=>E.markerEnd?`url('#${e6(E.markerEnd,g)}')`:void 0,[E.markerEnd,g]);if(E.hidden||null===D||null===j||null===$||null===F)return null;let Y=i?e=>{i(e,{...E})}:void 0,G=a?e=>{a(e,{...E})}:void 0,W=s?e=>{s(e,{...E})}:void 0,U=l?e=>{l(e,{...E})}:void 0,Z=d?e=>{d(e,{...E})}:void 0;return(0,b.jsx)("svg",{style:{zIndex:R},children:(0,b.jsxs)("g",{className:x(["react-flow__edge",`react-flow__edge-${S}`,E.className,m,{selected:E.selected,animated:E.animated,inactive:!N&&!r,updating:A,selectable:N}]),onClick:t=>{let{addSelectedEdges:n,unselectNodesAndEdges:o,multiSelectionActive:i}=T.getState();N&&(T.setState({nodesSelectionActive:!1}),E.selected&&i?(o({nodes:[],edges:[E]}),L.current?.blur()):n([e])),r&&r(t,E)},onDoubleClick:Y,onContextMenu:G,onMouseEnter:W,onMouseMove:U,onMouseLeave:Z,onKeyDown:M?t=>{if(!v&&H.includes(t.key)&&N){let{unselectNodesAndEdges:n,addSelectedEdges:o}=T.getState();"Escape"===t.key?(L.current?.blur(),n({edges:[E]})):o([e])}}:void 0,tabIndex:M?0:void 0,role:E.ariaRole??(M?"group":"img"),"aria-roledescription":"edge","data-id":e,"data-testid":`rf__edge-${e}`,"aria-label":null===E.ariaLabel?void 0:E.ariaLabel||`Edge from ${E.source} to ${E.target}`,"aria-describedby":M?`${t6}-${g}`:void 0,ref:L,...E.domAttributes,children:[!I&&(0,b.jsx)(C,{id:e,source:E.source,target:E.target,type:E.type,selected:E.selected,animated:E.animated,selectable:N,deletable:E.deletable??!0,label:E.label,labelStyle:E.labelStyle,labelShowBg:E.labelShowBg,labelBgStyle:E.labelBgStyle,labelBgPadding:E.labelBgPadding,labelBgBorderRadius:E.labelBgBorderRadius,sourceX:D,sourceY:j,targetX:$,targetY:F,sourcePosition:z,targetPosition:V,data:E.data,style:E.style,sourceHandleId:E.sourceHandle,targetHandleId:E.targetHandle,markerStart:K,markerEnd:X,pathOptions:"pathOptions"in E?E.pathOptions:void 0,interactionWidth:E.interactionWidth}),k&&(0,b.jsx)(oD,{edge:E,isReconnectable:k,reconnectRadius:u,onReconnect:c,onReconnectStart:h,onReconnectEnd:f,sourceX:D,sourceY:j,targetX:$,targetY:F,sourcePosition:z,targetPosition:V,setUpdateHover:O,setReconnecting:P})]})})});let o$=e=>({edgesFocusable:e.edgesFocusable,edgesReconnectable:e.edgesReconnectable,elementsSelectable:e.elementsSelectable,connectionMode:e.connectionMode,onError:e.onError});function oB({defaultMarkerColor:e,onlyRenderVisibleElements:t,rfId:n,edgeTypes:o,noPanClassName:r,onReconnect:i,onEdgeContextMenu:a,onEdgeMouseEnter:s,onEdgeMouseMove:l,onEdgeMouseLeave:d,onEdgeClick:u,reconnectRadius:c,onEdgeDoubleClick:h,onReconnectStart:f,onReconnectEnd:g,disableKeyboardA11y:p}){let{edgesFocusable:m,edgesReconnectable:y,elementsSelectable:v,onError:x}=t2(o$,tq),E=t2((0,w.useCallback)(e=>{if(!t)return e.edges.map(e=>e.id);let n=[];if(e.width&&e.height)for(let t of e.edges){let o=e.nodeLookup.get(t.source),r=e.nodeLookup.get(t.target);o&&r&&eG({sourceNode:o,targetNode:r,width:e.width,height:e.height,transform:e.transform})&&n.push(t.id)}return n},[t]),tq);return(0,b.jsxs)("div",{className:"react-flow__edges",children:[(0,b.jsx)(oc,{defaultColor:e,rfId:n}),E.map(e=>(0,b.jsx)(oj,{id:e,edgesFocusable:m,edgesReconnectable:y,elementsSelectable:v,noPanClassName:r,onReconnect:i,onContextMenu:a,onMouseEnter:s,onMouseMove:l,onMouseLeave:d,onClick:u,reconnectRadius:c,onDoubleClick:h,onReconnectStart:f,onReconnectEnd:g,rfId:n,onError:x,edgeTypes:o,disableKeyboardA11y:p},e))]})}oB.displayName="EdgeRenderer";let oF=(0,w.memo)(oB),oH=e=>`translate(${e[0]}px,${e[1]}px) scale(${e[2]})`;function oz({children:e}){let t=t3(),n=(0,w.useRef)(null),[o]=(0,w.useState)(()=>t.getState().transform);return nI(()=>{let e=null,o=()=>{let o=t.getState().transform;(!e||o[0]!==e[0]||o[1]!==e[1]||o[2]!==e[2])&&(e=o,n.current&&(n.current.style.transform=oH(o)))};return o(),t.subscribe(o)},[t]),(0,b.jsx)("div",{ref:n,className:"react-flow__viewport xyflow__viewport react-flow__container",style:{transform:oH(o)},children:e})}let oV=e=>e.panZoom?.syncViewport;function oK(e){return e.connection.inProgress?{...e.connection,to:ev(e.connection.to,e.transform)}:{...e.connection}}let oX=e=>({nodesConnectable:e.nodesConnectable,isValid:e.connection.isValid,inProgress:e.connection.inProgress,width:e.width,height:e.height});function oY({containerStyle:e,style:t,type:n,component:o}){let{nodesConnectable:r,width:i,height:a,isValid:s,inProgress:l}=t2(oX,tq);return i&&r&&l?(0,b.jsx)("svg",{style:e,width:i,height:a,className:"react-flow__connectionline react-flow__container",children:(0,b.jsx)("g",{className:x(["react-flow__connection",eI(s)]),children:(0,b.jsx)(oG,{style:t,type:n,CustomComponent:o,isValid:s})})}):null}let oG=({style:e,type:t=h.Bezier,CustomComponent:n,isValid:o})=>{let{inProgress:r,from:i,fromNode:a,fromHandle:s,fromPosition:l,to:d,toNode:u,toHandle:c,toPosition:f,pointer:g}=t2(oK,tq);if(!r)return;if(n)return(0,b.jsx)(n,{connectionLineType:t,connectionLineStyle:e,fromNode:a,fromHandle:s,fromX:i.x,fromY:i.y,toX:d.x,toY:d.y,fromPosition:l,toPosition:f,connectionStatus:eI(o),toNode:u,toHandle:c,pointer:g});let p="",m={sourceX:i.x,sourceY:i.y,sourcePosition:l,targetX:d.x,targetY:d.y,targetPosition:f};switch(t){case h.Bezier:[p]=eK(m);break;case h.SimpleBezier:[p]=om(m);break;case h.Step:[p]=e1({...m,borderRadius:0});break;case h.SmoothStep:[p]=e1(m);break;default:[p]=eq(m)}return(0,b.jsx)("path",{d:p,fill:"none",className:"react-flow__connection-path",style:e})};oG.displayName="ConnectionLine";let oW={};function oU(e=oW){(0,w.useRef)(e),t3(),(0,w.useEffect)(()=>{},[e])}function oZ({nodeTypes:e,edgeTypes:t,onInit:n,onNodeClick:o,onEdgeClick:r,onNodeDoubleClick:i,onEdgeDoubleClick:a,onNodeMouseEnter:s,onNodeMouseMove:l,onNodeMouseLeave:d,onNodeContextMenu:u,onSelectionContextMenu:c,onSelectionStart:h,onSelectionEnd:f,connectionLineType:g,connectionLineStyle:p,connectionLineComponent:m,connectionLineContainerStyle:y,selectionKeyCode:v,selectionOnDrag:x,selectionMode:E,multiSelectionKeyCode:_,panActivationKeyCode:S,zoomActivationKeyCode:C,deleteKeyCode:M,onlyRenderVisibleElements:k,elementsSelectable:N,defaultViewport:L,translateExtent:A,minZoom:O,maxZoom:I,preventScrolling:P,defaultMarkerColor:T,zoomOnScroll:R,zoomOnPinch:D,panOnScroll:j,panOnScrollSpeed:$,panOnScrollMode:B,zoomOnDoubleClick:F,panOnDrag:H,autoPanOnSelection:z,onPaneClick:V,onPaneMouseEnter:K,onPaneMouseMove:X,onPaneMouseLeave:Y,onPaneScroll:G,onPaneContextMenu:W,paneClickDistance:U,nodeClickDistance:Z,onEdgeContextMenu:q,onEdgeMouseEnter:Q,onEdgeMouseMove:J,onEdgeMouseLeave:ee,reconnectRadius:et,onReconnect:en,onReconnectStart:eo,onReconnectEnd:er,noDragClassName:ei,noWheelClassName:ea,noPanClassName:es,disableKeyboardA11y:el,nodeExtent:ed,rfId:eu,viewport:ec,onViewportChange:eh,nodesDraggable:ef}){let eg,ep,em,ey;return oU(e),oU(t),t3(),(0,w.useRef)(!1),(0,w.useEffect)(()=>{},[]),eg=nj(),ep=(0,w.useRef)(!1),(0,w.useEffect)(()=>{!ep.current&&eg.viewportInitialized&&n&&(setTimeout(()=>n(eg),1),ep.current=!0)}
1,[n,eg.viewportInitialized]),em=t2(oV),ey=t3(),(0,w.useEffect)(()=>{ec&&(em?.(ec),ey.setState({transform:[ec.x,ec.y,ec.zoom]}))},[ec,em]),(0,b.jsx)(on,{onPaneClick:V,onPaneMouseEnter:K,onPaneMouseMove:X,onPaneMouseLeave:Y,onPaneContextMenu:W,onPaneScroll:G,paneClickDistance:U,deleteKeyCode:M,selectionKeyCode:v,selectionOnDrag:x,selectionMode:E,onSelectionStart:h,onSelectionEnd:f,multiSelectionKeyCode:_,panActivationKeyCode:S,zoomActivationKeyCode:C,elementsSelectable:N,zoomOnScroll:R,zoomOnPinch:D,zoomOnDoubleClick:F,panOnScroll:j,panOnScrollSpeed:$,panOnScrollMode:B,panOnDrag:H,autoPanOnSelection:z,defaultViewport:L,translateExtent:A,minZoom:O,maxZoom:I,onSelectionContextMenu:c,preventScrolling:P,noDragClassName:ei,noWheelClassName:ea,noPanClassName:es,disableKeyboardA11y:el,onViewportChange:eh,isControlledViewport:!!ec,children:(0,b.jsxs)(oz,{children:[(0,b.jsx)(oF,{edgeTypes:t,onEdgeClick:r,onEdgeDoubleClick:a,onReconnect:en,onReconnectStart:eo,onReconnectEnd:er,onlyRenderVisibleElements:k,onEdgeContextMenu:q,onEdgeMouseEnter:Q,onEdgeMouseMove:J,onEdgeMouseLeave:ee,reconnectRadius:et,defaultMarkerColor:T,noPanClassName:es,disableKeyboardA11y:el,rfId:eu}),(0,b.jsx)(oY,{style:p,type:g,component:m,containerStyle:y}),(0,b.jsx)("div",{className:"react-flow__edgelabel-renderer"}),(0,b.jsx)(os,{nodeTypes:e,onNodeClick:o,onNodeDoubleClick:i,onNodeMouseEnter:s,onNodeMouseMove:l,onNodeMouseLeave:d,onNodeContextMenu:u,nodeClickDistance:Z,onlyRenderVisibleElements:k,noPanClassName:es,noDragClassName:ei,disableKeyboardA11y:el,nodeExtent:ed,rfId:eu,nodesDraggable:ef}),(0,b.jsx)("div",{className:"react-flow__viewport-portal"})]})})}oZ.displayName="GraphView";let oq=(0,w.memo)(oZ),oQ=em("React Flow","https://reactflow.dev/"),oJ=({nodes:e,edges:t,defaultNodes:n,defaultEdges:o,width:r,height:i,fitView:a,fitViewOptions:s,minZoom:l=.5,maxZoom:u=2,nodeOrigin:c,nodeExtent:h,zIndexMode:f="basic"}={})=>{let g=new Map,p=new Map,m=new Map,y=new Map,v=o??t??[],b=n??e??[],w=c??[0,0],x=h??F;tp(m,y,v);let{nodesInitialized:E}=tl(b,g,p,{nodeOrigin:w,nodeExtent:x,zIndexMode:f}),_=[0,0,1];if(a&&r&&i){let{x:e,y:t,zoom:n}=ex(Z(g,{filter:e=>!!((e.width||e.initialWidth)&&(e.height||e.initialHeight))}),r,i,l,u,s?.padding??.1);_=[e,t,n]}return{rfId:"1",width:r??0,height:i??0,transform:_,nodes:b,nodesInitialized:E,nodeLookup:g,parentLookup:p,edges:v,edgeLookup:y,connectionLookup:m,onNodesChange:null,onEdgesChange:null,hasDefaultNodes:void 0!==n,hasDefaultEdges:void 0!==o,panZoom:null,minZoom:l,maxZoom:u,translateExtent:F,nodeExtent:x,nodesSelectionActive:!1,userSelectionActive:!1,userSelectionRect:null,connectionMode:d.Strict,domNode:null,paneDragging:!1,noPanClassName:"nopan",nodeOrigin:w,nodeDragThreshold:1,connectionDragThreshold:1,snapGrid:[15,15],snapToGrid:!1,nodesDraggable:!0,nodesConnectable:!0,nodesFocusable:!0,edgesFocusable:!0,edgesReconnectable:!0,elementsSelectable:!0,elevateNodesOnSelect:!0,elevateEdgesOnSelect:!0,selectNodesOnDrag:!0,multiSelectionActive:!1,fitViewQueued:a??!1,fitViewOptions:s,fitViewResolver:null,connection:{...V},connectionClickStartHandle:null,connectOnClick:!0,ariaLiveMessage:"",autoPanOnConnect:!0,autoPanOnNodeDrag:!0,autoPanOnNodeFocus:!0,autoPanSpeed:15,connectionRadius:20,onError:oQ,isValidConnection:void 0,onSelectionChangeHandlers:[],lib:"react",debug:!1,ariaLabelConfig:z,zIndexMode:f,defaultEdgeOptions:void 0,onNodesChangeMiddlewareMap:new Map,onEdgesChangeMiddlewareMap:new Map,onNodesDelete:void 0,onEdgesDelete:void 0,onDelete:void 0,onBeforeDelete:void 0,onViewportChangeStart:void 0,onViewportChange:void 0,onViewportChangeEnd:void 0,onNodeDragStart:void 0,onNodeDrag:void 0,onNodeDragStop:void 0,onSelectionDragStart:void 0,onSelectionDrag:void 0,onSelectionDragStop:void 0,onMoveStart:void 0,onMove:void 0,onMoveEnd:void 0,onConnect:void 0,onConnectStart:void 0,onConnectEnd:void 0,onClickConnectStart:void 0,onClickConnectEnd:void 0}};function o0({initialNodes:e,initialEdges:t,defaultNodes:n,defaultEdges:o,initialWidth:r,initialHeight:i,initialMinZoom:a,initialMaxZoom:s,initialFitViewOptions:l,fitView:d,nodeOrigin:u,nodeExtent:c,zIndexMode:h,children:f}){let[p]=(0,w.useState)(()=>(({nodes:e,edges:t,defaultNodes:n,defaultEdges:o,width:r,height:i,fitView:a,fitViewOptions:s,minZoom:l,maxZoom:d,nodeOrigin:u,nodeExtent:c,zIndexMode:h})=>{let f,p;return f=(f,p)=>{async function m(){let{nodeLookup:e,panZoom:t,fitViewOptions:n,fitViewResolver:o,width:r,height:i,minZoom:a,maxZoom:s}=p();
1t&&(await Q({nodes:e,width:r,height:i,panZoom:t,minZoom:a,maxZoom:s},n),o?.resolve(!0),f({fitViewResolver:null}))}return{...oJ({nodes:e,edges:t,width:r,height:i,fitView:a,fitViewOptions:s,minZoom:l,maxZoom:d,nodeOrigin:u,nodeExtent:c,defaultNodes:n,defaultEdges:o,zIndexMode:h}),setNodes:e=>{let{nodeLookup:t,parentLookup:n,nodeOrigin:o,nodeExtent:r,elevateNodesOnSelect:i,fitViewQueued:a,zIndexMode:s,nodesSelectionActive:l}=p(),{nodesInitialized:d,hasSelectedNodes:u}=tl(e,t,n,{nodeOrigin:o,nodeExtent:r,elevateNodesOnSelect:i,checkEquality:!0,zIndexMode:s}),c=l&&u;a&&d?(m(),f({nodes:e,nodesInitialized:d,fitViewQueued:!1,fitViewOptions:void 0,nodesSelectionActive:c})):f({nodes:e,nodesInitialized:d,nodesSelectionActive:c})},setEdges:e=>{let{connectionLookup:t,edgeLookup:n}=p();tp(t,n,e),f({edges:e})},setDefaultNodesAndEdges:(e,t)=>{if(e){let{setNodes:t}=p();t(e),f({hasDefaultNodes:!0})}if(t){let{setEdges:e}=p();e(t),f({hasDefaultEdges:!0})}},updateNodeInternals:e=>{let{triggerNodeChanges:t,nodeLookup:n,parentLookup:o,domNode:r,nodeOrigin:i,nodeExtent:a,debug:s,fitViewQueued:l,zIndexMode:d}=p(),{changes:u,updatedInternals:c}=th(e,n,o,r,i,a,d);c&&(ta(n,o,{nodeOrigin:i,nodeExtent:a,zIndexMode:d}),l?(m(),f({fitViewQueued:!1,fitViewOptions:void 0})):f({}),u?.length>0&&(s&&console.log("React Flow: trigger node changes",u),t?.(u)))},updateNodePositions:(e,t=!1)=>{let n=[],o=[],{nodeLookup:r,triggerNodeChanges:i,connection:a,updateConnection:s,onNodesChangeMiddlewareMap:l}=p();for(let[i,l]of e){let e=r.get(i),d=!!(e?.expandParent&&e?.parentId&&l?.position),u={id:i,type:"position",position:d?{x:Math.max(0,l.position.x),y:Math.max(0,l.position.y)}:l.position,dragging:t};if(e&&a.inProgress&&a.fromNode.id===e.id){let t=e4(e,a.fromHandle,g.Left,!0);s({...a,from:t})}d&&e.parentId&&n.push({id:i,parentId:e.parentId,rect:{...l.internals.positionAbsolute,width:l.measured.width??0,height:l.measured.height??0}}),o.push(u)}if(n.length>0){let{parentLookup:e,nodeOrigin:t}=p(),i=tc(n,r,e,t);o.push(...i)}for(let e of l.values())o=e(o);i(o)},triggerNodeChanges:e=>{let{onNodesChange:t,setNodes:n,nodes:o,hasDefaultNodes:r,debug:i}=p();e?.length&&(r&&n(nE(e,o)),i&&console.log("React Flow: trigger node changes",e),t?.(e))},triggerEdgeChanges:e=>{let{onEdgesChange:t,setEdges:n,edges:o,hasDefaultEdges:r,debug:i}=p();e?.length&&(r&&n(nE(e,o)),i&&console.log("React Flow: trigger edge changes",e),t?.(e))},addSelectedNodes:e=>{let{multiSelectionActive:t,edgeLookup:n,nodeLookup:o,triggerNodeChanges:r,triggerEdgeChanges:i}=p();t?r(e.map(e=>nC(e,!0))):(r(nM(o,new Set([...e]),!0)),i(nM(n)))},addSelectedEdges:e=>{let{multiSelectionActive:t,edgeLookup:n,nodeLookup:o,triggerNodeChanges:r,triggerEdgeChanges:i}=p();t?i(e.map(e=>nC(e,!0))):(i(nM(n,new Set([...e]))),r(nM(o,new Set,!0)))},unselectNodesAndEdges:({nodes:e,edges:t}={})=>{let{edges:n,nodes:o,nodeLookup:r,triggerNodeChanges:i,triggerEdgeChanges:a}=p(),s=[];for(let t of e||o){if(!t.selected)continue;let e=r.get(t.id);e&&(e.selected=!1),s.push(nC(t.id,!1))}let l=[];for(let e of t||n)e.selected&&l.push(nC(e.id,!1));i(s),a(l)},setMinZoom:e=>{let{panZoom:t,maxZoom:n}=p();t?.setScaleExtent([e,n]),f({minZoom:e})},setMaxZoom:e=>{let{panZoom:t,minZoom:n}=p();t?.setScaleExtent([n,e]),f({maxZoom:e})},setTranslateExtent:e=>{p().panZoom?.setTranslateExtent(e),f({translateExtent:e})},resetSelectedElements:()=>{let{edges:e,nodes:t,triggerNodeChanges:n,triggerEdgeChanges:o,elementsSelectable:r}=p();if(!r)return;let i=t.reduce((e,t)=>t.selected?[...e,nC(t.id,!1)]:e,[]),a=e.reduce((e,t)=>t.selected?[...e,nC(t.id,!1)]:e,[]);n(i),o(a)},setNodeExtent:e=>{let{nodes:t,nodeLookup:n,parentLookup:o,nodeOrigin:r,elevateNodesOnSelect:i,nodeExtent:a,zIndexMode:s}=p();(e[0][0]!==a[0][0]||e[0][1]!==a[0][1]||e[1][0]!==a[1][0]||e[1][1]!==a[1][1])&&(tl(t,n,o,{nodeOrigin:r,nodeExtent:e,elevateNodesOnSelect:i,checkEquality:!1,zIndexMode:s}),f({nodeExtent:e}))},panBy:e=>{let{transform:t,width:n,height:o,panZoom:r,translateExtent:i}=p();return tf({delta:e,panZoom:r,transform:t,translateExtent:i,width:n,height:o})},setCenter:async(e,t,n)=>{let{width:o,height:r,maxZoom:i,panZoom:a}=p();if(!a)return!1;let s=void 0!==n?.zoom?n.zoom:i;return await a.setViewport({x:o/2-e*s,y:r/2-t*s,zoom:s},{duration:n?.duration,ease:n?.ease,interpolate:n?.interpolate}),!0},cancelConnection:()=>{f({connection:{...V}})},updateConnection:e=>{f({connection:e})},reset:()=>f({...oJ()})}},p=Object.is,f?tZ(f,p):tZ})({nodes:e,edges:t,defaultNodes:n,defaultEdges:o,width:r,height:i,fitView:d,minZoom:a,maxZoom:s,fitViewOptions:l,nodeOrigin:u,nodeExtent:c,zIndexMode:h}));return(0,b.jsx)(t0,{value:p,children:(0,b.jsx)(nR,{children:(0,b.jsx)(n2,{children:f})})})}function o1({children:e,nodes:t,edges:n,defaultNodes:o,defaultEdges:r,width:i,height:a,fitView:s,fitViewOptions:l,minZoom:d,maxZoom:u,nodeOrigin:c,nodeExtent:h,zIndexMode:f}){return(0,w.useContext)(tJ)?(0,b.jsx)(b.Fragment,{children:e}):(0,b.jsx)(o0,{initialNodes:t,initialEdges:n,defaultNodes:o,defaultEdges:r,initialWidth:i,initialHeight:a,fitView:s,initialFitViewOptions:l,initialMinZoom:d,initialMaxZoom:u,nodeOrigin:c,nodeExtent:h,zIndexMode:f,children:e})}let o2={width:"100%",height:"100%",overflow:"hidden",position:"relative",zIndex:0};var o3=nO(function({nodes:e,edges:t,defaultNodes:n,defaultEdges:o,className:r,no
1deTypes:i,edgeTypes:a,onNodeClick:s,onEdgeClick:l,onInit:d,onMove:f,onMoveStart:g,onMoveEnd:p,onConnect:m,onConnectStart:y,onConnectEnd:v,onClickConnectStart:E,onClickConnectEnd:_,onNodeMouseEnter:S,onNodeMouseMove:C,onNodeMouseLeave:M,onNodeContextMenu:k,onNodeDoubleClick:N,onNodeDragStart:L,onNodeDrag:A,onNodeDragStop:O,onNodesDelete:I,onEdgesDelete:P,onDelete:T,onSelectionChange:R,onSelectionDragStart:D,onSelectionDrag:j,onSelectionDragStop:$,onSelectionContextMenu:B,onSelectionStart:H,onSelectionEnd:z,onBeforeDelete:V,connectionMode:K,connectionLineType:X=h.Bezier,connectionLineStyle:Y,connectionLineComponent:G,connectionLineContainerStyle:W,deleteKeyCode:U="Backspace",selectionKeyCode:Z="Shift",selectionOnDrag:q=!1,selectionMode:Q=c.Full,panActivationKeyCode:J="Space",multiSelectionKeyCode:ee=eE()?"Meta":"Control",zoomActivationKeyCode:et=eE()?"Meta":"Control",snapToGrid:en,snapGrid:eo,onlyRenderVisibleElements:er=!1,selectNodesOnDrag:ei,nodesDraggable:ea,autoPanOnNodeFocus:es,nodesConnectable:el,nodesFocusable:ed,nodeOrigin:eu=nc,edgesFocusable:ec,edgesReconnectable:eh,elementsSelectable:ef=!0,defaultViewport:eg=nh,minZoom:ep=.5,maxZoom:em=2,translateExtent:ey=F,preventScrolling:ev=!0,nodeExtent:eb,defaultMarkerColor:ew="#b1b1b7",zoomOnScroll:ex=!0,zoomOnPinch:e_=!0,panOnScroll:eS=!1,panOnScrollSpeed:eC=.5,panOnScrollMode:eM=u.Free,zoomOnDoubleClick:ek=!0,panOnDrag:eN=!0,onPaneClick:eL,onPaneMouseEnter:eA,onPaneMouseMove:eO,onPaneMouseLeave:eI,onPaneScroll:eP,onPaneContextMenu:eT,paneClickDistance:eR=1,nodeClickDistance:eD=0,children:ej,onReconnect:e$,onReconnectStart:eB,onReconnectEnd:eF,onEdgeContextMenu:eH,onEdgeDoubleClick:ez,onEdgeMouseEnter:eV,onEdgeMouseMove:eK,onEdgeMouseLeave:eX,reconnectRadius:eY=10,onNodesChange:eG,onEdgesChange:eW,noDragClassName:eU="nodrag",noWheelClassName:eZ="nowheel",noPanClassName:eq="nopan",fitView:eQ,fitViewOptions:eJ,connectOnClick:e0,attributionPosition:e1,proOptions:e2,defaultEdgeOptions:e3,elevateNodesOnSelect:e5=!0,elevateEdgesOnSelect:e4=!1,disableKeyboardA11y:e8=!1,autoPanOnConnect:e6,autoPanOnNodeDrag:e7,autoPanOnSelection:e9=!0,autoPanSpeed:te,connectionRadius:tt,isValidConnection:tn,onError:to,style:tr,id:ti,nodeDragThreshold:ta,connectionDragThreshold:ts,viewport:tl,onViewportChange:td,width:tu,height:tc,colorMode:th="light",debug:tf,onScroll:tg,ariaLabelConfig:tp,zIndexMode:tm="basic",...ty},tv){let tb=ti||"1",tw=function(e){let[t,n]=(0,w.useState)("system"===e?null:e);return(0,w.useEffect)(()=>{if("system"!==e)return void n(e);let t=ny(),o=()=>n(t?.matches?"dark":"light");return o(),t?.addEventListener("change",o),()=>{t?.removeEventListener("change",o)}},[e]),null!==t?t:ny()?.matches?"dark":"light"}(th),tx=(0,w.useCallback)(e=>{e.currentTarget.scrollTo({top:0,left:0,behavior:"instant"}),tg?.(e)},[tg]);return(0,b.jsx)("div",{"data-testid":"rf__wrapper",...ty,onScroll:tx,style:{...tr,...o2},ref:tv,className:x(["react-flow",r,tw]),id:ti,role:"application",children:(0,b.jsxs)(o1,{nodes:e,edges:t,width:tu,height:tc,fitView:eQ,fitViewOptions:eJ,minZoom:ep,maxZoom:em,nodeOrigin:eu,nodeExtent:eb,zIndexMode:tm,children:[(0,b.jsx)(nm,{nodes:e,edges:t,defaultNodes:n,defaultEdges:o,onConnect:m,onConnectStart:y,onConnectEnd:v,onClickConnectStart:E,onClickConnectEnd:_,nodesDraggable:ea,autoPanOnNodeFocus:es,nodesConnectable:el,nodesFocusable:ed,edgesFocusable:ec,edgesReconnectable:eh,elementsSelectable:ef,elevateNodesOnSelect:e5,elevateEdgesOnSelect:e4,minZoom:ep,maxZoom:em,nodeExtent:eb,onNodesChange:eG,onEdgesChange:eW,snapToGrid:en,snapGrid:eo,connectionMode:K,translateExtent:ey,connectOnClick:e0,defaultEdgeOptions:e3,fitView:eQ,fitViewOptions:eJ,onNodesDelete:I,onEdgesDelete:P,onDelete:T,onNodeDragStart:L,onNodeDrag:A,onNodeDragStop:O,onSelectionDrag:j,onSelectionDragStart:D,onSelectionDragStop:$,onMove:f,onMoveStart:g,onMoveEnd:p,noPanClassName:eq,nodeOrigin:eu,rfId:tb,autoPanOnConnect:e6,autoPanOnNodeDrag:e7,autoPanSpeed:te,onError:to,connectionRadius:tt,isValidConnection:tn,selectNodesOnDrag:ei,nodeDragThreshold:ta,connectionDragThreshold:ts,onBeforeDelete:V,debug:tf,ariaLabelConfig:tp,zIndexMode:tm}),(0,b.jsx)(oq,{onInit:d,onNodeClick:s,onEdgeClick:l,onNodeMouseEnter:S,onNodeMouseMove:C,onNodeMouseLeave:M,onNodeContextMenu:k,onNodeDoubleClick:N,nodeTypes:i,edgeTypes:a,connectionLineType:X,connectionLineStyle:Y,connectionLineComponent:G,connectionLineContainerStyle:W,selectionKeyCode:Z,selectionOnDrag:q,selectionMode:Q,deleteKeyCode:U,multiSelectionKeyCode:ee,panActivationKeyCode:J,zoomActivationKeyCode:et,onlyRenderVisibleElements:er,defaultViewport:eg,translateExtent:ey,minZoom:ep,maxZoom:em,preventScrolling:ev,zoomOnScroll:ex,zoomOnPinch:e_,zoomOnDoubleClick:ek,panOnScroll:eS,panOnScrollSpeed:eC,panOnScrollMode:eM,panOnDrag:eN,autoPanOnSelection:e9,onPaneClick:eL,onPaneMouseEnter:eA,onPaneMouseMove:eO,onPaneMouseLeave:eI,onPaneScroll:eP,onPaneContextMenu:eT,paneClickDistance:eR,nodeClickDistance:eD,onSelectionContextMenu:B,onSelectionStart:H,onSelectionEnd:z,onReconnect:e$,onReconnectStart:eB,onReconnectEnd:eF,onEdgeContextMenu:eH,onEdgeDoubleClick:ez,onEdgeMouseEnter:eV,onEdgeMouseMove:eK,onEdgeMouseLeave:eX,reconnectRadius:eY,defaultMarkerColor:ew,noDragClassName:eU,noWheelClassName:eZ,noPanClassName:eq,rfId:tb,disableKeyboardA11y:e8,nodeExtent:eb,viewport:tl,onViewportChange:td,nodesDraggable:ea}),(0,b.jsx)(nu,{onSelectionChange:R}),ej,(0,b.jsx)(nr,{proOptions:e2,position:e1}),(0,b.jsx)(nt,{rfId:tb,disableKeyboardA11y:e8})]})})});let o5=e=>e.domNode?.querySelector(".react-flow__edgelabel-renderer");function o4({children:e}){let t=t2(o5);return t?(0,tQ.createPortal)(e,t):null}
1let o8=e=>({x:e.transform[0],y:e.transform[1],zoom:e.transform[2]});function o6(){return t2(o8,tq)}function o7(e){return t2((0,w.useCallback)(t=>t.nodeLookup.get(e),[e]),tq)}function o9({dimensions:e,lineWidth:t,variant:n,className:o}){return(0,b.jsx)("path",{strokeWidth:t,d:`M${e[0]/2} 0 V${e[1]} M0 ${e[1]/2} H${e[0]}`,className:x(["react-flow__background-pattern",n,o])})}function re({radius:e,className:t}){return(0,b.jsx)("circle",{cx:e,cy:e,r:e,className:x(["react-flow__background-pattern","dots",t])})}B.error014(),(l=m||(m={})).Lines="lines",l.Dots="dots",l.Cross="cross";let rt={[m.Dots]:1,[m.Lines]:1,[m.Cross]:6},rn=e=>({transform:e.transform,patternId:`pattern-${e.rfId}`});function ro({id:e,variant:t=m.Dots,gap:n=20,size:o,lineWidth:r=1,offset:i=0,color:a,bgColor:s,style:l,className:d,patternClassName:u}){let c=(0,w.useRef)(null),{transform:h,patternId:f}=t2(rn,tq),g=o||rt[t],p=t===m.Dots,y=t===m.Cross,v=Array.isArray(n)?n:[n,n],E=[v[0]*h[2]||1,v[1]*h[2]||1],_=g*h[2],S=Array.isArray(i)?i:[i,i],C=y?[_,_]:E,M=[S[0]*h[2]+C[0]/2,S[1]*h[2]+C[1]/2],k=`${f}${e||""}`;return(0,b.jsxs)("svg",{className:x(["react-flow__background",d]),style:{...l,...nF,"--xy-background-color-props":s,"--xy-background-pattern-color-props":a},ref:c,"data-testid":"rf__background",children:[(0,b.jsx)("pattern",{id:k,x:h[0]%E[0],y:h[1]%E[1],width:E[0],height:E[1],patternUnits:"userSpaceOnUse",patternTransform:`translate(-${M[0]},-${M[1]})`,children:p?(0,b.jsx)(re,{radius:_/2,className:u}):(0,b.jsx)(o9,{dimensions:C,lineWidth:r,variant:t,className:u})}),(0,b.jsx)("rect",{x:"0",y:"0",width:"100%",height:"100%",fill:`url(#${k})`})]})}ro.displayName="Background";let rr=(0,w.memo)(ro);function ri(){return(0,b.jsx)("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 32 32",children:(0,b.jsx)("path",{d:"M32 18.133H18.133V32h-4.266V18.133H0v-4.266h13.867V0h4.266v13.867H32z"})})}function ra(){return(0,b.jsx)("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 32 5",children:(0,b.jsx)("path",{d:"M0 0h32v4.2H0z"})})}function rs(){return(0,b.jsx)("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 32 30",children:(0,b.jsx)("path",{d:"M3.692 4.63c0-.53.4-.938.939-.938h5.215V0H4.708C2.13 0 0 2.054 0 4.63v5.216h3.692V4.631zM27.354 0h-5.2v3.692h5.17c.53 0 .984.4.984.939v5.215H32V4.631A4.624 4.624 0 0027.354 0zm.954 24.83c0 .532-.4.94-.939.94h-5.215v3.768h5.215c2.577 0 4.631-2.13 4.631-4.707v-5.139h-3.692v5.139zm-23.677.94c-.531 0-.939-.4-.939-.94v-5.138H0v5.139c0 2.577 2.13 4.707 4.708 4.707h5.138V25.77H4.631z"})})}function rl(){return(0,b.jsx)("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 25 32",children:(0,b.jsx)("path",{d:"M21.333 10.667H19.81V7.619C19.81 3.429 16.38 0 12.19 0 8 0 4.571 3.429 4.571 7.619v3.048H3.048A3.056 3.056 0 000 13.714v15.238A3.056 3.056 0 003.048 32h18.285a3.056 3.056 0 003.048-3.048V13.714a3.056 3.056 0 00-3.048-3.047zM12.19 24.533a3.056 3.056 0 01-3.047-3.047 3.056 3.056 0 013.047-3.048 3.056 3.056 0 013.048 3.048 3.056 3.056 0 01-3.048 3.047zm4.724-13.866H7.467V7.619c0-2.59 2.133-4.724 4.723-4.724 2.591 0 4.724 2.133 4.724 4.724v3.048z"})})}function rd(){return(0,b.jsx)("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 25 32",children:(0,b.jsx)("path",{d:"M21.333 10.667H19.81V7.619C19.81 3.429 16.38 0 12.19 0c-4.114 1.828-1.37 2.133.305 2.438 1.676.305 4.42 2.59 4.42 5.181v3.048H3.047A3.056 3.056 0 000 13.714v15.238A3.056 3.056 0 003.048 32h18.285a3.056 3.056 0 003.048-3.048V13.714a3.056 3.056 0 00-3.048-3.047zM12.19 24.533a3.056 3.056 0 01-3.047-3.047 3.056 3.056 0 013.047-3.048 3.056 3.056 0 013.048 3.048 3.056 3.056 0 01-3.048 3.047z"})})}function ru({children:e,className:t,...n}){return(0,b.jsx)("button",{type:"button",className:x(["react-flow__controls-button",t]),...n,children:e})}let rc=e=>({isInteractive:e.nodesDraggable||e.nodesConnectable||e.elementsSelectable,minZoomReached:e.transform[2]<=e.minZoom,maxZoomReached:e.transform[2]>=e.maxZoom,ariaLabelConfig:e.ariaLabelConfig});function rh({style:e,showZoom:t=!0,showFitView:n=!0,showInteractive:o=!0,fitViewOptions:r,onZoomIn:i,onZoomOut:a,onFitView:s,onInteractiveChange:l,className:d,children:u,position:c="bottom-left",orientation:h="vertical","aria-label":f}
1){let g=t3(),{isInteractive:p,minZoomReached:m,maxZoomReached:y,ariaLabelConfig:v}=t2(rc,tq),{zoomIn:w,zoomOut:E,fitView:_}=nj();return(0,b.jsxs)(nn,{className:x(["react-flow__controls","horizontal"===h?"horizontal":"vertical",d]),position:c,style:e,"data-testid":"rf__controls","aria-label":f??v["controls.ariaLabel"],children:[t&&(0,b.jsxs)(b.Fragment,{children:[(0,b.jsx)(ru,{onClick:()=>{w(),i?.()},className:"react-flow__controls-zoomin",title:v["controls.zoomIn.ariaLabel"],"aria-label":v["controls.zoomIn.ariaLabel"],disabled:y,children:(0,b.jsx)(ri,{})}),(0,b.jsx)(ru,{onClick:()=>{E(),a?.()},className:"react-flow__controls-zoomout",title:v["controls.zoomOut.ariaLabel"],"aria-label":v["controls.zoomOut.ariaLabel"],disabled:m,children:(0,b.jsx)(ra,{})})]}),n&&(0,b.jsx)(ru,{className:"react-flow__controls-fitview",onClick:()=>{_(r),s?.()},title:v["controls.fitView.ariaLabel"],"aria-label":v["controls.fitView.ariaLabel"],children:(0,b.jsx)(rs,{})}),o&&(0,b.jsx)(ru,{className:"react-flow__controls-interactive",onClick:()=>{g.setState({nodesDraggable:!p,nodesConnectable:!p,elementsSelectable:!p}),l?.(!p)},title:v["controls.interactive.ariaLabel"],"aria-label":v["controls.interactive.ariaLabel"],children:p?(0,b.jsx)(rd,{}):(0,b.jsx)(rl,{})}),u]})}rh.displayName="Controls";let rf=(0,w.memo)(rh),rg=(0,w.memo)(function({id:e,x:t,y:n,width:o,height:r,style:i,color:a,strokeColor:s,strokeWidth:l,className:d,borderRadius:u,shapeRendering:c,selected:h,onClick:f}){let{background:g,backgroundColor:p}=i||{};return(0,b.jsx)("rect",{className:x(["react-flow__minimap-node",{selected:h},d]),x:t,y:n,rx:u,ry:u,width:o,height:r,style:{fill:a||g||p,stroke:s,strokeWidth:l},shapeRendering:c,onClick:f?t=>f(t,e):void 0})}),rp=e=>e.nodes.map(e=>e.id),rm=e=>e instanceof Function?e:()=>e,ry=(0,w.memo)(function({id:e,nodeColorFunc:t,nodeStrokeColorFunc:n,nodeClassNameFunc:o,nodeBorderRadius:r,nodeStrokeWidth:i,shapeRendering:a,NodeComponent:s,onClick:l}){let{node:d,x:u,y:c,width:h,height:f}=t2(t=>{let n=t.nodeLookup.get(e);if(!n)return{node:void 0,x:0,y:0,width:0,height:0};let o=n.internals.userNode,{x:r,y:i}=n.internals.positionAbsolute,{width:a,height:s}=eS(o);return{node:o,x:r,y:i,width:a,height:s}},tq);return d&&!d.hidden&&eC(d)?(0,b.jsx)(s,{x:u,y:c,width:h,height:f,style:d.style,selected:!!d.selected,className:o(d),color:t(d),borderRadius:r,strokeColor:n(d),strokeWidth:i,shapeRendering:a,onClick:l,id:d.id}):null});var rv=(0,w.memo)(function({nodeStrokeColor:e,nodeColor:t,nodeClassName:n="",nodeBorderRadius:o=5,nodeStrokeWidth:r,nodeComponent:i=rg,onClick:a}){let s=t2(rp,tq),l=rm(t),d=rm(e),u=rm(n),c="u"<typeof window||window.chrome?"crispEdges":"geometricPrecision";return(0,b.jsx)(b.Fragment,{children:s.map(e=>(0,b.jsx)(ry,{id:e,nodeColorFunc:l,nodeStrokeColorFunc:d,nodeClassNameFunc:u,nodeBorderRadius:o,nodeStrokeWidth:r,NodeComponent:i,onClick:a,shapeRendering:c},e))})});let rb=e=>!e.hidden,rw=e=>{let t={x:-e.transform[0]/e.transform[2],y:-e.transform[1]/e.transform[2],width:e.width/e.transform[2],height:e.height/e.transform[2]},n=!1;for(let t of e.nodeLookup.values())if(!t.hidden){n=!0;break}return{viewBB:t,boundingRect:n?ec(Z(e.nodeLookup,{filter:rb}),t):t,rfId:e.rfId,panZoom:e.panZoom,translateExtent:e.translateExtent,flowWidth:e.width,flowHeight:e.height,ariaLabelConfig:e.ariaLabelConfig}},rx=(e,t)=>e.x===t.x&&e.y===t.y&&e.width===t.width&&e.height===t.height,rE=(e,t)=>rx(e.viewBB,t.viewBB)&&rx(e.boundingRect,t.boundingRect)&&e.rfId===t.rfId&&e.panZoom===t.panZoom&&e.translateExtent===t.translateExtent&&e.flowWidth===t.flowWidth&&e.flowHeight===t.flowHeight&&e.ariaLabelConfig===t.ariaLabelConfig;function r_({style:e,className:t,nodeStrokeColor:n,nodeColor:o,nodeClassName:r="",nodeBorderRadius:i=5,nodeStrokeWidth:a,nodeComponent:s,bgColor:l,maskColor:d,maskStrokeColor:u,maskStrokeWidth:c,position:h="bottom-right",onClick:f,onNodeClick:g,pannable:p=!1,zoomable:m=!1,ariaLabel:y,inversePan:v,zoomStep:E=1,offsetScale:_=5}){let S=t3(),C=(0,w.useRef)(null),{boundingRect:M,panZoom:k,viewBB:N,rfId:L,translateExtent:A,flowWidth:O,flowHeight:I,ariaLabelConfig:P}=t2(rw,rE),T=e?.width??200,R=e?.height??150,D=Math.max(M.width/T,M.height/R),j=D*T,$=D*R,B=_*D,F=M.x-(j-M.width)/2-B,H=M.y-($-M.height)/2-B,z=j+2*B,V=$+2*B,K=`react-flow__minimap-desc-${L}`,X=(0,w.useRef)(0),Y=(0,w.useRef)();X.current=D,(0,w.useEffect)(()=>{let e=S.getState().panZoom;if(C.current&&e)return Y.current=tC({domNode:C.current,panZoom:e,getTransform:()=>S.getState().transform,getViewScale:()=>X.current}),()=>{Y.current?.destroy()}},[k]),(0,w.useEffect)(()=>{Y.current?.update({translateExtent:A,width:O,height:I,inversePan:v,pannable:p,zoomStep:E,zoomable:m})},[p,m,v,E,A,O,I]);let G=f?e=>{let[t,n]=Y.current?.pointer(e)||[0,0];f(e,{x:t,y:n})}:void 0,W=(0,w.useCallback)((e,t)=>{let n=S.getState().nodeLookup.get(t).internals.userNode;g?.(e,n)},[g]),U=y??P["minimap.ariaLabel"];return(0,b.jsx)(nn,{position:h,style:{...e,"--xy-minimap-background-color-props":"string"==typeof l?l:void 0,"--xy-minimap-mask-background-color-props":"string"==typeof d?d:void 0,"--xy-minimap-mask-stroke-color-props":"string"==typeof u?u:void 0,"--xy-minimap-mask-stroke-width-props":"number"==typeof c?c*D:void 0,"--xy-minimap-node-background-color-props":"string"==typeof o?o:void 0,"--xy-minimap-node-stroke-color-props":"string"==typeof n?n:void 0,"--xy-minimap-node-stroke-width-props":"number"==typeof a?a:void 0},className:x(["react-flow__minimap",t]),"data-testid":"rf__minimap",children:(0,b.jsxs)("svg",{width:T,height:R,viewBox:`${F} ${H} ${z} ${V}`,className:"react-flow__minimap-svg",role:"img","aria-labelledby":K,ref:C,onClick:G,children:[U&&(0,b.jsx)("title",{id:K,children:U}),(0,b.jsx)(rv,{onClick:g?W:void 0,nodeColor:o,nodeStrokeColor:n,nodeBorderRadius:i,nodeClassName:r,no
1deStrokeWidth:a,nodeComponent:s}),(0,b.jsx)("path",{className:"react-flow__minimap-mask",d:`M${F-B},${H-B}h${z+2*B}v${V+2*B}h${-z-2*B}z 2 M${N.x},${N.y}h${N.width}v${N.height}h${-N.width}z`,fillRule:"evenodd",pointerEvents:"none"})]})})}r_.displayName="MiniMap";let rS=(0,w.memo)(r_),rC={[p.Line]:"right",[p.Handle]:"bottom-right"};(0,w.memo)(function({nodeId:e,position:t,variant:n=p.Handle,className:o,style:r,children:i,color:a,minWidth:s=10,minHeight:l=10,maxWidth:d=Number.MAX_VALUE,maxHeight:u=Number.MAX_VALUE,keepAspectRatio:c=!1,resizeDirection:h,autoScale:f=!0,shouldResize:g,onResizeStart:m,onResize:y,onResizeEnd:v}){let E,_=nJ(),S="string"==typeof e?e:_,C=t3(),M=(0,w.useRef)(null),k=n===p.Handle,N=t2((0,w.useCallback)((E=k&&f,e=>E?`${Math.max(1/e.transform[2],1)}`:void 0),[k,f]),tq),L=(0,w.useRef)(null),A=t??rC[n];(0,w.useEffect)(()=>{if(M.current&&S)return L.current||(L.current=tz({domNode:M.current,nodeId:S,getStoreItems:()=>{let{nodeLookup:e,transform:t,snapGrid:n,snapToGrid:o,nodeOrigin:r,domNode:i}=C.getState();
2return{nodeLookup:e,transform:t,snapGrid:n,snapToGrid:o,nodeOrigin:r,paneDomNode:i}},onChange:(e,t)=>{let{triggerNodeChanges:n,nodeLookup:o,parentLookup:r,nodeOrigin:i}=C.getState(),a=[],s={x:e.x,y:e.y},l=o.get(S);if(l&&l.expandParent&&l.parentId){let t=l.origin??i,n=e.width??l.measured.width??0,d=e.height??l.measured.height??0,u=tc([{id:l.id,parentId:l.parentId,rect:{width:n,height:d,...eM({x:e.x??l.position.x,y:e.y??l.position.y},{width:n,height:d},l.parentId,o,t)}}],o,r,i);a.push(...u),s.x=e.x?Math.max(t[0]*n,e.x):void 0,s.y=e.y?Math.max(t[1]*d,e.y):void 0}if(void 0!==s.x&&void 0!==s.y){let e={id:S,type:"position",position:{...s}};a.push(e)}if(void 0!==e.width&&void 0!==e.height){let t={id:S,type:"dimensions",resizing:!0,setAttributes:!h||("horizontal"===h?"width":"height"),dimensions:{width:e.width,height:e.height}};a.push(t)}for(let e of t){let t={...e,type:"position"};a.push(t)}n(a)},onEnd:({width:e,height:t})=>{C.getState().triggerNodeChanges([{id:S,type:"dimensions",resizing:!1,dimensions:{width:e,height:t}}])}})),L.current.update({controlPosition:A,boundaries:{minWidth:s,minHeight:l,maxWidth:d,maxHeight:u},keepAspectRatio:c,resizeDirection:h,onResizeStart:m,onResize:y,onResizeEnd:v,shouldResize:g}),()=>{L.current?.destroy()}},[A,s,l,d,u,c,m,y,v,g]);let O=A.split("-");return(0,b.jsx)("div",{className:x(["react-flow__resize-control","nodrag",...O,n,o]),ref:M,style:{...r,scale:N,...a&&{[k?"backgroundColor":"borderColor"]:a}},children:i})}),e.s(["Background",()=>rr,"BackgroundVariant",()=>m,"BaseEdge",()=>og,"Controls",()=>rf,"EdgeLabelRenderer",()=>o4,"Handle",()=>n5,"MiniMap",()=>rS,"ReactFlow",()=>o3,"ReactFlowProvider",()=>o0,"addEdge",()=>nA,"applyEdgeChanges",()=>nS,"applyNodeChanges",()=>n_,"useInternalNode",()=>o7,"useReactFlow",()=>nj,"useViewport",()=>o6],154548);let rM={Client:{CDN:["API_CALL"],GeoDns:["API_CALL"],ApiGateway:["API_CALL"],RateLimiter:["API_CALL"],LoadBalancer:["API_CALL"],Service:["API_CALL"]},GeoDns:{CDN:["API_CALL"],ApiGateway:["API_CALL"],RateLimiter:["API_CALL"],LoadBalancer:["API_CALL"],Service:["API_CALL"]},CDN:{ApiGateway:["API_CALL"],RateLimiter:["API_CALL"],LoadBalancer:["API_CALL"],Service:["API_CALL"]},ApiGateway:{RateLimiter:["API_CALL"],LoadBalancer:["API_CALL"],Service:["API_CALL"]},RateLimiter:{LoadBalancer:["API_CALL"],Service:["API_CALL"]},LoadBalancer:{Service:["API_CALL"],WebSocketService:["API_CALL"]},Service:{Service:["API_CALL"],Cache:["CACHE_CALL"],Database:["DB_CALL"],ObjectStorage:["API_CALL"],WebSocketService:["API_CALL"],EventStream:["KAFKA_EVENT"]},WebSocketService:{Service:["API_CALL"],Database:["DB_CALL"],EventStream:["KAFKA_EVENT"]},EventStream:{Service:["KAFKA_EVENT"],Worker:["KAFKA_EVENT"],StreamProcessor:["KAFKA_EVENT"]},StreamProcessor:{EventStream:["KAFKA_EVENT"],Service:["API_CALL"],Database:["DB_CALL"]},Worker:{Service:["API_CALL"],Database:["DB_CALL"],ObjectStorage:["API_CALL"],EventStream:["KAFKA_EVENT"],Cache:["CACHE_CALL"],WebSocketService:["API_CALL"]}};function rk(e,t){return rM[e]?.[t]??[]}function rN(e){return rM[e]??{}}function rL(e,t){let n=rk(e,t);return n.length>0?n[0]:void 0}let rA={API_CALL:"var(--edge-api)",KAFKA_EVENT:"var(--edge-kafka)",DB_CALL:"var(--edge-db)",CACHE_CALL:"var(--edge-cache)"};function rO(e){if(!e?.edgeType||!e.metadata)return"";let{edgeType:t,metadata:n}=e;if("API_CALL"===t&&"method"in n)return`${n.method??"GET"} ${n.path??"/"}`;if("KAFKA_EVENT"===t&&"topic_name"in n)return n.event_name||n.topic_name||"event";if("DB_CALL"===t&&"operation"in n){let e=`${n.operation??"SELECT"} ${n.table_name??""}`.trim();return n.key_field&&"INSERT"!==n.operation?`${e} by ${n.key_field}`:e}if("CACHE_CALL"===t&&"operation"in n){let e=`${n.operation??"GET"} ${n.key_pattern??""}`.trim();return"SET"===n.operation&&null!=n.ttl_seconds?`${e} TTL ${n.ttl_seconds}s`:e}return t.replace(/_/g," ").toLowerCase()}function rI(e){return e?rA[e]??"var(--border)":"var(--border)"}e.s(["EDGE_TYPE_BADGES",0,{API_CALL:"API",KAFKA_EVENT:"KAFKA",DB_CALL:"DB",CACHE_CALL:"CACHE"},"EDGE_TYPE_COLORS",0,rA,"getAllowedEdgeTypes",()=>rk,"getEdgeDisplayLabel",()=>rO,"getEdgeStrokeColor",()=>rI,"getValidTargets",()=>rN,"inferEdgeType",()=>rL],567716);let rP={API_CALL:{dropdownLabel:"Target Endpoint",getContracts:e=>(e.endpoints??[]).map(e=>({label:`${e.method} ${e.path}`,value:e.id,detail:e.summary??"",description:e.description})),buildMetadata(e,t){let n=(t.endpoints??[]).find(t=>
2t.id===e);if(n)return{method:n.method,path:n.path,summary:n.summary,request_fields:n.requestBody}},resolveBindingId(e,t){let n=(t.endpoints??[]).find(t=>t.method===e.method&&t.path===e.path);return n?.id??""},emptyHint:e=>`No endpoints defined on ${e}. Select the Service node and add an endpoint.`},KAFKA_EVENT:{dropdownLabel:"Topic",getContracts:e=>(e.topics??[]).map(e=>({label:e.name||"(unnamed)",value:e.id,detail:`${e.schema?.length??0} fields`,description:e.description})),buildMetadata(e,t){let n=(t.topics??[]).find(t=>t.id===e);if(n)return{topic_name:n.name,event_name:n.name,payload_fields:n.schema??[],partition_key:n.partitionKey}},resolveBindingId(e,t){let n=(t.topics??[]).find(t=>t.name===e.topic_name);return n?.id??""},emptyHint:e=>`No topics defined on ${e}. Select the Kafka node and add a topic.`},DB_CALL:{dropdownLabel:"Table",getContracts:e=>(e.tables??[]).map(e=>({label:e.name||"(unnamed)",value:e.id,detail:`${e.primaryKey?`PK: ${e.primaryKey} \u00b7 `:""}${e.columns?.length??0} cols`,description:e.description})),buildMetadata(e,t){let n=(t.tables??[]).find(t=>t.id===e);if(n)return{operation:"SELECT",table_name:n.name,fields:n.columns,key_field:n.primaryKey}},resolveBindingId(e,t){let n=(t.tables??[]).find(t=>t.name===e.table_name);return n?.id??""},emptyHint:e=>`No tables defined on ${e}. Select the Database node and add a table.`,operations:["SELECT","INSERT","UPDATE","DELETE"],operationHint:"SQL operation for this connection (SELECT, INSERT, UPDATE, DELETE)."},CACHE_CALL:{dropdownLabel:"Cache Space",getContracts:e=>(e.cacheSpaces??[]).map(e=>({label:e.name||"(unnamed)",value:e.id,detail:e.keyPattern?`Key: ${e.keyPattern}`:`${e.valueFields?.length??0} fields`,description:e.description})),buildMetadata(e,t){let n=(t.cacheSpaces??[]).find(t=>t.id===e);if(n)return{operation:"GET",key_pattern:n.keyPattern,ttl_seconds:n.defaultTtlSeconds,value_fields:n.valueFields}},resolveBindingId(e,t){let n=(t.cacheSpaces??[]).find(t=>t.keyPattern===e.key_pattern||t.name===e.name);return n?.id??""},emptyHint:e=>`No cache spaces defined on ${e}. Select the Cache node and add a cache space.`,operations:["GET","SET","DELETE","INVALIDATE"],operationHint:"How this edge accesses the cache (GET to read, SET to write)."}},rT={ObjectStorage:{API_CALL:{dropdownLabel:"Bucket",getContracts:e=>(e.buckets??[]).map(e=>({label:e.name||"(unnamed)",value:e.id,detail:e.keyPattern?`Key: ${e.keyPattern}`:`${e.objectFields?.length??0} fields`,description:e.description})),buildMetadata(e,t){let n=(t.buckets??[]).find(t=>t.id===e);if(n)return{operation:"PUT",bucket_name:n.name,key_pattern:n.keyPattern,object_fields:n.objectFields,average_object_size_mb:n.averageObjectSizeMb}},resolveBindingId(e,t){let n=(t.buckets??[]).find(t=>t.name===e.bucket_name||""!==t.keyPattern&&t.keyPattern===e.key_pattern);return n?.id??""},emptyHint:e=>`No buckets defined on ${e}. Select the Object Storage node and add a bucket.`,operations:["PUT","GET","DELETE","LIST","HEAD"],operationHint:"How this edge accesses the bucket (PUT to write, GET to read).",getFields(e,t){let n=t.buckets??[];return n.find(t=>t.id===e)?.objectFields??[]}}}},rR={ApiGateway:e=>`${e} is a gateway â it forwards to whatever it routes to. Nothing downstream of it defines a contract yet; connect it to a Service and add an endpoint there.`,CDN:e=>`${e} is a cache in front of an origin. Nothing downstream of it defines a contract yet; connect it to its origin Service or Object Storage first.`,GeoDns:e=>`${e} resolves to a region â the contract belongs to what it points at. Nothing downstream of it defines one yet.`,LoadBalancer:e=>`${e} distributes to its pool. Nothing downstream of it defines a contract yet; connect it to a Service and add an endpoint there.`,RateLimiter:e=>`${e} admits or rejects, then forwards. Nothing downstream of it defines a contract yet; connect it to a Service and add an endpoint there.`,StreamProcessor:e=>`${e} consumes from a stream rather than being called. Bind the upstream Event Stream edge to a topic instead.`,WebSocketService:e=>`${e} holds long-lived connections rather than serving request/response endpoints. Its behaviour comes from Performance Mode parameters.`,Worker:e=>`${e} consumes from a queue rather than being called. Bind the upstream Event Stream edge to a topic instead.`};function rD(e,t){if(!e)return;let n=rP[e];if(!t)return n;let o=rT[t]?.[e];if(o)return o;let r=rR[t];return r&&n?{...n,emptyHint:r}:n}let rj={Client:{getContracts:e=>(e.requests??[]).map((e,t)=>({label:e.label||`Request ${t+1}`,value:e.id,detail:`${Object.keys(e.payload).length} fields`})),getFields(e,t){let n=(t.requests??[]).find(t=>
2t.id===e);return n?Object.entries(n.payload).map(([e,t])=>({name:e,field_type:"number"==typeof t?Number.isInteger(t)?"integer":"number":"boolean"==typeof t?"boolean":Array.isArray(t)?"array":"object"==typeof t&&null!==t?"object":"string",required:!0,description:"From client request payload"})):[]}},Service:{getContracts:e=>(e.endpoints??[]).map(e=>({label:`${e.method} ${e.path}`,value:e.id,detail:e.summary??`${(e.requestBody??[]).length} fields`,description:e.description})),getFields(e,t){let n=t.endpoints??[];return n.find(t=>t.id===e)?.requestBody??[]}},EventStream:{getContracts:e=>(e.topics??[]).map(e=>({label:e.name||"(unnamed)",value:e.id,detail:`${e.schema?.length??0} fields`})),getFields(e,t){let n=t.topics??[];return n.find(t=>t.id===e)?.schema??[]}},Database:{getContracts:e=>(e.tables??[]).map(e=>({label:e.name||"(unnamed)",value:e.id,detail:`${e.columns?.length??0} cols`})),getFields(e,t){let n=t.tables??[];return n.find(t=>t.id===e)?.columns??[]}},Cache:{getContracts:e=>(e.cacheSpaces??[]).map(e=>({label:e.name||"(unnamed)",value:e.id,detail:e.keyPattern||`${e.valueFields.length} fields`})),getFields(e,t){let n=t.cacheSpaces??[];return n.find(t=>t.id===e)?.valueFields??[]}}};function r$(e,t,n,o){let r=rD(e,o);if(!r)return[];let i=r.resolveBindingId(t,n);if(!i)return[];if(r.getFields)return r.getFields(i,n);let a=rB[e];if(!a)return[];let s=rj[a];return s?.getFields(i,n)??[]}let rB={API_CALL:"Service",KAFKA_EVENT:"EventStream",DB_CALL:"Database",CACHE_CALL:"Cache"},rF={validate:{label:"Validate",description:"Reject requests that fail validation rules",color:"var(--error)",badge:"V",suggestedOrder:0},map:{label:"Map",description:"Transform input DTO to internal DTO",color:"var(--accent-blue)",badge:"M",suggestedOrder:1},filter:{label:"Filter",description:"Conditionally drop or reject requests",color:"var(--warning)",badge:"F",suggestedOrder:2},enrich:{label:"Enrich",description:"Compute and add fields to the DTO",color:"var(--accent-purple)",badge:"E",suggestedOrder:3},persist:{label:"Persist",description:"Query database â insert, select, update, or delete",color:"var(--success)",badge:"P",suggestedOrder:4},cache:{label:"Cache",description:"Cache operation â get, set, or delete cached data",color:"var(--edge-cache)",badge:"$",suggestedOrder:4.5},audit:{label:"Audit",description:"Create and publish a Kafka event",color:"var(--accent-cyan)",badge:"A",suggestedOrder:5},response:{label:"Response",description:"Configure the API response returned to caller",color:"#56d4dd",badge:"R",suggestedOrder:6}},rH=new Set(["is_null","is_not_null","is_empty","is_not_empty"]);function rz(e,t){let n=rF[e],o={id:`ps-${Date.now().toString(36)}-${Math.random().toString(36).slice(2,7)}`,type:e,label:n.label,order:t};switch(e){case"validate":return{...o,type:"validate",rules:[]};case"map":return{...o,type:"map",targetDto:"",mappings:[]};case"filter":return{...o,type:"filter",rules:[]};case"enrich":return{...o,type:"enrich",targetEdgeId:"",rules:[]};case"persist":return{...o,type:"persist",targetEdgeId:"",entityName:"",queryType:"insert",tableName:"",queryConditions:[],fieldMappings:[]};case"cache":return{...o,type:"cache",targetEdgeId:"",cacheSpace:"",cacheOperation:"get",keyField:"id"};case"audit":return{...o,type:"audit",targetEdgeId:"",eventName:"",payloadFields:[]};case"response":return{...o,type:"response",statusCode:200,bodyFields:[]}}}function rV(e,t){let n=t.toLowerCase().replace(/[^a-z0-9]+/g,"_").replace(/(^_|_$)/g,"");switch(e){case"Service":return{endpoints:[{id:`ep_${n}_default`,method:"GET",path:`/api/v1/${n}`,summary:`Default ${t} endpoint`,description:`Auto-generated endpoint for ${t}. Configure method, path, and request body as needed.`,requestBody:[]}]};case"Database":return{tables:[{id:`tbl_${n}_default`,name:`${n}_records`,description:`Default table for ${t}. Rename and add columns as needed.`,columns:[{name:"id",field_type:"string",required:!0,description:"Primary key"}],primaryKey:"id"}]};case"Cache":return{cacheSpaces:[{id:`cs_${n}_default`,name:`${n}_cache`,description:`Default cache space for ${t}. Configure key pattern and TTL as needed.`,keyPattern:`${n}:{id}`,valueFields:[],defaultTtlSeconds:3600}]};case"EventStream":return{topics:[{id:`t_${n}_default`,name:`${n}_events`,description:`Default topic for ${t}. Configure schema and partition key as needed.`,schema:[],partitionKey:"id"}]};case"ObjectStorage":return{buckets:[{id:`bkt_${n}_default`,name:`${n}-bucket`,description:`Default bucket for ${t}. Configure key pattern and object size as needed.`,keyPattern:`${n}/{id}`,objectFields:[],averageObjectSizeMb:1}]};default:return{}}}e.s(["COMPARISON_OPERATOR_OPTIONS",0,[{value:"eq",label:"Equals",shortLabel:"=="},{value:"neq",label:"Not Equals",shortLabel:"!="},{value:"gt",label:"Greater Than",shortLabel:">"},{value:"lt",label:"Less Than",shortLabel:"<"},{value:"gte",label:"Greater or Equal",shortLabel:">="},{value:"lte",label:"Less or Equal",shortLabel:"<="},{value:"is_null",label:"Is Null",shortLabel:"null"},{value:"is_not_null",label:"Is Not Null",shortLabel:"!null"},{value:"is_empty",label:"Is Empty",shortLabel:"empty"},{value:"is_not_empty",label:"Is Not Empty",shortLabel:"!empty"},{value:"contains",label:"Contains",shortLabel:"â"},{value:"starts_with",label:"Starts With",shortLabel:"^"},{value:"ends_with",label:"Ends With",shortLabel:"$"},{value:"regex",label:"Matches Regex",shortLabel:"/â¦/"},{value:"in",label:"In List",shortLabel:"â"}],"CONTRACT_DEFAULTS",0,{DEFAULT_HTTP_METHOD:"POST",DEFAULT_PATH:"/",DEFAULT_PRIMARY_KEY:"id",DEFAULT_TTL_
2SECONDS:3600,DEFAULT_FIELD_TYPE:"string"},"CONTRACT_EDITOR_REGISTRY",0,{Service:{configKey:"endpoints",sectionLabel:"API Endpoints",accentColor:"var(--edge-api)",idPrefix:"ep"},EventStream:{configKey:"topics",sectionLabel:"Topics",accentColor:"var(--edge-kafka)",idPrefix:"t"},Database:{configKey:"tables",sectionLabel:"Tables",accentColor:"var(--edge-db)",idPrefix:"tbl"},Cache:{configKey:"cacheSpaces",sectionLabel:"Cache Spaces",accentColor:"var(--edge-cache)",idPrefix:"cs"},ObjectStorage:{configKey:"buckets",sectionLabel:"Buckets",accentColor:"var(--edge-api)",idPrefix:"bkt"}},"EDGE_BINDING_REGISTRY",0,rP,"FIELD_TYPE_OPTIONS",0,[{value:"string",label:"String",shortLabel:"string"},{value:"number",label:"Number",shortLabel:"number"},{value:"integer",label:"Integer",shortLabel:"integer"},{value:"boolean",label:"Boolean",shortLabel:"boolean"},{value:"object",label:"Object",shortLabel:"object"},{value:"array",label:"Array",shortLabel:"array"}],"HTTP_METHODS",0,["GET","POST","PUT","DELETE","PATCH"],"HTTP_METHOD_COLORS",0,{GET:"var(--success)",POST:"var(--accent-blue)",PUT:"var(--warning)",DELETE:"var(--error)",PATCH:"var(--accent-purple)"},"PARAM_CATEGORY_CONFIG",0,{scaling:{label:"Scaling",accentColor:"var(--accent-purple)",order:0},capacity:{label:"Capacity",accentColor:"var(--accent-blue)",order:1},latency:{label:"Latency",accentColor:"var(--warning)",order:2},throughput:{label:"Throughput",accentColor:"var(--success)",order:3},behavior:{label:"Behavior",accentColor:"var(--accent-cyan)",order:4},storage:{label:"Storage",accentColor:"var(--error)",order:5},monitoring:{label:"Monitoring",accentColor:"var(--text-muted)",order:6}},"PROCESSING_STEP_REGISTRY",0,rF,"SOURCE_CONTRACT_REGISTRY",0,rj,"TARGET_BINDING_OVERRIDES",0,rT,"UNARY_OPERATORS",0,rH,"VALIDATION_MESSAGES",0,{JSON_MUST_BE_ARRAY:"Must be a JSON array",JSON_ITEMS_MUST_BE_OBJECTS:"Each item must be a JSON object",JSON_INVALID:"Invalid JSON"},"createDefaultStep",()=>rz,"getTargetFieldsForEdge",()=>r$,"resolveEdgeBinding",()=>rD,"seedDefaultContracts",()=>rV],284958);let rK=["endpoints","topics","tables","cacheSpaces","buckets"],rX=["operation"];function rY(e,t,n,o,r,i){if("KAFKA_EVENT"===e&&n?.componentType!=="EventStream")return t;let a=rD(e,n?.componentType);if(e&&a&&n&&o&&r&&i&&0===a.getContracts(n.config??{}).length){let t=function e(t,n,o,r,i){if(i.has(t))return[];i.add(t);let a=[];for(let s of o.filter(e=>e.source===t)){if(i.has(s.target))continue;let t=r.find(e=>e.id===s.target);if(!t)continue;let l=t.data,d=rD(n,l.componentType);d&&d.getContracts(l.config??{}).length>0?(i.add(s.target),a.push(l)):a.push(...e(s.target,n,o,r,i))}return a}(i,e,o,r,new Set);if(1===t.length)return t[0];if(t.length>1){let n={};for(let e of t){let t=e.config??{};for(let e of rK){let o=t[e];if(o&&o.length>0){let t=n[e]??[];n[e]=[...t,...o]}}}return{label:"(aggregated)",componentType:(t.find(t=>!rT[t.componentType]?.[e])??t[0]).componentType,config:n}}}return n}function rG(e,t){return e===t||!!e&&!!t&&JSON.stringify(e)===JSON.stringify(t)}function rW(e,t,n){let o=[];for(let r of n){let i=r.data?.edgeType,a=r.data?.metadata;if(!i||!a)continue;let s=rY(i,e.find(e=>e.id===r.source)?.data,e.find(e=>e.id===r.target)?.data,n,e,r.target);if(!s)continue;let l=rD(i,s.componentType);if(!l)continue;let d=l.resolveBindingId(a,s.config??{});if(!d)continue;let u=rY(i,t.find(e=>e.id===r.source)?.data,t.find(e=>e.id===r.target)?.data,n,t,r.target);if(!u)continue;let c=l.buildMetadata(d,s.config??{}),h=l.buildMetadata(d,u.config??{});if(rG(c,h))continue;if(!h){o.push({edgeId:r.id,metadata:void 0});continue}let f={...h};for(let e of rX)e in a&&e in f&&(f[e]=a[e]);rG(f,a)||o.push({edgeId:r.id,metadata:f})}return o}function rU(e,t,n,o){if(e)return o?o.client_to_region[n]??25:25;if(t===n)return o?.intra_region_ms??1;if(o){for(let e of o.cross_region)if(e.from===t&&e.to===n||e.from===n&&e.to===t)return e.latency_ms;return o.default_cross_region_ms}return 100}e.s(["CONTRACT_CONFIG_KEYS",0,rK,"resolveContractSource",()=>rY,"resyncEdgeContractMetadata",()=>rW],98637);let rZ={intra_az_ms:.3,intra_region_ms:1,default_cross_region_ms:120,cross_region:[{from:"us-east-1",to:"us-west-2",latency_ms:62},{from:"us-east-1",to:"eu-west-1",latency_ms:75},{from:"us-east-1",to:"eu-central-1",latency_ms:85},{from:"us-east-1",to:"ap-southeast-1",latency_ms:210},{from:"us-east-1",to:"ap-northeast-1",latency_ms:155},{from:"us-west-2",to:"eu-west-1",latency_ms:135},{from:"us-west-2",to:"eu-central-1",latency_ms:145},{from:"us-west-2",to:"ap-southeast-1",latency_ms:170},{from:"us-west-2",to:"ap-northeast-1",latency_ms:105},{from:"eu-west-1",to:"eu-central-1",latency_ms:25},{from:"eu-west-1",to:"ap-southeast-1",latency_ms:175},{from:"eu-west-1",to:"ap-northeast-1",latency_ms:220},{from:"eu-central-1",to:"ap-southeast-1",latency_ms:160},{from:"eu-central-1",to:"ap-northeast-1",latency_ms:210},{from:"ap-southeast-1",to:"ap-northeast-1",latency_ms:70}],client_to_region:{"us-east-1":20,"us-west-2":55,"eu-west-1":85,"eu-central-1":95,"ap-southeast-1":220,"ap-northeast-1":165}},rq={intra_az_ms:.3,intra_region_ms:.8,default_cross_region_ms:120,cross_region:[{from:"us-central1",to:"us-east1",latency_ms:30},{from:"us-central1",to:"europe-west1",latency_ms:100},{from:"us-central1",to:"europe-west3",latency_ms:110},{from:"us-central1",to:"asia-east1",latency_ms:170},{from:"us-central1",to:"asia-northeast1",latency_ms:130},{from:"us-east1",to:"europe-west1",latency_ms:80},{from:"us-east1",to:"europe-west3",latency_ms:90},{from:"us-east1",to:"asia-east1",latency_ms:200},{from:"us-east1",to:"asia-northeast1",latency_ms:160},{from:"europe-west1",to:"europe-west3",latency_ms:10},{from:"europe-west1",to:"asia-east1",latency_ms:180},{from:"europe-west1",to:"asia-northeast1",latency_ms:225},{from:"europe-west3",to:"asia-east1",latency_ms:165},{from:"europe-west3",to:"asia-northeast1",latency_ms:215},{from:"asia-east1",to:"asia-northeast1",latency_ms:45}],client_to_region:{"us-central1":25,"us-east1":20,"europe-west1":90,"europe-west3":100,"asia-east1":180,"asia-northeast1":160}},rQ={intra_az_ms:.3,intra_region_ms:1,default_cross_region_ms:120,cross_region:[{from:"eastus",to:"westus2",latency_ms:60},{from:"eastus",to:"westeurope",latency_ms:80},{from:"eastus",to:"northeurope",latency_ms:75},{from:"eastus",to:"southeastasia",latency_ms:215},{from:"eastus",to:"japaneast",latency_ms:160},{from:"westus2",to:"westeurope",latency_ms:140},{from:"westus2",to:"northeurope",latency_ms:135},{from:"westus2",to:"southeastasia",latency_ms:175},{from:"westus2",to:"japaneast",latency_ms:110},{from:"westeurope",to:"northeurope",latency_ms:15},{from:"westeurope",to:"southeastasia",latency_ms:170},{from:"westeurope",to:"japaneast",latency_ms:220},{from:"northeurope",to:"southeastasia",latency_ms:180},{from:"northeurope",to:"japaneast",latency_ms:225},{from:"southeastasia",to:"japaneast",latency_ms:68}],client_to_region:{eastus:20,westus2:55,westeurope:85,northeurope:80,southeastasia:220,japaneast:165}},rJ={intra_az_ms:.5,intra_region_ms:1,default_cross_region_ms:100,cross_region:[],client_to_region:{default:25}};function r0(e){switch(e){case"aws":return rZ;case"gcp":return rq;case"azure":return rQ;default:return rJ}}e.s(["AWS_DEFAULT_LATENCY_MATRIX",0,rZ,"getDefaultLatencyMatrix",()=>r0],158829);var r1=Object.defineProperty,r2={},r3={Graph:()=>iM,alg:()=>ii};for(var r5 in r3)r1(r2,r5,{get:r3[r5],enumerable:!0});var r4=Object.defineProperty,r8=(e,t)=>
2{for(var n in t)r4(e,n,{get:t[n],enumerable:!0})},r6=class{constructor(e){this._isDirected=!0,this._isMultigraph=!1,this._isCompound=!1,this._nodes={},this._in={},this._preds={},this._out={},this._sucs={},this._edgeObjs={},this._edgeLabels={},this._nodeCount=0,this._edgeCount=0,this._defaultNodeLabelFn=()=>{},this._defaultEdgeLabelFn=()=>{},e&&(this._isDirected=!("directed"in e)||e.directed,this._isMultigraph="multigraph"in e&&e.multigraph,this._isCompound="compound"in e&&e.compound),this._isCompound&&(this._parent={},this._children={},this._children["\0"]={})}isDirected(){return this._isDirected}isMultigraph(){return this._isMultigraph}isCompound(){return this._isCompound}setGraph(e){return this._label=e,this}graph(){return this._label}setDefaultNodeLabel(e){return"function"!=typeof e?this._defaultNodeLabelFn=()=>e:this._defaultNodeLabelFn=e,this}nodeCount(){return this._nodeCount}nodes(){return Object.keys(this._nodes)}sources(){return this.nodes().filter(e=>0===Object.keys(this._in[e]).length)}sinks(){return this.nodes().filter(e=>0===Object.keys(this._out[e]).length)}setNodes(e,t){return e.forEach(e=>{void 0!==t?this.setNode(e,t):this.setNode(e)}),this}setNode(e,t){return e in this._nodes?arguments.length>1&&(this._nodes[e]=t):(this._nodes[e]=arguments.length>
21?t:this._defaultNodeLabelFn(e),this._isCompound&&(this._parent[e]="\0",this._children[e]={},this._children["\0"][e]=!0),this._in[e]={},this._preds[e]={},this._out[e]={},this._sucs[e]={},++this._nodeCount),this}node(e){return this._nodes[e]}hasNode(e){return e in this._nodes}removeNode(e){if(e in this._nodes){let t=e=>this.removeEdge(this._edgeObjs[e]);delete this._nodes[e],this._isCompound&&(this._removeFromParentsChildList(e),delete this._parent[e],this.children(e).forEach(e=>{this.setParent(e)}),delete this._children[e]),Object.keys(this._in[e]).forEach(t),delete this._in[e],delete this._preds[e],Object.keys(this._out[e]).forEach(t),delete this._out[e],delete this._sucs[e],--this._nodeCount}return this}setParent(e,t){if(!this._isCompound)throw Error("Cannot set parent in a non-compound graph");if(void 0===t)t="\0";else{t+="";for(let n=t;void 0!==n;n=this.parent(n))if(n===e)throw Error("Setting "+t+" as parent of "+e+" would create a cycle");this.setNode(t)}return this.setNode(e),this._removeFromParentsChildList(e),this._parent[e]=t,this._children[t][e]=!0,this}parent(e){if(this._isCompound){let t=this._parent[e];if("\0"!==t)return t}}children(e="\0"){if(this._isCompound){let t=this._children[e];if(t)return Object.keys(t)}else{if("\0"===e)return this.nodes();this.hasNode(e)}return[]}predecessors(e){let t=this._preds[e];if(t)return Object.keys(t)}successors(e){let t=this._sucs[e];if(t)return Object.keys(t)}neighbors(e){let t=this.predecessors(e);if(t){let n=new Set(t),o=this.successors(e);if(o)for(let e of o)n.add(e);return Array.from(n.values())}}isLeaf(e){var t;let n;return(null!=(t=null==(n=this.isDirected()?this.successors(e):this.neighbors(e))?void 0:n.length)?t:0)===0}filterNodes(e){let t=new this.constructor({directed:this._isDirected,multigraph:this._isMultigraph,compound:this._isCompound});t.setGraph(this.graph()),Object.entries(this._nodes).forEach(([n,o])=>{e(n)&&t.setNode(n,o)}),Object.values(this._edgeObjs).forEach(e=>{t.hasNode(e.v)&&t.hasNode(e.w)&&t.setEdge(e,this.edge(e))});let n={},o=e=>{let r=this.parent(e);return!r||t.hasNode(r)?(n[e]=r,r):r in n?n[r]:o(r)};return this._isCompound&&t.nodes().forEach(e=>t.setParent(e,o(e))),t}setDefaultEdgeLabel(e){return"function"!=typeof e?this._defaultEdgeLabelFn=()=>e:this._defaultEdgeLabelFn=e,this}edgeCount(){return this._edgeCount}edges(){return Object.values(this._edgeObjs)}setPath(e,t){return e.reduce((e,n)=>(void 0!==t?this.setEdge(e,n,t):this.setEdge(e,n),n)),this}setEdge(e,t,n,o){let r,i,a,s,l=!1;"object"==typeof e&&null!==e&&"v"in e?(r=e.v,i=e.w,a=e.name,2==arguments.length&&(s=t,l=!0)):(r=e,i=t,a=o,arguments.length>2&&(s=n,l=!0)),r=""+r,i=""+i,void 0!==a&&(a=""+a);let d=ie(this._isDirected,r,i,a);if(d in this._edgeLabels)return l&&(this._edgeLabels[d]=s),this;if(void 0!==a&&!this._isMultigraph)throw Error("Cannot set a named edge when isMultigraph = false");this.setNode(r),this.setNode(i),this._edgeLabels[d]=l?s:this._defaultEdgeLabelFn(r,i,a);let u=function(e,t,n,o){let r=""+t,i=""+n;if(!e&&r>i){let e=r;r=i,i=e}let a={v:r,w:i};return o&&(a.name=o),a}(this._isDirected,r,i,a);return r=u.v,i=u.w,Object.freeze(u),this._edgeObjs[d]=u,r7(this._preds[i],r),r7(this._sucs[r],i),this._in[i][d]=u,this._out[r][d]=u,this._edgeCount++,this}edge(e,t,n){let o=1==arguments.length?it(this._isDirected,e):ie(this._isDirected,e,t,n);return this._edgeLabels[o]}edgeAsObj(e,t,n){let o=1==arguments.length?this.edge(e):this.edge(e,t,n);return"object"!=typeof o||null===o?{label:o}:o}hasEdge(e,t,n){return(1==arguments.length?it(this._isDirected,e):ie(this._isDirected,e,t,n))in this._edgeLabels}removeEdge(e,t,n){let o=1==arguments.length?it(this._isDirected,e):ie(this._isDirected,e,t,n),r=this._edgeObjs[o];if(r){let e=r.v,t=r.w;delete this._edgeLabels[o],delete this._edgeObjs[o],r9(this._preds[t],e),r9(this._sucs[e],t),delete this._in[t][o],delete this._out[e][o],this._edgeCount--}return this}inEdges(e,t){return this.isDirected()?this.filterEdges(this._in[e],e,t):this.nodeEdges(e,t)}outEdges(e,t){return this.isDirected()?this.filterEdges(this._out[e],e,t):this.nodeEdges(e,t)}nodeEdges(e,t){if(e in this._nodes)return this.filterEdges({...this._in[e],...this._out[e]},e,t)}_removeFromParentsChildList(e){delete this._children[this._parent[e]][e]}
2filterEdges(e,t,n){if(!e)return;let o=Object.values(e);return n?o.filter(e=>e.v===t&&e.w===n||e.v===n&&e.w===t):o}};function r7(e,t){e[t]?e[t]++:e[t]=1}function r9(e,t){void 0===e[t]||--e[t]||delete e[t]}function ie(e,t,n,o){let r=""+t,i=""+n;if(!e&&r>i){let e=r;r=i,i=e}return r+"\x01"+i+"\x01"+(void 0===o?"\0":o)}function it(e,t){return ie(e,t.v,t.w,t.name)}function io(e){var t,n;let o={options:{directed:e.isDirected(),multigraph:e.isMultigraph(),compound:e.isCompound()},nodes:(t=e).nodes().map(e=>{let n=t.node(e),o=t.parent(e),r={v:e};return void 0!==n&&(r.value=n),void 0!==o&&(r.parent=o),r}),edges:(n=e).edges().map(e=>{let t=n.edge(e),o={v:e.v,w:e.w};return void 0!==e.name&&(o.name=e.name),void 0!==t&&(o.value=t),o})},r=e.graph();return void 0!==r&&(o.value=structuredClone(r)),o}function ir(e){let t=new r6(e.options);return void 0!==e.value&&t.setGraph(e.value),e.nodes.forEach(e=>{t.setNode(e.v,e.value),e.parent&&t.setParent(e.v,e.parent)}),e.edges.forEach(e=>{t.setEdge({v:e.v,w:e.w,name:e.name},e.value)}),t}r8({},{read:()=>ir,write:()=>io});var ii={};r8(ii,{CycleException:()=>iv,bellmanFord:()=>is,components:()=>il,dijkstra:()=>ic,dijkstraAll:()=>ih,findCycles:()=>ip,floydWarshall:()=>iy,isAcyclic:()=>iw,postorder:()=>iE,preorder:()=>i_,prim:()=>iS,shortestPaths:()=>iC,tarjan:()=>ig,topsort:()=>ib});var ia=()=>1;function is(e,t,n,o){return function(e,t,n,o){let r={},i,a=0,s=e.nodes(),l=function(e){let t=r[e.v],o=r[e.w];if(!t||!o)return;let a=n(e);t.distance+a<o.distance&&(r[e.w]={distance:t.distance+a,predecessor:e.v},i=!0)},d=function(){s.forEach(function(e){o(e).forEach(function(t){let n=t.v===e?t.v:t.w,o=n===t.v?t.w:t.v;l({v:n,w:o})})})};s.forEach(function(e){r[e]={distance:e===t?0:1/0,predecessor:""}});let u=s.length;for(let e=1;e<u&&(i=!1,a++,d(),i);e++);if(a===u-1&&(i=!1,d(),i))throw Error("The graph contains a negative weight cycle");return r}(e,String(t),n||ia,o||function(t){var n;return null!=(n=e.outEdges(t))?n:[]})}function il(e){let t={},n=[],o;return e.nodes().forEach(function(r){o=[],function n(r){var i,a;r in t||(t[r]=!0,o.push(r),null==(i=e.successors(r))||i.forEach(n),null==(a=e.predecessors(r))||a.forEach(n))}(r),o.length&&n.push(o)}),n}var id=class{constructor(){this._arr=[],this._keyIndices={}}size(){return this._arr.length}keys(){return this._arr.map(e=>e.key)}has(e){return e in this._keyIndices}priority(e){let t=this._keyIndices[e];if(void 0!==t)return this._arr[t].priority}min(){if(0===this.size())throw Error("Queue underflow");return this._arr[0].key}add(e,t){let n=this._keyIndices,o=String(e);if(!(o in n)){let e=this._arr,r=e.length;return n[o]=r,e.push({key:o,priority:t}),this._decrease(r),!0}return!1}removeMin(){if(0===this.size())throw Error("Queue underflow");this._swap(0,this._arr.length-1);let e=this._arr.pop();return delete this._keyIndices[e.key],this._heapify(0),e.key}decrease(e,t){let n=this._keyIndices[e];if(void 0===n)throw Error(`Key not found: ${e}`);let o=this._arr[n].priority;if(t>o)throw Error(`New priority is greater than current priority. Key: ${e} Old: ${o} New: ${t}`);this._arr[n].priority=t,this._decrease(n)}_heapify(e){let t=this._arr,n=2*e,o=n+1,r=e;n<t.length&&(r=t[n].priority<t[r].priority?n:r,o<t.length&&(r=t[o].priority<t[r].priority?o:r),r!==e&&(this._swap(e,r),this._heapify(r)))}_decrease(e){let t=this._arr,n=t[e].priority,o;for(;0!==e&&!(t[o=e>>1].priority<n);)this._swap(e,o),e=o}_swap(e,t){let n=this._arr,o=this._keyIndices,r=n[e],i=n[t];n[e]=i,n[t]=r,o[i.key]=e,o[r.key]=t}},iu=()=>1;function ic(e,t,n,o){return function(e,t,n,o){let r={},i=new id,a,s,l=function(e){let t=e.v!==a?e.v:e.w,o=r[t];if(!o)return;let l=n(e),d=s.distance+l;if(l<0)throw Error("dijkstra does not allow negative edge weights. Bad edge: "+e+" Weight: "+l);d<o.distance&&(o.distance=d,o.predecessor=a,i.decrease(t,d))};for(e.nodes().forEach(function(e){let n=e===t?0:1/0;r[e]={distance:n,predecessor:""},i.add(e,n)});i.size()>0;){let e=r[a=i.removeMin()];if(!e||e.distance===1/0)break;s=e,o(a).forEach(l)}return r}(e,String(t),n||iu,o||function(t){var n;return null!=(n=e.outEdges(t))?n:[]})}
2function ih(e,t,n){return e.nodes().reduce(function(o,r){return o[r]=ic(e,r,t,n),o},{})}function ig(e){let t=0,n=[],o={},r=[];return e.nodes().forEach(function(i){i in o||function i(a){var s;let l=o[a]={onStack:!0,lowlink:t,index:t++};if(n.push(a),null==(s=e.successors(a))||s.forEach(function(e){if(e in o){let t=o[e];null!=t&&t.onStack&&(l.lowlink=Math.min(l.lowlink,t.index))}else{i(e);let t=o[e];t&&(l.lowlink=Math.min(l.lowlink,t.lowlink))}}),l.lowlink===l.index){let e=[],t;do{let r=o[t=n.pop()];r&&(r.onStack=!1),e.push(t)}while(a!==t)r.push(e)}}(i)}),r}function ip(e){return ig(e).filter(function(t){var n;let o=t[0];return!!o&&(t.length>1||1===t.length&&(null!=(n=e.outEdges(o,o))?n:[]).length>0)})}var im=()=>1;function iy(e,t,n){var o,r,i;let a,s;return o=e,r=t||im,i=n||function(t){var n;return null!=(n=e.outEdges(t))?n:[]},a={},(s=o.nodes()).forEach(function(e){let t={};a[e]=t,t[e]={distance:0,predecessor:""},s.forEach(function(n){e!==n&&(t[n]={distance:1/0,predecessor:""})}),i(e).forEach(function(n){let o=n.v===e?n.w:n.v,i=r(n);t[o]={distance:i,predecessor:e}})}),s.forEach(function(e){let t=a[e];t&&s.forEach(function(n){let o=a[n];o&&s.forEach(function(n){let r=o[e],i=t[n],a=o[n];if(r&&i&&a){let e=r.distance+i.distance;e<a.distance&&(a.distance=e,a.predecessor=i.predecessor)}})})}),a}var iv=class extends Error{constructor(e){super(e),this.name="CycleException"}};function ib(e){let t={},n={},o=[];if(e.sinks().forEach(function r(i){var a;if(i in n)throw new iv;i in t||(n[i]=!0,t[i]=!0,null==(a=e.predecessors(i))||a.forEach(r),delete n[i],o.push(i))}),Object.keys(t).length!==e.nodeCount())throw new iv;return o}function iw(e){try{ib(e)}catch(e){if(e instanceof iv)return!1;throw e}return!0}function ix(e,t,n){var o,r,i;let a,s;return o=t,r=function(e,t){return e.push(t),e},i=[],Array.isArray(o)||(o=[o]),a=t=>{var n;return null!=(n=e.isDirected()?e.successors(t):e.neighbors(t))?n:[]},s={},o.forEach(function(t){if(!e.hasNode(t))throw Error("Graph does not have node: "+t);i=function e(t,n,o,r,i,a,s){return n in r||(r[n]=!0,o||(s=a(s,n)),i(n).forEach(function(n){s=e(t,n,o,r,i,a,s)}),o&&(s=a(s,n))),s}(e,t,"post"===n,s,a,r,i)}),i}function iE(e,t){return ix(e,t,"post")}function i_(e,t){return ix(e,t,"pre")}function iS(e,t){var n;let o=new r6,r={},i=new id,a;function s(e){let n=e.v===a?e.w:e.v,o=i.priority(n);if(void 0!==o){let s=t(e);s<o&&(r[n]=a,i.decrease(n,s))}}if(0===e.nodeCount())return o;e.nodes().forEach(function(e){i.add(e,1/0),o.setNode(e)});let l=e.nodes()[0];void 0!==l&&i.decrease(l,0);let d=!1;for(;i.size()>0;){if((a=i.removeMin())in r)o.setEdge(a,r[a]);else{if(d)throw Error("Input graph is not connected: "+e);d=!0}null==(n=e.nodeEdges(a))||n.forEach(s)}return o}function iC(e,t,n,o){return function(e,t,n,o){if(void 0===n)return ic(e,t,n,o);let r=!1,i=e.nodes();for(let a=0;a<i.length;a++){let s=i[a];if(void 0===s)continue;let l=o(s);for(let e=0;e<l.length;e++){let t=l[e];if(!t)continue;let o=t.v===s?t.v:t.w,i=o===t.v?t.w:t.v;0>n({v:o,w:i})&&(r=!0)}if(r)return is(e,t,n,o)}return ic(e,t,n,o)}(e,t,n,null!=o?o:t=>{var n;return null!=(n=e.outEdges(t))?n:[]})}var iM=r6;function ik(e,t,n,o){let r=o;for(;e.hasNode(r);)r=o+""+ ++iR;return n.dummy=t,e.setNode(r,n),r}function iN(e){let t=new iM({multigraph:e.isMultigraph()}).setGraph(e.graph());return e.nodes().forEach(n=>{e.children(n).length||t.setNode(n,e.node(n))}
2),e.edges().forEach(n=>{t.setEdge(n,e.edge(n))}),t}function iL(e,t){let n,o,r=e.x,i=e.y,a=t.x-r,s=t.y-i,l=e.width/2,d=e.height/2;if(!a&&!s)throw Error("Not possible to find intersection inside of the rectangle");return Math.abs(s)*l>Math.abs(a)*d?(s<0&&(d=-d),n=d*a/s,o=d):(a<0&&(l=-l),n=l,o=l*s/a),{x:r+n,y:i+o}}function iA(e){let t=iD(iP(e)+1).map(()=>[]);return e.nodes().forEach(n=>{let o=e.node(n),r=o.rank;void 0!==r&&(t[r]||(t[r]=[]),t[r][o.order]=n)}),t}function iO(e,t,n,o){let r={width:0,height:0};return arguments.length>=4&&(r.rank=n,r.order=o),ik(e,"border",r,t)}function iI(e,t){return t.length>65535?e(...(function(e,t=65535){let n=[];for(let o=0;o<e.length;o+=t){let r=e.slice(o,o+t);n.push(r)}return n})(t).map(t=>e(...t))):e(...t)}function iP(e){return iI(Math.max,e.nodes().map(t=>{let n=e.node(t).rank;return void 0===n?5e-324:n}))}function iT(e,t){return t()}var iR=0;function iD(e,t,n=1){null==t&&(t=e,e=0);let o=e=>e<t;n<0&&(o=e=>t<e);let r=[];for(let t=e;o(t);t+=n)r.push(t);return r}function ij(e,t){let n={};for(let o of t)void 0!==e[o]&&(n[o]=e[o]);return n}function i$(e,t){let n;return n="string"==typeof t?e=>e[t]:t,Object.entries(e).reduce((e,[t,o])=>(e[t]=n(o,t),e),{})}function iB(e,t,n){var o,r,i,a,s,l;if(!(e&&t&&n&&"edge"===t.dummy&&"edge"===n.dummy&&t.edgeObj&&n.edgeObj&&e[t.edgeObj.v]&&e[n.edgeObj.v]&&e[t.edgeObj.w]&&e[n.edgeObj.w]))return 0;let d=!0;t.edgeObj.w===n.edgeObj.w&&(d=!1);let u=d?null!=(r=null==(o=e[t.edgeObj.v])?void 0:o.rank)?r:NaN:null!=(a=null==(i=e[t.edgeObj.w])?void 0:i.rank)?a:NaN,c=Object.entries(e).find(e=>{var n,o;return(null==(n=e[1].edgeObj)?void 0:n.v)===t.edgeObj.v&&(null==(o=e[1].edgeObj)?void 0:o.w)===t.edgeObj.w&&e[1].rank===u}),h=Object.entries(e).find(e=>{var t,o;return(null==(t=e[1].edgeObj)?void 0:t.v)===n.edgeObj.v&&(null==(o=e[1].edgeObj)?void 0:o.w)===n.edgeObj.w&&e[1].rank===u});if(!c||!h)return 0;let f=null!=(s=c[1].order)?s:NaN,g=null!=(l=h[1].order)?l:NaN;return isNaN(f-g)?0:f-g}var iF=class{constructor(){((e,t,n)=>{let o;return(o="symbol"!=typeof t?t+"":t)in e?r1(e,o,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[o]=n})(this,"_sentinel");let e={};e._next=e._prev=e,this._sentinel=e}dequeue(){let e=this._sentinel,t=e._prev;if(t!==e)return iH(t),t}enqueue(e){let t=this._sentinel;e._prev&&e._next&&iH(e),e._next=t._next,t._next._prev=e,t._next=e,e._prev=t}toString(){let e=[],t=this._sentinel,n=t._prev;for(;n!==t;)e.push(JSON.stringify(n,iz)),n=n._prev;return"["+e.join(", ")+"]"}};function iH(e){e._prev._next=e._next,e._next._prev=e._prev,delete e._next,delete e._prev}function iz(e,t){if("_next"!==e&&"_prev"!==e)return t}var iV=()=>1;function iK(e,t,n,o,r){let i=[],a=r?i:void 0;return(e.inEdges(o.v)||[]).forEach(o=>{let a=e.edge(o),s=e.node(o.v);r&&i.push({v:o.v,w:o.w}),s.out-=a,iX(t,n,s)}),(e.outEdges(o.v)||[]).forEach(o=>{let r=e.edge(o),i=o.w,a=e.node(i);a.in-=r,iX(t,n,a)}),e.removeNode(o.v),a}function iX(e,t,n){var o,r,i;n.out?n.in?null==(i=e[n.out-n.in+t])||i.enqueue(n):null==(r=e[e.length-1])||r.enqueue(n):null==(o=e[0])||o.enqueue(n)}function iY(e){let t={};e.sources().forEach(function n(o){let r=e.node(o);if(Object.hasOwn(t,o))return r.rank;t[o]=!0;let i=e.outEdges(o),a=iI(Math.min,i?i.map(t=>null==t?1/0:n(t.w)-e.edge(t).minlen):[]);return a===1/0&&(a=0),r.rank=a})}function iG(e,t){return e.node(t.w).rank-e.node(t.v).rank-e.edge(t).minlen}var iW=function(e){var t,n,o,r;let i,a,s=new iM({directed:!1}),l=e.nodes();if(0===l.length)throw Error("Graph must have at least one node");let d=l[0],u=e.nodeCount();for(s.setNode(d,{});t=s,n=e,t.nodes().forEach(function e(o){let r=n.nodeEdges(o);r&&r.forEach(r=>{let i=r.v,a=o===i?r.w:i;t.hasNode(a)||iG(n,r)||(t.setNode(a,{}),t.setEdge(o,a,{}),e(a))})}),t.nodeCount()<u&&(o=s,i=(r=e).edges().reduce((e,t)=>{let n=1/0;return o.hasNode(t.v)!==o.hasNode(t.w)&&(n=iG(r,t)),n<e[0]?[n,t]:e},[1/0,null])[1]);
2)a=s.hasNode(i.v)?iG(e,i):-iG(e,i),function(e,t,n){e.nodes().forEach(e=>t.node(e).rank+=n)}(s,e,a);return s},{preorder:iU,postorder:iZ}=ii;function iq(e){var t;let n,o,r;t=e,r=new iM().setGraph(t.graph()),t.nodes().forEach(e=>r.setNode(e,t.node(e))),t.edges().forEach(e=>{let n=r.edge(e.v,e.w)||{weight:0,minlen:1},o=t.edge(e);r.setEdge(e.v,e.w,{weight:n.weight+o.weight,minlen:Math.max(n.minlen,o.minlen)})}),iY(e=r);let i=iW(e);for(i0(i),iQ(i,e);n=i1(i);)o=i2(i,e,n),i3(i,e,n,o)}function iQ(e,t){let n=iZ(e,e.nodes());(n=n.slice(0,n.length-1)).forEach(n=>{var o,r,i;let a;return o=e,r=t,i=n,a=o.node(i).parent,void(o.edge(i,a).cutvalue=iJ(o,r,i))})}function iJ(e,t,n){let o=e.node(n).parent,r=!0,i=t.edge(n,o),a=0;i||(r=!1,i=t.edge(o,n)),a=i.weight;let s=t.nodeEdges(n);return s&&s.forEach(i=>{let s=i.v===n,l=s?i.w:i.v;if(l!==o){var d,u,c;let o=s===r,h=t.edge(i).weight;if(a+=o?h:-h,d=e,u=n,c=l,d.hasEdge(u,c)){let t=e.edge(n,l).cutvalue;a+=o?-t:t}}}),a}function i0(e,t){arguments.length<2&&(t=e.nodes()[0]),function e(t,n,o,r,i){let a=o,s=t.node(r);n[r]=!0;let l=t.neighbors(r);return l&&l.forEach(i=>{Object.hasOwn(n,i)||(o=e(t,n,o,i,r))}),s.low=a,s.lim=o++,i?s.parent=i:delete s.parent,o}(e,{},1,t)}function i1(e){return e.edges().find(t=>e.edge(t).cutvalue<0)}function i2(e,t,n){let o=n.v,r=n.w;t.hasEdge(o,r)||(o=n.w,r=n.v);let i=e.node(o),a=e.node(r),s=i,l=!1;return i.lim>a.lim&&(s=a,l=!0),t.edges().filter(t=>l===i5(e,e.node(t.v),s)&&l!==i5(e,e.node(t.w),s)).reduce((e,n)=>iG(t,n)<iG(t,e)?n:e)}function i3(e,t,n,o){let r=n.v,i=n.w;e.removeEdge(r,i),e.setEdge(o.v,o.w,{}),i0(e),iQ(e,t),function(e,t){let n=e.nodes().find(t=>!e.node(t).parent);if(!n)return;let o=iU(e,[n]);(o=o.slice(1)).forEach(n=>{let o=e.node(n).parent,r=t.edge(n,o),i=!1;r||(r=t.edge(o,n),i=!0),t.node(n).rank=t.node(o).rank+(i?r.minlen:-r.minlen)})}(e,t)}function i5(e,t,n){return n.low<=t.lim&&t.lim<=n.lim}iq.initLowLimValues=i0,iq.initCutValues=iQ,iq.calcCutValue=iJ,iq.leaveEdge=i1,iq.enterEdge=i2,iq.exchangeEdges=i3;function i4(e,t,n,o,r,i){let a=r[t][i-1],s=ik(e,"border",{width:0,height:0,rank:i,borderType:t},n);r[t][i]=s,e.setParent(s,o),a&&e.setEdge(a,s,{weight:1})}function i8(e){e.nodes().forEach(t=>
2i6(e.node(t))),e.edges().forEach(t=>i6(e.edge(t)))}function i6(e){let t=e.width;e.width=e.height,e.height=t}function i7(e){e.y=-e.y}function i9(e){let t=e.x;e.x=e.y,e.y=t}function ae(e,t,n){let o;for(;t.length&&(o=t[t.length-1]).i<=n;)t.pop(),e.push(o.vs),n++;return n}function at(e,t,n){let o=new Map,r=(e,t)=>{o.has(e)||o.set(e,[]),o.get(e).push(t)};for(let t of e.nodes()){let n=e.node(t);if("number"==typeof n.rank&&r(n.rank,t),"number"==typeof n.minRank&&"number"==typeof n.maxRank)for(let e=n.minRank;e<=n.maxRank;e++)e!==n.rank&&r(e,t)}return t.map(function(t){var r;let i,a;return r=o.get(t)||[],i=function(e){let t;for(;e.hasNode(t="_root"+ ++iR););return t}(e),a=new iM({compound:!0}).setGraph({root:i}).setDefaultNodeLabel(t=>e.node(t)),r.forEach(o=>{let r=e.node(o),s=e.parent(o);if(r.rank===t||r.minRank<=t&&t<=r.maxRank){a.setNode(o),a.setParent(o,s||i);let l=e[n](o);l&&l.forEach(t=>{let n=t.v===o?t.w:t.v,r=a.edge(n,o),i=void 0!==r?r.weight:0;a.setEdge(n,o,{weight:e.edge(t).weight+i})}),Object.hasOwn(r,"minRank")&&a.setNode(o,{borderLeft:r.borderLeft[t],borderRight:r.borderRight[t]})}}),a})}function an(e,t){Object.values(t).forEach(t=>t.forEach((t,n)=>e.node(t).order=n))}function ao(e,t,n){if(t>n){let e=t;t=n,n=e}let o=e[t];o||(e[t]=o={}),o[n]=!0}function ar(e,t,n){var o;if(!n)return!1;let r=null==(o=t.node(e))?void 0:o.edgeObj;if(!r||t.node(e).edgeLabel.reversed)return!1;let i=n.indexOf(null==r?void 0:r.v),a=n.indexOf(null==r?void 0:r.w);return -1!==i&&-1!==a&&i===(a+1)%n.length||i===(a-1)%n.length}var ai=new WeakMap;function aa(e,t,n){let o=t;for(;void 0!==o;){let t=e.parent(o);if(t===n)return o;o=t}}function as(e,t,n,o=null){var r,i;let a=(null==n?void 0:n.useDynamic)!==!1,s=a&&null!=(r=null==o?void 0:o.graph)?r:null,l=a&&null!=(i=null==o?void 0:o.rawNodes)?i:null;t(" makeSpaceForEdgeLabels",()=>{var t;let n;
2return n=(t=e).graph(),void(n.ranksep/=2,t.edges().forEach(e=>{var o;let r=t.edge(e);r.minlen*=2,"c"!==(null!=(o=r.labelpos)?o:"r").toLowerCase()&&("TB"===n.rankdir||"BT"===n.rankdir?r.width+=r.labeloffset:r.height+=r.labeloffset)}))}),t(" removeSelfEdges",()=>{var t;(t=e).edges().forEach(e=>{if(e.v===e.w){let n=t.node(e.v);n.selfEdges||(n.selfEdges=[]),n.selfEdges.push({e:e,label:t.edge(e)}),t.removeEdge(e)}})}),t(" acyclic",()=>{var t,n,o;let r,i,a,l;("greedy"===e.graph().acyclicer?function(e,t){var n,o;let r,i,a,s,l;if(1>=e.nodeCount())return[];let d=(n=e,o=t||iV,r=new iM,i=0,a=0,n.nodes().forEach(e=>{r.setNode(e,{v:e,in:0,out:0})}),n.edges().forEach(e=>{let t=r.edge(e.v,e.w)||0,n=o(e);r.setEdge(e.v,e.w,t+n);let s=r.node(e.v),l=r.node(e.w);a=Math.max(a,s.out+=n),i=Math.max(i,l.in+=n)}),s=(function(e){let t=[];for(let n=0;n<e;n++)t.push(n);return t})(a+i+3).map(()=>new iF),l=i+1,r.nodes().forEach(e=>{iX(s,l,r.node(e))}),{graph:r,buckets:s,zeroIdx:l});return(function(e,t,n){var o;let r=[],i=t[t.length-1],a=t[0],s;for(;e.nodeCount();){for(;s=a.dequeue();)iK(e,t,n,s);for(;s=i.dequeue();)iK(e,t,n,s);if(e.nodeCount()){for(let i=t.length-2;i>0;--i)if(s=null==(o=t[i])?void 0:o.dequeue()){r=r.concat(iK(e,t,n,s,!0)||[]);break}}}return r})(d.graph,d.buckets,d.zeroIdx).flatMap(t=>e.outEdges(t.v,t.w)||[])}(e,(t=e,e=>t.edge(e).weight)):(n=e,o=null!=s?s:null,r=[],i={},a={},l=function e(t){Object.hasOwn(a,t)||(a[t]=!0,i[t]=!0,n.outEdges(t).forEach(t=>{Object.hasOwn(i,t.w)?r.push(t):e(t.w)}),delete i[t])},o&&"function"==typeof o.node&&(l=function e(t){var s;Object.hasOwn(a,t)||(a[t]=!0,i[t]=!0,null==(s=n.outEdges(t))||s.forEach(a=>{var s,l,d,u,c;let h;Object.hasOwn(i,a.w)||(null==(s=o.node(t))?void 0:s.rank)>(null==(l=o.node(a.w))?void 0:l.rank)&&(d=n,u=a.w,c=a,h=new Set,function e(t){var n;if(d.sources().includes(t))return!0;for(let o of(h.add(t),null!=(n=d.inEdges(t))?n:[]))if((o.v!==c.v||o.w!==c.w)&&!h.has(o.v)&&e(o.v))return!0;return!1}(u))?r.push(a):e(a.w)}),delete i[t])}),n.sources().forEach(l),n.nodes().forEach(l),r)).forEach(t=>{let n=e.edge(t);e.removeEdge(t),n.forwardName=t.name,n.reversed=!0,e.setEdge(t.w,t.v,n,"rev"+ ++iR)})}),t(" nestingGraph.run",()=>{var t,n;let o,r,i,a,s,l;return o=ik(e,"root",{},"_root"),a=2*(i=iI(Math.max,Object.values((l={},(t=e).children("\0").forEach(e=>(function e(n,o){let r=t.children(n);r&&r.length&&r.forEach(t=>e(t,o+1)),l[n]=o}
2)(e,1)),r=l)))-1)+1,e.graph().nestingRoot=o,e.edges().forEach(t=>e.edge(t).minlen*=a),s=(n=e).edges().reduce((e,t)=>e+n.edge(t).weight,0)+1,void(e.children("\0").forEach(t=>{!function e(t,n,o,r,i,a,s){var l;let d=t.children(s);if(!d.length){s!==n&&t.setEdge(n,s,{weight:0,minlen:o});return}let u=iO(t,"_bt"),c=iO(t,"_bb"),h=t.node(s);t.setParent(u,s),h.borderTop=u,t.setParent(c,s),h.borderBottom=c,d.forEach(l=>{var d;e(t,n,o,r,i,a,l);let h=t.node(l),f=h.borderTop?h.borderTop:l,g=h.borderBottom?h.borderBottom:l,p=h.borderTop?r:2*r,m=f!==g?1:i-(null!=(d=a[s])?d:0)+1;t.setEdge(u,f,{weight:p,minlen:m,nestingEdge:!0}),t.setEdge(g,c,{weight:p,minlen:m,nestingEdge:!0})}),t.parent(s)||t.setEdge(n,u,{weight:0,minlen:i+(null!=(l=a[s])?l:0)})}(e,o,a,s,i,r,t)}),e.graph().nodeRankFactor=a)}),t(" rank",()=>(function(e){let t=e.graph().ranker;if("function"==typeof t)return t(e);switch(t){case"network-simplex":default:iq(e);break;case"tight-tree":var n;iY(n=e),iW(n);break;case"longest-path":iY(e);case"none":}})(iN(e))),t(" injectEdgeLabelProxies",()=>{var t;
2(t=e).edges().forEach(e=>{let n=t.edge(e);if(n.width&&n.height){let n=t.node(e.v),o={rank:(t.node(e.w).rank-n.rank)/2+n.rank,e:e};ik(t,"edge-proxy",o,"_ep")}})}),t(" removeEmptyRanks",()=>{let t,n,o,r;return t=iI(Math.min,e.nodes().map(t=>e.node(t).rank).filter(e=>void 0!==e)),n=[],e.nodes().forEach(o=>{let r=e.node(o).rank-t;n[r]||(n[r]=[]),n[r].push(o)}),o=0,r=e.graph().nodeRankFactor,void Array.from(n).forEach((t,n)=>{void 0===t&&n%r!=0?--o:void 0!==t&&o&&t.forEach(t=>e.node(t).rank+=o)})}),t(" nestingGraph.cleanup",()=>{let t;return t=e.graph(),void(e.removeNode(t.nestingRoot),delete t.nestingRoot,e.edges().forEach(t=>{e.edge(t).nestingEdge&&e.removeEdge(t)}))}),t(" normalizeRanks",()=>{let t;return t=iI(Math.min,e.nodes().map(t=>{let n=e.node(t).rank;return void 0===n?Number.MAX_VALUE:n})),void e.nodes().forEach(n=>{let o=e.node(n);Object.hasOwn(o,"rank")&&(o.rank-=t)})}),t(" assignRankMinMax",()=>{var t;let n;return n=0,void((t=e).nodes().forEach(e=>{let o=t.node(e);o.borderTop&&(o.minRank=t.node(o.borderTop).rank,o.maxRank=t.node(o.borderBottom).rank,n=Math.max(n,o.maxRank))}),t.graph().maxRank=n)}),t(" removeEdgeLabelProxies",()=>{var t;(t=e).nodes().forEach(e=>{let n=t.node(e);"edge-proxy"===n.dummy&&(t.edge(n.e).labelRank=n.rank,t.removeNode(e))})}),t(" normalize.run",()=>
2{e.graph().dummyChains=[],e.edges().forEach(t=>(function(e,t){let n,o,r,i=t.v,a=e.node(i).rank,s=t.w,l=e.node(s).rank,d=t.name,u=e.edge(t),c=u.labelRank;if(l!==a+1){for(e.removeEdge(t),r=0,++a;a<l;++r,++a)u.points=[],n=ik(e,"edge",o={width:0,height:0,edgeLabel:u,edgeObj:t,rank:a},"_d"),a===c&&(o.width=u.width,o.height=u.height,o.dummy="edge-label",o.labelpos=u.labelpos),e.setEdge(i,n,{weight:u.weight},d),0===r&&e.graph().dummyChains.push(n),i=n;e.setEdge(i,s,{weight:u.weight},d)}})(e,t))}),t(" parentDummyChains",()=>{var t,n;let o,r,i,a;return i=(o={},r=0,(n=t=e).children("\0").forEach(function e(t){let i=r;n.children(t).forEach(e),o[t]={low:i,lim:r++}}),o),void(Array.isArray((a=t.graph()).dummyChains)&&a.dummyChains.forEach(e=>{let n=t.node(e),o=n.edgeObj,r=function(e,t,n,o){let r=[],i=[],a=Math.min(t[n].low,t[o].low),s=Math.max(t[n].lim,t[o].lim),l;l=n;do r.push(l=e.parent(l));while(l&&(t[l].low>a||s>t[l].lim))let d=l,u=o;for(;(u=e.parent(u))!==d;)i.push(u);return{path:r.concat(i.reverse()),lca:d}}(t,i,o.v,o.w),a=r.path,s=r.lca,l=0,d=a[0],u=!0;for(;e!==o.w;){if(n=t.node(e),u){for(;(d=a[l])!==s&&t.node(d).maxRank<n.rank;)l++;d===s&&(u=!1)}if(!u){for(;l<a.length-1&&t.node(a[l+1]).minRank<=n.rank;)l++;d=a[l]}void 0!==d&&t.setParent(e,d),e=t.successors(e)[0]}}))}),t(" addBorderSegments",()=>{var t;(t=e).children("\0").forEach(function e(n){let o=t.children(n),r=t.node(n);if(o.length&&o.forEach(e),r&&Object.hasOwn(r,"minRank")){r.borderLeft=[],r.borderRight=[];for(let e=r.minRank,o=r.maxRank+1;e<o;++e)i4(t,"borderLeft","_bl",n,r,e),i4(t,"borderRight","_br",n,r,e)}})}),t(" order",()=>(function e(t,n={},o=null){if("function"==typeof n.customOrder)return void n.customOrder(t,e);let r=iP(t),i=at(t,iD(1,r+1),"inEdges"),a=at(t,iD(r-1,-1,-1),"outEdges"),s=function(e,t=null){let n={},o=e.nodes().filter(t=>!e.children(t).length),r=iD(iI(Math.max,o.map(t=>e.node(t).rank))+1).map(()=>[]);return o.sort((t,n)=>e.node(t).rank-e.node(n).rank).forEach(function o(i){if(n[i])return;n[i]=!0,r[e.node(i).rank].push(i);let a=e.successors(i);a&&[...a].sort((n,o)=>{var r,i;return r=n,i=o,iB(t,e.node(r),e.node(i))}).forEach(o)}),r}(t,o);if(an(t,s),n.disableOptimalOrderHeuristic)return;let l=1/0,d,u=n.constraints||[];for(let e=0,n=0;n<4;++e,++n){(function(e,t,n,o){let r=!0,i=new iM;e.forEach(function(e){var a;let s,l;n.forEach(e=>i.setEdge(e.left,e.right));let d=e.graph().root,{result:u,usedBias:c}=function e(t,n,o,r,i){var a,s,l,d,u,c,h,f,g,p,m;let y,v=null,b=i;"boolean"==typeof r?(b=r,v=null):void 0!==r&&(v=r);let w=t.children(n),x=t.node(n),E=x?x.borderLeft:void 0,_=x?x.borderRight:void 0,S={};E&&(w=w.filter(e=>e!==E&&e!==_));let C=function(e,t=[]){return t.map(t=>{let n=e.inEdges(t);if(!n||!n.length)return{v:t};{let o=n.reduce((t,n)=>{let o=e.edge(n),r=e.node(n.v);return{sum:t.sum+o.weight*r.order,weight:t.weight+o.weight}},{sum:0,weight:0});return{v:t,barycenter:o.sum/o.weight,weight:o.weight}}})}(t,w);
2C.forEach(n=>{if(t.children(n.v).length){var r,i;let{result:a}=e(t,n.v,o,v,b);S[n.v]=a,Object.hasOwn(a,"barycenter")&&(r=n,i=a,void 0!==r.barycenter?(r.barycenter=(r.barycenter*r.weight+i.barycenter*i.weight)/(r.weight+i.weight),r.weight+=i.weight):(r.barycenter=i.barycenter,r.weight=i.weight))}});let M=(y={},C.forEach((e,t)=>{let n={indegree:0,in:[],out:[],vs:[e.v],i:t};void 0!==e.barycenter&&(n.barycenter=e.barycenter,n.weight=e.weight),y[e.v]=n}),o.edges().forEach(e=>{let t=y[e.v],n=y[e.w];void 0!==t&&void 0!==n&&(n.indegree++,t.out.push(n))}),function(e){let t=[];for(;e.length;){let n=e.pop();t.push(n),n.in.reverse().forEach(function(e){return t=>{t.merged||(void 0===t.barycenter||void 0===e.barycenter||t.barycenter>=e.barycenter)&&function(e,t){let n=0,o=0;e.weight&&(n+=e.barycenter*e.weight,o+=e.weight),t.weight&&(n+=t.barycenter*t.weight,o+=t.weight),e.vs=t.vs.concat(e.vs),e.barycenter=n/o,e.weight=o,e.i=Math.min(t.i,e.i),t.merged=!0}(e,t)}}(n)),n.out.forEach(function(t){return n=>{n.in.push(t),0==--n.indegree&&e.push(n)}}(n))}return t.filter(e=>!e.merged).map(e=>ij(e,["vs","i","barycenter","weight"]))}(Object.values(y).filter(e=>!e.indegree)));!function(e,t){e.forEach(e=>{e.vs=e.vs.flatMap(e=>t[e]?t[e].vs:e)})}(M,S);let k={},N=!1;for(let e=0;e<M.length;e++)for(let n=e+1;n<M.length;n++)if(!(!M[e]||!M[n]||!(null!=(a=M[e])&&a.barycenter)||!(null!=(s=M[n])&&s.barycenter))&&(null==(l=M[e])?void 0:l.barycenter)===M[n].barycenter){let o=null!=(u=null==(d=M[e])?void 0:d.vs[0])?u:"",r=null!=(h=null==(c=M[n])?void 0:c.vs[0])?h:"",i=t.node(o),a=t.node(r);if("edge"===i.dummy&&"edge"===a.dummy&&(null==(f=i.edgeObj)?void 0:f.v)===(null==(g=a.edgeObj)?void 0:g.v)&&(null==(p=i.edgeObj)?void 0:p.w)===(null==(m=a.edgeObj)?void 0:m.w))if(i.edgeLabel.reversed){k[r]=M[e],M.splice(e,1),e--;break}else k[o]=M[n],M.splice(n,1),n--;else N=!0}let L=function(e,t,n,o,r){var i;let a,s={},l=null,d=null,u=r;"boolean"==typeof t?(u=t,s={}):t&&(s=t,l=null!=n?n:null,d=null!=o?o:null);let c=(i=e=>Object.hasOwn(e,"barycenter"),a={lhs:[],rhs:[]},e.forEach(e=>{i(e)?a.lhs.push(e):a.rhs.push(e)}),a),h=c.lhs,f=c.rhs.sort((e,t)=>t.i-e.i),g=[],p=0,m=0,y=0;for(let[e,t]of(h.sort(function(e,t,n){return(o,r)=>{if(o.barycenter<r.barycenter)return -1;if(o.barycenter>r.barycenter)return 1;if(e&&("string"==typeof o.vs[0]||"string"==typeof r.vs[0])){let n=iB(t,e.node(o.vs[0]),e.node(r.vs[0]));if(0!==n)return n}return n?r.i-o.i:o.i-r.i}}(d,l,!!u)),Object.entries(s))){let n=h.findIndex(t=>t.vs[0]===e);h.splice(n+1,0,t)}y=ae(g,f,y),h.forEach(e=>{y+=e.vs.length,g.push(e.vs),p+=e.barycenter*e.weight,m+=e.weight,y=ae(g,f,y)});let v={vs:g.flat(1)};return m&&(v.barycenter=p/m,v.weight=m),v}(M,k,v,t,b);if(E&&_){L.vs=[E,L.vs,_].flat(1);let e=t.predecessors(E);if(e&&e.length){let n=t.node(e[0]),o=t.predecessors(_),r=t.node(o[0]);Object.hasOwn(L,"barycenter")||(L.barycenter=0,L.weight=0),L.barycenter=(L.barycenter*L.weight+n.order+r.order)/(L.weight+2),L.weight+=2}}return Object.defineProperty(L,"result",{value:L,enumerable:!1,configurable:!0,writable:!0}),Object.defineProperty(L,"usedBias",{value:N,enumerable:!1,configurable:!0,writable:!0}),L}(e,d,i,o,r);t&&c&&(r=!r),u.vs.forEach((t,n)=>e.node(t).order=n),a=u.vs,s={},a.forEach(t=>{let n=e.parent(t),o,r;for(;n;){if((o=e.parent(n))?(r=s[o],s[o]=n):(r=l,l=n),r&&r!==n)return void i.setEdge(r,n);n=o}})})})(e%2?i:a,e%4>=2,u,o),s=iA(t);let r=function(e,t){let n=0;for(let o=1;o<t.length;++o)n+=function(e,t,n){var o;let r=(o=n.map((e,t)=>t),n.reduce((e,t,n)=>(e[t]=o[n],e),{})),i=t.flatMap(t=>{let n=e.outEdges(t);return n?n.map(t=>({pos:r[t.w],weight:e.edge(t).weight})).sort((e,t)=>e.pos-t.pos):[]}),a=1;for(;a<n.length;)a<<=1;let s=2*a-1;a-=1;let l=Array(s).fill(0),d=0;return i.forEach(e=>{let t=e.pos+a;l[t]+=e.weight;let n=0;for(;t>0;)t%2&&(n+=l[t+1]),t=t-1>>1,l[t]+=e.weight;d+=e.weight*n}),d}(e,t[o-1],t[o]);return n}(t,s);r<l?(n=0,d=Object.assign({},s),l=r):r===l&&(d=structuredClone(s))}an(t,d)})(e,n,l)),t(" insertSelfEdges",()=>{var t;iA(t=e).forEach(e=>{let n=0;e.forEach((e,o)=>{let r=t.node(e);"number"!=typeof r.rank&&(r.rank=0),r.order=o+n,(r.selfEdges||[]).forEac
2h(e=>{ik(t,"selfedge",{width:e.label.width,height:e.label.height,rank:r.rank,order:o+ ++n,e:e.e,edgeLabel:e.label},"_se"),Array.isArray(e.label.points)&&7===e.label.points.length||(e.label.points=[{x:0,y:-10},{x:0,y:-10},{x:0,y:0},{x:0,y:10},{x:0,y:10},{x:0,y:0},{x:0,y:0}])}),delete r.selfEdges})})}),t(" adjustCoordinateSystem",()=>{var t;let n;("lr"===(n=null==(t=e.graph().rankdir)?void 0:t.toLowerCase())||"rl"===n)&&i8(e)}),t(" position",()=>{var t,o,r,i,a;let s,l,d,u,c,h,f,g,p,m,y,v,b,w,x;return t=e,o=n.corePath,void(y=iA(a=t=iN(t)),b=(v=a.graph()).ranksep,w=v.rankalign,x=0,y.forEach(e=>{let t=e.reduce((e,t)=>{var n;let o=null!=(n=a.node(t).height)?n:0;return e>o?e:o},0);e.forEach(e=>{let n=a.node(e);"top"===w?n.y=x+n.height/2:"bottom"===w?n.y=x+t-n.height/2:n.y=x+t/2}),x+=t+b}),Object.entries((l=iA(r=t),d=Object.assign((s={},l.length&&l.reduce(function(e,t){let n=0,o=0,i=e.length,a=t[t.length-1];return t.forEach((e,l)=>{let d=function(e,t){if(e.node(t).dummy){let n=e.predecessors(t);if(n)return n.find(t=>e.node(t).dummy)}}(r,e),u=d?r.node(d).order:i;(d||e===a)&&(t.slice(o,l+1).forEach(e=>{let t=r.predecessors(e);t&&t.forEach(t=>{let o=r.node(t),i=o.order;(i<n||u<i)&&!(o.dummy&&r.node(e).dummy)&&ao(s,t,e)})}),o=l+1,n=u)}),t}),s),function(e,t){let n={};function o(t,o,r,i,a){iD(o,r).forEach(o=>{let r=t[o];if(void 0!==r&&e.node(r).dummy){let t=e.predecessors(r);t&&t.forEach(t=>{if(void 0===t)return;let o=e.node(t);o.dummy&&(o.order<i||o.order>a)&&ao(n,t,r)})}})}return t.length&&t.reduce(function(t,n){let r=-1,i=-1,a=0;return n.forEach((s,l)=>{if("border"===e.node(s).dummy){let t=e.predecessors(s);if(t&&t.length){let s=t[0];if(void 0===s)return;i=e.node(s).order,o(n,a,l,r,i),a=l,r=i}}o(n,a,n.length,i,t.length)}),n}),n}(r,l)),u={},["u","d"].forEach(e=>{c="u"===e?l:Object.values(l).reverse(),["l","r"].forEach(t=>{var n,i;let a,s,l;"r"===t&&(c=c.map(e=>Object.values(e).reverse()));let h=(n=c,i=t=>("u"===e?r.predecessors(t):r.successors(t))||[],a={},s={},l={},n.forEach(e=>{e.forEach((e,t)=>{a[e]=e,s[e]=e,l[e]=t})}),n.forEach(e=>{let t=-1,n=-1,u=!1,c=e,h=e.findIndex(e=>(null==o?void 0:o.includes(e))||ar(e,r,o));h>0&&(c=[e[h],...e.slice(0,h),...e.slice(h+1)],u=!0),c.forEach(e=>{var c;let h=i(e);if(h&&h.length){null!=o&&o.includes(e)&&(h=h.filter(e=>ar(e,r,o)));let i=h.sort((e,t)=>{let n=l[e],o=l[t];return(void 0!==n?n:0)-(void 0!==o?o:0)}),f=(i.length-1)/2;for(let o=Math.floor(f),r=Math.ceil(f);o<=r;++o){let r=i[o];if(void 0===r)continue;let h=l[r];if(void 0!==h&&s[e]===e&&t<h&&l[r]!==n&&!function(e,t,n){if(t>n){let e=t;t=n,n=e}let o=e[t];return void 0!==o&&Object.hasOwn(o,n)}(d,e,r)){let o=a[r];void 0!==o&&(s[r]=e,s[e]=a[e]=o,t=h,u&&(t=-1,n=null!=(c=l[r])?c:-1,u=!1))}}}})}),{root:a,align:s}),f=function(e,t,n,o,r=!1){var i,a,s,l,d,u,c;let h,f,g,p={},m=(i=e,a=t,s=n,l=r,h=new iM,g=(d=(f=i.graph()).nodesep,u=f.edgesep,c=l,(e,t,n)=>{let o=e.node(t),r=e.node(n),i,a;if(i=0+o.width/2,Object.hasOwn(o,"labelpos"))switch(o.labelpos.toLowerCase()){case"l":a=-o.width/2;break;case"r":a=o.width/2}if(a&&(i+=c?a:-a),a=void 0,i+=(o.dummy?u:d)/2,i+=(r.dummy?u:d)/2,i+=r.width/2,Object.hasOwn(r,"labelpos"))switch(r.labelpos.toLowerCase()){case"l":a=r.width/2;break;case"r":a=-r.width/2}return a&&(i+=c?a:-a),i}),a.forEach(e=>{let t;e.forEach(e=>{let n=s[e];if(void 0!==n){if(h.setNode(n),void 0!==t){let o=s[t];if(void 0!==o){let r=h.edge(o,n);h.setEdge(o,n,Math.max(g(i,e,t),r||0))}}t=e}})}),h),y=r?"borderLeft":"borderRight";function v(e,t){let n=m.nodes().slice(),o={},r=n.pop();for(;r;){if(o[r])e(r);else for(let e of(o[r]=!0,n.push(r),t(r)))n.push(e);r=n.pop()}}return v(function(e){let t=m.inEdges(e);t?p[e]=t.reduce((e,t)=>{var n;let o=null!=(n=p[t.v])?n:0,r=m.edge(t);return Math.max(e,o+(void 0!==r?r:0))},0):p[e]=0},function(e){return m.predecessors(e)||[]}),v(function(t){let n=m.outEdges(t),o=1/0;n&&(o=n.reduce((e,t)=>{let n=p[t.w],o=m.edge(t);return Math.min(e,(void 0!==n?n:0)-(void 0!==o?o:0))},1/0));let r=e.node(t);o!==1/0&&r.borderType!==y&&(p[t]=Math.max(void 0!==p[t]?p[t]:0,o))},function(e){return m.successors(e)||[]}
2),Object.keys(o).forEach(e=>{var t;let o=n[e];void 0!==o&&(p[e]=null!=(t=p[o])?t:0)}),p}(r,c,h.root,h.align,"r"===t);"r"===t&&(f=i$(f,e=>-e)),u[e+t]=f})}),h=Object.values(u).reduce((e,t)=>{let n=-1/0,o=1/0;Object.entries(t).forEach(([e,t])=>{var i,a;let s=(i=r,a=e,i.node(a).width/2);n=Math.max(t+s,n),o=Math.min(t-s,o)});let i=n-o;return i<e[0]&&(e=[i,t]),e},[1/0,null])[1],g=iI(Math.min,f=Object.values(h)),p=iI(Math.max,f),["u","d"].forEach(e=>{["l","r"].forEach(t=>{let n=e+t,o=u[n];if(!o||o===h)return;let r=Object.values(o),i=g-iI(Math.min,r);"l"!==t&&(i=p-iI(Math.max,r)),i&&(u[n]=i$(o,e=>e+i))})}),i=r.graph().align,(m=u.ul)?i$(m,(e,t)=>{var n,o;if(i){let e=u[i.toLowerCase()];if(e&&void 0!==e[t])return e[t]}let r=Object.values(u).map(e=>{let n=e[t];return void 0!==n?n:0}).sort((e,t)=>e-t);return((null!=(n=r[1])?n:0)+(null!=(o=r[2])?o:0))/2}):{})).forEach(([e,n])=>t.node(e).x=n))}),t(" positionSelfEdges",()=>{var t;(t=e).nodes().forEach(e=>{let n=t.node(e),o=e=>"number"==typeof e&&isFinite(e);if("selfedge"===n.dummy){let r=t.node(n.e.v),i=o(null==r?void 0:r.x)?r.x:0,a=o(null==r?void 0:r.y)?r.y:0,s=o(null==r?void 0:r.width)?r.width:0,l=o(null==r?void 0:r.height)?r.height:0,d=o(n.x)?n.x:i,u=o(n.y)?n.y:a,c=s/2,h=l/2;n.edgeLabel.points=[{x:d+c,y:u-h},{x:d+c,y:u-h},{x:d,y:u},{x:d-c,y:u+h},{x:d-c,y:u+h},{x:d,y:u},{x:d,y:u}],n.edgeLabel.x=d,n.edgeLabel.y=u,t.setEdge(n.e,n.edgeLabel),t.removeNode(e)}else n&&Array.isArray(n.selfEdges)&&n.selfEdges.forEach(e=>{if(!Array.isArray(e.label.points)||7!==e.label.points.length){let t=o(n.x)?n.x:0,r=o(n.y)?n.y:0,i=o(n.width)?n.width:0,a=o(n.height)?n.height:0,s=i/2,l=a/2;e.label.points=[{x:t+s,y:r-l},{x:t+s,y:r-l},{x:t,y:r},{x:t-s,y:r+l},{x:t-s,y:r+l},{x:t,y:r},{x:t,y:r}]}})})});let d=JSON.parse(JSON.stringify(e._nodes));return t(" removeBorderNodes",()=>{var t;(t=e).nodes().forEach(e=>{if(t.children(e).length){let n=t.node(e),o=t.node(n.borderTop),r=t.no
2de(n.borderBottom),i=t.node(n.borderLeft[n.borderLeft.length-1]),a=t.node(n.borderRight[n.borderRight.length-1]);n.width=Math.abs(a.x-i.x),n.height=Math.abs(r.y-o.y),n.x=i.x+n.width/2,n.y=o.y+n.height/2}}),t.nodes().forEach(e=>{"border"===t.node(e).dummy&&t.removeNode(e)})}),t(" normalize.undo",()=>{e.graph().dummyChains.forEach(t=>{let n=e.node(t),o=n.edgeLabel,r;for(e.setEdge(n.edgeObj,o);n.dummy;)r=e.successors(t)[0],e.removeNode(t),o.points.push({x:n.x,y:n.y}),"edge-label"===n.dummy&&(o.x=n.x,o.y=n.y,o.width=n.width,o.height=n.height),t=r,n=e.node(t)})}),t(" fixupEdgeLabelCoords",()=>{var t;(t=e).edges().forEach(e=>{let n=t.edge(e);if(Object.hasOwn(n,"x"))switch(("l"===n.labelpos||"r"===n.labelpos)&&(n.width-=n.labeloffset),n.labelpos){case"l":n.x-=n.width/2+n.labeloffset;break;case"r":n.x+=n.width/2+n.labeloffset}})}),t(" undoCoordinateSystem",()=>{var t,n,o;let r;("bt"===(r=null==(t=e.graph().rankdir)?void 0:t.toLowerCase())||"rl"===r)&&((n=e).nodes().forEach(e=>i7(n.node(e))),n.edges().forEach(e=>{var t;let o=n.edge(e);null==(t=o.points)||t.forEach(i7),Object.hasOwn(o,"y")&&i7(o)})),("lr"===r||"rl"===r)&&((o=e).nodes().forEach(e=>
2i9(o.node(e))),o.edges().forEach(e=>{var t;let n=o.edge(e);null==(t=n.points)||t.forEach(i9),Object.hasOwn(n,"x")&&i9(n)}),i8(e))}),t(" translateGraph",()=>(function(e){let t=1/0,n=0,o=1/0,r=0,i=e.graph(),a=i.marginx||0,s=i.marginy||0;function l(e){let i=e.x,a=e.y,s=e.width,l=e.height;t=Math.min(t,i-s/2),n=Math.max(n,i+s/2),o=Math.min(o,a-l/2),r=Math.max(r,a+l/2)}e.nodes().forEach(t=>l(e.node(t))),e.edges().forEach(t=>{let n=e.edge(t);Object.hasOwn(n,"x")&&l(n)}),t-=a,o-=s,e.nodes().forEach(n=>{let r=e.node(n);r.x-=t,r.y-=o}),e.edges().forEach(n=>{let r=e.edge(n);r.points.forEach(e=>{e.x-=t,e.y-=o}),Object.hasOwn(r,"x")&&(r.x-=t),Object.hasOwn(r,"y")&&(r.y-=o)}),i.width=n-t+a,i.height=r-o+s})(e)),t(" assignNodeIntersects",()=>{var t;(t=e).edges().forEach(e=>{if(e.v===e.w)return;let n=t.edge(e),o=t.node(e.v),r=t.node(e.w),i,a;n.points?(i=n.points[0],a=n.points[n.points.length-1]):(n.points=[],i=r,a=o),n.points.unshift(iL(o,i)),n.points.push(iL(r,a))})}),t(" reversePoints",()=>{var t;(t=e).edges().forEach(e=>{let n=t.edge(e);n.reversed&&n.points.reverse()})}),t(" acyclic.undo",()=>
vendor: 1,206 bytes, line 2
2{e.edges().forEach(t=>{let n=e.edge(t);if(n.reversed){e.removeEdge(t);let o=n.forwardName;delete n.reversed,delete n.forwardName,e.setEdge(t.w,t.v,n,o)}})}),{graph:e,rawNodes:d}}function al(e,t){e.nodes().forEach(n=>{let o=e.node(n),r=t.node(n);o&&(o.x=r.x,o.y=r.y,o.order=r.order,o.rank=r.rank,t.children(n).length&&(o.width=r.width,o.height=r.height))}),e.edges().forEach(n=>{let o=e.edge(n),r=t.edge(n);o.points=r.points,Object.hasOwn(r,"x")&&(o.x=r.x,o.y=r.y)}),e.graph().width=t.graph().width,e.graph().height=t.graph().height}var ad=["nodesep","edgesep","ranksep","marginx","marginy"],au={ranksep:50,edgesep:20,nodesep:50,rankdir:"TB",rankalign:"center"},ac=["acyclicer","ranker","rankdir","align","rankalign"],ah=["width","height","rank"],af={width:0,height:0},ag=["minlen","weight","width","height","labeloffset"],ap={minlen:1,weight:1,width:0,height:0,labeloffset:10,labelpos:"r"},am=["labelpos"];function ay(e){let t=new iM({multigraph:!0,compound:!0}),n=ab(e.graph());return t.setGraph(Object.assign({},au,av(n,ad),ij(n,ac))),e.nodes().forEach(n=>{let o=av(ab(e.node(n)),ah);Object.keys(af).forEach(e=>{void 0===o[e]&&(o[e]=af[e])}),t.setNode(n,o);let r=e.parent(n);void 0!==r&&t.setParent(n,r)}
2),e.edges().forEach(n=>{let o=ab(e.edge(n));t.setEdge(n,Object.assign({},ap,av(o,ag),ij(o,am)))}),t}function av(e,t){return i$(ij(e,t),Number)}function ab(e){let t={};return e&&Object.entries(e).forEach(([e,n])=>{"string"==typeof e&&(e=e.toLowerCase()),t[e]=n}),t}let aw=new Set(["Cache","Database","ObjectStorage"]);function ax(e){let t=e.measured;if(t&&"number"==typeof t.width&&"number"==typeof t.height&&t.width>0&&t.height>0)return{width:t.width,height:t.height};let n=e.data??{},o=180,r=96;return"string"==typeof n.label&&n.label.length>18&&(o=Math.min(280,Math.max(180,7*n.label.length+24))),"string"==typeof n.region&&"default"!==n.region&&(r+=16),!0===n.showMetrics&&(r+=28),"string"==typeof n.componentType&&aw.has(n.componentType)&&(r+=12),{width:o,height:r}}function aE(e){let{width:t,height:n}=ax(e);return{x:(e.position?.x??0)+t/2,y:(e.position?.y??0)+n/2}}e.s(["NODE_HEIGHT",0,96,"NODE_WIDTH",0,180,"getNodeCenter",()=>aE,"getNodeDimensions",()=>ax],348200);let a_={Client:0,GeoDns:1,CDN:1,ApiGateway:1,RateLimiter:1,LoadBalancer:2,Service:3,WebSocketService:3,EventStream:4,StreamProcessor:4,Worker:4,Cache:5,Database:5,ObjectStorage:5};function aS(e){return void 0===e?3:a_[e]??3}Object.values(a_);var aC=e.i(768774);let aM=new Set(["Client"]),ak=new Set(["Cache","Database","ObjectStorage"]);function aN(e){return aS(e.data?.componentType)}function aL(e){let t=e.measured?.width??e.width??180,n=e.measured?.height??e.height??80;return{x:e.position.x+t/2,y:e.position.y+n/2}}let aA={name:"dagre",compute(e,t,n){var o;let r,i=function(e,t,n={}){if(0===e.length)return[];let{direction:o="LR",rankSep:r=aC.AUTO_FORMAT_RANK_SEP_PX,nodeSep:i=aC.AUTO_FORMAT_NODE_SEP_PX,clusterGap:a=80}=n,s=new Map(e.map(e=>[e.id,e])),l=t.filter(e=>s.has(e.source)&&s.has(e.target)),d=new Set;for(let e of l)e.source!==e.target&&(d.add(e.source),d.add(e.target));let u=e.filter(e=>!!e.data?.pinned),c=new Set(u.map(e=>e.id)),h=e.filter(e=>!c.has(e.id)),f=h.filter(e=>d.has(e.id)),g=h.filter(e=>!d.has(e.id)),p=new Map;for(let e of u)p.set(e.id,{x:e.position.x,y:e.position.y});if(f.length>0){let e=new r2.Graph({multigraph:!0}).setDefaultEdgeLabel(()=>({}));e.setGraph({rankdir:o,ranksep:r,nodesep:i,marginx:40,marginy:40});let t=new Map;for(let n of f){let o,r=ax(n);t.set(n.id,r);let i=n.data?.componentType;i&&aM.has(i)?o="min":i&&ak.has(i)&&(o="max"),e.setNode(n.id,{width:r.width,height:r.height,...o?{rank:o}:{}})}for(let t=0;t<l.length;t++){let n=l[t];n.source!==n.target&&e.hasNode(n.source)&&e.hasNode(n.target)&&e.setEdge(n.source,n.target,{},n.id??`e${t}`)}for(let n of(function(e,t={}){(function e(t,n,o){var r;let i=t.nodes().filter(e=>t.children(e).length),a={};i.forEach(r=>{let i=t.node(r);if(i&&i.rankdir){let s=new iM({multigraph:!0,compound:!0});s.setGraph({rankdir:i.rankdir});let l=t.children(r);l.forEach(e=>{let n={...t.node(e)};s.setNode(e,n);let o=t.parent(e);o&&o!==r&&l.includes(o)&&s.setParent(e,o)});let d=new Set;
2t.edges().forEach(e=>{let n=aa(t,e.v,r),o=aa(t,e.w,r);if(n&&o&&n!==o){let r=`${n}\0${o}`;d.has(r)||(d.add(r),s.setEdge(n,o,{...t.edge(e)}))}}),e(s,n,o);let u=ay(s);as(u,n,o,null),al(s,u);let c=1/0,h=1/0,f=-1/0,g=-1/0;s.nodes().forEach(e=>{if(e===r)return;let t=s.node(e);t&&"number"==typeof t.x&&"number"==typeof t.y&&"number"==typeof t.width&&"number"==typeof t.height&&(c=Math.min(c,t.x-t.width/2),f=Math.max(f,t.x+t.width/2),h=Math.min(h,t.y-t.height/2),g=Math.max(g,t.y+t.height/2))}),isFinite(c)&&isFinite(h)&&isFinite(f)&&isFinite(g)||(c=h=0,f=g=0);let p=f-c,m=g-h;a[r]={minX:c,minY:h,maxX:f,maxY:g,width:p,height:m,offsetX:c,offsetY:h},i._dagreClusterSubgraph=s}});let s=[],l=new Map;i.forEach(e=>{let n=t.node(e);n&&n.rankdir&&a[e]&&l.set(e,(t.children(e)||[]).filter(t=>t!==e))});let d=new Set([...l.values()].flat()),u=new Map;l.forEach((e,n)=>{d.has(n)||u.set(n,(e=>{let n=[],o=(t.children(e)||[]).filter(t=>t!==e);for(;o.length>0;){let e=o.shift();n.push(e),(t.children(e)||[]).filter(t=>t!==e).forEach(e=>o.push(e))}return n})(n))});let c=new Set([...u.values()].flat()),h=e=>{for(let[t,n]of u)if(n.includes(e))return t;return e},f=[];
2t.edges().forEach(e=>{(c.has(e.v)||c.has(e.w))&&f.push({edge:e,label:t.edge(e)})});let g=new Map;c.forEach(e=>{let n=t.parent(e);g.set(e,"string"==typeof n?n:void 0)}),u.forEach((e,n)=>{let o=t.node(n),r=[];e.forEach(e=>{let n=t.node(e);n&&(r.push({id:e,node:n,parent:g.get(e)}),t.removeNode(e))});let i=f.filter(({edge:t})=>e.includes(t.v)||e.includes(t.w)),l=a[n];o&&(s.push({clusterId:n,subgraph:o._dagreClusterSubgraph,bounds:l,children:e,removedNodes:r,removedEdges:i}),o.width=l.width,o.height=l.height)});let p=new Set;f.forEach(({edge:e,label:n})=>{let o=h(e.v),r=h(e.w);if(o!==r&&t.hasNode(o)&&t.hasNode(r)){let e=`${o}\0${r}`;p.has(e)||(p.add(e),t.setEdge(o,r,{...n,width:0,height:0}))}});let m=ay(t),y=as(m,n,o,null!=(r=ai.get(t))?r:null);ai.set(t,y),al(t,m),p.forEach(e=>{let n=e.indexOf("\0"),o=e.slice(0,n),r=e.slice(n+1);t.hasEdge(o,r)&&t.removeEdge(o,r)}),s.forEach(({clusterId:e,subgraph:n,bounds:o,removedNodes:r,removedEdges:i})=>{var a,s;let l=t.node(e),d=null!=(a=null==l?void 0:l.x)?a:0,u=null!=(s=null==l?void 0:l.y)?s:0,c=(o.minX+o.maxX)/2,h=(o.minY+o.maxY)/2;r.forEach(({id:e,node:n,parent:o})=>{t.setNode(e,n),void 0!==o&&t.setParent(e,o)}
2),i.forEach(({edge:e,label:n})=>{t.setEdge(e,n)}),n.nodes().forEach(o=>{if(o===e)return;let r=n.node(o),i=t.node(o);i&&r&&"number"==typeof r.x&&"number"==typeof r.y&&(i.x=d+(r.x-c),i.y=u+(r.y-h))}),delete l._dagreClusterSubgraph}),i.forEach(e=>{var n,o;let r=t.node(e),i=a[e];if(r&&r.rankdir&&r._dagreClusterSubgraph&&i){let a=r._dagreClusterSubgraph,s=null!=(n=r.x)?n:0,l=null!=(o=r.y)?o:0,d=(i.minX+i.maxX)/2,u=(i.minY+i.maxY)/2;a.nodes().forEach(n=>{if(n===e)return;let o=a.node(n),r=t.node(n);if(r&&o&&"number"==typeof o.x&&"number"==typeof o.y){let e=o.x-d,t=o.y-u;r.x=s+e,r.y=l+t}}),delete r._dagreClusterSubgraph}})})(e,iT,t)}(e),f)){let o=e.node(n.id),r=t.get(n.id)??{width:180,height:96};o&&p.set(n.id,{x:o.x-r.width/2,y:o.y-r.height/2})}}if(g.length>0){let e=[...g].sort((e,t)=>{let n=aN(e)-aN(t);if(0!==n)return n;let o=e.data?.label??e.id,r=t.data?.label??t.id;return o.localeCompare(r)}),t=40,n=40;for(let e of f){let o=p.get(e.id);if(!o)continue;let r=ax(e);t=Math.max(t,o.y+r.height),n=Math.max(n,o.x+r.width)}if("LR"===o){let n=f.length>0?t+a:40;for(let t=0;t<e.length;t++){let o=Math.floor(t/8),r=t%8,i=e[t],a=ax(i);p.set(i.id,{x:40+200*r,y:n+o*(a.height+20)})}}else{let t=f.length>0?n+a:40;for(let n=0;n<e.length;n++){let o=Math.floor(n/8),r=n%8,i=e[n],a=ax(i);p.set(i.id,{x:t+200*o,y:40+r*(a.height+20)})}}}return e.map(e=>{let t=p.get(e.id);return t?{...e,position:t}:{...e}})}(e,t,{direction:n?.direction??"LR",rankSep:n?.rankSep,nodeSep:n?.nodeSep,clusterGap:n?.clusterGap}),a=(o=[...t],r=new Map(i.map(e=>[e.id,e])),o.map(e=>{let t=e.data?.waypoints;if(Array.isArray(t)&&t.length>0)return e;let n=r.get(e.source),o=r.get(e.target);if(!n||!o)return e;let a=aL(n),s=aL(o),l=null;for(let t of i){if(t.id===e.source||t.id===e.target||t.hidden)continue;let n=function(e,t){let n=e.measured?.width??e.width??180,o=e.measured?.height??e.height??80;return{x:e.position.x-12,y:e.position.y-12,w:n+24,h:o+24}}(t,0);if(function(e,t,n){let o=t.x-e.x,r=t.y-e.y,i=[-o,o,-r,r],a=[e.x-n.x,n.x+n.w-e.x,e.y-n.y,n.y+n.h-e.y],s=0,l=1;for(let e=0;e<4;e++){let t=i[e],n=a[e];if(0===t){if(n<0)return!1}else{let e=n/t;t<0?s=Math.max(s,e):l=Math.min(l,e)}}return s<=l}(a,s,n)){l=function(e,t,n){let o=(e.x+t.x)/2,r=(e.y+t.y)/2,i=n.x+n.w/2,a=n.y+n.h/2;return Math.abs(t.x-e.x)>=Math.abs(t.y-e.y)?r<=a?{x:o,y:n.y-12}:{x:o,y:n.y+n.h+12}:o<=i?{x:n.x-12,y:r}:{x:n.x+n.w+12,y:r}}(a,s,n);break}}return l?{...e,data:{...e.data??{},waypoints:[l]}}:e}));return{nodes:i,edges:a}}};function aO(e){return!!e.data?.pinned}let aI=null,aP=!1;async function aT(){if(aP)return null;if(aI)return aI;try{let e=await import("elkjs/lib/elk.bundled.js");return aI=new(e.default??e)}catch{return aP=!0,console.warn("[VETORA-4031] elkjs not available â falling back to dagre. Install elkjs for improved hierarchical layout."),null}}function aR(e,t){return`cluster_${e}_${t.toLowerCase().replace(/\s+/g,"_")}`}async function aD(e,t,n){let o,r=await aT();if(!r)return aA.compute(e,t,n);let i=n?.direction==="TB"?"DOWN":"RIGHT",a=n?.rankSep??aC.AUTO_FORMAT_RANK_SEP_PX,s=n?.nodeSep??aC.AUTO_FORMAT_NODE_SEP_PX,l=n?.clusters??[],d=new Set(e.filter(aO).map(e=>e.id)),u=new Map;for(let e=0;e<l.length;e++)for(let t of l[e].nodeIds)u.set(t,e);let c=e=>{let t=ax(e),n=aS(e.data?.componentType);return{id:e.id,width:t.width,height:t.height,layoutOptions:{"elk.partitioning.partition":String(n)}}};if(l.length>0){let t=new Map,n=[];for(let o of e){if(d.has(o.id))continue;let e=u.get(o.id);if(void 0!==e){let n=t.get(e)??[];n.push(c(o)),t.set(e,n)}else n.push(c(o))}o=[...l.map((e,n)=>({id:aR(n,e.name),layoutOptions:{"elk.padding":"[top=40, left=20, bottom=20, right=20]"},children:t.get(n)??[]})),...n]}else o=e.filter(e=>!d.has(e.id)).map(c);let h={"elk.algorithm":"layered","elk.direction":i,"elk.layered.spacing.nodeNodeBetweenLayers":String(a),"elk.spacing.nodeNode":String(s),"elk.layered.crossingMinimization.strategy":"LAYER_SWEEP","elk.layered.nodePlacement.strategy":"NETWORK_SIMPLEX","elk.edgeRouting":"ORTHOGONAL","elk.partitioning.activate":"true"};l.length>0&&(h["elk.hierarchyHandling"]="INCLUDE_CHILDREN");let f=t.filter(e=>e.source!==e.target&&!d.has(e.source)&&!d.has(e.target)).map((e,t)=>({id:e.id??`e${t}`,sources:[e.source],targets:[e.target]})),g=await r.layout({id:"root",layoutOptions:h,children:o,edges:f});return{nodes:function(e,t,n,o){if(0===t.length)return[...e];let r=new Set(t.map(e=>e.id)),i=t.map(e=>{let t=ax(e);return{x:e.position.x,y:e.position.y,width:t.width,height:t.height}});return e.map(e=>{if(r.has(e.id))return e;let t=ax(e),{x:a,y:s}=e.position;for(let e=0;e<i.length+1;e++){let e=i.find(e=>a<e.x+e.width&&a+t.width>e.x&&s<e.y+e.height&&s+t.height>e.y);if(!e)break;"RIGHT"===n?s=e.y+e.height+o:a=e.x+e.width+o}return a===e.position.x&&s===e.position.y?e:{...e,position:{x:a,y:s}}})}(e.map(e=>{if(l.length>0){let t=u.get(e.id);if(void 0!==t){let n=aR(t,l[t].name),o=g.children?.find(e=>e.id===n),r=o?.children?.find(t=>
2t.id===e.id);if(o?.x!=null&&r?.x!=null)return{...e,position:{x:o.x+r.x,y:o.y+r.y}}}else{let t=g.children?.find(t=>t.id===e.id);if(t?.x!=null)return{...e,position:{x:t.x,y:t.y}}}}else{let t=g.children?.find(t=>t.id===e.id);return null==t||null==t.x||null==t.y?{...e}:{...e,position:{x:t.x,y:t.y}}}return{...e}}),e.filter(e=>d.has(e.id)),i,s),edges:[...t]}}function aj(e,t){if(e.length<2)return{edgeCrossings:0,nodeOverlaps:0,flowConsistency:1,totalEdgeLength:0,score:100};let n=function(e,t){let n=new Map(e.map(e=>[e.id,e])),o=[];for(let e of t){let t=n.get(e.source),r=n.get(e.target);if(!t||!r||e.source===e.target)continue;let i=ax(t),a=ax(r);o.push({x1:(t.position?.x??0)+i.width/2,y1:(t.position?.y??0)+i.height/2,x2:(r.position?.x??0)+a.width/2,y2:(r.position?.y??0)+a.height/2})}let r=0;for(let e=0;e<o.length;e++)for(let t=e+1;t<o.length;t++)(function(e,t){if(e.x1===t.x1&&e.y1===t.y1||e.x1===t.x2&&e.y1===t.y2||e.x2===t.x1&&e.y2===t.y1||e.x2===t.x2&&e.y2===t.y2)return!1;let n=a$(t,e.x1,e.y1),o=a$(t,e.x2,e.y2),r=a$(e,t.x1,t.y1),i=a$(e,t.x2,t.y2);return(!!(n>0)&&!!(o<0)||!!(n<0)&&!!(o>0))&&(!!(r>0)&&!!(i<0)||!!(r<0)&&!!(i>0))})(o[e],o[t])&&r++;return r}(e,t),o=function(e){let t=0;for(let n=0;n<e.length;n++)for(let o=n+1;o<e.length;o++){let r=e[n],i=e[o],a=ax(r),s=ax(i),l=r.position?.x??0,d=r.position?.y??0,u=i.position?.x??0,c=i.position?.y??0;l<u+s.width&&l+a.width>u&&d<c+s.height&&d+a.height>c&&t++}return t}(e),r=function(e,t){if(0===t.length)return 1;let n=new Map(e.map(e=>[e.id,e])),o=1/0,r=-1/0,i=1/0,a=-1/0;for(let t of e){let e=t.position?.x??0,n=t.position?.y??0;o=Math.min(o,e),r=Math.max(r,e),i=Math.min(i,n),a=Math.max(a,n)}let s=r-o>=a-i,l=0,d=0;for(let e of t){let t=n.get(e.source),o=n.get(e.target);t&&o&&e.source!==e.target&&(d++,s?(o.position?.x??0)>(t.position?.x??0)&&l++:(o.position?.y??0)>(t.position?.y??0)&&l++)}return d>0?l/d:1}(e,t),i=function(e,t){let n=new Map(e.map(e=>[e.id,e])),o=0;for(let e of t){let t=n.get(e.source),r=n.get(e.target);if(!t||!r||e.source===e.target)continue;let i=ax(t),a=ax(r),s=(r.position?.x??0)+a.width/2-(t.position?.x??0)-i.width/2,l=(r.position?.y??0)+a.height/2-(t.position?.y??0)-i.height/2;o+=Math.sqrt(s*s+l*l)}return o}(e,t),a=Math.max(0,1-n/Math.max(1,t.length*(t.length-1)/2)),s=Math.max(0,1-o/Math.max(1,e.length*(e.length-1)/2)),l=Math.max(0,1-Math.abs(i/Math.max(1,t.length)-300)/900);return{edgeCrossings:n,nodeOverlaps:o,flowConsistency:Math.round(100*r)/100,totalEdgeLength:Math.round(i),score:Math.round(100*(.35*a+.25*s+.25*r+.15*l))}}function a$(e,t,n){return(e.x2-e.x1)*(n-e.y1)-(e.y2-e.y1)*(t-e.x1)}e.s(["measureQuality",()=>aj],61333);let aB=["rgba(99, 102, 241, 0.08)","rgba(16, 185, 129, 0.08)","rgba(245, 158, 11, 0.08)","rgba(239, 68, 68, 0.08)","rgba(139, 92, 246, 0.08)","rgba(6, 182, 212, 0.08)","rgba(236, 72, 153, 0.08)","rgba(34, 197, 94, 0.08)"],aF=new Set(["main","primary","secondary","internal","external","api","the","my","our","new","old"]);function aH(e,t){let n=new Map;for(let t of e){let e=t.data?.label,o=t.data?.domain;if(o){let e=n.get(o)??[];e.push(t.id),n.set(o,e);continue}if(!e)continue;let r=function(e){let t=e.trim(),n=t.split(/\s+/);if(n.length>=2){let e=n[0];if(!aF.has(e.toLowerCase()))return e}let o=t.split(/[-_]/);if(o.length>=2){let e=o[0];if(!aF.has(e.toLowerCase()))return e}return null}(e);if(!r)continue;let i=r.charAt(0).toUpperCase()+r.slice(1).toLowerCase(),a=n.get(i)??[];a.push(t.id),n.set(i,a)}let o=[],r=0;for(let[e,t]of n)!(t.length<2)&&(o.push({name:e,nodeIds:t,color:aB[r%aB.length]}),r++);let i=new Map;for(let e=0;e<o.length;e++)for(let t of o[e].nodeIds)i.set(t,e);for(let n of e.filter(e=>!i.has(e.id))){let e=new Set;for(let o of t){if(o.source===n.id){let t=i.get(o.target);void 0!==t&&e.add(t)}if(o.target===n.id){let t=i.get(o.source);void 0!==t&&e.add(t)}}if(1===e.size){let t=[...e][0];o[t].nodeIds.push(n.id),i.set(n.id,t)}}return o}function az(e,t,n=20){let o=t.filter(t=>e.includes(t.id));if(0===o.length)return null;let r=1/0,i=1/0,a=-1/0,s=-1/0;for(let e of o)r=Math.min(r,e.position.x),i=Math.min(i,e.position.y),a=Math.max(a,e.position.x+180),s=Math.max(s,e.position.y+96);return{x:r-n,y:i-n,width:a-r+2*n,height:s-i+2*n}}function aV(e,t){let n=e>=30;return{isLargeGraph:n,hideEdgeLabels:n&&t<.5,compactNodes:n&&t<.35,disableAnimations:n}}function aK(e){return e.data?.componentType}e.s(["clusterBounds",()=>az,"detectDomains",()=>aH],49124),e.s(["SIMPLIFY_THRESHOLD",0,300,"VIRTUALISE_THRESHOLD",0,150,"computeLargeGraphState",()=>aV],697131);
2let aX=[{t:.5,lateral:0},{t:aC.AUTO_FORMAT_LABEL_OFFSET_NEAR,lateral:0},{t:aC.AUTO_FORMAT_LABEL_OFFSET_FAR,lateral:0},{t:.5,lateral:aC.AUTO_FORMAT_LABEL_LATERAL_PX},{t:.5,lateral:-aC.AUTO_FORMAT_LABEL_LATERAL_PX}];function aY(e){switch(e.op){case"add_node":let t,n,o;return t=aJ.getState(),o={id:n=`node_${t.nextId}`,type:"component",position:{x:e.position_x,y:e.position_y},data:{label:e.label,componentType:e.component_type,config:{...e.params??{}},...e.description?{description:e.description}:{},origin:"copilot"}},aJ.setState(e=>({nodes:[...e.nodes,o],nextId:e.nextId+1})),n;case"remove_node":aJ.setState(t=>({nodes:t.nodes.filter(t=>t.id!==e.node_id),edges:t.edges.filter(t=>t.source!==e.node_id&&t.target!==e.node_id)}));return;case"update_node_params":aJ.setState(t=>({nodes:t.nodes.map(t=>t.id===e.node_id?{...t,data:{...t.data,config:{...t.data.config,...e.params}}}:t)}));return;case"update_node_label":aJ.setState(t=>({nodes:t.nodes.map(t=>t.id===e.node_id?{...t,data:{...t.data,label:e.label}}:t)}));return;case"move_node":aJ.setState(t=>({nodes:t.nodes.map(t=>t.id===e.node_id?{...t,position:{x:e.position_x,y:e.position_y}}:t)}));return;case"add_edge":!function(e){var t,n;let o,r,i=aJ.getState(),a=i.nodes.find(t=>t.id===e.source_id),s=i.nodes.find(t=>t.id===e.target_id);if(!a||!s)return console.warn(`[applyMutation] add_edge: source "${e.source_id}" or target "${e.target_id}" not found`);let l=a.data.componentType,d=s.data.componentType,u=e.edge_type??rL(l,d)??"API_CALL",c=s.data.config??{};if(e.contract_id){let t=rP[u];t&&(o=t.buildMetadata(e.contract_id,c)??void 0,r=e.contract_id)}o&&e.operation&&(o={...o,operation:e.operation});let h=(e.input_bindings??[]).map(e=>({id:String(e.id??`ib_copilot_${Date.now()}`),sourceContractId:String(e.source_contract_id??""),label:String(e.label??""),fieldMappings:e.field_mappings??[]})),f={...{source:e.source_id,target:e.target_id,sourceHandle:null,targetHandle:null,id:(t=e.source_id,n=e.target_id,`edge_copilot_${t}_${n}_${Date.now()}`)},type:"design",animated:!1,data:{edgeType:u,networkLatencyMs:e.latency_ms??3,...e.label?{customLabel:e.label}:{},...r?{contractId:r}:{},...o?{metadata:o}:{},...h.length>0?{inputBindings:h}:{}}};aJ.setState(e=>({edges:nA(f,e.edges)}))}(e);return;case"remove_edge":aJ.setState(t=>({edges:t.edges.filter(t=>t.id!==e.edge_id)}));return;case"update_edge":aJ.setState(t=>({edges:t.edges.map(t=>t.id===e.edge_id?{...t,data:{...t.data,...e.updates}}:t)}));return;default:return void console.warn("[applyMutation] unhandled op:",e.op)}}function aG(){try{let{useAppConfigStore:t}=e.r(318321);return t.getState().app.max_undo_history}catch{return 50}}function aW(){try{return null!==v.useArenaStore.getState().attemptLockReason}catch{return!1}}e.s(["applyMutation",()=>aY],481190);let aU={generic:"default",aws:"us-east-1",gcp:"us-central1",azure:"eastus"};function aZ(e,t){let n=e.toLowerCase().replace(/([A-Z])/g,"_$1");return`${n}_${t}`}let aq=[];function aQ(e){let t=new Map;for(let e of aq)t.set(e.id,e);let n=e.nodes.map(e=>{let n=t.get(e.id);return n&&n.position===e.position&&n.data===e.data?n:{...e,position:{...e.position},data:{...e.data,config:{...e.data.config}}}});return aq=n,{nodes:n,edges:e.edges.map(e=>({...e,data:e.data?{...e.data}:void 0})),nextId:e.nextId}}let aJ=(0,y.create)((t,n)=>({cloudProvider:"aws",regionLatencyMatrix:rZ,nodes:[],edges:[],nextId:1,collapsedClusters:[],screenToFlowPosition:null,undoStack:[],redoStack:[],canUndo:!1,canRedo:!1,layoutRunToken:0,layoutDirection:"TB"===window.localStorage.getItem("vetora.layoutDirection")?"TB":"LR",setLayoutDirection:e=>{window.localStorage.setItem("vetora.layoutDirection",e),t({layoutDirection:e})},selectedNodeId:null,setSelectedNodeId:e=>t({selectedNodeId:e}),pendingMutations:null,preBatchSnapshot:null,ghostNodeIds:new Set,removedNodeIds:new Set,editedNodeIds:new Set,movedNodeIds:new Set,ghostEdgeIds:new Set,removedEdgeIds:new Set,editedEdgeIds:new Set,pushSnapshot:()=>{let e=n(),o=aQ(e),r=[...e.undoStack,o];r.length>aG()&&r.shift(),t({undoStack:r,redoStack:[],canUndo:!0,canRedo:!1})},undo:()=>{if(aW())return;let e=n();if(0===e.undoStack.length)return;let o=aQ(e),r=[...e.redoStack,o],i=[...e.undoStack],a=i.pop();t({nodes:a.nodes,edges:a.edges,nextId:a.nextId,undoStack:i,redoStack:r,canUndo:i.length>0,canRedo:!0,layoutRunToken:e.layoutRunToken+1})},redo:()=>
2{if(aW())return;let e=n();if(0===e.redoStack.length)return;let o=aQ(e),r=[...e.undoStack,o],i=[...e.redoStack],a=i.pop();t({nodes:a.nodes,edges:a.edges,nextId:a.nextId,undoStack:r,redoStack:i,canUndo:!0,canRedo:i.length>0,layoutRunToken:e.layoutRunToken+1})},clearHistory:()=>{t({undoStack:[],redoStack:[],canUndo:!1,canRedo:!1})},onNodesChange:e=>{aW()||t(t=>({nodes:nE(e,t.nodes)}))},onEdgesChange:e=>{aW()||t(t=>({edges:nE(e,t.edges)}))},onConnect:e=>{let o,r;if(aW())return;let i=n();i.pushSnapshot();let a=i.nodes.find(t=>t.id===e.source),s=i.nodes.find(t=>t.id===e.target),l=a?.data.componentType??"",d=rL(l,s?.data.componentType??""),u=rU("Client"===l,a?.data.config?.region??"default",s?.data.config?.region??"default",i.regionLatencyMatrix);if(d&&s){let e=rP[d];if(e){let t=s.data.config??{},n=e.getContracts(t);if(n.length>0){let r=n[0];o=e.buildMetadata(r.value,t)}}if(o&&a){let e=rj[l];if(e){let t=e.getContracts(a.data.config??{});if(t.length>0){let e=t[0];r=[{id:`ib_auto_${Date.now().toString(36)}`,sourceContractId:e.value,label:e.label,fieldMappings:[]}]}}}}t(t=>({edges:nA({...e,type:"design",animated:!1,data:{networkLatencyMs:u,...d?{edgeType:d}:{},...o?{metadata:o}:{},...r?{inputBindings:r}:{}}},t.edges)}))},addNode:(o,r,i)=>{if(aW())return"";let a=n();a.pushSnapshot();let s=`node_${a.nextId}`,l=aZ(o,a.nextId),d=aU[a.cloudProvider]??"us-east-1",u=function(t){try{let{useAppConfigStore:n}=e.r(318321),o=n.getState().defaults,r={Service:"service",Cache:"cache",Database:"database",LoadBalancer:"load_balancer",EventStream:"event_stream",Worker:"worker"}[t];if(r&&r in o)return{...o[r]};return{}}catch{return{}}}(o),c=rV(o,l),h={id:s,type:"component",position:r,data:{label:l,componentType:o,config:{region:d,...u,...i?.defaultParams??{},...i?.defaultTierSpecs??{},...c},origin:"user",...i?.serviceKey?{cloudServiceKey:i.serviceKey}:{},...i?.defaultTierName?{cloudTierName:i.defaultTierName}:{}}};return t(e=>({nodes:[...e.nodes,h],nextId:e.nextId+1})),s},removeNode:e=>{aW()||(n().pushSnapshot(),t(t=>({nodes:t.nodes.filter(t=>t.id!==e),edges:t.edges.filter(t=>t.source!==e&&t.target!==e)})))},updateNodeConfig:(e,o)=>{if(aW())return;let r=n();r.pushSnapshot();let{cloudTierName:i,cloudServiceKey:a,...s}=o,l=r.nodes.map(t=>{if(t.id!==e)return t;let n={...t.data,config:{...t.data.config,...s}};return void 0!==i&&(n.cloudTierName=i),void 0!==a&&(n.cloudServiceKey=a),{...t,data:n}}),d=rK.some(e=>e in s)?rW(r.nodes,l,r.edges):[];if(0===d.length)return void t({nodes:l});let u=new Map(d.map(e=>[e.edgeId,e.metadata]));t({nodes:l,edges:r.edges.map(e=>u.has(e.id)?{...e,data:{...e.data,metadata:u.get(e.id)}}:e)})},updateNodeLabel:(e,o)=>{aW()||(n().pushSnapshot(),t(t=>({nodes:t.nodes.map(t=>t.id===e?{...t,data:{...t.data,label:o}}:t)})))},updateNodeDomain:(e,o)=>{aW()||(n().pushSnapshot(),t(t=>({nodes:t.nodes.map(t=>t.id===e?{...t,data:{...t.data,domain:o}}:t)})))},toggleCluster:e=>{aW()||t(t=>({collapsedClusters:t.collapsedClusters.includes(e)?t.collapsedClusters.filter(t=>t!==e):[...t.collapsedClusters,e]}))},duplicateNode:e=>{if(aW())return null;let o=n(),r=o.nodes.find(t=>t.id===e);if(!r)return null;o.pushSnapshot();let i=`node_${o.nextId}`,a=aZ(r.data.componentType,o.nextId),s={id:i,type:"component",position:{x:r.position.x+80,y:r.position.y+60},data:{label:a,componentType:r.data.componentType,config:{...r.data.config}}};return t(e=>({nodes:[...e.nodes,s],nextId:e.nextId+1})),i},updateEdgeData:(e,o)=>{aW()||(n().pushSnapshot(),t(t=>({edges:t.edges.map(t=>t.id===e?{...t,data:{...t.data,...o}}:t)})))},updateEdgeWaypoints:(e,n)=>{aW()||t(t=>({edges:t.edges.map(t=>t.id===e?{...t,data:{...t.data,waypoints:n}}:t)}))},setEdgeLabelOffset:(e,n)=>{aW()||t(t=>({edges:t.edges.map(t=>{if(t.id!==e)return t;let o={...t.data};return null===n?delete o.labelOffset:o.labelOffset=n,{...t,data:o}})}))},updateEdgeHandles:(e,o)=>{aW()||(n().pushSnapshot(),t(t=>({edges:t.edges.map(t=>{if(t.id!==e)return t;let n={...t};return"sourceHandle"in o&&(n.sourceHandle=o.sourceHandle??void 0),"targetHandle"in o&&(n.targetHandle=o.targetHandle??void 0),n})})))},removeEdge:e=>{aW()||(n().pushSnapshot(),t(t=>({edges:t.edges.filter(t=>t.id!==e)})))},reverseEdge:e=>{if(aW())return;let o=n(),r=o.edges.find(t=>
2t.id===e);if(!r)return;o.pushSnapshot();let i=r.target,a=r.source,s=r.targetHandle?r.targetHandle.replace("target","source"):void 0,l=r.sourceHandle?r.sourceHandle.replace("source","target"):void 0,d=o.nodes.find(e=>e.id===i),u=o.nodes.find(e=>e.id===a),c=d&&u?rL(d.data.componentType,u.data.componentType):void 0;t(t=>({edges:t.edges.map(t=>t.id===e?{...t,source:i,target:a,sourceHandle:s,targetHandle:l,data:{...t.data,...c?{edgeType:c}:{},metadata:void 0,inputBindings:[]}}:t)}))},setCloudProvider:e=>{if(aW())return;let o=r0(e),r=aU[e]??"us-east-1";if(t({cloudProvider:e,regionLatencyMatrix:o}),n().nodes.length>0){t(e=>({nodes:e.nodes.map(e=>({...e,data:{...e.data,config:{...e.data.config,region:r}}}))}));let e=n().nodes;t(t=>({edges:t.edges.map(t=>{let n=e.find(e=>e.id===t.source),i=e.find(e=>e.id===t.target);if(!n||!i)return t;let a=rU("Client"===n.data.componentType,n.data.config?.region??r,i.data.config?.region??r,o);return{...t,data:{...t.data,networkLatencyMs:a}}})}))}},restoreCloudProvider:e=>{if(aW())return;let n=r0(e);t({cloudProvider:e,regionLatencyMatrix:n})},setRegionLatencyMatrix:e=>{aW()||t({regionLatencyMatrix:e})},updateNodeRegion:(e,o)=>{if(aW())return;let r=n();r.pushSnapshot();let i=r.nodes.map(t=>t.id===e?{...t,data:{...t.data,config:{...t.data.config,region:o}}}:t),a=function(e,t,n,o,r){let i={},a=new Map(o.map(e=>[e.id,e]));for(let o of n){let n=o.source===e,s=o.target===e;if(!n&&!s)continue;let l=a.get(o.source),d=a.get(o.target);if(!l||!d)continue;let u="Client"===l.data.componentType,c=n?t:l.data.config?.region??"default",h=s?t:d.data.config?.region??"default";i[o.id]=rU(u,c,h,r)}return i}(e,o,r.edges,i,r.regionLatencyMatrix);t({nodes:i,edges:r.edges.map(e=>{let t=a[e.id];return void 0===t?e:{...e,data:{...e.data,networkLatencyMs:t}}})})},setDesignRegion:e=>{if(aW())return;let o=n();if(0===o.nodes.length)return;o.pushSnapshot(),t(t=>({nodes:t.nodes.map(t=>({...t,data:{...t.data,config:{...t.data.config,region:e}}}))}));let r=o.regionLatencyMatrix,i=n().nodes;t(t=>({edges:t.edges.map(t=>{let n=i.find(e=>e.id===t.source),o=i.find(e=>e.id===t.target);if(!n||!o)return t;let a=rU("Client"===n.data.componentType,n.data.config?.region??e,o.data.config?.region??e,r);return{...t,data:{...t.data,networkLatencyMs:a}}})}))},applyAutoLayout:e=>{var o;if(aW())return;let r=n();if(0===r.nodes.length)return;e?.scope,r.pushSnapshot();let i=r.layoutRunToken+1;t({layoutRunToken:i});let a=new Set(r.nodes.filter(e=>!!e.data?.pinned).map(e=>e.id)),s=(o=r.edges,o.map(e=>{let t=e.data,n=t?.waypoints;return!Array.isArray(n)||0===n.length||a.has(e.source)&&a.has(e.target)?e:{...e,data:{...t,waypoints:[]}}})),l=r.nodes,d={direction:e?.direction,rankSep:e?.rankSep,nodeSep:e?.nodeSep,clusterGap:e?.clusterGap,clusters:aH(r.nodes,s)},u=(e,o)=>{if(n().layoutRunToken!==i)return;let{edges:r}=function(e,t){let n=new Map(e.map(e=>[e.id,e])),o=new Map(e.map(e=>[e.id,aE(e)])),r=t.some(e=>{let t=n.get(e.source),o=n.get(e.target);return!!t&&!!o&&e.source!==e.target&&aS(aK(t))>aS(aK(o))}),i=null;if(r){let t=-1/0;for(let n of e){let e=ax(n);t=Math.max(t,n.position.y+e.height)}i=(t===-1/0?0:t)+aC.AUTO_FORMAT_FEEDBACK_LANE_GAP_PX}let a=t.map(function(e){if(e.source===e.target)return null;let t=n.get(e.source),r=n.get(e.target);if(!t||!r)return null;if(aS(aK(t))>aS(aK(r)))return{sourceFace:"bottom",targetFace:"bottom",isFeedback:!0};let i=o.get(e.source),a=o.get(e.target),s=a.x-i.x,l=a.y-i.y,d=Math.abs(s),u=Math.abs(l);return d>=1.5*u?s>=0?{sourceFace:"right",targetFace:"left",isFeedback:!1}:{sourceFace:"left",targetFace:"right",isFeedback:!1}:u>1.5*d?l>=0?{sourceFace:"bottom",targetFace:"top",isFeedback:!1}:{sourceFace:"top",targetFace:"bottom",isFeedback:!1}:d>=u?{sourceFace:s>=0?"right":"left",targetFace:l>=0?"top":"bottom",isFeedback:!1}:{sourceFace:l>=0?"bottom":"top",targetFace:s>=0?"left":"right",isFeedback:!1}});function s(e,t,n){let r=o.get(n);return r?"left"===t||"right"===t?r.y:r.x:0}function l(e,n){let o=new Map;t.forEach((t,n)=>{let r=a[n];if(!r)return;let i=e(t,r),s=o.get(i);s?s.push(n):o.set(i,[n])});let r=new Map;for(let e of o.values())[...e].sort((e,o)=>
2n(t[e],a[e])-n(t[o],a[o])).forEach((e,t)=>{r.set(e,t%5+1)});return r}let d=l((e,t)=>`${e.source}::${t.sourceFace}`,(e,t)=>s(e,t.sourceFace,e.target)),u=l((e,t)=>`${e.target}::${t.targetFace}`,(e,t)=>s(e,t.targetFace,e.source));return{edges:t.map((e,t)=>{let n=a[t];if(!n)return e;let o=d.get(t)??1,r=u.get(t)??1;return{...e,sourceHandle:`source-${n.sourceFace}-${o}`,targetHandle:`target-${n.targetFace}-${r}`,data:{...e.data,feedbackLane:n.isFeedback,feedbackLaneY:n.isFeedback?i:void 0,...n.isFeedback?{waypoints:[]}:{}}}}),feedbackLaneY:i}}(e,o),a=(function(e,t){let n=new Map(e.map(e=>[e.id,aE(e)])),o=new Map;t.forEach((e,t)=>{var n,r;if(e.source===e.target)return;let i=(n=e.source)<(r=e.target)?`${n}::${r}`:`${r}::${n}`,a=o.get(i);a?a.push(t):o.set(i,[t])});let r=t.map(()=>({t:.5,lateral:0}));for(let e of o.values())e.forEach((e,t)=>{r[e]=aX[t%aX.length]});let i=e=>{let o=t[e],i=n.get(o.source),a=n.get(o.target);if(!i||!a)return null;let s=r[e],l=a.x-i.x,d=a.y-i.y,u=Math.hypot(l,d)||1;return{x:i.x+l*s.t+-d/u*s.lateral,y:i.y+d*s.t+l/u*s.lateral}};if(t.length<=aC.AUTO_FORMAT_LABEL_RELAX_MAX_LABELS)for(let o=0;o<16;o++){let o=function(){let e=!1;for(let n=0;n<t.length;n++)if(t[n].source!==t[n].target)for(let o=n+1;o<t.length;o++){if(t[o].source===t[o].target)continue;let a=i(n),s=i(o);if(!a||!s)continue;let l=Math.hypot(a.x-s.x,a.y-s.y);if(l<aC.AUTO_FORMAT_LABEL_MIN_SEPARATION_PX){let t=(aC.AUTO_FORMAT_LABEL_MIN_SEPARATION_PX-l)/2;l>0&&(s.x,a.x);let i=l>0?(s.y-a.y)/l:1;r[n]={...r[n],lateral:r[n].lateral-i*t},r[o]={...r[o],lateral:r[o].lateral+i*t},e=!0}}return e}(),a=function(){let o=aC.AUTO_FORMAT_LABEL_NODE_CLEARANCE_WIDTH_PX/2,a=aC.AUTO_FORMAT_LABEL_NODE_CLEARANCE_HEIGHT_PX/2,s=!1;for(let l=0;l<t.length;l++){let d=t[l];if(d.source===d.target)continue;let u=i(l),c=n.get(d.source),h=n.get(d.target);if(u&&c&&h)for(let t of e){if(t.id===d.source||t.id===d.target)continue;let e=ax(t);if(!(u.x>t.position.x-o&&u.x<t.position.x+e.width+o&&u.y>t.position.y-a&&u.y<t.position.y+e.height+a))continue;let n=h.x-c.x,i=h.y-c.y,f=Math.hypot(n,i)||1,g=-i/f,p=n/f,m=t.position.x+e.width/2,y=t.position.y+e.height/2,v=(u.x-m)*g+(u.y-y)*p>=0?1:-1,b=Math.hypot(e.width/2,e.height/2)+Math.hypot(o,a)+4;r[l]={...r[l],lateral:r[l].lateral+v*b},s=!0;break}}return s}();if(!o&&!a)break}return t.map((e,t)=>({...e,data:{...e.data,_labelOffset:r[t]}}))})(e,r).map(e=>{let t=e.data;if(t&&("route"in t||"labelAnchor"in t)){let{route:n,labelAnchor:o,...r}=t;return{...e,data:r}}return e}),s=new Map(l.map(e=>[e.id,e.position])),d=performance.now(),u=o=>{if(n().layoutRunToken!==i)return;let r=Math.min(1,(o-d)/aC.AUTO_FORMAT_ANIMATION_MS),a=1-Math.pow(1-r,3);t({nodes:e.map(e=>{let t=s.get(e.id)??e.position;return{...e,position:{x:t.x+(e.position.x-t.x)*a,y:t.y+(e.position.y-t.y)*a}}})}),r<1?requestAnimationFrame(u):window.dispatchEvent(new CustomEvent("vetora:fit-view"))};t({edges:a}),requestAnimationFrame(u)};aD(r.nodes,s,d).then(e=>u(e.nodes,e.edges)).catch(()=>{let e=aA.compute(r.nodes,s,d);u(e.nodes,e.edges)})},clearCanvas:()=>{if(aW())return;n().pushSnapshot();let o=function(){try{let{useAppConfigStore:t}=e.r(318321);return t.getState().app.default_cloud_provider}catch{return"aws"}}(),r=r0(o);t({nodes:[],edges:[],nextId:1,collapsedClusters:[],cloudProvider:o,regionLatencyMatrix:r})},newDesign:e=>{if(aW())return;n().clearHistory();let o=r0(e);t({nodes:[],edges:[],nextId:1,collapsedClusters:[],cloudProvider:e,regionLatencyMatrix:o})},loadDesign:(e,o)=>{if(aW())return;n().clearHistory();let r=e.reduce((e,t)=>{let n=t.id.match(/(\d+)/);return n?Math.max(e,parseInt(n[1],10)):e},0);t({nodes:e.map(e=>({...e,selected:!1})),edges:o.map(e=>({...e,type:e.type||"design"})),nextId:r+1,collapsedClusters:[]})},setScreenToFlowPosition:e=>t({screenToFlowPosition:e}),stageMutationBatch:e=>{if(aW())return;let o=aQ(n()),r=new Set,i=new Set,a=new Set,s=new Set,l=new Set,d=new Set,u=new Set,c=new Map;for(let t of e.mutations)switch(t.op){case"add_node":{let e=aY(t);e&&(aJ.setState(t=>({nodes:t.nodes.map(t=>t.id===e?{...t,data:{...t.data,isGhost:!0}}:t)})),r.add(e),t.temp_id&&c.set(t.temp_id,e));break}case"remove_node":i.add(t.node_id);break;case"update_node_params":case"update_node_label":a.add(t.node_id);break;case"move_node":aY(t),s.add(t.node_id);break;case"add_edge":{let e=t.source_id.startsWith("temp_")||t.target_id.startsWith("temp_")?{...t,source_id:c.get(t.source_id)??t.source_id,target_id:c.get(t.target_id)??t.target_id}:t,n=new Set(aJ.getState().edges.map(e=>e.id));aY(e);let o=aJ.getState().edges.find(e=>!n.has(e.id));o&&l.add(o.id);break}case"remove_edge":d.add(t.edge_id);break;case"update_edge":u.add(t.edge_id)}t({pendingMutations:e,preBatchSnapshot:o,ghostNodeIds:r,removedNodeIds:i,editedNodeIds:a,movedNodeIds:s,ghostEdgeIds:l,removedEdgeIds:d,editedEdgeIds:u})},acceptMutationBatch:()=>
2{if(aW())return;let e=n();if(!e.pendingMutations)return;let o=e.preBatchSnapshot;if(o){let n=[...e.undoStack,o];n.length>aG()&&n.shift(),t({undoStack:n,redoStack:[],canUndo:!0,canRedo:!1})}for(let t of e.pendingMutations.mutations)"add_node"!==t.op&&"add_edge"!==t.op&&"move_node"!==t.op&&aY(t);aJ.setState(e=>({nodes:e.nodes.map(e=>{if(!e.data.isGhost)return e;let{isGhost:t,...n}=e.data;return{...e,data:n}})})),t({pendingMutations:null,preBatchSnapshot:null,ghostNodeIds:new Set,removedNodeIds:new Set,editedNodeIds:new Set,movedNodeIds:new Set,ghostEdgeIds:new Set,removedEdgeIds:new Set,editedEdgeIds:new Set})},acceptPartialMutationBatch:e=>{if(aW())return;let t=n();if(!t.pendingMutations)return;let o=t.pendingMutations,r=o.mutations.filter((t,n)=>e.has(n));if(0===r.length)return;n().rejectMutationBatch();let i={...o,mutations:r,summary:`${r.length} of ${o.mutations.length} changes accepted`};n().stageMutationBatch(i),n().acceptMutationBatch()},rejectMutationBatch:()=>{if(aW())return;let e=n(),o=e.ghostNodeIds,r=e.ghostEdgeIds;aJ.setState(e=>({nodes:e.nodes.filter(e=>!o.has(e.id)),edges:e.edges.filter(e=>!r.has(e.id))}));let i=e.preBatchSnapshot;if(i&&e.movedNodeIds.size>0){let t=e.movedNodeIds;aJ.setState(e=>({nodes:e.nodes.map(e=>{if(!t.has(e.id))return e;let n=i.nodes.find(t=>t.id===e.id);return n?{...e,position:{...n.position}}:e})}))}t({pendingMutations:null,preBatchSnapshot:null,ghostNodeIds:new Set,removedNodeIds:new Set,editedNodeIds:new Set,movedNodeIds:new Set,ghostEdgeIds:new Set,removedEdgeIds:new Set,editedEdgeIds:new Set})}})),a0=()=>aJ(e=>null!==e.pendingMutations)},352278,e=>{"use strict";var t=e.i(768834),n=e.i(768774);function o(e,t,o){let r=e.get(t);if(!r)return void e.set(t,[o]);let i=n.SSE_STREAM.MAX_METRICS_HISTORY_PER_SERIES,a=r.length>=i?[...r.slice(r.length-i+1),o]:[...r,o];e.set(t,a)}function r(e,t){let o=n.SSE_STREAM.MAX_LOG_ENTRIES;return e.length>=o?[...e.slice(e.length-o+1),t]:[...e,t]}function i(e,t){let n=new Map(e.latestMetrics),r=new Map(e.metricsHistory),i=new Map(e.cumulativeCompleted),a=new Map(e.cumulativeDropped);for(let e of t)n.set(e.component_id,e),o(r,e.component_id,e),i.set(e.component_id,(i.get(e.component_id)??0)+e.requests_completed),a.set(e.component_id,(a.get(e.component_id)??0)+e.requests_dropped);return{latestMetrics:n,metricsHistory:r,cumulativeCompleted:i,cumulativeDropped:a}}function a(e,t){let n=new Map(e.latestEndpointMetrics),r=new Map(e.endpointMetricsHistory);for(let e of t){let t=e.endpoint?.label??`${e.component_id}:unknown`;n.set(t,e),o(r,t,e)}return{latestEndpointMetrics:n,endpointMetricsHistory:r}}let s={duration_seconds:10,random_seed:42,metrics_interval_ms:1e3,max_events:0},l={type:"constant",base_rps:1e3,peak_rps:2e3},d={trace_enabled:!0,max_steps:5e3,timeout_ms:3e4},u=(0,t.create)(e=>({status:"idle",runId:0,simulationMode:"performance",selectedScenario:"",engineVersion:"v2.0",simulatorConfig:s,trafficConfig:l,progress:null,latestMetrics:new Map,metricsHistory:new Map,cumulativeCompleted:new Map,cumulativeDropped:new Map,latestEndpointMetrics:new Map,endpointMetricsHistory:new Map,bottleneckAlerts:[],result:null,simulationLogs:[],error:null,componentBehaviors:{},inputEvents:[],assertions:[],assertionResults:[],traces:[],functionalConfig:d,setStatus:t=>e({status:t}),setSimulationMode:t=>e({simulationMode:t}),setSelectedScenario:t=>e({selectedScenario:t}),setEngineVersion:t=>e({engineVersion:t}),setSimulatorConfig:t=>e(e=>({simulatorConfig:{...e.simulatorConfig,...t}})),setTrafficConfig:t=>e({trafficConfig:t}),restoreInputs:t=>e({trafficConfig:t?.trafficConfig??l,simulatorConfig:t?.simulatorConfig??s}),setProgress:t=>e({progress:t}),updateMetrics:t=>e(e=>i(e,t)),updateEndpointMetrics:t=>e(e=>a(e,t)),applyMetricsSnapshot:({components:t,endpoints:n,log:o})=>e(e=>{let s=i(e,t);return n&&n.length>0&&(s={...s,...a(e,n)}),o&&(s={...s,simulationLogs:r(e.simulationLogs,{timestamp:Date.now(),level:o.level,message:o.message})}),s}),addBottleneck:t=>e(e=>{let n=`${t.component_id}:${t.bottleneck_type}`;return e.bottleneckAlerts.some(e=>`${e.component_id}:${e.bottleneck_type}`===n)?e:{bottleneckAlerts:[...e.bottleneckAlerts,t]}}),setResult:t=>e({result:t,status:"completed"}),setError:t=>e({error:t,status:"failed"}),addLog:(t,n)=>e(e=>({simulationLogs:r(e.simulationLogs,{timestamp:Date.now(),level:t,message:n})}
2)),setComponentBehaviors:t=>e({componentBehaviors:t}),setComponentBehavior:(t,n)=>e(e=>({componentBehaviors:{...e.componentBehaviors,[t]:n}})),setInputEvents:t=>e({inputEvents:t}),setAssertions:t=>e({assertions:t}),setAssertionResults:t=>e({assertionResults:t}),setTraces:t=>e({traces:t}),setFunctionalConfig:t=>e(e=>({functionalConfig:{...e.functionalConfig,...t}})),reset:()=>e(e=>({status:"idle",runId:e.runId+1,progress:null,latestMetrics:new Map,metricsHistory:new Map,cumulativeCompleted:new Map,cumulativeDropped:new Map,latestEndpointMetrics:new Map,endpointMetricsHistory:new Map,bottleneckAlerts:[],result:null,simulationLogs:[],error:null,componentBehaviors:{},inputEvents:[],assertions:[],assertionResults:[],traces:[],functionalConfig:d}))}));e.s(["useSimulationStore",0,u])}]);
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.