All Downloads are FREE. Search and download functionalities are using the official Maven repository.

theme.keycloak.v2.admin.resources.assets.FlowDetails-C4B1eudZ.js Maven / Gradle / Ivy

There is a newer version: 26.0.7
Show newest version
import{jsx as S,jsxs as re,Fragment as Ce}from"react/jsx-runtime";import*as Te from"react";import I,{useEffect as ce,useState as ae,useMemo as Oe,createContext as jf,memo as ue,forwardRef as Qf,useRef as ne,useContext as wr,useCallback as me}from"react";import{_ as Ds,l as Pt,h as _e,B as ut,m as Dm,n as Jf,a as ze,o as eh,C as Fm,u as nn,f as Fs,g as br,M as In,q as An,F as _r,r as Mn,j as vt,s as Om,v as Tn,w as zm,P as th,R as Hm,x as nr,y as Lc,T as Bm,z as Vm,E as Gm,G as Os,H as nh,I as xr,J as Um,K as rh,N as Ym,D as qt,O as Km,A as Wm,Q as Zm,S as Xm,U as jm,V as Qm,W as Jm,X as ev,Y as tv,Z as ih,$ as oh,c as nv,e as rv,d as iv,i as ov,k as av,a0 as sv,a1 as cv,a2 as Yr}from"./index-C1LIsRX7.js";import{u as Pc}from"./ConfirmDialog-B5qjiAuo.js";import{V as uv}from"./ViewHeader-qjLr6U82.js";import{u as gs}from"./useToggle-K3Kx99tM.js";import{C as lv,B as dv,D as fv}from"./AuthenticationSection-CEzcDulC.js";import{N as hv}from"./NameDescription-CQ_fNXVs.js";import{P as pv,L as gv}from"./PaginatingTableToolbar-CpMLQtqt.js";import{r as mv,a as ah,b as vv,c as rn,d as Er,e as qn,f as sh,g as Ee,h as Rn,_ as Sr,i as zs,j as yv,k as wv,l as ch,m as Nr,n as bv,o as kn,p as Hs,q as uh,s as Bs,t as _v,u as xv,v as Cr,w as Vs,x as Ev,y as Ln,z as lh,A as Pn,B as dh,C as Sv,D as fh,E as Gs,F as Us,G as hh,H as Nv,I as Cv,J as ph,K as Ys,L as Iv,M as gh,N as Ks,O as Av,P as Mv,Q as Tv,R as qv,S as Rv}from"./Td-BwjBKSkH.js";import"react-dom";import{D as mh,a as kv,b as Lv,c as Pv,d as $v}from"./Droppable-DrenVtJB.js";import{s as Kr,D as vh,a as yh,b as wh,c as Wt,d as Dv}from"./DataListItemRow-COCiEHyF.js";import{P as Fv}from"./pencil-alt-icon-CuChRX1Z.js";import{D as Ov}from"./DynamicComponents-CIZcko9u.js";import{T as bh}from"./trash-icon-DDaN0w_B.js";import{T as $c}from"./Trans-DZTM8FLp.js";import{F as Dc,a as Fc}from"./FlexItem-DCAd8FXq.js";import"./RoutableTabs-j5CUH0-6.js";import"./PageHandler-CFMh3rCu.js";import"./useParams-n_2fXkN1.js";import"./PageList-D9zZFEpa.js";import"./KeycloakDataTable-jyvvxdb8.js";import"./_baseFlatten-BHAcGTxk.js";import"./Tabs-CNBvRApH.js";import"./DraggableTable-BwAWTeWo.js";import"./AddRoleMappingModal-Ds4yp8lg.js";import"./filter-icon-BVyMUArZ.js";import"./FormAccess-BcY70QlP.js";import"./copy-icon-DOS8MmN7.js";import"./TimeSelectorControl-BQB3aFfv.js";import"./TimeSelector-yr8Y_36J.js";import"./EmptyStateFooter-Cm2IMTi1.js";import"./EmptyStateActions-DBSnfkAA.js";import"./MultiLineInput-AcwuO_FT.js";import"./question-circle-icon-Dbt6ViOg.js";import"./sortBy-L-dz5MSQ.js";import"./grip-vertical-icon-Bnn0MebT.js";import"./ClientSelect-BTkwOwGP.js";import"./FileUpload-T43Q4AfB.js";import"./CodeEditor-CIeIZGz7.js";import"./GroupPickerDialog-DmX3SBxL.js";import"./KeySelect-B2uWUd6C.js";const _h=e=>{var{className:t="",isExpanded:n=!1,"aria-controls":r="","aria-label":i="Details",rowid:o="",id:a,buttonProps:s}=e,c=Ds(e,["className","isExpanded","aria-controls","aria-label","rowid","id","buttonProps"]);return Te.createElement("div",Object.assign({className:Pt(Kr.dataListItemControl,t)},c),Te.createElement("div",{className:Pt(Kr.dataListToggle)},Te.createElement(_e,Object.assign({id:a,variant:ut.plain,"aria-controls":r!==""&&r,"aria-label":i,"aria-labelledby":i!=="Details"?null:`${o} ${a}`,"aria-expanded":n},s),Te.createElement("div",{className:Pt(Kr.dataListToggleIcon)},Te.createElement(Dm,null)))))};_h.displayName="DataListToggle";const $t={modifiers:{compact:"pf-m-compact",selected:"pf-m-selected",disabled:"pf-m-disabled"},themeDark:"pf-v5-theme-dark",toggleGroup:"pf-v5-c-toggle-group",toggleGroupButton:"pf-v5-c-toggle-group__button",toggleGroupIcon:"pf-v5-c-toggle-group__icon",toggleGroupItem:"pf-v5-c-toggle-group__item",toggleGroupText:"pf-v5-c-toggle-group__text"};var rr;(function(e){e.icon="icon",e.text="text"})(rr||(rr={}));const ms=({variant:e,children:t})=>Te.createElement("span",{className:Pt(e==="icon"&&$t.toggleGroupIcon,e==="text"&&$t.toggleGroupText)},t);ms.displayName="ToggleGroupItemElement";const ir=e=>{var{text:t,icon:n,className:r,isDisabled:i=!1,isSelected:o=!1,"aria-label":a="",onChange:s=()=>{},buttonId:c=""}=e,l=Ds(e,["text","icon","className","isDisabled","isSelected","aria-label","onChange","buttonId"]);const u=d=>{s(d,!o)};return!a&&n&&!t&&console.warn("An accessible aria-label is required when using the toggle group item icon variant."),Te.createElement("div",Object.assign({className:Pt($t.toggleGroupItem,r)},l),Te.createElement("button",Object.assign({type:"button",className:Pt($t.toggleGroupButton,o&&$t.modifiers.selected),"aria-pressed":o,onClick:u},a&&{"aria-label":a},i&&{disabled:!0},c&&{id:c}),n?Te.createElement(ms,{variant:rr.icon},n):null,t?Te.createElement(ms,{variant:rr.text},t):null))};ir.displayName="ToggleGroupItem";const xh=e=>{var{className:t,children:n,isCompact:r=!1,areAllGroupsDisabled:i=!1,"aria-label":o}=e,a=Ds(e,["className","children","isCompact","areAllGroupsDisabled","aria-label"]);const s=Te.Children.map(n,c=>Te.isValidElement(c)&&c.type===ir?Te.cloneElement(c,i?{isDisabled:!0}:{}):c);return Te.createElement("div",Object.assign({className:Pt($t.toggleGroup,r&&$t.modifiers.compact,t),role:"group","aria-label":o},a),s)};xh.displayName="ToggleGroup";const zv={name:"DomainIcon",height:1024,width:1024,svgPath:"M544,511.9 C561.476067,511.948945 575.664266,525.962873 575.994253,543.371439 L576,543.9 L576,991.9 C575.951055,1009.37607 561.937127,1023.56427 544.528561,1023.89425 L544,1023.9 L352,1023.9 C334.523933,1023.85105 320.335734,1009.83713 320.005747,992.428561 L320,991.9 L320,543.9 C320.048945,526.423933 334.062873,512.235734 351.471439,511.905747 L352,511.9 L544,511.9 Z M704,576 L704,960 L640,960 L640,576 L704,576 Z M512,896 L384,896 L384,960 L512,960 L512,896 Z M960,513.1 L960,513.2 C960,665.4 884.1,799.9 768,880.9 L768,880.9 L768,799.4 C773.3,794.6 778.4,789.8 783.5,784.7 C855.624209,712.728348 896.108133,614.991161 896,513.1 L896,513.1 L960,513.1 Z M149.8,385 C100.714385,524.561202 135.973879,679.905126 240.5,784.6 C245.5,789.7 250.7,794.6 256,799.3 L256,799.3 L256,880.8 C139.9,799.8 63.9999013,665.3 63.9999013,513.1 C63.9712238,469.725105 70.236499,426.575548 82.6,385 L82.6,385 Z M512.1,704 L384,704 L384,832 L512.1,832 L512.1,704 Z M512,576 L448,576 L448,640 L512,640 L512,576 Z M864,-1.13686838e-13 C881.496381,-1.13686838e-13 895.713128,14.0417829 895.995713,31.4708215 L896,32 L896,406 C896,423.496381 881.958217,437.713128 864.529179,437.995713 L864,438 L608,438 C590.503619,438 576.286872,423.958217 576.004287,406.529179 L576,406 L576,32 C576,14.5036191 590.041783,0.286872383 607.470821,0.00428708574 L608,-1.13686838e-13 L864,-1.13686838e-13 Z M1024,64 L1024,384 L960,384 L960,64 L1024,64 Z M832,256 L640,256 L640,352 L832,352 L832,256 Z M224,-5.68434189e-14 C241.476067,0.0489452394 255.664266,14.0628726 255.994253,31.4714395 L256,32 L256,288 C255.951055,305.476067 241.937127,319.664266 224.528561,319.994253 L224,320 L32,320 C14.5239331,319.951055 0.335734448,305.937127 0.00574685353,288.528561 L0,288 L0,32 C0.0489452394,14.5239331 14.0628726,0.335734448 31.4714395,0.00574685353 L32,-5.68434189e-14 L224,-5.68434189e-14 Z M192,192 L64,192 L64,256 L192,256 L192,192 Z M512,65 L512,129 C460.642759,128.90985 409.795141,139.181409 362.5,159.2 C347.917219,165.399771 333.724426,172.47947 320,180.4 L320,180.4 L320,108.2 C380.012207,79.7623165 445.590913,65.0071076 512,65 L512,65 Z M832,64 L736,64 L736,160 L832,160 L832,64 Z M192,64 L128,64 L128,128 L192,128 L192,64 Z",yOffset:0,xOffset:0},Hv=Jf(zv),Bv={name:"TableIcon",height:512,width:512,svgPath:"M464 32H48C21.49 32 0 53.49 0 80v352c0 26.51 21.49 48 48 48h416c26.51 0 48-21.49 48-48V80c0-26.51-21.49-48-48-48zM224 416H64v-96h160v96zm0-160H64v-96h160v96zm224 160H288v-96h160v96zm0-160H288v-96h160v96z",yOffset:0,xOffset:0},Vv=Jf(Bv),Gv="_icon_1gmts_2",Uv={icon:Gv},Yv=()=>{const{t:e}=ze();return S(eh,{icon:S(Fm,{className:Uv.icon}),children:e("buildIn")})},Kv=({flow:e,toggleDialog:t})=>{const{adminClient:n}=nn(),{t:r}=ze(),{addAlert:i,addError:o}=Fs(),a=br({mode:"onChange"}),{reset:s,handleSubmit:c}=a;ce(()=>s(e),[e]);const l=async u=>{try{await n.authenticationManagement.updateFlow({flowId:e.id},{...e,...u}),i(r("updateFlowSuccess"),vt.success)}catch(d){o("updateFlowError",d)}t()};return S(In,{title:r("editFlow"),onClose:t,variant:An.small,actions:[S(_e,{"data-testid":"confirm",type:"submit",form:"edit-flow-form",children:r("edit")},"confirm"),S(_e,{"data-testid":"cancel",variant:ut.link,onClick:()=>t(),children:r("cancel")},"cancel")],isOpen:!0,children:S(_r,{...a,children:S(Mn,{id:"edit-flow-form",onSubmit:c(l),isHorizontal:!0,children:S(hv,{})})})})},Wv=({list:e,setValue:t})=>S(th,{variant:"light",className:"pf-v5-u-py-lg",children:S(Mn,{isHorizontal:!0,children:e?.map(n=>S(Hm,{id:n.id,name:"provider",label:n.displayName,"data-testid":n.id,description:n.description,onChange:()=>{t(n)}},n.id))})}),Ws=({name:e,type:t,onSelect:n})=>{const{adminClient:r}=nn(),{t:i}=ze(),[o,a]=ae(),[s,c]=ae(),[l,u]=ae(10),[d,f]=ae(0),[h,p]=ae(""),g=Om();Tn(async()=>{switch(t){case"client":return r.authenticationManagement.getClientAuthenticatorProviders();case"form":return r.authenticationManagement.getFormActionProviders();case"condition":return(await r.authenticationManagement.getAuthenticatorProviders()).filter(yr);case"basic":default:return(await r.authenticationManagement.getAuthenticatorProviders()).filter(b=>!yr(b))}},v=>c(v),[]);const m=Oe(()=>{const v=h.trim().toLowerCase();return g(s??[],zm("displayName")).filter(({displayName:b,description:_})=>b?.toLowerCase().includes(v)||_?.toLowerCase().includes(v)).slice(d,d+l+1)},[s,h,d,l]);return S(In,{variant:An.medium,isOpen:!0,title:i("addStepTo",{name:e}),onClose:()=>n(),actions:[S(_e,{id:"modal-add","data-testid":"modal-add",onClick:()=>n(o),children:i("add")},"add"),S(_e,{"data-testid":"cancel",id:"modal-cancel",variant:ut.link,onClick:()=>{n()},children:i("cancel")},"cancel")],children:s&&S(pv,{count:m.length||0,first:d,max:l,onNextClick:f,onPreviousClick:f,onPerPageSelect:(v,b)=>{f(v),u(b)},inputGroupName:"search",inputGroupPlaceholder:i("search"),inputGroupOnEnter:p,children:S(Wv,{list:m.slice(0,l),setValue:a})})})},Oc=["basic-flow","form-flow"],Zs=({name:e,onConfirm:t,onCancel:n})=>{const{adminClient:r}=nn(),{t:i}=ze(),o=br(),[a,s]=ae();return Tn(()=>r.authenticationManagement.getFormProviders(),s,[]),ce(()=>{a?.length===1&&o.setValue("provider",a[0].id)},[a]),S(In,{variant:An.medium,title:i("addStepTo",{name:e}),onClose:n,actions:[S(_e,{"data-testid":"modal-add",type:"submit",form:"sub-flow-form",children:i("add")},"add"),S(_e,{"data-testid":"cancel",variant:ut.link,onClick:n,children:i("cancel")},"cancel")],isOpen:!0,children:S(Mn,{id:"sub-flow-form",onSubmit:o.handleSubmit(t),isHorizontal:!0,children:re(_r,{...o,children:[S(nr,{name:"name",label:i("name"),labelIcon:i("clientIdHelp"),rules:{required:{value:!0,message:i("required")}}}),S(nr,{name:"description",label:i("description"),labelIcon:i("flowNameDescriptionHelp")}),S(Lc,{name:"type",menuAppendTo:"parent",label:i("flowType"),options:Oc.map(c=>({key:c,value:i(`flow-type.${c}`)})),controller:{defaultValue:Oc[0]}}),a&&a.length>1&&S(Lc,{name:"provider",label:i("provider"),labelIcon:i("authenticationFlowTypeHelp"),options:a.map(c=>({key:c.id,value:c.displayName})),controller:{defaultValue:""}})]})})})},Zv=["addExecution","addSubFlow"],Xv=({flow:e,onAddExecution:t,onAddFlow:n})=>{const{t:r}=ze(),[i,o]=ae();return re(Ce,{children:[i==="addExecution"&&S(Ws,{name:e.alias,type:e.providerId==="client-flow"?"client":"basic",onSelect:a=>{a&&t(a),o(void 0)}}),i==="addSubFlow"&&S(Zs,{name:e.alias,onCancel:()=>o(void 0),onConfirm:a=>{n(a),o(void 0)}}),S(gv,{message:r("emptyExecution"),instructions:r("emptyExecutionInstructions")}),S("div",{className:"keycloak__empty-execution-state__block",children:Zv.map(a=>re(Dc,{className:"keycloak__empty-execution-state__help",children:[re(Fc,{flex:{default:"flex_1"},children:[S(Bm,{headingLevel:"h2",size:Vm.md,children:r(`${a}Title`)}),S("p",{children:r(a)})]}),S(Dc,{alignSelf:{default:"alignSelfCenter"},children:S(Fc,{children:S(_e,{"data-testid":a,variant:"tertiary",onClick:()=>o(a),children:r(a)})})})]},a))})]})};function Se(e){if(typeof e=="string"||typeof e=="number")return""+e;let t="";if(Array.isArray(e))for(let n=0,r;n"u"||typeof window.document>"u"||typeof window.document.createElement>"u"?iy:ry;Ch.useSyncExternalStore=Qt.useSyncExternalStore!==void 0?Qt.useSyncExternalStore:oy;Nh.exports=Ch;var ay=Nh.exports;/**
 * @license React
 * use-sync-external-store-shim/with-selector.production.min.js
 *
 * Copyright (c) Facebook, Inc. and its affiliates.
 *
 * This source code is licensed under the MIT license found in the
 * LICENSE file in the root directory of this source tree.
 */var Ir=I,sy=ay;function cy(e,t){return e===t&&(e!==0||1/e===1/t)||e!==e&&t!==t}var uy=typeof Object.is=="function"?Object.is:cy,ly=sy.useSyncExternalStore,dy=Ir.useRef,fy=Ir.useEffect,hy=Ir.useMemo,py=Ir.useDebugValue;Sh.useSyncExternalStoreWithSelector=function(e,t,n,r,i){var o=dy(null);if(o.current===null){var a={hasValue:!1,value:null};o.current=a}else a=o.current;o=hy(function(){function c(h){if(!l){if(l=!0,u=h,h=r(h),i!==void 0&&a.hasValue){var p=a.value;if(i(p,h))return d=p}return d=h}if(p=d,uy(u,h))return p;var g=r(h);return i!==void 0&&i(p,g)?p:(u=h,d=g)}var l=!1,u,d,f=n===void 0?null:n;return[function(){return c(t())},f===null?void 0:function(){return c(f())}]},[t,n,r,i]);var s=ly(e,o[0],o[1]);return fy(function(){a.hasValue=!0,a.value=s},[s]),py(s),s};Eh.exports=Sh;var gy=Eh.exports;const my=Gm(gy);var vy={BASE_URL:"./",MODE:"production",DEV:!1,PROD:!0,SSR:!1};const zc=e=>{let t;const n=new Set,r=(u,d)=>{const f=typeof u=="function"?u(t):u;if(!Object.is(f,t)){const h=t;t=d??(typeof f!="object"||f===null)?f:Object.assign({},t,f),n.forEach(p=>p(t,h))}},i=()=>t,c={setState:r,getState:i,getInitialState:()=>l,subscribe:u=>(n.add(u),()=>n.delete(u)),destroy:()=>{(vy?"production":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()}},l=t=e(r,i,c);return c},yy=e=>e?zc(e):zc,{useDebugValue:wy}=I,{useSyncExternalStoreWithSelector:by}=my,_y=e=>e;function Ih(e,t=_y,n){const r=by(e.subscribe,e.getState,e.getServerState||e.getInitialState,t,n);return wy(r),r}const Hc=(e,t)=>{const n=yy(e),r=(i,o=t)=>Ih(n,i,o);return Object.assign(r,n),r},xy=(e,t)=>e?Hc(e,t):Hc;function xe(e,t){if(Object.is(e,t))return!0;if(typeof e!="object"||e===null||typeof t!="object"||t===null)return!1;if(e instanceof Map&&t instanceof Map){if(e.size!==t.size)return!1;for(const[r,i]of e)if(!Object.is(i,t.get(r)))return!1;return!0}if(e instanceof Set&&t instanceof Set){if(e.size!==t.size)return!1;for(const r of e)if(!t.has(r))return!1;return!0}const n=Object.keys(e);if(n.length!==Object.keys(t).length)return!1;for(const r of n)if(!Object.prototype.hasOwnProperty.call(t,r)||!Object.is(e[r],t[r]))return!1;return!0}var Ey={value:()=>{}};function Ar(){for(var e=0,t=arguments.length,n={},r;e=0&&(r=n.slice(i+1),n=n.slice(0,i)),n&&!t.hasOwnProperty(n))throw new Error("unknown type: "+n);return{type:n,name:r}})}Qn.prototype=Ar.prototype={constructor:Qn,on:function(e,t){var n=this._,r=Sy(e+"",n),i,o=-1,a=r.length;if(arguments.length<2){for(;++o0)for(var n=new Array(i),r=0,i,o;r=0&&(t=e.slice(0,n))!=="xmlns"&&(e=e.slice(n+1)),Vc.hasOwnProperty(t)?{space:Vc[t],local:e}:e}function Cy(e){return function(){var t=this.ownerDocument,n=this.namespaceURI;return n===vs&&t.documentElement.namespaceURI===vs?t.createElement(e):t.createElementNS(n,e)}}function Iy(e){return function(){return this.ownerDocument.createElementNS(e.space,e.local)}}function Ah(e){var t=Mr(e);return(t.local?Iy:Cy)(t)}function Ay(){}function Xs(e){return e==null?Ay:function(){return this.querySelector(e)}}function My(e){typeof e!="function"&&(e=Xs(e));for(var t=this._groups,n=t.length,r=new Array(n),i=0;i=_&&(_=b+1);!(M=m[_])&&++_=0;)(a=r[i])&&(o&&a.compareDocumentPosition(o)^4&&o.parentNode.insertBefore(a,o),o=a);return this}function e0(e){e||(e=t0);function t(d,f){return d&&f?e(d.__data__,f.__data__):!d-!f}for(var n=this._groups,r=n.length,i=new Array(r),o=0;ot?1:e>=t?0:NaN}function n0(){var e=arguments[0];return arguments[0]=this,e.apply(null,arguments),this}function r0(){return Array.from(this)}function i0(){for(var e=this._groups,t=0,n=e.length;t1?this.each((t==null?g0:typeof t=="function"?v0:m0)(e,t,n??"")):Jt(this.node(),e)}function Jt(e,t){return e.style.getPropertyValue(t)||kh(e).getComputedStyle(e,null).getPropertyValue(t)}function w0(e){return function(){delete this[e]}}function b0(e,t){return function(){this[e]=t}}function _0(e,t){return function(){var n=t.apply(this,arguments);n==null?delete this[e]:this[e]=n}}function x0(e,t){return arguments.length>1?this.each((t==null?w0:typeof t=="function"?_0:b0)(e,t)):this.node()[e]}function Lh(e){return e.trim().split(/^|\s+/)}function js(e){return e.classList||new Ph(e)}function Ph(e){this._node=e,this._names=Lh(e.getAttribute("class")||"")}Ph.prototype={add:function(e){var t=this._names.indexOf(e);t<0&&(this._names.push(e),this._node.setAttribute("class",this._names.join(" ")))},remove:function(e){var t=this._names.indexOf(e);t>=0&&(this._names.splice(t,1),this._node.setAttribute("class",this._names.join(" ")))},contains:function(e){return this._names.indexOf(e)>=0}};function $h(e,t){for(var n=js(e),r=-1,i=t.length;++r=0&&(n=t.slice(r+1),t=t.slice(0,r)),{type:t,name:n}})}function X0(e){return function(){var t=this.__on;if(t){for(var n=0,r=-1,i=t.length,o;n()=>e;function ys(e,{sourceEvent:t,subject:n,target:r,identifier:i,active:o,x:a,y:s,dx:c,dy:l,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:r,enumerable:!0,configurable:!0},identifier:{value:i,enumerable:!0,configurable:!0},active:{value:o,enumerable:!0,configurable:!0},x:{value:a,enumerable:!0,configurable:!0},y:{value:s,enumerable:!0,configurable:!0},dx:{value:c,enumerable:!0,configurable:!0},dy:{value:l,enumerable:!0,configurable:!0},_:{value:u}})}ys.prototype.on=function(){var e=this._.on.apply(this._,arguments);return e===this._?this:e};function aw(e){return!e.ctrlKey&&!e.button}function sw(){return this.parentNode}function cw(e,t){return t??{x:e.x,y:e.y}}function uw(){return navigator.maxTouchPoints||"ontouchstart"in this}function lw(){var e=aw,t=sw,n=cw,r=uw,i={},o=Ar("start","drag","end"),a=0,s,c,l,u,d=0;function f(w){w.on("mousedown.drag",h).filter(r).on("touchstart.drag",m).on("touchmove.drag",v,ow).on("touchend.drag touchcancel.drag",b).style("touch-action","none").style("-webkit-tap-highlight-color","rgba(0,0,0,0)")}function h(w,M){if(!(u||!e.call(this,w,M))){var N=_(this,t.call(this,w,M),w,M,"mouse");N&&(De(w.view).on("mousemove.drag",p,wn).on("mouseup.drag",g,wn),zh(w.view),Zr(w),l=!1,s=w.clientX,c=w.clientY,N("start",w))}}function p(w){if(Zt(w),!l){var M=w.clientX-s,N=w.clientY-c;l=M*M+N*N>d}i.mouse("drag",w)}function g(w){De(w.view).on("mousemove.drag mouseup.drag",null),Hh(w.view,l),Zt(w),i.mouse("end",w)}function m(w,M){if(e.call(this,w,M)){var N=w.changedTouches,A=t.call(this,w,M),q=N.length,T,F;for(T=0;T>8&15|t>>4&240,t>>4&15|t&240,(t&15)<<4|t&15,1):n===8?Hn(t>>24&255,t>>16&255,t>>8&255,(t&255)/255):n===4?Hn(t>>12&15|t>>8&240,t>>8&15|t>>4&240,t>>4&15|t&240,((t&15)<<4|t&15)/255):null):(t=fw.exec(e))?new qe(t[1],t[2],t[3],1):(t=hw.exec(e))?new qe(t[1]*255/100,t[2]*255/100,t[3]*255/100,1):(t=pw.exec(e))?Hn(t[1],t[2],t[3],t[4]):(t=gw.exec(e))?Hn(t[1]*255/100,t[2]*255/100,t[3]*255/100,t[4]):(t=mw.exec(e))?Xc(t[1],t[2]/100,t[3]/100,1):(t=vw.exec(e))?Xc(t[1],t[2]/100,t[3]/100,t[4]):Gc.hasOwnProperty(e)?Kc(Gc[e]):e==="transparent"?new qe(NaN,NaN,NaN,0):null}function Kc(e){return new qe(e>>16&255,e>>8&255,e&255,1)}function Hn(e,t,n,r){return r<=0&&(e=t=n=NaN),new qe(e,t,n,r)}function bw(e){return e instanceof Dn||(e=xn(e)),e?(e=e.rgb(),new qe(e.r,e.g,e.b,e.opacity)):new qe}function ws(e,t,n,r){return arguments.length===1?bw(e):new qe(e,t,n,r??1)}function qe(e,t,n,r){this.r=+e,this.g=+t,this.b=+n,this.opacity=+r}Qs(qe,ws,Bh(Dn,{brighter(e){return e=e==null?ar:Math.pow(ar,e),new qe(this.r*e,this.g*e,this.b*e,this.opacity)},darker(e){return e=e==null?bn:Math.pow(bn,e),new qe(this.r*e,this.g*e,this.b*e,this.opacity)},rgb(){return this},clamp(){return new qe(Dt(this.r),Dt(this.g),Dt(this.b),sr(this.opacity))},displayable(){return-.5<=this.r&&this.r<255.5&&-.5<=this.g&&this.g<255.5&&-.5<=this.b&&this.b<255.5&&0<=this.opacity&&this.opacity<=1},hex:Wc,formatHex:Wc,formatHex8:_w,formatRgb:Zc,toString:Zc}));function Wc(){return`#${Rt(this.r)}${Rt(this.g)}${Rt(this.b)}`}function _w(){return`#${Rt(this.r)}${Rt(this.g)}${Rt(this.b)}${Rt((isNaN(this.opacity)?1:this.opacity)*255)}`}function Zc(){const e=sr(this.opacity);return`${e===1?"rgb(":"rgba("}${Dt(this.r)}, ${Dt(this.g)}, ${Dt(this.b)}${e===1?")":`, ${e})`}`}function sr(e){return isNaN(e)?1:Math.max(0,Math.min(1,e))}function Dt(e){return Math.max(0,Math.min(255,Math.round(e)||0))}function Rt(e){return e=Dt(e),(e<16?"0":"")+e.toString(16)}function Xc(e,t,n,r){return r<=0?e=t=n=NaN:n<=0||n>=1?e=t=NaN:t<=0&&(e=NaN),new Ue(e,t,n,r)}function Vh(e){if(e instanceof Ue)return new Ue(e.h,e.s,e.l,e.opacity);if(e instanceof Dn||(e=xn(e)),!e)return new Ue;if(e instanceof Ue)return e;e=e.rgb();var t=e.r/255,n=e.g/255,r=e.b/255,i=Math.min(t,n,r),o=Math.max(t,n,r),a=NaN,s=o-i,c=(o+i)/2;return s?(t===o?a=(n-r)/s+(n0&&c<1?0:a,new Ue(a,s,c,e.opacity)}function xw(e,t,n,r){return arguments.length===1?Vh(e):new Ue(e,t,n,r??1)}function Ue(e,t,n,r){this.h=+e,this.s=+t,this.l=+n,this.opacity=+r}Qs(Ue,xw,Bh(Dn,{brighter(e){return e=e==null?ar:Math.pow(ar,e),new Ue(this.h,this.s,this.l*e,this.opacity)},darker(e){return e=e==null?bn:Math.pow(bn,e),new Ue(this.h,this.s,this.l*e,this.opacity)},rgb(){var e=this.h%360+(this.h<0)*360,t=isNaN(e)||isNaN(this.s)?0:this.s,n=this.l,r=n+(n<.5?n:1-n)*t,i=2*n-r;return new qe(Xr(e>=240?e-240:e+120,i,r),Xr(e,i,r),Xr(e<120?e+240:e-120,i,r),this.opacity)},clamp(){return new Ue(jc(this.h),Bn(this.s),Bn(this.l),sr(this.opacity))},displayable(){return(0<=this.s&&this.s<=1||isNaN(this.s))&&0<=this.l&&this.l<=1&&0<=this.opacity&&this.opacity<=1},formatHsl(){const e=sr(this.opacity);return`${e===1?"hsl(":"hsla("}${jc(this.h)}, ${Bn(this.s)*100}%, ${Bn(this.l)*100}%${e===1?")":`, ${e})`}`}}));function jc(e){return e=(e||0)%360,e<0?e+360:e}function Bn(e){return Math.max(0,Math.min(1,e||0))}function Xr(e,t,n){return(e<60?t+(n-t)*e/60:e<180?n:e<240?t+(n-t)*(240-e)/60:t)*255}const Gh=e=>()=>e;function Ew(e,t){return function(n){return e+n*t}}function Sw(e,t,n){return e=Math.pow(e,n),t=Math.pow(t,n)-e,n=1/n,function(r){return Math.pow(e+r*t,n)}}function Nw(e){return(e=+e)==1?Uh:function(t,n){return n-t?Sw(t,n,e):Gh(isNaN(t)?n:t)}}function Uh(e,t){var n=t-e;return n?Ew(e,n):Gh(isNaN(e)?t:e)}const Qc=function e(t){var n=Nw(t);function r(i,o){var a=n((i=ws(i)).r,(o=ws(o)).r),s=n(i.g,o.g),c=n(i.b,o.b),l=Uh(i.opacity,o.opacity);return function(u){return i.r=a(u),i.g=s(u),i.b=c(u),i.opacity=l(u),i+""}}return r.gamma=e,r}(1);function yt(e,t){return e=+e,t=+t,function(n){return e*(1-n)+t*n}}var bs=/[-+]?(?:\d+\.?\d*|\.?\d+)(?:[eE][-+]?\d+)?/g,jr=new RegExp(bs.source,"g");function Cw(e){return function(){return e}}function Iw(e){return function(t){return e(t)+""}}function Aw(e,t){var n=bs.lastIndex=jr.lastIndex=0,r,i,o,a=-1,s=[],c=[];for(e=e+"",t=t+"";(r=bs.exec(e))&&(i=jr.exec(t));)(o=i.index)>n&&(o=t.slice(n,o),s[a]?s[a]+=o:s[++a]=o),(r=r[0])===(i=i[0])?s[a]?s[a]+=i:s[++a]=i:(s[++a]=null,c.push({i:a,x:yt(r,i)})),n=jr.lastIndex;return n180?u+=360:u-l>180&&(l+=360),f.push({i:d.push(i(d)+"rotate(",null,r)-2,x:yt(l,u)})):u&&d.push(i(d)+"rotate("+u+r)}function s(l,u,d,f){l!==u?f.push({i:d.push(i(d)+"skewX(",null,r)-2,x:yt(l,u)}):u&&d.push(i(d)+"skewX("+u+r)}function c(l,u,d,f,h,p){if(l!==d||u!==f){var g=h.push(i(h)+"scale(",null,",",null,")");p.push({i:g-4,x:yt(l,d)},{i:g-2,x:yt(u,f)})}else(d!==1||f!==1)&&h.push(i(h)+"scale("+d+","+f+")")}return function(l,u){var d=[],f=[];return l=e(l),u=e(u),o(l.translateX,l.translateY,u.translateX,u.translateY,d,f),a(l.rotate,u.rotate,d,f),s(l.skewX,u.skewX,d,f),c(l.scaleX,l.scaleY,u.scaleX,u.scaleY,d,f),l=u=null,function(h){for(var p=-1,g=f.length,m;++p=0&&e._call.call(void 0,t),e=e._next;--en}function tu(){Ot=(ur=En.now())+Tr,en=hn=0;try{Fw()}finally{en=0,zw(),Ot=0}}function Ow(){var e=En.now(),t=e-ur;t>Wh&&(Tr-=t,ur=e)}function zw(){for(var e,t=cr,n,r=1/0;t;)t._call?(r>t._time&&(r=t._time),e=t,t=t._next):(n=t._next,t._next=null,t=e?e._next=n:cr=n);pn=e,xs(r)}function xs(e){if(!en){hn&&(hn=clearTimeout(hn));var t=e-Ot;t>24?(e<1/0&&(hn=setTimeout(tu,e-En.now()-Tr)),cn&&(cn=clearInterval(cn))):(cn||(ur=En.now(),cn=setInterval(Ow,Wh)),en=1,Zh(tu))}}function nu(e,t,n){var r=new lr;return t=t==null?0:+t,r.restart(i=>{r.stop(),e(i+t)},t,n),r}var Hw=Ar("start","end","cancel","interrupt"),Bw=[],jh=0,ru=1,Es=2,Jn=3,iu=4,Ss=5,er=6;function qr(e,t,n,r,i,o){var a=e.__transition;if(!a)e.__transition={};else if(n in a)return;Vw(e,n,{name:t,index:r,group:i,on:Hw,tween:Bw,time:o.time,delay:o.delay,duration:o.duration,ease:o.ease,timer:null,state:jh})}function ec(e,t){var n=Ke(e,t);if(n.state>jh)throw new Error("too late; already scheduled");return n}function et(e,t){var n=Ke(e,t);if(n.state>Jn)throw new Error("too late; already running");return n}function Ke(e,t){var n=e.__transition;if(!n||!(n=n[t]))throw new Error("transition not found");return n}function Vw(e,t,n){var r=e.__transition,i;r[t]=n,n.timer=Xh(o,0,n.time);function o(l){n.state=ru,n.timer.restart(a,n.delay,n.time),n.delay<=l&&a(l-n.delay)}function a(l){var u,d,f,h;if(n.state!==ru)return c();for(u in r)if(h=r[u],h.name===n.name){if(h.state===Jn)return nu(a);h.state===iu?(h.state=er,h.timer.stop(),h.on.call("interrupt",e,e.__data__,h.index,h.group),delete r[u]):+uEs&&r.state=0&&(t=t.slice(0,n)),!t||t==="start"})}function wb(e,t,n){var r,i,o=yb(t)?ec:et;return function(){var a=o(this,e),s=a.on;s!==r&&(i=(r=s).copy()).on(t,n),a.on=i}}function bb(e,t){var n=this._id;return arguments.length<2?Ke(this.node(),n).on.on(e):this.each(wb(n,e,t))}function _b(e){return function(){var t=this.parentNode;for(var n in this.__transition)if(+n!==e)return;t&&t.removeChild(this)}}function xb(){return this.on("end.remove",_b(this._id))}function Eb(e){var t=this._name,n=this._id;typeof e!="function"&&(e=Xs(e));for(var r=this._groups,i=r.length,o=new Array(i),a=0;a()=>e;function Wb(e,{sourceEvent:t,target:n,transform:r,dispatch:i}){Object.defineProperties(this,{type:{value:e,enumerable:!0,configurable:!0},sourceEvent:{value:t,enumerable:!0,configurable:!0},target:{value:n,enumerable:!0,configurable:!0},transform:{value:r,enumerable:!0,configurable:!0},_:{value:i}})}function ot(e,t,n){this.k=e,this.x=t,this.y=n}ot.prototype={constructor:ot,scale:function(e){return e===1?this:new ot(this.k*e,this.x,this.y)},translate:function(e,t){return e===0&t===0?this:new ot(this.k,this.x+this.k*e,this.y+this.k*t)},apply:function(e){return[e[0]*this.k+this.x,e[1]*this.k+this.y]},applyX:function(e){return e*this.k+this.x},applyY:function(e){return e*this.k+this.y},invert:function(e){return[(e[0]-this.x)/this.k,(e[1]-this.y)/this.k]},invertX:function(e){return(e-this.x)/this.k},invertY:function(e){return(e-this.y)/this.k},rescaleX:function(e){return e.copy().domain(e.range().map(this.invertX,this).map(e.invert,e))},rescaleY:function(e){return e.copy().domain(e.range().map(this.invertY,this).map(e.invert,e))},toString:function(){return"translate("+this.x+","+this.y+") scale("+this.k+")"}};var ct=new ot(1,0,0);ot.prototype;function Qr(e){e.stopImmediatePropagation()}function un(e){e.preventDefault(),e.stopImmediatePropagation()}function Zb(e){return(!e.ctrlKey||e.type==="wheel")&&!e.button}function Xb(){var e=this;return e instanceof SVGElement?(e=e.ownerSVGElement||e,e.hasAttribute("viewBox")?(e=e.viewBox.baseVal,[[e.x,e.y],[e.x+e.width,e.y+e.height]]):[[0,0],[e.width.baseVal.value,e.height.baseVal.value]]):[[0,0],[e.clientWidth,e.clientHeight]]}function ou(){return this.__zoom||ct}function jb(e){return-e.deltaY*(e.deltaMode===1?.05:e.deltaMode?1:.002)*(e.ctrlKey?10:1)}function Qb(){return navigator.maxTouchPoints||"ontouchstart"in this}function Jb(e,t,n){var r=e.invertX(t[0][0])-n[0][0],i=e.invertX(t[1][0])-n[1][0],o=e.invertY(t[0][1])-n[0][1],a=e.invertY(t[1][1])-n[1][1];return e.translate(i>r?(r+i)/2:Math.min(0,r)||Math.max(0,i),a>o?(o+a)/2:Math.min(0,o)||Math.max(0,a))}function tp(){var e=Zb,t=Xb,n=Jb,r=jb,i=Qb,o=[0,1/0],a=[[-1/0,-1/0],[1/0,1/0]],s=250,c=$w,l=Ar("start","zoom","end"),u,d,f,h=500,p=150,g=0,m=10;function v(y){y.property("__zoom",ou).on("wheel.zoom",q,{passive:!1}).on("mousedown.zoom",T).on("dblclick.zoom",F).filter(i).on("touchstart.zoom",D).on("touchmove.zoom",O).on("touchend.zoom touchcancel.zoom",L).style("-webkit-tap-highlight-color","rgba(0,0,0,0)")}v.transform=function(y,C,x,k){var $=y.selection?y.selection():y;$.property("__zoom",ou),y!==$?M(y,C,x,k):$.interrupt().each(function(){N(this,arguments).event(k).start().zoom(null,typeof C=="function"?C.apply(this,arguments):C).end()})},v.scaleBy=function(y,C,x,k){v.scaleTo(y,function(){var $=this.__zoom.k,E=typeof C=="function"?C.apply(this,arguments):C;return $*E},x,k)},v.scaleTo=function(y,C,x,k){v.transform(y,function(){var $=t.apply(this,arguments),E=this.__zoom,P=x==null?w($):typeof x=="function"?x.apply(this,arguments):x,R=E.invert(P),H=typeof C=="function"?C.apply(this,arguments):C;return n(_(b(E,H),P,R),$,a)},x,k)},v.translateBy=function(y,C,x,k){v.transform(y,function(){return n(this.__zoom.translate(typeof C=="function"?C.apply(this,arguments):C,typeof x=="function"?x.apply(this,arguments):x),t.apply(this,arguments),a)},null,k)},v.translateTo=function(y,C,x,k,$){v.transform(y,function(){var E=t.apply(this,arguments),P=this.__zoom,R=k==null?w(E):typeof k=="function"?k.apply(this,arguments):k;return n(ct.translate(R[0],R[1]).scale(P.k).translate(typeof C=="function"?-C.apply(this,arguments):-C,typeof x=="function"?-x.apply(this,arguments):-x),E,a)},k,$)};function b(y,C){return C=Math.max(o[0],Math.min(o[1],C)),C===y.k?y:new ot(C,y.x,y.y)}function _(y,C,x){var k=C[0]-x[0]*y.k,$=C[1]-x[1]*y.k;return k===y.x&&$===y.y?y:new ot(y.k,k,$)}function w(y){return[(+y[0][0]+ +y[1][0])/2,(+y[0][1]+ +y[1][1])/2]}function M(y,C,x,k){y.on("start.zoom",function(){N(this,arguments).event(k).start()}).on("interrupt.zoom end.zoom",function(){N(this,arguments).event(k).end()}).tween("zoom",function(){var $=this,E=arguments,P=N($,E).event(k),R=t.apply($,E),H=x==null?w(R):typeof x=="function"?x.apply($,E):x,U=Math.max(R[1][0]-R[0][0],R[1][1]-R[0][1]),B=$.__zoom,X=typeof C=="function"?C.apply($,E):C,J=c(B.invert(H).concat(U/B.k),X.invert(H).concat(U/X.k));return function(z){if(z===1)z=X;else{var V=J(z),W=U/V[2];z=new ot(W,H[0]-V[0]*W,H[1]-V[1]*W)}P.zoom(null,z)}})}function N(y,C,x){return!x&&y.__zooming||new A(y,C)}function A(y,C){this.that=y,this.args=C,this.active=0,this.sourceEvent=null,this.extent=t.apply(y,C),this.taps=0}A.prototype={event:function(y){return y&&(this.sourceEvent=y),this},start:function(){return++this.active===1&&(this.that.__zooming=this,this.emit("start")),this},zoom:function(y,C){return this.mouse&&y!=="mouse"&&(this.mouse[1]=C.invert(this.mouse[0])),this.touch0&&y!=="touch"&&(this.touch0[1]=C.invert(this.touch0[0])),this.touch1&&y!=="touch"&&(this.touch1[1]=C.invert(this.touch1[0])),this.that.__zoom=C,this.emit("zoom"),this},end:function(){return--this.active===0&&(delete this.that.__zooming,this.emit("end")),this},emit:function(y){var C=De(this.that).datum();l.call(y,this.that,new Wb(y,{sourceEvent:this.sourceEvent,target:v,type:y,transform:this.that.__zoom,dispatch:l}),C)}};function q(y,...C){if(!e.apply(this,arguments))return;var x=N(this,C).event(y),k=this.__zoom,$=Math.max(o[0],Math.min(o[1],k.k*Math.pow(2,r.apply(this,arguments)))),E=Ge(y);if(x.wheel)(x.mouse[0][0]!==E[0]||x.mouse[0][1]!==E[1])&&(x.mouse[1]=k.invert(x.mouse[0]=E)),clearTimeout(x.wheel);else{if(k.k===$)return;x.mouse=[E,k.invert(E)],tr(this),x.start()}un(y),x.wheel=setTimeout(P,p),x.zoom("mouse",n(_(b(k,$),x.mouse[0],x.mouse[1]),x.extent,a));function P(){x.wheel=null,x.end()}}function T(y,...C){if(f||!e.apply(this,arguments))return;var x=y.currentTarget,k=N(this,C,!0).event(y),$=De(y.view).on("mousemove.zoom",H,!0).on("mouseup.zoom",U,!0),E=Ge(y,x),P=y.clientX,R=y.clientY;zh(y.view),Qr(y),k.mouse=[E,this.__zoom.invert(E)],tr(this),k.start();function H(B){if(un(B),!k.moved){var X=B.clientX-P,J=B.clientY-R;k.moved=X*X+J*J>g}k.event(B).zoom("mouse",n(_(k.that.__zoom,k.mouse[0]=Ge(B,x),k.mouse[1]),k.extent,a))}function U(B){$.on("mousemove.zoom mouseup.zoom",null),Hh(B.view,k.moved),un(B),k.event(B).end()}}function F(y,...C){if(e.apply(this,arguments)){var x=this.__zoom,k=Ge(y.changedTouches?y.changedTouches[0]:y,this),$=x.invert(k),E=x.k*(y.shiftKey?.5:2),P=n(_(b(x,E),k,$),t.apply(this,C),a);un(y),s>0?De(this).transition().duration(s).call(M,P,k,y):De(this).call(v.transform,P,k,y)}}function D(y,...C){if(e.apply(this,arguments)){var x=y.touches,k=x.length,$=N(this,C,y.changedTouches.length===k).event(y),E,P,R,H;for(Qr(y),P=0;P"[React Flow]: Seems like you have not used zustand provider as an ancestor. Help: https://reactflow.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 React Flow 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,t)=>`Couldn't create edge for ${e?"target":"source"} handle id: "${e?t.targetHandle:t.sourceHandle}", edge id: ${t.id}.`,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.`},np=dt.error001();function le(e,t){const n=wr(Rr);if(n===null)throw new Error(np);return Ih(n,e,t)}const ve=()=>{const e=wr(Rr);if(e===null)throw new Error(np);return Oe(()=>({getState:e.getState,setState:e.setState,subscribe:e.subscribe,destroy:e.destroy}),[e])},t_=e=>e.userSelectionActive?"none":"all";function nc({position:e,children:t,className:n,style:r,...i}){const o=le(t_),a=`${e}`.split("-");return I.createElement("div",{className:Se(["react-flow__panel",n,...a]),style:{...r,pointerEvents:o},...i},t)}function n_({proOptions:e,position:t="bottom-right"}){return e?.hideAttribution?null:I.createElement(nc,{position:t,className:"react-flow__attribution","data-message":"Please only hide this attribution when you are subscribed to React Flow Pro: https://reactflow.dev/pro"},I.createElement("a",{href:"https://reactflow.dev",target:"_blank",rel:"noopener noreferrer","aria-label":"React Flow attribution"},"React Flow"))}const r_=({x:e,y:t,label:n,labelStyle:r={},labelShowBg:i=!0,labelBgStyle:o={},labelBgPadding:a=[2,4],labelBgBorderRadius:s=2,children:c,className:l,...u})=>{const d=ne(null),[f,h]=ae({x:0,y:0,width:0,height:0}),p=Se(["react-flow__edge-textwrapper",l]);return ce(()=>{if(d.current){const g=d.current.getBBox();h({x:g.x,y:g.y,width:g.width,height:g.height})}},[n]),typeof n>"u"||!n?null:I.createElement("g",{transform:`translate(${e-f.width/2} ${t-f.height/2})`,className:p,visibility:f.width?"visible":"hidden",...u},i&&I.createElement("rect",{width:f.width+2*a[0],x:-a[0],y:-a[1],height:f.height+2*a[1],className:"react-flow__edge-textbg",style:o,rx:s,ry:s}),I.createElement("text",{className:"react-flow__edge-text",y:f.height/2,dy:"0.3em",ref:d,style:r},n),c)};var i_=ue(r_);const rc=e=>({width:e.offsetWidth,height:e.offsetHeight}),tn=(e,t=0,n=1)=>Math.min(Math.max(e,t),n),ic=(e={x:0,y:0},t)=>({x:tn(e.x,t[0][0],t[1][0]),y:tn(e.y,t[0][1],t[1][1])}),au=(e,t,n)=>en?-tn(Math.abs(e-n),1,50)/50:0,rp=(e,t)=>{const n=au(e.x,35,t.width-35)*20,r=au(e.y,35,t.height-35)*20;return[n,r]},ip=e=>e.getRootNode?.()||window?.document,op=(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)}),Sn=({x:e,y:t,width:n,height:r})=>({x:e,y:t,x2:e+n,y2:t+r}),ap=({x:e,y:t,x2:n,y2:r})=>({x:e,y:t,width:n-e,height:r-t}),su=e=>({...e.positionAbsolute||{x:0,y:0},width:e.width||0,height:e.height||0}),o_=(e,t)=>ap(op(Sn(e),Sn(t))),Ns=(e,t)=>{const n=Math.max(0,Math.min(e.x+e.width,t.x+t.width)-Math.max(e.x,t.x)),r=Math.max(0,Math.min(e.y+e.height,t.y+t.height)-Math.max(e.y,t.y));return Math.ceil(n*r)},a_=e=>Fe(e.width)&&Fe(e.height)&&Fe(e.x)&&Fe(e.y),Fe=e=>!isNaN(e)&&isFinite(e),pe=Symbol.for("internals"),sp=["Enter"," ","Escape"],s_=(e,t)=>{},c_=e=>"nativeEvent"in e;function Cs(e){const n=(c_(e)?e.nativeEvent:e).composedPath?.()?.[0]||e.target;return["INPUT","SELECT","TEXTAREA"].includes(n?.nodeName)||n?.hasAttribute("contenteditable")||!!n?.closest(".nokey")}const cp=e=>"clientX"in e,Et=(e,t)=>{const n=cp(e),r=n?e.clientX:e.touches?.[0].clientX,i=n?e.clientY:e.touches?.[0].clientY;return{x:r-(t?.left??0),y:i-(t?.top??0)}},dr=()=>typeof navigator<"u"&&navigator?.userAgent?.indexOf("Mac")>=0,Fn=({id:e,path:t,labelX:n,labelY:r,label:i,labelStyle:o,labelShowBg:a,labelBgStyle:s,labelBgPadding:c,labelBgBorderRadius:l,style:u,markerEnd:d,markerStart:f,interactionWidth:h=20})=>I.createElement(I.Fragment,null,I.createElement("path",{id:e,style:u,d:t,fill:"none",className:"react-flow__edge-path",markerEnd:d,markerStart:f}),h&&I.createElement("path",{d:t,fill:"none",strokeOpacity:0,strokeWidth:h,className:"react-flow__edge-interaction"}),i&&Fe(n)&&Fe(r)?I.createElement(i_,{x:n,y:r,label:i,labelStyle:o,labelShowBg:a,labelBgStyle:s,labelBgPadding:c,labelBgBorderRadius:l}):null);Fn.displayName="BaseEdge";const u_=(e,t)=>typeof t<"u"&&t?`url(#${t})`:typeof e<"u"?`url(#react-flow__${e})`:"none";function ln(e,t,n){return n===void 0?n:r=>{const i=t().edges.find(o=>o.id===e);i&&n(r,{...i})}}function up({sourceX:e,sourceY:t,targetX:n,targetY:r}){const i=Math.abs(n-e)/2,o=n{const[m,v,b]=dp({sourceX:e,sourceY:t,sourcePosition:i,targetX:n,targetY:r,targetPosition:o});return I.createElement(Fn,{path:m,labelX:v,labelY:b,label:a,labelStyle:s,labelShowBg:c,labelBgStyle:l,labelBgPadding:u,labelBgBorderRadius:d,style:f,markerEnd:h,markerStart:p,interactionWidth:g})});oc.displayName="SimpleBezierEdge";const uu={[G.Left]:{x:-1,y:0},[G.Right]:{x:1,y:0},[G.Top]:{x:0,y:-1},[G.Bottom]:{x:0,y:1}},l_=({source:e,sourcePosition:t=G.Bottom,target:n})=>t===G.Left||t===G.Right?e.xMath.sqrt(Math.pow(t.x-e.x,2)+Math.pow(t.y-e.y,2));function d_({source:e,sourcePosition:t=G.Bottom,target:n,targetPosition:r=G.Top,center:i,offset:o}){const a=uu[t],s=uu[r],c={x:e.x+a.x*o,y:e.y+a.y*o},l={x:n.x+s.x*o,y:n.y+s.y*o},u=l_({source:c,sourcePosition:t,target:l}),d=u.x!==0?"x":"y",f=u[d];let h=[],p,g;const m={x:0,y:0},v={x:0,y:0},[b,_,w,M]=up({sourceX:e.x,sourceY:e.y,targetX:n.x,targetY:n.y});if(a[d]*s[d]===-1){p=i.x??b,g=i.y??_;const A=[{x:p,y:c.y},{x:p,y:l.y}],q=[{x:c.x,y:g},{x:l.x,y:g}];a[d]===f?h=d==="x"?A:q:h=d==="x"?q:A}else{const A=[{x:c.x,y:l.y}],q=[{x:l.x,y:c.y}];if(d==="x"?h=a.x===f?q:A:h=a.y===f?A:q,t===r){const L=Math.abs(e[d]-n[d]);if(L<=o){const y=Math.min(o-1,o-L);a[d]===f?m[d]=(c[d]>e[d]?-1:1)*y:v[d]=(l[d]>n[d]?-1:1)*y}}if(t!==r){const L=d==="x"?"y":"x",y=a[d]===s[L],C=c[L]>l[L],x=c[L]=O?(p=(T.x+F.x)/2,g=h[0].y):(p=h[0].x,g=(T.y+F.y)/2)}return[[e,{x:c.x+m.x,y:c.y+m.y},...h,{x:l.x+v.x,y:l.y+v.y},n],p,g,w,M]}function f_(e,t,n,r){const i=Math.min(lu(e,t)/2,lu(t,n)/2,r),{x:o,y:a}=t;if(e.x===o&&o===n.x||e.y===a&&a===n.y)return`L${o} ${a}`;if(e.y===a){const l=e.x{let _="";return b>0&&b{const[v,b,_]=Is({sourceX:e,sourceY:t,sourcePosition:d,targetX:n,targetY:r,targetPosition:f,borderRadius:g?.borderRadius,offset:g?.offset});return I.createElement(Fn,{path:v,labelX:b,labelY:_,label:i,labelStyle:o,labelShowBg:a,labelBgStyle:s,labelBgPadding:c,labelBgBorderRadius:l,style:u,markerEnd:h,markerStart:p,interactionWidth:m})});kr.displayName="SmoothStepEdge";const ac=ue(e=>I.createElement(kr,{...e,pathOptions:Oe(()=>({borderRadius:0,offset:e.pathOptions?.offset}),[e.pathOptions?.offset])}));ac.displayName="StepEdge";function h_({sourceX:e,sourceY:t,targetX:n,targetY:r}){const[i,o,a,s]=up({sourceX:e,sourceY:t,targetX:n,targetY:r});return[`M ${e},${t}L ${n},${r}`,i,o,a,s]}const sc=ue(({sourceX:e,sourceY:t,targetX:n,targetY:r,label:i,labelStyle:o,labelShowBg:a,labelBgStyle:s,labelBgPadding:c,labelBgBorderRadius:l,style:u,markerEnd:d,markerStart:f,interactionWidth:h})=>{const[p,g,m]=h_({sourceX:e,sourceY:t,targetX:n,targetY:r});return I.createElement(Fn,{path:p,labelX:g,labelY:m,label:i,labelStyle:o,labelShowBg:a,labelBgStyle:s,labelBgPadding:c,labelBgBorderRadius:l,style:u,markerEnd:d,markerStart:f,interactionWidth:h})});sc.displayName="StraightEdge";function Un(e,t){return e>=0?.5*e:t*25*Math.sqrt(-e)}function du({pos:e,x1:t,y1:n,x2:r,y2:i,c:o}){switch(e){case G.Left:return[t-Un(t-r,o),n];case G.Right:return[t+Un(r-t,o),n];case G.Top:return[t,n-Un(n-i,o)];case G.Bottom:return[t,n+Un(i-n,o)]}}function cc({sourceX:e,sourceY:t,sourcePosition:n=G.Bottom,targetX:r,targetY:i,targetPosition:o=G.Top,curvature:a=.25}){const[s,c]=du({pos:n,x1:e,y1:t,x2:r,y2:i,c:a}),[l,u]=du({pos:o,x1:r,y1:i,x2:e,y2:t,c:a}),[d,f,h,p]=lp({sourceX:e,sourceY:t,targetX:r,targetY:i,sourceControlX:s,sourceControlY:c,targetControlX:l,targetControlY:u});return[`M${e},${t} C${s},${c} ${l},${u} ${r},${i}`,d,f,h,p]}const hr=ue(({sourceX:e,sourceY:t,targetX:n,targetY:r,sourcePosition:i=G.Bottom,targetPosition:o=G.Top,label:a,labelStyle:s,labelShowBg:c,labelBgStyle:l,labelBgPadding:u,labelBgBorderRadius:d,style:f,markerEnd:h,markerStart:p,pathOptions:g,interactionWidth:m})=>{const[v,b,_]=cc({sourceX:e,sourceY:t,sourcePosition:i,targetX:n,targetY:r,targetPosition:o,curvature:g?.curvature});return I.createElement(Fn,{path:v,labelX:b,labelY:_,label:a,labelStyle:s,labelShowBg:c,labelBgStyle:l,labelBgPadding:u,labelBgBorderRadius:d,style:f,markerEnd:h,markerStart:p,interactionWidth:m})});hr.displayName="BezierEdge";const uc=jf(null),p_=uc.Provider;uc.Consumer;const g_=()=>wr(uc),m_=e=>"id"in e&&"source"in e&&"target"in e,v_=({source:e,sourceHandle:t,target:n,targetHandle:r})=>`reactflow__edge-${e}${t||""}-${n}${r||""}`,As=(e,t)=>typeof e>"u"?"":typeof e=="string"?e:`${t?`${t}__`:""}${Object.keys(e).sort().map(r=>`${r}=${e[r]}`).join("&")}`,y_=(e,t)=>t.some(n=>n.source===e.source&&n.target===e.target&&(n.sourceHandle===e.sourceHandle||!n.sourceHandle&&!e.sourceHandle)&&(n.targetHandle===e.targetHandle||!n.targetHandle&&!e.targetHandle)),w_=(e,t)=>{if(!e.source||!e.target)return t;let n;return m_(e)?n={...e}:n={...e,id:v_(e)},y_(n,t)?t:t.concat(n)},Ms=({x:e,y:t},[n,r,i],o,[a,s])=>{const c={x:(e-n)/i,y:(t-r)/i};return o?{x:a*Math.round(c.x/a),y:s*Math.round(c.y/s)}:c},fp=({x:e,y:t},[n,r,i])=>({x:e*i+n,y:t*i+r}),Ft=(e,t=[0,0])=>{if(!e)return{x:0,y:0,positionAbsolute:{x:0,y:0}};const n=(e.width??0)*t[0],r=(e.height??0)*t[1],i={x:e.position.x-n,y:e.position.y-r};return{...i,positionAbsolute:e.positionAbsolute?{x:e.positionAbsolute.x-n,y:e.positionAbsolute.y-r}:i}},Lr=(e,t=[0,0])=>{if(e.length===0)return{x:0,y:0,width:0,height:0};const n=e.reduce((r,i)=>{const{x:o,y:a}=Ft(i,t).positionAbsolute;return op(r,Sn({x:o,y:a,width:i.width||0,height:i.height||0}))},{x:1/0,y:1/0,x2:-1/0,y2:-1/0});return ap(n)},hp=(e,t,[n,r,i]=[0,0,1],o=!1,a=!1,s=[0,0])=>{const c={x:(t.x-n)/i,y:(t.y-r)/i,width:t.width/i,height:t.height/i},l=[];return e.forEach(u=>{const{width:d,height:f,selectable:h=!0,hidden:p=!1}=u;if(a&&!h||p)return!1;const{positionAbsolute:g}=Ft(u,s),m={x:g.x,y:g.y,width:d||0,height:f||0},v=Ns(c,m),b=typeof d>"u"||typeof f>"u"||d===null||f===null,_=o&&v>0,w=(d||0)*(f||0);(b||_||v>=w||u.dragging)&&l.push(u)}),l},pp=(e,t)=>{const n=e.map(r=>r.id);return t.filter(r=>n.includes(r.source)||n.includes(r.target))},gp=(e,t,n,r,i,o=.1)=>{const a=t/(e.width*(1+o)),s=n/(e.height*(1+o)),c=Math.min(a,s),l=tn(c,r,i),u=e.x+e.width/2,d=e.y+e.height/2,f=t/2-u*l,h=n/2-d*l;return{x:f,y:h,zoom:l}},Tt=(e,t=0)=>e.transition().duration(t);function fu(e,t,n,r){return(t[n]||[]).reduce((i,o)=>(`${e.id}-${o.id}-${n}`!==r&&i.push({id:o.id||null,type:n,nodeId:e.id,x:(e.positionAbsolute?.x??0)+o.x+o.width/2,y:(e.positionAbsolute?.y??0)+o.y+o.height/2}),i),[])}function b_(e,t,n,r,i,o){const{x:a,y:s}=Et(e),l=t.elementsFromPoint(a,s).find(p=>p.classList.contains("react-flow__handle"));if(l){const p=l.getAttribute("data-nodeid");if(p){const g=lc(void 0,l),m=l.getAttribute("data-handleid"),v=o({nodeId:p,id:m,type:g});if(v){const b=i.find(_=>_.nodeId===p&&_.type===g&&_.id===m);return{handle:{id:m,type:g,nodeId:p,x:b?.x||n.x,y:b?.y||n.y},validHandleResult:v}}}}let u=[],d=1/0;if(i.forEach(p=>{const g=Math.sqrt((p.x-n.x)**2+(p.y-n.y)**2);if(g<=r){const m=o(p);g<=d&&(gp.isValid),h=u.some(({handle:p})=>p.type==="target");return u.find(({handle:p,validHandleResult:g})=>h?p.type==="target":f?g.isValid:!0)||u[0]}const __={source:null,target:null,sourceHandle:null,targetHandle:null},mp=()=>({handleDomNode:null,isValid:!1,connection:__,endHandle:null});function vp(e,t,n,r,i,o,a){const s=i==="target",c=a.querySelector(`.react-flow__handle[data-id="${e?.nodeId}-${e?.id}-${e?.type}"]`),l={...mp(),handleDomNode:c};if(c){const u=lc(void 0,c),d=c.getAttribute("data-nodeid"),f=c.getAttribute("data-handleid"),h=c.classList.contains("connectable"),p=c.classList.contains("connectableend"),g={source:s?d:n,sourceHandle:s?f:r,target:s?n:d,targetHandle:s?r:f};l.connection=g,h&&p&&(t===zt.Strict?s&&u==="source"||!s&&u==="target":d!==n||f!==r)&&(l.endHandle={nodeId:d,handleId:f,type:u},l.isValid=o(g))}return l}function x_({nodes:e,nodeId:t,handleId:n,handleType:r}){return e.reduce((i,o)=>{if(o[pe]){const{handleBounds:a}=o[pe];let s=[],c=[];a&&(s=fu(o,a,"source",`${t}-${n}-${r}`),c=fu(o,a,"target",`${t}-${n}-${r}`)),i.push(...s,...c)}return i},[])}function lc(e,t){return e||(t?.classList.contains("target")?"target":t?.classList.contains("source")?"source":null)}function Jr(e){e?.classList.remove("valid","connecting","react-flow__handle-valid","react-flow__handle-connecting")}function E_(e,t){let n=null;return t?n="valid":e&&!t&&(n="invalid"),n}function yp({event:e,handleId:t,nodeId:n,onConnect:r,isTarget:i,getState:o,setState:a,isValidConnection:s,edgeUpdaterType:c,onEdgeUpdateEnd:l}){const u=ip(e.target),{connectionMode:d,domNode:f,autoPanOnConnect:h,connectionRadius:p,onConnectStart:g,panBy:m,getNodes:v,cancelConnection:b}=o();let _=0,w;const{x:M,y:N}=Et(e),A=u?.elementFromPoint(M,N),q=lc(c,A),T=f?.getBoundingClientRect();if(!T||!q)return;let F,D=Et(e,T),O=!1,L=null,y=!1,C=null;const x=x_({nodes:v(),nodeId:n,handleId:t,handleType:q}),k=()=>{if(!h)return;const[P,R]=rp(D,T);m({x:P,y:R}),_=requestAnimationFrame(k)};a({connectionPosition:D,connectionStatus:null,connectionNodeId:n,connectionHandleId:t,connectionHandleType:q,connectionStartHandle:{nodeId:n,handleId:t,type:q},connectionEndHandle:null}),g?.(e,{nodeId:n,handleId:t,handleType:q});function $(P){const{transform:R}=o();D=Et(P,T);const{handle:H,validHandleResult:U}=b_(P,u,Ms(D,R,!1,[1,1]),p,x,B=>vp(B,d,n,t,i?"target":"source",s,u));if(w=H,O||(k(),O=!0),C=U.handleDomNode,L=U.connection,y=U.isValid,a({connectionPosition:w&&y?fp({x:w.x,y:w.y},R):D,connectionStatus:E_(!!w,y),connectionEndHandle:U.endHandle}),!w&&!y&&!C)return Jr(F);L.source!==L.target&&C&&(Jr(F),F=C,C.classList.add("connecting","react-flow__handle-connecting"),C.classList.toggle("valid",y),C.classList.toggle("react-flow__handle-valid",y))}function E(P){(w||C)&&L&&y&&r?.(L),o().onConnectEnd?.(P),c&&l?.(P),Jr(F),b(),cancelAnimationFrame(_),O=!1,y=!1,L=null,C=null,u.removeEventListener("mousemove",$),u.removeEventListener("mouseup",E),u.removeEventListener("touchmove",$),u.removeEventListener("touchend",E)}u.addEventListener("mousemove",$),u.addEventListener("mouseup",E),u.addEventListener("touchmove",$),u.addEventListener("touchend",E)}const hu=()=>!0,S_=e=>({connectionStartHandle:e.connectionStartHandle,connectOnClick:e.connectOnClick,noPanClassName:e.noPanClassName}),N_=(e,t,n)=>r=>{const{connectionStartHandle:i,connectionEndHandle:o,connectionClickStartHandle:a}=r;return{connecting:i?.nodeId===e&&i?.handleId===t&&i?.type===n||o?.nodeId===e&&o?.handleId===t&&o?.type===n,clickConnecting:a?.nodeId===e&&a?.handleId===t&&a?.type===n}},wp=Qf(({type:e="source",position:t=G.Top,isValidConnection:n,isConnectable:r=!0,isConnectableStart:i=!0,isConnectableEnd:o=!0,id:a,onConnect:s,children:c,className:l,onMouseDown:u,onTouchStart:d,...f},h)=>{const p=a||null,g=e==="target",m=ve(),v=g_(),{connectOnClick:b,noPanClassName:_}=le(S_,xe),{connecting:w,clickConnecting:M}=le(N_(v,p,e),xe);v||m.getState().onError?.("010",dt.error010());const N=T=>{const{defaultEdgeOptions:F,onConnect:D,hasDefaultEdges:O}=m.getState(),L={...F,...T};if(O){const{edges:y,setEdges:C}=m.getState();C(w_(L,y))}D?.(L),s?.(L)},A=T=>{if(!v)return;const F=cp(T);i&&(F&&T.button===0||!F)&&yp({event:T,handleId:p,nodeId:v,onConnect:N,isTarget:g,getState:m.getState,setState:m.setState,isValidConnection:n||m.getState().isValidConnection||hu}),F?u?.(T):d?.(T)},q=T=>{const{onClickConnectStart:F,onClickConnectEnd:D,connectionClickStartHandle:O,connectionMode:L,isValidConnection:y}=m.getState();if(!v||!O&&!i)return;if(!O){F?.(T,{nodeId:v,handleId:p,handleType:e}),m.setState({connectionClickStartHandle:{nodeId:v,type:e,handleId:p}});return}const C=ip(T.target),x=n||y||hu,{connection:k,isValid:$}=vp({nodeId:v,id:p,type:e},L,O.nodeId,O.handleId||null,O.type,x,C);$&&N(k),D?.(T),m.setState({connectionClickStartHandle:null})};return I.createElement("div",{"data-handleid":p,"data-nodeid":v,"data-handlepos":t,"data-id":`${v}-${p}-${e}`,className:Se(["react-flow__handle",`react-flow__handle-${t}`,"nodrag",_,l,{source:!g,target:g,connectable:r,connectablestart:i,connectableend:o,connecting:M,connectionindicator:r&&(i&&!w||o&&w)}]),onMouseDown:A,onTouchStart:A,onClick:b?q:void 0,ref:h,...f},c)});wp.displayName="Handle";var Nt=ue(wp);const bp=({data:e,isConnectable:t,targetPosition:n=G.Top,sourcePosition:r=G.Bottom})=>I.createElement(I.Fragment,null,I.createElement(Nt,{type:"target",position:n,isConnectable:t}),e?.label,I.createElement(Nt,{type:"source",position:r,isConnectable:t}));bp.displayName="DefaultNode";var Ts=ue(bp);const _p=({data:e,isConnectable:t,sourcePosition:n=G.Bottom})=>I.createElement(I.Fragment,null,e?.label,I.createElement(Nt,{type:"source",position:n,isConnectable:t}));_p.displayName="InputNode";var xp=ue(_p);const Ep=({data:e,isConnectable:t,targetPosition:n=G.Top})=>I.createElement(I.Fragment,null,I.createElement(Nt,{type:"target",position:n,isConnectable:t}),e?.label);Ep.displayName="OutputNode";var Sp=ue(Ep);const dc=()=>null;dc.displayName="GroupNode";const C_=e=>({selectedNodes:e.getNodes().filter(t=>t.selected),selectedEdges:e.edges.filter(t=>t.selected).map(t=>({...t}))}),Yn=e=>e.id;function I_(e,t){return xe(e.selectedNodes.map(Yn),t.selectedNodes.map(Yn))&&xe(e.selectedEdges.map(Yn),t.selectedEdges.map(Yn))}const Np=ue(({onSelectionChange:e})=>{const t=ve(),{selectedNodes:n,selectedEdges:r}=le(C_,I_);return ce(()=>{const i={nodes:n,edges:r};e?.(i),t.getState().onSelectionChange.forEach(o=>o(i))},[n,r,e]),null});Np.displayName="SelectionListener";const A_=e=>!!e.onSelectionChange;function M_({onSelectionChange:e}){const t=le(A_);return e||t?I.createElement(Np,{onSelectionChange:e}):null}const T_=e=>({setNodes:e.setNodes,setEdges:e.setEdges,setDefaultNodesAndEdges:e.setDefaultNodesAndEdges,setMinZoom:e.setMinZoom,setMaxZoom:e.setMaxZoom,setTranslateExtent:e.setTranslateExtent,setNodeExtent:e.setNodeExtent,reset:e.reset});function Vt(e,t){ce(()=>{typeof e<"u"&&t(e)},[e])}function te(e,t,n){ce(()=>{typeof t<"u"&&n({[e]:t})},[t])}const q_=({nodes:e,edges:t,defaultNodes:n,defaultEdges:r,onConnect:i,onConnectStart:o,onConnectEnd:a,onClickConnectStart:s,onClickConnectEnd:c,nodesDraggable:l,nodesConnectable:u,nodesFocusable:d,edgesFocusable:f,edgesUpdatable:h,elevateNodesOnSelect:p,minZoom:g,maxZoom:m,nodeExtent:v,onNodesChange:b,onEdgesChange:_,elementsSelectable:w,connectionMode:M,snapGrid:N,snapToGrid:A,translateExtent:q,connectOnClick:T,defaultEdgeOptions:F,fitView:D,fitViewOptions:O,onNodesDelete:L,onEdgesDelete:y,onNodeDrag:C,onNodeDragStart:x,onNodeDragStop:k,onSelectionDrag:$,onSelectionDragStart:E,onSelectionDragStop:P,noPanClassName:R,nodeOrigin:H,rfId:U,autoPanOnConnect:B,autoPanOnNodeDrag:X,onError:J,connectionRadius:z,isValidConnection:V,nodeDragThreshold:W})=>{const{setNodes:j,setEdges:ie,setDefaultNodesAndEdges:oe,setMinZoom:de,setMaxZoom:ye,setTranslateExtent:Z,setNodeExtent:we,reset:K}=le(T_,xe),Y=ve();return ce(()=>{const he=r?.map(Be=>({...Be,...F}));return oe(n,he),()=>{K()}},[]),te("defaultEdgeOptions",F,Y.setState),te("connectionMode",M,Y.setState),te("onConnect",i,Y.setState),te("onConnectStart",o,Y.setState),te("onConnectEnd",a,Y.setState),te("onClickConnectStart",s,Y.setState),te("onClickConnectEnd",c,Y.setState),te("nodesDraggable",l,Y.setState),te("nodesConnectable",u,Y.setState),te("nodesFocusable",d,Y.setState),te("edgesFocusable",f,Y.setState),te("edgesUpdatable",h,Y.setState),te("elementsSelectable",w,Y.setState),te("elevateNodesOnSelect",p,Y.setState),te("snapToGrid",A,Y.setState),te("snapGrid",N,Y.setState),te("onNodesChange",b,Y.setState),te("onEdgesChange",_,Y.setState),te("connectOnClick",T,Y.setState),te("fitViewOnInit",D,Y.setState),te("fitViewOnInitOptions",O,Y.setState),te("onNodesDelete",L,Y.setState),te("onEdgesDelete",y,Y.setState),te("onNodeDrag",C,Y.setState),te("onNodeDragStart",x,Y.setState),te("onNodeDragStop",k,Y.setState),te("onSelectionDrag",$,Y.setState),te("onSelectionDragStart",E,Y.setState),te("onSelectionDragStop",P,Y.setState),te("noPanClassName",R,Y.setState),te("nodeOrigin",H,Y.setState),te("rfId",U,Y.setState),te("autoPanOnConnect",B,Y.setState),te("autoPanOnNodeDrag",X,Y.setState),te("onError",J,Y.setState),te("connectionRadius",z,Y.setState),te("isValidConnection",V,Y.setState),te("nodeDragThreshold",W,Y.setState),Vt(e,j),Vt(t,ie),Vt(g,de),Vt(m,ye),Vt(q,Z),Vt(v,we),null},pu={display:"none"},R_={position:"absolute",width:1,height:1,margin:-1,border:0,padding:0,overflow:"hidden",clip:"rect(0px, 0px, 0px, 0px)",clipPath:"inset(100%)"},Cp="react-flow__node-desc",Ip="react-flow__edge-desc",k_="react-flow__aria-live",L_=e=>e.ariaLiveMessage;function P_({rfId:e}){const t=le(L_);return I.createElement("div",{id:`${k_}-${e}`,"aria-live":"assertive","aria-atomic":"true",style:R_},t)}function $_({rfId:e,disableKeyboardA11y:t}){return I.createElement(I.Fragment,null,I.createElement("div",{id:`${Cp}-${e}`,style:pu},"Press enter or space to select a node.",!t&&"You can then use the arrow keys to move the node around."," Press delete to remove it and escape to cancel."," "),I.createElement("div",{id:`${Ip}-${e}`,style:pu},"Press enter or space to select an edge. You can then press delete to remove it or escape to cancel."),!t&&I.createElement(P_,{rfId:e}))}var Cn=(e=null,t={actInsideInputWithModifier:!0})=>{const[n,r]=ae(!1),i=ne(!1),o=ne(new Set([])),[a,s]=Oe(()=>{if(e!==null){const l=(Array.isArray(e)?e:[e]).filter(d=>typeof d=="string").map(d=>d.split("+")),u=l.reduce((d,f)=>d.concat(...f),[]);return[l,u]}return[[],[]]},[e]);return ce(()=>{const c=typeof document<"u"?document:null,l=t?.target||c;if(e!==null){const u=h=>{if(i.current=h.ctrlKey||h.metaKey||h.shiftKey,(!i.current||i.current&&!t.actInsideInputWithModifier)&&Cs(h))return!1;const g=mu(h.code,s);o.current.add(h[g]),gu(a,o.current,!1)&&(h.preventDefault(),r(!0))},d=h=>{if((!i.current||i.current&&!t.actInsideInputWithModifier)&&Cs(h))return!1;const g=mu(h.code,s);gu(a,o.current,!0)?(r(!1),o.current.clear()):o.current.delete(h[g]),h.key==="Meta"&&o.current.clear(),i.current=!1},f=()=>{o.current.clear(),r(!1)};return l?.addEventListener("keydown",u),l?.addEventListener("keyup",d),window.addEventListener("blur",f),()=>{l?.removeEventListener("keydown",u),l?.removeEventListener("keyup",d),window.removeEventListener("blur",f)}}},[e,r]),n};function gu(e,t,n){return e.filter(r=>n||r.length===t.size).some(r=>r.every(i=>t.has(i)))}function mu(e,t){return t.includes(e)?"code":"key"}function Ap(e,t,n,r){const i=e.parentNode||e.parentId;if(!i)return n;const o=t.get(i),a=Ft(o,r);return Ap(o,t,{x:(n.x??0)+a.x,y:(n.y??0)+a.y,z:(o[pe]?.z??0)>(n.z??0)?o[pe]?.z??0:n.z??0},r)}function Mp(e,t,n){e.forEach(r=>{const i=r.parentNode||r.parentId;if(i&&!e.has(i))throw new Error(`Parent node ${i} not found`);if(i||n?.[r.id]){const{x:o,y:a,z:s}=Ap(r,e,{...r.position,z:r[pe]?.z??0},t);r.positionAbsolute={x:o,y:a},r[pe].z=s,n?.[r.id]&&(r[pe].isParent=!0)}})}function ei(e,t,n,r){const i=new Map,o={},a=r?1e3:0;return e.forEach(s=>{const c=(Fe(s.zIndex)?s.zIndex:0)+(s.selected?a:0),l=t.get(s.id),u={...s,positionAbsolute:{x:s.position.x,y:s.position.y}},d=s.parentNode||s.parentId;d&&(o[d]=!0);const f=l?.type&&l?.type!==s.type;Object.defineProperty(u,pe,{enumerable:!1,value:{handleBounds:f?void 0:l?.[pe]?.handleBounds,z:c}}),i.set(s.id,u)}),Mp(i,n,o),i}function Tp(e,t={}){const{getNodes:n,width:r,height:i,minZoom:o,maxZoom:a,d3Zoom:s,d3Selection:c,fitViewOnInitDone:l,fitViewOnInit:u,nodeOrigin:d}=e(),f=t.initial&&!l&&u;if(s&&c&&(f||!t.initial)){const p=n().filter(m=>{const v=t.includeHiddenNodes?m.width&&m.height:!m.hidden;return t.nodes?.length?v&&t.nodes.some(b=>b.id===m.id):v}),g=p.every(m=>m.width&&m.height);if(p.length>0&&g){const m=Lr(p,d),{x:v,y:b,zoom:_}=gp(m,r,i,t.minZoom??o,t.maxZoom??a,t.padding??.1),w=ct.translate(v,b).scale(_);return typeof t.duration=="number"&&t.duration>0?s.transform(Tt(c,t.duration),w):s.transform(c,w),!0}}return!1}function D_(e,t){return e.forEach(n=>{const r=t.get(n.id);r&&t.set(r.id,{...r,[pe]:r[pe],selected:n.selected})}),new Map(t)}function F_(e,t){return t.map(n=>{const r=e.find(i=>i.id===n.id);return r&&(n.selected=r.selected),n})}function Kn({changedNodes:e,changedEdges:t,get:n,set:r}){const{nodeInternals:i,edges:o,onNodesChange:a,onEdgesChange:s,hasDefaultNodes:c,hasDefaultEdges:l}=n();e?.length&&(c&&r({nodeInternals:D_(e,i)}),a?.(e)),t?.length&&(l&&r({edges:F_(t,o)}),s?.(t))}const Gt=()=>{},O_={zoomIn:Gt,zoomOut:Gt,zoomTo:Gt,getZoom:()=>1,setViewport:Gt,getViewport:()=>({x:0,y:0,zoom:1}),fitView:()=>!1,setCenter:Gt,fitBounds:Gt,project:e=>e,screenToFlowPosition:e=>e,flowToScreenPosition:e=>e,viewportInitialized:!1},z_=e=>({d3Zoom:e.d3Zoom,d3Selection:e.d3Selection}),H_=()=>{const e=ve(),{d3Zoom:t,d3Selection:n}=le(z_,xe);return Oe(()=>n&&t?{zoomIn:i=>t.scaleBy(Tt(n,i?.duration),1.2),zoomOut:i=>t.scaleBy(Tt(n,i?.duration),1/1.2),zoomTo:(i,o)=>t.scaleTo(Tt(n,o?.duration),i),getZoom:()=>e.getState().transform[2],setViewport:(i,o)=>{const[a,s,c]=e.getState().transform,l=ct.translate(i.x??a,i.y??s).scale(i.zoom??c);t.transform(Tt(n,o?.duration),l)},getViewport:()=>{const[i,o,a]=e.getState().transform;return{x:i,y:o,zoom:a}},fitView:i=>Tp(e.getState,i),setCenter:(i,o,a)=>{const{width:s,height:c,maxZoom:l}=e.getState(),u=typeof a?.zoom<"u"?a.zoom:l,d=s/2-i*u,f=c/2-o*u,h=ct.translate(d,f).scale(u);t.transform(Tt(n,a?.duration),h)},fitBounds:(i,o)=>{const{width:a,height:s,minZoom:c,maxZoom:l}=e.getState(),{x:u,y:d,zoom:f}=gp(i,a,s,c,l,o?.padding??.1),h=ct.translate(u,d).scale(f);t.transform(Tt(n,o?.duration),h)},project:i=>{const{transform:o,snapToGrid:a,snapGrid:s}=e.getState();return console.warn("[DEPRECATED] `project` is deprecated. Instead use `screenToFlowPosition`. There is no need to subtract the react flow bounds anymore! https://reactflow.dev/api-reference/types/react-flow-instance#screen-to-flow-position"),Ms(i,o,a,s)},screenToFlowPosition:i=>{const{transform:o,snapToGrid:a,snapGrid:s,domNode:c}=e.getState();if(!c)return i;const{x:l,y:u}=c.getBoundingClientRect(),d={x:i.x-l,y:i.y-u};return Ms(d,o,a,s)},flowToScreenPosition:i=>{const{transform:o,domNode:a}=e.getState();if(!a)return i;const{x:s,y:c}=a.getBoundingClientRect(),l=fp(i,o);return{x:l.x+s,y:l.y+c}},viewportInitialized:!0}:O_,[t,n])};function fc(){const e=H_(),t=ve(),n=me(()=>t.getState().getNodes().map(g=>({...g})),[]),r=me(g=>t.getState().nodeInternals.get(g),[]),i=me(()=>{const{edges:g=[]}=t.getState();return g.map(m=>({...m}))},[]),o=me(g=>{const{edges:m=[]}=t.getState();return m.find(v=>v.id===g)},[]),a=me(g=>{const{getNodes:m,setNodes:v,hasDefaultNodes:b,onNodesChange:_}=t.getState(),w=m(),M=typeof g=="function"?g(w):g;if(b)v(M);else if(_){const N=M.length===0?w.map(A=>({type:"remove",id:A.id})):M.map(A=>({item:A,type:"reset"}));_(N)}},[]),s=me(g=>{const{edges:m=[],setEdges:v,hasDefaultEdges:b,onEdgesChange:_}=t.getState(),w=typeof g=="function"?g(m):g;if(b)v(w);else if(_){const M=w.length===0?m.map(N=>({type:"remove",id:N.id})):w.map(N=>({item:N,type:"reset"}));_(M)}},[]),c=me(g=>{const m=Array.isArray(g)?g:[g],{getNodes:v,setNodes:b,hasDefaultNodes:_,onNodesChange:w}=t.getState();if(_){const N=[...v(),...m];b(N)}else if(w){const M=m.map(N=>({item:N,type:"add"}));w(M)}},[]),l=me(g=>{const m=Array.isArray(g)?g:[g],{edges:v=[],setEdges:b,hasDefaultEdges:_,onEdgesChange:w}=t.getState();if(_)b([...v,...m]);else if(w){const M=m.map(N=>({item:N,type:"add"}));w(M)}},[]),u=me(()=>{const{getNodes:g,edges:m=[],transform:v}=t.getState(),[b,_,w]=v;return{nodes:g().map(M=>({...M})),edges:m.map(M=>({...M})),viewport:{x:b,y:_,zoom:w}}},[]),d=me(({nodes:g,edges:m})=>{const{nodeInternals:v,getNodes:b,edges:_,hasDefaultNodes:w,hasDefaultEdges:M,onNodesDelete:N,onEdgesDelete:A,onNodesChange:q,onEdgesChange:T}=t.getState(),F=(g||[]).map(C=>C.id),D=(m||[]).map(C=>C.id),O=b().reduce((C,x)=>{const k=x.parentNode||x.parentId,$=!F.includes(x.id)&&k&&C.find(P=>P.id===k);return(typeof x.deletable=="boolean"?x.deletable:!0)&&(F.includes(x.id)||$)&&C.push(x),C},[]),L=_.filter(C=>typeof C.deletable=="boolean"?C.deletable:!0),y=L.filter(C=>D.includes(C.id));if(O||y){const C=pp(O,L),x=[...y,...C],k=x.reduce(($,E)=>($.includes(E.id)||$.push(E.id),$),[]);if((M||w)&&(M&&t.setState({edges:_.filter($=>!k.includes($.id))}),w&&(O.forEach($=>{v.delete($.id)}),t.setState({nodeInternals:new Map(v)}))),k.length>0&&(A?.(x),T&&T(k.map($=>({id:$,type:"remove"})))),O.length>0&&(N?.(O),q)){const $=O.map(E=>({id:E.id,type:"remove"}));q($)}}},[]),f=me(g=>{const m=a_(g),v=m?null:t.getState().nodeInternals.get(g.id);return!m&&!v?[null,null,m]:[m?g:su(v),v,m]},[]),h=me((g,m=!0,v)=>{const[b,_,w]=f(g);return b?(v||t.getState().getNodes()).filter(M=>{if(!w&&(M.id===_.id||!M.positionAbsolute))return!1;const N=su(M),A=Ns(N,b);return m&&A>0||A>=b.width*b.height}):[]},[]),p=me((g,m,v=!0)=>{const[b]=f(g);if(!b)return!1;const _=Ns(b,m);return v&&_>0||_>=b.width*b.height},[]);return Oe(()=>({...e,getNodes:n,getNode:r,getEdges:i,getEdge:o,setNodes:a,setEdges:s,addNodes:c,addEdges:l,toObject:u,deleteElements:d,getIntersectingNodes:h,isNodeIntersecting:p}),[e,n,r,i,o,a,s,c,l,u,d,h,p])}const B_={actInsideInputWithModifier:!1};var V_=({deleteKeyCode:e,multiSelectionKeyCode:t})=>{const n=ve(),{deleteElements:r}=fc(),i=Cn(e,B_),o=Cn(t);ce(()=>{if(i){const{edges:a,getNodes:s}=n.getState(),c=s().filter(u=>u.selected),l=a.filter(u=>u.selected);r({nodes:c,edges:l}),n.setState({nodesSelectionActive:!1})}},[i]),ce(()=>{n.setState({multiSelectionActive:o})},[o])};function G_(e){const t=ve();ce(()=>{let n;const r=()=>{if(!e.current)return;const i=rc(e.current);(i.height===0||i.width===0)&&t.getState().onError?.("004",dt.error004()),t.setState({width:i.width||500,height:i.height||500})};return r(),window.addEventListener("resize",r),e.current&&(n=new ResizeObserver(()=>r()),n.observe(e.current)),()=>{window.removeEventListener("resize",r),n&&e.current&&n.unobserve(e.current)}},[])}const hc={position:"absolute",width:"100%",height:"100%",top:0,left:0},U_=(e,t)=>e.x!==t.x||e.y!==t.y||e.zoom!==t.k,Wn=e=>({x:e.x,y:e.y,zoom:e.k}),Ut=(e,t)=>e.target.closest(`.${t}`),vu=(e,t)=>t===2&&Array.isArray(e)&&e.includes(2),yu=e=>{const t=e.ctrlKey&&dr()?10:1;return-e.deltaY*(e.deltaMode===1?.05:e.deltaMode?1:.002)*t},Y_=e=>({d3Zoom:e.d3Zoom,d3Selection:e.d3Selection,d3ZoomHandler:e.d3ZoomHandler,userSelectionActive:e.userSelectionActive}),K_=({onMove:e,onMoveStart:t,onMoveEnd:n,onPaneContextMenu:r,zoomOnScroll:i=!0,zoomOnPinch:o=!0,panOnScroll:a=!1,panOnScrollSpeed:s=.5,panOnScrollMode:c=kt.Free,zoomOnDoubleClick:l=!0,elementsSelectable:u,panOnDrag:d=!0,defaultViewport:f,translateExtent:h,minZoom:p,maxZoom:g,zoomActivationKeyCode:m,preventScrolling:v=!0,children:b,noWheelClassName:_,noPanClassName:w})=>{const M=ne(),N=ve(),A=ne(!1),q=ne(!1),T=ne(null),F=ne({x:0,y:0,zoom:0}),{d3Zoom:D,d3Selection:O,d3ZoomHandler:L,userSelectionActive:y}=le(Y_,xe),C=Cn(m),x=ne(0),k=ne(!1),$=ne();return G_(T),ce(()=>{if(T.current){const E=T.current.getBoundingClientRect(),P=tp().scaleExtent([p,g]).translateExtent(h),R=De(T.current).call(P),H=ct.translate(f.x,f.y).scale(tn(f.zoom,p,g)),U=[[0,0],[E.width,E.height]],B=P.constrain()(H,U,h);P.transform(R,B),P.wheelDelta(yu),N.setState({d3Zoom:P,d3Selection:R,d3ZoomHandler:R.on("wheel.zoom"),transform:[B.x,B.y,B.k],domNode:T.current.closest(".react-flow")})}},[]),ce(()=>{O&&D&&(a&&!C&&!y?O.on("wheel.zoom",E=>{if(Ut(E,_))return!1;E.preventDefault(),E.stopImmediatePropagation();const P=O.property("__zoom").k||1;if(E.ctrlKey&&o){const V=Ge(E),W=yu(E),j=P*Math.pow(2,W);D.scaleTo(O,j,V,E);return}const R=E.deltaMode===1?20:1;let H=c===kt.Vertical?0:E.deltaX*R,U=c===kt.Horizontal?0:E.deltaY*R;!dr()&&E.shiftKey&&c!==kt.Vertical&&(H=E.deltaY*R,U=0),D.translateBy(O,-(H/P)*s,-(U/P)*s,{internal:!0});const B=Wn(O.property("__zoom")),{onViewportChangeStart:X,onViewportChange:J,onViewportChangeEnd:z}=N.getState();clearTimeout($.current),k.current||(k.current=!0,t?.(E,B),X?.(B)),k.current&&(e?.(E,B),J?.(B),$.current=setTimeout(()=>{n?.(E,B),z?.(B),k.current=!1},150))},{passive:!1}):typeof L<"u"&&O.on("wheel.zoom",function(E,P){if(!v&&E.type==="wheel"&&!E.ctrlKey||Ut(E,_))return null;E.preventDefault(),L.call(this,E,P)},{passive:!1}))},[y,a,c,O,D,L,C,o,v,_,t,e,n]),ce(()=>{D&&D.on("start",E=>{if(!E.sourceEvent||E.sourceEvent.internal)return null;x.current=E.sourceEvent?.button;const{onViewportChangeStart:P}=N.getState(),R=Wn(E.transform);A.current=!0,F.current=R,E.sourceEvent?.type==="mousedown"&&N.setState({paneDragging:!0}),P?.(R),t?.(E.sourceEvent,R)})},[D,t]),ce(()=>{D&&(y&&!A.current?D.on("zoom",null):y||D.on("zoom",E=>{const{onViewportChange:P}=N.getState();if(N.setState({transform:[E.transform.x,E.transform.y,E.transform.k]}),q.current=!!(r&&vu(d,x.current??0)),(e||P)&&!E.sourceEvent?.internal){const R=Wn(E.transform);P?.(R),e?.(E.sourceEvent,R)}}))},[y,D,e,d,r]),ce(()=>{D&&D.on("end",E=>{if(!E.sourceEvent||E.sourceEvent.internal)return null;const{onViewportChangeEnd:P}=N.getState();if(A.current=!1,N.setState({paneDragging:!1}),r&&vu(d,x.current??0)&&!q.current&&r(E.sourceEvent),q.current=!1,(n||P)&&U_(F.current,E.transform)){const R=Wn(E.transform);F.current=R,clearTimeout(M.current),M.current=setTimeout(()=>{P?.(R),n?.(E.sourceEvent,R)},a?150:0)}})},[D,a,d,n,r]),ce(()=>{D&&D.filter(E=>{const P=C||i,R=o&&E.ctrlKey;if((d===!0||Array.isArray(d)&&d.includes(1))&&E.button===1&&E.type==="mousedown"&&(Ut(E,"react-flow__node")||Ut(E,"react-flow__edge")))return!0;if(!d&&!P&&!a&&!l&&!o||y||!l&&E.type==="dblclick"||Ut(E,_)&&E.type==="wheel"||Ut(E,w)&&(E.type!=="wheel"||a&&E.type==="wheel"&&!C)||!o&&E.ctrlKey&&E.type==="wheel"||!P&&!a&&!R&&E.type==="wheel"||!d&&(E.type==="mousedown"||E.type==="touchstart")||Array.isArray(d)&&!d.includes(E.button)&&E.type==="mousedown")return!1;const H=Array.isArray(d)&&d.includes(E.button)||!E.button||E.button<=1;return(!E.ctrlKey||E.type==="wheel")&&H})},[y,D,i,o,a,l,d,u,C]),I.createElement("div",{className:"react-flow__renderer",ref:T,style:hc},b)},W_=e=>({userSelectionActive:e.userSelectionActive,userSelectionRect:e.userSelectionRect});function Z_(){const{userSelectionActive:e,userSelectionRect:t}=le(W_,xe);return e&&t?I.createElement("div",{className:"react-flow__selection react-flow__container",style:{width:t.width,height:t.height,transform:`translate(${t.x}px, ${t.y}px)`}}):null}function wu(e,t){const n=t.parentNode||t.parentId,r=e.find(i=>i.id===n);if(r){const i=t.position.x+t.width-r.width,o=t.position.y+t.height-r.height;if(i>0||o>0||t.position.x<0||t.position.y<0){if(r.style={...r.style},r.style.width=r.style.width??r.width,r.style.height=r.style.height??r.height,i>0&&(r.style.width+=i),o>0&&(r.style.height+=o),t.position.x<0){const a=Math.abs(t.position.x);r.position.x=r.position.x-a,r.style.width+=a,t.position.x=0}if(t.position.y<0){const a=Math.abs(t.position.y);r.position.y=r.position.y-a,r.style.height+=a,t.position.y=0}r.width=r.style.width,r.height=r.style.height}}}function qp(e,t){if(e.some(r=>r.type==="reset"))return e.filter(r=>r.type==="reset").map(r=>r.item);const n=e.filter(r=>r.type==="add").map(r=>r.item);return t.reduce((r,i)=>{const o=e.filter(s=>s.id===i.id);if(o.length===0)return r.push(i),r;const a={...i};for(const s of o)if(s)switch(s.type){case"select":{a.selected=s.selected;break}case"position":{typeof s.position<"u"&&(a.position=s.position),typeof s.positionAbsolute<"u"&&(a.positionAbsolute=s.positionAbsolute),typeof s.dragging<"u"&&(a.dragging=s.dragging),a.expandParent&&wu(r,a);break}case"dimensions":{typeof s.dimensions<"u"&&(a.width=s.dimensions.width,a.height=s.dimensions.height),typeof s.updateStyle<"u"&&(a.style={...a.style||{},...s.dimensions}),typeof s.resizing=="boolean"&&(a.resizing=s.resizing),a.expandParent&&wu(r,a);break}case"remove":return r}return r.push(a),r},n)}function Rp(e,t){return qp(e,t)}function X_(e,t){return qp(e,t)}const wt=(e,t)=>({id:e,type:"select",selected:t});function Kt(e,t){return e.reduce((n,r)=>{const i=t.includes(r.id);return!r.selected&&i?(r.selected=!0,n.push(wt(r.id,!0))):r.selected&&!i&&(r.selected=!1,n.push(wt(r.id,!1))),n},[])}const ti=(e,t)=>n=>{n.target===t.current&&e?.(n)},j_=e=>({userSelectionActive:e.userSelectionActive,elementsSelectable:e.elementsSelectable,dragging:e.paneDragging}),kp=ue(({isSelecting:e,selectionMode:t=Nn.Full,panOnDrag:n,onSelectionStart:r,onSelectionEnd:i,onPaneClick:o,onPaneContextMenu:a,onPaneScroll:s,onPaneMouseEnter:c,onPaneMouseMove:l,onPaneMouseLeave:u,children:d})=>{const f=ne(null),h=ve(),p=ne(0),g=ne(0),m=ne(),{userSelectionActive:v,elementsSelectable:b,dragging:_}=le(j_,xe),w=()=>{h.setState({userSelectionActive:!1,userSelectionRect:null}),p.current=0,g.current=0},M=L=>{o?.(L),h.getState().resetSelectedElements(),h.setState({nodesSelectionActive:!1})},N=L=>{if(Array.isArray(n)&&n?.includes(2)){L.preventDefault();return}a?.(L)},A=s?L=>s(L):void 0,q=L=>{const{resetSelectedElements:y,domNode:C}=h.getState();if(m.current=C?.getBoundingClientRect(),!b||!e||L.button!==0||L.target!==f.current||!m.current)return;const{x,y:k}=Et(L,m.current);y(),h.setState({userSelectionRect:{width:0,height:0,startX:x,startY:k,x,y:k}}),r?.(L)},T=L=>{const{userSelectionRect:y,nodeInternals:C,edges:x,transform:k,onNodesChange:$,onEdgesChange:E,nodeOrigin:P,getNodes:R}=h.getState();if(!e||!m.current||!y)return;h.setState({userSelectionActive:!0,nodesSelectionActive:!1});const H=Et(L,m.current),U=y.startX??0,B=y.startY??0,X={...y,x:H.xj.id),W=z.map(j=>j.id);if(p.current!==W.length){p.current=W.length;const j=Kt(J,W);j.length&&$?.(j)}if(g.current!==V.length){g.current=V.length;const j=Kt(x,V);j.length&&E?.(j)}h.setState({userSelectionRect:X})},F=L=>{if(L.button!==0)return;const{userSelectionRect:y}=h.getState();!v&&y&&L.target===f.current&&M?.(L),h.setState({nodesSelectionActive:p.current>0}),w(),i?.(L)},D=L=>{v&&(h.setState({nodesSelectionActive:p.current>0}),i?.(L)),w()},O=b&&(e||v);return I.createElement("div",{className:Se(["react-flow__pane",{dragging:_,selection:e}]),onClick:O?void 0:ti(M,f),onContextMenu:ti(N,f),onWheel:ti(A,f),onMouseEnter:O?void 0:c,onMouseDown:O?q:void 0,onMouseMove:O?T:l,onMouseUp:O?F:void 0,onMouseLeave:O?D:u,ref:f,style:hc},d,I.createElement(Z_,null))});kp.displayName="Pane";function Lp(e,t){const n=e.parentNode||e.parentId;if(!n)return!1;const r=t.get(n);return r?r.selected?!0:Lp(r,t):!1}function bu(e,t,n){let r=e;do{if(r?.matches(t))return!0;if(r===n.current)return!1;r=r.parentElement}while(r);return!1}function Q_(e,t,n,r){return Array.from(e.values()).filter(i=>(i.selected||i.id===r)&&(!i.parentNode||i.parentId||!Lp(i,e))&&(i.draggable||t&&typeof i.draggable>"u")).map(i=>({id:i.id,position:i.position||{x:0,y:0},positionAbsolute:i.positionAbsolute||{x:0,y:0},distance:{x:n.x-(i.positionAbsolute?.x??0),y:n.y-(i.positionAbsolute?.y??0)},delta:{x:0,y:0},extent:i.extent,parentNode:i.parentNode||i.parentId,parentId:i.parentNode||i.parentId,width:i.width,height:i.height,expandParent:i.expandParent}))}function J_(e,t){return!t||t==="parent"?t:[t[0],[t[1][0]-(e.width||0),t[1][1]-(e.height||0)]]}function Pp(e,t,n,r,i=[0,0],o){const a=J_(e,e.extent||r);let s=a;const c=e.parentNode||e.parentId;if(e.extent==="parent"&&!e.expandParent)if(c&&e.width&&e.height){const d=n.get(c),{x:f,y:h}=Ft(d,i).positionAbsolute;s=d&&Fe(f)&&Fe(h)&&Fe(d.width)&&Fe(d.height)?[[f+e.width*i[0],h+e.height*i[1]],[f+d.width-e.width+e.width*i[0],h+d.height-e.height+e.height*i[1]]]:s}else o?.("005",dt.error005()),s=a;else if(e.extent&&c&&e.extent!=="parent"){const d=n.get(c),{x:f,y:h}=Ft(d,i).positionAbsolute;s=[[e.extent[0][0]+f,e.extent[0][1]+h],[e.extent[1][0]+f,e.extent[1][1]+h]]}let l={x:0,y:0};if(c){const d=n.get(c);l=Ft(d,i).positionAbsolute}const u=s&&s!=="parent"?ic(t,s):t;return{position:{x:u.x-l.x,y:u.y-l.y},positionAbsolute:u}}function ni({nodeId:e,dragItems:t,nodeInternals:n}){const r=t.map(i=>({...n.get(i.id),position:i.position,positionAbsolute:i.positionAbsolute}));return[e?r.find(i=>i.id===e):r[0],r]}const _u=(e,t,n,r)=>{const i=t.querySelectorAll(e);if(!i||!i.length)return null;const o=Array.from(i),a=t.getBoundingClientRect(),s={x:a.width*r[0],y:a.height*r[1]};return o.map(c=>{const l=c.getBoundingClientRect();return{id:c.getAttribute("data-handleid"),position:c.getAttribute("data-handlepos"),x:(l.left-a.left-s.x)/n,y:(l.top-a.top-s.y)/n,...rc(c)}})};function dn(e,t,n){return n===void 0?n:r=>{const i=t().nodeInternals.get(e);i&&n(r,{...i})}}function qs({id:e,store:t,unselect:n=!1,nodeRef:r}){const{addSelectedNodes:i,unselectNodesAndEdges:o,multiSelectionActive:a,nodeInternals:s,onError:c}=t.getState(),l=s.get(e);if(!l){c?.("012",dt.error012(e));return}t.setState({nodesSelectionActive:!1}),l.selected?(n||l.selected&&a)&&(o({nodes:[l],edges:[]}),requestAnimationFrame(()=>r?.current?.blur())):i([e])}function e1(){const e=ve();return me(({sourceEvent:n})=>{const{transform:r,snapGrid:i,snapToGrid:o}=e.getState(),a=n.touches?n.touches[0].clientX:n.clientX,s=n.touches?n.touches[0].clientY:n.clientY,c={x:(a-r[0])/r[2],y:(s-r[1])/r[2]};return{xSnapped:o?i[0]*Math.round(c.x/i[0]):c.x,ySnapped:o?i[1]*Math.round(c.y/i[1]):c.y,...c}},[])}function ri(e){return(t,n,r)=>e?.(t,r)}function $p({nodeRef:e,disabled:t=!1,noDragClassName:n,handleSelector:r,nodeId:i,isSelectable:o,selectNodesOnDrag:a}){const s=ve(),[c,l]=ae(!1),u=ne([]),d=ne({x:null,y:null}),f=ne(0),h=ne(null),p=ne({x:0,y:0}),g=ne(null),m=ne(!1),v=ne(!1),b=e1();return ce(()=>{if(e?.current){const _=De(e.current),w=({x:A,y:q})=>{const{nodeInternals:T,onNodeDrag:F,onSelectionDrag:D,updateNodePositions:O,nodeExtent:L,snapGrid:y,snapToGrid:C,nodeOrigin:x,onError:k}=s.getState();d.current={x:A,y:q};let $=!1,E={x:0,y:0,x2:0,y2:0};if(u.current.length>1&&L){const R=Lr(u.current,x);E=Sn(R)}if(u.current=u.current.map(R=>{const H={x:A-R.distance.x,y:q-R.distance.y};C&&(H.x=y[0]*Math.round(H.x/y[0]),H.y=y[1]*Math.round(H.y/y[1]));const U=[[L[0][0],L[0][1]],[L[1][0],L[1][1]]];u.current.length>1&&L&&!R.extent&&(U[0][0]=R.positionAbsolute.x-E.x+L[0][0],U[1][0]=R.positionAbsolute.x+(R.width??0)-E.x2+L[1][0],U[0][1]=R.positionAbsolute.y-E.y+L[0][1],U[1][1]=R.positionAbsolute.y+(R.height??0)-E.y2+L[1][1]);const B=Pp(R,H,T,U,x,k);return $=$||R.position.x!==B.position.x||R.position.y!==B.position.y,R.position=B.position,R.positionAbsolute=B.positionAbsolute,R}),!$)return;O(u.current,!0,!0),l(!0);const P=i?F:ri(D);if(P&&g.current){const[R,H]=ni({nodeId:i,dragItems:u.current,nodeInternals:T});P(g.current,R,H)}},M=()=>{if(!h.current)return;const[A,q]=rp(p.current,h.current);if(A!==0||q!==0){const{transform:T,panBy:F}=s.getState();d.current.x=(d.current.x??0)-A/T[2],d.current.y=(d.current.y??0)-q/T[2],F({x:A,y:q})&&w(d.current)}f.current=requestAnimationFrame(M)},N=A=>{const{nodeInternals:q,multiSelectionActive:T,nodesDraggable:F,unselectNodesAndEdges:D,onNodeDragStart:O,onSelectionDragStart:L}=s.getState();v.current=!0;const y=i?O:ri(L);(!a||!o)&&!T&&i&&(q.get(i)?.selected||D()),i&&o&&a&&qs({id:i,store:s,nodeRef:e});const C=b(A);if(d.current=C,u.current=Q_(q,F,C,i),y&&u.current){const[x,k]=ni({nodeId:i,dragItems:u.current,nodeInternals:q});y(A.sourceEvent,x,k)}};if(t)_.on(".drag",null);else{const A=lw().on("start",q=>{const{domNode:T,nodeDragThreshold:F}=s.getState();F===0&&N(q);const D=b(q);d.current=D,h.current=T?.getBoundingClientRect()||null,p.current=Et(q.sourceEvent,h.current)}).on("drag",q=>{const T=b(q),{autoPanOnNodeDrag:F,nodeDragThreshold:D}=s.getState();if(!m.current&&v.current&&F&&(m.current=!0,M()),!v.current){const O=T.xSnapped-(d?.current?.x??0),L=T.ySnapped-(d?.current?.y??0);Math.sqrt(O*O+L*L)>D&&N(q)}(d.current.x!==T.xSnapped||d.current.y!==T.ySnapped)&&u.current&&v.current&&(g.current=q.sourceEvent,p.current=Et(q.sourceEvent,h.current),w(T))}).on("end",q=>{if(v.current&&(l(!1),m.current=!1,v.current=!1,cancelAnimationFrame(f.current),u.current)){const{updateNodePositions:T,nodeInternals:F,onNodeDragStop:D,onSelectionDragStop:O}=s.getState(),L=i?D:ri(O);if(T(u.current,!1,!1),L){const[y,C]=ni({nodeId:i,dragItems:u.current,nodeInternals:F});L(q.sourceEvent,y,C)}}}).filter(q=>{const T=q.target;return!q.button&&(!n||!bu(T,`.${n}`,e))&&(!r||bu(T,r,e))});return _.call(A),()=>{_.on(".drag",null)}}}},[e,t,n,r,o,s,i,a,b]),c}function Dp(){const e=ve();return me(n=>{const{nodeInternals:r,nodeExtent:i,updateNodePositions:o,getNodes:a,snapToGrid:s,snapGrid:c,onError:l,nodesDraggable:u}=e.getState(),d=a().filter(b=>b.selected&&(b.draggable||u&&typeof b.draggable>"u")),f=s?c[0]:5,h=s?c[1]:5,p=n.isShiftPressed?4:1,g=n.x*f*p,m=n.y*h*p,v=d.map(b=>{if(b.positionAbsolute){const _={x:b.positionAbsolute.x+g,y:b.positionAbsolute.y+m};s&&(_.x=c[0]*Math.round(_.x/c[0]),_.y=c[1]*Math.round(_.y/c[1]));const{positionAbsolute:w,position:M}=Pp(b,_,r,i,void 0,l);b.position=M,b.positionAbsolute=w}return b});o(v,!0,!1)},[])}const jt={ArrowUp:{x:0,y:-1},ArrowDown:{x:0,y:1},ArrowLeft:{x:-1,y:0},ArrowRight:{x:1,y:0}};var fn=e=>{const t=({id:n,type:r,data:i,xPos:o,yPos:a,xPosOrigin:s,yPosOrigin:c,selected:l,onClick:u,onMouseEnter:d,onMouseMove:f,onMouseLeave:h,onContextMenu:p,onDoubleClick:g,style:m,className:v,isDraggable:b,isSelectable:_,isConnectable:w,isFocusable:M,selectNodesOnDrag:N,sourcePosition:A,targetPosition:q,hidden:T,resizeObserver:F,dragHandle:D,zIndex:O,isParent:L,noDragClassName:y,noPanClassName:C,initialized:x,disableKeyboardA11y:k,ariaLabel:$,rfId:E,hasHandleBounds:P})=>{const R=ve(),H=ne(null),U=ne(null),B=ne(A),X=ne(q),J=ne(r),z=_||b||u||d||f||h,V=Dp(),W=dn(n,R.getState,d),j=dn(n,R.getState,f),ie=dn(n,R.getState,h),oe=dn(n,R.getState,p),de=dn(n,R.getState,g),ye=K=>{const{nodeDragThreshold:Y}=R.getState();if(_&&(!N||!b||Y>0)&&qs({id:n,store:R,nodeRef:H}),u){const he=R.getState().nodeInternals.get(n);he&&u(K,{...he})}},Z=K=>{if(!Cs(K)&&!k)if(sp.includes(K.key)&&_){const Y=K.key==="Escape";qs({id:n,store:R,unselect:Y,nodeRef:H})}else b&&l&&Object.prototype.hasOwnProperty.call(jt,K.key)&&(R.setState({ariaLiveMessage:`Moved selected node ${K.key.replace("Arrow","").toLowerCase()}. New position, x: ${~~o}, y: ${~~a}`}),V({x:jt[K.key].x,y:jt[K.key].y,isShiftPressed:K.shiftKey}))};ce(()=>()=>{U.current&&(F?.unobserve(U.current),U.current=null)},[]),ce(()=>{if(H.current&&!T){const K=H.current;(!x||!P||U.current!==K)&&(U.current&&F?.unobserve(U.current),F?.observe(K),U.current=K)}},[T,x,P]),ce(()=>{const K=J.current!==r,Y=B.current!==A,he=X.current!==q;H.current&&(K||Y||he)&&(K&&(J.current=r),Y&&(B.current=A),he&&(X.current=q),R.getState().updateNodeDimensions([{id:n,nodeElement:H.current,forceUpdate:!0}]))},[n,r,A,q]);const we=$p({nodeRef:H,disabled:T||!b,noDragClassName:y,handleSelector:D,nodeId:n,isSelectable:_,selectNodesOnDrag:N});return T?null:I.createElement("div",{className:Se(["react-flow__node",`react-flow__node-${r}`,{[C]:b},v,{selected:l,selectable:_,parent:L,dragging:we}]),ref:H,style:{zIndex:O,transform:`translate(${s}px,${c}px)`,pointerEvents:z?"all":"none",visibility:x?"visible":"hidden",...m},"data-id":n,"data-testid":`rf__node-${n}`,onMouseEnter:W,onMouseMove:j,onMouseLeave:ie,onContextMenu:oe,onClick:ye,onDoubleClick:de,onKeyDown:M?Z:void 0,tabIndex:M?0:void 0,role:M?"button":void 0,"aria-describedby":k?void 0:`${Cp}-${E}`,"aria-label":$},I.createElement(p_,{value:n},I.createElement(e,{id:n,data:i,type:r,xPos:o,yPos:a,selected:l,isConnectable:w,sourcePosition:A,targetPosition:q,dragging:we,dragHandle:D,zIndex:O})))};return t.displayName="NodeWrapper",ue(t)};const t1=e=>{const t=e.getNodes().filter(n=>n.selected);return{...Lr(t,e.nodeOrigin),transformString:`translate(${e.transform[0]}px,${e.transform[1]}px) scale(${e.transform[2]})`,userSelectionActive:e.userSelectionActive}};function n1({onSelectionContextMenu:e,noPanClassName:t,disableKeyboardA11y:n}){const r=ve(),{width:i,height:o,x:a,y:s,transformString:c,userSelectionActive:l}=le(t1,xe),u=Dp(),d=ne(null);if(ce(()=>{n||d.current?.focus({preventScroll:!0})},[n]),$p({nodeRef:d}),l||!i||!o)return null;const f=e?p=>{const g=r.getState().getNodes().filter(m=>m.selected);e(p,g)}:void 0,h=p=>{Object.prototype.hasOwnProperty.call(jt,p.key)&&u({x:jt[p.key].x,y:jt[p.key].y,isShiftPressed:p.shiftKey})};return I.createElement("div",{className:Se(["react-flow__nodesselection","react-flow__container",t]),style:{transform:c}},I.createElement("div",{ref:d,className:"react-flow__nodesselection-rect",onContextMenu:f,tabIndex:n?void 0:-1,onKeyDown:n?void 0:h,style:{width:i,height:o,top:s,left:a}}))}var r1=ue(n1);const i1=e=>e.nodesSelectionActive,Fp=({children:e,onPaneClick:t,onPaneMouseEnter:n,onPaneMouseMove:r,onPaneMouseLeave:i,onPaneContextMenu:o,onPaneScroll:a,deleteKeyCode:s,onMove:c,onMoveStart:l,onMoveEnd:u,selectionKeyCode:d,selectionOnDrag:f,selectionMode:h,onSelectionStart:p,onSelectionEnd:g,multiSelectionKeyCode:m,panActivationKeyCode:v,zoomActivationKeyCode:b,elementsSelectable:_,zoomOnScroll:w,zoomOnPinch:M,panOnScroll:N,panOnScrollSpeed:A,panOnScrollMode:q,zoomOnDoubleClick:T,panOnDrag:F,defaultViewport:D,translateExtent:O,minZoom:L,maxZoom:y,preventScrolling:C,onSelectionContextMenu:x,noWheelClassName:k,noPanClassName:$,disableKeyboardA11y:E})=>{const P=le(i1),R=Cn(d),H=Cn(v),U=H||F,B=H||N,X=R||f&&U!==!0;return V_({deleteKeyCode:s,multiSelectionKeyCode:m}),I.createElement(K_,{onMove:c,onMoveStart:l,onMoveEnd:u,onPaneContextMenu:o,elementsSelectable:_,zoomOnScroll:w,zoomOnPinch:M,panOnScroll:B,panOnScrollSpeed:A,panOnScrollMode:q,zoomOnDoubleClick:T,panOnDrag:!R&&U,defaultViewport:D,translateExtent:O,minZoom:L,maxZoom:y,zoomActivationKeyCode:b,preventScrolling:C,noWheelClassName:k,noPanClassName:$},I.createElement(kp,{onSelectionStart:p,onSelectionEnd:g,onPaneClick:t,onPaneMouseEnter:n,onPaneMouseMove:r,onPaneMouseLeave:i,onPaneContextMenu:o,onPaneScroll:a,panOnDrag:U,isSelecting:!!X,selectionMode:h},e,P&&I.createElement(r1,{onSelectionContextMenu:x,noPanClassName:$,disableKeyboardA11y:E})))};Fp.displayName="FlowRenderer";var o1=ue(Fp);function a1(e){return le(me(n=>e?hp(n.nodeInternals,{x:0,y:0,width:n.width,height:n.height},n.transform,!0):n.getNodes(),[e]))}function s1(e){const t={input:fn(e.input||xp),default:fn(e.default||Ts),output:fn(e.output||Sp),group:fn(e.group||dc)},n={},r=Object.keys(e).filter(i=>!["input","default","output","group"].includes(i)).reduce((i,o)=>(i[o]=fn(e[o]||Ts),i),n);return{...t,...r}}const c1=({x:e,y:t,width:n,height:r,origin:i})=>!n||!r?{x:e,y:t}:i[0]<0||i[1]<0||i[0]>1||i[1]>1?{x:e,y:t}:{x:e-n*i[0],y:t-r*i[1]},u1=e=>({nodesDraggable:e.nodesDraggable,nodesConnectable:e.nodesConnectable,nodesFocusable:e.nodesFocusable,elementsSelectable:e.elementsSelectable,updateNodeDimensions:e.updateNodeDimensions,onError:e.onError}),Op=e=>{const{nodesDraggable:t,nodesConnectable:n,nodesFocusable:r,elementsSelectable:i,updateNodeDimensions:o,onError:a}=le(u1,xe),s=a1(e.onlyRenderVisibleElements),c=ne(),l=Oe(()=>{if(typeof ResizeObserver>"u")return null;const u=new ResizeObserver(d=>{const f=d.map(h=>({id:h.target.getAttribute("data-id"),nodeElement:h.target,forceUpdate:!0}));o(f)});return c.current=u,u},[]);return ce(()=>()=>{c?.current?.disconnect()},[]),I.createElement("div",{className:"react-flow__nodes",style:hc},s.map(u=>{let d=u.type||"default";e.nodeTypes[d]||(a?.("003",dt.error003(d)),d="default");const f=e.nodeTypes[d]||e.nodeTypes.default,h=!!(u.draggable||t&&typeof u.draggable>"u"),p=!!(u.selectable||i&&typeof u.selectable>"u"),g=!!(u.connectable||n&&typeof u.connectable>"u"),m=!!(u.focusable||r&&typeof u.focusable>"u"),v=e.nodeExtent?ic(u.positionAbsolute,e.nodeExtent):u.positionAbsolute,b=v?.x??0,_=v?.y??0,w=c1({x:b,y:_,width:u.width??0,height:u.height??0,origin:e.nodeOrigin});return I.createElement(f,{key:u.id,id:u.id,className:u.className,style:u.style,type:d,data:u.data,sourcePosition:u.sourcePosition||G.Bottom,targetPosition:u.targetPosition||G.Top,hidden:u.hidden,xPos:b,yPos:_,xPosOrigin:w.x,yPosOrigin:w.y,selectNodesOnDrag:e.selectNodesOnDrag,onClick:e.onNodeClick,onMouseEnter:e.onNodeMouseEnter,onMouseMove:e.onNodeMouseMove,onMouseLeave:e.onNodeMouseLeave,onContextMenu:e.onNodeContextMenu,onDoubleClick:e.onNodeDoubleClick,selected:!!u.selected,isDraggable:h,isSelectable:p,isConnectable:g,isFocusable:m,resizeObserver:l,dragHandle:u.dragHandle,zIndex:u[pe]?.z??0,isParent:!!u[pe]?.isParent,noDragClassName:e.noDragClassName,noPanClassName:e.noPanClassName,initialized:!!u.width&&!!u.height,rfId:e.rfId,disableKeyboardA11y:e.disableKeyboardA11y,ariaLabel:u.ariaLabel,hasHandleBounds:!!u[pe]?.handleBounds})}))};Op.displayName="NodeRenderer";var l1=ue(Op);const d1=(e,t,n)=>n===G.Left?e-t:n===G.Right?e+t:e,f1=(e,t,n)=>n===G.Top?e-t:n===G.Bottom?e+t:e,xu="react-flow__edgeupdater",Eu=({position:e,centerX:t,centerY:n,radius:r=10,onMouseDown:i,onMouseEnter:o,onMouseOut:a,type:s})=>I.createElement("circle",{onMouseDown:i,onMouseEnter:o,onMouseOut:a,className:Se([xu,`${xu}-${s}`]),cx:d1(t,r,e),cy:f1(n,r,e),r,stroke:"transparent",fill:"transparent"}),h1=()=>!0;var Yt=e=>{const t=({id:n,className:r,type:i,data:o,onClick:a,onEdgeDoubleClick:s,selected:c,animated:l,label:u,labelStyle:d,labelShowBg:f,labelBgStyle:h,labelBgPadding:p,labelBgBorderRadius:g,style:m,source:v,target:b,sourceX:_,sourceY:w,targetX:M,targetY:N,sourcePosition:A,targetPosition:q,elementsSelectable:T,hidden:F,sourceHandleId:D,targetHandleId:O,onContextMenu:L,onMouseEnter:y,onMouseMove:C,onMouseLeave:x,edgeUpdaterRadius:k,onEdgeUpdate:$,onEdgeUpdateStart:E,onEdgeUpdateEnd:P,markerEnd:R,markerStart:H,rfId:U,ariaLabel:B,isFocusable:X,isUpdatable:J,pathOptions:z,interactionWidth:V,disableKeyboardA11y:W})=>{const j=ne(null),[ie,oe]=ae(!1),[de,ye]=ae(!1),Z=ve(),we=Oe(()=>`url('#${As(H,U)}')`,[H,U]),K=Oe(()=>`url('#${As(R,U)}')`,[R,U]);if(F)return null;const Y=be=>{const{edges:Le,addSelectedEdges:Ne,unselectNodesAndEdges:Ae,multiSelectionActive:Bt}=Z.getState(),je=Le.find(At=>At.id===n);je&&(T&&(Z.setState({nodesSelectionActive:!1}),je.selected&&Bt?(Ae({nodes:[],edges:[je]}),j.current?.blur()):Ne([n])),a&&a(be,je))},he=ln(n,Z.getState,s),Be=ln(n,Z.getState,L),Ze=ln(n,Z.getState,y),Ie=ln(n,Z.getState,C),ge=ln(n,Z.getState,x),Me=(be,Le)=>{if(be.button!==0)return;const{edges:Ne,isValidConnection:Ae}=Z.getState(),Bt=Le?b:v,je=(Le?O:D)||null,At=Le?"target":"source",Br=Ae||h1,Vr=Le,sn=Ne.find(Mt=>Mt.id===n);ye(!0),E?.(be,sn,At);const Gr=Mt=>{ye(!1),P?.(Mt,sn,At)};yp({event:be,handleId:je,nodeId:Bt,onConnect:Mt=>$?.(sn,Mt),isTarget:Vr,getState:Z.getState,setState:Z.setState,isValidConnection:Br,edgeUpdaterType:At,onEdgeUpdateEnd:Gr})},Ve=be=>Me(be,!0),tt=be=>Me(be,!1),Xe=()=>oe(!0),ke=()=>oe(!1),nt=!T&&!a,pt=be=>{if(!W&&sp.includes(be.key)&&T){const{unselectNodesAndEdges:Le,addSelectedEdges:Ne,edges:Ae}=Z.getState();be.key==="Escape"?(j.current?.blur(),Le({edges:[Ae.find(je=>je.id===n)]})):Ne([n])}};return I.createElement("g",{className:Se(["react-flow__edge",`react-flow__edge-${i}`,r,{selected:c,animated:l,inactive:nt,updating:ie}]),onClick:Y,onDoubleClick:he,onContextMenu:Be,onMouseEnter:Ze,onMouseMove:Ie,onMouseLeave:ge,onKeyDown:X?pt:void 0,tabIndex:X?0:void 0,role:X?"button":"img","data-testid":`rf__edge-${n}`,"aria-label":B===null?void 0:B||`Edge from ${v} to ${b}`,"aria-describedby":X?`${Ip}-${U}`:void 0,ref:j},!de&&I.createElement(e,{id:n,source:v,target:b,selected:c,animated:l,label:u,labelStyle:d,labelShowBg:f,labelBgStyle:h,labelBgPadding:p,labelBgBorderRadius:g,data:o,style:m,sourceX:_,sourceY:w,targetX:M,targetY:N,sourcePosition:A,targetPosition:q,sourceHandleId:D,targetHandleId:O,markerStart:we,markerEnd:K,pathOptions:z,interactionWidth:V}),J&&I.createElement(I.Fragment,null,(J==="source"||J===!0)&&I.createElement(Eu,{position:A,centerX:_,centerY:w,radius:k,onMouseDown:Ve,onMouseEnter:Xe,onMouseOut:ke,type:"source"}),(J==="target"||J===!0)&&I.createElement(Eu,{position:q,centerX:M,centerY:N,radius:k,onMouseDown:tt,onMouseEnter:Xe,onMouseOut:ke,type:"target"})))};return t.displayName="EdgeWrapper",ue(t)};function p1(e){const t={default:Yt(e.default||hr),straight:Yt(e.bezier||sc),step:Yt(e.step||ac),smoothstep:Yt(e.step||kr),simplebezier:Yt(e.simplebezier||oc)},n={},r=Object.keys(e).filter(i=>!["default","bezier"].includes(i)).reduce((i,o)=>(i[o]=Yt(e[o]||hr),i),n);return{...t,...r}}function Su(e,t,n=null){const r=(n?.x||0)+t.x,i=(n?.y||0)+t.y,o=n?.width||t.width,a=n?.height||t.height;switch(e){case G.Top:return{x:r+o/2,y:i};case G.Right:return{x:r+o,y:i+a/2};case G.Bottom:return{x:r+o/2,y:i+a};case G.Left:return{x:r,y:i+a/2}}}function Nu(e,t){return e?e.length===1||!t?e[0]:t&&e.find(n=>n.id===t)||null:null}const g1=(e,t,n,r,i,o)=>{const a=Su(n,e,t),s=Su(o,r,i);return{sourceX:a.x,sourceY:a.y,targetX:s.x,targetY:s.y}};function m1({sourcePos:e,targetPos:t,sourceWidth:n,sourceHeight:r,targetWidth:i,targetHeight:o,width:a,height:s,transform:c}){const l={x:Math.min(e.x,t.x),y:Math.min(e.y,t.y),x2:Math.max(e.x+n,t.x+i),y2:Math.max(e.y+r,t.y+o)};l.x===l.x2&&(l.x2+=1),l.y===l.y2&&(l.y2+=1);const u=Sn({x:(0-c[0])/c[2],y:(0-c[1])/c[2],width:a/c[2],height:s/c[2]}),d=Math.max(0,Math.min(u.x2,l.x2)-Math.max(u.x,l.x)),f=Math.max(0,Math.min(u.y2,l.y2)-Math.max(u.y,l.y));return Math.ceil(d*f)>0}function Cu(e){const t=e?.[pe]?.handleBounds||null,n=t&&e?.width&&e?.height&&typeof e?.positionAbsolute?.x<"u"&&typeof e?.positionAbsolute?.y<"u";return[{x:e?.positionAbsolute?.x||0,y:e?.positionAbsolute?.y||0,width:e?.width||0,height:e?.height||0},t,!!n]}const v1=[{level:0,isMaxLevel:!0,edges:[]}];function y1(e,t,n=!1){let r=-1;const i=e.reduce((a,s)=>{const c=Fe(s.zIndex);let l=c?s.zIndex:0;if(n){const u=t.get(s.target),d=t.get(s.source),f=s.selected||u?.selected||d?.selected,h=Math.max(d?.[pe]?.z||0,u?.[pe]?.z||0,1e3);l=(c?s.zIndex:0)+(f?h:0)}return a[l]?a[l].push(s):a[l]=[s],r=l>r?l:r,a},{}),o=Object.entries(i).map(([a,s])=>{const c=+a;return{edges:s,level:c,isMaxLevel:c===r}});return o.length===0?v1:o}function w1(e,t,n){const r=le(me(i=>e?i.edges.filter(o=>{const a=t.get(o.source),s=t.get(o.target);return a?.width&&a?.height&&s?.width&&s?.height&&m1({sourcePos:a.positionAbsolute||{x:0,y:0},targetPos:s.positionAbsolute||{x:0,y:0},sourceWidth:a.width,sourceHeight:a.height,targetWidth:s.width,targetHeight:s.height,width:i.width,height:i.height,transform:i.transform})}):i.edges,[e,t]));return y1(r,t,n)}const b1=({color:e="none",strokeWidth:t=1})=>I.createElement("polyline",{style:{stroke:e,strokeWidth:t},strokeLinecap:"round",strokeLinejoin:"round",fill:"none",points:"-5,-4 0,0 -5,4"}),_1=({color:e="none",strokeWidth:t=1})=>I.createElement("polyline",{style:{stroke:e,fill:e,strokeWidth:t},strokeLinecap:"round",strokeLinejoin:"round",points:"-5,-4 0,0 -5,4 -5,-4"}),Iu={[fr.Arrow]:b1,[fr.ArrowClosed]:_1};function x1(e){const t=ve();return Oe(()=>Object.prototype.hasOwnProperty.call(Iu,e)?Iu[e]:(t.getState().onError?.("009",dt.error009(e)),null),[e])}const E1=({id:e,type:t,color:n,width:r=12.5,height:i=12.5,markerUnits:o="strokeWidth",strokeWidth:a,orient:s="auto-start-reverse"})=>{const c=x1(t);return c?I.createElement("marker",{className:"react-flow__arrowhead",id:e,markerWidth:`${r}`,markerHeight:`${i}`,viewBox:"-10 -10 20 20",markerUnits:o,orient:s,refX:"0",refY:"0"},I.createElement(c,{color:n,strokeWidth:a})):null},S1=({defaultColor:e,rfId:t})=>n=>{const r=[];return n.edges.reduce((i,o)=>([o.markerStart,o.markerEnd].forEach(a=>{if(a&&typeof a=="object"){const s=As(a,t);r.includes(s)||(i.push({id:s,color:a.color||e,...a}),r.push(s))}}),i),[]).sort((i,o)=>i.id.localeCompare(o.id))},zp=({defaultColor:e,rfId:t})=>{const n=le(me(S1({defaultColor:e,rfId:t}),[e,t]),(r,i)=>!(r.length!==i.length||r.some((o,a)=>o.id!==i[a].id)));return I.createElement("defs",null,n.map(r=>I.createElement(E1,{id:r.id,key:r.id,type:r.type,color:r.color,width:r.width,height:r.height,markerUnits:r.markerUnits,strokeWidth:r.strokeWidth,orient:r.orient})))};zp.displayName="MarkerDefinitions";var N1=ue(zp);const C1=e=>({nodesConnectable:e.nodesConnectable,edgesFocusable:e.edgesFocusable,edgesUpdatable:e.edgesUpdatable,elementsSelectable:e.elementsSelectable,width:e.width,height:e.height,connectionMode:e.connectionMode,nodeInternals:e.nodeInternals,onError:e.onError}),Hp=({defaultMarkerColor:e,onlyRenderVisibleElements:t,elevateEdgesOnSelect:n,rfId:r,edgeTypes:i,noPanClassName:o,onEdgeUpdate:a,onEdgeContextMenu:s,onEdgeMouseEnter:c,onEdgeMouseMove:l,onEdgeMouseLeave:u,onEdgeClick:d,edgeUpdaterRadius:f,onEdgeDoubleClick:h,onEdgeUpdateStart:p,onEdgeUpdateEnd:g,children:m,disableKeyboardA11y:v})=>{const{edgesFocusable:b,edgesUpdatable:_,elementsSelectable:w,width:M,height:N,connectionMode:A,nodeInternals:q,onError:T}=le(C1,xe),F=w1(t,q,n);return M?I.createElement(I.Fragment,null,F.map(({level:D,edges:O,isMaxLevel:L})=>I.createElement("svg",{key:D,style:{zIndex:D},width:M,height:N,className:"react-flow__edges react-flow__container"},L&&I.createElement(N1,{defaultColor:e,rfId:r}),I.createElement("g",null,O.map(y=>{const[C,x,k]=Cu(q.get(y.source)),[$,E,P]=Cu(q.get(y.target));if(!k||!P)return null;let R=y.type||"default";i[R]||(T?.("011",dt.error011(R)),R="default");const H=i[R]||i.default,U=A===zt.Strict?E.target:(E.target??[]).concat(E.source??[]),B=Nu(x.source,y.sourceHandle),X=Nu(U,y.targetHandle),J=B?.position||G.Bottom,z=X?.position||G.Top,V=!!(y.focusable||b&&typeof y.focusable>"u"),W=typeof a<"u"&&(y.updatable||_&&typeof y.updatable>"u");if(!B||!X)return T?.("008",dt.error008(B,y)),null;const{sourceX:j,sourceY:ie,targetX:oe,targetY:de}=g1(C,B,J,$,X,z);return I.createElement(H,{key:y.id,id:y.id,className:Se([y.className,o]),type:R,data:y.data,selected:!!y.selected,animated:!!y.animated,hidden:!!y.hidden,label:y.label,labelStyle:y.labelStyle,labelShowBg:y.labelShowBg,labelBgStyle:y.labelBgStyle,labelBgPadding:y.labelBgPadding,labelBgBorderRadius:y.labelBgBorderRadius,style:y.style,source:y.source,target:y.target,sourceHandleId:y.sourceHandle,targetHandleId:y.targetHandle,markerEnd:y.markerEnd,markerStart:y.markerStart,sourceX:j,sourceY:ie,targetX:oe,targetY:de,sourcePosition:J,targetPosition:z,elementsSelectable:w,onEdgeUpdate:a,onContextMenu:s,onMouseEnter:c,onMouseMove:l,onMouseLeave:u,onClick:d,edgeUpdaterRadius:f,onEdgeDoubleClick:h,onEdgeUpdateStart:p,onEdgeUpdateEnd:g,rfId:r,ariaLabel:y.ariaLabel,isFocusable:V,isUpdatable:W,pathOptions:"pathOptions"in y?y.pathOptions:void 0,interactionWidth:y.interactionWidth,disableKeyboardA11y:v})})))),m):null};Hp.displayName="EdgeRenderer";var I1=ue(Hp);const A1=e=>`translate(${e.transform[0]}px,${e.transform[1]}px) scale(${e.transform[2]})`;function M1({children:e}){const t=le(A1);return I.createElement("div",{className:"react-flow__viewport react-flow__container",style:{transform:t}},e)}function T1(e){const t=fc(),n=ne(!1);ce(()=>{!n.current&&t.viewportInitialized&&e&&(setTimeout(()=>e(t),1),n.current=!0)},[e,t.viewportInitialized])}const q1={[G.Left]:G.Right,[G.Right]:G.Left,[G.Top]:G.Bottom,[G.Bottom]:G.Top},Bp=({nodeId:e,handleType:t,style:n,type:r=bt.Bezier,CustomComponent:i,connectionStatus:o})=>{const{fromNode:a,handleId:s,toX:c,toY:l,connectionMode:u}=le(me(N=>({fromNode:N.nodeInternals.get(e),handleId:N.connectionHandleId,toX:(N.connectionPosition.x-N.transform[0])/N.transform[2],toY:(N.connectionPosition.y-N.transform[1])/N.transform[2],connectionMode:N.connectionMode}),[e]),xe),d=a?.[pe]?.handleBounds;let f=d?.[t];if(u===zt.Loose&&(f=f||d?.[t==="source"?"target":"source"]),!a||!f)return null;const h=s?f.find(N=>N.id===s):f[0],p=h?h.x+h.width/2:(a.width??0)/2,g=h?h.y+h.height/2:a.height??0,m=(a.positionAbsolute?.x??0)+p,v=(a.positionAbsolute?.y??0)+g,b=h?.position,_=b?q1[b]:null;if(!b||!_)return null;if(i)return I.createElement(i,{connectionLineType:r,connectionLineStyle:n,fromNode:a,fromHandle:h,fromX:m,fromY:v,toX:c,toY:l,fromPosition:b,toPosition:_,connectionStatus:o});let w="";const M={sourceX:m,sourceY:v,sourcePosition:b,targetX:c,targetY:l,targetPosition:_};return r===bt.Bezier?[w]=cc(M):r===bt.Step?[w]=Is({...M,borderRadius:0}):r===bt.SmoothStep?[w]=Is(M):r===bt.SimpleBezier?[w]=dp(M):w=`M${m},${v} ${c},${l}`,I.createElement("path",{d:w,fill:"none",className:"react-flow__connection-path",style:n})};Bp.displayName="ConnectionLine";const R1=e=>({nodeId:e.connectionNodeId,handleType:e.connectionHandleType,nodesConnectable:e.nodesConnectable,connectionStatus:e.connectionStatus,width:e.width,height:e.height});function k1({containerStyle:e,style:t,type:n,component:r}){const{nodeId:i,handleType:o,nodesConnectable:a,width:s,height:c,connectionStatus:l}=le(R1,xe);return!(i&&o&&s&&a)?null:I.createElement("svg",{style:e,width:s,height:c,className:"react-flow__edges react-flow__connectionline react-flow__container"},I.createElement("g",{className:Se(["react-flow__connection",l])},I.createElement(Bp,{nodeId:i,handleType:o,style:t,type:n,CustomComponent:r,connectionStatus:l})))}function Au(e,t){return ne(null),ve(),Oe(()=>t(e),[e])}const Vp=({nodeTypes:e,edgeTypes:t,onMove:n,onMoveStart:r,onMoveEnd:i,onInit:o,onNodeClick:a,onEdgeClick:s,onNodeDoubleClick:c,onEdgeDoubleClick:l,onNodeMouseEnter:u,onNodeMouseMove:d,onNodeMouseLeave:f,onNodeContextMenu:h,onSelectionContextMenu:p,onSelectionStart:g,onSelectionEnd:m,connectionLineType:v,connectionLineStyle:b,connectionLineComponent:_,connectionLineContainerStyle:w,selectionKeyCode:M,selectionOnDrag:N,selectionMode:A,multiSelectionKeyCode:q,panActivationKeyCode:T,zoomActivationKeyCode:F,deleteKeyCode:D,onlyRenderVisibleElements:O,elementsSelectable:L,selectNodesOnDrag:y,defaultViewport:C,translateExtent:x,minZoom:k,maxZoom:$,preventScrolling:E,defaultMarkerColor:P,zoomOnScroll:R,zoomOnPinch:H,panOnScroll:U,panOnScrollSpeed:B,panOnScrollMode:X,zoomOnDoubleClick:J,panOnDrag:z,onPaneClick:V,onPaneMouseEnter:W,onPaneMouseMove:j,onPaneMouseLeave:ie,onPaneScroll:oe,onPaneContextMenu:de,onEdgeUpdate:ye,onEdgeContextMenu:Z,onEdgeMouseEnter:we,onEdgeMouseMove:K,onEdgeMouseLeave:Y,edgeUpdaterRadius:he,onEdgeUpdateStart:Be,onEdgeUpdateEnd:Ze,noDragClassName:Ie,noWheelClassName:ge,noPanClassName:Me,elevateEdgesOnSelect:Ve,disableKeyboardA11y:tt,nodeOrigin:Xe,nodeExtent:ke,rfId:nt})=>{const pt=Au(e,s1),be=Au(t,p1);return T1(o),I.createElement(o1,{onPaneClick:V,onPaneMouseEnter:W,onPaneMouseMove:j,onPaneMouseLeave:ie,onPaneContextMenu:de,onPaneScroll:oe,deleteKeyCode:D,selectionKeyCode:M,selectionOnDrag:N,selectionMode:A,onSelectionStart:g,onSelectionEnd:m,multiSelectionKeyCode:q,panActivationKeyCode:T,zoomActivationKeyCode:F,elementsSelectable:L,onMove:n,onMoveStart:r,onMoveEnd:i,zoomOnScroll:R,zoomOnPinch:H,zoomOnDoubleClick:J,panOnScroll:U,panOnScrollSpeed:B,panOnScrollMode:X,panOnDrag:z,defaultViewport:C,translateExtent:x,minZoom:k,maxZoom:$,onSelectionContextMenu:p,preventScrolling:E,noDragClassName:Ie,noWheelClassName:ge,noPanClassName:Me,disableKeyboardA11y:tt},I.createElement(M1,null,I.createElement(I1,{edgeTypes:be,onEdgeClick:s,onEdgeDoubleClick:l,onEdgeUpdate:ye,onlyRenderVisibleElements:O,onEdgeContextMenu:Z,onEdgeMouseEnter:we,onEdgeMouseMove:K,onEdgeMouseLeave:Y,onEdgeUpdateStart:Be,onEdgeUpdateEnd:Ze,edgeUpdaterRadius:he,defaultMarkerColor:P,noPanClassName:Me,elevateEdgesOnSelect:!!Ve,disableKeyboardA11y:tt,rfId:nt},I.createElement(k1,{style:b,type:v,component:_,containerStyle:w})),I.createElement("div",{className:"react-flow__edgelabel-renderer"}),I.createElement(l1,{nodeTypes:pt,onNodeClick:a,onNodeDoubleClick:c,onNodeMouseEnter:u,onNodeMouseMove:d,onNodeMouseLeave:f,onNodeContextMenu:h,selectNodesOnDrag:y,onlyRenderVisibleElements:O,noPanClassName:Me,noDragClassName:Ie,disableKeyboardA11y:tt,nodeOrigin:Xe,nodeExtent:ke,rfId:nt})))};Vp.displayName="GraphView";var L1=ue(Vp);const Rs=[[Number.NEGATIVE_INFINITY,Number.NEGATIVE_INFINITY],[Number.POSITIVE_INFINITY,Number.POSITIVE_INFINITY]],gt={rfId:"1",width:0,height:0,transform:[0,0,1],nodeInternals:new Map,edges:[],onNodesChange:null,onEdgesChange:null,hasDefaultNodes:!1,hasDefaultEdges:!1,d3Zoom:null,d3Selection:null,d3ZoomHandler:void 0,minZoom:.5,maxZoom:2,translateExtent:Rs,nodeExtent:Rs,nodesSelectionActive:!1,userSelectionActive:!1,userSelectionRect:null,connectionNodeId:null,connectionHandleId:null,connectionHandleType:"source",connectionPosition:{x:0,y:0},connectionStatus:null,connectionMode:zt.Strict,domNode:null,paneDragging:!1,noPanClassName:"nopan",nodeOrigin:[0,0],nodeDragThreshold:0,snapGrid:[15,15],snapToGrid:!1,nodesDraggable:!0,nodesConnectable:!0,nodesFocusable:!0,edgesFocusable:!0,edgesUpdatable:!0,elementsSelectable:!0,elevateNodesOnSelect:!0,fitViewOnInit:!1,fitViewOnInitDone:!1,fitViewOnInitOptions:void 0,onSelectionChange:[],multiSelectionActive:!1,connectionStartHandle:null,connectionEndHandle:null,connectionClickStartHandle:null,connectOnClick:!0,ariaLiveMessage:"",autoPanOnConnect:!0,autoPanOnNodeDrag:!0,connectionRadius:20,onError:s_,isValidConnection:void 0},P1=()=>xy((e,t)=>({...gt,setNodes:n=>{const{nodeInternals:r,nodeOrigin:i,elevateNodesOnSelect:o}=t();e({nodeInternals:ei(n,r,i,o)})},getNodes:()=>Array.from(t().nodeInternals.values()),setEdges:n=>{const{defaultEdgeOptions:r={}}=t();e({edges:n.map(i=>({...r,...i}))})},setDefaultNodesAndEdges:(n,r)=>{const i=typeof n<"u",o=typeof r<"u",a=i?ei(n,new Map,t().nodeOrigin,t().elevateNodesOnSelect):new Map;e({nodeInternals:a,edges:o?r:[],hasDefaultNodes:i,hasDefaultEdges:o})},updateNodeDimensions:n=>{const{onNodesChange:r,nodeInternals:i,fitViewOnInit:o,fitViewOnInitDone:a,fitViewOnInitOptions:s,domNode:c,nodeOrigin:l}=t(),u=c?.querySelector(".react-flow__viewport");if(!u)return;const d=window.getComputedStyle(u),{m22:f}=new window.DOMMatrixReadOnly(d.transform),h=n.reduce((g,m)=>{const v=i.get(m.id);if(v?.hidden)i.set(v.id,{...v,[pe]:{...v[pe],handleBounds:void 0}});else if(v){const b=rc(m.nodeElement);!!(b.width&&b.height&&(v.width!==b.width||v.height!==b.height||m.forceUpdate))&&(i.set(v.id,{...v,[pe]:{...v[pe],handleBounds:{source:_u(".source",m.nodeElement,f,l),target:_u(".target",m.nodeElement,f,l)}},...b}),g.push({id:v.id,type:"dimensions",dimensions:b}))}return g},[]);Mp(i,l);const p=a||o&&!a&&Tp(t,{initial:!0,...s});e({nodeInternals:new Map(i),fitViewOnInitDone:p}),h?.length>0&&r?.(h)},updateNodePositions:(n,r=!0,i=!1)=>{const{triggerNodeChanges:o}=t(),a=n.map(s=>{const c={id:s.id,type:"position",dragging:i};return r&&(c.positionAbsolute=s.positionAbsolute,c.position=s.position),c});o(a)},triggerNodeChanges:n=>{const{onNodesChange:r,nodeInternals:i,hasDefaultNodes:o,nodeOrigin:a,getNodes:s,elevateNodesOnSelect:c}=t();if(n?.length){if(o){const l=Rp(n,s()),u=ei(l,i,a,c);e({nodeInternals:u})}r?.(n)}},addSelectedNodes:n=>{const{multiSelectionActive:r,edges:i,getNodes:o}=t();let a,s=null;r?a=n.map(c=>wt(c,!0)):(a=Kt(o(),n),s=Kt(i,[])),Kn({changedNodes:a,changedEdges:s,get:t,set:e})},addSelectedEdges:n=>{const{multiSelectionActive:r,edges:i,getNodes:o}=t();let a,s=null;r?a=n.map(c=>wt(c,!0)):(a=Kt(i,n),s=Kt(o(),[])),Kn({changedNodes:s,changedEdges:a,get:t,set:e})},unselectNodesAndEdges:({nodes:n,edges:r}={})=>{const{edges:i,getNodes:o}=t(),a=n||o(),s=r||i,c=a.map(u=>(u.selected=!1,wt(u.id,!1))),l=s.map(u=>wt(u.id,!1));Kn({changedNodes:c,changedEdges:l,get:t,set:e})},setMinZoom:n=>{const{d3Zoom:r,maxZoom:i}=t();r?.scaleExtent([n,i]),e({minZoom:n})},setMaxZoom:n=>{const{d3Zoom:r,minZoom:i}=t();r?.scaleExtent([i,n]),e({maxZoom:n})},setTranslateExtent:n=>{t().d3Zoom?.translateExtent(n),e({translateExtent:n})},resetSelectedElements:()=>{const{edges:n,getNodes:r}=t(),o=r().filter(s=>s.selected).map(s=>wt(s.id,!1)),a=n.filter(s=>s.selected).map(s=>wt(s.id,!1));Kn({changedNodes:o,changedEdges:a,get:t,set:e})},setNodeExtent:n=>{const{nodeInternals:r}=t();r.forEach(i=>{i.positionAbsolute=ic(i.position,n)}),e({nodeExtent:n,nodeInternals:new Map(r)})},panBy:n=>{const{transform:r,width:i,height:o,d3Zoom:a,d3Selection:s,translateExtent:c}=t();if(!a||!s||!n.x&&!n.y)return!1;const l=ct.translate(r[0]+n.x,r[1]+n.y).scale(r[2]),u=[[0,0],[i,o]],d=a?.constrain()(l,u,c);return a.transform(s,d),r[0]!==d.x||r[1]!==d.y||r[2]!==d.k},cancelConnection:()=>e({connectionNodeId:gt.connectionNodeId,connectionHandleId:gt.connectionHandleId,connectionHandleType:gt.connectionHandleType,connectionStatus:gt.connectionStatus,connectionStartHandle:gt.connectionStartHandle,connectionEndHandle:gt.connectionEndHandle}),reset:()=>e({...gt})}),Object.is),Gp=({children:e})=>{const t=ne(null);return t.current||(t.current=P1()),I.createElement(e_,{value:t.current},e)};Gp.displayName="ReactFlowProvider";const Up=({children:e})=>wr(Rr)?I.createElement(I.Fragment,null,e):I.createElement(Gp,null,e);Up.displayName="ReactFlowWrapper";const $1={input:xp,default:Ts,output:Sp,group:dc},D1={default:hr,straight:sc,step:ac,smoothstep:kr,simplebezier:oc},F1=[0,0],O1=[15,15],z1={x:0,y:0,zoom:1},H1={width:"100%",height:"100%",overflow:"hidden",position:"relative",zIndex:0},Yp=Qf(({nodes:e,edges:t,defaultNodes:n,defaultEdges:r,className:i,nodeTypes:o=$1,edgeTypes:a=D1,onNodeClick:s,onEdgeClick:c,onInit:l,onMove:u,onMoveStart:d,onMoveEnd:f,onConnect:h,onConnectStart:p,onConnectEnd:g,onClickConnectStart:m,onClickConnectEnd:v,onNodeMouseEnter:b,onNodeMouseMove:_,onNodeMouseLeave:w,onNodeContextMenu:M,onNodeDoubleClick:N,onNodeDragStart:A,onNodeDrag:q,onNodeDragStop:T,onNodesDelete:F,onEdgesDelete:D,onSelectionChange:O,onSelectionDragStart:L,onSelectionDrag:y,onSelectionDragStop:C,onSelectionContextMenu:x,onSelectionStart:k,onSelectionEnd:$,connectionMode:E=zt.Strict,connectionLineType:P=bt.Bezier,connectionLineStyle:R,connectionLineComponent:H,connectionLineContainerStyle:U,deleteKeyCode:B="Backspace",selectionKeyCode:X="Shift",selectionOnDrag:J=!1,selectionMode:z=Nn.Full,panActivationKeyCode:V="Space",multiSelectionKeyCode:W=dr()?"Meta":"Control",zoomActivationKeyCode:j=dr()?"Meta":"Control",snapToGrid:ie=!1,snapGrid:oe=O1,onlyRenderVisibleElements:de=!1,selectNodesOnDrag:ye=!0,nodesDraggable:Z,nodesConnectable:we,nodesFocusable:K,nodeOrigin:Y=F1,edgesFocusable:he,edgesUpdatable:Be,elementsSelectable:Ze,defaultViewport:Ie=z1,minZoom:ge=.5,maxZoom:Me=2,translateExtent:Ve=Rs,preventScrolling:tt=!0,nodeExtent:Xe,defaultMarkerColor:ke="#b1b1b7",zoomOnScroll:nt=!0,zoomOnPinch:pt=!0,panOnScroll:be=!1,panOnScrollSpeed:Le=.5,panOnScrollMode:Ne=kt.Free,zoomOnDoubleClick:Ae=!0,panOnDrag:Bt=!0,onPaneClick:je,onPaneMouseEnter:At,onPaneMouseMove:Br,onPaneMouseLeave:Vr,onPaneScroll:sn,onPaneContextMenu:Gr,children:Tc,onEdgeUpdate:Mt,onEdgeContextMenu:cm,onEdgeDoubleClick:um,onEdgeMouseEnter:lm,onEdgeMouseMove:dm,onEdgeMouseLeave:fm,onEdgeUpdateStart:hm,onEdgeUpdateEnd:pm,edgeUpdaterRadius:gm=10,onNodesChange:mm,onEdgesChange:vm,noDragClassName:ym="nodrag",noWheelClassName:wm="nowheel",noPanClassName:qc="nopan",fitView:bm=!1,fitViewOptions:_m,connectOnClick:xm=!0,attributionPosition:Em,proOptions:Sm,defaultEdgeOptions:Nm,elevateNodesOnSelect:Cm=!0,elevateEdgesOnSelect:Im=!1,disableKeyboardA11y:Rc=!1,autoPanOnConnect:Am=!0,autoPanOnNodeDrag:Mm=!0,connectionRadius:Tm=20,isValidConnection:qm,onError:Rm,style:km,id:kc,nodeDragThreshold:Lm,...Pm},$m)=>{const Ur=kc||"1";return I.createElement("div",{...Pm,style:{...km,...H1},ref:$m,className:Se(["react-flow",i]),"data-testid":"rf__wrapper",id:kc},I.createElement(Up,null,I.createElement(L1,{onInit:l,onMove:u,onMoveStart:d,onMoveEnd:f,onNodeClick:s,onEdgeClick:c,onNodeMouseEnter:b,onNodeMouseMove:_,onNodeMouseLeave:w,onNodeContextMenu:M,onNodeDoubleClick:N,nodeTypes:o,edgeTypes:a,connectionLineType:P,connectionLineStyle:R,connectionLineComponent:H,connectionLineContainerStyle:U,selectionKeyCode:X,selectionOnDrag:J,selectionMode:z,deleteKeyCode:B,multiSelectionKeyCode:W,panActivationKeyCode:V,zoomActivationKeyCode:j,onlyRenderVisibleElements:de,selectNodesOnDrag:ye,defaultViewport:Ie,translateExtent:Ve,minZoom:ge,maxZoom:Me,preventScrolling:tt,zoomOnScroll:nt,zoomOnPinch:pt,zoomOnDoubleClick:Ae,panOnScroll:be,panOnScrollSpeed:Le,panOnScrollMode:Ne,panOnDrag:Bt,onPaneClick:je,onPaneMouseEnter:At,onPaneMouseMove:Br,onPaneMouseLeave:Vr,onPaneScroll:sn,onPaneContextMenu:Gr,onSelectionContextMenu:x,onSelectionStart:k,onSelectionEnd:$,onEdgeUpdate:Mt,onEdgeContextMenu:cm,onEdgeDoubleClick:um,onEdgeMouseEnter:lm,onEdgeMouseMove:dm,onEdgeMouseLeave:fm,onEdgeUpdateStart:hm,onEdgeUpdateEnd:pm,edgeUpdaterRadius:gm,defaultMarkerColor:ke,noDragClassName:ym,noWheelClassName:wm,noPanClassName:qc,elevateEdgesOnSelect:Im,rfId:Ur,disableKeyboardA11y:Rc,nodeOrigin:Y,nodeExtent:Xe}),I.createElement(q_,{nodes:e,edges:t,defaultNodes:n,defaultEdges:r,onConnect:h,onConnectStart:p,onConnectEnd:g,onClickConnectStart:m,onClickConnectEnd:v,nodesDraggable:Z,nodesConnectable:we,nodesFocusable:K,edgesFocusable:he,edgesUpdatable:Be,elementsSelectable:Ze,elevateNodesOnSelect:Cm,minZoom:ge,maxZoom:Me,nodeExtent:Xe,onNodesChange:mm,onEdgesChange:vm,snapToGrid:ie,snapGrid:oe,connectionMode:E,translateExtent:Ve,connectOnClick:xm,defaultEdgeOptions:Nm,fitView:bm,fitViewOptions:_m,onNodesDelete:F,onEdgesDelete:D,onNodeDragStart:A,onNodeDrag:q,onNodeDragStop:T,onSelectionDrag:y,onSelectionDragStart:L,onSelectionDragStop:C,noPanClassName:qc,nodeOrigin:Y,rfId:Ur,autoPanOnConnect:Am,autoPanOnNodeDrag:Mm,onError:Rm,connectionRadius:Tm,isValidConnection:qm,nodeDragThreshold:Lm}),I.createElement(M_,{onSelectionChange:O}),Tc,I.createElement(n_,{proOptions:Sm,position:Em}),I.createElement($_,{rfId:Ur,disableKeyboardA11y:Rc})))});Yp.displayName="ReactFlow";function Kp(e){return t=>{const[n,r]=ae(t),i=me(o=>r(a=>e(o,a)),[]);return[n,r,i]}}const B1=Kp(Rp),V1=Kp(X_),Wp=({id:e,x:t,y:n,width:r,height:i,style:o,color:a,strokeColor:s,strokeWidth:c,className:l,borderRadius:u,shapeRendering:d,onClick:f,selected:h})=>{const{background:p,backgroundColor:g}=o||{},m=a||p||g;return I.createElement("rect",{className:Se(["react-flow__minimap-node",{selected:h},l]),x:t,y:n,rx:u,ry:u,width:r,height:i,fill:m,stroke:s,strokeWidth:c,shapeRendering:d,onClick:f?v=>f(v,e):void 0})};Wp.displayName="MiniMapNode";var G1=ue(Wp);const U1=e=>e.nodeOrigin,Y1=e=>e.getNodes().filter(t=>!t.hidden&&t.width&&t.height),ii=e=>e instanceof Function?e:()=>e;function K1({nodeStrokeColor:e="transparent",nodeColor:t="#e2e2e2",nodeClassName:n="",nodeBorderRadius:r=5,nodeStrokeWidth:i=2,nodeComponent:o=G1,onClick:a}){const s=le(Y1,xe),c=le(U1),l=ii(t),u=ii(e),d=ii(n),f=typeof window>"u"||window.chrome?"crispEdges":"geometricPrecision";return I.createElement(I.Fragment,null,s.map(h=>{const{x:p,y:g}=Ft(h,c).positionAbsolute;return I.createElement(o,{key:h.id,x:p,y:g,width:h.width,height:h.height,style:h.style,selected:h.selected,className:d(h),color:l(h),borderRadius:r,strokeColor:u(h),strokeWidth:i,shapeRendering:f,onClick:a,id:h.id})}))}var W1=ue(K1);const Z1=200,X1=150,j1=e=>{const t=e.getNodes(),n={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]};return{viewBB:n,boundingRect:t.length>0?o_(Lr(t,e.nodeOrigin),n):n,rfId:e.rfId}},Q1="react-flow__minimap-desc";function Zp({style:e,className:t,nodeStrokeColor:n="transparent",nodeColor:r="#e2e2e2",nodeClassName:i="",nodeBorderRadius:o=5,nodeStrokeWidth:a=2,nodeComponent:s,maskColor:c="rgb(240, 240, 240, 0.6)",maskStrokeColor:l="none",maskStrokeWidth:u=1,position:d="bottom-right",onClick:f,onNodeClick:h,pannable:p=!1,zoomable:g=!1,ariaLabel:m="React Flow mini map",inversePan:v=!1,zoomStep:b=10,offsetScale:_=5}){const w=ve(),M=ne(null),{boundingRect:N,viewBB:A,rfId:q}=le(j1,xe),T=e?.width??Z1,F=e?.height??X1,D=N.width/T,O=N.height/F,L=Math.max(D,O),y=L*T,C=L*F,x=_*L,k=N.x-(y-N.width)/2-x,$=N.y-(C-N.height)/2-x,E=y+x*2,P=C+x*2,R=`${Q1}-${q}`,H=ne(0);H.current=L,ce(()=>{if(M.current){const X=De(M.current),J=W=>{const{transform:j,d3Selection:ie,d3Zoom:oe}=w.getState();if(W.sourceEvent.type!=="wheel"||!ie||!oe)return;const de=-W.sourceEvent.deltaY*(W.sourceEvent.deltaMode===1?.05:W.sourceEvent.deltaMode?1:.002)*b,ye=j[2]*Math.pow(2,de);oe.scaleTo(ie,ye)},z=W=>{const{transform:j,d3Selection:ie,d3Zoom:oe,translateExtent:de,width:ye,height:Z}=w.getState();if(W.sourceEvent.type!=="mousemove"||!ie||!oe)return;const we=H.current*Math.max(1,j[2])*(v?-1:1),K={x:j[0]-W.sourceEvent.movementX*we,y:j[1]-W.sourceEvent.movementY*we},Y=[[0,0],[ye,Z]],he=ct.translate(K.x,K.y).scale(j[2]),Be=oe.constrain()(he,Y,de);oe.transform(ie,Be)},V=tp().on("zoom",p?z:null).on("zoom.wheel",g?J:null);return X.call(V),()=>{X.on("zoom",null)}}},[p,g,v,b]);const U=f?X=>{const J=Ge(X);f(X,{x:J[0],y:J[1]})}:void 0,B=h?(X,J)=>{const z=w.getState().nodeInternals.get(J);h(X,z)}:void 0;return I.createElement(nc,{position:d,style:e,className:Se(["react-flow__minimap",t]),"data-testid":"rf__minimap"},I.createElement("svg",{width:T,height:F,viewBox:`${k} ${$} ${E} ${P}`,role:"img","aria-labelledby":R,ref:M,onClick:U},m&&I.createElement("title",{id:R},m),I.createElement(W1,{onClick:B,nodeColor:r,nodeStrokeColor:n,nodeBorderRadius:o,nodeClassName:i,nodeStrokeWidth:a,nodeComponent:s}),I.createElement("path",{className:"react-flow__minimap-mask",d:`M${k-x},${$-x}h${E+x*2}v${P+x*2}h${-E-x*2}z
        M${A.x},${A.y}h${A.width}v${A.height}h${-A.width}z`,fill:c,fillRule:"evenodd",stroke:l,strokeWidth:u,pointerEvents:"none"})))}Zp.displayName="MiniMap";var J1=ue(Zp);function ex(){return I.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 32 32"},I.createElement("path",{d:"M32 18.133H18.133V32h-4.266V18.133H0v-4.266h13.867V0h4.266v13.867H32z"}))}function tx(){return I.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 32 5"},I.createElement("path",{d:"M0 0h32v4.2H0z"}))}function nx(){return I.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 32 30"},I.createElement("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 rx(){return I.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 25 32"},I.createElement("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 ix(){return I.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 25 32"},I.createElement("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"}))}const gn=({children:e,className:t,...n})=>I.createElement("button",{type:"button",className:Se(["react-flow__controls-button",t]),...n},e);gn.displayName="ControlButton";const ox=e=>({isInteractive:e.nodesDraggable||e.nodesConnectable||e.elementsSelectable,minZoomReached:e.transform[2]<=e.minZoom,maxZoomReached:e.transform[2]>=e.maxZoom}),Xp=({style:e,showZoom:t=!0,showFitView:n=!0,showInteractive:r=!0,fitViewOptions:i,onZoomIn:o,onZoomOut:a,onFitView:s,onInteractiveChange:c,className:l,children:u,position:d="bottom-left"})=>{const f=ve(),[h,p]=ae(!1),{isInteractive:g,minZoomReached:m,maxZoomReached:v}=le(ox,xe),{zoomIn:b,zoomOut:_,fitView:w}=fc();if(ce(()=>{p(!0)},[]),!h)return null;const M=()=>{b(),o?.()},N=()=>{_(),a?.()},A=()=>{w(i),s?.()},q=()=>{f.setState({nodesDraggable:!g,nodesConnectable:!g,elementsSelectable:!g}),c?.(!g)};return I.createElement(nc,{className:Se(["react-flow__controls",l]),position:d,style:e,"data-testid":"rf__controls"},t&&I.createElement(I.Fragment,null,I.createElement(gn,{onClick:M,className:"react-flow__controls-zoomin",title:"zoom in","aria-label":"zoom in",disabled:v},I.createElement(ex,null)),I.createElement(gn,{onClick:N,className:"react-flow__controls-zoomout",title:"zoom out","aria-label":"zoom out",disabled:m},I.createElement(tx,null))),n&&I.createElement(gn,{className:"react-flow__controls-fitview",onClick:A,title:"fit view","aria-label":"fit view"},I.createElement(nx,null)),r&&I.createElement(gn,{className:"react-flow__controls-interactive",onClick:q,title:"toggle interactivity","aria-label":"toggle interactivity"},g?I.createElement(ix,null):I.createElement(rx,null)),u)};Xp.displayName="Controls";var ax=ue(Xp),Ye;(function(e){e.Lines="lines",e.Dots="dots",e.Cross="cross"})(Ye||(Ye={}));function sx({color:e,dimensions:t,lineWidth:n}){return I.createElement("path",{stroke:e,strokeWidth:n,d:`M${t[0]/2} 0 V${t[1]} M0 ${t[1]/2} H${t[0]}`})}function cx({color:e,radius:t}){return I.createElement("circle",{cx:t,cy:t,r:t,fill:e})}const ux={[Ye.Dots]:"#91919a",[Ye.Lines]:"#eee",[Ye.Cross]:"#e2e2e2"},lx={[Ye.Dots]:1,[Ye.Lines]:1,[Ye.Cross]:6},dx=e=>({transform:e.transform,patternId:`pattern-${e.rfId}`});function jp({id:e,variant:t=Ye.Dots,gap:n=20,size:r,lineWidth:i=1,offset:o=2,color:a,style:s,className:c}){const l=ne(null),{transform:u,patternId:d}=le(dx,xe),f=a||ux[t],h=r||lx[t],p=t===Ye.Dots,g=t===Ye.Cross,m=Array.isArray(n)?n:[n,n],v=[m[0]*u[2]||1,m[1]*u[2]||1],b=h*u[2],_=g?[b,b]:v,w=p?[b/o,b/o]:[_[0]/o,_[1]/o];return I.createElement("svg",{className:Se(["react-flow__background",c]),style:{...s,position:"absolute",width:"100%",height:"100%",top:0,left:0},ref:l,"data-testid":"rf__background"},I.createElement("pattern",{id:d+e,x:u[0]%v[0],y:u[1]%v[1],width:v[0],height:v[1],patternUnits:"userSpaceOnUse",patternTransform:`translate(-${w[0]},-${w[1]})`},p?I.createElement(cx,{color:f,radius:b/o}):I.createElement(sx,{dimensions:_,color:f,lineWidth:i})),I.createElement("rect",{x:"0",y:"0",width:"100%",height:"100%",fill:`url(#${d+e})`}))}jp.displayName="Background";var fx=ue(jp);function hx(e,t){const n=ne(!1);ce(()=>{if(n.current)return e();n.current=!0},t)}var oi,Mu;function pc(){if(Mu)return oi;Mu=1;function e(t,n){for(var r=-1,i=t==null?0:t.length;++rh))return!1;var g=d.get(a),m=d.get(s);if(g&&m)return g==s&&m==a;var v=-1,b=!0,_=c&i?new e:void 0;for(d.set(a,s),d.set(s,a);++v0&&o(u)?i>1?n(u,i-1,o,a,s):e(s,u):a||(s[s.length]=u)}return s}return Yo=n,Yo}var Ko,md;function Sg(){if(md)return Ko;md=1;function e(t,n,r,i){for(var o=t.length,a=r+(i?1:-1);i?a--:++a-1}return jo=t,jo}var Qo,_d;function mE(){if(_d)return Qo;_d=1;function e(t,n,r){for(var i=-1,o=t==null?0:t.length;++i=a){var v=l?null:i(c);if(v)return o(v);p=!1,f=r,m=new e}else m=l?[]:g;e:for(;++d1?h.setNode(p,d):h.setNode(p)}),this},i.prototype.setNode=function(u,d){return e.has(this._nodes,u)?(arguments.length>1&&(this._nodes[u]=d),this):(this._nodes[u]=arguments.length>1?d:this._defaultNodeLabelFn(u),this._isCompound&&(this._parent[u]=n,this._children[u]={},this._children[n][u]=!0),this._in[u]={},this._preds[u]={},this._out[u]={},this._sucs[u]={},++this._nodeCount,this)},i.prototype.node=function(u){return this._nodes[u]},i.prototype.hasNode=function(u){return e.has(this._nodes,u)},i.prototype.removeNode=function(u){var d=this;if(e.has(this._nodes,u)){var f=function(h){d.removeEdge(d._edgeObjs[h])};delete this._nodes[u],this._isCompound&&(this._removeFromParentsChildList(u),delete this._parent[u],e.each(this.children(u),function(h){d.setParent(h)}),delete this._children[u]),e.each(e.keys(this._in[u]),f),delete this._in[u],delete this._preds[u],e.each(e.keys(this._out[u]),f),delete this._out[u],delete this._sucs[u],--this._nodeCount}return this},i.prototype.setParent=function(u,d){if(!this._isCompound)throw new Error("Cannot set parent in a non-compound graph");if(e.isUndefined(d))d=n;else{d+="";for(var f=d;!e.isUndefined(f);f=this.parent(f))if(f===u)throw new Error("Setting "+d+" as parent of "+u+" would create a cycle");this.setNode(d)}return this.setNode(u),this._removeFromParentsChildList(u),this._parent[u]=d,this._children[d][u]=!0,this},i.prototype._removeFromParentsChildList=function(u){delete this._children[this._parent[u]][u]},i.prototype.parent=function(u){if(this._isCompound){var d=this._parent[u];if(d!==n)return d}},i.prototype.children=function(u){if(e.isUndefined(u)&&(u=n),this._isCompound){var d=this._children[u];if(d)return e.keys(d)}else{if(u===n)return this.nodes();if(this.hasNode(u))return[]}},i.prototype.predecessors=function(u){var d=this._preds[u];if(d)return e.keys(d)},i.prototype.successors=function(u){var d=this._sucs[u];if(d)return e.keys(d)},i.prototype.neighbors=function(u){var d=this.predecessors(u);if(d)return e.union(d,this.successors(u))},i.prototype.isLeaf=function(u){var d;return this.isDirected()?d=this.successors(u):d=this.neighbors(u),d.length===0},i.prototype.filterNodes=function(u){var d=new this.constructor({directed:this._isDirected,multigraph:this._isMultigraph,compound:this._isCompound});d.setGraph(this.graph());var f=this;e.each(this._nodes,function(g,m){u(m)&&d.setNode(m,g)}),e.each(this._edgeObjs,function(g){d.hasNode(g.v)&&d.hasNode(g.w)&&d.setEdge(g,f.edge(g))});var h={};function p(g){var m=f.parent(g);return m===void 0||d.hasNode(m)?(h[g]=m,m):m in h?h[m]:p(m)}return this._isCompound&&e.each(d.nodes(),function(g){d.setParent(g,p(g))}),d},i.prototype.setDefaultEdgeLabel=function(u){return e.isFunction(u)||(u=e.constant(u)),this._defaultEdgeLabelFn=u,this},i.prototype.edgeCount=function(){return this._edgeCount},i.prototype.edges=function(){return e.values(this._edgeObjs)},i.prototype.setPath=function(u,d){var f=this,h=arguments;return e.reduce(u,function(p,g){return h.length>1?f.setEdge(p,g,d):f.setEdge(p,g),g}),this},i.prototype.setEdge=function(){var u,d,f,h,p=!1,g=arguments[0];typeof g=="object"&&g!==null&&"v"in g?(u=g.v,d=g.w,f=g.name,arguments.length===2&&(h=arguments[1],p=!0)):(u=g,d=arguments[1],f=arguments[3],arguments.length>2&&(h=arguments[2],p=!0)),u=""+u,d=""+d,e.isUndefined(f)||(f=""+f);var m=s(this._isDirected,u,d,f);if(e.has(this._edgeLabels,m))return p&&(this._edgeLabels[m]=h),this;if(!e.isUndefined(f)&&!this._isMultigraph)throw new Error("Cannot set a named edge when isMultigraph = false");this.setNode(u),this.setNode(d),this._edgeLabels[m]=p?h:this._defaultEdgeLabelFn(u,d,f);var v=c(this._isDirected,u,d,f);return u=v.v,d=v.w,Object.freeze(v),this._edgeObjs[m]=v,o(this._preds[d],u),o(this._sucs[u],d),this._in[d][m]=v,this._out[u][m]=v,this._edgeCount++,this},i.prototype.edge=function(u,d,f){var h=arguments.length===1?l(this._isDirected,arguments[0]):s(this._isDirected,u,d,f);return this._edgeLabels[h]},i.prototype.hasEdge=function(u,d,f){var h=arguments.length===1?l(this._isDirected,arguments[0]):s(this._isDirected,u,d,f);return e.has(this._edgeLabels,h)},i.prototype.removeEdge=function(u,d,f){var h=arguments.length===1?l(this._isDirected,arguments[0]):s(this._isDirected,u,d,f),p=this._edgeObjs[h];return p&&(u=p.v,d=p.w,delete this._edgeLabels[h],delete this._edgeObjs[h],a(this._preds[d],u),a(this._sucs[u],d),delete this._in[d][h],delete this._out[u][h],this._edgeCount--),this},i.prototype.inEdges=function(u,d){var f=this._in[u];if(f){var h=e.values(f);return d?e.filter(h,function(p){return p.v===d}):h}},i.prototype.outEdges=function(u,d){var f=this._out[u];if(f){var h=e.values(f);return d?e.filter(h,function(p){return p.w===d}):h}},i.prototype.nodeEdges=function(u,d){var f=this.inEdges(u,d);if(f)return f.concat(this.outEdges(u,d))};function o(u,d){u[d]?u[d]++:u[d]=1}function a(u,d){--u[d]||delete u[d]}function s(u,d,f,h){var p=""+d,g=""+f;if(!u&&p>g){var m=p;p=g,g=m}return p+r+g+r+(e.isUndefined(h)?t:h)}function c(u,d,f,h){var p=""+d,g=""+f;if(!u&&p>g){var m=p;p=g,g=m}var v={v:p,w:g};return h&&(v.name=h),v}function l(u,d){return s(u,d.v,d.w,d.name)}return aa}var sa,Td;function xE(){return Td||(Td=1,sa="2.1.8"),sa}var ca,qd;function EE(){return qd||(qd=1,ca={Graph:xc(),version:xE()}),ca}var ua,Rd;function SE(){if(Rd)return ua;Rd=1;var e=He(),t=xc();ua={write:n,read:o};function n(a){var s={options:{directed:a.isDirected(),multigraph:a.isMultigraph(),compound:a.isCompound()},nodes:r(a),edges:i(a)};return e.isUndefined(a.graph())||(s.value=e.clone(a.graph())),s}function r(a){return e.map(a.nodes(),function(s){var c=a.node(s),l=a.parent(s),u={v:s};return e.isUndefined(c)||(u.value=c),e.isUndefined(l)||(u.parent=l),u})}function i(a){return e.map(a.edges(),function(s){var c=a.edge(s),l={v:s.v,w:s.w};return e.isUndefined(s.name)||(l.name=s.name),e.isUndefined(c)||(l.value=c),l})}function o(a){var s=new t(a.options).setGraph(a.value);return e.each(a.nodes,function(c){s.setNode(c.v,c.value),c.parent&&s.setParent(c.v,c.parent)}),e.each(a.edges,function(c){s.setEdge({v:c.v,w:c.w,name:c.name},c.value)}),s}return ua}var la,kd;function NE(){if(kd)return la;kd=1;var e=He();la=t;function t(n){var r={},i=[],o;function a(s){e.has(r,s)||(r[s]=!0,o.push(s),e.each(n.successors(s),a),e.each(n.predecessors(s),a))}return e.each(n.nodes(),function(s){o=[],a(s),o.length&&i.push(o)}),i}return la}var da,Ld;function Cg(){if(Ld)return da;Ld=1;var e=He();da=t;function t(){this._arr=[],this._keyIndices={}}return t.prototype.size=function(){return this._arr.length},t.prototype.keys=function(){return this._arr.map(function(n){return n.key})},t.prototype.has=function(n){return e.has(this._keyIndices,n)},t.prototype.priority=function(n){var r=this._keyIndices[n];if(r!==void 0)return this._arr[r].priority},t.prototype.min=function(){if(this.size()===0)throw new Error("Queue underflow");return this._arr[0].key},t.prototype.add=function(n,r){var i=this._keyIndices;if(n=String(n),!e.has(i,n)){var o=this._arr,a=o.length;return i[n]=a,o.push({key:n,priority:r}),this._decrease(a),!0}return!1},t.prototype.removeMin=function(){this._swap(0,this._arr.length-1);var n=this._arr.pop();return delete this._keyIndices[n.key],this._heapify(0),n.key},t.prototype.decrease=function(n,r){var i=this._keyIndices[n];if(r>this._arr[i].priority)throw new Error("New priority is greater than current priority. Key: "+n+" Old: "+this._arr[i].priority+" New: "+r);this._arr[i].priority=r,this._decrease(i)},t.prototype._heapify=function(n){var r=this._arr,i=2*n,o=i+1,a=n;i>1,!(r[o].priority0&&(d=u.removeMin(),f=l[d],f.distance!==Number.POSITIVE_INFINITY);)c(d).forEach(h);return l}return fa}var ha,$d;function CE(){if($d)return ha;$d=1;var e=Ig(),t=He();ha=n;function n(r,i,o){return t.transform(r.nodes(),function(a,s){a[s]=e(r,s,i,o)},{})}return ha}var pa,Dd;function Ag(){if(Dd)return pa;Dd=1;var e=He();pa=t;function t(n){var r=0,i=[],o={},a=[];function s(c){var l=o[c]={onStack:!0,lowlink:r,index:r++};if(i.push(c),n.successors(c).forEach(function(f){e.has(o,f)?o[f].onStack&&(l.lowlink=Math.min(l.lowlink,o[f].index)):(s(f),l.lowlink=Math.min(l.lowlink,o[f].lowlink))}),l.lowlink===l.index){var u=[],d;do d=i.pop(),o[d].onStack=!1,u.push(d);while(c!==d);a.push(u)}}return n.nodes().forEach(function(c){e.has(o,c)||s(c)}),a}return pa}var ga,Fd;function IE(){if(Fd)return ga;Fd=1;var e=He(),t=Ag();ga=n;function n(r){return e.filter(t(r),function(i){return i.length>1||i.length===1&&r.hasEdge(i[0],i[0])})}return ga}var ma,Od;function AE(){if(Od)return ma;Od=1;var e=He();ma=n;var t=e.constant(1);function n(i,o,a){return r(i,o||t,a||function(s){return i.outEdges(s)})}function r(i,o,a){var s={},c=i.nodes();return c.forEach(function(l){s[l]={},s[l][l]={distance:0},c.forEach(function(u){l!==u&&(s[l][u]={distance:Number.POSITIVE_INFINITY})}),a(l).forEach(function(u){var d=u.v===l?u.w:u.v,f=o(u);s[l][d]={distance:f,predecessor:l}})}),c.forEach(function(l){var u=s[l];c.forEach(function(d){var f=s[d];c.forEach(function(h){var p=f[l],g=u[h],m=f[h],v=p.distance+g.distance;v0;){if(l=c.removeMin(),e.has(s,l))a.setEdge(l,s[l]);else{if(d)throw new Error("Input graph is not connected: "+i);d=!0}i.nodeEdges(l).forEach(u)}return a}return xa}var Ea,Yd;function kE(){return Yd||(Yd=1,Ea={components:NE(),dijkstra:Ig(),dijkstraAll:CE(),findCycles:IE(),floydWarshall:AE(),isAcyclic:ME(),postorder:TE(),preorder:qE(),prim:RE(),tarjan:Ag(),topsort:Mg()}),Ea}var Sa,Kd;function LE(){if(Kd)return Sa;Kd=1;var e=EE();return Sa={Graph:e.Graph,json:SE(),alg:kE(),version:e.version},Sa}var pr;if(typeof Os=="function")try{pr=LE()}catch{}pr||(pr=window.graphlib);var We=pr,Na,Wd;function PE(){if(Wd)return Na;Wd=1;var e=ig(),t=1,n=4;function r(i){return e(i,t|n)}return Na=r,Na}var Ca,Zd;function $E(){if(Zd)return Ca;Zd=1;var e=Ys(),t=fh(),n=Ks(),r=qn(),i=Object.prototype,o=i.hasOwnProperty,a=e(function(s,c){s=Object(s);var l=-1,u=c.length,d=u>2?c[2]:void 0;for(d&&n(c[0],c[1],d)&&(u=1);++l-1?c[l?o[u]:u]:void 0}}return Ia=r,Ia}var Aa,jd;function FE(){if(jd)return Aa;jd=1;var e=/\s/;function t(n){for(var r=n.length;r--&&e.test(n.charAt(r)););return r}return Aa=t,Aa}var Ma,Qd;function OE(){if(Qd)return Ma;Qd=1;var e=FE(),t=/^\s+/;function n(r){return r&&r.slice(0,e(r)+1).replace(t,"")}return Ma=n,Ma}var Ta,Jd;function zE(){if(Jd)return Ta;Jd=1;var e=OE(),t=Ln,n=an(),r=NaN,i=/^[-+]0x[0-9a-f]+$/i,o=/^0b[01]+$/i,a=/^0o[0-7]+$/i,s=parseInt;function c(l){if(typeof l=="number")return l;if(n(l))return r;if(t(l)){var u=typeof l.valueOf=="function"?l.valueOf():l;l=t(u)?u+"":u}if(typeof l!="string")return l===0?l:+l;l=e(l);var d=o.test(l);return d||a.test(l)?s(l.slice(2),d?2:8):i.test(l)?r:+l}return Ta=c,Ta}var qa,ef;function qg(){if(ef)return qa;ef=1;var e=zE(),t=1/0,n=17976931348623157e292;function r(i){if(!i)return i===0?i:0;if(i=e(i),i===t||i===-t){var o=i<0?-1:1;return o*n}return i===i?i:0}return qa=r,qa}var Ra,tf;function HE(){if(tf)return Ra;tf=1;var e=qg();function t(n){var r=e(n),i=r%1;return r===r?i?r-i:r:0}return Ra=t,Ra}var ka,nf;function BE(){if(nf)return ka;nf=1;var e=Sg(),t=ht(),n=HE(),r=Math.max;function i(o,a,s){var c=o==null?0:o.length;if(!c)return-1;var l=s==null?0:n(s);return l<0&&(l=r(c+l,0)),e(o,t(a,3),l)}return ka=i,ka}var La,rf;function VE(){if(rf)return La;rf=1;var e=DE(),t=BE(),n=e(t);return La=n,La}var Pa,of;function Rg(){if(of)return Pa;of=1;var e=_c();function t(n){var r=n==null?0:n.length;return r?e(n,1):[]}return Pa=t,Pa}var $a,af;function GE(){if(af)return $a;af=1;var e=lh(),t=og(),n=qn();function r(i,o){return i==null?i:e(i,t(o),n)}return $a=r,$a}var Da,sf;function UE(){if(sf)return Da;sf=1;function e(t){var n=t==null?0:t.length;return n?t[n-1]:void 0}return Da=e,Da}var Fa,cf;function YE(){if(cf)return Fa;cf=1;var e=Av(),t=yc(),n=ht();function r(i,o){var a={};return o=n(o,3),t(i,function(s,c,l){e(a,c,o(s,c,l))}),a}return Fa=r,Fa}var Oa,uf;function Ec(){if(uf)return Oa;uf=1;var e=an();function t(n,r,i){for(var o=-1,a=n.length;++on}return za=e,za}var Ha,df;function WE(){if(df)return Ha;df=1;var e=Ec(),t=KE(),n=Pn();function r(i){return i&&i.length?e(i,n,t):void 0}return Ha=r,Ha}var Ba,ff;function ZE(){if(ff)return Ba;ff=1;var e=Tv,t=Mv,n=t(function(r,i,o){e(r,i,o)});return Ba=n,Ba}var Va,hf;function kg(){if(hf)return Va;hf=1;function e(t,n){return tr||s&&c&&u&&!l&&!d||o&&c&&u||!i&&u||!a)return 1;if(!o&&!s&&!d&&n=l)return u;var d=i[o];return u*(d=="desc"?-1:1)}}return n.index-r.index}return rs=t,rs}var is,Af;function lS(){if(Af)return is;Af=1;var e=$r(),t=Fr(),n=ht(),r=_g(),i=sS(),o=Hs(),a=uS(),s=Pn(),c=Ee();function l(u,d,f){d.length?d=e(d,function(g){return c(g)?function(m){return t(m,g.length===1?g[0]:g)}:g}):d=[s];var h=-1;d=e(d,o(n));var p=r(u,function(g,m,v){var b=e(d,function(_){return _(g)});return{criteria:b,index:++h,value:g}});return i(p,function(g,m){return a(g,m,f)})}return is=l,is}var os,Mf;function dS(){if(Mf)return os;Mf=1;var e=_c(),t=lS(),n=Ys(),r=Ks(),i=n(function(o,a){if(o==null)return[];var s=a.length;return s>1&&r(o,a[0],a[1])?a=[]:s>2&&r(a[0],a[1],a[2])&&(a=[a[0]]),t(o,e(a,1),[])});return os=i,os}var as,Tf;function fS(){if(Tf)return as;Tf=1;var e=pg(),t=0;function n(r){var i=++t;return e(r)+i}return as=n,as}var ss,qf;function hS(){if(qf)return ss;qf=1;function e(t,n,r){for(var i=-1,o=t.length,a=n.length,s={};++i0;--s)if(a=t[s].dequeue(),a){r=r.concat(us(e,t,n,a,!0));break}}}return r}function us(e,t,n,r,i){var o=i?[]:void 0;return at.forEach(e.inEdges(r.v),function(a){var s=e.edge(a),c=e.node(a.v);i&&o.push({v:a.v,w:a.w}),c.out-=s,ks(t,n,c)}),at.forEach(e.outEdges(r.v),function(a){var s=e.edge(a),c=a.w,l=e.node(c);l.in-=s,ks(t,n,l)}),e.removeNode(r.v),o}function ES(e,t){var n=new vS,r=0,i=0;at.forEach(e.nodes(),function(s){n.setNode(s,{v:s,in:0,out:0})}),at.forEach(e.edges(),function(s){var c=n.edge(s.v,s.w)||0,l=t(s),u=c+l;n.setEdge(s.v,s.w,u),i=Math.max(i,n.node(s.v).out+=l),r=Math.max(r,n.node(s.w).in+=l)});var o=at.range(i+r+3).map(function(){return new yS}),a=r+1;return at.forEach(n.nodes(),function(s){ks(o,a,n.node(s))}),{graph:n,buckets:o,zeroIdx:a}}function ks(e,t,n){n.out?n.in?e[n.out-n.in+t].enqueue(n):e[e.length-1].enqueue(n):e[0].enqueue(n)}var Lt=fe,SS=wS,NS={run:CS,undo:AS};function CS(e){var t=e.graph().acyclicer==="greedy"?SS(e,n(e)):IS(e);Lt.forEach(t,function(r){var i=e.edge(r);e.removeEdge(r),i.forwardName=r.name,i.reversed=!0,e.setEdge(r.w,r.v,i,Lt.uniqueId("rev"))});function n(r){return function(i){return r.edge(i).weight}}}function IS(e){var t=[],n={},r={};function i(o){Lt.has(r,o)||(r[o]=!0,n[o]=!0,Lt.forEach(e.outEdges(o),function(a){Lt.has(n,a.w)?t.push(a):i(a.w)}),delete n[o])}return Lt.forEach(e.nodes(),i),t}function AS(e){Lt.forEach(e.edges(),function(t){var n=e.edge(t);if(n.reversed){e.removeEdge(t);var r=n.forwardName;delete n.reversed,delete n.forwardName,e.setEdge(t.w,t.v,n,r)}})}var se=fe,Pg=We.Graph,Re={addDummyNode:$g,simplify:MS,asNonCompoundGraph:TS,successorWeights:qS,predecessorWeights:RS,intersectRect:kS,buildLayerMatrix:LS,normalizeRanks:PS,removeEmptyRanks:$S,addBorderNode:DS,maxRank:Dg,partition:FS,time:OS,notime:zS};function $g(e,t,n,r){var i;do i=se.uniqueId(r);while(e.hasNode(i));return n.dummy=t,e.setNode(i,n),i}function MS(e){var t=new Pg().setGraph(e.graph());return se.forEach(e.nodes(),function(n){t.setNode(n,e.node(n))}),se.forEach(e.edges(),function(n){var r=t.edge(n.v,n.w)||{weight:0,minlen:1},i=e.edge(n);t.setEdge(n.v,n.w,{weight:r.weight+i.weight,minlen:Math.max(r.minlen,i.minlen)})}),t}function TS(e){var t=new Pg({multigraph:e.isMultigraph()}).setGraph(e.graph());return se.forEach(e.nodes(),function(n){e.children(n).length||t.setNode(n,e.node(n))}),se.forEach(e.edges(),function(n){t.setEdge(n,e.edge(n))}),t}function qS(e){var t=se.map(e.nodes(),function(n){var r={};return se.forEach(e.outEdges(n),function(i){r[i.w]=(r[i.w]||0)+e.edge(i).weight}),r});return se.zipObject(e.nodes(),t)}function RS(e){var t=se.map(e.nodes(),function(n){var r={};return se.forEach(e.inEdges(n),function(i){r[i.v]=(r[i.v]||0)+e.edge(i).weight}),r});return se.zipObject(e.nodes(),t)}function kS(e,t){var n=e.x,r=e.y,i=t.x-n,o=t.y-r,a=e.width/2,s=e.height/2;if(!i&&!o)throw new Error("Not possible to find intersection inside of the rectangle");var c,l;return Math.abs(o)*a>Math.abs(i)*s?(o<0&&(s=-s),c=s*i/o,l=s):(i<0&&(a=-a),c=a,l=a*o/i),{x:n+c,y:r+l}}function LS(e){var t=se.map(se.range(Dg(e)+1),function(){return[]});return se.forEach(e.nodes(),function(n){var r=e.node(n),i=r.rank;se.isUndefined(i)||(t[i][r.order]=n)}),t}function PS(e){var t=se.min(se.map(e.nodes(),function(n){return e.node(n).rank}));se.forEach(e.nodes(),function(n){var r=e.node(n);se.has(r,"rank")&&(r.rank-=t)})}function $S(e){var t=se.min(se.map(e.nodes(),function(o){return e.node(o).rank})),n=[];se.forEach(e.nodes(),function(o){var a=e.node(o).rank-t;n[a]||(n[a]=[]),n[a].push(o)});var r=0,i=e.graph().nodeRankFactor;se.forEach(n,function(o,a){se.isUndefined(o)&&a%i!==0?--r:r&&se.forEach(o,function(s){e.node(s).rank+=r})})}function DS(e,t,n,r){var i={width:0,height:0};return arguments.length>=4&&(i.rank=n,i.order=r),$g(e,"border",i,t)}function Dg(e){return se.max(se.map(e.nodes(),function(t){var n=e.node(t).rank;if(!se.isUndefined(n))return n}))}function FS(e,t){var n={lhs:[],rhs:[]};return se.forEach(e,function(r){t(r)?n.lhs.push(r):n.rhs.push(r)}),n}function OS(e,t){var n=se.now();try{return t()}finally{console.log(e+" time: "+(se.now()-n)+"ms")}}function zS(e,t){return t()}var Fg=fe,HS=Re,BS={run:VS,undo:US};function VS(e){e.graph().dummyChains=[],Fg.forEach(e.edges(),function(t){GS(e,t)})}function GS(e,t){var n=t.v,r=e.node(n).rank,i=t.w,o=e.node(i).rank,a=t.name,s=e.edge(t),c=s.labelRank;if(o!==r+1){e.removeEdge(t);var l,u,d;for(d=0,++r;ra.lim&&(s=a,c=!0);var l=ft.filter(t.edges(),function(u){return c===kf(e,e.node(u.v),s)&&c!==kf(e,e.node(u.w),s)});return ft.minBy(l,function(u){return e2(t,u)})}function Gg(e,t,n,r){var i=n.v,o=n.w;e.removeEdge(i,o),e.setEdge(r.v,r.w,{}),Nc(e),Sc(e,t),s2(e,t)}function s2(e,t){var n=ft.find(e.nodes(),function(i){return!t.node(i).parent}),r=n2(e,n);r=r.slice(1),ft.forEach(r,function(i){var o=e.node(i).parent,a=t.edge(i,o),s=!1;a||(a=t.edge(o,i),s=!0),t.node(i).rank=t.node(o).rank+(s?a.minlen:-a.minlen)})}function c2(e,t,n){return e.hasEdge(t,n)}function kf(e,t,n){return n.low<=t.lim&&t.lim<=n.lim}var u2=zr,Ug=u2.longestPath,l2=Og,d2=o2,f2=h2;function h2(e){switch(e.graph().ranker){case"network-simplex":Lf(e);break;case"tight-tree":g2(e);break;case"longest-path":p2(e);break;default:Lf(e)}}var p2=Ug;function g2(e){Ug(e),l2(e)}function Lf(e){d2(e)}var Ls=fe,m2=v2;function v2(e){var t=w2(e);Ls.forEach(e.graph().dummyChains,function(n){for(var r=e.node(n),i=r.edgeObj,o=y2(e,t,i.v,i.w),a=o.path,s=o.lca,c=0,l=a[c],u=!0;n!==i.w;){if(r=e.node(n),u){for(;(l=a[c])!==s&&e.node(l).maxRanka||s>t[c].lim));for(l=c,c=r;(c=e.parent(c))!==l;)o.push(c);return{path:i.concat(o.reverse()),lca:l}}function w2(e){var t={},n=0;function r(i){var o=n;Ls.forEach(e.children(i),r),t[i]={low:o,lim:n++}}return Ls.forEach(e.children(),r),t}var st=fe,Ps=Re,b2={run:_2,cleanup:S2};function _2(e){var t=Ps.addDummyNode(e,"root",{},"_root"),n=x2(e),r=st.max(st.values(n))-1,i=2*r+1;e.graph().nestingRoot=t,st.forEach(e.edges(),function(a){e.edge(a).minlen*=i});var o=E2(e)+1;st.forEach(e.children(),function(a){Yg(e,t,i,o,r,n,a)}),e.graph().nodeRankFactor=i}function Yg(e,t,n,r,i,o,a){var s=e.children(a);if(!s.length){a!==t&&e.setEdge(t,a,{weight:0,minlen:n});return}var c=Ps.addBorderNode(e,"_bt"),l=Ps.addBorderNode(e,"_bb"),u=e.node(a);e.setParent(c,a),u.borderTop=c,e.setParent(l,a),u.borderBottom=l,st.forEach(s,function(d){Yg(e,t,n,r,i,o,d);var f=e.node(d),h=f.borderTop?f.borderTop:d,p=f.borderBottom?f.borderBottom:d,g=f.borderTop?r:2*r,m=h!==p?1:i-o[a]+1;e.setEdge(c,h,{weight:g,minlen:m,nestingEdge:!0}),e.setEdge(p,l,{weight:g,minlen:m,nestingEdge:!0})}),e.parent(a)||e.setEdge(t,c,{weight:0,minlen:i+o[a]})}function x2(e){var t={};function n(r,i){var o=e.children(r);o&&o.length&&st.forEach(o,function(a){n(a,i+1)}),t[r]=i}return st.forEach(e.children(),function(r){n(r,1)}),t}function E2(e){return st.reduce(e.edges(),function(t,n){return t+e.edge(n).weight},0)}function S2(e){var t=e.graph();e.removeNode(t.nestingRoot),delete t.nestingRoot,st.forEach(e.edges(),function(n){var r=e.edge(n);r.nestingEdge&&e.removeEdge(n)})}var ls=fe,N2=Re,C2=I2;function I2(e){function t(n){var r=e.children(n),i=e.node(n);if(r.length&&ls.forEach(r,t),ls.has(i,"minRank")){i.borderLeft=[],i.borderRight=[];for(var o=i.minRank,a=i.maxRank+1;o0;)u%2&&(d+=s[u+1]),u=u-1>>1,s[u]+=l.weight;c+=l.weight*d})),c}var Df=fe,F2=O2;function O2(e,t){return Df.map(t,function(n){var r=e.inEdges(n);if(r.length){var i=Df.reduce(r,function(o,a){var s=e.edge(a),c=e.node(a.v);return{sum:o.sum+s.weight*c.order,weight:o.weight+s.weight}},{sum:0,weight:0});return{v:n,barycenter:i.sum/i.weight,weight:i.weight}}else return{v:n}})}var Pe=fe,z2=H2;function H2(e,t){var n={};Pe.forEach(e,function(i,o){var a=n[i.v]={indegree:0,in:[],out:[],vs:[i.v],i:o};Pe.isUndefined(i.barycenter)||(a.barycenter=i.barycenter,a.weight=i.weight)}),Pe.forEach(t.edges(),function(i){var o=n[i.v],a=n[i.w];!Pe.isUndefined(o)&&!Pe.isUndefined(a)&&(a.indegree++,o.out.push(n[i.w]))});var r=Pe.filter(n,function(i){return!i.indegree});return B2(r)}function B2(e){var t=[];function n(o){return function(a){a.merged||(Pe.isUndefined(a.barycenter)||Pe.isUndefined(o.barycenter)||a.barycenter>=o.barycenter)&&V2(o,a)}}function r(o){return function(a){a.in.push(o),--a.indegree===0&&e.push(a)}}for(;e.length;){var i=e.pop();t.push(i),Pe.forEach(i.in.reverse(),n(i)),Pe.forEach(i.out,r(i))}return Pe.map(Pe.filter(t,function(o){return!o.merged}),function(o){return Pe.pick(o,["vs","i","barycenter","weight"])})}function V2(e,t){var n=0,r=0;e.weight&&(n+=e.barycenter*e.weight,r+=e.weight),t.weight&&(n+=t.barycenter*t.weight,r+=t.weight),e.vs=t.vs.concat(e.vs),e.barycenter=n/r,e.weight=r,e.i=Math.min(t.i,e.i),t.merged=!0}var mn=fe,G2=Re,U2=Y2;function Y2(e,t){var n=G2.partition(e,function(u){return mn.has(u,"barycenter")}),r=n.lhs,i=mn.sortBy(n.rhs,function(u){return-u.i}),o=[],a=0,s=0,c=0;r.sort(K2(!!t)),c=Ff(o,i,c),mn.forEach(r,function(u){c+=u.vs.length,o.push(u.vs),a+=u.barycenter*u.weight,s+=u.weight,c=Ff(o,i,c)});var l={vs:mn.flatten(o,!0)};return s&&(l.barycenter=a/s,l.weight=s),l}function Ff(e,t,n){for(var r;t.length&&(r=mn.last(t)).i<=n;)t.pop(),e.push(r.vs),n++;return n}function K2(e){return function(t,n){return t.barycentern.barycenter?1:e?n.i-t.i:t.i-n.i}}var _t=fe,W2=F2,Z2=z2,X2=U2,j2=Wg;function Wg(e,t,n,r){var i=e.children(t),o=e.node(t),a=o?o.borderLeft:void 0,s=o?o.borderRight:void 0,c={};a&&(i=_t.filter(i,function(p){return p!==a&&p!==s}));var l=W2(e,i);_t.forEach(l,function(p){if(e.children(p.v).length){var g=Wg(e,p.v,n,r);c[p.v]=g,_t.has(g,"barycenter")&&J2(p,g)}});var u=Z2(l,n);Q2(u,c);var d=X2(u,r);if(a&&(d.vs=_t.flatten([a,d.vs,s],!0),e.predecessors(a).length)){var f=e.node(e.predecessors(a)[0]),h=e.node(e.predecessors(s)[0]);_t.has(d,"barycenter")||(d.barycenter=0,d.weight=0),d.barycenter=(d.barycenter*d.weight+f.order+h.order)/(d.weight+2),d.weight+=2}return d}function Q2(e,t){_t.forEach(e,function(n){n.vs=_t.flatten(n.vs.map(function(r){return t[r]?t[r].vs:r}),!0)})}function J2(e,t){_t.isUndefined(e.barycenter)?(e.barycenter=t.barycenter,e.weight=t.weight):(e.barycenter=(e.barycenter*e.weight+t.barycenter*t.weight)/(e.weight+t.weight),e.weight+=t.weight)}var vn=fe,eN=We.Graph,tN=nN;function nN(e,t,n){var r=rN(e),i=new eN({compound:!0}).setGraph({root:r}).setDefaultNodeLabel(function(o){return e.node(o)});return vn.forEach(e.nodes(),function(o){var a=e.node(o),s=e.parent(o);(a.rank===t||a.minRank<=t&&t<=a.maxRank)&&(i.setNode(o),i.setParent(o,s||r),vn.forEach(e[n](o),function(c){var l=c.v===o?c.w:c.v,u=i.edge(l,o),d=vn.isUndefined(u)?0:u.weight;i.setEdge(l,o,{weight:e.edge(c).weight+d})}),vn.has(a,"minRank")&&i.setNode(o,{borderLeft:a.borderLeft[t],borderRight:a.borderRight[t]}))}),i}function rN(e){for(var t;e.hasNode(t=vn.uniqueId("_root")););return t}var iN=fe,oN=aN;function aN(e,t,n){var r={},i;iN.forEach(n,function(o){for(var a=e.parent(o),s,c;a;){if(s=e.parent(a),s?(c=r[s],r[s]=a):(c=i,i=a),c&&c!==a){t.setEdge(c,a);return}a=s}})}var St=fe,sN=k2,cN=P2,uN=j2,lN=tN,dN=oN,fN=We.Graph,Of=Re,hN=pN;function pN(e){var t=Of.maxRank(e),n=zf(e,St.range(1,t+1),"inEdges"),r=zf(e,St.range(t-1,-1,-1),"outEdges"),i=sN(e);Hf(e,i);for(var o=Number.POSITIVE_INFINITY,a,s=0,c=0;c<4;++s,++c){gN(s%2?n:r,s%4>=2),i=Of.buildLayerMatrix(e);var l=cN(e,i);ll)&&Cc(n,f,u)})})}function i(o,a){var s=-1,c,l=0;return Q.forEach(a,function(u,d){if(e.node(u).dummy==="border"){var f=e.predecessors(u);f.length&&(c=e.node(f[0]).order,r(a,l,d,s,c),l=d,s=c)}r(a,l,a.length,c,o.length)}),a}return Q.reduce(t,i),n}function wN(e,t){if(e.node(t).dummy)return Q.find(e.predecessors(t),function(n){return e.node(n).dummy})}function Cc(e,t,n){if(t>n){var r=t;t=n,n=r}var i=e[t];i||(e[t]=i={}),i[n]=!0}function jg(e,t,n){if(t>n){var r=t;t=n,n=r}return Q.has(e[t],n)}function Qg(e,t,n,r){var i={},o={},a={};return Q.forEach(t,function(s){Q.forEach(s,function(c,l){i[c]=c,o[c]=c,a[c]=l})}),Q.forEach(t,function(s){var c=-1;Q.forEach(s,function(l){var u=r(l);if(u.length){u=Q.sortBy(u,function(g){return a[g]});for(var d=(u.length-1)/2,f=Math.floor(d),h=Math.ceil(d);f<=h;++f){var p=u[f];o[l]===l&&c({}));const Yf=130,Kf=40,fC=130,hC=(e,t="LR")=>{const n=t==="LR";return xt.setGraph({rankdir:t}),e.forEach((r,i)=>{const o=i>0?e[i-1]:void 0;xt.setNode(r.id,{width:Yf,height:o?.type==="conditional"?fC:Kf})}),Ic.layout(xt),e.map(r=>{const i=xt.node(r.id);return r.targetPosition=n?G.Left:G.Top,r.sourcePosition=n?G.Right:G.Bottom,r.position={x:i.x-Yf/2,y:i.y-Kf/2},r})},pC=(e,t="LR")=>(xt.setGraph({rankdir:t}),e.forEach(n=>{xt.setEdge(n.source,n.target)}),Ic.layout(xt),e),jn=33,gC=({id:e,sourceX:t,sourceY:n,targetX:r,targetY:i,sourcePosition:o,targetPosition:a,label:s,style:c={},markerType:l,markerEndId:u,selected:d,data:{onEdgeClick:f}})=>{const[h,p,g]=cc({sourceX:t,sourceY:n,sourcePosition:o,targetX:r,targetY:i,targetPosition:a}),m=u_(l,u);return re(Ce,{children:[S("path",{id:e,style:c,className:"react-flow__edge-path",d:h,markerEnd:m}),!d&&S("text",{children:S("textPath",{href:`#${e}`,style:{fontSize:"11px"},startOffset:"50%",textAnchor:"middle",children:s})}),d&&S("foreignObject",{width:jn,height:jn,x:p-jn/2,y:g-jn/2,className:"edgebutton-foreignobject",requiredExtensions:"http://www.w3.org/1999/xhtml",children:S("button",{className:"edgebutton",onClick:v=>f(v,e),children:S(nh,{})})})]})},mC=({data:e,selected:t})=>re(Ce,{children:[S(Nt,{position:G.Right,type:"source"}),S("div",{className:`react-flow__node-default keycloak__authentication__conditional_node ${t?"selected":""}`,children:S("div",{children:e.label})}),S(Nt,{position:G.Left,type:"target"})]}),vC=ue(mC),yC=({data:{label:e},prefix:t,selected:n})=>re(Ce,{children:[S(Nt,{position:G.Right,type:"source"}),S("div",{className:`react-flow__node-default keycloak__authentication__subflow_node ${n?"selected":""}`,children:re("div",{children:[t," ",e]})}),S(Nt,{position:G.Left,type:"target"})]}),im=ue(yC),wC=({...e})=>S(im,{...e,prefix:"Start"}),bC=({...e})=>S(im,{...e,prefix:"End"}),_C={conditional:vC,startSubFlow:wC,endSubFlow:bC},xC=new Map([["input","keycloak__authentication__input_node"],["output","keycloak__authentication__output_node"]]);function EC(e,t){const n=[];for(let r=0;re.requirement==="ALTERNATIVE"||e.requirement==="CONDITIONAL",Hr=(e,t,n)=>({id:`edge-${e}-to-${t}`,type:"buttonEdge",source:e,target:t,label:n,data:{onEdgeClick:(r,i)=>{r.stopPropagation(),alert(`hello ${i}`)}}}),$s=(e,t)=>({id:e.id,type:t,sourcePosition:t==="output"?void 0:G.Right,targetPosition:t==="input"?void 0:G.Left,data:{label:e.displayName},position:{x:0,y:0},className:xC.get(t||"")}),NC=e=>{const t=[];for(let n=0;n({startId:e.id,nodes:[e],edges:[],nextLinkFns:t?[n=>Hr(e.id,n)]:[]}),CC=e=>{if(!e.executionList)throw new Error("Execution list is required for subflow");const t=om(Ac(e.executionList));return t.nextLinkFns.push(...e.executionList.filter(n=>yr(n)).map(n=>r=>Hr(n.id,r,"false"))),t},IC=e=>{const t=NC(e);return t.length>0?t:[e[0]]},AC=e=>e.length===0?[]:IC(e).map(n=>{if(n.executionList)return CC(n);const r=yr(n),i=(()=>{if(r)return"true";if(n.requirement==="ALTERNATIVE")return"success"})();return{startId:n.id,nodes:[$s(n,r?"conditional":void 0)],edges:[],nextLinkFns:[o=>Hr(n.id,o,i)]}}),Ac=e=>{if(e.length===0)return[];const t=AC(e);return[t,...Ac(e.slice(t.length))]},om=e=>{const t=[],n=[];let r=[];for(const i of e)t.push(...i.flatMap(o=>o.nodes)),n.push(...i.flatMap(o=>o.edges),...r.map(o=>o(i[0].startId)),...EC((o,a)=>Hr(o.startId,a.startId,"attempted"),i)),r=i.flatMap(o=>o.nextLinkFns);return{startId:e[0][0].startId,nodes:t,edges:n,nextLinkFns:r}},MC={buttonEdge:gC};function Zf(e){const t=e.filter(o=>o.requirement!=="DISABLED"),n=[[Wf($s({id:"start",displayName:"Start"},"input"))],...Ac(t),[Wf($s({id:"end",displayName:"End"},"output"),!1)]],{nodes:r,edges:i}=om(n);return[hC(r),pC(i)]}const TC=({executionList:{expandableList:e}})=>{const[t,n]=ae(!1),[r,i]=Oe(()=>Zf(e),[]),[o,a,s]=B1(r),[c,l,u]=V1(i);return hx(()=>{const[h,p]=Zf(e);a(h),l(p)},[e]),re(Yp,{nodes:o,edges:c,onNodesChange:s,onEdgesChange:u,onInit:h=>h.fitView({duration:100}),nodeTypes:_C,edgeTypes:MC,onNodeClick:()=>{n(!t)},nodesConnectable:!1,children:[S(J1,{}),S(ax,{}),S(fx,{})]})},qC=()=>{const{t:e}=ze();return S(vh,{"aria-labelledby":"headerName",id:"header",children:re(yh,{children:[S(mh,{className:"keycloak__authentication__header-drag-button","aria-label":e("disabled")}),S(wh,{className:"keycloak__authentication__header",dataListCells:[S(Wt,{id:"headerName",children:e("steps")},"step"),S(Wt,{children:e("requirement")},"requirement"),S(Wt,{},"config")]})]})})},RC=({execution:e,onAddExecution:t,onAddFlow:n})=>{const{adminClient:r}=nn(),{t:i}=ze(),[o,a]=ae(!1),[s,c]=ae(),[l,u]=ae();return Tn(()=>r.authenticationManagement.getFlow({flowId:e.flowId}),({providerId:d})=>u(d),[]),S(xr,{content:i("add"),children:re(Ce,{children:[S(Um,{popperProps:{position:"right"},isOpen:o,toggle:d=>S(rh,{ref:d,variant:"plain",onClick:()=>a(!o),"aria-label":i("add"),"data-testid":`${e.displayName}-edit-dropdown`,children:S(nh,{})}),onSelect:()=>a(!1),children:re(Ym,{children:[S(qt,{onClick:()=>c(l==="form-flow"?"form":"basic"),children:i("addStep")},"addStep"),S(qt,{onClick:()=>c("condition"),children:i("addCondition")},"addCondition"),S(qt,{onClick:()=>c("subFlow"),children:i("addSubFlow")},"addSubFlow")]})}),s&&s!=="subFlow"&&S(Ws,{name:e.displayName,type:s,onSelect:d=>{d&&t(e,d),c(void 0)}}),s==="subFlow"&&S(Zs,{name:e.displayName,onCancel:()=>c(void 0),onConfirm:d=>{n(e,d),c(void 0)}})]})})},kC=({execution:e,onRowChange:t})=>{const{t:n}=ze(),r=br({mode:"onChange",defaultValues:e}),[i,o]=gs();ce(()=>r.reset(e),[e]);const a=s=>{t({...e,...s}),o()};return re(Ce,{children:[S(xr,{content:n("edit"),children:S(_e,{variant:"plain","data-testid":`${e.id}-edit`,"aria-label":n("edit"),onClick:o,children:S(Fv,{})})}),i&&S(In,{title:n("editFlow"),onClose:o,variant:An.small,actions:[S(_e,{"data-testid":"confirm",type:"submit",form:"edit-flow-form",isDisabled:!r.formState.isValid,children:n("edit")},"confirm"),S(_e,{"data-testid":"cancel",variant:ut.link,onClick:o,children:n("cancel")},"cancel")],isOpen:!0,children:S(Mn,{id:"edit-flow-form",onSubmit:r.handleSubmit(a),isHorizontal:!0,children:re(_r,{...r,children:[S(nr,{name:"name",label:n("name"),labelIcon:n("flowNameHelp"),rules:{required:{value:!0,message:n("required")}}}),S(Km,{name:"description",label:n("description"),labelIcon:n("flowDescriptionHelp"),rules:{maxLength:{value:255,message:n("maxLength",{length:255})}}})]})})})]})},LC=({execution:e})=>{const{adminClient:t}=nn(),{t:n}=ze(),{addAlert:r,addError:i}=Fs(),[o,a]=ae(!1),[s,c]=ae(),[l,u]=ae(),d=br(),{setValue:f,handleSubmit:h}=d,p=e.authenticationFlow?[]:[{helpText:n("authenticatorRefConfig.value.help"),label:n("authenticatorRefConfig.value.label"),name:"default.reference.value",readOnly:!1,secret:!1,type:"String"},{helpText:n("authenticatorRefConfig.maxAge.help"),label:n("authenticatorRefConfig.maxAge.label"),name:"default.reference.maxAge",readOnly:!1,secret:!1,type:"String"}],g=v=>{Zm(v||{},f)};Tn(async()=>{let v;const b=e.configurable?await t.authenticationManagement.getConfigDescription({providerId:e.providerId}):{name:e.displayName,properties:[]};return e.authenticationConfig&&(v=await t.authenticationManagement.getConfig({id:e.authenticationConfig})),b.properties=[...p,...b.properties],{configDescription:b,config:v}},({configDescription:v,config:b})=>{u(v),c(b)},[]),ce(()=>{s&&g(s)},[s]);const m=async v=>{const b=Xm(v);try{if(s){const _={id:s.id,alias:s.alias,config:b.config};await t.authenticationManagement.updateConfig(_),c({..._})}else{const _={id:e.id,alias:b.alias,config:b.config},{id:w}=await t.authenticationManagement.createConfig(_);c({..._.config,id:w,alias:_.alias})}r(n("configSaveSuccess"),vt.success),a(!1)}catch(_){i("configSaveError",_)}};return re(Ce,{children:[S(xr,{content:n("settings"),children:S(_e,{variant:"plain","aria-label":n("settings"),onClick:()=>a(!0),children:S(lv,{})})}),l&&S(In,{variant:An.small,isOpen:o,title:n("executionConfig",{name:l.name}),onClose:()=>a(!1),children:re(Mn,{id:"execution-config-form",onSubmit:h(m),children:[re(_r,{...d,children:[S(nr,{name:"alias",label:n("alias"),labelIcon:n("authenticationAliasHelp"),rules:{required:{value:!0,message:n("required")}},isDisabled:!!s}),S(Ov,{stringify:!0,properties:l.properties||[]})]}),re(Wm,{children:[S(_e,{"data-testid":"save",variant:"primary",type:"submit",children:n("save")}),S(_e,{"data-testid":"cancel",variant:ut.link,onClick:()=>{a(!1)},children:n("cancel")}),s&&re(_e,{className:"pf-v5-u-ml-4xl","data-testid":"clear",variant:ut.link,onClick:async()=>{await t.authenticationManagement.delConfig({id:s.id}),c(void 0),a(!1)},children:[n("clear")," ",S(bh,{})]})]})]})})]})},PC=({flow:e,onChange:t})=>{const{t:n}=ze(),[r,i]=ae(!1),o=e.requirementChoices.map((a,s)=>S(jm,{value:a,children:n(`requirements.${a}`)},s));return re(Ce,{children:[e.requirementChoices&&e.requirementChoices.length>1&&S(Qm,{onOpenChange:a=>i(a),onSelect:(a,s)=>{e.requirement=s?.toString(),t(e),i(!1)},selected:e.requirement,isOpen:r,toggle:a=>S(rh,{className:"keycloak__authentication__requirement-dropdown",ref:a,onClick:()=>i(!r),isExpanded:r,children:n(`requirements.${e.requirement}`)}),children:S(Jm,{children:o})}),(!e.requirementChoices||e.requirementChoices.length<=1)&&S(Ce,{children:n(`requirements.${e.requirement}`)})]})},$C=({id:e,title:t,alias:n})=>S(ev,{"data-testid":t,className:"keycloak__authentication__title",isFlat:!0,children:re(tv,{"data-id":e,id:`title-id-${e}`,children:[t," ",S("br",{}),S(ih,{component:oh.small,children:n})]})}),am=({builtIn:e,execution:t,onRowClick:n,onRowChange:r,onAddExecution:i,onAddFlow:o,onDelete:a})=>{const{t:s}=ze(),c=!!t.executionList?.length;return re(Ce,{children:[S(kv,{hasNoWrapper:!0,children:S(vh,{className:"keycloak__authentication__flow-item",id:t.id,isExpanded:!t.isCollapsed,"aria-labelledby":`title-id-${t.id}`,children:re(yh,{className:"keycloak__authentication__flow-row","aria-level":t.level+1,role:"heading","aria-labelledby":t.id,children:[S(Lv,{children:S(mh,{"aria-label":s("dragHelp")})}),c&&S(_h,{onClick:()=>n(t),isExpanded:!t.isCollapsed,id:`toggle1-${t.id}`,"aria-controls":t.executionList[0].id}),S(wh,{dataListCells:[re(Wt,{children:[!t.authenticationFlow&&S($C,{id:t.id,alias:t.alias,title:t.displayName},t.id),t.authenticationFlow&&re(Ce,{children:[t.displayName," ",S("br",{})," ",re(ih,{component:oh.small,children:[t.alias," ",t.description]})]})]},`${t.id}-name`),S(Wt,{children:S(PC,{flow:t,onChange:r})},`${t.id}-requirement`),re(Wt,{children:[S(LC,{execution:t}),t.authenticationFlow&&!e&&re(Ce,{children:[S(RC,{execution:t,onAddExecution:i,onAddFlow:o}),S(kC,{execution:t,onRowChange:r})]}),!e&&S(xr,{content:s("delete"),children:S(_e,{variant:"plain","data-testid":`${t.displayName}-delete`,"aria-label":s("delete"),onClick:()=>a(t),children:S(bh,{})})})]},`${t.id}-config`)]})]})})},`draggable-${t.id}`),!t.isCollapsed&&c&&t.executionList?.map(l=>S(am,{builtIn:e,execution:l,onRowClick:n,onRowChange:r,onAddExecution:i,onAddFlow:o,onDelete:a},l.id))]})};class sm{oldIndex;newIndex;constructor(t,n){this.oldIndex=t,this.newIndex=n}}class Xf extends sm{parent;constructor(t,n,r){super(t,n),this.parent=r}}class Mc{#e;expandableList;constructor(t){this.#e=t;const n={executionList:[],isCollapsed:!1};this.#t(0,-1,n),this.expandableList=n.executionList}#t(t,n,r){for(let i=t;iu===t.id),o=r.findIndex(u=>u.id===t.id),a=r[o],s=r[i],c=this.#n(a.level,o),l=this.#n(s.level,i);return c?.id!==l?.id?s.level>0?new Xf(l?.executionList?.length||0,s.index,l):new Xf(this.expandableList.length,s.index):new sm(a.index,s.index)}clone(){const t=new Mc([]);return t.#e=this.#e,t.expandableList=this.expandableList,t}}const yr=e=>e.displayName?.startsWith("Condition ");function CI(){const{adminClient:e}=nn(),{t}=ze(),{realm:n}=nv(),{addAlert:r,addError:i}=Fs(),{id:o,usedBy:a,builtIn:s}=rv(),c=iv(),[l,u]=ae(0),d=()=>u(new Date().getTime()),[f,h]=ae(!0),[p,g]=ae(),[m,v]=ae(),[b,_]=ae(""),[w,M]=ae(),[N,A]=ae(),[q,T]=ae(),[F,D,O]=gs(),[L,y]=ae(!1),[C,x]=gs();Tn(async()=>{const V=(await e.authenticationManagement.getFlows()).find(j=>j.id===o);if(!V)throw new Error(t("notFound"));const W=await e.authenticationManagement.getExecutions({flow:V.alias});return{flow:V,executions:W}},({flow:z,executions:V})=>{g(z),v(new Mc(V))},[l]);const k=async(z,V)=>{try{let W=z.id;if("parent"in V){let ie={};"authenticationConfig"in z&&(ie=await e.authenticationManagement.getConfig({id:z.authenticationConfig}));try{await e.authenticationManagement.delExecution({id:W})}catch{}if("authenticationFlow"in z){const oe=z,de=await e.authenticationManagement.addFlowToFlow({flow:V.parent?.displayName||p?.alias,alias:oe.displayName,description:oe.description,provider:z.providerId,type:"basic-flow"});W=de.id,z.executionList?.forEach((ye,Z)=>k(ye,{parent:{...z,id:de.id},newIndex:Z,oldIndex:Z}))}else{const oe=await e.authenticationManagement.addExecutionToFlow({flow:V.parent?.displayName||p?.alias,provider:z.providerId});if(ie.id){const de={id:oe.id,alias:ie.alias,config:ie.config};await e.authenticationManagement.createConfig(de)}W=oe.id}}const j=V.newIndex-V.oldIndex;for(let ie=0;ie0?await e.authenticationManagement.lowerPriorityExecution({id:W}):await e.authenticationManagement.raisePriorityExecution({id:W});d(),r(t("updateFlowSuccess"),vt.success)}catch(W){i("updateFlowError",W)}},$=async z=>{const{executionList:V,isCollapsed:W,...j}=z;try{await e.authenticationManagement.updateExecution({flow:p?.alias},j),d(),r(t("updateFlowSuccess"),vt.success)}catch(ie){i("updateFlowError",ie)}},E=async(z,V)=>{try{await e.authenticationManagement.addExecutionToFlow({flow:z,provider:V.id}),d(),r(t("updateFlowSuccess"),vt.success)}catch(W){i("updateFlowError",W)}},P=async(z,{name:V,description:W="",type:j,provider:ie})=>{try{await e.authenticationManagement.addFlowToFlow({flow:z,alias:V,description:W,provider:ie,type:j}),d(),r(t("updateFlowSuccess"),vt.success)}catch(oe){i("updateFlowError",oe)}},[R,H]=Pc({titleKey:"deleteConfirmExecution",children:re($c,{i18nKey:"deleteConfirmExecutionMessage",children:[" ",S("strong",{children:{name:q?.displayName}}),"."]}),continueButtonLabel:"delete",continueButtonVariant:ut.danger,onConfirm:async()=>{try{await e.authenticationManagement.delExecution({id:q?.id}),r(t("deleteExecutionSuccess"),vt.success),d()}catch(z){i("deleteExecutionError",z)}}}),[U,B]=Pc({titleKey:"deleteConfirmFlow",children:re($c,{i18nKey:"deleteConfirmFlowMessage",children:[" ",S("strong",{children:{flow:p?.alias||""}}),"."]}),continueButtonLabel:"delete",continueButtonVariant:ut.danger,onConfirm:async()=>{try{await e.authenticationManagement.deleteFlow({flowId:p.id}),c(ov({realm:n})),r(t("deleteFlowSuccess"),vt.success)}catch(z){i("deleteFlowError",z)}}}),X=m?.expandableList.length!==0,J=[...a!=="DEFAULT"?[S(qt,{"data-testid":"set-as-default",onClick:x,children:t("bindFlow")},"default")]:[],S(qt,{onClick:()=>O(!0),children:t("duplicate")},"duplicate"),...s?[]:[S(qt,{"data-testid":"edit-flow",onClick:()=>y(!0),children:t("editInfo")},"edit"),S(qt,{"data-testid":"delete-flow",onClick:()=>U(),children:t("delete")},"delete")]];return re(Ce,{children:[C&&S(dv,{flowAlias:p?.alias,onClose:z=>{x(),c(av({realm:n,id:o,usedBy:z?"DEFAULT":"notInUse",builtIn:s?"builtIn":void 0}))}}),F&&S(fv,{name:p?.alias,description:p?.description,toggleDialog:D,onComplete:()=>{d(),O(!1)}}),L&&S(Kv,{flow:p,toggleDialog:()=>{y(!L),d()}}),S(B,{}),S(uv,{titleKey:p?.alias||"",badges:[{text:S(eh,{children:t(`used.${a}`)})},s?{text:S(Yv,{}),id:"builtIn"}:{}],dropdownItems:J}),re(th,{variant:"light",children:[m&&X&&re(Ce,{children:[S(sv,{id:"toolbar",children:re(cv,{children:[S(Yr,{children:re(xh,{children:[S(ir,{icon:S(Vv,{}),"aria-label":t("tableView"),buttonId:"tableView",isSelected:f,onChange:()=>h(!0)}),S(ir,{icon:S(Hv,{}),"aria-label":t("diagramView"),buttonId:"diagramView",isSelected:!f,onChange:()=>h(!1)})]})}),S(Yr,{children:S(_e,{"data-testid":"addStep",variant:"secondary",onClick:()=>M(!0),children:t("addStep")})}),S(Yr,{children:S(_e,{"data-testid":"addSubFlow",variant:"secondary",onClick:()=>A(!0),children:t("addSubFlow")})})]})}),S(H,{}),f&&S(Pv,{onDrag:({index:z})=>{const V=m.findExecution(z);return _(t("onDragStart",{item:V.displayName})),V.isCollapsed||(V.isCollapsed=!0,v(m.clone())),!0},onDragMove:({index:z})=>{const V=m.findExecution(z);_(t("onDragMove",{item:V?.displayName}))},onDrop:(z,V)=>{if(V){const W=m.findExecution(z.index),j=m.order().map(de=>de.id);_(t("onDragFinish",{list:W.displayName}));const[ie]=j.splice(z.index,1);j.splice(V.index,0,ie);const oe=m.getChange(W,j);return k(W,oe),!0}else return _(t("onDragCancel")),!1},children:S($v,{hasNoWrapper:!0,children:re(Dv,{"aria-label":t("flows"),children:[S(qC,{}),S(Ce,{children:m.expandableList.map(z=>S(am,{builtIn:!!s,execution:z,onRowClick:V=>{V.isCollapsed=!V.isCollapsed,v(m.clone())},onRowChange:$,onAddExecution:(V,W)=>E(V.displayName,W),onAddFlow:(V,W)=>P(V.displayName,W),onDelete:V=>{T(V),R()}},z.id))})]})})}),p&&re(Ce,{children:[w&&S(Ws,{name:p.alias,type:p.providerId==="client-flow"?"client":"basic",onSelect:z=>{z&&E(p.alias,z),M(!1)}}),N&&S(Zs,{name:p.alias,onCancel:()=>A(!1),onConfirm:z=>{P(p.alias,z),A(!1)}})]}),S("div",{className:"pf-v5-screen-reader","aria-live":"assertive",children:b})]}),!f&&m?.expandableList&&S(TC,{executionList:m}),!m?.expandableList||p&&!X&&S(Xv,{flow:p,onAddExecution:z=>E(p.alias,z),onAddFlow:z=>P(p.alias,z)})]})]})}export{CI as default,yr as providerConditionFilter};
//# sourceMappingURL=FlowDetails-C4B1eudZ.js.map




© 2015 - 2025 Weber Informatics LLC | Privacy Policy