@squeed/flow-sdk 2.0.36 → 2.0.37
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +6 -0
- package/dist/index.cjs +7 -7
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.js +385 -383
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
"use strict";var mv=Object.create;var
|
|
1
|
+
"use strict";var mv=Object.create;var Vo=Object.defineProperty;var bv=Object.getOwnPropertyDescriptor;var xv=Object.getOwnPropertyNames;var vv=Object.getPrototypeOf,wv=Object.prototype.hasOwnProperty;var Cv=(e,r,t)=>r in e?Vo(e,r,{enumerable:!0,configurable:!0,writable:!0,value:t}):e[r]=t;var Sv=(e,r,t,n)=>{if(r&&typeof r=="object"||typeof r=="function")for(let o of xv(r))!wv.call(e,o)&&o!==t&&Vo(e,o,{get:()=>r[o],enumerable:!(n=bv(r,o))||n.enumerable});return e};var dt=(e,r,t)=>(t=e!=null?mv(vv(e)):{},Sv(r||!e||!e.__esModule?Vo(t,"default",{value:e,enumerable:!0}):t,e));var qt=(e,r,t)=>Cv(e,typeof r!="symbol"?r+"":r,t);Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const f=require("react/jsx-runtime"),W=require("@chakra-ui/react"),j=require("react"),Jr=require("react-dom"),Y=require("react-icons/pi"),km=require("@emotion/react"),jv=require("@emotion/styled"),Ev=require("react-icons/tb"),_v=require("markdown-to-jsx/react"),Am=e=>e&&e.__esModule?e:{default:e},fo=Am(jv),Rv=Am(_v);function kv(e,r){let t,n,o,i;const s=(l=t)=>!!l&&["completed","failed","cancelled"].includes(l.status),a=()=>{const l=i;i=void 0,l==null||l()},c=l=>{if(!n||n.signal.aborted||!t||l.executionId!==t.executionId||s())return;const{step:d,...u}=l;t={...t,...u,steps:d?{...t.steps,[d.id]:{...t.steps[d.id],...d}}:t.steps},n.state=t,s()&&a(),r(t)};return{getState:()=>t,async run(l,d=crypto.randomUUID()){if(n&&!n.signal.aborted&&!s())throw new Error("An execution is already active.");o==null||o.abort(),a(),o=new AbortController;const u={executionId:d,input:l,signal:o.signal,state:{executionId:d,status:"subscribing",steps:{}}};n=u,t=u.state,r(t);try{const h=await e.subscribe(u,m=>{n===u&&c(m)});if(n!==u||u.signal.aborted||s())return h(),u.state;if(i=h,c({executionId:d,status:"running"}),n!==u||u.signal.aborted||s(u.state))return u.state;const p=await e.execute(u);n===u&&p&&c(p)}catch(h){if(s(u.state))return u.state;throw n===u&&!u.signal.aborted&&c({executionId:d,status:"failed",error:h instanceof Error?h.message:String(h)}),h}return u.state},async cancel(){const l=n;if(!(!l||l.signal.aborted||s())){if(!e.cancel)throw new Error("This adapter does not support cancellation.");await e.cancel(l),n===l&&c({executionId:l.executionId,status:"cancelled"})}},dispose(){o==null||o.abort(),n=void 0,a()}}}function ho({edge:e,enabled:r,bounds:t,inside:n=[],threshold:o=80}){const[i,s]=j.useState(!1),[a,c]=j.useState(!1),l=j.useRef(n);return l.current=n,j.useEffect(()=>{if(!r)return;const d=()=>{const h=document.querySelectorAll(':popover-open, dialog[open], [role="dialog"], [role="menu"], [role="listbox"]');c(Array.from(h).some(p=>p.getClientRects().length>0&&!p.closest('[hidden], [aria-hidden="true"], [data-state="closed"]')&&getComputedStyle(p).visibility==="visible"))},u=new MutationObserver(d);return u.observe(document.body,{childList:!0,subtree:!0,attributes:!0,attributeFilter:["open","hidden","aria-hidden","data-state"]}),document.addEventListener("toggle",d,!0),d(),()=>{u.disconnect(),document.removeEventListener("toggle",d,!0)}},[r]),j.useEffect(()=>{const d=h=>{var x;const p=(x=t.current)==null?void 0:x.getBoundingClientRect();if(!p)return;const m=h.target instanceof Node?h.target:null,g=!!m&&l.current.some(v=>{var w;return(w=v.current)==null?void 0:w.contains(m)}),y=e==="bottom"?p.bottom-h.clientY:h.clientY-p.top,b=h.clientX>=p.left&&h.clientX<=p.right&&y>=0&&y<=o;s(g||b)},u=()=>s(!1);return document.addEventListener("pointermove",d,!0),document.addEventListener("pointerdown",d,!0),document.documentElement.addEventListener("pointerleave",u),()=>{document.removeEventListener("pointermove",d,!0),document.removeEventListener("pointerdown",d,!0),document.documentElement.removeEventListener("pointerleave",u)}},[e,t,o]),r&&(i||a)}const rn="#c6c6c6";function oo(e,r=.2){const t=e.replace(/^#/,""),n=parseInt(t,16);let o=n>>16&255,i=n>>8&255,s=n&255;return o=Math.max(0,Math.floor(o*(1-r))),i=Math.max(0,Math.floor(i*(1-r))),s=Math.max(0,Math.floor(s*(1-r))),"#"+((1<<24)+(o<<16)+(i<<8)+s).toString(16).slice(1).toUpperCase()}function Eu(e,r,t){const n=a=>{const c=/^#?([0-9a-f]{6})$/i.exec((a==null?void 0:a.trim())??"");return c?parseInt(c[1],16):null},o=n(e),i=n(r);if(o===null||i===null)return null;const s=a=>Math.round((o>>a&255)*(1-t)+(i>>a&255)*t);return"#"+((1<<24)+(s(16)<<16)+(s(8)<<8)+s(0)).toString(16).slice(1).toUpperCase()}const nr=e=>e==="transparent"?{background:"transparent",highlight:"transparent",border:"transparent",property:"gray.900",boolean:"green.800",string:"gray.900",number:"orange.800"}:e!=null&&e.startsWith("#")?{background:e,highlight:oo(e,.1),border:oo(e,.5),property:"gray.900",boolean:"green.200",string:"gray.900",number:"orange.800"}:e==="gray"?{background:"gray.950",highlight:"gray.800",border:"gray.700",property:"gray.200",boolean:"green.400",string:"gray.200",number:"orange.600"}:e==="white"?{background:"white",highlight:"gray.200",border:"gray.400",property:"gray.900",boolean:"green.400",string:"gray.900",number:"orange.600"}:{background:e+".100",highlight:e+".200",border:e+".700",property:"gray.900",boolean:"green.800",string:"gray.900",number:"orange.800"},Pm=e=>{if(e==="transparent")return{primary:e,secondary:e,light:e};let r=e;if(r!=null&&r.startsWith("#"))return{secondary:oo(e)};let t=String(Number(e.slice(-3))+200);t=e.slice(0,-3).concat(t);let n=String(Number(e.slice(-3))-100);return n=e.slice(0,-3).concat(n),{primary:r,secondary:t,light:n}},_u={red:{50:"#FFF5F5",100:"#FED7D7",200:"#FEB2B2",300:"#FC8181",400:"#F56565",500:"#E53E3E",600:"#C53030",700:"#9B2C2C",800:"#822727",900:"#63171B"},orange:{50:"#FFFAF0",100:"#FEEBC8",200:"#FBD38D",300:"#F6AD55",400:"#ED8936",500:"#DD6B20",600:"#C05621",700:"#9C4221",800:"#7B341E",900:"#652B19"},yellow:{50:"#FFFFF0",100:"#FEFCBF",200:"#FAF089",300:"#F6E05E",400:"#ECC94B",500:"#D69E2E",600:"#B7791F",700:"#975A16",800:"#744210",900:"#5F370E"},green:{50:"#F0FFF4",100:"#C6F6D5",200:"#9AE6B4",300:"#68D391",400:"#48BB78",500:"#38A169",600:"#2F855A",700:"#276749",800:"#22543D",900:"#1C4532"},teal:{50:"#E6FFFA",100:"#B2F5EA",200:"#81E6D9",300:"#4FD1C5",400:"#38B2AC",500:"#319795",600:"#2C7A7B",700:"#285E61",800:"#234E52",900:"#1D4044"},blue:{50:"#EBF8FF",100:"#BEE3F8",200:"#90CDF4",300:"#63B3ED",400:"#4299E1",500:"#3182CE",600:"#2B6CB0",700:"#2C5282",800:"#2A4365",900:"#1A365D"},cyan:{50:"#EDFDFD",100:"#C4F1F9",200:"#9DECF9",300:"#76E4F7",400:"#0BC5EA",500:"#00B5D8",600:"#00A3C4",700:"#0987A0",800:"#086F83",900:"#065666"},purple:{50:"#FAF5FF",100:"#E9D8FD",200:"#D6BCFA",300:"#B794F4",400:"#9F7AEA",500:"#805AD5",600:"#6B46C1",700:"#553C9A",800:"#44337A",900:"#322659"},pink:{50:"#FFF5F7",100:"#FED7E2",200:"#FBB6CE",300:"#F687B3",400:"#ED64A6",500:"#D53F8C",600:"#B83280",700:"#97266D",800:"#702459",900:"#521B41"},gray:{50:"#F7FAFC",100:"#EDF2F7",200:"#E2E8F0",300:"#CBD5E0",400:"#A0AEC0",500:"#718096",600:"#4A5568",700:"#2D3748",800:"#1A202C",900:"#171923",950:"#0d1117"}},Me=(e,r)=>{var i;if(e==="transparent"||e!=null&&e.startsWith("#")||e!=null&&e.startsWith("var(--"))return e;if(!e)return"whitesmoke";const t=e.replace(/\./g,"-");try{const a=getComputedStyle(document.documentElement).getPropertyValue(`--chakra-colors-${t}`).trim();if(a&&a!=="")return a}catch{}const[n,o]=e.split(".");return n&&o&&((i=_u[n])!=null&&i[Number(o)])?_u[n][Number(o)]:`var(--chakra-colors-${t})`},Av=km.keyframes`
|
|
2
2
|
0%, 100% { box-shadow: var(--flow-rest-shadow); }
|
|
3
3
|
25%, 50% { box-shadow: var(--flow-hover-shadow); }
|
|
4
4
|
`,Pv=km.keyframes`
|
|
5
5
|
from { box-shadow: var(--flow-start-shadow); }
|
|
6
6
|
to { box-shadow: var(--flow-rest-shadow); }
|
|
7
|
-
`;function Mm(e,r=!0,t="&:hover",n=!0){const o=`color-mix(in srgb, ${e} 60%, transparent)`,s=`0 0 0 ${r?8:0}px ${o}`,a=`0 0 0 8px ${o}`;return{boxShadow:s,css:{"--flow-rest-shadow":a,"--flow-hover-shadow":`0 0 0 18px ${o}`,"@media (hover: hover)":{[t]:{boxShadow:a,"@media (prefers-reduced-motion: no-preference)":{animation:n?`${Av} 1200ms steps(10, end) 600ms`:"none"}}}}}}function xr(e,r){const{boxShadow:t,css:n}=Mm(e,!1),o=n["@media (hover: hover)"]["&:hover"];return{borderWidth:"1px",borderStyle:"solid",borderColor:"transparent",boxShadow:t,...n,"--flow-start-shadow":t,"@media (hover: hover)":{"&:hover":{...o,borderColor:r,"@media (prefers-reduced-motion: no-preference)":{animation:`${Pv} 600ms steps(5, end)`}}}}}const Im=j.createContext(null),Tm=j.createContext({nodeById:new Map,edgeById:new Map,parentIds:new Set});function Kt(){return j.useContext(Tm)}function Je(){const e=j.useContext(Im);if(!e)throw new Error("useFlowDiagramContext must be used within FlowDiagram");return e}function Om({config:e,callbacks:r,nodes:t=[],edges:n=[],children:o}){var Be;const i=j.useMemo(()=>{var je,Ve,nt;const U=new Map;for(const Xe of t)(je=Xe.data)!=null&&je.id&&U.set(Xe.data.id,Xe);const Ce=new Map;for(const Xe of n)(Ve=Xe.data)!=null&&Ve.id&&Ce.set(Xe.data.id,Xe);const Ne=new Set;for(const Xe of t)(nt=Xe.data)!=null&&nt.parent&&Ne.add(Xe.data.parent);return{nodeById:U,edgeById:Ce,parentIds:Ne}},[t,n]),s=j.useRef(null),[a,c]=j.useState([]),[l,d]=j.useState(null),[u,h]=j.useState(!0),[p,m]=j.useState(!1),[g,y]=j.useState(!0),[b,x]=j.useState(!1),[v,w]=j.useState(!1),[C,S]=j.useState(!0),[R,P]=j.useState(!1),[k,T]=j.useState(()=>{var U;return(U=e.nodeGrid)!=null&&U.enabled?{...e.nodeGrid.options,...e.nodeGrid.order?{order:e.nodeGrid.order}:{}}:null}),E=j.useRef(k),[M,_]=j.useState(k??((Be=e.nodeGrid)==null?void 0:Be.options)??{gaps:15,fill:!1,padding:0}),[N,$]=j.useState(()=>new Set),B=j.useCallback(U=>{var Ce;!!(U!=null&&U.fill)!=!!((Ce=E.current)!=null&&Ce.fill)&&$(new Set),E.current=U,U&&_(U),T(U)},[]),[O,I]=j.useState("auto"),[ee,ae]=j.useState(!1),ne=e.compactPropertyLayout??ee,[oe,pe]=j.useState({}),q=e.nodeViewModes??oe,[F,G]=j.useState(e.allNodesIconLabel);j.useEffect(()=>G(e.allNodesIconLabel),[e.allNodesIconLabel]);const[D,ce]=j.useState({}),Q=j.useCallback((U,Ce)=>{ce(Ne=>{const je={...Ne};for(const Ve of U)Ce===void 0?delete je[Ve]:je[Ve]=Ce;return je})},[]),K=[...i.nodeById.values()].filter(U=>{var Ce;return i.parentIds.has(U.data.id)||((Ce=U.data.config)==null?void 0:Ce.parentContainer)||U.data.type==="objectView"||U.data.type==="arrayView"||U.data.type==="text"||U.data.type==="grid"}),ie=K.every(U=>{var Ce,Ne,je;return i.parentIds.has(U.data.id)||(Ce=U.data.config)!=null&&Ce.parentContainer?!!((Ne=U.data.config)!=null&&Ne.collapsed):q[U.data.id]==="icon-label"||U.data.type==="grid"&&q[U.data.id]===void 0||((je=U.data.config)==null?void 0:je.labelBelow)&&q[U.data.id]!=="properties"}),ye=F??e.allNodesIconLabel??ie,[we,fe]=j.useState("normal"),[ge,X]=j.useState(),H=e.edgeRadius??ge,be=H!==void 0&&Number.isFinite(H)?Math.min(500,Math.max(0,H)):void 0,[J,xe]=j.useState(),Se=e.spacing??we,Fe=typeof Se=="number"?Number.isFinite(Se)?Math.min(2,Math.max(e.nodeGridSpacing==="layout"?0:.5,Se)):1:Se==="compact"?.5:Se==="spacious"?2:1,De=e.backgroundVariant??J??(e.backgroundPattern==="none"&&e.backgroundColor==="transparent"?"transparent":e.backgroundPattern??"dot"),[he,Re]=j.useState(),ze=Object.prototype.hasOwnProperty.call(e,"workflowContract")?e.workflowContract:he,[Te,qe]=j.useState("blue.500"),[Qe,ct]=j.useState(!1),Pe=j.useRef(r);Pe.current=r;const Ze=j.useMemo(()=>{const U=Ce=>(...Ne)=>{var je,Ve;return(Ve=(je=Pe.current)==null?void 0:je[Ce])==null?void 0:Ve.call(je,...Ne)};return{onNodeSelect:U("onNodeSelect"),onNodesCopy:U("onNodesCopy"),onNodesDuplicate:U("onNodesDuplicate"),onBackgroundClick:U("onBackgroundClick"),onBottomBarCollapsedChange:U("onBottomBarCollapsedChange"),onNodeGridZoomOut:U("onNodeGridZoomOut"),onNodeGridFillRequest:U("onNodeGridFillRequest"),onNodeGridModeRequest:U("onNodeGridModeRequest"),onNodeGridDrop:U("onNodeGridDrop"),onNodeParentChange:U("onNodeParentChange"),onNodeDeselect:U("onNodeDeselect"),onNodeDoubleClick:U("onNodeDoubleClick"),onNodeViewToggle:U("onNodeViewToggle"),onNodeTypeViewChange:U("onNodeTypeViewChange"),onNodeCreate:U("onNodeCreate"),onNodeCreateRequest:U("onNodeCreateRequest"),onNodeDelete:U("onNodeDelete"),onNodeLabelChange:U("onNodeLabelChange"),onNodeSubtitleChange:U("onNodeSubtitleChange"),onNodeContentChange:U("onNodeContentChange"),onNodeDimensionChange:U("onNodeDimensionChange"),onNodeCollapse:U("onNodeCollapse"),onNodeColorChange:U("onNodeColorChange"),onNodeBorderColorChange:U("onNodeBorderColorChange"),onNodeBorderStyleChange:U("onNodeBorderStyleChange"),onNodeBorderWidthChange:U("onNodeBorderWidthChange"),onNodeBorderRadiusChange:(Ce,Ne)=>{var je,Ve,nt;(je=E.current)!=null&&je.fill&&$(Xe=>new Set([...Xe,Ce])),(nt=(Ve=Pe.current).onNodeBorderRadiusChange)==null||nt.call(Ve,Ce,Ne)},onNodeIconChange:U("onNodeIconChange"),onNodeOutlineChange:U("onNodeOutlineChange"),onNodeAnimationChange:U("onNodeAnimationChange"),onNodeAnimationVariantChange:U("onNodeAnimationVariantChange"),onEdgeAnimationVariantChange:U("onEdgeAnimationVariantChange"),onNodeHoverAction:U("onNodeHoverAction"),onEdgeCreate:U("onEdgeCreate"),onEdgeSelect:U("onEdgeSelect"),onEdgeDeselect:U("onEdgeDeselect"),onEdgeRemove:U("onEdgeRemove"),onEdgeDelete:U("onEdgeDelete"),onEdgeColorChange:U("onEdgeColorChange"),onEdgeTypeChange:U("onEdgeTypeChange"),onEdgeIconChange:U("onEdgeIconChange"),onEdgeLabelChange:U("onEdgeLabelChange"),onEdgeStyleChange:U("onEdgeStyleChange"),onViewportChange:U("onViewportChange"),onDirectionChange:U("onDirectionChange"),onThemeColorChange:U("onThemeColorChange"),onSpacingChange:U("onSpacingChange"),onEdgeRadiusChange:U("onEdgeRadiusChange"),onBackgroundVariantChange:U("onBackgroundVariantChange"),onEdgeModeChange:U("onEdgeModeChange"),onCompactPropertyLayoutChange:U("onCompactPropertyLayoutChange"),onWorkflowContractChange:U("onWorkflowContractChange"),onWorkflowConfigurationOpen:r.onWorkflowConfigurationOpen?U("onWorkflowConfigurationOpen"):void 0,onArrayModeChange:U("onArrayModeChange"),onInit:U("onInit"),onLayoutComplete:U("onLayoutComplete"),onJsonChange:U("onJsonChange")}},[]),Ye=e.themeColor||Te,[at,Ot]=j.useState(""),Rt=e.edgeColor??at,Vr=e.colorMode||"light",rt=e.direction||"LR",Ke=e.nodeAlignment??"center",Zt=e.edgeMode==="workflow"?"nodes":e.edgeMode??O,ft=e.readOnly??!1,jr=JSON.stringify(e.parentNodeStyle??null),Pt=j.useMemo(()=>e.parentNodeStyle,[jr]),Er=e.isZoomMode!==void 0?e.isZoomMode:u,Vt=e.isMultiSelectMode!==void 0?e.isMultiSelectMode:p,Xt=e.isEdgeHandlesEnabled!==void 0?e.isEdgeHandlesEnabled:b,ar=e.isDragMode!==void 0?e.isDragMode:g,We=j.useRef(e);We.current=e;const de=j.useMemo(()=>({get direction(){return We.current.direction},get nodeAlignment(){return We.current.nodeAlignment},get edgeMode(){return We.current.edgeMode},get compactPropertyLayout(){return We.current.compactPropertyLayout},get bottomBarCollapsed(){return We.current.bottomBarCollapsed},get bottomBarNavigation(){return We.current.bottomBarNavigation},get bottomBarFill(){return We.current.bottomBarFill},get bottomBarCollision(){return We.current.bottomBarCollision},get nodeGridConnections(){return We.current.nodeGridConnections},get nodeGrid(){return We.current.nodeGrid},get edgeType(){return We.current.edgeType},get edgeReveal(){return We.current.edgeReveal},get customEdgeTypes(){return We.current.customEdgeTypes},get themeColor(){return We.current.themeColor},get colorMode(){return We.current.colorMode},get readOnly(){return We.current.readOnly},get editable(){return We.current.editable},get minZoom(){return We.current.minZoom},get nodeGridSpacing(){return We.current.nodeGridSpacing},get maxZoom(){return We.current.maxZoom},get backgroundPattern(){return We.current.backgroundPattern},get edgeColor(){return We.current.edgeColor},get parentNodeStyle(){return We.current.parentNodeStyle},get backgroundColor(){return We.current.backgroundColor},get edgeHandles(){return We.current.edgeHandles},get initialViewport(){return We.current.initialViewport},get animateViewport(){return We.current.animateViewport},get disableAnimations(){return We.current.disableAnimations},get nodeOverlayActions(){return We.current.nodeOverlayActions},get renderNodeOverlay(){return We.current.renderNodeOverlay},get renderSelectedNodeToolbar(){return We.current.renderSelectedNodeToolbar},get renderSelectedEdgeToolbar(){return We.current.renderSelectedEdgeToolbar},get renderBottomBar(){return We.current.renderBottomBar},get bottomBarExtra(){return We.current.bottomBarExtra},get selectionToolbar(){return We.current.selectionToolbar},get customViews(){return We.current.customViews},get disableKeyboardShortcuts(){return We.current.disableKeyboardShortcuts},get isZoomMode(){return We.current.isZoomMode},get isMultiSelectMode(){return We.current.isMultiSelectMode},get isEdgeHandlesEnabled(){return We.current.isEdgeHandlesEnabled},get isDragMode(){return We.current.isDragMode}}),[]),W=j.useCallback((U,Ce)=>{var Ne;if(Ce!=="default"&&Ce!=="properties"&&Ce!=="icon-label")throw new Error("Unknown node view mode.");G(je=>je??ye),pe(je=>je[U]===Ce?je:{...je,[U]:Ce}),(Ne=r.onNodeViewModeChange)==null||Ne.call(r,U,Ce)},[r.onNodeViewModeChange,ye]),se=j.useMemo(()=>({allNodesIconLabel:ye,setAllNodesIconLabel:U=>{var Ce,Ne,je,Ve,nt;if(G(U),!U)for(const[Xe,St]of Object.entries(q))St==="icon-label"&&!i.nodeById.has(Xe)&&W(Xe,"default");for(const Xe of K)i.parentIds.has(Xe.data.id)||(Ce=Xe.data.config)!=null&&Ce.parentContainer?!ft&&!!((Ne=Xe.data.config)!=null&&Ne.collapsed)!==U&&((je=r.onNodeCollapse)==null||je.call(r,Xe.data.id,U)):W(Xe.data.id,U?"icon-label":(Ve=Xe.data.config)!=null&&Ve.labelBelow?"properties":"default");(nt=r.onAllNodesIconLabelChange)==null||nt.call(r,U)},nodeViewModes:q,setNodeViewMode:W,nodeRadiusPreviews:D,setNodeRadiusPreview:Q,spacing:Fe,setSpacing:fe,edgeRadius:be,setEdgeRadius:X,backgroundVariant:De,setBackgroundVariant:xe,themeColor:Ye,setThemeColor:qe,backgroundSelected:Qe,setBackgroundSelected:ct,edgeColor:Rt,setEdgeColor:U=>{var Ce;Ot(U),(Ce=r.onGraphEdgeColorChange)==null||Ce.call(r,U)},colorMode:Vr,direction:rt,nodeAlignment:Ke,edgeMode:Zt,setEdgeMode:I,compactPropertyLayout:ne,setCompactPropertyLayout:ae,workflowContract:ze,setWorkflowContract:Re,parentNodeStyle:Pt,selectedNodeIds:a,setSelectedNodeIds:c,selectedEdgeId:l,setSelectedEdgeId:d,isZoomMode:Er,setIsZoomMode:h,isMultiSelectMode:Vt,setIsMultiSelectMode:m,isDragMode:ar,setIsDragMode:y,isEdgeHandlesEnabled:Xt,setIsEdgeHandlesEnabled:x,isArrayNodeMode:v,setIsArrayNodeMode:w,isPinned:C,setIsPinned:S,isPerformanceMode:R,setIsPerformanceMode:P,nodeGridOptions:k,setNodeGridOptions:B,lastNodeGridOptions:M,fillRadiusEditedIds:N,setFillRadiusEditedIds:$,engineRef:s,callbacks:Ze,config:de,readOnly:ft}),[ye,i,W,r.onNodeCollapse,r.onAllNodesIconLabelChange,r.onGraphEdgeColorChange,q,r.onNodeViewModeChange,D,Q,Ye,Fe,De,be,e.backgroundColor,Qe,Rt,Vr,rt,Ke,Zt,ze,Pt,a,l,Er,Vt,ar,Xt,v,C,R,k,M,N,ft,e.edgeHandles,e.edgeType,e.edgeReveal,e.animateViewport,e.disableAnimations,e.customEdgeTypes,e.selectionToolbar,e.bottomBarExtra,e.bottomBarCollapsed,e.bottomBarNavigation,e.bottomBarFill,e.bottomBarCollision,e.nodeGridSpacing,e.nodeGridConnections,e.compactPropertyLayout,ne,Ze,de]);return f.jsx(Im.Provider,{value:se,children:f.jsx(Tm.Provider,{value:i,children:o})})}function wt(e,r,t){return e?t:r}function Ln(e){const[r]=(e==null?void 0:e.split("."))||[],{secondary:t}=Pm(e),n=nr(r).background,o=nr(r).highlight,i=nr(r).border,s=nr(r).property,a=nr(r).property;let c=nr(r).background,l=nr(r).highlight;return c=e==="transparent"?e:Me(c)+50,l=e==="transparent"?e:Me(l)+20,{bgColor:n,highlightColor:o,borderColor:i,textColor:s,propertyColor:a,secondary:t,bgColorFaint:c,highlightColorFaint:l}}function lt(e=null){const{colorMode:r}=Je(),t=e==null?void 0:e.includes("gray"),n=r==="dark",o=wt(n,"white","gray.900"),i=wt(n,"gray.100","gray.800"),s=wt(n,"gray.200","blackAlpha.400"),a=wt(n,"gray.200","blackAlpha.600"),c=wt(n,"gray.500","gray.700"),l=wt(n,"gray.700","gray.700"),d=wt(n,"gray.900","gray.900"),u=wt(n,"gray.400","gray.500"),h=wt(n,"gray.400","gray.500"),p=wt(n,"gray.900","gray.200"),m=wt(n,t?"gray.900":"gray.200",t?"gray.200":"gray.900"),g=wt(n,"gray.900","gray.200"),y=wt(n,e&&"#000000",e||"#ffffff"),b=wt(n,e||"#ffffff",e?"#000000":"#ffffff"),x=l,v=wt(n,"gray.300","gray.800"),w=wt(n,"white","blackAlpha.400"),C=wt(n,"green.100","green.700");return{canvas:o,background:i,backgroundSecondary:s,darkBackgroundSecondary:a,border:c,darkColor:d,backgroundWhiteColor:w,borderSecondary:l,colorActive:u,colorInactive:h,iconColor:g,moreIconColor:x,colorText:p,themedColorText:m,logoColor:y,logoColorSecondary:b,darkColorActive:v,greenColor:C}}var yn=(e=>(e.TOP_DOWN="TB",e.BOTTOM_UP="BT",e.LEFT_RIGHT="LR",e.RIGHT_LEFT="RL",e.CENTER="C",e))(yn||{});const Ed=["","icon-label","object","text","grid","parent"];var Mv=typeof global=="object"&&global&&global.Object===Object&&global,Iv=typeof self=="object"&&self&&self.Object===Object&&self,Tv=Mv||Iv||Function("return this")(),Zr=Tv.Symbol,Nm=Object.prototype,Ov=Nm.hasOwnProperty,Nv=Nm.toString,pn=Zr?Zr.toStringTag:void 0;function $v(e){var r=Ov.call(e,pn),t=e[pn];try{e[pn]=void 0;var n=!0}catch{}var o=Nv.call(e);return n&&(r?e[pn]=t:delete e[pn]),o}var qv=Object.prototype,Lv=qv.toString;function Fv(e){return Lv.call(e)}var zv="[object Null]",Bv="[object Undefined]",Ru=Zr?Zr.toStringTag:void 0;function Dv(e){return e==null?e===void 0?Bv:zv:Ru&&Ru in Object(e)?$v(e):Fv(e)}function Vv(e){return e!=null&&typeof e=="object"}var Wv="[object Symbol]";function Gv(e){return typeof e=="symbol"||Vv(e)&&Dv(e)==Wv}function Uv(e,r){for(var t=-1,n=e==null?0:e.length,o=Array(n);++t<n;)o[t]=r(e[t],t,e);return o}var it=Array.isArray,ku=Zr?Zr.prototype:void 0,Au=ku?ku.toString:void 0;function $m(e){if(typeof e=="string")return e;if(it(e))return Uv(e,$m)+"";if(Gv(e))return Au?Au.call(e):"";var r=e+"";return r=="0"&&1/e==-1/0?"-0":r}function _d(e){return e==null?"":$m(e)}function Hv(e,r,t){var n=-1,o=e.length;r<0&&(r=-r>o?0:o+r),t=t>o?o:t,t<0&&(t+=o),o=r>t?0:t-r>>>0,r>>>=0;for(var i=Array(o);++n<o;)i[n]=e[n+r];return i}function Kv(e,r,t){var n=e.length;return t=t===void 0?n:t,!r&&t>=n?e:Hv(e,r,t)}var Jv="\\ud800-\\udfff",Zv="\\u0300-\\u036f",Xv="\\ufe20-\\ufe2f",Yv="\\u20d0-\\u20ff",Qv=Zv+Xv+Yv,e0="\\ufe0e\\ufe0f",t0="\\u200d",r0=RegExp("["+t0+Jv+Qv+e0+"]");function qm(e){return r0.test(e)}function n0(e){return e.split("")}var Lm="\\ud800-\\udfff",o0="\\u0300-\\u036f",i0="\\ufe20-\\ufe2f",a0="\\u20d0-\\u20ff",s0=o0+i0+a0,c0="\\ufe0e\\ufe0f",l0="["+Lm+"]",pd="["+s0+"]",gd="\\ud83c[\\udffb-\\udfff]",d0="(?:"+pd+"|"+gd+")",Fm="[^"+Lm+"]",zm="(?:\\ud83c[\\udde6-\\uddff]){2}",Bm="[\\ud800-\\udbff][\\udc00-\\udfff]",u0="\\u200d",Dm=d0+"?",Vm="["+c0+"]?",f0="(?:"+u0+"(?:"+[Fm,zm,Bm].join("|")+")"+Vm+Dm+")*",h0=Vm+Dm+f0,p0="(?:"+[Fm+pd+"?",pd,zm,Bm,l0].join("|")+")",g0=RegExp(gd+"(?="+gd+")|"+p0+h0,"g");function y0(e){return e.match(g0)||[]}function m0(e){return qm(e)?y0(e):n0(e)}function b0(e){return function(r){r=_d(r);var t=qm(r)?m0(r):void 0,n=t?t[0]:r.charAt(0),o=t?Kv(t,1).join(""):r.slice(1);return n[e]()+o}}var x0=b0("toUpperCase");function v0(e,r,t,n){for(var o=-1,i=e==null?0:e.length;++o<i;)t=r(t,e[o],o,e);return t}function w0(e){return function(r){return e==null?void 0:e[r]}}var C0={À:"A",Á:"A",Â:"A",Ã:"A",Ä:"A",Å:"A",à:"a",á:"a",â:"a",ã:"a",ä:"a",å:"a",Ç:"C",ç:"c",Ð:"D",ð:"d",È:"E",É:"E",Ê:"E",Ë:"E",è:"e",é:"e",ê:"e",ë:"e",Ì:"I",Í:"I",Î:"I",Ï:"I",ì:"i",í:"i",î:"i",ï:"i",Ñ:"N",ñ:"n",Ò:"O",Ó:"O",Ô:"O",Õ:"O",Ö:"O",Ø:"O",ò:"o",ó:"o",ô:"o",õ:"o",ö:"o",ø:"o",Ù:"U",Ú:"U",Û:"U",Ü:"U",ù:"u",ú:"u",û:"u",ü:"u",Ý:"Y",ý:"y",ÿ:"y",Æ:"Ae",æ:"ae",Þ:"Th",þ:"th",ß:"ss",Ā:"A",Ă:"A",Ą:"A",ā:"a",ă:"a",ą:"a",Ć:"C",Ĉ:"C",Ċ:"C",Č:"C",ć:"c",ĉ:"c",ċ:"c",č:"c",Ď:"D",Đ:"D",ď:"d",đ:"d",Ē:"E",Ĕ:"E",Ė:"E",Ę:"E",Ě:"E",ē:"e",ĕ:"e",ė:"e",ę:"e",ě:"e",Ĝ:"G",Ğ:"G",Ġ:"G",Ģ:"G",ĝ:"g",ğ:"g",ġ:"g",ģ:"g",Ĥ:"H",Ħ:"H",ĥ:"h",ħ:"h",Ĩ:"I",Ī:"I",Ĭ:"I",Į:"I",İ:"I",ĩ:"i",ī:"i",ĭ:"i",į:"i",ı:"i",Ĵ:"J",ĵ:"j",Ķ:"K",ķ:"k",ĸ:"k",Ĺ:"L",Ļ:"L",Ľ:"L",Ŀ:"L",Ł:"L",ĺ:"l",ļ:"l",ľ:"l",ŀ:"l",ł:"l",Ń:"N",Ņ:"N",Ň:"N",Ŋ:"N",ń:"n",ņ:"n",ň:"n",ŋ:"n",Ō:"O",Ŏ:"O",Ő:"O",ō:"o",ŏ:"o",ő:"o",Ŕ:"R",Ŗ:"R",Ř:"R",ŕ:"r",ŗ:"r",ř:"r",Ś:"S",Ŝ:"S",Ş:"S",Š:"S",ś:"s",ŝ:"s",ş:"s",š:"s",Ţ:"T",Ť:"T",Ŧ:"T",ţ:"t",ť:"t",ŧ:"t",Ũ:"U",Ū:"U",Ŭ:"U",Ů:"U",Ű:"U",Ų:"U",ũ:"u",ū:"u",ŭ:"u",ů:"u",ű:"u",ų:"u",Ŵ:"W",ŵ:"w",Ŷ:"Y",ŷ:"y",Ÿ:"Y",Ź:"Z",Ż:"Z",Ž:"Z",ź:"z",ż:"z",ž:"z",IJ:"IJ",ij:"ij",Œ:"Oe",œ:"oe",ʼn:"'n",ſ:"s"},S0=w0(C0),j0=/[\xc0-\xd6\xd8-\xf6\xf8-\xff\u0100-\u017f]/g,E0="\\u0300-\\u036f",_0="\\ufe20-\\ufe2f",R0="\\u20d0-\\u20ff",k0=E0+_0+R0,A0="["+k0+"]",P0=RegExp(A0,"g");function M0(e){return e=_d(e),e&&e.replace(j0,S0).replace(P0,"")}var I0=/[^\x00-\x2f\x3a-\x40\x5b-\x60\x7b-\x7f]+/g;function T0(e){return e.match(I0)||[]}var O0=/[a-z][A-Z]|[A-Z]{2}[a-z]|[0-9][a-zA-Z]|[a-zA-Z][0-9]|[^a-zA-Z0-9 ]/;function N0(e){return O0.test(e)}var Wm="\\ud800-\\udfff",$0="\\u0300-\\u036f",q0="\\ufe20-\\ufe2f",L0="\\u20d0-\\u20ff",F0=$0+q0+L0,Gm="\\u2700-\\u27bf",Um="a-z\\xdf-\\xf6\\xf8-\\xff",z0="\\xac\\xb1\\xd7\\xf7",B0="\\x00-\\x2f\\x3a-\\x40\\x5b-\\x60\\x7b-\\xbf",D0="\\u2000-\\u206f",V0=" \\t\\x0b\\f\\xa0\\ufeff\\n\\r\\u2028\\u2029\\u1680\\u180e\\u2000\\u2001\\u2002\\u2003\\u2004\\u2005\\u2006\\u2007\\u2008\\u2009\\u200a\\u202f\\u205f\\u3000",Hm="A-Z\\xc0-\\xd6\\xd8-\\xde",W0="\\ufe0e\\ufe0f",Km=z0+B0+D0+V0,Jm="['’]",Pu="["+Km+"]",G0="["+F0+"]",Zm="\\d+",U0="["+Gm+"]",Xm="["+Um+"]",Ym="[^"+Wm+Km+Zm+Gm+Um+Hm+"]",H0="\\ud83c[\\udffb-\\udfff]",K0="(?:"+G0+"|"+H0+")",J0="[^"+Wm+"]",Qm="(?:\\ud83c[\\udde6-\\uddff]){2}",eb="[\\ud800-\\udbff][\\udc00-\\udfff]",Wr="["+Hm+"]",Z0="\\u200d",Mu="(?:"+Xm+"|"+Ym+")",X0="(?:"+Wr+"|"+Ym+")",Iu="(?:"+Jm+"(?:d|ll|m|re|s|t|ve))?",Tu="(?:"+Jm+"(?:D|LL|M|RE|S|T|VE))?",tb=K0+"?",rb="["+W0+"]?",Y0="(?:"+Z0+"(?:"+[J0,Qm,eb].join("|")+")"+rb+tb+")*",Q0="\\d*(?:1st|2nd|3rd|(?![123])\\dth)(?=\\b|[A-Z_])",ew="\\d*(?:1ST|2ND|3RD|(?![123])\\dTH)(?=\\b|[a-z_])",tw=rb+tb+Y0,rw="(?:"+[U0,Qm,eb].join("|")+")"+tw,nw=RegExp([Wr+"?"+Xm+"+"+Iu+"(?="+[Pu,Wr,"$"].join("|")+")",X0+"+"+Tu+"(?="+[Pu,Wr+Mu,"$"].join("|")+")",Wr+"?"+Mu+"+"+Iu,Wr+"+"+Tu,ew,Q0,Zm,rw].join("|"),"g");function ow(e){return e.match(nw)||[]}function iw(e,r,t){return e=_d(e),r=r,r===void 0?N0(e)?ow(e):T0(e):e.match(r)||[]}var aw="['’]",sw=RegExp(aw,"g");function cw(e){return function(r){return v0(iw(M0(r).replace(sw,"")),e,"")}}var Ft=cw(function(e,r,t){return e+(t?" ":"")+x0(r)});function nb({label:e,disabled:r=!1}){const t=j.useRef(null),n=j.useRef(),{colorInactive:o}=lt(),i=()=>{var c;return(c=t.current)==null?void 0:c.closest("[data-flow-floating-panel]")},s=(c,l)=>{const d=i();if(!d)return;const u=d.getBoundingClientRect();d.style.left=`${Math.max(12,Math.min(c,window.innerWidth-u.width-12))}px`,d.style.top=`${Math.max(12,Math.min(l,window.innerHeight-u.height-12))}px`,d.style.right="auto",d.style.bottom="auto",d.dataset.flowPanelMoved="true"},a=(c=!1)=>{var d;const l=n.current;l&&(c&&s(l.left,l.top),n.current=void 0,(d=t.current)!=null&&d.hasPointerCapture(l.pointerId)&&t.current.releasePointerCapture(l.pointerId),t.current&&(t.current.style.cursor=""))};return j.useEffect(()=>{const c=()=>{const u=i();if(!(u!=null&&u.dataset.flowPanelMoved))return;const h=u.getBoundingClientRect();s(h.left,h.top)},l=u=>{u.key!=="Escape"||!n.current||(u.preventDefault(),u.stopPropagation(),a(!0))},d=()=>a(!0);return window.addEventListener("resize",c),window.addEventListener("keydown",l,!0),window.addEventListener("blur",d),()=>{window.removeEventListener("resize",c),window.removeEventListener("keydown",l,!0),window.removeEventListener("blur",d),a()}},[]),f.jsx(V.chakra.button,{ref:t,type:"button","aria-label":`Drag ${e}`,title:r?"Pin to drag":`Drag ${e}`,disabled:r,"data-panel-drag-handle":"",display:"flex",alignItems:"center",justifyContent:"center",width:"64px",height:"24px",flexShrink:0,marginInline:"auto",border:0,background:"transparent",color:o,cursor:"grab",touchAction:"none",userSelect:"none",_disabled:{opacity:.35,cursor:"default"},onPointerDown:c=>{var d;if(c.button!==0||n.current)return;const l=(d=i())==null?void 0:d.getBoundingClientRect();l&&(c.preventDefault(),c.stopPropagation(),n.current={pointerId:c.pointerId,x:c.clientX,y:c.clientY,left:l.left,top:l.top},c.currentTarget.setPointerCapture(c.pointerId),c.currentTarget.style.cursor="grabbing")},onPointerMove:c=>{const l=n.current;!l||l.pointerId!==c.pointerId||(c.stopPropagation(),s(l.left+c.clientX-l.x,l.top+c.clientY-l.y))},onPointerUp:c=>{var l;((l=n.current)==null?void 0:l.pointerId)===c.pointerId&&a()},onPointerCancel:()=>a(!0),onLostPointerCapture:()=>a(),onKeyDown:c=>{var u;const l=(u=i())==null?void 0:u.getBoundingClientRect();if(!l||!["ArrowLeft","ArrowRight","ArrowUp","ArrowDown"].includes(c.key))return;c.preventDefault(),c.stopPropagation();const d=c.shiftKey?40:10;s(l.left+(c.key==="ArrowLeft"?-d:c.key==="ArrowRight"?d:0),l.top+(c.key==="ArrowUp"?-d:c.key==="ArrowDown"?d:0))},children:f.jsx(Y.PiDotsSix,{size:20,"aria-hidden":"true"})})}function lw(){let e,r=null;const t=new Set,n=o=>{r=o,t.forEach(i=>i())};return{subscribe:o=>(t.add(o),()=>{t.delete(o)}),getSnapshot:()=>r,select(o,i){e=o,n(i)},update(o,i){e===o&&n(i)},remove(o){e===o&&(e=void 0,n(null))}}}const Xr=j.createContext(null),dw=()=>j.useState(lw)[0];function po(e,r=!0){const t=j.useContext(Xr),n=j.useId();return j.useEffect(()=>{r?t==null||t.update(n,e):t==null||t.remove(n)}),j.useEffect(()=>()=>t==null?void 0:t.remove(n),[t,n]),()=>{r&&(t==null||t.select(n,e))}}function uw({divider:e,visibleActions:r=[]}){const t=j.useContext(Xr),n=j.useSyncExternalStore(t.subscribe,t.getSnapshot,()=>null),o=n&&r.includes(n.props["aria-label"]??"");return f.jsx(Xr.Provider,{value:null,children:f.jsxs("span",{"data-recent-toolbar-action":"",style:{display:n&&!o?"contents":"none"},children:[n&&!o&&e,!o&&n]})})}function He({label:e,children:r}){const t=j.cloneElement(r,{title:r.props.title??e});if(!V.Tooltip.Root){const n=V.Tooltip;return f.jsx(n,{label:e,placement:"top",fontSize:"xs",borderRadius:"15px",children:t})}return f.jsxs(V.Tooltip.Root,{positioning:{placement:"top"},children:[f.jsx(V.Tooltip.Trigger,{asChild:!0,children:t}),f.jsx(V.Portal,{children:f.jsx(V.Tooltip.Positioner,{children:f.jsx(V.Tooltip.Content,{fontSize:"xs",borderRadius:"15px",children:e})})})]})}function Sn(){const{border:e}=lt(),{colorMode:r}=Je();return f.jsx(V.chakra.span,{role:"separator","aria-orientation":"vertical",display:"block",flexShrink:0,w:"1px",h:"20px",mx:"4px",bg:r==="dark"?e:"gray.300"})}function Mt({children:e,value:r,onValueChange:t,disabled:n,style:o,title:i,icon:s,popupContent:a,footer:c,pinned:l=!1,draggable:d=!1,open:u,onOpenChange:h,labelCase:p="title","aria-label":m,...g}){var O;const{colorMode:y}=Je(),{background:b,border:x,colorText:v,colorInactive:w}=lt(),C=y==="dark",S=j.useId(),R=j.useRef(null),P=j.useRef(null),[k,T]=j.useState(!1),E=po(f.jsx(Mt,{value:r,onValueChange:t,disabled:n,style:o,title:i,icon:s,popupContent:a,footer:c,pinned:l,draggable:d,labelCase:p,"aria-label":m,children:e}),!!s);j.useLayoutEffect(()=>{const I=P.current,ee=I.matches(":popover-open"),ae=document.activeElement instanceof HTMLElement&&I.contains(document.activeElement)?document.activeElement:null,ne=[I,...I.querySelectorAll("*")].filter(q=>q.scrollTop||q.scrollLeft).map(q=>({element:q,top:q.scrollTop,left:q.scrollLeft})),oe=l?"manual":"auto";if(I.getAttribute("popover")!==oe&&I.setAttribute("popover",oe),ee){I.showPopover(),!l&&I.dataset.flowPanelMoved&&(delete I.dataset.flowPanelMoved,N()),ae==null||ae.focus({preventScroll:!0});for(const{element:q,top:F,left:G}of ne)q.scrollTop=F,q.scrollLeft=G}const pe=q=>{const F=q.newState==="open";T(F),h==null||h(F)};return I.addEventListener("toggle",pe),()=>I.removeEventListener("toggle",pe)},[l,h]);const M=j.Children.toArray(e).filter(j.isValidElement).map(I=>{const ee=I.props;return{value:String(ee.value),label:typeof ee.children=="string"&&p==="title"?Ft(ee.children):ee.children,disabled:ee.disabled}}),_=()=>{var I;return(I=P.current)==null?void 0:I.hidePopover()},N=()=>{var pe,q,F,G,D;const I=(pe=R.current)==null?void 0:pe.getBoundingClientRect(),ee=P.current;if(!I||!ee||l&&ee.dataset.flowPanelMoved)return;if((q=R.current)!=null&&q.closest("[popover]")){const ce=window.innerHeight-I.bottom-16,Q=I.top-16;ee.style.maxHeight=`${Math.max(60,ce,Q)}px`;const K=ee.getBoundingClientRect();ee.style.left=`${Math.max(12,Math.min(I.right-K.width,window.innerWidth-K.width-12))}px`,ee.style.top=`${Math.max(12,K.height<=ce?I.bottom+4:I.top-K.height-4)}px`;return}const ae=(D=(G=(F=R.current)==null?void 0:F.closest("[data-flow-toolbar-scroll]"))==null?void 0:G.parentElement)==null?void 0:D.getBoundingClientRect(),ne=ae??I;ee.style.maxHeight=`${Math.max(60,Math.max(ne.top-40,window.innerHeight-ne.bottom-40))}px`;const oe=ee.getBoundingClientRect();ee.style.left=`${Math.max(12,Math.min(Math.max((ae==null?void 0:ae.left)??12,I.right-oe.width),((ae==null?void 0:ae.right)??window.innerWidth-12)-oe.width,window.innerWidth-oe.width-12))}px`,ee.style.top=`${Math.max(12,ne.top>=oe.height+36?ne.top-oe.height-24:Math.min(ne.bottom+24,window.innerHeight-oe.height-12))}px`},$=()=>{var ae,ne,oe,pe,q,F;if(n)return;if(P.current&&!P.current.matches(":popover-open")&&delete P.current.dataset.flowPanelMoved,(ae=P.current)==null||ae.showPopover(),N(),a){(oe=(ne=P.current)==null?void 0:ne.querySelector("input"))==null||oe.focus({preventScroll:!0});return}const I=(pe=P.current)==null?void 0:pe.querySelectorAll('[role="option"]:not(:disabled)');(F=((q=P.current)==null?void 0:q.querySelector('[aria-selected="true"]:not(:disabled)'))??(I==null?void 0:I[0]))==null||F.focus()};j.useLayoutEffect(()=>{u!==void 0&&(u?$():_())},[u]),j.useEffect(()=>{if(k){if(n){_();return}return window.addEventListener("resize",N),window.addEventListener("scroll",N,!0),()=>{window.removeEventListener("resize",N),window.removeEventListener("scroll",N,!0)}}},[k,n,l]);const B=`var(--chakra-colors-${b.replace(".","-")})`;return f.jsxs(f.Fragment,{children:[f.jsx(He,{label:i??m,children:f.jsx(V.chakra.button,{...g,ref:R,type:"button",role:"combobox","data-flow-select-icon":s?"":void 0,"aria-label":m,title:i??m,"aria-haspopup":a?"dialog":"listbox","aria-expanded":k,"aria-controls":S,disabled:n,h:"30px",w:"160px",px:"6px",fontSize:"12px",border:"none",borderRadius:"4px",bg:"transparent",color:s?w:v,display:"flex",alignItems:"center",justifyContent:s?"center":"space-between",gap:2,style:o,onClick:()=>{E(),k?_():$()},onKeyDown:I=>{["ArrowDown","ArrowUp"].includes(I.key)&&(I.preventDefault(),$())},children:s??f.jsxs(f.Fragment,{children:[f.jsx("span",{style:{overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:((O=M.find(I=>I.value===r))==null?void 0:O.label)??r}),f.jsx(Y.PiCaretUp,{size:16,style:{flexShrink:0}})]})})}),f.jsxs(V.chakra.div,{ref:P,id:S,"data-flow-select-pinned":l?"":void 0,"data-flow-floating-panel":d&&l?"":void 0,role:a?"dialog":"listbox","aria-label":m,position:"fixed",m:0,p:2,minW:"180px",maxW:"calc(100vw - 24px)",gridTemplateColumns:c&&a?"minmax(0, 1fr)":void 0,gridTemplateRows:c&&a?`${d&&l?"auto ":""}minmax(0, 1fr) auto`:void 0,overflowY:c&&a?"hidden":"auto",bg:b,color:v,borderRadius:"30px",css:{"&:popover-open":{display:c&&a?"grid":void 0},scrollbarWidth:"none","&::-webkit-scrollbar":{display:"none"},'& [role="option"]':io,'& details [role="option"]:first-child':{borderTopLeftRadius:"4px",borderTopRightRadius:"4px"},...xr(B,`var(--chakra-colors-${(C?x:"gray.300").replace(".","-")})`)},onKeyDown:I=>{var ne,oe,pe;if(a&&!["Escape","Tab"].includes(I.key))return;const ee=[...I.currentTarget.querySelectorAll('[role="option"]:not(:disabled), [data-flow-menu-action]:not(:disabled)')],ae=ee.indexOf(document.activeElement);if(["ArrowDown","ArrowUp","Home","End"].includes(I.key)){I.preventDefault();const q=I.key==="Home"?0:I.key==="End"?ee.length-1:(ae+(I.key==="ArrowDown"?1:-1)+ee.length)%ee.length;(ne=ee[q])==null||ne.focus()}else if(I.key==="Escape"||I.key==="Tab"){if(I.key==="Tab"&&l)return;I.key==="Escape"&&(I.preventDefault(),I.stopPropagation()),_(),(oe=R.current)==null||oe.focus()}else I.key.length===1&&I.key!==" "&&((pe=ee.find((q,F)=>{var G;return F>ae&&((G=q.textContent)==null?void 0:G.toLowerCase().startsWith(I.key.toLowerCase()))}))==null||pe.focus())},children:[d&&l&&f.jsx(nb,{label:m}),a??M.map(I=>f.jsxs(V.chakra.button,{type:"button",role:"option","aria-selected":I.value===r,disabled:I.disabled,tabIndex:-1,display:"flex",alignItems:"center",gap:3,px:3,py:2,w:"100%",fontSize:"sm",textAlign:"left",bg:"transparent",color:v,_hover:{bg:C?"whiteAlpha.100":"blackAlpha.50"},_focusVisible:{bg:C?"whiteAlpha.100":"blackAlpha.50"},onClick:()=>{var ee;l||(_(),(ee=R.current)==null||ee.focus()),t(I.value)},children:[f.jsx("span",{style:{flex:1},children:I.label}),f.jsx(Y.PiCheck,{size:16,color:`var(--chakra-colors-${v.replace(".","-")})`,"aria-hidden":"true",style:{flexShrink:0,visibility:I.value===r?"visible":"hidden"}})]},I.value)),c]})]})}const io={borderRadius:"4px","&:first-child":{borderTopLeftRadius:"22px",borderTopRightRadius:"22px"},"&:last-child":{borderBottomLeftRadius:"22px",borderBottomRightRadius:"22px"}},Oe=j.forwardRef(function({icon:r,rememberAction:t=!0,...n},o){const{colorMode:i}=Je(),s=Object.fromEntries(Object.entries(n).filter(([c])=>c!=="id"&&c!=="aria-describedby"&&!c.startsWith("data-")&&!/^on(Pointer|Mouse|Focus|Blur)/.test(c))),a=po(f.jsx(He,{label:n.title??n["aria-label"]??"Last used action",children:f.jsx(Oe,{...s,icon:r})}),t&&!!n.onClick);return f.jsx(V.IconButton,{ref:o,_hover:{bg:i==="dark"?"whiteAlpha.100":"blackAlpha.50"},title:n.title??n["aria-label"],...n,onClick:c=>{var l;a(),(l=n.onClick)==null||l.call(n,c)},children:r})}),nn=j.forwardRef(function(r,t){const{themeColor:n}=Je();return f.jsx(He,{label:"Close",children:f.jsx(Oe,{ref:t,size:"sm",variant:"plain",bg:"transparent",_hover:{bg:"transparent",color:n},color:n,focusRingColor:n,...r,"aria-label":r["aria-label"]??"Close selection tools",icon:f.jsx(Y.PiXLight,{size:20,"aria-hidden":"true"})})})});function ob({onBeforeExpand:e}={}){const{allNodesIconLabel:r,setAllNodesIconLabel:t}=Je();return f.jsx(Yr,{label:"Collapse all",hideLabel:!0,checked:r,icon:f.jsx(Y.PiArrowsInLineVertical,{size:20}),onChange:n=>{n||e==null||e(),t(n)}})}function Yr({label:e,icon:r,checked:t,onChange:n,disabled:o,hideLabel:i=!1,helper:s=e}){const{themeColor:a,readOnly:c}=Je(),{colorInactive:l}=lt();return f.jsx(He,{label:s,children:f.jsx(Oe,{"aria-label":e,"aria-pressed":t,icon:f.jsxs(f.Fragment,{children:[r,!i&&f.jsx(V.Text,{as:"span",fontSize:"16px",fontWeight:t?"bold":"normal",whiteSpace:"nowrap",children:e})]}),size:"sm",variant:"ghost",width:"auto",px:2,gap:2,color:t?a:l,disabled:o||c,onClick:()=>n(!t)})})}function ib({label:e="Compact layout"}={}){const{compactPropertyLayout:r,setCompactPropertyLayout:t,callbacks:n}=Je();return f.jsx(Yr,{hideLabel:!0,label:e,checked:r,icon:f.jsx(V.Icon,{as:Y.PiArrowsIn,boxSize:5}),onChange:o=>{var i;t(o),(i=n.onCompactPropertyLayoutChange)==null||i.call(n,o)}})}const fw=fo.default.input`
|
|
7
|
+
`;function Mm(e,r=!0,t="&:hover",n=!0){const o=`color-mix(in srgb, ${e} 60%, transparent)`,s=`0 0 0 ${r?8:0}px ${o}`,a=`0 0 0 8px ${o}`;return{boxShadow:s,css:{"--flow-rest-shadow":a,"--flow-hover-shadow":`0 0 0 18px ${o}`,"@media (hover: hover)":{[t]:{boxShadow:a,"@media (prefers-reduced-motion: no-preference)":{animation:n?`${Av} 1200ms steps(10, end) 600ms`:"none"}}}}}}function xr(e,r){const{boxShadow:t,css:n}=Mm(e,!1),o=n["@media (hover: hover)"]["&:hover"];return{borderWidth:"1px",borderStyle:"solid",borderColor:"transparent",boxShadow:t,...n,"--flow-start-shadow":t,"@media (hover: hover)":{"&:hover":{...o,borderColor:r,"@media (prefers-reduced-motion: no-preference)":{animation:`${Pv} 600ms steps(5, end)`}}}}}const Im=j.createContext(null),Tm=j.createContext({nodeById:new Map,edgeById:new Map,parentIds:new Set});function Kt(){return j.useContext(Tm)}function Ze(){const e=j.useContext(Im);if(!e)throw new Error("useFlowDiagramContext must be used within FlowDiagram");return e}function Nm({config:e,callbacks:r,nodes:t=[],edges:n=[],children:o}){var Be;const i=j.useMemo(()=>{var je,We,ot;const U=new Map;for(const Xe of t)(je=Xe.data)!=null&&je.id&&U.set(Xe.data.id,Xe);const Ce=new Map;for(const Xe of n)(We=Xe.data)!=null&&We.id&&Ce.set(Xe.data.id,Xe);const Oe=new Set;for(const Xe of t)(ot=Xe.data)!=null&&ot.parent&&Oe.add(Xe.data.parent);return{nodeById:U,edgeById:Ce,parentIds:Oe}},[t,n]),s=j.useRef(null),[a,c]=j.useState([]),[l,d]=j.useState(null),[u,h]=j.useState(!0),[p,m]=j.useState(!1),[g,y]=j.useState(!0),[b,x]=j.useState(!1),[v,w]=j.useState(!1),[C,S]=j.useState(!0),[R,P]=j.useState(!1),[k,T]=j.useState(()=>{var U;return(U=e.nodeGrid)!=null&&U.enabled?{...e.nodeGrid.options,...e.nodeGrid.order?{order:e.nodeGrid.order}:{}}:null}),E=j.useRef(k),[M,_]=j.useState(k??((Be=e.nodeGrid)==null?void 0:Be.options)??{gaps:15,fill:!1,padding:0}),[O,$]=j.useState(()=>new Set),B=j.useCallback(U=>{var Ce;!!(U!=null&&U.fill)!=!!((Ce=E.current)!=null&&Ce.fill)&&$(new Set),E.current=U,U&&_(U),T(U)},[]),[N,I]=j.useState("auto"),[ee,ae]=j.useState(!1),ne=e.compactPropertyLayout??ee,[oe,pe]=j.useState({}),q=e.nodeViewModes??oe,[F,G]=j.useState(e.allNodesIconLabel);j.useEffect(()=>G(e.allNodesIconLabel),[e.allNodesIconLabel]);const[D,ce]=j.useState({}),Q=j.useCallback((U,Ce)=>{ce(Oe=>{const je={...Oe};for(const We of U)Ce===void 0?delete je[We]:je[We]=Ce;return je})},[]),K=[...i.nodeById.values()].filter(U=>{var Ce;return i.parentIds.has(U.data.id)||((Ce=U.data.config)==null?void 0:Ce.parentContainer)||U.data.type==="objectView"||U.data.type==="arrayView"||U.data.type==="text"||U.data.type==="grid"}),ie=K.every(U=>{var Ce,Oe,je;return i.parentIds.has(U.data.id)||(Ce=U.data.config)!=null&&Ce.parentContainer?!!((Oe=U.data.config)!=null&&Oe.collapsed):q[U.data.id]==="icon-label"||U.data.type==="grid"&&q[U.data.id]===void 0||((je=U.data.config)==null?void 0:je.labelBelow)&&q[U.data.id]!=="properties"}),ye=F??e.allNodesIconLabel??ie,[we,he]=j.useState("normal"),[ge,X]=j.useState(),H=e.edgeRadius??ge,be=H!==void 0&&Number.isFinite(H)?Math.min(500,Math.max(0,H)):void 0,[J,xe]=j.useState(),Se=e.spacing??we,Fe=typeof Se=="number"?Number.isFinite(Se)?Math.min(2,Math.max(e.nodeGridSpacing==="layout"?0:.5,Se)):1:Se==="compact"?.5:Se==="spacious"?2:1,De=e.backgroundVariant??J??(e.backgroundPattern==="none"&&e.backgroundColor==="transparent"?"transparent":e.backgroundPattern??"dot"),[ue,Re]=j.useState(),ze=Object.prototype.hasOwnProperty.call(e,"workflowContract")?e.workflowContract:ue,[Te,qe]=j.useState("blue.500"),[Qe,ct]=j.useState(!1),Pe=j.useRef(r);Pe.current=r;const Je=j.useMemo(()=>{const U=Ce=>(...Oe)=>{var je,We;return(We=(je=Pe.current)==null?void 0:je[Ce])==null?void 0:We.call(je,...Oe)};return{onNodeSelect:U("onNodeSelect"),onNodesCopy:U("onNodesCopy"),onNodesDuplicate:U("onNodesDuplicate"),onBackgroundClick:U("onBackgroundClick"),onBottomBarCollapsedChange:U("onBottomBarCollapsedChange"),onNodeGridZoomOut:U("onNodeGridZoomOut"),onNodeGridFillRequest:U("onNodeGridFillRequest"),onNodeGridModeRequest:U("onNodeGridModeRequest"),onNodeGridDrop:U("onNodeGridDrop"),onNodeParentChange:U("onNodeParentChange"),onNodeDeselect:U("onNodeDeselect"),onNodeDoubleClick:U("onNodeDoubleClick"),onNodeViewToggle:U("onNodeViewToggle"),onNodeTypeViewChange:U("onNodeTypeViewChange"),onNodeCreate:U("onNodeCreate"),onNodeCreateRequest:U("onNodeCreateRequest"),onNodeDelete:U("onNodeDelete"),onNodeLabelChange:U("onNodeLabelChange"),onNodeSubtitleChange:U("onNodeSubtitleChange"),onNodeContentChange:U("onNodeContentChange"),onNodeDimensionChange:U("onNodeDimensionChange"),onNodeCollapse:U("onNodeCollapse"),onNodeColorChange:U("onNodeColorChange"),onNodeBorderColorChange:U("onNodeBorderColorChange"),onNodeBorderStyleChange:U("onNodeBorderStyleChange"),onNodeBorderWidthChange:U("onNodeBorderWidthChange"),onNodeBorderRadiusChange:(Ce,Oe)=>{var je,We,ot;(je=E.current)!=null&&je.fill&&$(Xe=>new Set([...Xe,Ce])),(ot=(We=Pe.current).onNodeBorderRadiusChange)==null||ot.call(We,Ce,Oe)},onNodeIconChange:U("onNodeIconChange"),onNodeOutlineChange:U("onNodeOutlineChange"),onNodeAnimationChange:U("onNodeAnimationChange"),onNodeAnimationVariantChange:U("onNodeAnimationVariantChange"),onEdgeAnimationVariantChange:U("onEdgeAnimationVariantChange"),onNodeHoverAction:U("onNodeHoverAction"),onEdgeCreate:U("onEdgeCreate"),onEdgeSelect:U("onEdgeSelect"),onEdgeDeselect:U("onEdgeDeselect"),onEdgeRemove:U("onEdgeRemove"),onEdgeDelete:U("onEdgeDelete"),onEdgeColorChange:U("onEdgeColorChange"),onEdgeTypeChange:U("onEdgeTypeChange"),onEdgeIconChange:U("onEdgeIconChange"),onEdgeLabelChange:U("onEdgeLabelChange"),onEdgeStyleChange:U("onEdgeStyleChange"),onViewportChange:U("onViewportChange"),onDirectionChange:U("onDirectionChange"),onThemeColorChange:U("onThemeColorChange"),onSpacingChange:U("onSpacingChange"),onEdgeRadiusChange:U("onEdgeRadiusChange"),onBackgroundVariantChange:U("onBackgroundVariantChange"),onEdgeModeChange:U("onEdgeModeChange"),onCompactPropertyLayoutChange:U("onCompactPropertyLayoutChange"),onWorkflowContractChange:U("onWorkflowContractChange"),onWorkflowConfigurationOpen:r.onWorkflowConfigurationOpen?U("onWorkflowConfigurationOpen"):void 0,onArrayModeChange:U("onArrayModeChange"),onInit:U("onInit"),onLayoutComplete:U("onLayoutComplete"),onJsonChange:U("onJsonChange")}},[]),Ye=e.themeColor||Te,[nt,Nt]=j.useState(""),Rt=e.edgeColor??nt,Wr=e.colorMode||"light",rt=e.direction||"LR",Ke=e.nodeAlignment??"center",Zt=e.edgeMode==="workflow"?"nodes":e.edgeMode??N,ft=e.readOnly??!1,jr=JSON.stringify(e.parentNodeStyle??null),Pt=j.useMemo(()=>e.parentNodeStyle,[jr]),Er=e.isZoomMode!==void 0?e.isZoomMode:u,Wt=e.isMultiSelectMode!==void 0?e.isMultiSelectMode:p,Xt=e.isEdgeHandlesEnabled!==void 0?e.isEdgeHandlesEnabled:b,ar=e.isDragMode!==void 0?e.isDragMode:g,Ve=j.useRef(e);Ve.current=e;const de=j.useMemo(()=>({get direction(){return Ve.current.direction},get nodeAlignment(){return Ve.current.nodeAlignment},get edgeMode(){return Ve.current.edgeMode},get compactPropertyLayout(){return Ve.current.compactPropertyLayout},get bottomBarCollapsed(){return Ve.current.bottomBarCollapsed},get bottomBarNavigation(){return Ve.current.bottomBarNavigation},get bottomBarFill(){return Ve.current.bottomBarFill},get bottomBarCollision(){return Ve.current.bottomBarCollision},get nodeGridConnections(){return Ve.current.nodeGridConnections},get nodeGrid(){return Ve.current.nodeGrid},get edgeType(){return Ve.current.edgeType},get edgeReveal(){return Ve.current.edgeReveal},get customEdgeTypes(){return Ve.current.customEdgeTypes},get themeColor(){return Ve.current.themeColor},get colorMode(){return Ve.current.colorMode},get readOnly(){return Ve.current.readOnly},get editable(){return Ve.current.editable},get minZoom(){return Ve.current.minZoom},get nodeGridSpacing(){return Ve.current.nodeGridSpacing},get maxZoom(){return Ve.current.maxZoom},get backgroundPattern(){return Ve.current.backgroundPattern},get edgeColor(){return Ve.current.edgeColor},get parentNodeStyle(){return Ve.current.parentNodeStyle},get backgroundColor(){return Ve.current.backgroundColor},get edgeHandles(){return Ve.current.edgeHandles},get initialViewport(){return Ve.current.initialViewport},get animateViewport(){return Ve.current.animateViewport},get disableAnimations(){return Ve.current.disableAnimations},get nodeOverlayActions(){return Ve.current.nodeOverlayActions},get renderNodeOverlay(){return Ve.current.renderNodeOverlay},get renderSelectedNodeToolbar(){return Ve.current.renderSelectedNodeToolbar},get renderSelectedEdgeToolbar(){return Ve.current.renderSelectedEdgeToolbar},get renderBottomBar(){return Ve.current.renderBottomBar},get bottomBarExtra(){return Ve.current.bottomBarExtra},get selectionToolbar(){return Ve.current.selectionToolbar},get customViews(){return Ve.current.customViews},get disableKeyboardShortcuts(){return Ve.current.disableKeyboardShortcuts},get isZoomMode(){return Ve.current.isZoomMode},get isMultiSelectMode(){return Ve.current.isMultiSelectMode},get isEdgeHandlesEnabled(){return Ve.current.isEdgeHandlesEnabled},get isDragMode(){return Ve.current.isDragMode}}),[]),V=j.useCallback((U,Ce)=>{var Oe;if(Ce!=="default"&&Ce!=="properties"&&Ce!=="icon-label")throw new Error("Unknown node view mode.");G(je=>je??ye),pe(je=>je[U]===Ce?je:{...je,[U]:Ce}),(Oe=r.onNodeViewModeChange)==null||Oe.call(r,U,Ce)},[r.onNodeViewModeChange,ye]),se=j.useMemo(()=>({allNodesIconLabel:ye,setAllNodesIconLabel:U=>{var Ce,Oe,je,We,ot;if(G(U),!U)for(const[Xe,St]of Object.entries(q))St==="icon-label"&&!i.nodeById.has(Xe)&&V(Xe,"default");for(const Xe of K)i.parentIds.has(Xe.data.id)||(Ce=Xe.data.config)!=null&&Ce.parentContainer?!ft&&!!((Oe=Xe.data.config)!=null&&Oe.collapsed)!==U&&((je=r.onNodeCollapse)==null||je.call(r,Xe.data.id,U)):V(Xe.data.id,U?"icon-label":(We=Xe.data.config)!=null&&We.labelBelow?"properties":"default");(ot=r.onAllNodesIconLabelChange)==null||ot.call(r,U)},nodeViewModes:q,setNodeViewMode:V,nodeRadiusPreviews:D,setNodeRadiusPreview:Q,spacing:Fe,setSpacing:he,edgeRadius:be,setEdgeRadius:X,backgroundVariant:De,setBackgroundVariant:xe,themeColor:Ye,setThemeColor:qe,backgroundSelected:Qe,setBackgroundSelected:ct,edgeColor:Rt,setEdgeColor:U=>{var Ce;Nt(U),(Ce=r.onGraphEdgeColorChange)==null||Ce.call(r,U)},colorMode:Wr,direction:rt,nodeAlignment:Ke,edgeMode:Zt,setEdgeMode:I,compactPropertyLayout:ne,setCompactPropertyLayout:ae,workflowContract:ze,setWorkflowContract:Re,parentNodeStyle:Pt,selectedNodeIds:a,setSelectedNodeIds:c,selectedEdgeId:l,setSelectedEdgeId:d,isZoomMode:Er,setIsZoomMode:h,isMultiSelectMode:Wt,setIsMultiSelectMode:m,isDragMode:ar,setIsDragMode:y,isEdgeHandlesEnabled:Xt,setIsEdgeHandlesEnabled:x,isArrayNodeMode:v,setIsArrayNodeMode:w,isPinned:C,setIsPinned:S,isPerformanceMode:R,setIsPerformanceMode:P,nodeGridOptions:k,setNodeGridOptions:B,lastNodeGridOptions:M,fillRadiusEditedIds:O,setFillRadiusEditedIds:$,engineRef:s,callbacks:Je,config:de,readOnly:ft}),[ye,i,V,r.onNodeCollapse,r.onAllNodesIconLabelChange,r.onGraphEdgeColorChange,q,r.onNodeViewModeChange,D,Q,Ye,Fe,De,be,e.backgroundColor,Qe,Rt,Wr,rt,Ke,Zt,ze,Pt,a,l,Er,Wt,ar,Xt,v,C,R,k,M,O,ft,e.edgeHandles,e.edgeType,e.edgeReveal,e.animateViewport,e.disableAnimations,e.customEdgeTypes,e.selectionToolbar,e.bottomBarExtra,e.bottomBarCollapsed,e.bottomBarNavigation,e.bottomBarFill,e.bottomBarCollision,e.nodeGridSpacing,e.nodeGridConnections,e.compactPropertyLayout,ne,Je,de]);return f.jsx(Im.Provider,{value:se,children:f.jsx(Tm.Provider,{value:i,children:o})})}function wt(e,r,t){return e?t:r}function Ln(e){const[r]=(e==null?void 0:e.split("."))||[],{secondary:t}=Pm(e),n=nr(r).background,o=nr(r).highlight,i=nr(r).border,s=nr(r).property,a=nr(r).property;let c=nr(r).background,l=nr(r).highlight;return c=e==="transparent"?e:Me(c)+50,l=e==="transparent"?e:Me(l)+20,{bgColor:n,highlightColor:o,borderColor:i,textColor:s,propertyColor:a,secondary:t,bgColorFaint:c,highlightColorFaint:l}}function lt(e=null){const{colorMode:r}=Ze(),t=e==null?void 0:e.includes("gray"),n=r==="dark",o=wt(n,"white","gray.900"),i=wt(n,"gray.100","gray.800"),s=wt(n,"gray.200","blackAlpha.400"),a=wt(n,"gray.200","blackAlpha.600"),c=wt(n,"gray.500","gray.700"),l=wt(n,"gray.700","gray.700"),d=wt(n,"gray.900","gray.900"),u=wt(n,"gray.400","gray.500"),h=wt(n,"gray.400","gray.500"),p=wt(n,"gray.900","gray.200"),m=wt(n,t?"gray.900":"gray.200",t?"gray.200":"gray.900"),g=wt(n,"gray.900","gray.200"),y=wt(n,e&&"#000000",e||"#ffffff"),b=wt(n,e||"#ffffff",e?"#000000":"#ffffff"),x=l,v=wt(n,"gray.300","gray.800"),w=wt(n,"white","blackAlpha.400"),C=wt(n,"green.100","green.700");return{canvas:o,background:i,backgroundSecondary:s,darkBackgroundSecondary:a,border:c,darkColor:d,backgroundWhiteColor:w,borderSecondary:l,colorActive:u,colorInactive:h,iconColor:g,moreIconColor:x,colorText:p,themedColorText:m,logoColor:y,logoColorSecondary:b,darkColorActive:v,greenColor:C}}var yn=(e=>(e.TOP_DOWN="TB",e.BOTTOM_UP="BT",e.LEFT_RIGHT="LR",e.RIGHT_LEFT="RL",e.CENTER="C",e))(yn||{});const Ed=["","icon-label","object","text","grid","parent"];var Mv=typeof global=="object"&&global&&global.Object===Object&&global,Iv=typeof self=="object"&&self&&self.Object===Object&&self,Tv=Mv||Iv||Function("return this")(),Zr=Tv.Symbol,Om=Object.prototype,Nv=Om.hasOwnProperty,Ov=Om.toString,pn=Zr?Zr.toStringTag:void 0;function $v(e){var r=Nv.call(e,pn),t=e[pn];try{e[pn]=void 0;var n=!0}catch{}var o=Ov.call(e);return n&&(r?e[pn]=t:delete e[pn]),o}var qv=Object.prototype,Lv=qv.toString;function Fv(e){return Lv.call(e)}var zv="[object Null]",Bv="[object Undefined]",Ru=Zr?Zr.toStringTag:void 0;function Dv(e){return e==null?e===void 0?Bv:zv:Ru&&Ru in Object(e)?$v(e):Fv(e)}function Wv(e){return e!=null&&typeof e=="object"}var Vv="[object Symbol]";function Gv(e){return typeof e=="symbol"||Wv(e)&&Dv(e)==Vv}function Uv(e,r){for(var t=-1,n=e==null?0:e.length,o=Array(n);++t<n;)o[t]=r(e[t],t,e);return o}var at=Array.isArray,ku=Zr?Zr.prototype:void 0,Au=ku?ku.toString:void 0;function $m(e){if(typeof e=="string")return e;if(at(e))return Uv(e,$m)+"";if(Gv(e))return Au?Au.call(e):"";var r=e+"";return r=="0"&&1/e==-1/0?"-0":r}function _d(e){return e==null?"":$m(e)}function Hv(e,r,t){var n=-1,o=e.length;r<0&&(r=-r>o?0:o+r),t=t>o?o:t,t<0&&(t+=o),o=r>t?0:t-r>>>0,r>>>=0;for(var i=Array(o);++n<o;)i[n]=e[n+r];return i}function Kv(e,r,t){var n=e.length;return t=t===void 0?n:t,!r&&t>=n?e:Hv(e,r,t)}var Jv="\\ud800-\\udfff",Zv="\\u0300-\\u036f",Xv="\\ufe20-\\ufe2f",Yv="\\u20d0-\\u20ff",Qv=Zv+Xv+Yv,e0="\\ufe0e\\ufe0f",t0="\\u200d",r0=RegExp("["+t0+Jv+Qv+e0+"]");function qm(e){return r0.test(e)}function n0(e){return e.split("")}var Lm="\\ud800-\\udfff",o0="\\u0300-\\u036f",i0="\\ufe20-\\ufe2f",a0="\\u20d0-\\u20ff",s0=o0+i0+a0,c0="\\ufe0e\\ufe0f",l0="["+Lm+"]",pd="["+s0+"]",gd="\\ud83c[\\udffb-\\udfff]",d0="(?:"+pd+"|"+gd+")",Fm="[^"+Lm+"]",zm="(?:\\ud83c[\\udde6-\\uddff]){2}",Bm="[\\ud800-\\udbff][\\udc00-\\udfff]",u0="\\u200d",Dm=d0+"?",Wm="["+c0+"]?",f0="(?:"+u0+"(?:"+[Fm,zm,Bm].join("|")+")"+Wm+Dm+")*",h0=Wm+Dm+f0,p0="(?:"+[Fm+pd+"?",pd,zm,Bm,l0].join("|")+")",g0=RegExp(gd+"(?="+gd+")|"+p0+h0,"g");function y0(e){return e.match(g0)||[]}function m0(e){return qm(e)?y0(e):n0(e)}function b0(e){return function(r){r=_d(r);var t=qm(r)?m0(r):void 0,n=t?t[0]:r.charAt(0),o=t?Kv(t,1).join(""):r.slice(1);return n[e]()+o}}var x0=b0("toUpperCase");function v0(e,r,t,n){for(var o=-1,i=e==null?0:e.length;++o<i;)t=r(t,e[o],o,e);return t}function w0(e){return function(r){return e==null?void 0:e[r]}}var C0={À:"A",Á:"A",Â:"A",Ã:"A",Ä:"A",Å:"A",à:"a",á:"a",â:"a",ã:"a",ä:"a",å:"a",Ç:"C",ç:"c",Ð:"D",ð:"d",È:"E",É:"E",Ê:"E",Ë:"E",è:"e",é:"e",ê:"e",ë:"e",Ì:"I",Í:"I",Î:"I",Ï:"I",ì:"i",í:"i",î:"i",ï:"i",Ñ:"N",ñ:"n",Ò:"O",Ó:"O",Ô:"O",Õ:"O",Ö:"O",Ø:"O",ò:"o",ó:"o",ô:"o",õ:"o",ö:"o",ø:"o",Ù:"U",Ú:"U",Û:"U",Ü:"U",ù:"u",ú:"u",û:"u",ü:"u",Ý:"Y",ý:"y",ÿ:"y",Æ:"Ae",æ:"ae",Þ:"Th",þ:"th",ß:"ss",Ā:"A",Ă:"A",Ą:"A",ā:"a",ă:"a",ą:"a",Ć:"C",Ĉ:"C",Ċ:"C",Č:"C",ć:"c",ĉ:"c",ċ:"c",č:"c",Ď:"D",Đ:"D",ď:"d",đ:"d",Ē:"E",Ĕ:"E",Ė:"E",Ę:"E",Ě:"E",ē:"e",ĕ:"e",ė:"e",ę:"e",ě:"e",Ĝ:"G",Ğ:"G",Ġ:"G",Ģ:"G",ĝ:"g",ğ:"g",ġ:"g",ģ:"g",Ĥ:"H",Ħ:"H",ĥ:"h",ħ:"h",Ĩ:"I",Ī:"I",Ĭ:"I",Į:"I",İ:"I",ĩ:"i",ī:"i",ĭ:"i",į:"i",ı:"i",Ĵ:"J",ĵ:"j",Ķ:"K",ķ:"k",ĸ:"k",Ĺ:"L",Ļ:"L",Ľ:"L",Ŀ:"L",Ł:"L",ĺ:"l",ļ:"l",ľ:"l",ŀ:"l",ł:"l",Ń:"N",Ņ:"N",Ň:"N",Ŋ:"N",ń:"n",ņ:"n",ň:"n",ŋ:"n",Ō:"O",Ŏ:"O",Ő:"O",ō:"o",ŏ:"o",ő:"o",Ŕ:"R",Ŗ:"R",Ř:"R",ŕ:"r",ŗ:"r",ř:"r",Ś:"S",Ŝ:"S",Ş:"S",Š:"S",ś:"s",ŝ:"s",ş:"s",š:"s",Ţ:"T",Ť:"T",Ŧ:"T",ţ:"t",ť:"t",ŧ:"t",Ũ:"U",Ū:"U",Ŭ:"U",Ů:"U",Ű:"U",Ų:"U",ũ:"u",ū:"u",ŭ:"u",ů:"u",ű:"u",ų:"u",Ŵ:"W",ŵ:"w",Ŷ:"Y",ŷ:"y",Ÿ:"Y",Ź:"Z",Ż:"Z",Ž:"Z",ź:"z",ż:"z",ž:"z",IJ:"IJ",ij:"ij",Œ:"Oe",œ:"oe",ʼn:"'n",ſ:"s"},S0=w0(C0),j0=/[\xc0-\xd6\xd8-\xf6\xf8-\xff\u0100-\u017f]/g,E0="\\u0300-\\u036f",_0="\\ufe20-\\ufe2f",R0="\\u20d0-\\u20ff",k0=E0+_0+R0,A0="["+k0+"]",P0=RegExp(A0,"g");function M0(e){return e=_d(e),e&&e.replace(j0,S0).replace(P0,"")}var I0=/[^\x00-\x2f\x3a-\x40\x5b-\x60\x7b-\x7f]+/g;function T0(e){return e.match(I0)||[]}var N0=/[a-z][A-Z]|[A-Z]{2}[a-z]|[0-9][a-zA-Z]|[a-zA-Z][0-9]|[^a-zA-Z0-9 ]/;function O0(e){return N0.test(e)}var Vm="\\ud800-\\udfff",$0="\\u0300-\\u036f",q0="\\ufe20-\\ufe2f",L0="\\u20d0-\\u20ff",F0=$0+q0+L0,Gm="\\u2700-\\u27bf",Um="a-z\\xdf-\\xf6\\xf8-\\xff",z0="\\xac\\xb1\\xd7\\xf7",B0="\\x00-\\x2f\\x3a-\\x40\\x5b-\\x60\\x7b-\\xbf",D0="\\u2000-\\u206f",W0=" \\t\\x0b\\f\\xa0\\ufeff\\n\\r\\u2028\\u2029\\u1680\\u180e\\u2000\\u2001\\u2002\\u2003\\u2004\\u2005\\u2006\\u2007\\u2008\\u2009\\u200a\\u202f\\u205f\\u3000",Hm="A-Z\\xc0-\\xd6\\xd8-\\xde",V0="\\ufe0e\\ufe0f",Km=z0+B0+D0+W0,Jm="['’]",Pu="["+Km+"]",G0="["+F0+"]",Zm="\\d+",U0="["+Gm+"]",Xm="["+Um+"]",Ym="[^"+Vm+Km+Zm+Gm+Um+Hm+"]",H0="\\ud83c[\\udffb-\\udfff]",K0="(?:"+G0+"|"+H0+")",J0="[^"+Vm+"]",Qm="(?:\\ud83c[\\udde6-\\uddff]){2}",eb="[\\ud800-\\udbff][\\udc00-\\udfff]",Vr="["+Hm+"]",Z0="\\u200d",Mu="(?:"+Xm+"|"+Ym+")",X0="(?:"+Vr+"|"+Ym+")",Iu="(?:"+Jm+"(?:d|ll|m|re|s|t|ve))?",Tu="(?:"+Jm+"(?:D|LL|M|RE|S|T|VE))?",tb=K0+"?",rb="["+V0+"]?",Y0="(?:"+Z0+"(?:"+[J0,Qm,eb].join("|")+")"+rb+tb+")*",Q0="\\d*(?:1st|2nd|3rd|(?![123])\\dth)(?=\\b|[A-Z_])",ew="\\d*(?:1ST|2ND|3RD|(?![123])\\dTH)(?=\\b|[a-z_])",tw=rb+tb+Y0,rw="(?:"+[U0,Qm,eb].join("|")+")"+tw,nw=RegExp([Vr+"?"+Xm+"+"+Iu+"(?="+[Pu,Vr,"$"].join("|")+")",X0+"+"+Tu+"(?="+[Pu,Vr+Mu,"$"].join("|")+")",Vr+"?"+Mu+"+"+Iu,Vr+"+"+Tu,ew,Q0,Zm,rw].join("|"),"g");function ow(e){return e.match(nw)||[]}function iw(e,r,t){return e=_d(e),r=r,r===void 0?O0(e)?ow(e):T0(e):e.match(r)||[]}var aw="['’]",sw=RegExp(aw,"g");function cw(e){return function(r){return v0(iw(M0(r).replace(sw,"")),e,"")}}var Ft=cw(function(e,r,t){return e+(t?" ":"")+x0(r)});function nb({label:e,disabled:r=!1}){const t=j.useRef(null),n=j.useRef(),{colorInactive:o}=lt(),i=()=>{var c;return(c=t.current)==null?void 0:c.closest("[data-flow-floating-panel]")},s=(c,l)=>{const d=i();if(!d)return;const u=d.getBoundingClientRect();d.style.left=`${Math.max(12,Math.min(c,window.innerWidth-u.width-12))}px`,d.style.top=`${Math.max(12,Math.min(l,window.innerHeight-u.height-12))}px`,d.style.right="auto",d.style.bottom="auto",d.dataset.flowPanelMoved="true"},a=(c=!1)=>{var d;const l=n.current;l&&(c&&s(l.left,l.top),n.current=void 0,(d=t.current)!=null&&d.hasPointerCapture(l.pointerId)&&t.current.releasePointerCapture(l.pointerId),t.current&&(t.current.style.cursor=""))};return j.useEffect(()=>{const c=()=>{const u=i();if(!(u!=null&&u.dataset.flowPanelMoved))return;const h=u.getBoundingClientRect();s(h.left,h.top)},l=u=>{u.key!=="Escape"||!n.current||(u.preventDefault(),u.stopPropagation(),a(!0))},d=()=>a(!0);return window.addEventListener("resize",c),window.addEventListener("keydown",l,!0),window.addEventListener("blur",d),()=>{window.removeEventListener("resize",c),window.removeEventListener("keydown",l,!0),window.removeEventListener("blur",d),a()}},[]),f.jsx(W.chakra.button,{ref:t,type:"button","aria-label":`Drag ${e}`,title:r?"Pin to drag":`Drag ${e}`,disabled:r,"data-panel-drag-handle":"",display:"flex",alignItems:"center",justifyContent:"center",width:"64px",height:"24px",flexShrink:0,marginInline:"auto",border:0,background:"transparent",color:o,cursor:"grab",touchAction:"none",userSelect:"none",_disabled:{opacity:.35,cursor:"default"},onPointerDown:c=>{var d;if(c.button!==0||n.current)return;const l=(d=i())==null?void 0:d.getBoundingClientRect();l&&(c.preventDefault(),c.stopPropagation(),n.current={pointerId:c.pointerId,x:c.clientX,y:c.clientY,left:l.left,top:l.top},c.currentTarget.setPointerCapture(c.pointerId),c.currentTarget.style.cursor="grabbing")},onPointerMove:c=>{const l=n.current;!l||l.pointerId!==c.pointerId||(c.stopPropagation(),s(l.left+c.clientX-l.x,l.top+c.clientY-l.y))},onPointerUp:c=>{var l;((l=n.current)==null?void 0:l.pointerId)===c.pointerId&&a()},onPointerCancel:()=>a(!0),onLostPointerCapture:()=>a(),onKeyDown:c=>{var u;const l=(u=i())==null?void 0:u.getBoundingClientRect();if(!l||!["ArrowLeft","ArrowRight","ArrowUp","ArrowDown"].includes(c.key))return;c.preventDefault(),c.stopPropagation();const d=c.shiftKey?40:10;s(l.left+(c.key==="ArrowLeft"?-d:c.key==="ArrowRight"?d:0),l.top+(c.key==="ArrowUp"?-d:c.key==="ArrowDown"?d:0))},children:f.jsx(Y.PiDotsSix,{size:20,"aria-hidden":"true"})})}function lw(){let e,r=null;const t=new Set,n=o=>{r=o,t.forEach(i=>i())};return{subscribe:o=>(t.add(o),()=>{t.delete(o)}),getSnapshot:()=>r,select(o,i){e=o,n(i)},update(o,i){e===o&&n(i)},remove(o){e===o&&(e=void 0,n(null))}}}const Xr=j.createContext(null),dw=()=>j.useState(lw)[0];function po(e,r=!0){const t=j.useContext(Xr),n=j.useId();return j.useEffect(()=>{r?t==null||t.update(n,e):t==null||t.remove(n)}),j.useEffect(()=>()=>t==null?void 0:t.remove(n),[t,n]),()=>{r&&(t==null||t.select(n,e))}}function uw({divider:e,visibleActions:r=[]}){const t=j.useContext(Xr),n=j.useSyncExternalStore(t.subscribe,t.getSnapshot,()=>null),o=n&&r.includes(n.props["aria-label"]??"");return f.jsx(Xr.Provider,{value:null,children:f.jsxs("span",{"data-recent-toolbar-action":"",style:{display:n&&!o?"contents":"none"},children:[n&&!o&&e,!o&&n]})})}function He({label:e,children:r}){const t=j.cloneElement(r,{title:r.props.title??e});if(!W.Tooltip.Root){const n=W.Tooltip;return f.jsx(n,{label:e,placement:"top",fontSize:"xs",borderRadius:"15px",children:t})}return f.jsxs(W.Tooltip.Root,{positioning:{placement:"top"},children:[f.jsx(W.Tooltip.Trigger,{asChild:!0,children:t}),f.jsx(W.Portal,{children:f.jsx(W.Tooltip.Positioner,{children:f.jsx(W.Tooltip.Content,{fontSize:"xs",borderRadius:"15px",children:e})})})]})}function Sn(){const{border:e}=lt(),{colorMode:r}=Ze();return f.jsx(W.chakra.span,{role:"separator","aria-orientation":"vertical",display:"block",flexShrink:0,w:"1px",h:"20px",mx:"4px",bg:r==="dark"?e:"gray.300"})}function Mt({children:e,value:r,onValueChange:t,disabled:n,style:o,title:i,icon:s,popupContent:a,footer:c,pinned:l=!1,draggable:d=!1,open:u,onOpenChange:h,labelCase:p="title","aria-label":m,...g}){var N;const{colorMode:y}=Ze(),{background:b,border:x,colorText:v,colorInactive:w}=lt(),C=y==="dark",S=j.useId(),R=j.useRef(null),P=j.useRef(null),[k,T]=j.useState(!1),E=po(f.jsx(Mt,{value:r,onValueChange:t,disabled:n,style:o,title:i,icon:s,popupContent:a,footer:c,pinned:l,draggable:d,labelCase:p,"aria-label":m,children:e}),!!s);j.useLayoutEffect(()=>{const I=P.current,ee=I.matches(":popover-open"),ae=document.activeElement instanceof HTMLElement&&I.contains(document.activeElement)?document.activeElement:null,ne=[I,...I.querySelectorAll("*")].filter(q=>q.scrollTop||q.scrollLeft).map(q=>({element:q,top:q.scrollTop,left:q.scrollLeft})),oe=l?"manual":"auto";if(I.getAttribute("popover")!==oe&&I.setAttribute("popover",oe),ee){I.showPopover(),!l&&I.dataset.flowPanelMoved&&(delete I.dataset.flowPanelMoved,O()),ae==null||ae.focus({preventScroll:!0});for(const{element:q,top:F,left:G}of ne)q.scrollTop=F,q.scrollLeft=G}const pe=q=>{const F=q.newState==="open";T(F),h==null||h(F)};return I.addEventListener("toggle",pe),()=>I.removeEventListener("toggle",pe)},[l,h]);const M=j.Children.toArray(e).filter(j.isValidElement).map(I=>{const ee=I.props;return{value:String(ee.value),label:typeof ee.children=="string"&&p==="title"?Ft(ee.children):ee.children,disabled:ee.disabled}}),_=()=>{var I;return(I=P.current)==null?void 0:I.hidePopover()},O=()=>{var pe,q,F,G,D;const I=(pe=R.current)==null?void 0:pe.getBoundingClientRect(),ee=P.current;if(!I||!ee||l&&ee.dataset.flowPanelMoved)return;if((q=R.current)!=null&&q.closest("[popover]")){const ce=window.innerHeight-I.bottom-16,Q=I.top-16;ee.style.maxHeight=`${Math.max(60,ce,Q)}px`;const K=ee.getBoundingClientRect();ee.style.left=`${Math.max(12,Math.min(I.right-K.width,window.innerWidth-K.width-12))}px`,ee.style.top=`${Math.max(12,K.height<=ce?I.bottom+4:I.top-K.height-4)}px`;return}const ae=(D=(G=(F=R.current)==null?void 0:F.closest("[data-flow-toolbar-scroll]"))==null?void 0:G.parentElement)==null?void 0:D.getBoundingClientRect(),ne=ae??I;ee.style.maxHeight=`${Math.max(60,Math.max(ne.top-40,window.innerHeight-ne.bottom-40))}px`;const oe=ee.getBoundingClientRect();ee.style.left=`${Math.max(12,Math.min(Math.max((ae==null?void 0:ae.left)??12,I.right-oe.width),((ae==null?void 0:ae.right)??window.innerWidth-12)-oe.width,window.innerWidth-oe.width-12))}px`,ee.style.top=`${Math.max(12,ne.top>=oe.height+36?ne.top-oe.height-24:Math.min(ne.bottom+24,window.innerHeight-oe.height-12))}px`},$=()=>{var ae,ne,oe,pe,q,F;if(n)return;if(P.current&&!P.current.matches(":popover-open")&&delete P.current.dataset.flowPanelMoved,(ae=P.current)==null||ae.showPopover(),O(),a){(oe=(ne=P.current)==null?void 0:ne.querySelector("input"))==null||oe.focus({preventScroll:!0});return}const I=(pe=P.current)==null?void 0:pe.querySelectorAll('[role="option"]:not(:disabled)');(F=((q=P.current)==null?void 0:q.querySelector('[aria-selected="true"]:not(:disabled)'))??(I==null?void 0:I[0]))==null||F.focus()};j.useLayoutEffect(()=>{u!==void 0&&(u?$():_())},[u]),j.useEffect(()=>{if(k){if(n){_();return}return window.addEventListener("resize",O),window.addEventListener("scroll",O,!0),()=>{window.removeEventListener("resize",O),window.removeEventListener("scroll",O,!0)}}},[k,n,l]);const B=`var(--chakra-colors-${b.replace(".","-")})`;return f.jsxs(f.Fragment,{children:[f.jsx(He,{label:i??m,children:f.jsx(W.chakra.button,{...g,ref:R,type:"button",role:"combobox","data-flow-select-icon":s?"":void 0,"aria-label":m,title:i??m,"aria-haspopup":a?"dialog":"listbox","aria-expanded":k,"aria-controls":S,disabled:n,h:"30px",w:"160px",px:"6px",fontSize:"12px",border:"none",borderRadius:"4px",bg:"transparent",color:s?w:v,display:"flex",alignItems:"center",justifyContent:s?"center":"space-between",gap:2,style:o,onClick:()=>{E(),k?_():$()},onKeyDown:I=>{["ArrowDown","ArrowUp"].includes(I.key)&&(I.preventDefault(),$())},children:s??f.jsxs(f.Fragment,{children:[f.jsx("span",{style:{overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:((N=M.find(I=>I.value===r))==null?void 0:N.label)??r}),f.jsx(Y.PiCaretUp,{size:16,style:{flexShrink:0}})]})})}),f.jsxs(W.chakra.div,{ref:P,id:S,"data-flow-select-pinned":l?"":void 0,"data-flow-floating-panel":d&&l?"":void 0,role:a?"dialog":"listbox","aria-label":m,position:"fixed",m:0,p:2,minW:"180px",maxW:"calc(100vw - 24px)",gridTemplateColumns:c&&a?"minmax(0, 1fr)":void 0,gridTemplateRows:c&&a?`${d&&l?"auto ":""}minmax(0, 1fr) auto`:void 0,overflowY:c&&a?"hidden":"auto",bg:b,color:v,borderRadius:"30px",css:{"&:popover-open":{display:c&&a?"grid":void 0},scrollbarWidth:"none","&::-webkit-scrollbar":{display:"none"},'& [role="option"]':io,'& details [role="option"]:first-child':{borderTopLeftRadius:"4px",borderTopRightRadius:"4px"},...xr(B,`var(--chakra-colors-${(C?x:"gray.300").replace(".","-")})`)},onKeyDown:I=>{var ne,oe,pe;if(a&&!["Escape","Tab"].includes(I.key))return;const ee=[...I.currentTarget.querySelectorAll('[role="option"]:not(:disabled), [data-flow-menu-action]:not(:disabled)')],ae=ee.indexOf(document.activeElement);if(["ArrowDown","ArrowUp","Home","End"].includes(I.key)){I.preventDefault();const q=I.key==="Home"?0:I.key==="End"?ee.length-1:(ae+(I.key==="ArrowDown"?1:-1)+ee.length)%ee.length;(ne=ee[q])==null||ne.focus()}else if(I.key==="Escape"||I.key==="Tab"){if(I.key==="Tab"&&l)return;I.key==="Escape"&&(I.preventDefault(),I.stopPropagation()),_(),(oe=R.current)==null||oe.focus()}else I.key.length===1&&I.key!==" "&&((pe=ee.find((q,F)=>{var G;return F>ae&&((G=q.textContent)==null?void 0:G.toLowerCase().startsWith(I.key.toLowerCase()))}))==null||pe.focus())},children:[d&&l&&f.jsx(nb,{label:m}),a??M.map(I=>f.jsxs(W.chakra.button,{type:"button",role:"option","aria-selected":I.value===r,disabled:I.disabled,tabIndex:-1,display:"flex",alignItems:"center",gap:3,px:3,py:2,w:"100%",fontSize:"sm",textAlign:"left",bg:"transparent",color:v,_hover:{bg:C?"whiteAlpha.100":"blackAlpha.50"},_focusVisible:{bg:C?"whiteAlpha.100":"blackAlpha.50"},onClick:()=>{var ee;l||(_(),(ee=R.current)==null||ee.focus()),t(I.value)},children:[f.jsx("span",{style:{flex:1},children:I.label}),f.jsx(Y.PiCheck,{size:16,color:`var(--chakra-colors-${v.replace(".","-")})`,"aria-hidden":"true",style:{flexShrink:0,visibility:I.value===r?"visible":"hidden"}})]},I.value)),c]})]})}const io={borderRadius:"4px","&:first-child":{borderTopLeftRadius:"22px",borderTopRightRadius:"22px"},"&:last-child":{borderBottomLeftRadius:"22px",borderBottomRightRadius:"22px"}},Ne=j.forwardRef(function({icon:r,rememberAction:t=!0,...n},o){const{colorMode:i}=Ze(),s=Object.fromEntries(Object.entries(n).filter(([c])=>c!=="id"&&c!=="aria-describedby"&&!c.startsWith("data-")&&!/^on(Pointer|Mouse|Focus|Blur)/.test(c))),a=po(f.jsx(He,{label:n.title??n["aria-label"]??"Last used action",children:f.jsx(Ne,{...s,icon:r})}),t&&!!n.onClick);return f.jsx(W.IconButton,{ref:o,_hover:{bg:i==="dark"?"whiteAlpha.100":"blackAlpha.50"},title:n.title??n["aria-label"],...n,onClick:c=>{var l;a(),(l=n.onClick)==null||l.call(n,c)},children:r})}),nn=j.forwardRef(function(r,t){const{themeColor:n}=Ze();return f.jsx(He,{label:"Close",children:f.jsx(Ne,{ref:t,size:"sm",variant:"plain",bg:"transparent",_hover:{bg:"transparent",color:n},color:n,focusRingColor:n,...r,"aria-label":r["aria-label"]??"Close selection tools",icon:f.jsx(Y.PiXLight,{size:20,"aria-hidden":"true"})})})});function ob({onBeforeExpand:e}={}){const{allNodesIconLabel:r,setAllNodesIconLabel:t}=Ze();return f.jsx(Yr,{label:"Collapse all",hideLabel:!0,checked:r,icon:f.jsx(Y.PiArrowsInLineVertical,{size:20}),onChange:n=>{n||e==null||e(),t(n)}})}function Yr({label:e,icon:r,checked:t,onChange:n,disabled:o,hideLabel:i=!1,helper:s=e}){const{themeColor:a,readOnly:c}=Ze(),{colorInactive:l}=lt();return f.jsx(He,{label:s,children:f.jsx(Ne,{"aria-label":e,"aria-pressed":t,icon:f.jsxs(f.Fragment,{children:[r,!i&&f.jsx(W.Text,{as:"span",fontSize:"16px",fontWeight:t?"bold":"normal",whiteSpace:"nowrap",children:e})]}),size:"sm",variant:"ghost",width:"auto",px:2,gap:2,color:t?a:l,disabled:o||c,onClick:()=>n(!t)})})}function ib({label:e="Compact layout"}={}){const{compactPropertyLayout:r,setCompactPropertyLayout:t,callbacks:n}=Ze();return f.jsx(Yr,{hideLabel:!0,label:e,checked:r,icon:f.jsx(W.Icon,{as:Y.PiArrowsIn,boxSize:5}),onChange:o=>{var i;t(o),(i=n.onCompactPropertyLayoutChange)==null||i.call(n,o)}})}const fw=fo.default.input`
|
|
8
8
|
appearance: none;
|
|
9
9
|
width: 100%;
|
|
10
10
|
height: 24px;
|
|
@@ -55,7 +55,7 @@
|
|
|
55
55
|
cursor: default;
|
|
56
56
|
opacity: 0.5;
|
|
57
57
|
}
|
|
58
|
-
`,Rd=j.forwardRef(function({style:r,...t},n){return f.jsx(fw,{...t,ref:n,style:{...r,backgroundImage:"none","--flow-range-track":(r==null?void 0:r.backgroundImage)??"none"}})});function yd({label:e,inputLabel:r,value:t,displayValue:n,min:o,max:i,step:s=5,onChange:a,onChangeEnd:c}){const l=j.useId(),{readOnly:d,themeColor:u}=Je(),{colorInactive:h}=lt(),p=(t-o)/(i-o)*100,m=u.includes(".")?`var(--chakra-colors-${u.replace(".","-")})`:u;return f.jsxs("div",{style:{width:224,maxWidth:"calc(100vw - 64px)",padding:12},children:[f.jsxs("label",{htmlFor:l,style:{display:"flex",justifyContent:"space-between",fontSize:14,marginBottom:12},children:[e," ",f.jsx("span",{children:n})]}),f.jsx(Rd,{id:l,"aria-label":r,type:"range",min:o,max:i,step:s,value:t,disabled:d,style:{color:m,accentColor:m,backgroundImage:`linear-gradient(to right, currentColor ${p}%, var(--chakra-colors-${h.replace(".","-")}) ${p}%)`},onChange:g=>a(Number(g.target.value)),onPointerUp:c,onKeyUp:c,onBlur:c})]})}const Ou={dot:{label:"Dots",icon:Y.PiDotsNine},grid:{label:"Grid",icon:Y.PiGridFour},steel:{label:"Steel",icon:Y.PiLineSegments},none:{label:"Solid",icon:Y.PiSquareFill},transparent:{label:"Transparent",icon:Y.PiSelection}};function ab(){const{spacing:e,setSpacing:r,edgeRadius:t,setEdgeRadius:n,backgroundVariant:o,setBackgroundVariant:i,callbacks:s,readOnly:a,config:c}=Je(),l=Ou[o].icon;return f.jsxs(f.Fragment,{children:[f.jsx(Sn,{}),f.jsx(Mt,{"aria-label":"Node spacing",title:`Spacing: ${Math.round(e*100)}%`,icon:f.jsx(Y.PiArrowsOutCardinal,{size:20}),style:{width:36},value:"spacing",disabled:a,onValueChange:()=>{},popupContent:f.jsx(yd,{label:"Spacing",inputLabel:"Node spacing percentage",min:c.nodeGridSpacing==="layout"?0:50,max:200,value:Math.round(e*100),displayValue:`${Math.round(e*100)}%`,onChange:d=>{var u;r(d/100),(u=s.onSpacingChange)==null||u.call(s,d/100)}}),children:f.jsx("option",{value:"spacing",children:"Spacing"})}),f.jsx(Sn,{}),f.jsx(Mt,{"aria-label":"Edge radius",title:`Edge radius: ${t??"Default"}`,icon:f.jsx(Y.PiBezierCurve,{size:20}),style:{width:36},value:"radius",disabled:a,onValueChange:()=>{},popupContent:f.jsx(yd,{label:"Edge radius",inputLabel:"Edge corner radius",min:0,max:500,value:t??500,displayValue:t??"Default",onChange:d=>{var u;n(d),(u=s.onEdgeRadiusChange)==null||u.call(s,d)}}),children:f.jsx("option",{value:"radius",children:"Edge radius"})}),f.jsx(Sn,{}),f.jsxs(Mt,{"aria-label":"Background variant",title:`Background: ${Ou[o].label}`,icon:f.jsx(l,{size:20,"data-background-icon":o}),style:{width:36},value:o,disabled:a,onValueChange:d=>{var u;i(d),(u=s.onBackgroundVariantChange)==null||u.call(s,d)},children:[f.jsx("option",{value:"dot",children:"Dots"}),f.jsx("option",{value:"grid",children:"Grid"}),f.jsx("option",{value:"steel",children:"Steel"}),f.jsx("option",{value:"none",children:"Solid"}),f.jsx("option",{value:"transparent",children:"Transparent"})]})]})}function sb(){var o;const{engineRef:e,nodeGridOptions:r,readOnly:t}=Je(),n=!!(r!=null&&r.fill);return f.jsx(Yr,{label:"Grid adjustment",hideLabel:!0,helper:n?"Grid adjustment":"Enable Collision and Fill to adjust the Grid",icon:f.jsx(Y.PiArrowsHorizontal,{size:20}),checked:n&&!!((o=r==null?void 0:r.adjustment)!=null&&o.enabled),disabled:!n,onChange:i=>{var s;t||!(r!=null&&r.fill)||(s=e.current)==null||s.setNodeGridMode(!0,{...r,adjustment:{...r.adjustment,enabled:i}})}})}function to({fillOnly:e=!1}={}){const{engineRef:r,nodeGridOptions:t,lastNodeGridOptions:n,readOnly:o,themeColor:i,callbacks:s,config:a}=Je(),{colorText:c,colorInactive:l}=lt(),d=t??n,u=typeof d.gaps=="object"?d.gaps.x:d.gaps??d.margin??15,h=Math.max(200,u),p=m=>{var g;return(g=r.current)==null?void 0:g.setNodeGridMode(!0,{...d,...m})};return f.jsxs(f.Fragment,{children:[!e&&a.bottomBarCollision!==!1&&f.jsx(Yr,{label:"Collision mode",hideLabel:!0,icon:f.jsx(Y.PiGridFour,{size:20}),checked:t!==null,onChange:m=>{var g,y;((g=s.onNodeGridModeRequest)==null?void 0:g.call(s,m,d))!==!0&&((y=r.current)==null||y.setNodeGridMode(m,d))}}),(t||a.bottomBarFill===!0)&&f.jsxs(V.HStack,{role:"group","aria-label":"Collision settings",gap:2,flexShrink:0,children:[!e&&t&&a.nodeGridSpacing!=="layout"&&f.jsxs(f.Fragment,{children:[f.jsx(V.Box,{width:"96px",flexShrink:0,display:"flex",alignItems:"center",children:f.jsx(Rd,{type:"range","aria-label":"Collision gap",title:`Gap: ${u}`,min:0,max:h,step:5,value:u,disabled:o,style:{color:Me(i),backgroundImage:`linear-gradient(to right, currentColor ${u/h*100}%, ${Me(l)} ${u/h*100}%)`},onChange:m=>p({gaps:Number(m.target.value)})})}),f.jsx(V.Text,{fontSize:"xs",color:c,width:"28px",textAlign:"right",fontVariantNumeric:"tabular-nums",children:u})]}),a.bottomBarFill!==!1&&f.jsx(Yr,{label:"Fill",hideLabel:!0,helper:t?"Fill available canvas space":"Enable Collision mode to use Fill",icon:f.jsx(Y.PiArrowsOut,{size:18}),checked:!!t&&!!d.fill,disabled:!t,onChange:m=>{var g,y;!t&&((g=s.onNodeGridModeRequest)==null?void 0:g.call(s,!0,{...d,fill:m}))===!0||m&&((y=s.onNodeGridFillRequest)==null?void 0:y.call(s,{...d,fill:m}))===!0||p({fill:m})}}),!e&&t&&d.fill&&f.jsx(sb,{})]})]})}const Ct=[];for(let e=0;e<256;++e)Ct.push((e+256).toString(16).slice(1));function hw(e,r=0){return(Ct[e[r+0]]+Ct[e[r+1]]+Ct[e[r+2]]+Ct[e[r+3]]+"-"+Ct[e[r+4]]+Ct[e[r+5]]+"-"+Ct[e[r+6]]+Ct[e[r+7]]+"-"+Ct[e[r+8]]+Ct[e[r+9]]+"-"+Ct[e[r+10]]+Ct[e[r+11]]+Ct[e[r+12]]+Ct[e[r+13]]+Ct[e[r+14]]+Ct[e[r+15]]).toLowerCase()}let Go;const pw=new Uint8Array(16);function gw(){if(!Go){if(typeof crypto>"u"||!crypto.getRandomValues)throw new Error("crypto.getRandomValues() not supported. See https://github.com/uuidjs/uuid#getrandomvalues-not-supported");Go=crypto.getRandomValues.bind(crypto)}return Go(pw)}const yw=typeof crypto<"u"&&crypto.randomUUID&&crypto.randomUUID.bind(crypto),Nu={randomUUID:yw};function kd(e,r,t){var o;if(Nu.randomUUID&&!e)return Nu.randomUUID();e=e||{};const n=e.random??((o=e.rng)==null?void 0:o.call(e))??gw();if(n.length<16)throw new Error("Random bytes length must be >= 16");return n[6]=n[6]&15|64,n[8]=n[8]&63|128,hw(n)}function mw(e,r){let t=1e5;const n=new Set(["__proto__","prototype","constructor"]),o=new Map,i=(c,l,d)=>{if(--t<0||d>100)throw new Error("Content references exceed the expansion limit.");if(!c||typeof c!="object")return c;if(Object.prototype.hasOwnProperty.call(c,"$contentRef")){const p=c,m=p.$contentRef,g=p.path??[];if(typeof m!="string"||!/^root(?:\.[A-Za-z0-9_%~-]+)*$/.test(m)||m.split(".").some(v=>n.has(v))||!Array.isArray(g)||g.some(v=>typeof v=="number"?!Number.isSafeInteger(v)||v<0:typeof v!="string"||n.has(v))||p.prefix!==void 0&&typeof p.prefix!="string"||p.suffix!==void 0&&typeof p.suffix!="string"||Object.keys(p).some(v=>!["$contentRef","path","prefix","suffix"].includes(v)))throw new Error("Invalid content reference.");const y=JSON.stringify([m,g]);if(l.includes(y))throw new Error(`Circular content reference: ${m}.`);if(!o.has(m)){const v=r(m);o.set(m,typeof v=="string"?JSON.parse(v):v)}let b=o.get(m);for(const v of g)b=b&&typeof b=="object"&&Object.prototype.hasOwnProperty.call(b,v)?b[v]:void 0;if(b===void 0)throw new Error(`Content reference not found: ${m}.`);const x=i(b,[...l,y],d+1);if(p.prefix!==void 0||p.suffix!==void 0){if(typeof x!="string")throw new Error("Content reference formatting requires a string.");return`${p.prefix??""}${x}${p.suffix??""}`}return x}if(Array.isArray(c)){const p=c.map(m=>i(m,l,d+1));return p.some((m,g)=>m!==c[g])?p:c}const u={...c};let h=!1;for(const[p,m]of Object.entries(c)){if(n.has(p))throw new Error("Unsafe content property.");const g=i(m,l,d+1);u[p]=g,h||(h=g!==m)}return h?u:c},s=typeof e=="string"?JSON.parse(e):e,a=i(s,[],0);return a===s?e:a}const go={label:"Untitled",description:"",isTask:!1,isLocked:!1},Ad={id:null,type:"text",data:{...go,viewProps:{width:"max-content !important",maxWidth:700,height:"100%",borderColor:"transparent",borderRadius:25,borderWidth:0,boxShadow:"none",textOverflow:"ellipsis",fontWeight:"bold",textColor:"gray.800",textAlign:"center"}}},$u={id:null,type:"objectView",data:{...go,headerTitle:null,viewProps:{width:"100%",borderWidth:2,borderRadius:53,height:"100%",justifyContent:"space-between",flexDirection:"row",textColor:"gray.900"}}},bw={id:null,type:"arrayView",data:{...go,viewProps:{width:"max-content !important",maxWidth:700,height:"100%",textAlign:"center",borderRadius:25,fontSize:"5xl",borderWidth:2,textOverflow:"ellipsis",wordBreak:"keep-all",fontWeight:"bold",textColor:"gray.900",placeholder:"Start Typing"}}},qu={id:null,type:"workflowStep",data:{...go,viewProps:{width:"max-content !important",maxWidth:350,minWidth:280,height:"100%",borderRadius:15,borderWidth:3}}},It=e=>typeof e=="object",cb=e=>Array.isArray(e),xw=["order","position","selected","locked","grabbed","grabbable","scratch"],vr=e=>Object.entries(e).reduce((r,[t,n])=>(!It(n)&&!t.startsWith("$")&&(r[t]=n),r),{}),Pd=(e,r)=>typeof e=="string"&&e.startsWith("$")?Uo(e,r):It(e)&&!cb(e)?Object.entries(e).reduce((t,[n,o])=>(typeof o=="string"&&o.startsWith("$")&&n==="..."?(delete t["..."],t[n]={...Uo(o,r),...e}):typeof o=="string"&&o.startsWith("$")?t[n]=Uo(o,r):t[n]=o,t),{}):e,wr=e=>Object.entries(e).reduce((r,[t,n])=>(It(n)&&t&&n&&!t.startsWith("$")&&(xw.includes(t)&&(t=t+"#"),r[t]=n),r),{}),Tr=(e,r,{label:t,parent:n=void 0},o,i=null)=>(i!==null&&(It(i)||cb(i))&&(i=JSON.stringify(i,null,2)),{data:{parent:n,...e.data,id:r,text:t||"",label:t,code:i||null,type:e.type,description:o}}),yr=(e,r,t=null,n=null,o=null,i=!1,s=null)=>({data:{id:kd(),source:o?r:e,target:o?e:r,label:n||"",isInverted:o,isEdgeAnimated:i,parent:s}}),Cr=(e,r=[])=>{const t={},n={};let o=[];if(e)for(const[i,s]of Object.entries(e))i.startsWith("$")&&i!=="$"?t[i.slice(1)]=s:i!=="$"?n[i]=s:i==="$"&&(o=s);return{newConfig:t,updatedObject:n,arrayObject:o}},Gr=(e,r)=>{let t=$u;const{view:n,borderColor:o,borderRadius:i,bgColor:s,textColor:a,fontSize:c,stepType:l}=r;e=n||e,l?t={...qu}:e==="object"?t=$u:e==="text"?t=Ad:e==="array"?t=bw:e==="workflowStep"&&(t={...qu});const d=t.data.viewProps;return t.data.viewProps={...d,borderRadius:i||(l?15:53),bgColor:s,borderColor:o,textColor:a,fontSize:c},t.data.config=r,{config:t}},In=(e,r)=>(e=r.find(n=>n.data.id===e)?`${e}.#`:e,e),Uo=(e,{ids:r,jsnObjct:t})=>{if(typeof e=="string"&&(e!=null&&e.startsWith("$"))){const n=e.replace("$","").replace("*","");e==null||e.endsWith("*");const o=r.find(a=>a.split(".").slice(-1)[0]===n||n===a);if(!o)return e;const i=vw(o,t);return JSON.stringify(i).includes(e)?e:i||e}return e},vw=(e,r)=>{let t=e.split(".").splice(1);return t=t[t.length-1]==="#"||t[t.length-1].includes("{")?t.slice(0,-2):t,(i=>t.reduce((s,a)=>{a=a.replace("[","").replace("]","");const{arrayObject:c}=Cr(s);return s=c.length?c:s,s[a]},i))(r)};function Hr(e,r="root",t=[]){try{const{arrayObject:n}=Cr(e);n.length&&(e=n);const o=vr(e),i=wr(e);return It(e)?(it(e)||it(e)&&r==="root"||!it(e)&&Object.keys(o).length||r==="root")&&t.push(r):t.push(r),Object.keys(i).length&&!it(e)?jn({chldPth:null,itrblObjct:i,nodes:t,path:r}):it(e)&&e.forEach((s,a)=>{const c=vr(s),l=wr(s),{newConfig:d,arrayObject:u}=Cr(s);let h=`${r}.${a}`;It(s)?Object.keys(c).length?(Hr(c,h,t),Object.keys(l).length&&!it(s)&&jn({chldPth:h,itrblObjct:l,nodes:t,path:r})):Object.keys(l).length&&!it(s)?jn({chldPth:h,itrblObjct:l,nodes:t,path:r}):it(s)&&lb({chldPth:h,item:s,nodes:t,path:r}):t.push(h)}),{nodes:t}}catch{return{nodes:t}}}const jn=({chldPth:e,itrblObjct:r,nodes:t,path:n})=>Object.entries(r).forEach(([o,i],s)=>{const a=vr(i),c=wr(i),{newConfig:l,arrayObject:d}=Cr(i);d.length&&(i=d),n.split(".").slice(0,2).join(".");let u=e?`${e}.${o}`:`${n}.${o}`;if(It(i)&&!it(i)){const h=Object.keys(a).length===0;if(h&&(Gr("array",l),t.push(u)),Object.keys(a).length){const p=it(i)?`${i.length||""}`:`{${Object.keys(i).length||""}}`;let m=u;h&&(m=`${u}.${p}`),Hr(i,m,t)}else Object.keys(c).length&&!it(i)?jn({chldPth:u,itrblObjct:c,path:u,nodes:t}):Hr(i,u,t)}else it(i)&&Hr(i,u,t)}),lb=({chldPth:e,item:r,nodes:t,path:n})=>r.forEach((o,i)=>{let s=`${e}.${i}`;const a=wr(o),c=vr(o);It(o)?!it(o)&&Object.keys(c).length?Hr(o,s,t):Object.keys(a).length&&!it(o)?jn({chldPth:s,itrblObjct:a,path:n,nodes:t}):it(o)&&lb({chldPth:s,item:o,nodes:t,path:n}):t.push(s)}),En=[];let _n;function $r(e,r="root",t=[],n=[],o="untitled",i={hideDefaultObject:!1,sprtObjctKy:!1,isCntr:!1},s={}){if(!e||typeof e!="object")return console.error("Invalid object passed",e),{nodes:t,edges:n};const a=e;if(r==="root"&&(En.length=0),!_n){const{nodes:d}=Hr(e);_n={ids:d,jsnObjct:e}}let{hideDefaultObject:c,sprtObjctKy:l}=i;try{r=In(r,t);const{newConfig:d,arrayObject:u}=Cr(e),h=Object.keys(s).length>0?s:d;u.length&&(e=u);const p=vr(e),m=wr(e),{label:g,collapsed:y,parent:b}=h;if(!It(e))t.push(Tr(Ad,r,{label:g||r,parent:b},e,a));else if(it(e)||it(e)&&r==="root"){const{config:x}=Gr("array",h),v=it(e)?`${e.length||""}`:`{${Object.keys(e).length||""}}`,w=r==="root"?o:`${o} ${v}`;t.push(Tr(x,r,{label:g||w,parent:b},e,it(a)?{[o]:a}:a))}else if(!it(e)&&Object.keys(p).length||r==="root"){const{config:x}=Gr(null,h),v=it(e)?`${e.length||""}`:`{${Object.keys(e).length||""}}`,w=r.split("."),C=w[w.length-1];let S=isNaN(Number(C))?null:Number(C)+1;const R=isNaN(Number(C))?C:w[w.length-2]+" "+S,P=r==="root"?o:R;let k=!1;Number.isNaN(Number(o))||(k=!0);const T=e;if(g){const{config:E}=Gr("object",h);t.push(Tr(E,r,{label:g||`${g} ${v}`,parent:b},p,T))}else x.data.headerTitle=P,t.push(Tr(x,r,{label:g,parent:b},p,T))}return y||(Object.keys(m).length&&!it(e)?Rn({flowConfig:i,chldPth:null,edges:n,isInverted:null,itrblObjct:m,nodes:t,path:r,newConfig:h}):it(e)&&e.forEach((x,v)=>{x=Pd(x,_n);const w=x,C=vr(x),S=wr(x),{newConfig:R,arrayObject:P}=Cr(x);P.length&&(x=P);const{config:k}=Gr(typeof x=="string"?"text":"array",R),{hideConfig:T,sourceLabel:E,label:M,isEdgeAnimated:_,parent:N}=R;c=c||T;const $=r==="root"&&i.isCntr,B=r.split(".").slice(0,2).join("."),O=En.includes(B),I=i.isCntr&&O||v%2===0&&$;let ee=`${r}.${v}`;ee=In(ee,t),I&&En.push(ee),It(x)?Object.keys(C).length&&!it(x)?(n.push(yr(r,ee,null,E,I,_)),$r(x,ee,t,n,M||v,i,R)):Object.keys(S).length&&!it(x)?Rn({flowConfig:i,chldPth:ee,isInverted:I,edges:n,itrblObjct:S,nodes:t,path:r,newConfig:R,forceIsInverted:!0}):it(x)?db({flowConfig:i,chldPth:ee,edges:n,isInverted:I,item:x,nodes:t,path:r}):It(x)&&Rn({flowConfig:i,chldPth:ee,isInverted:I,edges:n,itrblObjct:[x],nodes:t,path:r,newConfig:R}):(n.push(yr(r,ee,null,E,I,_)),t.push(Tr(k,ee,{label:M||String(x),parent:N},x,w)))})),{nodes:t,edges:n}}catch{return{nodes:t,edges:n}}}const Rn=({chldPth:e,flowConfig:r,edges:t,itrblObjct:n,nodes:o,isInverted:i,path:s,newConfig:a,forceIsInverted:c=!1})=>{let{hideDefaultObject:l,sprtObjctKy:d}=r;return Object.entries(n).forEach(([u,h],p)=>{h=Pd(h,_n);const m=h,g=vr(h),y=wr(h),{newConfig:b,arrayObject:x}=Cr(h);x.length&&(h=x);const{hideConfig:v,sourceLabel:w,label:C,content:S,target:R,targetLabel:P,collapsed:k,isEdgeAnimated:T,parent:E}=b;l=l||v;const M=s==="root"&&r.isCntr,_=s.split(".").slice(0,2).join("."),N=En.includes(_);c||(i=r.isCntr&&N||p%2===0&&M);let $=e?`${e}.${u}`:`${s}.${u}`;if($=In($,o),i&&En.push($),R&&t.push(yr($,R,null,P,i,T)),It(h)&&!it(h)){t.push(yr(s,$,null,w,i,T));const B=d||Object.keys(g).length===0;if(B){const O=S?"object":"array",{config:I}=Gr(O,b);I.data.headerTitle=S?C:null,o.push(Tr(I,$,{label:C||u,parent:E},h,m))}if(Object.keys(g).length&&!l){const O=it(h)?` ${h.length||""}`:`{${Object.keys(h).length||""}}`;let I=$;B&&(I=`${$}.${O}`,I=In(I,o),t.push(yr($,I,null,w,i,T))),$r(h,I,o,t,C||u,r,b)}else Object.keys(y).length&&!it(h)?Rn({chldPth:$,flowConfig:r,itrblObjct:y,path:$,edges:t,nodes:o,newConfig:b,isInverted:i}):$r(h,$,o,t,u,r,b)}else it(h)&&(t.push(yr(s,$,null,w,i,T)),$r(h,$,o,t,u,r,b))})},db=({flowConfig:e,chldPth:r,edges:t,isInverted:n,item:o,nodes:i,path:s})=>o.forEach((a,c)=>{let l=`${r}.${c}`;l=In(l,i);const d=a;a=Pd(a,_n);const u=wr(a),h=vr(a),{newConfig:p}=Cr(a),{collapsed:m,label:g,parent:y,sourceLabel:b,isEdgeAnimated:x,content:v}=p;It(a)?!it(a)&&Object.keys(h).length?(t.push(yr(s,l,null,b,n,x)),$r(a,l,i,t,c,e,p)):Object.keys(u).length&&!it(a)&&!m?Rn({chldPth:l,flowConfig:e,itrblObjct:u,path:s,edges:t,nodes:i,isInverted:n,newConfig:p}):it(a)&&db({flowConfig:e,chldPth:l,edges:t,isInverted:n,item:a,nodes:i,path:s}):(t.push(yr(s,l,null,b,n,x)),i.push(Tr(Ad,l,{label:g||String(a),parent:y},a,d)))});function ww(e,r){const t=new Set,n=(l,d="root")=>{if(!(!l||typeof l!="object")){l.$view==="parent"&&t.add(d),typeof l.$parent=="string"&&t.add(l.$parent);for(const[u,h]of Object.entries(l))(!u.startsWith("$")||u==="$")&&n(h,u==="$"?d:`${d}.${u}`)}};if(n(e),!t.size)return r;const o=new Map(r.nodes.map(l=>[l.data.id,l])),i=l=>{var p,m;let d=l.data.id;const u=new Set([l.data.id]);let h=l.data.parent;for(;h&&!u.has(h);)t.has(h)&&o.has(h)&&((p=Le(e,h))!=null&&p.$collapsed)&&(d=h),u.add(h),h=(m=o.get(h))==null?void 0:m.data.parent;return d},s=new Map(r.nodes.map(l=>[l.data.id,i(l)])),a=r.nodes.filter(l=>s.get(l.data.id)===l.data.id).map(l=>{if(!t.has(l.data.id))return l;const d=Le(e,l.data.id),u=!!(d!=null&&d.$collapsed);return{...l,data:{...l.data,...u?{type:"arrayView"}:{},config:{...l.data.config,parentContainer:!0,collapsed:u,...u?{labelBelow:!0,icon:(d==null?void 0:d.$icon)||"PiStack"}:{}}}}}),c=new Set(a.map(l=>l.data.id));return{nodes:a,edges:r.edges.flatMap(l=>{const d=s.get(l.data.source),u=s.get(l.data.target);return!d||!u||!c.has(d)||!c.has(u)?[]:d===l.data.source&&u===l.data.target?[l]:d===u?[]:[{...l,data:{...l.data,source:d,target:u,collapsedEndpoints:l.data.collapsedEndpoints??{source:l.data.source,target:l.data.target}}}]})}}function yo(e){if(!Array.isArray(e==null?void 0:e.$connections))return[];const r=new Map;return e.$connections.flatMap((t,n)=>{if(!t||typeof t!="object")return[];const o=t;if(typeof o.target!="string"||!/^root(?:\.|$)/.test(o.target))return[];if(o.sourceProperty!==void 0&&typeof o.sourceProperty!="string")return[];if(o.targetProperty!==void 0&&typeof o.targetProperty!="string")return[];const i=typeof o.id=="string"&&o.id?JSON.stringify(["id",o.id]):JSON.stringify(["ports",o.target,o.sourceProperty??null,o.targetProperty??null]),s=r.get(i)??0;return r.set(i,s+1),[{value:o,key:`${i}#${s}`,index:n}]})}function ub(e,r,t){const n=yo(e).find(c=>c.key===r);if(!n)return e;const o=t(n.value),i=e.$connections.flatMap((c,l)=>l===n.index?o?[o]:[]:[c]);if(i.length)return{...e,$connections:i};const{$connections:s,...a}=e;return a}function Cw(e){const r=[],t=(n,o)=>{if(!n||typeof n!="object")return n;if(Array.isArray(n))return n.map((i,s)=>t(i,`${o}.${s}`));for(const i of yo(n)){const s=i.value;r.push({data:{id:`connection:${JSON.stringify([o,i.key])}`,source:o,target:s.target,type:typeof s.type=="string"?s.type:void 0,sourceProperty:s.sourceProperty,targetProperty:s.targetProperty,icon:typeof s.icon=="string"?s.icon:void 0,label:typeof s.label=="string"?s.label:void 0,color:typeof s.color=="string"?s.color:void 0,isEdgeDashed:s.style==="dashed",isEdgeAnimated:s.style==="animated",...["dashed","traveling"].includes(s.animationVariant)?{edgeAnimationVariant:s.animationVariant}:{},connection:{address:o,key:i.key}}})}return Object.fromEntries(Object.entries(n).filter(([i])=>i!=="$connections").map(([i,s])=>[i,i==="$"?t(s,o):i.startsWith("$")?s:t(s,`${o}.${i}`)]))};return{json:t(e,"root"),edges:r}}const Kr="root",Lu=e=>e==="#"||e.startsWith("{")||/^\s\d*$/.test(e);function Gt(e){const r=e.split(".");for(r[0]===Kr&&r.shift();r.length&&Lu(r[r.length-1]);)r.pop();return r.filter(t=>!Lu(t))}function mo(e){return e==null||typeof e!="object"?e:Array.isArray(e.$)?e.$:e}function Le(e,r){return Gt(r).reduce((t,n)=>{var o;if(t!=null)return(o=mo(t))==null?void 0:o[n]},e)}function Sw(e){return Array.isArray(e)?[...e]:{...e}}function _t(e,r,t){const n=Gt(r),o=(i,s)=>{if(s===n.length)return t(i);const a=n[s],c=mo(i);if(c==null||typeof c!="object")return i;const l=o(c[a],s+1);if(Object.is(l,c[a]))return i;const d=Sw(c);return d[a]=l,c!==i?{...i,$:d}:d};return o(e,0)}function cr(e,r,t){const n=t===""&&r!=="$content"||t===void 0||t===null;if(Array.isArray(e))return n?e:{[r]:t,$:[...e]};const o=e!=null&&typeof e=="object"?{...e}:{};return e!=null&&typeof e!="object"&&(o.$label=String(e)),n?delete o[r]:o[r]=t,o}function xt(e,r,t,n){return _t(e,r,o=>t==="$label"&&typeof o=="string"&&typeof n=="string"&&n!==""?n:cr(o,t,n))}const Md=(e,r,t)=>xt(e,r,"$collapsed",t);function Or(e){if(e.connection)return{address:e.connection.address,kind:"connection"};const r=e.collapsedEndpoints??e,t=e.isInverted?r.target:r.source,n=e.isInverted?r.source:r.target,o=Gt(t).join("."),i=Gt(n).join(".");return i.startsWith(o?o+".":"")&&i!==o?{address:n,kind:"hierarchy"}:o.startsWith(i?i+".":"")&&o!==i?{address:t,kind:"hierarchy"}:{address:t,kind:"target"}}function gr(e,r,t,n){if(r.connection){const a=r.connection;return _t(e,a.address,c=>ub(c,a.key,l=>{if(t==="$edgeIcon")return cr(l,"icon",n);if(t==="$edgeType")return cr(l,"type",n);if(t==="$edgeAnimationVariant")return cr(l,"animationVariant",n);if(t==="$sourceLabel"||t==="$edgeColor")return cr(l,t==="$sourceLabel"?"label":"color",n);const d=t==="$isEdgeAnimated"?"animated":"dashed";return n?{...l,style:d}:l.style===d?cr(l,"style",void 0):l}))}const{address:o,kind:i}=Or(r),s=i==="target"&&t==="$sourceLabel"?"$targetLabel":i==="target"&&t==="$edgeType"?"$targetEdgeType":i==="target"&&t==="$edgeIcon"?"$targetIcon":i==="target"&&t==="$edgeAnimationVariant"?"$targetAnimationVariant":t;return _t(e,o,a=>cr(a,s,n))}const fb=(e,r,t)=>gr(gr(e,r,"$isEdgeAnimated",t==="animated"||void 0),r,"$isEdgeDashed",t==="dashed"||void 0);function Id(e,r,t,n){let o=n||"";const i=_t(e,r,a=>{const c=mo(a);if(Array.isArray(c)){o=String(c.length);const d=[...c,t];return c===a?d:{...a,$:d}}const l=a!=null&&typeof a=="object"&&!Array.isArray(a)?{...a}:a!=null&&typeof a!="object"?{$label:String(a)}:{};if(!o){let d=1;for(;`node_${d}`in l;)d++;o=`node_${d}`}return l[o]=t,l}),s=Gt(r);return{json:i,address:[Kr,...s,o].join(".")}}function hb(e,r){const t=Gt(r);if(!t.length)return e;const n=t[t.length-1],o=[Kr,...t.slice(0,-1)].join(".");return _t(e,o,i=>{const s=mo(i);if(s==null||typeof s!="object"||!Object.prototype.hasOwnProperty.call(s,n))return i;if(Array.isArray(s)){const l=s.filter((d,u)=>String(u)!==n);return s===i?l:{...i,$:l}}const{[n]:a,...c}=i;return c})}const pb=(e,r,t,n)=>xt(n?_t(e,r,o=>cr(o,"$targetLabel",n)):e,r,"$target",t);function Td(e,r,t){const n=Le(e,r);return yo(n).some(({value:i})=>i.target===t.target&&i.sourceProperty===t.sourceProperty&&i.targetProperty===t.targetProperty)?e:_t(e,r,i=>cr(i,"$connections",[...Array.isArray(i==null?void 0:i.$connections)?i.$connections:[],{...t,id:t.id||kd()}]))}function gb(e,r){if(r.connection){const i=r.connection;return yo(Le(e,i.address)).some(s=>s.key===i.key)?{json:_t(e,i.address,s=>ub(s,i.key,()=>null)),removed:!0}:{json:e,removed:!1}}const{address:t,kind:n}=Or(r);return n==="hierarchy"?Le(e,t)===void 0?{json:e,removed:!1}:{json:_t(e,t,i=>({...i,$hideParentEdge:!0})),removed:!0}:n!=="target"?{json:e,removed:!1}:{json:_t(e,t,i=>{const{$target:s,$targetLabel:a,...c}=i||{};return c}),removed:!0}}function md(e,r={}){var x;const t=Cw(e),{nodes:n,edges:o}=$r(t.json,Kr,[],[],r.title||"untitled",{hideDefaultObject:!!r.hideDefaultObject,sprtObjctKy:!!r.separateObjectKeys,isCntr:!!r.isCenter}),i=new Set(n.map(v=>v.data.id)),s=new Map;for(const v of n){const w=v.data.id;if(!w.endsWith(".0")||Le(e,w)!==void 0)continue;const C=w.slice(0,-2),S=Le(e,C);!i.has(C)&&S&&typeof S=="object"&&!Array.isArray(S)&&typeof S.$label=="string"&&Object.keys(S).every(R=>R.startsWith("$")&&R!=="$")&&s.set(w,C)}const a=v=>s.get(v)??v,c=new Set(n.flatMap(v=>v.data.parent?[a(v.data.parent)]:[])),l=new Map;if(r.isCenter){const v=new Map;for(const{data:w}of o){const C=Or(w);if(C.kind==="hierarchy")l.set(a(C.address),!!w.isInverted);else if(!Array.isArray(e)&&e.$hideRoot===!0){const S=a(w.isInverted?w.source:w.target);if(Gt(S).length!==1)continue;const R=!!w.isInverted;v.set(S,v.has(S)&&v.get(S)!==R?null:R)}}for(const[w]of l){const C=`${Kr}.${Gt(w)[0]}`,S=v.get(C);typeof S=="boolean"&&l.set(w,S)}}const d=n.map(v=>{var k;const w=a(v.data.id),C=Le(e,w),S={...v.data,id:w};l.has(w)&&(S.config={...S.config,isInverted:l.get(w)});const R=C&&typeof C=="object"&&!Array.isArray(C)&&"$"in C?C.$:C;if((Array.isArray(R)?R.length>0:R&&typeof R=="object"&&Object.keys(R).some(T=>!T.startsWith("$")))&&(S.config={...S.config,collapsed:!!C.$collapsed}),c.has(w)||(S.viewProps={...S.viewProps},delete S.viewProps.borderWidth),!C||typeof C!="object"||Array.isArray(C))return{data:S};if(C.$view==="parent"&&(S.type="objectView",S.config={...S.config,typeView:"parent",parentContainer:!0,collapsed:!!C.$collapsed}),C.$view==="grid"){S.type="grid";const T=C.$gridSize;if(T!==void 0&&(!T||![T.width,T.height].every(E=>Number.isFinite(E)&&E>0&&E<=16384)))throw new Error("Invalid grid frame size.");S.config={...S.config,typeView:"grid",documentId:C.$document,gridSize:T},S.viewProps={...S.viewProps,bgColor:C.$bgColor??"transparent",borderRadius:C.$borderRadius??0,borderWidth:C.$borderWidth??0}}if(C.$form&&typeof C.$form=="object"&&(S.config={...S.config,form:C.$form},S.type="objectView"),Array.isArray(C.$ports)){const T=C.$ports.filter(E=>E&&typeof E.id=="string"&&["source","target"].includes(E.role)&&["top","right","bottom","left"].includes(E.side));S.config={...S.config,ports:T}}S.parent&&(S.parent=a(S.parent)),typeof C.$label=="string"&&(S.label=C.$label,S.headerTitle=C.$label),typeof C.$subtitle=="string"&&(S.config={...S.config,subtitle:C.$subtitle}),typeof C.$outline=="boolean"&&(S.viewProps={...S.viewProps,outline:C.$outline}),["solid","dashed","dotted","double"].includes(C.$borderStyle)&&(S.viewProps={...S.viewProps,borderStyle:C.$borderStyle}),Number.isFinite(C.$borderWidth)&&C.$borderWidth>=0&&(S.viewProps={...S.viewProps,borderWidth:C.$borderWidth}),Number.isFinite(C.$borderRadius)&&C.$borderRadius>=0&&(S.viewProps={...S.viewProps,borderRadius:C.$borderRadius});for(const T of["width","height"]){const E=C[`$${T}`];typeof E=="number"&&Number.isFinite(E)&&E>0&&(S.viewProps={...S.viewProps,[T]:`${E}px`})}if(typeof C.$isNodeAnimated=="boolean"&&(S.isNodeAnimated=C.$isNodeAnimated),["traveling","pulse"].includes(C.$nodeAnimationVariant)&&(S.nodeAnimationVariant=C.$nodeAnimationVariant),typeof C.$content=="string"||C.$contentFormat==="jsx"&&Array.isArray(C.$content)){S.config={...S.config,content:C.$content};const T=C.$contentFormat??"markdown";if(!["markdown","html","jsx"].includes(T))throw new Error("Invalid content format: expected markdown, html, or jsx.");if(S.config.contentFormat=T,T==="jsx")try{const E=mw(C.$content,M=>{const _=Le(e,M);return(_==null?void 0:_.$contentFormat)==="jsx"?_.$content:void 0});E!==C.$content&&(S.config.contentSource=C.$content,S.config.content=E)}catch(E){S.config.contentSource=C.$content,S.config.content=[],S.config.contentReferenceError=E instanceof Error?E.message:"Invalid content reference."}C.$view||(S.type="objectView")}return(((k=S.config)==null?void 0:k.collapsed)!==void 0||C.$collapsed!==void 0||C.$icon!==void 0)&&(S.config={...S.config||{}},(C.$collapsed!==void 0||S.config.collapsed!==void 0)&&(S.config.collapsed=!!C.$collapsed),C.$icon!==void 0&&(S.config.icon=C.$icon)),{data:S}}),u=new Map,h=o.map(v=>{let w=a(v.data.source),C=a(v.data.target),S=v.data.isInverted;const R=Or(v.data),P=l.get(a(R.address));R.kind==="hierarchy"&&P!==void 0&&P!==!!S&&([w,C]=[C,w],S=P);const k=`${w}->${C}`,T=u.get(k)??0;u.set(k,T+1);const E={...v.data,id:T?`${k}#${T}`:k,source:w,target:C,isInverted:S},M=Or(E),_=Le(e,M.address);if(_&&typeof _=="object"){const N=_[M.kind==="target"?"$targetEdgeType":"$edgeType"];typeof N=="string"&&(E.type=N);const $=_[M.kind==="target"?"$targetIcon":"$edgeIcon"];typeof $=="string"&&(E.icon=$),_.$isEdgeAnimated!==void 0&&(E.isEdgeAnimated=!!_.$isEdgeAnimated);const B=_[M.kind==="target"?"$targetAnimationVariant":"$edgeAnimationVariant"];["dashed","traveling"].includes(B)&&(E.edgeAnimationVariant=B),_.$isEdgeDashed!==void 0&&(E.isEdgeDashed=!!_.$isEdgeDashed),_.$edgeColor&&(E.color=_.$edgeColor)}return{data:E}});if(!Array.isArray(e)&&(e==null?void 0:e.$hideRoot)===!0){const v=d.findIndex(w=>w.data.id===Kr);v!==-1&&d.splice(v,1)}const p=new Set(d.map(v=>v.data.id));for(let v=h.length-1;v>=0;v--){const w=h[v].data,C=Or(w);(!p.has(w.source)||!p.has(w.target)||C.kind==="hierarchy"&&((x=Le(e,C.address))==null?void 0:x.$hideParentEdge)===!0)&&h.splice(v,1)}h.push(...t.edges.filter(v=>p.has(v.data.source)&&p.has(v.data.target)));const m=ww(e,{nodes:d,edges:h}),g=m.nodes.filter(v=>{var w;return(w=v.data.config)==null?void 0:w.collapsed}).map(v=>Gt(v.data.id));if(!g.length)return m;const y=m.nodes.filter(v=>{const w=Gt(v.data.id);return!g.some(C=>C.length<w.length&&C.every((S,R)=>S===w[R]))}),b=new Set(y.map(v=>v.data.id));return{nodes:y,edges:m.edges.filter(v=>b.has(v.data.source)&&b.has(v.data.target))}}function jw(e,r){const t=new Set(e.filter(c=>{var l,d;return(d=(l=c.data)==null?void 0:l.config)==null?void 0:d.collapsed}).map(c=>c.data.id));if(!t.size)return{nodes:e,edges:r};const n=new Map(e.map(c=>[c.data.id,c])),o=new Set(e.map(c=>c.data.parent).filter(Boolean)),i=new Map(e.map(c=>{var h;let l=c.data.id,d=c.data.parent;const u=new Set([l]);for(;d&&!u.has(d);)t.has(d)&&(l=d),u.add(d),d=(h=n.get(d))==null?void 0:h.data.parent;return[c.data.id,l]})),s=new Map;for(const c of r){const l=c.data.isInverted?c.data.target:c.data.source,d=c.data.isInverted?c.data.source:c.data.target;(s.get(l)??s.set(l,[]).get(l)).push(d)}const a=new Set(e.filter(c=>i.get(c.data.id)!==c.data.id).map(c=>c.data.id));for(const c of t){if(o.has(c))continue;const l=[...s.get(c)||[]];for(;l.length;){const d=l.pop();t.has(d)||a.has(d)||(a.add(d),l.push(...s.get(d)||[]))}}return{nodes:e.filter(c=>!a.has(c.data.id)).map(c=>{var l;return t.has(c.data.id)&&o.has(c.data.id)?{...c,data:{...c.data,type:"arrayView",label:c.data.label??c.data.headerTitle,config:{...c.data.config,parentContainer:!0,labelBelow:!0,icon:((l=c.data.config)==null?void 0:l.icon)||"PiStack"}}}:c}),edges:r.flatMap(c=>{const l=i.get(c.data.source)??c.data.source,d=i.get(c.data.target)??c.data.target;return a.has(l)||a.has(d)?[]:l===c.data.source&&d===c.data.target?[c]:l===d?[]:[{...c,data:{...c.data,source:l,target:d,collapsedEndpoints:c.data.collapsedEndpoints??{source:c.data.source,target:c.data.target}}}]})}}function Od(e,r){const t=JSON.parse(e);let n=512;const o=(s,a=[])=>{if(--n<0)throw new Error("Interface exceeds the 512-type expansion limit.");if(!s||typeof s!="object"||Array.isArray(s))throw new Error("Expected a JSON Schema object.");const c=new Set(["$schema","$id","$defs","definitions","$ref","title","description","default","examples","type","properties","required","items","enum","const","anyOf","additionalProperties"]);for(const d of Object.keys(s))if(!c.has(d))throw new Error(`Unsupported JSON Schema keyword: ${d}`);const l=["$schema","$id","$defs","definitions","title","description","default","examples"];if(s.$ref){if(Object.keys(s).some(u=>!["$ref","title","description"].includes(u)))throw new Error("Use $ref without sibling constraints.");if(typeof s.$ref!="string"||!s.$ref.startsWith("#/")||a.includes(s.$ref))throw new Error("Only nonrecursive local $ref references are supported.");let d=t;for(const u of s.$ref.slice(2).split("/")){const h=u.replace(/~1/g,"/").replace(/~0/g,"~");if(!d||!Object.prototype.hasOwnProperty.call(d,h))throw new Error(`Unresolved reference: ${s.$ref}`);d=d[h]}return o(d,[...a,s.$ref])}if(s.anyOf){if(!Array.isArray(s.anyOf)||!s.anyOf.length||Object.keys(s).some(d=>d!=="anyOf"&&!l.includes(d)))throw new Error("Use a nonempty anyOf without sibling type constraints.");return{kind:"union",types:s.anyOf.map(d=>o(d,a))}}if(Object.prototype.hasOwnProperty.call(s,"const")||s.enum){if(Object.keys(s).some(h=>![...l,"const","enum","type"].includes(h))||s.enum&&Object.prototype.hasOwnProperty.call(s,"const"))throw new Error("Use enum or const without sibling constraints other than type.");const d=Object.prototype.hasOwnProperty.call(s,"const")?[s.const]:s.enum;if(!Array.isArray(d)||!d.length)throw new Error("Expected a nonempty enum.");return{kind:"union",types:d.map(h=>{if(h!==null&&!["string","number","boolean"].includes(typeof h))throw new Error("Only primitive literals are supported.");const p=h===null?"null":typeof h;if(s.type&&!(Array.isArray(s.type)?s.type:[s.type]).some(m=>m===p||m==="integer"&&Number.isInteger(h)))throw new Error("Literal does not match its declared type.");return{kind:"literal",value:h}})}}if(Array.isArray(s.type)){if(!s.type.length||s.type.some(d=>typeof d!="string"))throw new Error("Expected a nonempty list of primitive types.");if(Object.keys(s).some(d=>d!=="type"&&!l.includes(d)))throw new Error("Use anyOf for unions with object or array constraints.");return{kind:"union",types:s.type.map(d=>o({type:d},a))}}if((s.properties||s.required||s.additionalProperties!==void 0)&&s.type!=="object"&&s.type!==void 0)throw new Error("Object constraints require an object type.");if(s.items&&s.type!=="array")throw new Error("items requires an array type.");if(s.type==="object"||s.properties){if(s.additionalProperties!==void 0&&s.additionalProperties!==!0)throw new Error("Closed objects and typed additionalProperties are not supported.");if(!s.properties||typeof s.properties!="object"||Array.isArray(s.properties))throw new Error("Object schemas must declare properties.");if(s.required!==void 0&&(!Array.isArray(s.required)||s.required.some(u=>typeof u!="string"||!Object.prototype.hasOwnProperty.call(s.properties,u))))throw new Error("required must list declared property names.");return{kind:"object",properties:Object.fromEntries(Object.entries(s.properties).map(([u,h])=>[u,{type:o(h,a),optional:!(s.required??[]).includes(u)}]))}}if(s.type==="array")return{kind:"array",items:o(s.items,a)};if(["string","number","integer","boolean","null"].includes(s.type))return{kind:s.type};throw new Error("Every property must declare a supported type.")},i=o(t);if(i.kind!=="object")throw new Error("The root schema must be an object keyed by node ID.");if(Object.values(i.properties).some(s=>s.type.kind!=="object"))throw new Error("Each node must declare an object of property types.");return{name:r,nodes:i.properties}}async function Nd(e,r,t,n={}){var m;let o=512;const i=await import("typescript"),s=i.createSourceFile(r,e,i.ScriptTarget.Latest,!0,i.ScriptKind.TS),a=s.parseDiagnostics;if(a!=null&&a.length)throw new Error("Invalid TypeScript syntax.");const c=new Map;for(const g of s.statements){if(!i.isInterfaceDeclaration(g)&&!i.isTypeAliasDeclaration(g))throw new Error("Upload interfaces/type aliases only; imports and executable code are not supported.");if((m=g.typeParameters)!=null&&m.length||c.has(g.name.text))throw new Error("Generics and duplicate declarations are not supported.");c.set(g.name.text,g)}const l=(g,y)=>{var C;const b={},x=g.find(S=>i.isIndexSignatureDeclaration(S));let v;if(x&&n.allowJson&&i.isIndexSignatureDeclaration(x)){if(g.filter(S=>i.isIndexSignatureDeclaration(S)).length!==1||x.parameters.length!==1||((C=x.parameters[0].type)==null?void 0:C.kind)!==i.SyntaxKind.StringKeyword||!x.type)throw new Error("Only one string-keyed index signature is supported for forms.");v=u(x.type,y)}return{kind:"object",properties:Object.fromEntries(g.filter(S=>S!==x||!v).map(S=>{if(!i.isPropertySignature(S)||!S.type||!S.name||!i.isIdentifier(S.name)&&!i.isStringLiteral(S.name))throw new Error("Only explicitly typed named properties are supported.");const R=u(S.type,y),P=n.allowJson?i.getJSDocTags(S).filter(k=>k.tagName.text==="port"):[];if(P.length>1)throw new Error(`Duplicate port declaration: ${S.name.text}`);if(P.length){const[k,T,E]=String(P[0].comment??"").trim().split(/\s+/);if(k!=="config"||!T||E||!c.has(T))throw new Error(`Config port ${S.name.text} requires @port config ResourceType`);const M=R.kind==="array";if((R.kind==="array"?R.items.kind:R.kind)!=="string")throw new Error(`Config port ${S.name.text} must be a string or string array reference`);b[S.name.text]={kind:"config",resourceType:T,multiple:M}}return[S.name.text,{type:R,optional:!!S.questionToken}]})),...v?{additionalProperties:v}:{},...Object.keys(b).length?{ports:b}:{}}},d=(g,y)=>{var C;if(y.includes(g))throw new Error("Recursive types are not supported.");const b=c.get(g);if(!b)throw new Error(`Unknown type: ${g}`);let x;if(i.isInterfaceDeclaration(b)){if((C=b.heritageClauses)!=null&&C.length)throw new Error("Interface inheritance is not supported; declare properties explicitly.");x=l(b.members,[...y,g])}else x=u(b.type,[...y,g]);const v=n.allowJson?i.getJSDocTags(b).filter(S=>S.tagName.text==="port"):[];if(!v.length)return x;if(x.kind!=="object")throw new Error("Node ports require an object interface");const w={...x.ports};for(const S of v){const[R,P,...k]=String(S.comment??"").trim().split(/\s+/);if(!["input","output","error"].includes(R)||!/^[A-Za-z][\w-]*$/.test(P??""))throw new Error("Node ports require @port input|output|error Name");const T=k.length?JSON.parse(k.join(" ")):void 0;if(T!==void 0&&typeof T!="string")throw new Error("Node port labels must be JSON strings");if(Object.prototype.hasOwnProperty.call(w,P))throw new Error(`Duplicate port declaration: ${P}`);w[P]={kind:R,...typeof T=="string"?{label:T}:{}}}return{...x,ports:w}},u=(g,y)=>{var b,x,v;if(--o<0)throw new Error("Interface exceeds the 512-type expansion limit.");if(g.kind===i.SyntaxKind.StringKeyword)return{kind:"string"};if(g.kind===i.SyntaxKind.NumberKeyword)return{kind:"number"};if(g.kind===i.SyntaxKind.BooleanKeyword)return{kind:"boolean"};if(n.allowJson&&[i.SyntaxKind.AnyKeyword,i.SyntaxKind.UnknownKeyword].includes(g.kind))return{kind:"json"};if(i.isParenthesizedTypeNode(g))return u(g.type,y);if(i.isUnionTypeNode(g))return{kind:"union",types:g.types.map(w=>u(w,y))};if(i.isArrayTypeNode(g))return{kind:"array",items:u(g.elementType,y)};if(i.isTypeLiteralNode(g))return l(g.members,y);if(i.isLiteralTypeNode(g)){const w=g.literal;if(i.isStringLiteral(w))return{kind:"literal",value:w.text};if(i.isNumericLiteral(w))return{kind:"literal",value:Number(w.text)};if(w.kind===i.SyntaxKind.NullKeyword)return{kind:"null"};if(w.kind===i.SyntaxKind.TrueKeyword||w.kind===i.SyntaxKind.FalseKeyword)return{kind:"literal",value:w.kind===i.SyntaxKind.TrueKeyword}}if(i.isTypeReferenceNode(g)&&i.isIdentifier(g.typeName)){if(n.allowJson&&g.typeName.text==="Record"&&!c.has("Record")&&((b=g.typeArguments)==null?void 0:b.length)===2&&g.typeArguments[0].kind===i.SyntaxKind.StringKeyword)return{kind:"object",properties:{},additionalProperties:u(g.typeArguments[1],y)};if(g.typeName.text==="Array"&&((x=g.typeArguments)==null?void 0:x.length)===1)return{kind:"array",items:u(g.typeArguments[0],y)};if(!((v=g.typeArguments)!=null&&v.length))return d(g.typeName.text,y)}throw new Error(`Unsupported TypeScript type: ${g.getText(s)}`)},h=t??(c.has("Graph")?"Graph":c.size===1?[...c.keys()][0]:void 0);if(!h)throw new Error("Declare an interface Graph keyed by node ID.");const p=d(h,[]);if(p.kind!=="object")throw new Error("Graph must be an object keyed by node ID.");return p}async function yb(e,r){const t=await Nd(e,r);if(Object.values(t.properties).some(n=>n.type.kind!=="object"))throw new Error("Each node must declare an object of property types.");return{name:r,nodes:t.properties}}function mn(e,r){if(e.kind==="json"||r.kind==="json"||e.kind==="object"&&e.additionalProperties||r.kind==="object"&&r.additionalProperties)return!1;if(e.kind==="union")return e.types.every(t=>mn(t,r));if(r.kind==="union")return r.types.some(t=>mn(e,t));if(e.kind==="literal"){if(r.kind==="literal")return e.value===r.value;const t=e.value===null?"null":typeof e.value;return r.kind===t||r.kind==="integer"&&typeof e.value=="number"&&Number.isInteger(e.value)}return e.kind==="integer"&&r.kind==="number"?!0:e.kind==="array"&&r.kind==="array"?mn(e.items,r.items):e.kind==="object"&&r.kind==="object"?Object.entries(r.properties).every(([t,n])=>{const o=Object.prototype.hasOwnProperty.call(e.properties,t)?e.properties[t]:void 0;return o?(n.optional||!o.optional)&&mn(o.type,n.type):n.optional}):e.kind===r.kind}function $d(e,r){if(!r.sourceProperty&&!r.targetProperty)return;const t=(s,a)=>{var d;const c=Object.prototype.hasOwnProperty.call(e.nodes,s)?s:s.replace(/^root\./,""),l=Object.prototype.hasOwnProperty.call(e.nodes,c)?(d=e.nodes[c])==null?void 0:d.type:void 0;return a&&(l==null?void 0:l.kind)==="object"&&Object.prototype.hasOwnProperty.call(l.properties,a)?l.properties[a]:void 0},n=t(r.source,r.sourceProperty),o=t(r.target,r.targetProperty);if(!n||!o)return"Unverified: source or target property is missing from the interface.";const i=s=>s.kind==="json"||s.kind==="object"&&(!!s.additionalProperties||Object.values(s.properties).some(a=>i(a.type)))||s.kind==="array"&&i(s.items)||s.kind==="union"&&s.types.some(i);if(i(n.type)||i(o.type))return"Unverified: arbitrary JSON or dictionary fields require runtime validation.";if(n.optional&&!o.optional)return"Optional source cannot supply a required target property.";if(!mn(n.type,o.type))return`Incompatible property types: ${r.sourceProperty} -> ${r.targetProperty}.`}async function mb(e){if(e.size>256*1024)throw new Error("Interface must be 256 KB or smaller.");const r=await e.text();if(/\.json$/i.test(e.name))return Od(r,e.name);if(/\.ts$/i.test(e.name))return yb(r,e.name);throw new Error("Choose a .ts interface or .json JSON Schema file.")}const Fu=new WeakMap;function Qr(e){if(!e||typeof e!="object")return e;const r=Fu.get(e);if(r)return r;const t=()=>{throw new Error("Form callback data is read-only. Return edits instead.")},n=new Proxy(Array.isArray(e)?[]:{},{get:(o,i)=>Qr(Reflect.get(e,i)),has:(o,i)=>Reflect.has(e,i),ownKeys:()=>Reflect.ownKeys(e),getOwnPropertyDescriptor:(o,i)=>{const s=Reflect.getOwnPropertyDescriptor(e,i);return s&&{...s,value:Qr(Reflect.get(e,i)),configurable:i!=="length"||!Array.isArray(e)}},set:t,deleteProperty:t,defineProperty:t,setPrototypeOf:t,preventExtensions:t});return Fu.set(e,n),n}function on(e,r,t){var o;const n=r.split(".");for(let i=n.length;i>0;i--){const s=n.slice(0,i).join("."),a=(o=Le(e,s))==null?void 0:o.$form;if(!(a!=null&&a.$type))continue;let c=Object.prototype.hasOwnProperty.call(t,a.$type)?t[a.$type]:void 0;for(const u of n.slice(i))(c==null?void 0:c.kind)==="array"&&/^\d+$/.test(u)?c=c.items:(c==null?void 0:c.kind)==="object"?c=Object.prototype.hasOwnProperty.call(c.properties,u)?c.properties[u].type:void 0:c=void 0;if((c==null?void 0:c.kind)!=="object")return;const l=n.slice(i).join("."),d=Object.fromEntries(Object.entries(a.$fields??{}).filter(([u])=>!l||u.startsWith(`${l}.`)).map(([u,h])=>[l?u.slice(l.length+1):u,h]));return{type:c,fields:d,binding:a}}}async function qd(e,r){if(e.size>256*1024)throw new Error("Form schema exceeds 256 KB.");const t=await e.text();if(e.name.endsWith(".ts")){if(!r.length||r.length>32)throw new Error("Choose between 1 and 32 form interface names.");const o=[],i=new Set(r);for(const s of i){if(i.size>32)throw new Error("Choose between 1 and 32 form interface names.");const a=await Nd(t,e.name,s,{allowJson:!0});o.push([s,a]);for(const c of Object.values(a.ports??{}))c.resourceType&&i.add(c.resourceType)}return Object.fromEntries(o)}if(!e.name.endsWith(".json"))throw new Error("Choose a .ts interface or .json schema file.");const n=Od(t,e.name);return Object.fromEntries(Object.entries(n.nodes).map(([o,i])=>[o,i.type]))}function bo(e,r){return!e||("$in"in e?e.$in.includes(Le(r,e.$address)):Le(r,e.$address)===e.$equals)}function kn(e){const r=e.kind==="array"?e.items:e,t=r.kind==="union"?r.types:[r];if(t.every(n=>n.kind==="literal"))return t.map(n=>({label:String(n.value),value:n.value}))}function Ut(e,r,t){if(r===void 0||r==="")return t?"Required":void 0;if(e.kind==="json"){const n=new Set,o=i=>{if(i===null||typeof i=="string"||typeof i=="boolean")return!0;if(typeof i=="number")return Number.isFinite(i);if(!i||typeof i!="object"||n.has(i)||!Array.isArray(i)&&![Object.prototype,null].includes(Object.getPrototypeOf(i)))return!1;n.add(i);const s=Object.values(i).every(o);return n.delete(i),s};return o(r)?void 0:"Expected a JSON value"}if(e.kind==="union")return e.types.some(n=>!Ut(n,r,!0))?void 0:"Choose a valid value";if(e.kind==="literal")return r===e.value?void 0:"Choose a valid value";if(e.kind==="array")return Array.isArray(r)&&r.every(n=>!Ut(e.items,n,!0))?void 0:"Invalid list value";if(e.kind==="object")return!r||typeof r!="object"||Array.isArray(r)?"Expected an object":e.additionalProperties&&Object.entries(r).some(([n,o])=>!Object.prototype.hasOwnProperty.call(e.properties,n)&&Ut(e.additionalProperties,o,!0))?"Invalid dictionary value":Object.entries(e.properties).some(([n,o])=>Ut(o.type,r[n],!o.optional))?"Invalid object fields":void 0;if(e.kind==="null")return r===null?void 0:"Expected null";if(e.kind==="integer")return Number.isInteger(r)?void 0:"Expected a whole number";if(typeof r!==e.kind||typeof r=="number"&&!Number.isFinite(r))return`Expected ${e.kind}`}function zu(e,r){const t=r.address.split(".");if(t.shift()!=="root"||!t.length||t.some(a=>!a||["__proto__","prototype","constructor","#"].includes(a)))throw new Error("Invalid form field address.");const n=t.pop(),o=n==="$bgColor"||n==="$textColor"||n==="$borderColor";if(t.some(a=>a.startsWith("$"))||n.startsWith("$")&&!o)throw new Error("Unsupported form metadata address.");const i=["root",...t].join("."),s=Le(e,i);if(!s||typeof s!="object")throw new Error(`Missing form parent: ${i}`);if(o){if(r.op==="set"&&typeof r.value!="string")throw new Error("Node colors must be strings.");return xt(e,i,n,r.op==="remove"?void 0:r.value)}return _t(e,i,a=>{const c=Array.isArray(a.$)?a.$:a;if(r.op==="remove"&&!Object.prototype.hasOwnProperty.call(c,n)||r.op==="set"&&Object.is(c[n],r.value))return a;const l=Array.isArray(c)?[...c]:{...c};if(Array.isArray(l)&&(!/^(0|[1-9]\d*)$/.test(n)||Number(n)>=l.length))throw new Error("Invalid array address.");return r.op==="remove"?Array.isArray(l)?l.splice(Number(n),1):delete l[n]:Object.defineProperty(l,n,{value:structuredClone(r.value),enumerable:!0,writable:!0,configurable:!0}),c===a?l:{...a,$:l}})}function xo(e,r,t){let n=zu(e,r.value===void 0?{op:"remove",address:r.address}:{op:"set",address:r.address,value:r.value});const o=t==null?void 0:t({...r,previousValue:Qr(Le(e,r.address)),data:Qr(n)});if(o&&!Array.isArray(o))throw new Error("Form change handlers must return edits synchronously.");for(const i of Array.isArray(o)?o:[]){if(i.op!=="set"&&i.op!=="remove")throw new Error("Unsupported form edit.");n=zu(n,i)}return n}const An="data:image/svg+xml;base64,";function hr(e){if(e.startsWith(An))return!0;try{const r=new URL(e);return(r.protocol==="https:"||r.protocol==="http:")&&!r.username&&!r.password}catch{return!1}}async function Ew(e){if(e.size>256*1024)throw new Error("SVG must be 256 KB or smaller.");const r=await e.text(),t=new DOMParser().parseFromString(r,"image/svg+xml");if(t.doctype||t.querySelector("parsererror")||t.documentElement.localName!=="svg"||t.documentElement.namespaceURI!=="http://www.w3.org/2000/svg")throw new Error("Choose a valid SVG file.");if(t.querySelector("script, foreignObject")||[...t.querySelectorAll("*")].some(i=>[...i.attributes].some(s=>/^on/i.test(s.name))))throw new Error("SVG scripts and event handlers are not allowed.");const n=new TextEncoder().encode(r);let o="";for(const i of n)o+=String.fromCharCode(i);return An+btoa(o)}const or=({name:e,svg:r=!1,...t})=>{const[n,o]=j.useState(null),[i,s]=j.useState(!0),[a,c]=j.useState(!1),l=typeof e=="string"&&hr(e);if(j.useEffect(()=>{if(l||!e||e.length<2){o(null),s(!1);return}s(!0),c(!1),(async()=>{try{let u;if(e.startsWith("Md"))u="md";else if(e.startsWith("Fa"))u="fa6";else if(e.startsWith("Io5"))u="io5";else if(e.startsWith("Io"))u="io";else if(e.startsWith("Ti"))u="ti";else if(e.startsWith("Go"))u="go";else if(e.startsWith("Fi"))u="fi";else if(e.startsWith("Di"))u="di";else if(e.startsWith("Ai"))u="ai";else if(e.startsWith("Bs"))u="bs";else if(e.startsWith("Ri"))u="ri";else if(e.startsWith("Fc"))u="fc";else if(e.startsWith("Gi"))u="gi";else if(e.startsWith("Hi2"))u="hi2";else if(e.startsWith("Hi"))u="hi";else if(e.startsWith("Si"))u="si";else if(e.startsWith("Sl"))u="sl";else if(e.startsWith("Im"))u="im";else if(e.startsWith("Bi"))u="bi";else if(e.startsWith("Pi"))u="pi";else if(e.startsWith("Vsc"))u="vsc";else if(e.startsWith("Tb"))u="tb";else if(e.startsWith("Tfi"))u="tfi";else if(e.startsWith("Cg"))u="cg";else if(e.startsWith("Lia"))u="lia";else if(e.startsWith("Lu"))u="lu";else throw new Error(`Unknown library prefix for icon: ${e}`);let h;switch(u){case"md":h=await import("react-icons/md");break;case"fa6":h=await import("react-icons/fa6");break;case"io5":h=await import("react-icons/io5");break;case"io":h=await import("react-icons/io");break;case"ti":h=await import("react-icons/ti");break;case"go":h=await import("react-icons/go");break;case"fi":h=await import("react-icons/fi");break;case"di":h=await import("react-icons/di");break;case"ai":h=await import("react-icons/ai");break;case"bs":h=await import("react-icons/bs");break;case"ri":h=await import("react-icons/ri");break;case"fc":h=await import("react-icons/fc");break;case"gi":h=await import("react-icons/gi");break;case"hi2":h=await import("react-icons/hi2");break;case"hi":h=await import("react-icons/hi");break;case"si":h=await import("react-icons/si");break;case"sl":h=await import("react-icons/sl");break;case"im":h=await import("react-icons/im");break;case"bi":h=await import("react-icons/bi");break;case"pi":h=await import("react-icons/pi");break;case"vsc":h=await import("react-icons/vsc");break;case"tb":h=await import("react-icons/tb");break;case"tfi":h=await import("react-icons/tfi");break;case"cg":h=await import("react-icons/cg");break;case"lia":h=await import("react-icons/lia");break;case"lu":h=await import("react-icons/lu");break;default:throw new Error(`Unsupported library: ${u}`)}const p=h[e];if(!p)throw new Error(`Icon ${e} not found in library ${u}`);o(()=>p)}catch(u){console.warn(`Failed to load icon ${e}:`,u.message),c(!0),o(null)}finally{s(!1)}})()},[e,l]),l){const{size:d=80,style:u,...h}=t;return r?f.jsx("image",{...h,href:e,width:d,height:d,preserveAspectRatio:"xMidYMid meet",style:u}):f.jsx("img",{...h,src:e,alt:"",width:d,height:d,referrerPolicy:"no-referrer",style:{objectFit:"contain",...u}})}return i||!n?null:f.jsx(n,{...t})};function _w(e,r){let t=e;for(const n of r){if(n.op!=="set"&&n.op!=="remove")throw new Error("Unsupported state edit.");const o=n.address.split(".");if(o.some(s=>s.startsWith("$")||["__proto__","prototype","constructor"].includes(s)))throw new Error("State edits cannot target view metadata or unsafe keys.");const i=n.op==="remove"?void 0:n.value;Tn(i),t=xo(t,{address:n.address,nodeAddress:o.slice(0,-1).join("."),value:i})}return Tn(t),t}function Fn(e,r,t){const n=Object.prototype.hasOwnProperty.call(e,r)?e[r]:void 0;if(!(!n||!t||!Object.prototype.hasOwnProperty.call(t,n.type)))return{address:n.address,type:t[n.type],fields:n.fields??{}}}function Tn(e){if(!(!e||typeof e!="object"))for(const[r,t]of Object.entries(e)){if(r.startsWith("$")||["__proto__","prototype","constructor"].includes(r))throw new Error(`Form state cannot contain view metadata or unsafe keys: ${r}`);Tn(t)}}function Rw(e,r,t){Tn(r.value);const n=xo(e,r,t);return Tn(n),n}function bb(e,r){const t=(n,o="")=>{if(!n||typeof n!="object")return n;if(["$label","$subtitle","$content","$icon","$bgColor","$textColor","$borderColor"].includes(o)&&typeof n.$state=="string"){const s=Le(r,n.$state);return s==null?"":typeof s=="object"?JSON.stringify(s,null,2):String(s)}let i=n;for(const[s,a]of Object.entries(n)){const c=t(a,s);c!==a&&(i===n&&(i=Array.isArray(n)?[...n]:{...n}),Object.defineProperty(i,s,{value:c,enumerable:!0,writable:!0,configurable:!0}))}return i};return t(e)}const kw=e=>!!e&&!e.includes(".")&&!e.startsWith("$")&&!["__proto__","constructor","prototype"].includes(e),Aw=e=>`root.__form_${encodeURIComponent(e).replace(/\./g,"%2E")}`,bn=(e,r)=>JSON.stringify([e,r]);function On(e,r){if(e.kind==="union"){const t=e.types.find(n=>n.kind===(Array.isArray(r)?"array":r===null?"null":typeof r)||n.kind==="literal"&&Object.is(n.value,r));return On(t??e.types.find(n=>n.kind!=="null")??e.types[0]??{kind:"json"},r)}return e.kind!=="json"?e:Array.isArray(r)?{kind:"array",items:{kind:"json"}}:r!==null&&typeof r=="object"||r===void 0?{kind:"object",properties:{},additionalProperties:{kind:"json"}}:{kind:r===null?"null":typeof r}}function xn(e){const r=On(e,void 0);return r.kind==="object"?{}:r.kind==="array"?[]:r.kind==="literal"?r.value:r.kind==="number"||r.kind==="integer"?0:r.kind==="boolean"?!1:r.kind==="null"?null:""}function Bu(e){return e.kind==="json"?[{kind:"string"},{kind:"number"},{kind:"boolean"},{kind:"null"},{kind:"object",properties:{},additionalProperties:{kind:"json"}},{kind:"array",items:{kind:"json"}}]:e.kind==="union"&&!kn(e)?e.types:[e]}function Pw(e,r,t){if(r.address===t.address)return;const n=Le(e,r.address),o=(i,s)=>s===void 0?!1:i.kind==="union"?i.types.some(a=>o(a,s)):i.kind==="array"?Array.isArray(s)&&s.every(a=>o(i.items,a)):i.kind==="object"?!!s&&typeof s=="object"&&!Array.isArray(s)&&Object.entries(i.properties).every(([a,c])=>c.optional&&s[a]===void 0||o(c.type,s[a]))&&Object.entries(s).every(([a,c])=>Object.prototype.hasOwnProperty.call(i.properties,a)||!i.additionalProperties||o(i.additionalProperties,c)):s===""?i.kind==="string"||i.kind==="json"||i.kind==="literal"&&i.value==="":!Ut(i,s,!0);if(o(t.type,n))return structuredClone(n)}function xb(e,r,t,n){var c,l;const o={sourceSchema:t,sourceBindings:r,nodes:[],edges:[],schema:{...t},bindings:{...r},slots:new Map,containers:new Map},i=new Set(n.map(d=>d.data.id)),s=new Map(n.flatMap(d=>{const u=r[d.data.id];return u&&t[u.type]?[[u.address,d.data.id]]:[]})),a=(d,u,h,p,m,g=!1)=>{var R,P,k,T,E;if(m>24||o.containers.size>512)throw new Error("Structured form exceeds the flow node limit.");const y=Le(e,u),b=On(h,y),x=b.kind!=="object"&&b.kind!=="array";o.containers.set(d,{address:u,type:b,declared:h,scalar:x});const v=`__form:${d}`,w={...(R=o.bindings[d])==null?void 0:R.fields},C={kind:"object",properties:{},ports:{...b.kind==="object"?b.ports:{},...g?{resource:{label:"output",...b.kind==="object"?(P=b.ports)==null?void 0:P.resource:{},kind:"output"}}:{}}},S=b.kind==="object"?{...b.properties,...Object.fromEntries(Object.keys(y??{}).filter(M=>!Object.prototype.hasOwnProperty.call(b.properties,M)&&b.additionalProperties).map(M=>[M,{type:b.additionalProperties,optional:!0}]))}:b.kind==="array"?Object.fromEntries((Array.isArray(y)?y:[]).map((M,_)=>[String(_),{type:b.items,optional:!0}])):{value:{type:kn(h)?h:b,optional:!1}};for(const[M,_]of Object.entries(S)){if(!kw(M))throw new Error(`Unsupported structured property key: ${M}`);const N=x?u:`${u}.${M}`,$=Le(e,N),B=On(_.type,$),O=B.kind==="object"||B.kind==="array",I=(k=C.ports)==null?void 0:k[M],ee=(I==null?void 0:I.kind)==="config"&&(((T=w[M])==null?void 0:T.$options)||kn(_.type)),ae=_.type.kind==="json"||_.type.kind==="union"&&!kn(_.type);if(((E=w[M])==null?void 0:E.$control)==="upload"||!O&&b.kind!=="array"&&(!ae||x)||ee){C.properties[M]={..._,type:_.type.kind==="json"?B:_.type};continue}const ne=s.get(N)??Aw(N),oe=b.kind==="array"?`Item ${Number(M)+1}`:M,pe={address:N,owner:d,field:M,type:_.type,label:oe,nodeId:ne,present:$!==void 0};if(o.slots.set(bn(d,M),pe),C.ports[M]={kind:"config",resourceType:`__form:${ne}`},$===void 0||(o.edges.push({data:{id:`__form-edge:${d}:${M}`,source:ne,target:d,sourceProperty:"output:resource",targetProperty:`config:${M}`,isEdgeDashed:!0}}),o.containers.has(ne)||s.has(N)))continue;if(i.has(ne))throw new Error(`Structured node identity conflict: ${ne}`);i.add(ne);const q={data:{id:ne,type:"objectView",label:oe,headerTitle:oe,description:{},config:{form:!0,icon:B.kind==="array"?"PiListNumbers":O?"PiBracketsCurly":"PiTextT"},viewProps:{bgColor:p}}};o.nodes.push(q),a(ne,N,_.type,p,m+1,!0);const F=o.schema[`__form:${ne}`];q.data.description=Object.fromEntries(Object.keys(F.properties).map(G=>[G,Le(e,B.kind==="array"||B.kind==="object"?`${N}.${G}`:N)]).filter(([,G])=>G!==void 0))}o.schema[v]=C,o.bindings[d]={...o.bindings[d],address:u,type:v,fields:w}};for(const d of n){const u=r[d.data.id];if(u!=null&&u.portResources)continue;const h=u&&t[u.type];!u||!h||Le(e,u.address)===void 0||a(d.data.id,u.address,h,(c=d.data.viewProps)==null?void 0:c.bgColor,0,o.edges.some(p=>p.data.source===d.data.id))}for(const d of o.edges){const u=o.bindings[d.data.source],h=o.schema[u.type].ports;h.resource={...h.resource,kind:"output",label:((l=h.resource)==null?void 0:l.label)??"output"}}return o}const Nr=(e="reference")=>({kind:e,text:"",paths:[""]}),vb=e=>/^[A-Za-z_][\w]*(?:\.[A-Za-z_][\w]*|\.\d+)+$/.test(e)&&!e.split(".").some(r=>["__proto__","constructor","prototype"].includes(r));function Mw(e,r){const t=new Set(r.map(s=>s.path)),n=s=>{if(!s.paths.length||s.paths.some(a=>!vb(a)||!t.has(a)))throw new Error("Choose an available reference.");return[...s.paths,...s.fallback===void 0?[]:[JSON.stringify(s.fallback)]].join(" || ")},o=s=>{if(s.includes("{{")||s.includes("}}"))throw new Error("Use a reference part for dynamic values.");return s},i=s=>s.map(a=>{if(a.kind==="text")return o(a.text);if(a.kind==="conditional"){if(a.paths.length!==1||a.fallback!==void 0)throw new Error("Choose one condition reference.");return`{{#if ${n(a)}}}${o(a.text)}{{/if}}`}return`{{${n(a)}}}`}).join("");if(e.mode==="reference"||e.mode==="condition"){if(e.parts.length!==1||e.parts[0].kind!=="reference")throw new Error("Choose one reference binding.");const s=i(e.parts);return e.mode==="condition"?`${s} == ${JSON.stringify(e.comparison)}`:s}if(e.mode==="json"){const s=e.fields.map(a=>a.key);if(!s.length||new Set(s).size!==s.length||s.some(a=>!a||["__proto__","constructor","prototype"].includes(a)))throw new Error("Output field names must be unique and nonempty.");return JSON.stringify(Object.fromEntries(e.fields.map(a=>[a.key,i(a.parts)])))}return i(e.parts)}async function Iw(e){const r=await import("typescript"),t=s=>{const a=r.createSourceFile("binding.ts",`(${s})`,r.ScriptTarget.Latest,!0,r.ScriptKind.TS);if(a.parseDiagnostics.length)throw new Error("Unsupported reference expression.");const c=a.statements[0];if(!c||!r.isExpressionStatement(c))throw new Error("Unsupported reference expression.");const l=Nr();l.paths=[];const d=u=>{if(r.isParenthesizedExpression(u))return d(u.expression);if(r.isBinaryExpression(u)&&u.operatorToken.kind===r.SyntaxKind.BarBarToken){d(u.left),d(u.right);return}if(r.isStringLiteral(u)){if(l.fallback!==void 0)throw new Error("Multiple fallback values.");l.fallback=u.text;return}const h=u.getText(a);if(!vb(h)||l.fallback!==void 0)throw new Error("Unsupported reference expression.");l.paths.push(h)};if(d(c.expression),!l.paths.length)throw new Error("A binding needs a reference.");return l},n=s=>{const a=[];let c=0;const l=/\{\{([\s\S]*?)\}\}/g;for(const d of s.matchAll(l)){const u=d.index;if(u<c)continue;u>c&&a.push({...Nr("text"),text:s.slice(c,u)});const h=d[1].trim();if(h.startsWith("#if ")){const p=s.indexOf("{{/if}}",u+d[0].length);if(p<0)throw new Error("Unclosed condition.");a.push({...t(h.slice(4)),kind:"conditional",text:s.slice(u+d[0].length,p)}),c=p+7}else a.push(t(h)),c=u+d[0].length}return c<s.length&&a.push({...Nr("text"),text:s.slice(c)}),a},o={mode:"reference",parts:[Nr()],comparison:"",fields:[]};if(!e)return o;if(e.trim().startsWith("{"))try{const s=JSON.parse(e);if(s&&typeof s=="object"&&!Array.isArray(s)&&Object.values(s).every(a=>typeof a=="string"))return{...o,mode:"json",fields:Object.entries(s).map(([a,c])=>({key:a,parts:n(c)}))}}catch{}const i=n(e);if(i.length===2&&i[0].kind==="reference"&&i[1].kind==="text"){const s=r.createSourceFile("condition.ts",`value ${i[1].text}`,r.ScriptTarget.Latest,!0,r.ScriptKind.TS),a=s.statements[0];if(s.statements.length===1&&r.isExpressionStatement(a)&&r.isBinaryExpression(a.expression)&&a.expression.operatorToken.kind===r.SyntaxKind.EqualsEqualsToken&&r.isStringLiteral(a.expression.right))return{...o,mode:"condition",parts:[i[0]],comparison:a.expression.right.text}}return{...o,mode:i.length===1&&i[0].kind==="reference"?"reference":"template",parts:i}}function Du({parts:e,references:r,onChange:t,disabled:n}){const o=(i,s)=>t(e.map((a,c)=>c===i?{...a,...s}:a));return f.jsxs("div",{style:{display:"grid",gap:12},children:[e.map((i,s)=>f.jsxs("fieldset",{"data-binding-part":s,style:{border:0,padding:0,margin:0,minWidth:0},children:[f.jsxs("legend",{children:["Part ",s+1]}),f.jsxs("div",{style:{display:"flex",gap:8},children:[f.jsxs("span",{"data-form-select":"",style:{flex:1},children:[f.jsxs("select",{"aria-label":"Part type",disabled:n,value:i.kind,onChange:a=>o(s,{kind:a.target.value}),children:[f.jsx("option",{value:"reference",children:"Reference"}),f.jsx("option",{value:"text",children:"Text"}),f.jsx("option",{value:"conditional",children:"Conditional text"})]}),f.jsx(Y.PiCaretDown,{size:16,"aria-hidden":"true"})]}),f.jsx(Oe,{"aria-label":`Remove part ${s+1}`,title:"Remove part",icon:f.jsx(Y.PiTrash,{size:18}),size:"sm",variant:"ghost",disabled:n,onClick:()=>t(e.filter((a,c)=>c!==s))})]}),i.kind!=="text"&&f.jsxs(f.Fragment,{children:[i.paths.map((a,c)=>f.jsxs("label",{children:["Reference ",c+1,f.jsxs("span",{"data-form-select":"",style:{display:"block"},children:[f.jsxs("select",{"aria-label":`Reference ${c+1}`,disabled:n,value:a,onChange:l=>o(s,{paths:i.paths.map((d,u)=>u===c?l.target.value:d)}),children:[f.jsx("option",{value:"",children:"Select reference"}),r.map(l=>f.jsx("option",{value:l.path,children:l.label},l.path))]}),f.jsx(Y.PiCaretDown,{size:16,"aria-hidden":"true"})]})]},c)),i.kind==="reference"&&f.jsxs(f.Fragment,{children:[f.jsx(Oe,{"aria-label":"Add fallback reference",title:"Add fallback reference",icon:f.jsx(Y.PiPlus,{size:18}),size:"sm",variant:"ghost",disabled:n,onClick:()=>o(s,{paths:[...i.paths,""]})}),f.jsxs("label",{style:{display:"flex",gap:8,alignItems:"center"},children:[f.jsx("input",{type:"checkbox","aria-label":"Default value enabled",disabled:n,checked:i.fallback!==void 0,onChange:a=>o(s,{fallback:a.target.checked?"":void 0})}),"Default value"]}),i.fallback!==void 0&&f.jsx("input",{"aria-label":"Default value",disabled:n,value:i.fallback,onChange:a=>o(s,{fallback:a.target.value})})]})]}),i.kind!=="reference"&&f.jsxs("label",{children:["Text",f.jsx("textarea",{"aria-label":"Part text",disabled:n,value:i.text,onChange:a=>o(s,{text:a.target.value})})]})]},s)),f.jsx(Oe,{"aria-label":"Add part",title:"Add part",icon:f.jsx(Y.PiPlus,{size:18}),size:"sm",variant:"ghost",disabled:n,onClick:()=>t([...e,Nr()])})]})}function Tw({label:e,value:r,references:t,disabled:n,onChange:o}){const[i,s]=j.useState(),[a,c]=j.useState(""),[l,d]=j.useState(!1),u=async()=>{d(!0),c("");try{s(await Iw(typeof r=="string"?r:""))}catch(h){c(h instanceof Error?h.message:"Unable to read binding.")}finally{d(!1)}};return f.jsxs("div",{"data-runtime-binding":e,style:{marginBottom:8},children:[f.jsx(Oe,{"aria-label":`Bind ${e}`,title:`Bind ${e}`,icon:f.jsx(Y.PiLink,{size:18}),size:"sm",variant:"ghost",disabled:n||l,onClick:u}),typeof r=="string"&&r.includes("{{")&&f.jsx("span",{children:"Bound value"}),i&&f.jsxs("fieldset",{disabled:n,style:{border:0,margin:0,padding:"8px 0",minWidth:0},children:[f.jsxs("label",{children:["Binding mode",f.jsxs("span",{"data-form-select":"",style:{display:"block"},children:[f.jsxs("select",{"aria-label":"Binding mode",value:i.mode,onChange:h=>s({...i,mode:h.target.value,parts:[Nr()]}),children:[f.jsx("option",{value:"reference",children:"Reference"}),f.jsx("option",{value:"condition",children:"Equals"}),f.jsx("option",{value:"template",children:"Text template"}),f.jsx("option",{value:"json",children:"JSON output"})]}),f.jsx(Y.PiCaretDown,{size:16,"aria-hidden":"true"})]})]}),i.mode==="json"?f.jsxs(f.Fragment,{children:[i.fields.map((h,p)=>f.jsxs("fieldset",{"data-output-field":p,style:{border:0,margin:0,padding:"8px 0",minWidth:0},children:[f.jsxs("label",{children:["Output field name",f.jsx("input",{"aria-label":"Output field name",value:h.key,onChange:m=>s({...i,fields:i.fields.map((g,y)=>y===p?{...g,key:m.target.value}:g)})})]}),f.jsx(Du,{parts:h.parts,references:t,disabled:n,onChange:m=>s({...i,fields:i.fields.map((g,y)=>y===p?{...g,parts:m}:g)})}),f.jsx(Oe,{"aria-label":"Remove output field",title:"Remove output field",icon:f.jsx(Y.PiTrash,{size:18}),size:"sm",variant:"ghost",onClick:()=>s({...i,fields:i.fields.filter((m,g)=>g!==p)})})]},p)),f.jsx(Oe,{"aria-label":"Add output field",title:"Add output field",icon:f.jsx(Y.PiPlus,{size:18}),size:"sm",variant:"ghost",onClick:()=>s({...i,fields:[...i.fields,{key:"",parts:[Nr()]}]})})]}):f.jsx(Du,{parts:i.parts,references:t,disabled:n,onChange:h=>s({...i,parts:h})}),i.mode==="condition"&&f.jsxs("label",{children:["Equals",f.jsx("input",{"aria-label":"Comparison value",value:i.comparison,onChange:h=>s({...i,comparison:h.target.value})})]}),f.jsxs("div",{style:{display:"flex",gap:8,marginTop:12},children:[f.jsx(Oe,{"aria-label":"Apply binding",title:"Apply binding",icon:f.jsx(Y.PiCheck,{size:20}),size:"sm",variant:"ghost",onClick:()=>{try{o(Mw(i,t)),s(void 0),c("")}catch(h){c(h instanceof Error?h.message:"Unable to apply binding.")}}}),f.jsx(Oe,{"aria-label":"Cancel binding",title:"Cancel binding",icon:f.jsx(Y.PiX,{size:20}),size:"sm",variant:"ghost",onClick:()=>{s(void 0),c("")}})]})]}),a&&f.jsx("p",{role:"alert",children:a})]})}function Ow({nodeAddress:e,onOpen:r}){const{structured:t,data:n,callbacks:o,editable:i,onFieldCreate:s}=j.useContext(Tt),a=Je(),[c,l]=j.useState(""),[d,u]=j.useState("0"),[h,p]=j.useState(""),m=t==null?void 0:t.containers.get(e);if(!m||!n||!t)return null;const g=a.readOnly||a.config.editable===!1||!i,y=Le(n,m.address),b=Bu(m.declared),x=m.type.kind==="array"?m.type.items:m.type.kind==="object"?m.type.additionalProperties:void 0,v=x?Bu(x):[],w=!!s&&m.type.kind==="object"&&(x==null?void 0:x.kind)==="json",C=_=>_.kind==="literal"?String(_.value):_.kind==="string"?"Text":Ft(_.kind),S=[...t.slots.values()].filter(_=>_.owner===e),R=(_,N)=>{var $;return($=o.onFormChange)==null?void 0:$.call(o,{data:n,nodeAddress:m.address,address:_,previousValue:Le(n,_),value:N})},P=_=>{var N;a.setSelectedNodeIds([_]),(N=a.engineRef.current)==null||N.focusNode(_,90,!1)},k=(_,N)=>{if(!Array.isArray(y))return;const $=[...y];[$[_],$[_+N]]=[$[_+N],$[_]],R(m.address,$)},T=()=>{const _=v[Number(d)]??v[0];if(_)if(m.type.kind==="array")R(m.address,[...Array.isArray(y)?y:[],xn(_)]);else{if(!c||c.includes(".")||c.startsWith("$")||["__proto__","constructor","prototype"].includes(c)){p("Choose a property name without dots or reserved prefixes.");return}if(Object.prototype.hasOwnProperty.call(y,c)){p("Property already exists.");return}w&&(d==="file"||d==="files")?s==null||s({data:n,nodeAddress:m.address,address:`${m.address}.${c}`,previousValue:void 0,value:d==="files"?[]:""},{$control:"upload"}):R(`${m.address}.${c}`,xn(_)),l(""),p("")}},E=m.type.kind==="object"&&!!m.type.additionalProperties,M=m.type.kind==="array";return f.jsxs("div",{"data-structured-controls":"",style:{display:"grid",gap:8,minWidth:0},children:[b.length>1&&f.jsxs("label",{children:["Value type",f.jsx("span",{"data-form-select":"",style:{display:"block"},children:f.jsx(Mt,{"aria-label":"Value type",disabled:g,value:String(b.findIndex(_=>On(_,y).kind===m.type.kind)),onValueChange:_=>R(m.address,xn(b[Number(_)])),children:b.map((_,N)=>f.jsx("option",{value:N,children:C(_)},N))})})]}),S.map((_,N)=>f.jsxs("div",{"data-structured-slot":_.address,style:{display:"flex",gap:6,alignItems:"center",minWidth:0},children:[_.type.kind==="array"?f.jsx(Y.PiListNumbers,{size:20}):f.jsx(Y.PiBracketsCurly,{size:20}),f.jsx("span",{style:{flex:1,overflowWrap:"anywhere"},children:Ft(_.label)}),f.jsx(Oe,{"aria-label":`${_.present?r?"Edit":"Focus":"Create"} ${Ft(_.label)}`,title:`${_.present?r?"Edit":"Focus":"Create"} ${Ft(_.label)}`,icon:_.present?f.jsx(Y.PiMagnifyingGlass,{size:18}):f.jsx(Y.PiPlus,{size:18}),size:"sm",variant:"ghost",disabled:g&&!_.present,onClick:$=>{var B;_.present?r?r(_.nodeId):((B=$.currentTarget.closest("dialog"))==null||B.close(),P(_.nodeId)):R(_.address,xn(_.type))}}),M&&f.jsxs(f.Fragment,{children:[f.jsx(Oe,{"aria-label":`Move item ${N+1} up`,icon:f.jsx(Y.PiArrowUp,{size:18}),size:"sm",variant:"ghost",disabled:g||N===0,onClick:()=>k(N,-1)}),f.jsx(Oe,{"aria-label":`Move item ${N+1} down`,icon:f.jsx(Y.PiArrowDown,{size:18}),size:"sm",variant:"ghost",disabled:g||N===S.length-1,onClick:()=>k(N,1)})]}),_.present&&f.jsx(Oe,{"aria-label":`Remove ${Ft(_.label)}`,icon:f.jsx(Y.PiTrash,{size:18}),size:"sm",variant:"ghost",disabled:g,onClick:()=>M?R(m.address,y.filter(($,B)=>B!==N)):R(_.address,void 0)})]},_.address)),(M||E)&&f.jsxs("div",{style:{display:"flex",gap:8,flexWrap:"wrap",alignItems:"end"},children:[E&&f.jsxs("label",{style:{flex:"1 1 120px",minWidth:0,display:"grid",gap:8},children:["Property name",f.jsx("input",{"aria-label":"Property name",placeholder:"Required",value:c,disabled:g,onChange:_=>l(_.target.value)})]}),v.length>1&&f.jsxs("label",{style:{flex:"1 1 100px",minWidth:0,display:"grid",gap:8},children:["New value type",f.jsx("span",{"data-form-select":"",style:{display:"block"},children:f.jsxs(Mt,{"aria-label":"New value type",value:d,disabled:g,onValueChange:u,children:[v.map((_,N)=>f.jsx("option",{value:N,children:C(_)},N)),w&&f.jsx("option",{value:"file",children:"File"}),w&&f.jsx("option",{value:"files",children:"Files"})]})})]}),f.jsx("span",{style:{display:"flex",alignItems:"center",flexShrink:0,...E||v.length>1?{height:"calc(1.4em + 20px)",fontSize:15,marginBottom:6}:{}},children:f.jsx(Oe,{"aria-label":M?"Add item":"Add property",icon:f.jsx(Y.PiPlus,{size:20}),size:"sm",variant:"ghost",disabled:g,onClick:T})})]}),h&&f.jsx("p",{role:"alert",children:h})]})}const Tt=j.createContext({callbacks:{}}),Xn=fo.default.div`
|
|
58
|
+
`,Rd=j.forwardRef(function({style:r,...t},n){return f.jsx(fw,{...t,ref:n,style:{...r,backgroundImage:"none","--flow-range-track":(r==null?void 0:r.backgroundImage)??"none"}})});function yd({label:e,inputLabel:r,value:t,displayValue:n,min:o,max:i,step:s=5,onChange:a,onChangeEnd:c}){const l=j.useId(),{readOnly:d,themeColor:u}=Ze(),{colorInactive:h}=lt(),p=(t-o)/(i-o)*100,m=u.includes(".")?`var(--chakra-colors-${u.replace(".","-")})`:u;return f.jsxs("div",{style:{width:224,maxWidth:"calc(100vw - 64px)",padding:12},children:[f.jsxs("label",{htmlFor:l,style:{display:"flex",justifyContent:"space-between",fontSize:14,marginBottom:12},children:[e," ",f.jsx("span",{children:n})]}),f.jsx(Rd,{id:l,"aria-label":r,type:"range",min:o,max:i,step:s,value:t,disabled:d,style:{color:m,accentColor:m,backgroundImage:`linear-gradient(to right, currentColor ${p}%, var(--chakra-colors-${h.replace(".","-")}) ${p}%)`},onChange:g=>a(Number(g.target.value)),onPointerUp:c,onKeyUp:c,onBlur:c})]})}const Nu={dot:{label:"Dots",icon:Y.PiDotsNine},grid:{label:"Grid",icon:Y.PiGridFour},steel:{label:"Steel",icon:Y.PiLineSegments},none:{label:"Solid",icon:Y.PiSquareFill},transparent:{label:"Transparent",icon:Y.PiSelection}};function ab(){const{spacing:e,setSpacing:r,edgeRadius:t,setEdgeRadius:n,backgroundVariant:o,setBackgroundVariant:i,callbacks:s,readOnly:a,config:c}=Ze(),l=Nu[o].icon;return f.jsxs(f.Fragment,{children:[f.jsx(Sn,{}),f.jsx(Mt,{"aria-label":"Node spacing",title:`Spacing: ${Math.round(e*100)}%`,icon:f.jsx(Y.PiArrowsOutCardinal,{size:20}),style:{width:36},value:"spacing",disabled:a,onValueChange:()=>{},popupContent:f.jsx(yd,{label:"Spacing",inputLabel:"Node spacing percentage",min:c.nodeGridSpacing==="layout"?0:50,max:200,value:Math.round(e*100),displayValue:`${Math.round(e*100)}%`,onChange:d=>{var u;r(d/100),(u=s.onSpacingChange)==null||u.call(s,d/100)}}),children:f.jsx("option",{value:"spacing",children:"Spacing"})}),f.jsx(Sn,{}),f.jsx(Mt,{"aria-label":"Edge radius",title:`Edge radius: ${t??"Default"}`,icon:f.jsx(Y.PiBezierCurve,{size:20}),style:{width:36},value:"radius",disabled:a,onValueChange:()=>{},popupContent:f.jsx(yd,{label:"Edge radius",inputLabel:"Edge corner radius",min:0,max:500,value:t??500,displayValue:t??"Default",onChange:d=>{var u;n(d),(u=s.onEdgeRadiusChange)==null||u.call(s,d)}}),children:f.jsx("option",{value:"radius",children:"Edge radius"})}),f.jsx(Sn,{}),f.jsxs(Mt,{"aria-label":"Background variant",title:`Background: ${Nu[o].label}`,icon:f.jsx(l,{size:20,"data-background-icon":o}),style:{width:36},value:o,disabled:a,onValueChange:d=>{var u;i(d),(u=s.onBackgroundVariantChange)==null||u.call(s,d)},children:[f.jsx("option",{value:"dot",children:"Dots"}),f.jsx("option",{value:"grid",children:"Grid"}),f.jsx("option",{value:"steel",children:"Steel"}),f.jsx("option",{value:"none",children:"Solid"}),f.jsx("option",{value:"transparent",children:"Transparent"})]})]})}function sb(){var o;const{engineRef:e,nodeGridOptions:r,readOnly:t}=Ze(),n=!!(r!=null&&r.fill);return f.jsx(Yr,{label:"Grid adjustment",hideLabel:!0,helper:n?"Grid adjustment":"Enable Collision and Fill to adjust the Grid",icon:f.jsx(Y.PiArrowsHorizontal,{size:20}),checked:n&&!!((o=r==null?void 0:r.adjustment)!=null&&o.enabled),disabled:!n,onChange:i=>{var s;t||!(r!=null&&r.fill)||(s=e.current)==null||s.setNodeGridMode(!0,{...r,adjustment:{...r.adjustment,enabled:i}})}})}function to({fillOnly:e=!1}={}){const{engineRef:r,nodeGridOptions:t,lastNodeGridOptions:n,readOnly:o,themeColor:i,callbacks:s,config:a}=Ze(),{colorText:c,colorInactive:l}=lt(),d=t??n,u=typeof d.gaps=="object"?d.gaps.x:d.gaps??d.margin??15,h=Math.max(200,u),p=m=>{var g;return(g=r.current)==null?void 0:g.setNodeGridMode(!0,{...d,...m})};return f.jsxs(f.Fragment,{children:[!e&&a.bottomBarCollision!==!1&&f.jsx(Yr,{label:"Collision mode",hideLabel:!0,icon:f.jsx(Y.PiGridFour,{size:20}),checked:t!==null,onChange:m=>{var g,y;((g=s.onNodeGridModeRequest)==null?void 0:g.call(s,m,d))!==!0&&((y=r.current)==null||y.setNodeGridMode(m,d))}}),(t||a.bottomBarFill===!0)&&f.jsxs(W.HStack,{role:"group","aria-label":"Collision settings",gap:2,flexShrink:0,children:[!e&&t&&a.nodeGridSpacing!=="layout"&&f.jsxs(f.Fragment,{children:[f.jsx(W.Box,{width:"96px",flexShrink:0,display:"flex",alignItems:"center",children:f.jsx(Rd,{type:"range","aria-label":"Collision gap",title:`Gap: ${u}`,min:0,max:h,step:5,value:u,disabled:o,style:{color:Me(i),backgroundImage:`linear-gradient(to right, currentColor ${u/h*100}%, ${Me(l)} ${u/h*100}%)`},onChange:m=>p({gaps:Number(m.target.value)})})}),f.jsx(W.Text,{fontSize:"xs",color:c,width:"28px",textAlign:"right",fontVariantNumeric:"tabular-nums",children:u})]}),a.bottomBarFill!==!1&&f.jsx(Yr,{label:"Fill",hideLabel:!0,helper:t?"Fill available canvas space":"Enable Collision mode to use Fill",icon:f.jsx(Y.PiArrowsOut,{size:18}),checked:!!t&&!!d.fill,disabled:!t,onChange:m=>{var g,y;!t&&((g=s.onNodeGridModeRequest)==null?void 0:g.call(s,!0,{...d,fill:m}))===!0||m&&((y=s.onNodeGridFillRequest)==null?void 0:y.call(s,{...d,fill:m}))===!0||p({fill:m})}}),!e&&t&&d.fill&&f.jsx(sb,{})]})]})}const Ct=[];for(let e=0;e<256;++e)Ct.push((e+256).toString(16).slice(1));function hw(e,r=0){return(Ct[e[r+0]]+Ct[e[r+1]]+Ct[e[r+2]]+Ct[e[r+3]]+"-"+Ct[e[r+4]]+Ct[e[r+5]]+"-"+Ct[e[r+6]]+Ct[e[r+7]]+"-"+Ct[e[r+8]]+Ct[e[r+9]]+"-"+Ct[e[r+10]]+Ct[e[r+11]]+Ct[e[r+12]]+Ct[e[r+13]]+Ct[e[r+14]]+Ct[e[r+15]]).toLowerCase()}let Go;const pw=new Uint8Array(16);function gw(){if(!Go){if(typeof crypto>"u"||!crypto.getRandomValues)throw new Error("crypto.getRandomValues() not supported. See https://github.com/uuidjs/uuid#getrandomvalues-not-supported");Go=crypto.getRandomValues.bind(crypto)}return Go(pw)}const yw=typeof crypto<"u"&&crypto.randomUUID&&crypto.randomUUID.bind(crypto),Ou={randomUUID:yw};function kd(e,r,t){var o;if(Ou.randomUUID&&!e)return Ou.randomUUID();e=e||{};const n=e.random??((o=e.rng)==null?void 0:o.call(e))??gw();if(n.length<16)throw new Error("Random bytes length must be >= 16");return n[6]=n[6]&15|64,n[8]=n[8]&63|128,hw(n)}function mw(e,r){let t=1e5;const n=new Set(["__proto__","prototype","constructor"]),o=new Map,i=(c,l,d)=>{if(--t<0||d>100)throw new Error("Content references exceed the expansion limit.");if(!c||typeof c!="object")return c;if(Object.prototype.hasOwnProperty.call(c,"$contentRef")){const p=c,m=p.$contentRef,g=p.path??[];if(typeof m!="string"||!/^root(?:\.[A-Za-z0-9_%~-]+)*$/.test(m)||m.split(".").some(v=>n.has(v))||!Array.isArray(g)||g.some(v=>typeof v=="number"?!Number.isSafeInteger(v)||v<0:typeof v!="string"||n.has(v))||p.prefix!==void 0&&typeof p.prefix!="string"||p.suffix!==void 0&&typeof p.suffix!="string"||Object.keys(p).some(v=>!["$contentRef","path","prefix","suffix"].includes(v)))throw new Error("Invalid content reference.");const y=JSON.stringify([m,g]);if(l.includes(y))throw new Error(`Circular content reference: ${m}.`);if(!o.has(m)){const v=r(m);o.set(m,typeof v=="string"?JSON.parse(v):v)}let b=o.get(m);for(const v of g)b=b&&typeof b=="object"&&Object.prototype.hasOwnProperty.call(b,v)?b[v]:void 0;if(b===void 0)throw new Error(`Content reference not found: ${m}.`);const x=i(b,[...l,y],d+1);if(p.prefix!==void 0||p.suffix!==void 0){if(typeof x!="string")throw new Error("Content reference formatting requires a string.");return`${p.prefix??""}${x}${p.suffix??""}`}return x}if(Array.isArray(c)){const p=c.map(m=>i(m,l,d+1));return p.some((m,g)=>m!==c[g])?p:c}const u={...c};let h=!1;for(const[p,m]of Object.entries(c)){if(n.has(p))throw new Error("Unsafe content property.");const g=i(m,l,d+1);u[p]=g,h||(h=g!==m)}return h?u:c},s=typeof e=="string"?JSON.parse(e):e,a=i(s,[],0);return a===s?e:a}const go={label:"Untitled",description:"",isTask:!1,isLocked:!1},Ad={id:null,type:"text",data:{...go,viewProps:{width:"max-content !important",maxWidth:700,height:"100%",borderColor:"transparent",borderRadius:25,borderWidth:0,boxShadow:"none",textOverflow:"ellipsis",fontWeight:"bold",textColor:"gray.800",textAlign:"center"}}},$u={id:null,type:"objectView",data:{...go,headerTitle:null,viewProps:{width:"100%",borderWidth:2,borderRadius:53,height:"100%",justifyContent:"space-between",flexDirection:"row",textColor:"gray.900"}}},bw={id:null,type:"arrayView",data:{...go,viewProps:{width:"max-content !important",maxWidth:700,height:"100%",textAlign:"center",borderRadius:25,fontSize:"5xl",borderWidth:2,textOverflow:"ellipsis",wordBreak:"keep-all",fontWeight:"bold",textColor:"gray.900",placeholder:"Start Typing"}}},qu={id:null,type:"workflowStep",data:{...go,viewProps:{width:"max-content !important",maxWidth:350,minWidth:280,height:"100%",borderRadius:15,borderWidth:3}}},It=e=>typeof e=="object",cb=e=>Array.isArray(e),xw=["order","position","selected","locked","grabbed","grabbable","scratch"],vr=e=>Object.entries(e).reduce((r,[t,n])=>(!It(n)&&!t.startsWith("$")&&(r[t]=n),r),{}),Pd=(e,r)=>typeof e=="string"&&e.startsWith("$")?Uo(e,r):It(e)&&!cb(e)?Object.entries(e).reduce((t,[n,o])=>(typeof o=="string"&&o.startsWith("$")&&n==="..."?(delete t["..."],t[n]={...Uo(o,r),...e}):typeof o=="string"&&o.startsWith("$")?t[n]=Uo(o,r):t[n]=o,t),{}):e,wr=e=>Object.entries(e).reduce((r,[t,n])=>(It(n)&&t&&n&&!t.startsWith("$")&&(xw.includes(t)&&(t=t+"#"),r[t]=n),r),{}),Tr=(e,r,{label:t,parent:n=void 0},o,i=null)=>(i!==null&&(It(i)||cb(i))&&(i=JSON.stringify(i,null,2)),{data:{parent:n,...e.data,id:r,text:t||"",label:t,code:i||null,type:e.type,description:o}}),yr=(e,r,t=null,n=null,o=null,i=!1,s=null)=>({data:{id:kd(),source:o?r:e,target:o?e:r,label:n||"",isInverted:o,isEdgeAnimated:i,parent:s}}),Cr=(e,r=[])=>{const t={},n={};let o=[];if(e)for(const[i,s]of Object.entries(e))i.startsWith("$")&&i!=="$"?t[i.slice(1)]=s:i!=="$"?n[i]=s:i==="$"&&(o=s);return{newConfig:t,updatedObject:n,arrayObject:o}},Gr=(e,r)=>{let t=$u;const{view:n,borderColor:o,borderRadius:i,bgColor:s,textColor:a,fontSize:c,stepType:l}=r;e=n||e,l?t={...qu}:e==="object"?t=$u:e==="text"?t=Ad:e==="array"?t=bw:e==="workflowStep"&&(t={...qu});const d=t.data.viewProps;return t.data.viewProps={...d,borderRadius:i||(l?15:53),bgColor:s,borderColor:o,textColor:a,fontSize:c},t.data.config=r,{config:t}},In=(e,r)=>(e=r.find(n=>n.data.id===e)?`${e}.#`:e,e),Uo=(e,{ids:r,jsnObjct:t})=>{if(typeof e=="string"&&(e!=null&&e.startsWith("$"))){const n=e.replace("$","").replace("*","");e==null||e.endsWith("*");const o=r.find(a=>a.split(".").slice(-1)[0]===n||n===a);if(!o)return e;const i=vw(o,t);return JSON.stringify(i).includes(e)?e:i||e}return e},vw=(e,r)=>{let t=e.split(".").splice(1);return t=t[t.length-1]==="#"||t[t.length-1].includes("{")?t.slice(0,-2):t,(i=>t.reduce((s,a)=>{a=a.replace("[","").replace("]","");const{arrayObject:c}=Cr(s);return s=c.length?c:s,s[a]},i))(r)};function Hr(e,r="root",t=[]){try{const{arrayObject:n}=Cr(e);n.length&&(e=n);const o=vr(e),i=wr(e);return It(e)?(at(e)||at(e)&&r==="root"||!at(e)&&Object.keys(o).length||r==="root")&&t.push(r):t.push(r),Object.keys(i).length&&!at(e)?jn({chldPth:null,itrblObjct:i,nodes:t,path:r}):at(e)&&e.forEach((s,a)=>{const c=vr(s),l=wr(s),{newConfig:d,arrayObject:u}=Cr(s);let h=`${r}.${a}`;It(s)?Object.keys(c).length?(Hr(c,h,t),Object.keys(l).length&&!at(s)&&jn({chldPth:h,itrblObjct:l,nodes:t,path:r})):Object.keys(l).length&&!at(s)?jn({chldPth:h,itrblObjct:l,nodes:t,path:r}):at(s)&&lb({chldPth:h,item:s,nodes:t,path:r}):t.push(h)}),{nodes:t}}catch{return{nodes:t}}}const jn=({chldPth:e,itrblObjct:r,nodes:t,path:n})=>Object.entries(r).forEach(([o,i],s)=>{const a=vr(i),c=wr(i),{newConfig:l,arrayObject:d}=Cr(i);d.length&&(i=d),n.split(".").slice(0,2).join(".");let u=e?`${e}.${o}`:`${n}.${o}`;if(It(i)&&!at(i)){const h=Object.keys(a).length===0;if(h&&(Gr("array",l),t.push(u)),Object.keys(a).length){const p=at(i)?`${i.length||""}`:`{${Object.keys(i).length||""}}`;let m=u;h&&(m=`${u}.${p}`),Hr(i,m,t)}else Object.keys(c).length&&!at(i)?jn({chldPth:u,itrblObjct:c,path:u,nodes:t}):Hr(i,u,t)}else at(i)&&Hr(i,u,t)}),lb=({chldPth:e,item:r,nodes:t,path:n})=>r.forEach((o,i)=>{let s=`${e}.${i}`;const a=wr(o),c=vr(o);It(o)?!at(o)&&Object.keys(c).length?Hr(o,s,t):Object.keys(a).length&&!at(o)?jn({chldPth:s,itrblObjct:a,path:n,nodes:t}):at(o)&&lb({chldPth:s,item:o,nodes:t,path:n}):t.push(s)}),En=[];let _n;function $r(e,r="root",t=[],n=[],o="untitled",i={hideDefaultObject:!1,sprtObjctKy:!1,isCntr:!1},s={}){if(!e||typeof e!="object")return console.error("Invalid object passed",e),{nodes:t,edges:n};const a=e;if(r==="root"&&(En.length=0),!_n){const{nodes:d}=Hr(e);_n={ids:d,jsnObjct:e}}let{hideDefaultObject:c,sprtObjctKy:l}=i;try{r=In(r,t);const{newConfig:d,arrayObject:u}=Cr(e),h=Object.keys(s).length>0?s:d;u.length&&(e=u);const p=vr(e),m=wr(e),{label:g,collapsed:y,parent:b}=h;if(!It(e))t.push(Tr(Ad,r,{label:g||r,parent:b},e,a));else if(at(e)||at(e)&&r==="root"){const{config:x}=Gr("array",h),v=at(e)?`${e.length||""}`:`{${Object.keys(e).length||""}}`,w=r==="root"?o:`${o} ${v}`;t.push(Tr(x,r,{label:g||w,parent:b},e,at(a)?{[o]:a}:a))}else if(!at(e)&&Object.keys(p).length||r==="root"){const{config:x}=Gr(null,h),v=at(e)?`${e.length||""}`:`{${Object.keys(e).length||""}}`,w=r.split("."),C=w[w.length-1];let S=isNaN(Number(C))?null:Number(C)+1;const R=isNaN(Number(C))?C:w[w.length-2]+" "+S,P=r==="root"?o:R;let k=!1;Number.isNaN(Number(o))||(k=!0);const T=e;if(g){const{config:E}=Gr("object",h);t.push(Tr(E,r,{label:g||`${g} ${v}`,parent:b},p,T))}else x.data.headerTitle=P,t.push(Tr(x,r,{label:g,parent:b},p,T))}return y||(Object.keys(m).length&&!at(e)?Rn({flowConfig:i,chldPth:null,edges:n,isInverted:null,itrblObjct:m,nodes:t,path:r,newConfig:h}):at(e)&&e.forEach((x,v)=>{x=Pd(x,_n);const w=x,C=vr(x),S=wr(x),{newConfig:R,arrayObject:P}=Cr(x);P.length&&(x=P);const{config:k}=Gr(typeof x=="string"?"text":"array",R),{hideConfig:T,sourceLabel:E,label:M,isEdgeAnimated:_,parent:O}=R;c=c||T;const $=r==="root"&&i.isCntr,B=r.split(".").slice(0,2).join("."),N=En.includes(B),I=i.isCntr&&N||v%2===0&&$;let ee=`${r}.${v}`;ee=In(ee,t),I&&En.push(ee),It(x)?Object.keys(C).length&&!at(x)?(n.push(yr(r,ee,null,E,I,_)),$r(x,ee,t,n,M||v,i,R)):Object.keys(S).length&&!at(x)?Rn({flowConfig:i,chldPth:ee,isInverted:I,edges:n,itrblObjct:S,nodes:t,path:r,newConfig:R,forceIsInverted:!0}):at(x)?db({flowConfig:i,chldPth:ee,edges:n,isInverted:I,item:x,nodes:t,path:r}):It(x)&&Rn({flowConfig:i,chldPth:ee,isInverted:I,edges:n,itrblObjct:[x],nodes:t,path:r,newConfig:R}):(n.push(yr(r,ee,null,E,I,_)),t.push(Tr(k,ee,{label:M||String(x),parent:O},x,w)))})),{nodes:t,edges:n}}catch{return{nodes:t,edges:n}}}const Rn=({chldPth:e,flowConfig:r,edges:t,itrblObjct:n,nodes:o,isInverted:i,path:s,newConfig:a,forceIsInverted:c=!1})=>{let{hideDefaultObject:l,sprtObjctKy:d}=r;return Object.entries(n).forEach(([u,h],p)=>{h=Pd(h,_n);const m=h,g=vr(h),y=wr(h),{newConfig:b,arrayObject:x}=Cr(h);x.length&&(h=x);const{hideConfig:v,sourceLabel:w,label:C,content:S,target:R,targetLabel:P,collapsed:k,isEdgeAnimated:T,parent:E}=b;l=l||v;const M=s==="root"&&r.isCntr,_=s.split(".").slice(0,2).join("."),O=En.includes(_);c||(i=r.isCntr&&O||p%2===0&&M);let $=e?`${e}.${u}`:`${s}.${u}`;if($=In($,o),i&&En.push($),R&&t.push(yr($,R,null,P,i,T)),It(h)&&!at(h)){t.push(yr(s,$,null,w,i,T));const B=d||Object.keys(g).length===0;if(B){const N=S?"object":"array",{config:I}=Gr(N,b);I.data.headerTitle=S?C:null,o.push(Tr(I,$,{label:C||u,parent:E},h,m))}if(Object.keys(g).length&&!l){const N=at(h)?` ${h.length||""}`:`{${Object.keys(h).length||""}}`;let I=$;B&&(I=`${$}.${N}`,I=In(I,o),t.push(yr($,I,null,w,i,T))),$r(h,I,o,t,C||u,r,b)}else Object.keys(y).length&&!at(h)?Rn({chldPth:$,flowConfig:r,itrblObjct:y,path:$,edges:t,nodes:o,newConfig:b,isInverted:i}):$r(h,$,o,t,u,r,b)}else at(h)&&(t.push(yr(s,$,null,w,i,T)),$r(h,$,o,t,u,r,b))})},db=({flowConfig:e,chldPth:r,edges:t,isInverted:n,item:o,nodes:i,path:s})=>o.forEach((a,c)=>{let l=`${r}.${c}`;l=In(l,i);const d=a;a=Pd(a,_n);const u=wr(a),h=vr(a),{newConfig:p}=Cr(a),{collapsed:m,label:g,parent:y,sourceLabel:b,isEdgeAnimated:x,content:v}=p;It(a)?!at(a)&&Object.keys(h).length?(t.push(yr(s,l,null,b,n,x)),$r(a,l,i,t,c,e,p)):Object.keys(u).length&&!at(a)&&!m?Rn({chldPth:l,flowConfig:e,itrblObjct:u,path:s,edges:t,nodes:i,isInverted:n,newConfig:p}):at(a)&&db({flowConfig:e,chldPth:l,edges:t,isInverted:n,item:a,nodes:i,path:s}):(t.push(yr(s,l,null,b,n,x)),i.push(Tr(Ad,l,{label:g||String(a),parent:y},a,d)))});function ww(e,r){const t=new Set,n=(l,d="root")=>{if(!(!l||typeof l!="object")){l.$view==="parent"&&t.add(d),typeof l.$parent=="string"&&t.add(l.$parent);for(const[u,h]of Object.entries(l))(!u.startsWith("$")||u==="$")&&n(h,u==="$"?d:`${d}.${u}`)}};if(n(e),!t.size)return r;const o=new Map(r.nodes.map(l=>[l.data.id,l])),i=l=>{var p,m;let d=l.data.id;const u=new Set([l.data.id]);let h=l.data.parent;for(;h&&!u.has(h);)t.has(h)&&o.has(h)&&((p=Le(e,h))!=null&&p.$collapsed)&&(d=h),u.add(h),h=(m=o.get(h))==null?void 0:m.data.parent;return d},s=new Map(r.nodes.map(l=>[l.data.id,i(l)])),a=r.nodes.filter(l=>s.get(l.data.id)===l.data.id).map(l=>{if(!t.has(l.data.id))return l;const d=Le(e,l.data.id),u=!!(d!=null&&d.$collapsed);return{...l,data:{...l.data,...u?{type:"arrayView"}:{},config:{...l.data.config,parentContainer:!0,collapsed:u,...u?{labelBelow:!0,icon:(d==null?void 0:d.$icon)||"PiStack"}:{}}}}}),c=new Set(a.map(l=>l.data.id));return{nodes:a,edges:r.edges.flatMap(l=>{const d=s.get(l.data.source),u=s.get(l.data.target);return!d||!u||!c.has(d)||!c.has(u)?[]:d===l.data.source&&u===l.data.target?[l]:d===u?[]:[{...l,data:{...l.data,source:d,target:u,collapsedEndpoints:l.data.collapsedEndpoints??{source:l.data.source,target:l.data.target}}}]})}}function yo(e){if(!Array.isArray(e==null?void 0:e.$connections))return[];const r=new Map;return e.$connections.flatMap((t,n)=>{if(!t||typeof t!="object")return[];const o=t;if(typeof o.target!="string"||!/^root(?:\.|$)/.test(o.target))return[];if(o.sourceProperty!==void 0&&typeof o.sourceProperty!="string")return[];if(o.targetProperty!==void 0&&typeof o.targetProperty!="string")return[];const i=typeof o.id=="string"&&o.id?JSON.stringify(["id",o.id]):JSON.stringify(["ports",o.target,o.sourceProperty??null,o.targetProperty??null]),s=r.get(i)??0;return r.set(i,s+1),[{value:o,key:`${i}#${s}`,index:n}]})}function ub(e,r,t){const n=yo(e).find(c=>c.key===r);if(!n)return e;const o=t(n.value),i=e.$connections.flatMap((c,l)=>l===n.index?o?[o]:[]:[c]);if(i.length)return{...e,$connections:i};const{$connections:s,...a}=e;return a}function Cw(e){const r=[],t=(n,o)=>{if(!n||typeof n!="object")return n;if(Array.isArray(n))return n.map((i,s)=>t(i,`${o}.${s}`));for(const i of yo(n)){const s=i.value;r.push({data:{id:`connection:${JSON.stringify([o,i.key])}`,source:o,target:s.target,type:typeof s.type=="string"?s.type:void 0,sourceProperty:s.sourceProperty,targetProperty:s.targetProperty,icon:typeof s.icon=="string"?s.icon:void 0,label:typeof s.label=="string"?s.label:void 0,color:typeof s.color=="string"?s.color:void 0,isEdgeDashed:s.style==="dashed",isEdgeAnimated:s.style==="animated",...["dashed","traveling"].includes(s.animationVariant)?{edgeAnimationVariant:s.animationVariant}:{},connection:{address:o,key:i.key}}})}return Object.fromEntries(Object.entries(n).filter(([i])=>i!=="$connections").map(([i,s])=>[i,i==="$"?t(s,o):i.startsWith("$")?s:t(s,`${o}.${i}`)]))};return{json:t(e,"root"),edges:r}}const Kr="root",Lu=e=>e==="#"||e.startsWith("{")||/^\s\d*$/.test(e);function Gt(e){const r=e.split(".");for(r[0]===Kr&&r.shift();r.length&&Lu(r[r.length-1]);)r.pop();return r.filter(t=>!Lu(t))}function mo(e){return e==null||typeof e!="object"?e:Array.isArray(e.$)?e.$:e}function Le(e,r){return Gt(r).reduce((t,n)=>{var o;if(t!=null)return(o=mo(t))==null?void 0:o[n]},e)}function Sw(e){return Array.isArray(e)?[...e]:{...e}}function _t(e,r,t){const n=Gt(r),o=(i,s)=>{if(s===n.length)return t(i);const a=n[s],c=mo(i);if(c==null||typeof c!="object")return i;const l=o(c[a],s+1);if(Object.is(l,c[a]))return i;const d=Sw(c);return d[a]=l,c!==i?{...i,$:d}:d};return o(e,0)}function cr(e,r,t){const n=t===""&&r!=="$content"||t===void 0||t===null;if(Array.isArray(e))return n?e:{[r]:t,$:[...e]};const o=e!=null&&typeof e=="object"?{...e}:{};return e!=null&&typeof e!="object"&&(o.$label=String(e)),n?delete o[r]:o[r]=t,o}function xt(e,r,t,n){return _t(e,r,o=>t==="$label"&&typeof o=="string"&&typeof n=="string"&&n!==""?n:cr(o,t,n))}const Md=(e,r,t)=>xt(e,r,"$collapsed",t);function Nr(e){if(e.connection)return{address:e.connection.address,kind:"connection"};const r=e.collapsedEndpoints??e,t=e.isInverted?r.target:r.source,n=e.isInverted?r.source:r.target,o=Gt(t).join("."),i=Gt(n).join(".");return i.startsWith(o?o+".":"")&&i!==o?{address:n,kind:"hierarchy"}:o.startsWith(i?i+".":"")&&o!==i?{address:t,kind:"hierarchy"}:{address:t,kind:"target"}}function gr(e,r,t,n){if(r.connection){const a=r.connection;return _t(e,a.address,c=>ub(c,a.key,l=>{if(t==="$edgeIcon")return cr(l,"icon",n);if(t==="$edgeType")return cr(l,"type",n);if(t==="$edgeAnimationVariant")return cr(l,"animationVariant",n);if(t==="$sourceLabel"||t==="$edgeColor")return cr(l,t==="$sourceLabel"?"label":"color",n);const d=t==="$isEdgeAnimated"?"animated":"dashed";return n?{...l,style:d}:l.style===d?cr(l,"style",void 0):l}))}const{address:o,kind:i}=Nr(r),s=i==="target"&&t==="$sourceLabel"?"$targetLabel":i==="target"&&t==="$edgeType"?"$targetEdgeType":i==="target"&&t==="$edgeIcon"?"$targetIcon":i==="target"&&t==="$edgeAnimationVariant"?"$targetAnimationVariant":t;return _t(e,o,a=>cr(a,s,n))}const fb=(e,r,t)=>gr(gr(e,r,"$isEdgeAnimated",t==="animated"||void 0),r,"$isEdgeDashed",t==="dashed"||void 0);function Id(e,r,t,n){let o=n||"";const i=_t(e,r,a=>{const c=mo(a);if(Array.isArray(c)){o=String(c.length);const d=[...c,t];return c===a?d:{...a,$:d}}const l=a!=null&&typeof a=="object"&&!Array.isArray(a)?{...a}:a!=null&&typeof a!="object"?{$label:String(a)}:{};if(!o){let d=1;for(;`node_${d}`in l;)d++;o=`node_${d}`}return l[o]=t,l}),s=Gt(r);return{json:i,address:[Kr,...s,o].join(".")}}function hb(e,r){const t=Gt(r);if(!t.length)return e;const n=t[t.length-1],o=[Kr,...t.slice(0,-1)].join(".");return _t(e,o,i=>{const s=mo(i);if(s==null||typeof s!="object"||!Object.prototype.hasOwnProperty.call(s,n))return i;if(Array.isArray(s)){const l=s.filter((d,u)=>String(u)!==n);return s===i?l:{...i,$:l}}const{[n]:a,...c}=i;return c})}const pb=(e,r,t,n)=>xt(n?_t(e,r,o=>cr(o,"$targetLabel",n)):e,r,"$target",t);function Td(e,r,t){const n=Le(e,r);return yo(n).some(({value:i})=>i.target===t.target&&i.sourceProperty===t.sourceProperty&&i.targetProperty===t.targetProperty)?e:_t(e,r,i=>cr(i,"$connections",[...Array.isArray(i==null?void 0:i.$connections)?i.$connections:[],{...t,id:t.id||kd()}]))}function gb(e,r){if(r.connection){const i=r.connection;return yo(Le(e,i.address)).some(s=>s.key===i.key)?{json:_t(e,i.address,s=>ub(s,i.key,()=>null)),removed:!0}:{json:e,removed:!1}}const{address:t,kind:n}=Nr(r);return n==="hierarchy"?Le(e,t)===void 0?{json:e,removed:!1}:{json:_t(e,t,i=>({...i,$hideParentEdge:!0})),removed:!0}:n!=="target"?{json:e,removed:!1}:{json:_t(e,t,i=>{const{$target:s,$targetLabel:a,...c}=i||{};return c}),removed:!0}}function md(e,r={}){var x;const t=Cw(e),{nodes:n,edges:o}=$r(t.json,Kr,[],[],r.title||"untitled",{hideDefaultObject:!!r.hideDefaultObject,sprtObjctKy:!!r.separateObjectKeys,isCntr:!!r.isCenter}),i=new Set(n.map(v=>v.data.id)),s=new Map;for(const v of n){const w=v.data.id;if(!w.endsWith(".0")||Le(e,w)!==void 0)continue;const C=w.slice(0,-2),S=Le(e,C);!i.has(C)&&S&&typeof S=="object"&&!Array.isArray(S)&&typeof S.$label=="string"&&Object.keys(S).every(R=>R.startsWith("$")&&R!=="$")&&s.set(w,C)}const a=v=>s.get(v)??v,c=new Set(n.flatMap(v=>v.data.parent?[a(v.data.parent)]:[])),l=new Map;if(r.isCenter){const v=new Map;for(const{data:w}of o){const C=Nr(w);if(C.kind==="hierarchy")l.set(a(C.address),!!w.isInverted);else if(!Array.isArray(e)&&e.$hideRoot===!0){const S=a(w.isInverted?w.source:w.target);if(Gt(S).length!==1)continue;const R=!!w.isInverted;v.set(S,v.has(S)&&v.get(S)!==R?null:R)}}for(const[w]of l){const C=`${Kr}.${Gt(w)[0]}`,S=v.get(C);typeof S=="boolean"&&l.set(w,S)}}const d=n.map(v=>{var k;const w=a(v.data.id),C=Le(e,w),S={...v.data,id:w};l.has(w)&&(S.config={...S.config,isInverted:l.get(w)});const R=C&&typeof C=="object"&&!Array.isArray(C)&&"$"in C?C.$:C;if((Array.isArray(R)?R.length>0:R&&typeof R=="object"&&Object.keys(R).some(T=>!T.startsWith("$")))&&(S.config={...S.config,collapsed:!!C.$collapsed}),c.has(w)||(S.viewProps={...S.viewProps},delete S.viewProps.borderWidth),!C||typeof C!="object"||Array.isArray(C))return{data:S};if(C.$view==="parent"&&(S.type="objectView",S.config={...S.config,typeView:"parent",parentContainer:!0,collapsed:!!C.$collapsed}),C.$view==="grid"){S.type="grid";const T=C.$gridSize;if(T!==void 0&&(!T||![T.width,T.height].every(E=>Number.isFinite(E)&&E>0&&E<=16384)))throw new Error("Invalid grid frame size.");S.config={...S.config,typeView:"grid",documentId:C.$document,gridSize:T},S.viewProps={...S.viewProps,bgColor:C.$bgColor??"transparent",borderRadius:C.$borderRadius??0,borderWidth:C.$borderWidth??0}}if(C.$form&&typeof C.$form=="object"&&(S.config={...S.config,form:C.$form},S.type="objectView"),Array.isArray(C.$ports)){const T=C.$ports.filter(E=>E&&typeof E.id=="string"&&["source","target"].includes(E.role)&&["top","right","bottom","left"].includes(E.side));S.config={...S.config,ports:T}}S.parent&&(S.parent=a(S.parent)),typeof C.$label=="string"&&(S.label=C.$label,S.headerTitle=C.$label),typeof C.$subtitle=="string"&&(S.config={...S.config,subtitle:C.$subtitle}),typeof C.$outline=="boolean"&&(S.viewProps={...S.viewProps,outline:C.$outline}),["solid","dashed","dotted","double"].includes(C.$borderStyle)&&(S.viewProps={...S.viewProps,borderStyle:C.$borderStyle}),Number.isFinite(C.$borderWidth)&&C.$borderWidth>=0&&(S.viewProps={...S.viewProps,borderWidth:C.$borderWidth}),Number.isFinite(C.$borderRadius)&&C.$borderRadius>=0&&(S.viewProps={...S.viewProps,borderRadius:C.$borderRadius});for(const T of["width","height"]){const E=C[`$${T}`];typeof E=="number"&&Number.isFinite(E)&&E>0&&(S.viewProps={...S.viewProps,[T]:`${E}px`})}if(typeof C.$isNodeAnimated=="boolean"&&(S.isNodeAnimated=C.$isNodeAnimated),["traveling","pulse"].includes(C.$nodeAnimationVariant)&&(S.nodeAnimationVariant=C.$nodeAnimationVariant),typeof C.$content=="string"||C.$contentFormat==="jsx"&&Array.isArray(C.$content)){S.config={...S.config,content:C.$content};const T=C.$contentFormat??"markdown";if(!["markdown","html","jsx"].includes(T))throw new Error("Invalid content format: expected markdown, html, or jsx.");if(S.config.contentFormat=T,T==="jsx")try{const E=mw(C.$content,M=>{const _=Le(e,M);return(_==null?void 0:_.$contentFormat)==="jsx"?_.$content:void 0});E!==C.$content&&(S.config.contentSource=C.$content,S.config.content=E)}catch(E){S.config.contentSource=C.$content,S.config.content=[],S.config.contentReferenceError=E instanceof Error?E.message:"Invalid content reference."}C.$view||(S.type="objectView")}return(((k=S.config)==null?void 0:k.collapsed)!==void 0||C.$collapsed!==void 0||C.$icon!==void 0)&&(S.config={...S.config||{}},(C.$collapsed!==void 0||S.config.collapsed!==void 0)&&(S.config.collapsed=!!C.$collapsed),C.$icon!==void 0&&(S.config.icon=C.$icon)),{data:S}}),u=new Map,h=o.map(v=>{let w=a(v.data.source),C=a(v.data.target),S=v.data.isInverted;const R=Nr(v.data),P=l.get(a(R.address));R.kind==="hierarchy"&&P!==void 0&&P!==!!S&&([w,C]=[C,w],S=P);const k=`${w}->${C}`,T=u.get(k)??0;u.set(k,T+1);const E={...v.data,id:T?`${k}#${T}`:k,source:w,target:C,isInverted:S},M=Nr(E),_=Le(e,M.address);if(_&&typeof _=="object"){const O=_[M.kind==="target"?"$targetEdgeType":"$edgeType"];typeof O=="string"&&(E.type=O);const $=_[M.kind==="target"?"$targetIcon":"$edgeIcon"];typeof $=="string"&&(E.icon=$),_.$isEdgeAnimated!==void 0&&(E.isEdgeAnimated=!!_.$isEdgeAnimated);const B=_[M.kind==="target"?"$targetAnimationVariant":"$edgeAnimationVariant"];["dashed","traveling"].includes(B)&&(E.edgeAnimationVariant=B),_.$isEdgeDashed!==void 0&&(E.isEdgeDashed=!!_.$isEdgeDashed),_.$edgeColor&&(E.color=_.$edgeColor)}return{data:E}});if(!Array.isArray(e)&&(e==null?void 0:e.$hideRoot)===!0){const v=d.findIndex(w=>w.data.id===Kr);v!==-1&&d.splice(v,1)}const p=new Set(d.map(v=>v.data.id));for(let v=h.length-1;v>=0;v--){const w=h[v].data,C=Nr(w);(!p.has(w.source)||!p.has(w.target)||C.kind==="hierarchy"&&((x=Le(e,C.address))==null?void 0:x.$hideParentEdge)===!0)&&h.splice(v,1)}h.push(...t.edges.filter(v=>p.has(v.data.source)&&p.has(v.data.target)));const m=ww(e,{nodes:d,edges:h}),g=m.nodes.filter(v=>{var w;return(w=v.data.config)==null?void 0:w.collapsed}).map(v=>Gt(v.data.id));if(!g.length)return m;const y=m.nodes.filter(v=>{const w=Gt(v.data.id);return!g.some(C=>C.length<w.length&&C.every((S,R)=>S===w[R]))}),b=new Set(y.map(v=>v.data.id));return{nodes:y,edges:m.edges.filter(v=>b.has(v.data.source)&&b.has(v.data.target))}}function jw(e,r){const t=new Set(e.filter(c=>{var l,d;return(d=(l=c.data)==null?void 0:l.config)==null?void 0:d.collapsed}).map(c=>c.data.id));if(!t.size)return{nodes:e,edges:r};const n=new Map(e.map(c=>[c.data.id,c])),o=new Set(e.map(c=>c.data.parent).filter(Boolean)),i=new Map(e.map(c=>{var h;let l=c.data.id,d=c.data.parent;const u=new Set([l]);for(;d&&!u.has(d);)t.has(d)&&(l=d),u.add(d),d=(h=n.get(d))==null?void 0:h.data.parent;return[c.data.id,l]})),s=new Map;for(const c of r){const l=c.data.isInverted?c.data.target:c.data.source,d=c.data.isInverted?c.data.source:c.data.target;(s.get(l)??s.set(l,[]).get(l)).push(d)}const a=new Set(e.filter(c=>i.get(c.data.id)!==c.data.id).map(c=>c.data.id));for(const c of t){if(o.has(c))continue;const l=[...s.get(c)||[]];for(;l.length;){const d=l.pop();t.has(d)||a.has(d)||(a.add(d),l.push(...s.get(d)||[]))}}return{nodes:e.filter(c=>!a.has(c.data.id)).map(c=>{var l;return t.has(c.data.id)&&o.has(c.data.id)?{...c,data:{...c.data,type:"arrayView",label:c.data.label??c.data.headerTitle,config:{...c.data.config,parentContainer:!0,labelBelow:!0,icon:((l=c.data.config)==null?void 0:l.icon)||"PiStack"}}}:c}),edges:r.flatMap(c=>{const l=i.get(c.data.source)??c.data.source,d=i.get(c.data.target)??c.data.target;return a.has(l)||a.has(d)?[]:l===c.data.source&&d===c.data.target?[c]:l===d?[]:[{...c,data:{...c.data,source:l,target:d,collapsedEndpoints:c.data.collapsedEndpoints??{source:c.data.source,target:c.data.target}}}]})}}function Nd(e,r){const t=JSON.parse(e);let n=512;const o=(s,a=[])=>{if(--n<0)throw new Error("Interface exceeds the 512-type expansion limit.");if(!s||typeof s!="object"||Array.isArray(s))throw new Error("Expected a JSON Schema object.");const c=new Set(["$schema","$id","$defs","definitions","$ref","title","description","default","examples","type","properties","required","items","enum","const","anyOf","additionalProperties"]);for(const d of Object.keys(s))if(!c.has(d))throw new Error(`Unsupported JSON Schema keyword: ${d}`);const l=["$schema","$id","$defs","definitions","title","description","default","examples"];if(s.$ref){if(Object.keys(s).some(u=>!["$ref","title","description"].includes(u)))throw new Error("Use $ref without sibling constraints.");if(typeof s.$ref!="string"||!s.$ref.startsWith("#/")||a.includes(s.$ref))throw new Error("Only nonrecursive local $ref references are supported.");let d=t;for(const u of s.$ref.slice(2).split("/")){const h=u.replace(/~1/g,"/").replace(/~0/g,"~");if(!d||!Object.prototype.hasOwnProperty.call(d,h))throw new Error(`Unresolved reference: ${s.$ref}`);d=d[h]}return o(d,[...a,s.$ref])}if(s.anyOf){if(!Array.isArray(s.anyOf)||!s.anyOf.length||Object.keys(s).some(d=>d!=="anyOf"&&!l.includes(d)))throw new Error("Use a nonempty anyOf without sibling type constraints.");return{kind:"union",types:s.anyOf.map(d=>o(d,a))}}if(Object.prototype.hasOwnProperty.call(s,"const")||s.enum){if(Object.keys(s).some(h=>![...l,"const","enum","type"].includes(h))||s.enum&&Object.prototype.hasOwnProperty.call(s,"const"))throw new Error("Use enum or const without sibling constraints other than type.");const d=Object.prototype.hasOwnProperty.call(s,"const")?[s.const]:s.enum;if(!Array.isArray(d)||!d.length)throw new Error("Expected a nonempty enum.");return{kind:"union",types:d.map(h=>{if(h!==null&&!["string","number","boolean"].includes(typeof h))throw new Error("Only primitive literals are supported.");const p=h===null?"null":typeof h;if(s.type&&!(Array.isArray(s.type)?s.type:[s.type]).some(m=>m===p||m==="integer"&&Number.isInteger(h)))throw new Error("Literal does not match its declared type.");return{kind:"literal",value:h}})}}if(Array.isArray(s.type)){if(!s.type.length||s.type.some(d=>typeof d!="string"))throw new Error("Expected a nonempty list of primitive types.");if(Object.keys(s).some(d=>d!=="type"&&!l.includes(d)))throw new Error("Use anyOf for unions with object or array constraints.");return{kind:"union",types:s.type.map(d=>o({type:d},a))}}if((s.properties||s.required||s.additionalProperties!==void 0)&&s.type!=="object"&&s.type!==void 0)throw new Error("Object constraints require an object type.");if(s.items&&s.type!=="array")throw new Error("items requires an array type.");if(s.type==="object"||s.properties){if(s.additionalProperties!==void 0&&s.additionalProperties!==!0)throw new Error("Closed objects and typed additionalProperties are not supported.");if(!s.properties||typeof s.properties!="object"||Array.isArray(s.properties))throw new Error("Object schemas must declare properties.");if(s.required!==void 0&&(!Array.isArray(s.required)||s.required.some(u=>typeof u!="string"||!Object.prototype.hasOwnProperty.call(s.properties,u))))throw new Error("required must list declared property names.");return{kind:"object",properties:Object.fromEntries(Object.entries(s.properties).map(([u,h])=>[u,{type:o(h,a),optional:!(s.required??[]).includes(u)}]))}}if(s.type==="array")return{kind:"array",items:o(s.items,a)};if(["string","number","integer","boolean","null"].includes(s.type))return{kind:s.type};throw new Error("Every property must declare a supported type.")},i=o(t);if(i.kind!=="object")throw new Error("The root schema must be an object keyed by node ID.");if(Object.values(i.properties).some(s=>s.type.kind!=="object"))throw new Error("Each node must declare an object of property types.");return{name:r,nodes:i.properties}}async function Od(e,r,t,n={}){var m;let o=512;const i=await import("typescript"),s=i.createSourceFile(r,e,i.ScriptTarget.Latest,!0,i.ScriptKind.TS),a=s.parseDiagnostics;if(a!=null&&a.length)throw new Error("Invalid TypeScript syntax.");const c=new Map;for(const g of s.statements){if(!i.isInterfaceDeclaration(g)&&!i.isTypeAliasDeclaration(g))throw new Error("Upload interfaces/type aliases only; imports and executable code are not supported.");if((m=g.typeParameters)!=null&&m.length||c.has(g.name.text))throw new Error("Generics and duplicate declarations are not supported.");c.set(g.name.text,g)}const l=(g,y)=>{var C;const b={},x=g.find(S=>i.isIndexSignatureDeclaration(S));let v;if(x&&n.allowJson&&i.isIndexSignatureDeclaration(x)){if(g.filter(S=>i.isIndexSignatureDeclaration(S)).length!==1||x.parameters.length!==1||((C=x.parameters[0].type)==null?void 0:C.kind)!==i.SyntaxKind.StringKeyword||!x.type)throw new Error("Only one string-keyed index signature is supported for forms.");v=u(x.type,y)}return{kind:"object",properties:Object.fromEntries(g.filter(S=>S!==x||!v).map(S=>{if(!i.isPropertySignature(S)||!S.type||!S.name||!i.isIdentifier(S.name)&&!i.isStringLiteral(S.name))throw new Error("Only explicitly typed named properties are supported.");const R=u(S.type,y),P=n.allowJson?i.getJSDocTags(S).filter(k=>k.tagName.text==="port"):[];if(P.length>1)throw new Error(`Duplicate port declaration: ${S.name.text}`);if(P.length){const[k,T,E]=String(P[0].comment??"").trim().split(/\s+/);if(k!=="config"||!T||E||!c.has(T))throw new Error(`Config port ${S.name.text} requires @port config ResourceType`);const M=R.kind==="array";if((R.kind==="array"?R.items.kind:R.kind)!=="string")throw new Error(`Config port ${S.name.text} must be a string or string array reference`);b[S.name.text]={kind:"config",resourceType:T,multiple:M}}return[S.name.text,{type:R,optional:!!S.questionToken}]})),...v?{additionalProperties:v}:{},...Object.keys(b).length?{ports:b}:{}}},d=(g,y)=>{var C;if(y.includes(g))throw new Error("Recursive types are not supported.");const b=c.get(g);if(!b)throw new Error(`Unknown type: ${g}`);let x;if(i.isInterfaceDeclaration(b)){if((C=b.heritageClauses)!=null&&C.length)throw new Error("Interface inheritance is not supported; declare properties explicitly.");x=l(b.members,[...y,g])}else x=u(b.type,[...y,g]);const v=n.allowJson?i.getJSDocTags(b).filter(S=>S.tagName.text==="port"):[];if(!v.length)return x;if(x.kind!=="object")throw new Error("Node ports require an object interface");const w={...x.ports};for(const S of v){const[R,P,...k]=String(S.comment??"").trim().split(/\s+/);if(!["input","output","error"].includes(R)||!/^[A-Za-z][\w-]*$/.test(P??""))throw new Error("Node ports require @port input|output|error Name");const T=k.length?JSON.parse(k.join(" ")):void 0;if(T!==void 0&&typeof T!="string")throw new Error("Node port labels must be JSON strings");if(Object.prototype.hasOwnProperty.call(w,P))throw new Error(`Duplicate port declaration: ${P}`);w[P]={kind:R,...typeof T=="string"?{label:T}:{}}}return{...x,ports:w}},u=(g,y)=>{var b,x,v;if(--o<0)throw new Error("Interface exceeds the 512-type expansion limit.");if(g.kind===i.SyntaxKind.StringKeyword)return{kind:"string"};if(g.kind===i.SyntaxKind.NumberKeyword)return{kind:"number"};if(g.kind===i.SyntaxKind.BooleanKeyword)return{kind:"boolean"};if(n.allowJson&&[i.SyntaxKind.AnyKeyword,i.SyntaxKind.UnknownKeyword].includes(g.kind))return{kind:"json"};if(i.isParenthesizedTypeNode(g))return u(g.type,y);if(i.isUnionTypeNode(g))return{kind:"union",types:g.types.map(w=>u(w,y))};if(i.isArrayTypeNode(g))return{kind:"array",items:u(g.elementType,y)};if(i.isTypeLiteralNode(g))return l(g.members,y);if(i.isLiteralTypeNode(g)){const w=g.literal;if(i.isStringLiteral(w))return{kind:"literal",value:w.text};if(i.isNumericLiteral(w))return{kind:"literal",value:Number(w.text)};if(w.kind===i.SyntaxKind.NullKeyword)return{kind:"null"};if(w.kind===i.SyntaxKind.TrueKeyword||w.kind===i.SyntaxKind.FalseKeyword)return{kind:"literal",value:w.kind===i.SyntaxKind.TrueKeyword}}if(i.isTypeReferenceNode(g)&&i.isIdentifier(g.typeName)){if(n.allowJson&&g.typeName.text==="Record"&&!c.has("Record")&&((b=g.typeArguments)==null?void 0:b.length)===2&&g.typeArguments[0].kind===i.SyntaxKind.StringKeyword)return{kind:"object",properties:{},additionalProperties:u(g.typeArguments[1],y)};if(g.typeName.text==="Array"&&((x=g.typeArguments)==null?void 0:x.length)===1)return{kind:"array",items:u(g.typeArguments[0],y)};if(!((v=g.typeArguments)!=null&&v.length))return d(g.typeName.text,y)}throw new Error(`Unsupported TypeScript type: ${g.getText(s)}`)},h=t??(c.has("Graph")?"Graph":c.size===1?[...c.keys()][0]:void 0);if(!h)throw new Error("Declare an interface Graph keyed by node ID.");const p=d(h,[]);if(p.kind!=="object")throw new Error("Graph must be an object keyed by node ID.");return p}async function yb(e,r){const t=await Od(e,r);if(Object.values(t.properties).some(n=>n.type.kind!=="object"))throw new Error("Each node must declare an object of property types.");return{name:r,nodes:t.properties}}function mn(e,r){if(e.kind==="json"||r.kind==="json"||e.kind==="object"&&e.additionalProperties||r.kind==="object"&&r.additionalProperties)return!1;if(e.kind==="union")return e.types.every(t=>mn(t,r));if(r.kind==="union")return r.types.some(t=>mn(e,t));if(e.kind==="literal"){if(r.kind==="literal")return e.value===r.value;const t=e.value===null?"null":typeof e.value;return r.kind===t||r.kind==="integer"&&typeof e.value=="number"&&Number.isInteger(e.value)}return e.kind==="integer"&&r.kind==="number"?!0:e.kind==="array"&&r.kind==="array"?mn(e.items,r.items):e.kind==="object"&&r.kind==="object"?Object.entries(r.properties).every(([t,n])=>{const o=Object.prototype.hasOwnProperty.call(e.properties,t)?e.properties[t]:void 0;return o?(n.optional||!o.optional)&&mn(o.type,n.type):n.optional}):e.kind===r.kind}function $d(e,r){if(!r.sourceProperty&&!r.targetProperty)return;const t=(s,a)=>{var d;const c=Object.prototype.hasOwnProperty.call(e.nodes,s)?s:s.replace(/^root\./,""),l=Object.prototype.hasOwnProperty.call(e.nodes,c)?(d=e.nodes[c])==null?void 0:d.type:void 0;return a&&(l==null?void 0:l.kind)==="object"&&Object.prototype.hasOwnProperty.call(l.properties,a)?l.properties[a]:void 0},n=t(r.source,r.sourceProperty),o=t(r.target,r.targetProperty);if(!n||!o)return"Unverified: source or target property is missing from the interface.";const i=s=>s.kind==="json"||s.kind==="object"&&(!!s.additionalProperties||Object.values(s.properties).some(a=>i(a.type)))||s.kind==="array"&&i(s.items)||s.kind==="union"&&s.types.some(i);if(i(n.type)||i(o.type))return"Unverified: arbitrary JSON or dictionary fields require runtime validation.";if(n.optional&&!o.optional)return"Optional source cannot supply a required target property.";if(!mn(n.type,o.type))return`Incompatible property types: ${r.sourceProperty} -> ${r.targetProperty}.`}async function mb(e){if(e.size>256*1024)throw new Error("Interface must be 256 KB or smaller.");const r=await e.text();if(/\.json$/i.test(e.name))return Nd(r,e.name);if(/\.ts$/i.test(e.name))return yb(r,e.name);throw new Error("Choose a .ts interface or .json JSON Schema file.")}const Fu=new WeakMap;function Qr(e){if(!e||typeof e!="object")return e;const r=Fu.get(e);if(r)return r;const t=()=>{throw new Error("Form callback data is read-only. Return edits instead.")},n=new Proxy(Array.isArray(e)?[]:{},{get:(o,i)=>Qr(Reflect.get(e,i)),has:(o,i)=>Reflect.has(e,i),ownKeys:()=>Reflect.ownKeys(e),getOwnPropertyDescriptor:(o,i)=>{const s=Reflect.getOwnPropertyDescriptor(e,i);return s&&{...s,value:Qr(Reflect.get(e,i)),configurable:i!=="length"||!Array.isArray(e)}},set:t,deleteProperty:t,defineProperty:t,setPrototypeOf:t,preventExtensions:t});return Fu.set(e,n),n}function on(e,r,t){var o;const n=r.split(".");for(let i=n.length;i>0;i--){const s=n.slice(0,i).join("."),a=(o=Le(e,s))==null?void 0:o.$form;if(!(a!=null&&a.$type))continue;let c=Object.prototype.hasOwnProperty.call(t,a.$type)?t[a.$type]:void 0;for(const u of n.slice(i))(c==null?void 0:c.kind)==="array"&&/^\d+$/.test(u)?c=c.items:(c==null?void 0:c.kind)==="object"?c=Object.prototype.hasOwnProperty.call(c.properties,u)?c.properties[u].type:void 0:c=void 0;if((c==null?void 0:c.kind)!=="object")return;const l=n.slice(i).join("."),d=Object.fromEntries(Object.entries(a.$fields??{}).filter(([u])=>!l||u.startsWith(`${l}.`)).map(([u,h])=>[l?u.slice(l.length+1):u,h]));return{type:c,fields:d,binding:a}}}async function qd(e,r){if(e.size>256*1024)throw new Error("Form schema exceeds 256 KB.");const t=await e.text();if(e.name.endsWith(".ts")){if(!r.length||r.length>32)throw new Error("Choose between 1 and 32 form interface names.");const o=[],i=new Set(r);for(const s of i){if(i.size>32)throw new Error("Choose between 1 and 32 form interface names.");const a=await Od(t,e.name,s,{allowJson:!0});o.push([s,a]);for(const c of Object.values(a.ports??{}))c.resourceType&&i.add(c.resourceType)}return Object.fromEntries(o)}if(!e.name.endsWith(".json"))throw new Error("Choose a .ts interface or .json schema file.");const n=Nd(t,e.name);return Object.fromEntries(Object.entries(n.nodes).map(([o,i])=>[o,i.type]))}function bo(e,r){return!e||("$in"in e?e.$in.includes(Le(r,e.$address)):Le(r,e.$address)===e.$equals)}function kn(e){const r=e.kind==="array"?e.items:e,t=r.kind==="union"?r.types:[r];if(t.every(n=>n.kind==="literal"))return t.map(n=>({label:String(n.value),value:n.value}))}function Ut(e,r,t){if(r===void 0||r==="")return t?"Required":void 0;if(e.kind==="json"){const n=new Set,o=i=>{if(i===null||typeof i=="string"||typeof i=="boolean")return!0;if(typeof i=="number")return Number.isFinite(i);if(!i||typeof i!="object"||n.has(i)||!Array.isArray(i)&&![Object.prototype,null].includes(Object.getPrototypeOf(i)))return!1;n.add(i);const s=Object.values(i).every(o);return n.delete(i),s};return o(r)?void 0:"Expected a JSON value"}if(e.kind==="union")return e.types.some(n=>!Ut(n,r,!0))?void 0:"Choose a valid value";if(e.kind==="literal")return r===e.value?void 0:"Choose a valid value";if(e.kind==="array")return Array.isArray(r)&&r.every(n=>!Ut(e.items,n,!0))?void 0:"Invalid list value";if(e.kind==="object")return!r||typeof r!="object"||Array.isArray(r)?"Expected an object":e.additionalProperties&&Object.entries(r).some(([n,o])=>!Object.prototype.hasOwnProperty.call(e.properties,n)&&Ut(e.additionalProperties,o,!0))?"Invalid dictionary value":Object.entries(e.properties).some(([n,o])=>Ut(o.type,r[n],!o.optional))?"Invalid object fields":void 0;if(e.kind==="null")return r===null?void 0:"Expected null";if(e.kind==="integer")return Number.isInteger(r)?void 0:"Expected a whole number";if(typeof r!==e.kind||typeof r=="number"&&!Number.isFinite(r))return`Expected ${e.kind}`}function zu(e,r){const t=r.address.split(".");if(t.shift()!=="root"||!t.length||t.some(a=>!a||["__proto__","prototype","constructor","#"].includes(a)))throw new Error("Invalid form field address.");const n=t.pop(),o=n==="$bgColor"||n==="$textColor"||n==="$borderColor";if(t.some(a=>a.startsWith("$"))||n.startsWith("$")&&!o)throw new Error("Unsupported form metadata address.");const i=["root",...t].join("."),s=Le(e,i);if(!s||typeof s!="object")throw new Error(`Missing form parent: ${i}`);if(o){if(r.op==="set"&&typeof r.value!="string")throw new Error("Node colors must be strings.");return xt(e,i,n,r.op==="remove"?void 0:r.value)}return _t(e,i,a=>{const c=Array.isArray(a.$)?a.$:a;if(r.op==="remove"&&!Object.prototype.hasOwnProperty.call(c,n)||r.op==="set"&&Object.is(c[n],r.value))return a;const l=Array.isArray(c)?[...c]:{...c};if(Array.isArray(l)&&(!/^(0|[1-9]\d*)$/.test(n)||Number(n)>=l.length))throw new Error("Invalid array address.");return r.op==="remove"?Array.isArray(l)?l.splice(Number(n),1):delete l[n]:Object.defineProperty(l,n,{value:structuredClone(r.value),enumerable:!0,writable:!0,configurable:!0}),c===a?l:{...a,$:l}})}function xo(e,r,t){let n=zu(e,r.value===void 0?{op:"remove",address:r.address}:{op:"set",address:r.address,value:r.value});const o=t==null?void 0:t({...r,previousValue:Qr(Le(e,r.address)),data:Qr(n)});if(o&&!Array.isArray(o))throw new Error("Form change handlers must return edits synchronously.");for(const i of Array.isArray(o)?o:[]){if(i.op!=="set"&&i.op!=="remove")throw new Error("Unsupported form edit.");n=zu(n,i)}return n}const An="data:image/svg+xml;base64,";function hr(e){if(e.startsWith(An))return!0;try{const r=new URL(e);return(r.protocol==="https:"||r.protocol==="http:")&&!r.username&&!r.password}catch{return!1}}async function Ew(e){if(e.size>256*1024)throw new Error("SVG must be 256 KB or smaller.");const r=await e.text(),t=new DOMParser().parseFromString(r,"image/svg+xml");if(t.doctype||t.querySelector("parsererror")||t.documentElement.localName!=="svg"||t.documentElement.namespaceURI!=="http://www.w3.org/2000/svg")throw new Error("Choose a valid SVG file.");if(t.querySelector("script, foreignObject")||[...t.querySelectorAll("*")].some(i=>[...i.attributes].some(s=>/^on/i.test(s.name))))throw new Error("SVG scripts and event handlers are not allowed.");const n=new TextEncoder().encode(r);let o="";for(const i of n)o+=String.fromCharCode(i);return An+btoa(o)}const or=({name:e,svg:r=!1,...t})=>{const[n,o]=j.useState(null),[i,s]=j.useState(!0),[a,c]=j.useState(!1),l=typeof e=="string"&&hr(e);if(j.useEffect(()=>{if(l||!e||e.length<2){o(null),s(!1);return}s(!0),c(!1),(async()=>{try{let u;if(e.startsWith("Md"))u="md";else if(e.startsWith("Fa"))u="fa6";else if(e.startsWith("Io5"))u="io5";else if(e.startsWith("Io"))u="io";else if(e.startsWith("Ti"))u="ti";else if(e.startsWith("Go"))u="go";else if(e.startsWith("Fi"))u="fi";else if(e.startsWith("Di"))u="di";else if(e.startsWith("Ai"))u="ai";else if(e.startsWith("Bs"))u="bs";else if(e.startsWith("Ri"))u="ri";else if(e.startsWith("Fc"))u="fc";else if(e.startsWith("Gi"))u="gi";else if(e.startsWith("Hi2"))u="hi2";else if(e.startsWith("Hi"))u="hi";else if(e.startsWith("Si"))u="si";else if(e.startsWith("Sl"))u="sl";else if(e.startsWith("Im"))u="im";else if(e.startsWith("Bi"))u="bi";else if(e.startsWith("Pi"))u="pi";else if(e.startsWith("Vsc"))u="vsc";else if(e.startsWith("Tb"))u="tb";else if(e.startsWith("Tfi"))u="tfi";else if(e.startsWith("Cg"))u="cg";else if(e.startsWith("Lia"))u="lia";else if(e.startsWith("Lu"))u="lu";else throw new Error(`Unknown library prefix for icon: ${e}`);let h;switch(u){case"md":h=await import("react-icons/md");break;case"fa6":h=await import("react-icons/fa6");break;case"io5":h=await import("react-icons/io5");break;case"io":h=await import("react-icons/io");break;case"ti":h=await import("react-icons/ti");break;case"go":h=await import("react-icons/go");break;case"fi":h=await import("react-icons/fi");break;case"di":h=await import("react-icons/di");break;case"ai":h=await import("react-icons/ai");break;case"bs":h=await import("react-icons/bs");break;case"ri":h=await import("react-icons/ri");break;case"fc":h=await import("react-icons/fc");break;case"gi":h=await import("react-icons/gi");break;case"hi2":h=await import("react-icons/hi2");break;case"hi":h=await import("react-icons/hi");break;case"si":h=await import("react-icons/si");break;case"sl":h=await import("react-icons/sl");break;case"im":h=await import("react-icons/im");break;case"bi":h=await import("react-icons/bi");break;case"pi":h=await import("react-icons/pi");break;case"vsc":h=await import("react-icons/vsc");break;case"tb":h=await import("react-icons/tb");break;case"tfi":h=await import("react-icons/tfi");break;case"cg":h=await import("react-icons/cg");break;case"lia":h=await import("react-icons/lia");break;case"lu":h=await import("react-icons/lu");break;default:throw new Error(`Unsupported library: ${u}`)}const p=h[e];if(!p)throw new Error(`Icon ${e} not found in library ${u}`);o(()=>p)}catch(u){console.warn(`Failed to load icon ${e}:`,u.message),c(!0),o(null)}finally{s(!1)}})()},[e,l]),l){const{size:d=80,style:u,...h}=t;return r?f.jsx("image",{...h,href:e,width:d,height:d,preserveAspectRatio:"xMidYMid meet",style:u}):f.jsx("img",{...h,src:e,alt:"",width:d,height:d,referrerPolicy:"no-referrer",style:{objectFit:"contain",...u}})}return i||!n?null:f.jsx(n,{...t})};function _w(e,r){let t=e;for(const n of r){if(n.op!=="set"&&n.op!=="remove")throw new Error("Unsupported state edit.");const o=n.address.split(".");if(o.some(s=>s.startsWith("$")||["__proto__","prototype","constructor"].includes(s)))throw new Error("State edits cannot target view metadata or unsafe keys.");const i=n.op==="remove"?void 0:n.value;Tn(i),t=xo(t,{address:n.address,nodeAddress:o.slice(0,-1).join("."),value:i})}return Tn(t),t}function Fn(e,r,t){const n=Object.prototype.hasOwnProperty.call(e,r)?e[r]:void 0;if(!(!n||!t||!Object.prototype.hasOwnProperty.call(t,n.type)))return{address:n.address,type:t[n.type],fields:n.fields??{}}}function Tn(e){if(!(!e||typeof e!="object"))for(const[r,t]of Object.entries(e)){if(r.startsWith("$")||["__proto__","prototype","constructor"].includes(r))throw new Error(`Form state cannot contain view metadata or unsafe keys: ${r}`);Tn(t)}}function Rw(e,r,t){Tn(r.value);const n=xo(e,r,t);return Tn(n),n}function bb(e,r){const t=(n,o="")=>{if(!n||typeof n!="object")return n;if(["$label","$subtitle","$content","$icon","$bgColor","$textColor","$borderColor"].includes(o)&&typeof n.$state=="string"){const s=Le(r,n.$state);return s==null?"":typeof s=="object"?JSON.stringify(s,null,2):String(s)}let i=n;for(const[s,a]of Object.entries(n)){const c=t(a,s);c!==a&&(i===n&&(i=Array.isArray(n)?[...n]:{...n}),Object.defineProperty(i,s,{value:c,enumerable:!0,writable:!0,configurable:!0}))}return i};return t(e)}const kw=e=>!!e&&!e.includes(".")&&!e.startsWith("$")&&!["__proto__","constructor","prototype"].includes(e),Aw=e=>`root.__form_${encodeURIComponent(e).replace(/\./g,"%2E")}`,bn=(e,r)=>JSON.stringify([e,r]);function Nn(e,r){if(e.kind==="union"){const t=e.types.find(n=>n.kind===(Array.isArray(r)?"array":r===null?"null":typeof r)||n.kind==="literal"&&Object.is(n.value,r));return Nn(t??e.types.find(n=>n.kind!=="null")??e.types[0]??{kind:"json"},r)}return e.kind!=="json"?e:Array.isArray(r)?{kind:"array",items:{kind:"json"}}:r!==null&&typeof r=="object"||r===void 0?{kind:"object",properties:{},additionalProperties:{kind:"json"}}:{kind:r===null?"null":typeof r}}function xn(e){const r=Nn(e,void 0);return r.kind==="object"?{}:r.kind==="array"?[]:r.kind==="literal"?r.value:r.kind==="number"||r.kind==="integer"?0:r.kind==="boolean"?!1:r.kind==="null"?null:""}function Bu(e){return e.kind==="json"?[{kind:"string"},{kind:"number"},{kind:"boolean"},{kind:"null"},{kind:"object",properties:{},additionalProperties:{kind:"json"}},{kind:"array",items:{kind:"json"}}]:e.kind==="union"&&!kn(e)?e.types:[e]}function Pw(e,r,t){if(r.address===t.address)return;const n=Le(e,r.address),o=(i,s)=>s===void 0?!1:i.kind==="union"?i.types.some(a=>o(a,s)):i.kind==="array"?Array.isArray(s)&&s.every(a=>o(i.items,a)):i.kind==="object"?!!s&&typeof s=="object"&&!Array.isArray(s)&&Object.entries(i.properties).every(([a,c])=>c.optional&&s[a]===void 0||o(c.type,s[a]))&&Object.entries(s).every(([a,c])=>Object.prototype.hasOwnProperty.call(i.properties,a)||!i.additionalProperties||o(i.additionalProperties,c)):s===""?i.kind==="string"||i.kind==="json"||i.kind==="literal"&&i.value==="":!Ut(i,s,!0);if(o(t.type,n))return structuredClone(n)}function xb(e,r,t,n){var c,l;const o={sourceSchema:t,sourceBindings:r,nodes:[],edges:[],schema:{...t},bindings:{...r},slots:new Map,containers:new Map},i=new Set(n.map(d=>d.data.id)),s=new Map(n.flatMap(d=>{const u=r[d.data.id];return u&&t[u.type]?[[u.address,d.data.id]]:[]})),a=(d,u,h,p,m,g=!1)=>{var R,P,k,T,E;if(m>24||o.containers.size>512)throw new Error("Structured form exceeds the flow node limit.");const y=Le(e,u),b=Nn(h,y),x=b.kind!=="object"&&b.kind!=="array";o.containers.set(d,{address:u,type:b,declared:h,scalar:x});const v=`__form:${d}`,w={...(R=o.bindings[d])==null?void 0:R.fields},C={kind:"object",properties:{},ports:{...b.kind==="object"?b.ports:{},...g?{resource:{label:"output",...b.kind==="object"?(P=b.ports)==null?void 0:P.resource:{},kind:"output"}}:{}}},S=b.kind==="object"?{...b.properties,...Object.fromEntries(Object.keys(y??{}).filter(M=>!Object.prototype.hasOwnProperty.call(b.properties,M)&&b.additionalProperties).map(M=>[M,{type:b.additionalProperties,optional:!0}]))}:b.kind==="array"?Object.fromEntries((Array.isArray(y)?y:[]).map((M,_)=>[String(_),{type:b.items,optional:!0}])):{value:{type:kn(h)?h:b,optional:!1}};for(const[M,_]of Object.entries(S)){if(!kw(M))throw new Error(`Unsupported structured property key: ${M}`);const O=x?u:`${u}.${M}`,$=Le(e,O),B=Nn(_.type,$),N=B.kind==="object"||B.kind==="array",I=(k=C.ports)==null?void 0:k[M],ee=(I==null?void 0:I.kind)==="config"&&(((T=w[M])==null?void 0:T.$options)||kn(_.type)),ae=_.type.kind==="json"||_.type.kind==="union"&&!kn(_.type);if(((E=w[M])==null?void 0:E.$control)==="upload"||!N&&b.kind!=="array"&&(!ae||x)||ee){C.properties[M]={..._,type:_.type.kind==="json"?B:_.type};continue}const ne=s.get(O)??Aw(O),oe=b.kind==="array"?`Item ${Number(M)+1}`:M,pe={address:O,owner:d,field:M,type:_.type,label:oe,nodeId:ne,present:$!==void 0};if(o.slots.set(bn(d,M),pe),C.ports[M]={kind:"config",resourceType:`__form:${ne}`},$===void 0||(o.edges.push({data:{id:`__form-edge:${d}:${M}`,source:ne,target:d,sourceProperty:"output:resource",targetProperty:`config:${M}`,isEdgeDashed:!0}}),o.containers.has(ne)||s.has(O)))continue;if(i.has(ne))throw new Error(`Structured node identity conflict: ${ne}`);i.add(ne);const q={data:{id:ne,type:"objectView",label:oe,headerTitle:oe,description:{},config:{form:!0,icon:B.kind==="array"?"PiListNumbers":N?"PiBracketsCurly":"PiTextT"},viewProps:{bgColor:p}}};o.nodes.push(q),a(ne,O,_.type,p,m+1,!0);const F=o.schema[`__form:${ne}`];q.data.description=Object.fromEntries(Object.keys(F.properties).map(G=>[G,Le(e,B.kind==="array"||B.kind==="object"?`${O}.${G}`:O)]).filter(([,G])=>G!==void 0))}o.schema[v]=C,o.bindings[d]={...o.bindings[d],address:u,type:v,fields:w}};for(const d of n){const u=r[d.data.id];if(u!=null&&u.portResources)continue;const h=u&&t[u.type];!u||!h||Le(e,u.address)===void 0||a(d.data.id,u.address,h,(c=d.data.viewProps)==null?void 0:c.bgColor,0,o.edges.some(p=>p.data.source===d.data.id))}for(const d of o.edges){const u=o.bindings[d.data.source],h=o.schema[u.type].ports;h.resource={...h.resource,kind:"output",label:((l=h.resource)==null?void 0:l.label)??"output"}}return o}const Or=(e="reference")=>({kind:e,text:"",paths:[""]}),vb=e=>/^[A-Za-z_][\w]*(?:\.[A-Za-z_][\w]*|\.\d+)+$/.test(e)&&!e.split(".").some(r=>["__proto__","constructor","prototype"].includes(r));function Mw(e,r){const t=new Set(r.map(s=>s.path)),n=s=>{if(!s.paths.length||s.paths.some(a=>!vb(a)||!t.has(a)))throw new Error("Choose an available reference.");return[...s.paths,...s.fallback===void 0?[]:[JSON.stringify(s.fallback)]].join(" || ")},o=s=>{if(s.includes("{{")||s.includes("}}"))throw new Error("Use a reference part for dynamic values.");return s},i=s=>s.map(a=>{if(a.kind==="text")return o(a.text);if(a.kind==="conditional"){if(a.paths.length!==1||a.fallback!==void 0)throw new Error("Choose one condition reference.");return`{{#if ${n(a)}}}${o(a.text)}{{/if}}`}return`{{${n(a)}}}`}).join("");if(e.mode==="reference"||e.mode==="condition"){if(e.parts.length!==1||e.parts[0].kind!=="reference")throw new Error("Choose one reference binding.");const s=i(e.parts);return e.mode==="condition"?`${s} == ${JSON.stringify(e.comparison)}`:s}if(e.mode==="json"){const s=e.fields.map(a=>a.key);if(!s.length||new Set(s).size!==s.length||s.some(a=>!a||["__proto__","constructor","prototype"].includes(a)))throw new Error("Output field names must be unique and nonempty.");return JSON.stringify(Object.fromEntries(e.fields.map(a=>[a.key,i(a.parts)])))}return i(e.parts)}async function Iw(e){const r=await import("typescript"),t=s=>{const a=r.createSourceFile("binding.ts",`(${s})`,r.ScriptTarget.Latest,!0,r.ScriptKind.TS);if(a.parseDiagnostics.length)throw new Error("Unsupported reference expression.");const c=a.statements[0];if(!c||!r.isExpressionStatement(c))throw new Error("Unsupported reference expression.");const l=Or();l.paths=[];const d=u=>{if(r.isParenthesizedExpression(u))return d(u.expression);if(r.isBinaryExpression(u)&&u.operatorToken.kind===r.SyntaxKind.BarBarToken){d(u.left),d(u.right);return}if(r.isStringLiteral(u)){if(l.fallback!==void 0)throw new Error("Multiple fallback values.");l.fallback=u.text;return}const h=u.getText(a);if(!vb(h)||l.fallback!==void 0)throw new Error("Unsupported reference expression.");l.paths.push(h)};if(d(c.expression),!l.paths.length)throw new Error("A binding needs a reference.");return l},n=s=>{const a=[];let c=0;const l=/\{\{([\s\S]*?)\}\}/g;for(const d of s.matchAll(l)){const u=d.index;if(u<c)continue;u>c&&a.push({...Or("text"),text:s.slice(c,u)});const h=d[1].trim();if(h.startsWith("#if ")){const p=s.indexOf("{{/if}}",u+d[0].length);if(p<0)throw new Error("Unclosed condition.");a.push({...t(h.slice(4)),kind:"conditional",text:s.slice(u+d[0].length,p)}),c=p+7}else a.push(t(h)),c=u+d[0].length}return c<s.length&&a.push({...Or("text"),text:s.slice(c)}),a},o={mode:"reference",parts:[Or()],comparison:"",fields:[]};if(!e)return o;if(e.trim().startsWith("{"))try{const s=JSON.parse(e);if(s&&typeof s=="object"&&!Array.isArray(s)&&Object.values(s).every(a=>typeof a=="string"))return{...o,mode:"json",fields:Object.entries(s).map(([a,c])=>({key:a,parts:n(c)}))}}catch{}const i=n(e);if(i.length===2&&i[0].kind==="reference"&&i[1].kind==="text"){const s=r.createSourceFile("condition.ts",`value ${i[1].text}`,r.ScriptTarget.Latest,!0,r.ScriptKind.TS),a=s.statements[0];if(s.statements.length===1&&r.isExpressionStatement(a)&&r.isBinaryExpression(a.expression)&&a.expression.operatorToken.kind===r.SyntaxKind.EqualsEqualsToken&&r.isStringLiteral(a.expression.right))return{...o,mode:"condition",parts:[i[0]],comparison:a.expression.right.text}}return{...o,mode:i.length===1&&i[0].kind==="reference"?"reference":"template",parts:i}}function Du({parts:e,references:r,onChange:t,disabled:n}){const o=(i,s)=>t(e.map((a,c)=>c===i?{...a,...s}:a));return f.jsxs("div",{style:{display:"grid",gap:12},children:[e.map((i,s)=>f.jsxs("fieldset",{"data-binding-part":s,style:{border:0,padding:0,margin:0,minWidth:0},children:[f.jsxs("legend",{children:["Part ",s+1]}),f.jsxs("div",{style:{display:"flex",gap:8},children:[f.jsxs("span",{"data-form-select":"",style:{flex:1},children:[f.jsxs("select",{"aria-label":"Part type",disabled:n,value:i.kind,onChange:a=>o(s,{kind:a.target.value}),children:[f.jsx("option",{value:"reference",children:"Reference"}),f.jsx("option",{value:"text",children:"Text"}),f.jsx("option",{value:"conditional",children:"Conditional text"})]}),f.jsx(Y.PiCaretDown,{size:16,"aria-hidden":"true"})]}),f.jsx(Ne,{"aria-label":`Remove part ${s+1}`,title:"Remove part",icon:f.jsx(Y.PiTrash,{size:18}),size:"sm",variant:"ghost",disabled:n,onClick:()=>t(e.filter((a,c)=>c!==s))})]}),i.kind!=="text"&&f.jsxs(f.Fragment,{children:[i.paths.map((a,c)=>f.jsxs("label",{children:["Reference ",c+1,f.jsxs("span",{"data-form-select":"",style:{display:"block"},children:[f.jsxs("select",{"aria-label":`Reference ${c+1}`,disabled:n,value:a,onChange:l=>o(s,{paths:i.paths.map((d,u)=>u===c?l.target.value:d)}),children:[f.jsx("option",{value:"",children:"Select reference"}),r.map(l=>f.jsx("option",{value:l.path,children:l.label},l.path))]}),f.jsx(Y.PiCaretDown,{size:16,"aria-hidden":"true"})]})]},c)),i.kind==="reference"&&f.jsxs(f.Fragment,{children:[f.jsx(Ne,{"aria-label":"Add fallback reference",title:"Add fallback reference",icon:f.jsx(Y.PiPlus,{size:18}),size:"sm",variant:"ghost",disabled:n,onClick:()=>o(s,{paths:[...i.paths,""]})}),f.jsxs("label",{style:{display:"flex",gap:8,alignItems:"center"},children:[f.jsx("input",{type:"checkbox","aria-label":"Default value enabled",disabled:n,checked:i.fallback!==void 0,onChange:a=>o(s,{fallback:a.target.checked?"":void 0})}),"Default value"]}),i.fallback!==void 0&&f.jsx("input",{"aria-label":"Default value",disabled:n,value:i.fallback,onChange:a=>o(s,{fallback:a.target.value})})]})]}),i.kind!=="reference"&&f.jsxs("label",{children:["Text",f.jsx("textarea",{"aria-label":"Part text",disabled:n,value:i.text,onChange:a=>o(s,{text:a.target.value})})]})]},s)),f.jsx(Ne,{"aria-label":"Add part",title:"Add part",icon:f.jsx(Y.PiPlus,{size:18}),size:"sm",variant:"ghost",disabled:n,onClick:()=>t([...e,Or()])})]})}function Tw({label:e,value:r,references:t,disabled:n,onChange:o}){const[i,s]=j.useState(),[a,c]=j.useState(""),[l,d]=j.useState(!1),u=async()=>{d(!0),c("");try{s(await Iw(typeof r=="string"?r:""))}catch(h){c(h instanceof Error?h.message:"Unable to read binding.")}finally{d(!1)}};return f.jsxs("div",{"data-runtime-binding":e,style:{marginBottom:8},children:[f.jsx(Ne,{"aria-label":`Bind ${e}`,title:`Bind ${e}`,icon:f.jsx(Y.PiLink,{size:18}),size:"sm",variant:"ghost",disabled:n||l,onClick:u}),typeof r=="string"&&r.includes("{{")&&f.jsx("span",{children:"Bound value"}),i&&f.jsxs("fieldset",{disabled:n,style:{border:0,margin:0,padding:"8px 0",minWidth:0},children:[f.jsxs("label",{children:["Binding mode",f.jsxs("span",{"data-form-select":"",style:{display:"block"},children:[f.jsxs("select",{"aria-label":"Binding mode",value:i.mode,onChange:h=>s({...i,mode:h.target.value,parts:[Or()]}),children:[f.jsx("option",{value:"reference",children:"Reference"}),f.jsx("option",{value:"condition",children:"Equals"}),f.jsx("option",{value:"template",children:"Text template"}),f.jsx("option",{value:"json",children:"JSON output"})]}),f.jsx(Y.PiCaretDown,{size:16,"aria-hidden":"true"})]})]}),i.mode==="json"?f.jsxs(f.Fragment,{children:[i.fields.map((h,p)=>f.jsxs("fieldset",{"data-output-field":p,style:{border:0,margin:0,padding:"8px 0",minWidth:0},children:[f.jsxs("label",{children:["Output field name",f.jsx("input",{"aria-label":"Output field name",value:h.key,onChange:m=>s({...i,fields:i.fields.map((g,y)=>y===p?{...g,key:m.target.value}:g)})})]}),f.jsx(Du,{parts:h.parts,references:t,disabled:n,onChange:m=>s({...i,fields:i.fields.map((g,y)=>y===p?{...g,parts:m}:g)})}),f.jsx(Ne,{"aria-label":"Remove output field",title:"Remove output field",icon:f.jsx(Y.PiTrash,{size:18}),size:"sm",variant:"ghost",onClick:()=>s({...i,fields:i.fields.filter((m,g)=>g!==p)})})]},p)),f.jsx(Ne,{"aria-label":"Add output field",title:"Add output field",icon:f.jsx(Y.PiPlus,{size:18}),size:"sm",variant:"ghost",onClick:()=>s({...i,fields:[...i.fields,{key:"",parts:[Or()]}]})})]}):f.jsx(Du,{parts:i.parts,references:t,disabled:n,onChange:h=>s({...i,parts:h})}),i.mode==="condition"&&f.jsxs("label",{children:["Equals",f.jsx("input",{"aria-label":"Comparison value",value:i.comparison,onChange:h=>s({...i,comparison:h.target.value})})]}),f.jsxs("div",{style:{display:"flex",gap:8,marginTop:12},children:[f.jsx(Ne,{"aria-label":"Apply binding",title:"Apply binding",icon:f.jsx(Y.PiCheck,{size:20}),size:"sm",variant:"ghost",onClick:()=>{try{o(Mw(i,t)),s(void 0),c("")}catch(h){c(h instanceof Error?h.message:"Unable to apply binding.")}}}),f.jsx(Ne,{"aria-label":"Cancel binding",title:"Cancel binding",icon:f.jsx(Y.PiX,{size:20}),size:"sm",variant:"ghost",onClick:()=>{s(void 0),c("")}})]})]}),a&&f.jsx("p",{role:"alert",children:a})]})}function Nw({nodeAddress:e,onOpen:r}){const{structured:t,data:n,callbacks:o,editable:i,onFieldCreate:s}=j.useContext(Tt),a=Ze(),[c,l]=j.useState(""),[d,u]=j.useState("0"),[h,p]=j.useState(""),m=t==null?void 0:t.containers.get(e);if(!m||!n||!t)return null;const g=a.readOnly||a.config.editable===!1||!i,y=Le(n,m.address),b=Bu(m.declared),x=m.type.kind==="array"?m.type.items:m.type.kind==="object"?m.type.additionalProperties:void 0,v=x?Bu(x):[],w=!!s&&m.type.kind==="object"&&(x==null?void 0:x.kind)==="json",C=_=>_.kind==="literal"?String(_.value):_.kind==="string"?"Text":Ft(_.kind),S=[...t.slots.values()].filter(_=>_.owner===e),R=(_,O)=>{var $;return($=o.onFormChange)==null?void 0:$.call(o,{data:n,nodeAddress:m.address,address:_,previousValue:Le(n,_),value:O})},P=_=>{var O;a.setSelectedNodeIds([_]),(O=a.engineRef.current)==null||O.focusNode(_,90,!1)},k=(_,O)=>{if(!Array.isArray(y))return;const $=[...y];[$[_],$[_+O]]=[$[_+O],$[_]],R(m.address,$)},T=()=>{const _=v[Number(d)]??v[0];if(_)if(m.type.kind==="array")R(m.address,[...Array.isArray(y)?y:[],xn(_)]);else{if(!c||c.includes(".")||c.startsWith("$")||["__proto__","constructor","prototype"].includes(c)){p("Choose a property name without dots or reserved prefixes.");return}if(Object.prototype.hasOwnProperty.call(y,c)){p("Property already exists.");return}w&&(d==="file"||d==="files")?s==null||s({data:n,nodeAddress:m.address,address:`${m.address}.${c}`,previousValue:void 0,value:d==="files"?[]:""},{$control:"upload"}):R(`${m.address}.${c}`,xn(_)),l(""),p("")}},E=m.type.kind==="object"&&!!m.type.additionalProperties,M=m.type.kind==="array";return f.jsxs("div",{"data-structured-controls":"",style:{display:"grid",gap:8,minWidth:0},children:[b.length>1&&f.jsxs("label",{children:["Value type",f.jsx("span",{"data-form-select":"",style:{display:"block"},children:f.jsx(Mt,{"aria-label":"Value type",disabled:g,value:String(b.findIndex(_=>Nn(_,y).kind===m.type.kind)),onValueChange:_=>R(m.address,xn(b[Number(_)])),children:b.map((_,O)=>f.jsx("option",{value:O,children:C(_)},O))})})]}),S.map((_,O)=>f.jsxs("div",{"data-structured-slot":_.address,style:{display:"flex",gap:6,alignItems:"center",minWidth:0},children:[_.type.kind==="array"?f.jsx(Y.PiListNumbers,{size:20}):f.jsx(Y.PiBracketsCurly,{size:20}),f.jsx("span",{style:{flex:1,overflowWrap:"anywhere"},children:Ft(_.label)}),f.jsx(Ne,{"aria-label":`${_.present?r?"Edit":"Focus":"Create"} ${Ft(_.label)}`,title:`${_.present?r?"Edit":"Focus":"Create"} ${Ft(_.label)}`,icon:_.present?f.jsx(Y.PiMagnifyingGlass,{size:18}):f.jsx(Y.PiPlus,{size:18}),size:"sm",variant:"ghost",disabled:g&&!_.present,onClick:$=>{var B;_.present?r?r(_.nodeId):((B=$.currentTarget.closest("dialog"))==null||B.close(),P(_.nodeId)):R(_.address,xn(_.type))}}),M&&f.jsxs(f.Fragment,{children:[f.jsx(Ne,{"aria-label":`Move item ${O+1} up`,icon:f.jsx(Y.PiArrowUp,{size:18}),size:"sm",variant:"ghost",disabled:g||O===0,onClick:()=>k(O,-1)}),f.jsx(Ne,{"aria-label":`Move item ${O+1} down`,icon:f.jsx(Y.PiArrowDown,{size:18}),size:"sm",variant:"ghost",disabled:g||O===S.length-1,onClick:()=>k(O,1)})]}),_.present&&f.jsx(Ne,{"aria-label":`Remove ${Ft(_.label)}`,icon:f.jsx(Y.PiTrash,{size:18}),size:"sm",variant:"ghost",disabled:g,onClick:()=>M?R(m.address,y.filter(($,B)=>B!==O)):R(_.address,void 0)})]},_.address)),(M||E)&&f.jsxs("div",{style:{display:"flex",gap:8,flexWrap:"wrap",alignItems:"end"},children:[E&&f.jsxs("label",{style:{flex:"1 1 120px",minWidth:0,display:"grid",gap:8},children:["Property name",f.jsx("input",{"aria-label":"Property name",placeholder:"Required",value:c,disabled:g,onChange:_=>l(_.target.value)})]}),v.length>1&&f.jsxs("label",{style:{flex:"1 1 100px",minWidth:0,display:"grid",gap:8},children:["New value type",f.jsx("span",{"data-form-select":"",style:{display:"block"},children:f.jsxs(Mt,{"aria-label":"New value type",value:d,disabled:g,onValueChange:u,children:[v.map((_,O)=>f.jsx("option",{value:O,children:C(_)},O)),w&&f.jsx("option",{value:"file",children:"File"}),w&&f.jsx("option",{value:"files",children:"Files"})]})})]}),f.jsx("span",{style:{display:"flex",alignItems:"center",flexShrink:0,...E||v.length>1?{height:"calc(1.4em + 20px)",fontSize:15,marginBottom:6}:{}},children:f.jsx(Ne,{"aria-label":M?"Add item":"Add property",icon:f.jsx(Y.PiPlus,{size:20}),size:"sm",variant:"ghost",disabled:g,onClick:T})})]}),h&&f.jsx("p",{role:"alert",children:h})]})}const Tt=j.createContext({callbacks:{}}),Xn=fo.default.div`
|
|
59
59
|
--flow-form-input-radius: 16px;
|
|
60
60
|
--flow-form-input-background: color-mix(
|
|
61
61
|
in srgb,
|
|
@@ -206,8 +206,8 @@
|
|
|
206
206
|
font-size: 14px;
|
|
207
207
|
margin-top: 8px;
|
|
208
208
|
}
|
|
209
|
-
`;function Vu({request:e,property:r,config:t,value:n,disabled:o}){var fe,ge,X,H,be;const{callbacks:i,structured:s,references:a}=j.useContext(Tt),{themeColor:c}=Je(),{background:l}=lt(),d=j.useId(),u=r.type.kind==="object"||r.type.kind==="array"||r.type.kind==="json",h=n===void 0?"":u?JSON.stringify(n,null,2):String(n),[p,m]=j.useState(h),[g,y]=j.useState(""),[b,x]=j.useState(0),v=j.useRef(null),w=j.useRef(),[C,S]=j.useState(!1),[R,P]=j.useState(!1),[k,T]=j.useState(),E=((fe=t.$options)==null?void 0:fe.$source)==="callback",M=i.resolveFormOptions,{data:_,address:N,nodeAddress:$,nodeId:B}=e;j.useEffect(()=>(S(!1),P(!1),()=>{var J;(J=w.current)==null||J.abort(),w.current=void 0}),[N,$,B,o,h,t.$control,(ge=t.$upload)==null?void 0:ge.accept,(X=t.$upload)==null?void 0:X.maxSizeBytes]);const O=j.useRef(_);O.current=_;const I=JSON.stringify([N,B,(H=t.$options)!=null&&H.$dependsOn?t.$options.$dependsOn.map(J=>Le(_,J)):Le(_,$)]);j.useEffect(()=>{m(h),y("")},[h,N,B]),j.useEffect(()=>{if(!E)return;const J=new AbortController;return Promise.resolve().then(()=>{if(!M)throw new Error("No options resolver configured");return M({address:N,nodeAddress:$,nodeId:B,data:Qr(O.current),signal:J.signal})}).then(xe=>{if(!Array.isArray(xe)||xe.some(Se=>!Se||typeof Se.label!="string"||!["string","number","boolean"].includes(typeof Se.value)&&Se.value!==null))throw new Error("Invalid options response");J.signal.aborted||T({key:I,options:xe})}).catch(xe=>{J.signal.aborted||T({key:I,options:[],error:xe instanceof Error?xe.message:"Options unavailable"})}),()=>J.abort()},[E,M,I,N,$,B,b]);const ee=E&&(k==null?void 0:k.key)!==I,ae=E?(k==null?void 0:k.key)===I?k.options:[]:r.type.kind==="null"?[{label:"Null",value:null}]:r.type.kind==="boolean"?[{label:"Yes",value:!0},{label:"No",value:!1}]:kn(r.type),ne=r.type.kind==="array",oe=(t.$control==="upload"?"upload":s&&u||t.$control==="checkbox"?"pills":t.$control)??(ae?ne||r.type.kind==="boolean"?"pills":"select":r.type.kind==="boolean"?"checkbox":u?"textarea":"input"),pe=!r.optional||!!t.$requiredWhen&&bo(t.$requiredWhen,_),q=pe?"Required":"Optional",F=oe!=="upload"&&!!(a!=null&&a.length)&&typeof n=="string"&&n.includes("{{"),G=g||E&&(k==null?void 0:k.key)===I&&k.error||!F&&Ut(r.type,n,pe),D=Ft(t.$label??N.split(".").pop()),ce=J=>{var xe;if(!(o||Object.is(J,n)))try{(xe=i.onFormChange)==null||xe.call(i,{...e,previousValue:n,value:J}),y("")}catch(Se){y(Se instanceof Error?Se.message:"Unable to update field")}},Q=j.useRef(ce);j.useLayoutEffect(()=>{Q.current=ce});const K=()=>{if(u){try{const Fe=p===""&&r.optional?void 0:JSON.parse(p),De=Ut(r.type,Fe,pe);if(De){y(De);return}ce(Fe)}catch{y("Enter valid JSON")}return}const J=r.type.kind==="number"||r.type.kind==="integer",xe=p===""&&r.optional?void 0:J&&p!==""?Number(p):p,Se=Ut(r.type,xe,pe);if(J&&Se&&p!==""){y(Se);return}ce(xe)},ie=async J=>{var Se,Fe,De;if(o||w.current||!J.length)return;const xe=new AbortController;w.current=xe,y(""),S(!0);try{if(r.type.kind!=="string"&&!(r.type.kind==="array"&&r.type.items.kind==="string"))throw new Error("Uploads require a string or string-array field.");if(!ne&&J.length!==1)throw new Error("Choose one file for this field.");if(!i.uploadFormFile)throw new Error("No file upload handler configured.");const he=(Fe=(Se=t.$upload)==null?void 0:Se.accept)==null?void 0:Fe.split(",").map(qe=>qe.trim().toLowerCase()).filter(Boolean);for(const qe of J){if(((De=t.$upload)==null?void 0:De.maxSizeBytes)!==void 0&&qe.size>t.$upload.maxSizeBytes)throw new Error(`${qe.name} exceeds the file size limit.`);if(he!=null&&he.length&&!he.some(Qe=>Qe.startsWith(".")?qe.name.toLowerCase().endsWith(Qe):Qe.endsWith("/*")?qe.type.toLowerCase().startsWith(Qe.slice(0,-1)):qe.type.toLowerCase()===Qe))throw new Error(`${qe.name} is not an accepted file type.`)}const Re=await Promise.all(J.map(async qe=>{const Qe=await i.uploadFormFile({...e,data:Qr(_),file:qe,signal:xe.signal});if(typeof Qe!="string")throw new Error("Upload handler must return an HTTP or HTTPS URL.");let ct;try{ct=new URL(Qe)}catch{throw new Error("Upload handler must return an HTTP or HTTPS URL.")}if(!["http:","https:"].includes(ct.protocol)||ct.username||ct.password)throw new Error("Upload handler must return an HTTP or HTTPS URL.");return Qe}));if(xe.signal.aborted||w.current!==xe)return;const ze=ne?[...Array.isArray(n)?n:[],...Re]:Re[0],Te=Ut(r.type,ze,pe);if(Te)throw new Error(Te);Q.current(ze)}catch(he){xe.signal.aborted||y(he instanceof Error?he.message:"Unable to upload file."),xe.abort()}finally{w.current===xe&&(w.current=void 0,S(!1))}},ye={id:d,disabled:o,"aria-label":D,"aria-required":pe,"aria-invalid":!!G,"aria-describedby":G?`${d}-error`:void 0},we=Me(c);return f.jsxs("div",{"data-form-field":N,"data-flow-property":N.slice($.length+1),children:[f.jsxs("div",{style:{display:"flex",justifyContent:"space-between",alignItems:"center"},children:[f.jsxs("label",{htmlFor:d,children:[D,pe?" *":""]}),r.optional&&n!==void 0&&f.jsx("button",{type:"button","aria-label":`Reset ${D}`,title:`Reset ${D}`,disabled:o||C,style:{width:24,height:24,padding:0,display:"inline-flex",alignItems:"center",justifyContent:"center",flexShrink:0,border:0,background:"transparent",color:"inherit"},onClick:()=>ce(void 0),children:f.jsx(Y.PiArrowCounterClockwise,{size:14})})]}),!!(a!=null&&a.length)&&!u&&oe!=="upload"&&f.jsx(Tw,{label:D,value:n,references:a,disabled:o,onChange:ce}),oe==="upload"?f.jsxs("div",{"data-form-upload":ne?"multiple":"single","aria-busy":C,style:{"--flow-upload-surface":Me(l),outline:R?"2px dashed var(--flow-form-input-background)":void 0,borderRadius:"var(--flow-form-input-radius)"},onDragOver:J=>{J.preventDefault(),J.stopPropagation(),!o&&!C&&(J.dataTransfer.dropEffect="copy",P(!0))},onDragLeave:J=>{J.currentTarget.contains(J.relatedTarget)||P(!1)},onDrop:J=>{J.preventDefault(),J.stopPropagation(),P(!1),ie(Array.from(J.dataTransfer.files))},children:[f.jsx("input",{ref:v,type:"file",hidden:!0,"aria-label":`Upload ${D}`,accept:(be=t.$upload)==null?void 0:be.accept,multiple:ne,disabled:o||C,onChange:J=>{const xe=Array.from(J.target.files??[]);J.target.value="",ie(xe)}}),f.jsxs("div",{"data-upload-items":"",children:[(ne?Array.isArray(n)?n:[]:n?[n]:[]).map((J,xe)=>f.jsxs("div",{"data-upload-preview":"",children:[typeof J=="string"&&hr(J)&&f.jsxs("a",{href:J,target:"_blank",rel:"noopener noreferrer","aria-label":`${D} file ${xe+1}`,children:[f.jsx(Y.PiFile,{size:32,"aria-hidden":"true"}),f.jsx(or,{name:J,size:120,onError:Se=>{Se.currentTarget.style.visibility="hidden"}})]}),f.jsxs("div",{"data-upload-actions":"",children:[!ne&&f.jsx(Oe,{"aria-label":`Replace ${D}`,title:`Replace ${D}`,icon:f.jsx(Y.PiUploadSimple,{}),size:"xs",variant:"ghost",disabled:o||C,onClick:()=>{var Se;return(Se=v.current)==null?void 0:Se.click()}}),f.jsx(Oe,{"aria-label":`Remove ${D} file ${xe+1}`,title:"Remove file",icon:f.jsx(Y.PiTrash,{}),size:"xs",variant:"ghost",disabled:o||C,onClick:()=>ce(ne&&Array.isArray(n)?n.filter((Se,Fe)=>Fe!==xe):"")})]})]},`${xe}:${J}`)),(ne||!n)&&f.jsx("button",{...ye,type:"button","data-upload-drop":"",title:`Upload ${D}`,disabled:o||C,onClick:()=>{var J;return(J=v.current)==null?void 0:J.click()},children:f.jsx(Y.PiPlus,{size:28,"aria-hidden":"true"})})]}),C&&f.jsx("span",{role:"status",children:"Uploading..."})]}):F?null:oe==="select"?f.jsx("div",{"data-form-select":"",children:f.jsxs(Mt,{...ye,disabled:o||ee||!!(k!=null&&k.error),labelCase:"preserve",value:String((ae==null?void 0:ae.findIndex(J=>Object.is(J.value,n)))??-1),onValueChange:J=>{const xe=ae==null?void 0:ae[Number(J)];xe&&ce(xe.value)},children:[f.jsx("option",{value:-1,disabled:!0,children:n!==void 0&&n!==""?String(n):q}),ae==null?void 0:ae.map((J,xe)=>f.jsx("option",{value:xe,children:Ft(J.label)||J.label},xe))]})}):oe==="pills"?f.jsxs("div",{id:d,role:"group","aria-label":D,"aria-describedby":ye["aria-describedby"],style:{display:"flex",flexWrap:"wrap",gap:8},children:[ae==null?void 0:ae.map((J,xe)=>{const Se=ne?Array.isArray(n)&&n.includes(J.value):Object.is(n,J.value);return f.jsx("button",{type:"button",disabled:o||ee,"aria-pressed":Se,style:{padding:"8px 16px",borderRadius:24,border:0,color:Se?we:"inherit",background:Se?"color-mix(in srgb, currentColor 12%, transparent)":"color-mix(in srgb, currentColor 7%, transparent)"},onClick:()=>ce(ne?Se?n.filter(Fe=>Fe!==J.value):[...Array.isArray(n)?n:[],J.value]:J.value),children:Ft(J.label)||J.label},xe)}),ee&&f.jsx("span",{role:"status",children:"Loading..."})]}):oe==="textarea"?f.jsx("textarea",{...ye,placeholder:q,value:p,onChange:J=>m(J.target.value),onBlur:K}):f.jsx("input",{...ye,placeholder:q,type:r.type.kind==="number"||r.type.kind==="integer"?"number":"text",step:r.type.kind==="integer"?1:"any",value:p,onChange:J=>m(J.target.value),onBlur:K,onKeyDown:J=>{J.key==="Enter"&&K(),J.key==="Escape"&&m(n===void 0?"":String(n))}}),G&&f.jsx("div",{role:"alert",id:`${d}-error`,children:G}),E&&(k==null?void 0:k.error)&&f.jsx("button",{type:"button",disabled:o,onClick:()=>{T(void 0),x(b+1)},children:"Retry"})]})}function Ld({nodeAddress:e,structured:r=!1}){return r?f.jsx(Nw,{nodeAddress:e},e):f.jsx(bd,{nodeAddress:e})}function Nw({nodeAddress:e}){var u,h,p;const r=j.useContext(Tt),[t,n]=j.useState([]),o=((u=r.structured)==null?void 0:u.sourceSchema)??r.schema,i=((h=r.structured)==null?void 0:h.sourceBindings)??r.bindings,s=j.useMemo(()=>{if(!(!r.data||!o||!i))return xb(r.data,i,o,[{data:{id:e,type:"objectView"}}])},[r.data,i,o,e]);if(!s)return f.jsx(bd,{nodeAddress:e});const a=t.findIndex(m=>!s.containers.has(m)),c=a<0?t:t.slice(0,a),l=c.at(-1)??e,d=(p=[...s.slots.values()].find(m=>m.nodeId===l))==null?void 0:p.label;return f.jsxs(Tt.Provider,{value:{...r,structured:s,schema:s.schema,bindings:s.bindings,renderForm:void 0,onFieldCreate:l===e?r.onFieldCreate:void 0},children:[!!c.length&&f.jsxs("div",{style:{display:"flex",alignItems:"center",gap:8,marginBottom:8},children:[f.jsx(Oe,{"aria-label":"Back to parent fields",title:"Back to parent fields",icon:f.jsx(Y.PiArrowLeft,{size:18}),size:"sm",variant:"ghost",onClick:()=>n(c.slice(0,-1))}),f.jsx("strong",{style:{minWidth:0,overflowWrap:"anywhere"},children:Ft(d)})]}),f.jsx(bd,{nodeAddress:l,onOpen:m=>n([...c,m])},l)]})}function bd({nodeAddress:e,onOpen:r}){var S,R;const{data:t,schema:n,callbacks:o,bindings:i,editable:s,renderForm:a,structured:c}=j.useContext(Tt),{readOnly:l,config:d,colorMode:u}=Je(),h=a==null?void 0:a(e);if(h!==void 0)return f.jsx("fieldset",{"data-flow-form":e,disabled:l||d.editable===!1||!s,style:{border:0,margin:0,padding:0,minWidth:0},children:h});if(!t)return f.jsx(Xn,{$colorMode:u,role:"alert",children:"Forms require a JSON document."});const p=i?Fn(i,e,n):void 0,m=i?p:n&&on(t,e,n);if(!m)return f.jsx(Xn,{$colorMode:u,role:"status",children:"Form schema unavailable."});const g=(p==null?void 0:p.address)??e,y=Le(t,g),b=(S=c==null?void 0:c.containers.get(e))==null?void 0:S.scalar;if(y===void 0||typeof y!="object"&&!b)return f.jsx(Xn,{$colorMode:u,role:"alert",children:"Bound form state is unavailable."});const x=Object.entries(m.type.properties).filter(([P])=>{var k;return bo((k=m.fields[P])==null?void 0:k.$visibleWhen,t)}),v=x.length>8||x.some(([P])=>{var k;return(k=m.fields[P])==null?void 0:k.$section}),w=new Map;for(const P of x){const[k,T]=P,E=v?Ft(((R=m.fields[k])==null?void 0:R.$section)??(T.type.kind==="object"||T.type.kind==="array"?k:T.optional?"Options":"General")):"";w.has(E)||w.set(E,[]),w.get(E).push(P)}const C=([P,k])=>f.jsx(Vu,{request:{data:t,address:b?g:`${g}.${P}`,nodeAddress:g,nodeId:typeof(y==null?void 0:y.id)=="string"?y.id:void 0},property:k,config:m.fields[P]??{},value:b?y:y==null?void 0:y[P],disabled:l||d.editable===!1||!(s??!!o.onJsonChange)},`${(y==null?void 0:y.id)??e}:${P}`);return f.jsxs(Xn,{$colorMode:u,"data-flow-form":e,onClick:P=>P.stopPropagation(),onDoubleClick:P=>P.stopPropagation(),children:[c&&f.jsx(Ow,{nodeAddress:e,onOpen:r}),!c&&p&&m.type.additionalProperties&&x.length===0&&f.jsx(Vu,{request:{data:t,address:g,nodeAddress:g},property:{type:m.type,optional:!1},config:{$label:"Configuration",$control:"textarea"},value:y,disabled:l||d.editable===!1||!s}),[...w].map(([P,k])=>v&&k.length>1?f.jsxs("details",{open:!0,children:[f.jsxs("summary",{children:[f.jsx("span",{children:P}),f.jsx(Y.PiCaretDown,{size:16,"aria-hidden":"true"})]}),k.map(C)]},P):k.map(C))]})}function wb(e){const{viewData:r}=j.useContext(Tt),{nodeById:t,edgeById:n,parentIds:o}=Kt();if(r){const i=Le(r,e),s=i&&typeof i=="object"&&!Array.isArray(i)&&"$"in i?i.$:i;return Array.isArray(s)?s.length>0:!!s&&typeof s=="object"&&Object.entries(s).some(([a,c])=>!a.startsWith("$")&&c!==null&&typeof c=="object")}return o.has(e)?!0:[...n.values()].some(({data:i})=>{const s=i.isInverted?i.target:i.source,a=i.isInverted?i.source:i.target;return s===e&&a!==e&&t.has(a)})}function Nn(e,r){return typeof e=="number"&&Number.isFinite(e)&&e>=0?e:r}function $n(e,r,t,n){return{borderColor:r,borderWidth:Nn(e==null?void 0:e.borderWidth,n),borderStyle:(e==null?void 0:e.borderStyle)??"solid",...Mm(r==="transparent"?"currentColor":r,t,".flow-sdk-node:hover &",!t)}}function Cb({label:e,value:r,options:t,onChange:n,disabled:o}){var i;return f.jsxs(Mt,{"aria-label":e,title:`Animation: ${((i=t.find(s=>s.value===r))==null?void 0:i.label)??"Mixed"}`,value:r,style:{width:104},disabled:o,onValueChange:s=>{const a=t.find(c=>c.value===s);a&&n(a.value)},children:[r===""&&f.jsx("option",{value:"",disabled:!0,children:"Mixed"}),t.map(s=>f.jsx("option",{value:s.value,children:s.label},s.value))]})}function Fd({nodeId:e,edgeId:r,value:t,open:n,onOpenChange:o}){const{callbacks:i,readOnly:s,themeColor:a,colorMode:c}=Je(),{background:l,backgroundSecondary:d,border:u,colorText:h,colorInactive:p}=lt(),m=c==="dark"?rn:Me(p),g=j.useRef(null),y=j.useRef(null),b=j.useRef(0),[x,v]=j.useState(!1),[w,C]=j.useState("icons"),[S,R]=j.useState([]),[P,k]=j.useState("loading"),[T,E]=j.useState(""),[M,_]=j.useState(0),[N,$]=j.useState(""),[B,O]=j.useState(""),[I,ee]=j.useState(!1);j.useEffect(()=>()=>{b.current++},[]),j.useEffect(()=>{if(!x)return;let D=!0;return import("react-icons/pi").then(ce=>{D&&(R(Object.keys(ce).filter(Q=>Q.startsWith("Pi")).sort()),k("ready"))}).catch(()=>{D&&k("unavailable")}),()=>{D=!1}},[x]),j.useEffect(()=>{var D;s&&((D=g.current)==null||D.close())},[s]),j.useEffect(()=>{var D,ce,Q;if(n!==void 0){if(!n||s){(D=g.current)==null||D.close();return}(ce=g.current)!=null&&ce.open||(O(""),C(t==="PiFileSvg"||t&&hr(t)?"custom":"icons"),$(t&&!t.startsWith(An)&&hr(t)?t:""),v(!0),(Q=g.current)==null||Q.showModal())}},[n,s,t]);const ae=D=>{var ce,Q,K;s||(r?(ce=i.onEdgeIconChange)==null||ce.call(i,r,D):e&&((Q=i.onNodeIconChange)==null||Q.call(i,e,D)),o==null||o(!1),(K=g.current)==null||K.close())},ne=S.filter(D=>D.replace(/([a-z])([A-Z])/g,"$1 $2").toLowerCase().includes(T.trim().toLowerCase())),oe=36,pe=Math.max(1,Math.ceil(ne.length/oe)),q=Math.min(M,pe-1),F=ne.slice(q*oe,(q+1)*oe),G={width:"100%",padding:"8px 14px",background:"transparent",color:"inherit",border:`1px solid ${Me(u)}`,borderRadius:30};return f.jsxs(f.Fragment,{children:[n===void 0&&f.jsx(He,{label:r?"Choose edge icon":"Choose node icon",children:f.jsx(Oe,{"aria-label":r?"Choose edge icon":"Choose node icon",icon:f.jsx(Y.PiShapes,{size:20}),size:"sm",variant:"ghost",color:Me(a),disabled:s,onClick:()=>{var D;O(""),C(t&&hr(t)?"custom":"icons"),$(t&&!t.startsWith(An)&&hr(t)?t:""),v(!0),(D=g.current)==null||D.showModal()}})}),f.jsx(V.chakra.dialog,{ref:g,"aria-label":r?"Choose edge icon":"Choose node icon",css:xr(Me(l),Me(u)),onClose:()=>{v(!1),o==null||o(!1),b.current++,ee(!1)},onClick:D=>{D.stopPropagation(),D.target===D.currentTarget&&D.currentTarget.close()},onKeyDown:D=>D.stopPropagation(),style:{margin:"auto",padding:12,width:336,maxWidth:"calc(100vw - 32px)",maxHeight:"calc(100vh - 32px)",overflowY:"auto",borderRadius:30,background:Me(l),color:Me(h)},children:x&&f.jsxs("div",{style:{display:"grid",gap:8},children:[f.jsxs("div",{style:{display:"flex",alignItems:"center",justifyContent:"space-between",gap:8},children:[f.jsx("strong",{children:r?"Edge icon":"Node icon"}),f.jsxs("div",{style:{display:"flex",alignItems:"center",marginLeft:"auto",gap:4},children:[t&&f.jsx(He,{label:"Remove icon",children:f.jsx(Oe,{"aria-label":r?"Remove edge icon":"Remove node icon",icon:f.jsx(Y.PiTrash,{size:18}),size:"sm",variant:"ghost",disabled:s||I,onClick:()=>ae("")})}),f.jsx(nn,{"aria-label":"Close icon picker",onClick:()=>{var D;return(D=g.current)==null?void 0:D.close()}})]})]}),f.jsxs(V.Tabs.Root,{value:w,onValueChange:({value:D})=>{C(D),O("")},display:"contents",css:{"--indicator-thickness":"1px"},children:[f.jsx(V.Tabs.List,{"aria-label":"Icon source",width:"100%",borderBottomWidth:0,children:["icons","custom"].map(D=>f.jsx(V.Tabs.Trigger,{value:D,flex:1,minW:0,justifyContent:"center",px:3,py:2,fontSize:"13px",_selected:{color:a,borderColor:m,"--indicator-color":m},children:D==="icons"?"React icons":"Custom SVG"},D))}),f.jsx("input",{ref:y,type:"file",accept:".svg,image/svg+xml","aria-label":"Upload SVG icon",hidden:!0,disabled:I||s,onChange:async D=>{var K;const ce=(K=D.target.files)==null?void 0:K[0];if(D.target.value="",!ce)return;const Q=++b.current;ee(!0),O("");try{const ie=await Ew(ce);Q===b.current&&ae(ie)}catch(ie){Q===b.current&&O(ie instanceof Error?ie.message:"Unable to read SVG.")}finally{Q===b.current&&ee(!1)}}}),f.jsx(V.Tabs.Content,{value:w,p:0,style:{display:"grid",gap:8},children:w==="icons"?f.jsxs(f.Fragment,{children:[f.jsx("input",{"aria-label":"Search icons",placeholder:"Search icons...",value:T,onChange:D=>{E(D.target.value),_(0)},style:G}),f.jsxs("div",{style:{height:244,overflowY:"auto",display:"grid",gridTemplateColumns:"repeat(6, minmax(0, 1fr))",gridAutoRows:36,gap:4},children:[F.map(D=>f.jsx("button",{type:"button","aria-label":`Choose ${D}`,"aria-pressed":t===D,title:D,onClick:()=>ae(D),style:{display:"grid",placeItems:"center",borderRadius:5,border:`${t===D?2:1}px solid ${Me(t===D?a:u)}`,background:Me(t===D?l:d),color:"inherit",cursor:"pointer"},children:f.jsx(or,{name:D,size:24})},D)),F.length===0&&f.jsx("span",{role:"status",style:{gridColumn:"1 / -1"},children:P==="loading"?"Loading icons...":P==="unavailable"?"React icons unavailable":"No icons found"})]}),f.jsxs("div",{style:{display:"flex",alignItems:"center",justifyContent:"space-between",gap:8},children:[f.jsxs("span",{role:"status",style:{fontSize:12},children:[ne.length," icons · ",q+1," / ",pe]}),f.jsxs("div",{style:{display:"flex",gap:4},children:[f.jsx(He,{label:"Previous icons",children:f.jsx(Oe,{"aria-label":"Previous icons",icon:f.jsx(Y.PiCaretLeft,{size:18}),size:"sm",variant:"ghost",disabled:q===0,onClick:()=>_(q-1)})}),f.jsx(He,{label:"Next icons",children:f.jsx(Oe,{"aria-label":"Next icons",icon:f.jsx(Y.PiCaretRight,{size:18}),size:"sm",variant:"ghost",disabled:q+1>=pe,onClick:()=>_(q+1)})})]})]})]}):f.jsxs(f.Fragment,{children:[t&&hr(t)&&f.jsx(or,{name:t,size:64}),f.jsxs("button",{type:"button",disabled:I||s,onClick:()=>{var D;return(D=y.current)==null?void 0:D.click()},style:{...G,display:"flex",justifyContent:"center",gap:8,alignItems:"center",cursor:"pointer"},children:[f.jsx(Y.PiUploadSimple,{}),I?"Uploading...":"Upload SVG"]}),f.jsxs("form",{style:{display:"flex",alignItems:"center",gap:6,minWidth:0},onSubmit:D=>{D.preventDefault(),!(I||s)&&(!hr(N.trim())||N.trim().startsWith(An)?O("Enter an HTTP or HTTPS image URL."):ae(N.trim()))},children:[f.jsx("input",{type:"url","aria-label":"SVG URL",placeholder:"https://example.com/icon.svg",value:N,disabled:I||s,onChange:D=>$(D.target.value),style:{...G,flex:1,minWidth:0}}),f.jsx(He,{label:"Apply URL",children:f.jsx(Oe,{type:"submit","aria-label":"Apply URL",icon:f.jsx(Y.PiArrowRight,{size:20}),size:"sm",variant:"ghost",disabled:I||s||!N.trim(),style:{flexShrink:0}})})]})]})})]}),B&&f.jsx("div",{role:"alert",style:{fontSize:13},children:B})]})})]})}const ao=["white","blue.500","teal.500","green.500","yellow.500","orange.500","red.500","purple.500","pink.500","gray.500",rn],Sb=["gray.900",rn,"gray.600","gray.200","white"];function jb(){const{config:e}=Je(),r=e.selectionToolbar||{},t=new Set(r.hide||[]);return{palette:r.palette||ao,show:n=>!t.has(n)}}function Et(){const{border:e}=lt();return f.jsx(V.Icon,{mx:-1,as:Y.PiLineVerticalThin,boxSize:5,color:e})}function qr({value:e,placeholder:r,ariaLabel:t,width:n="140px",type:o="text",min:i,disabled:s=!1,onCommit:a}){const{colorText:c}=lt(),[l,d]=j.useState(e),u=j.useRef(!1);j.useEffect(()=>d(e),[e]);const h=()=>{if(u.current)return;u.current=!0;const p=l.trim();if(o==="number"&&p!==""&&(!Number.isFinite(Number(p))||Number(p)<(i??0))){d(e);return}p!==e&&a(p)};return f.jsx(V.Input,{"aria-label":t,type:o,min:i,disabled:s,size:"xs",fontSize:"16px",w:n,value:l,placeholder:r,color:c,borderWidth:0,_focusVisible:{boxShadow:"none",outline:"none"},borderRadius:"8px",onFocus:()=>{u.current=!1},onChange:p=>d(p.target.value),onBlur:h,onKeyDown:p=>{p.key==="Enter"&&(h(),p.target.blur()),p.key==="Escape"&&(u.current=!0,d(e),p.target.blur())}})}function Lr({colors:e,value:r,label:t,onPick:n,onReset:o,includeTransparent:i=!0}){const{colorInactive:s,colorText:a}=lt(),[c,l]=j.useState(!1),d=j.useId(),u=j.useRef(null),h=r??e[0]??"transparent",p=po(f.jsx(Lr,{colors:e,value:r,label:t,onPick:n,onReset:o,includeTransparent:i}));return f.jsx(Xr.Provider,{value:null,children:f.jsxs(V.HStack,{gap:1,"aria-label":t,role:"group",onClickCapture:p,onKeyDown:m=>{var g;m.key==="Escape"&&(l(!1),(g=u.current)==null||g.focus())},children:[f.jsx(He,{label:`${t}: ${h}`,children:f.jsx(V.chakra.button,{ref:u,type:"button","aria-label":`${t} colors`,"aria-expanded":c,"aria-controls":d,w:4,h:4,flexShrink:0,borderRadius:"full",cursor:"pointer",style:{backgroundColor:Me(h),...h==="transparent"?{backgroundImage:"conic-gradient(#fff 25%, #a0aec0 0 50%, #fff 0 75%, #a0aec0 0)",backgroundSize:"8px 8px"}:{}},outline:`2px solid ${Me(a)}`,outlineOffset:"1px",onClick:()=>l(m=>!m)})}),c&&f.jsxs(V.HStack,{id:d,gap:1,children:[[...new Set([...e,...i?["transparent"]:[]])].map(m=>{const g=r===m;return f.jsx(He,{label:`${t}: ${m}`,children:f.jsx(V.Box,{as:"button","aria-label":`${t} ${m}`,"aria-pressed":g,w:4,h:4,borderRadius:"full",cursor:"pointer",style:{backgroundColor:Me(m),...m==="transparent"?{backgroundImage:"conic-gradient(#fff 25%, #a0aec0 0 50%, #fff 0 75%, #a0aec0 0)",backgroundSize:"8px 8px"}:{}},outline:g?`2px solid ${Me(a)}`:"none",outlineOffset:"1px",_hover:{transform:"scale(1.15)"},onClick:()=>n(m),onDoubleClick:y=>{var b;y.stopPropagation(),l(!1),(b=u.current)==null||b.focus()}})},m)}),o&&f.jsx(He,{label:`Reset ${t.toLowerCase()}`,children:f.jsx(Oe,{"aria-label":`Reset ${t}`,icon:f.jsx(V.Icon,{as:Y.PiEraser,boxSize:4}),size:"xs",variant:"ghost",color:s,onClick:()=>{var m;o(),l(!1),(m=u.current)==null||m.focus()}})})]})]})})}function Eb({edgeId:e,onClose:r}){var p;const{callbacks:t,themeColor:n,config:o}=Je(),{colorInactive:i}=lt(),{edgeById:s}=Kt(),{palette:a,show:c}=jb(),l=(p=s.get(e))==null?void 0:p.data,d=[...new Set(["rounded-orthogonal","orthogonal","straight","bezier",...Object.keys(o.customEdgeTypes??{}),...l!=null&&l.type?[l.type]:[]])],u=l!=null&&l.isEdgeAnimated?"animated":l!=null&&l.isEdgeDashed?"dashed":"solid",h=[{key:"solid",icon:Y.PiLineSegment,label:"Solid"},{key:"dashed",icon:Y.PiLineSegments,label:"Dashed"},{key:"animated",icon:Y.PiFastForward,label:"Animated"}];return f.jsxs(f.Fragment,{children:[f.jsx(nn,{onClick:r}),c("label")&&f.jsxs(f.Fragment,{children:[f.jsx(Et,{}),f.jsx(qr,{ariaLabel:"Edge label",placeholder:"Edge label",value:(l==null?void 0:l.label)||"",onCommit:m=>{var g;return(g=t.onEdgeLabelChange)==null?void 0:g.call(t,e,m)}})]}),c("style")&&f.jsxs(f.Fragment,{children:[f.jsx(Et,{}),h.map(m=>f.jsx(He,{label:m.label,children:f.jsx(Oe,{"aria-label":`Edge style ${m.key}`,"aria-pressed":u===m.key,icon:f.jsx(V.Icon,{as:m.icon,boxSize:5}),size:"sm",variant:"ghost",color:u===m.key?n:i,onClick:()=>{var g;return(g=t.onEdgeStyleChange)==null?void 0:g.call(t,e,m.key)}})},m.key)),u==="animated"&&f.jsx(Cb,{label:"Edge animation",value:(l==null?void 0:l.edgeAnimationVariant)??"dashed",options:[{value:"dashed",label:"Dash"},{value:"traveling",label:"Trace"}],disabled:o.readOnly,onChange:m=>{var g;return(g=t.onEdgeAnimationVariantChange)==null?void 0:g.call(t,e,m)}}),f.jsxs(Mt,{"aria-label":"Edge shape",title:`Edge shape: ${(l==null?void 0:l.type)??"Default"}`,icon:f.jsx(Y.PiBezierCurve,{size:20}),style:{width:36},value:(l==null?void 0:l.type)??"",disabled:o.readOnly,onValueChange:m=>{var g;return(g=t.onEdgeTypeChange)==null?void 0:g.call(t,e,m||void 0)},children:[f.jsx("option",{value:"",children:"Default"}),d.map(m=>f.jsx("option",{value:m,children:m},m))]})]}),c("icon")&&f.jsxs(f.Fragment,{children:[f.jsx(Et,{}),f.jsx(Fd,{edgeId:e,value:l==null?void 0:l.icon},e),f.jsx(qr,{ariaLabel:"Edge icon",placeholder:"Icon name or SVG URL",value:(l==null?void 0:l.icon)??"",onCommit:m=>{var g;return(g=t.onEdgeIconChange)==null?void 0:g.call(t,e,m)}})]}),c("color")&&f.jsxs(f.Fragment,{children:[f.jsx(Et,{}),f.jsx(Lr,{label:"Edge color",colors:a,value:l==null?void 0:l.color,onPick:m=>{var g;return(g=t.onEdgeColorChange)==null?void 0:g.call(t,e,m)},onReset:()=>{var m;return(m=t.onEdgeColorChange)==null?void 0:m.call(t,e,"")}})]}),c("delete")&&f.jsxs(f.Fragment,{children:[f.jsx(Et,{}),f.jsx(He,{label:"Delete edge",children:f.jsx(Oe,{"aria-label":"Delete edge",icon:f.jsx(V.Icon,{as:Y.PiTrash,boxSize:5}),size:"sm",variant:"ghost",color:"red.400",onClick:()=>{var m;(m=t.onEdgeDelete)==null||m.call(t,e,l),r()}})})]})]})}function _b({ids:e,showDivider:r=!0}){const{callbacks:t,config:n,nodeGridOptions:o,fillRadiusEditedIds:i,setNodeRadiusPreview:s}=Je(),{colorInactive:a}=lt(),{nodeById:c}=Kt(),[l,d]=j.useState(),u=j.useRef(),h=j.useRef(),p=j.useRef({callbacks:t,readOnly:n.readOnly,nodeById:c});p.current={callbacks:t,readOnly:n.readOnly,nodeById:c};const m=()=>{var C,S;clearTimeout(h.current);const w=u.current;if(u.current=void 0,!!w){if(!p.current.readOnly)for(const R of w.ids)p.current.nodeById.has(R)&&((S=(C=p.current.callbacks).onNodeBorderRadiusChange)==null||S.call(C,R,w.radius));s(w.ids,void 0),d(void 0)}},g=j.useRef(m);g.current=m,j.useEffect(()=>{const w=()=>g.current();return window.addEventListener("pagehide",w),()=>{window.removeEventListener("pagehide",w),w()}},[]);const y=e.map(w=>{var C,S;return o!=null&&o.fill&&!i.has(w)?0:(S=(C=c.get(w))==null?void 0:C.data.viewProps)==null?void 0:S.borderRadius}),b=!y.every(w=>w===y[0]),x=l??y[0]??0,v=w=>{n.readOnly||(w!==void 0&&e.every(C=>{var S;return((S=c.get(C))==null?void 0:S.data.type)==="grid"})?(d(w),s(e,w),u.current={ids:[...e],radius:w},clearTimeout(h.current),h.current=setTimeout(m,150)):(clearTimeout(h.current),u.current=void 0,d(void 0),s(e,void 0),e.forEach(C=>{var S;return(S=t.onNodeBorderRadiusChange)==null?void 0:S.call(t,C,w)})))};return f.jsxs(f.Fragment,{children:[r&&f.jsx(Et,{}),f.jsx(V.Box,{position:"relative",w:"36px",h:"30px",display:"grid",placeItems:"center",children:f.jsx(Mt,{icon:f.jsx(V.Icon,{as:Ev.TbBorderRadius,boxSize:5,color:a,"aria-hidden":"true"}),"aria-label":"Node border radius",title:`Border radius: ${b?"Mixed":y[0]===void 0?"Default":`${y[0]}px`}`,style:{position:"absolute",inset:0,width:"100%",height:"100%",cursor:"pointer"},value:"radius",disabled:n.readOnly,onValueChange:()=>{},popupContent:f.jsxs(f.Fragment,{children:[f.jsx(yd,{label:"Border radius",inputLabel:"Node corner radius",min:0,max:Math.max(500,...y.map(w=>w??0)),step:1,value:x,displayValue:l!==void 0?`${l}px`:b?"Mixed":y[0]===void 0?"Default":`${x}px`,onChange:v,onChangeEnd:m}),f.jsx(He,{label:"Reset border radius",children:f.jsx(Oe,{"aria-label":"Reset border radius",icon:f.jsx(Y.PiEraser,{size:20}),size:"sm",variant:"ghost",color:a,disabled:n.readOnly,onClick:()=>v(void 0)})})]}),children:f.jsx("option",{value:"radius",children:"Border radius"})})})]})}function Rb({ids:e,onClose:r,afterLabel:t}){var ce,Q,K,ie,ye,we,fe,ge;const{callbacks:n,colorMode:o,themeColor:i,config:s,setNodeViewMode:a,nodeViewModes:c}=Je(),{colorText:l,colorInactive:d}=lt(),{nodeById:u,parentIds:h}=Kt(),{palette:p,show:m}=jb(),g=e.length===1,[y,b]=j.useState(""),x=g?(ce=u.get(e[0]))==null?void 0:ce.data:void 0,v=e.map(X=>{var J,xe,Se,Fe,De,he;const H=(J=u.get(X))==null?void 0:J.data,be=((xe=H==null?void 0:H.config)==null?void 0:xe.typeView)??"";return be==="object"&&((Se=H==null?void 0:H.config)==null?void 0:Se.content)!==void 0&&c[X]!=="properties"?"content":be==="icon-label"&&((Fe=H==null?void 0:H.viewProps)==null?void 0:Fe.bgColor)==="transparent"&&((De=H==null?void 0:H.viewProps)==null?void 0:De.borderWidth)===0&&((he=H==null?void 0:H.viewProps)==null?void 0:he.outline)===!1?"media":be}),w=v.some(X=>X!==v[0]),C=w?"mixed":v[0]??"",S=[{value:"text",label:"Text",view:"text",icon:Y.PiTextT},{value:"icon-label",label:"Icon Label",view:"icon-label",icon:Y.PiShapes},{value:"object",label:"Object",view:"object",icon:Y.PiBracketsCurly},{value:"grid",label:"Grid",view:"grid",icon:Y.PiGridFour},{value:"parent",label:"Parent",view:"parent",icon:Y.PiStack},{value:"media",label:"Media",view:"icon-label",icon:Y.PiFileSvg},{value:"content",label:"Content",view:"object",icon:Y.PiTextAlignLeft}],R=e.some(X=>{var be,J,xe,Se;const H=(be=u.get(X))==null?void 0:be.data;return H&&((J=H.config)==null?void 0:J.typeView)!=="grid"&&((xe=H.config)==null?void 0:xe.typeView)!=="parent"&&(h.has(X)||((Se=H.config)==null?void 0:Se.parentContainer)||Object.prototype.hasOwnProperty.call(s.customViews??{},H.type))}),P=(Q=x==null?void 0:x.config)==null?void 0:Q.collapsed,k=wb(e[0]),T=X=>{var H,be,J;return(((be=(H=u.get(X))==null?void 0:H.data.viewProps)==null?void 0:be.outline)??(h.has(X)?(J=s.parentNodeStyle)==null?void 0:J.outline:!1))===!0},E=e.every(T),M=!E&&e.some(T),_=X=>{var H;return((H=u.get(X))==null?void 0:H.data.isNodeAnimated)===!0},N=e.every(_),$=!N&&e.some(_),B=e.map(X=>{var H;return((H=u.get(X))==null?void 0:H.data.nodeAnimationVariant)??"traveling"}),O=B.every(X=>X===B[0])?B[0]:"",I=X=>e.forEach(X),[ee,ae]=j.useState(!1),ne=ee&&m("color")&&m("borderColor"),oe=X=>{var H,be,J;return(((be=(H=u.get(X))==null?void 0:H.data.viewProps)==null?void 0:be.borderStyle)??(h.has(X)?(J=s.parentNodeStyle)==null?void 0:J.borderStyle:"solid"))==="dashed"},pe=e.every(oe),q=!pe&&e.some(oe),F=e.map(X=>{var J,xe,Se;const H=(J=u.get(X))==null?void 0:J.data,be=h.has(X)?Nn((xe=s.parentNodeStyle)==null?void 0:xe.borderWidth,6):(H==null?void 0:H.type)==="objectView"?3:2;return Nn((Se=H==null?void 0:H.viewProps)==null?void 0:Se.borderWidth,be)}),G=F.every(X=>X===F[0])?String(F[0]??""):"",D=X=>I(H=>{var be,J;ne?(be=n.onNodeBorderColorChange)==null||be.call(n,H,X):(J=n.onNodeColorChange)==null||J.call(n,H,"bg",X)});return f.jsxs(f.Fragment,{children:[f.jsx(nn,{onClick:r}),f.jsx(Et,{}),g&&m("label")?f.jsx(qr,{ariaLabel:"Node label",placeholder:"Node label",value:(x==null?void 0:x.label)??(x==null?void 0:x.headerTitle)??"",onCommit:X=>{var H;return(H=n.onNodeLabelChange)==null?void 0:H.call(n,e[0],X)}}):f.jsxs(V.Text,{fontSize:"xs",color:l,whiteSpace:"nowrap",px:1,children:[e.length," selected"]}),t,m("typeView")&&f.jsxs(Mt,{"aria-label":"Type view",title:R?"Type view is managed by the custom renderer or container":`Type view: ${C||"None (default)"}`,icon:f.jsx(Y.PiCards,{size:20}),style:{width:36},value:C,disabled:s.readOnly||s.editable===!1||R,onValueChange:X=>{var be;const H=(be=S.find(J=>J.value===X))==null?void 0:be.view;H&&I(J=>{var Se,Fe,De,he,Re,ze,Te,qe,Qe,ct,Pe,Ze,Ye;const xe=(Se=u.get(J))==null?void 0:Se.data;X==="media"?((Fe=n.onNodeColorChange)==null||Fe.call(n,J,"bg","transparent"),(De=n.onNodeBorderColorChange)==null||De.call(n,J,"#00000000"),(he=n.onNodeBorderWidthChange)==null||he.call(n,J,0),(Re=n.onNodeOutlineChange)==null||Re.call(n,J,!1)):v[e.indexOf(J)]==="media"&&((ze=n.onNodeColorChange)==null||ze.call(n,J,"bg",""),(Te=n.onNodeBorderColorChange)==null||Te.call(n,J,""),(qe=n.onNodeBorderWidthChange)==null||qe.call(n,J,void 0)),X==="content"&&((Qe=xe==null?void 0:xe.config)==null?void 0:Qe.content)===void 0&&((ct=n.onNodeContentChange)==null||ct.call(n,J,"")),(Pe=n.onNodeTypeViewChange)==null||Pe.call(n,J,H),a(J,X==="object"&&((Ze=xe==null?void 0:xe.config)==null?void 0:Ze.content)!==void 0?"properties":"default"),(Ye=n.onNodeViewToggle)==null||Ye.call(n,J)})},children:[w&&f.jsx("option",{value:"mixed",disabled:!0,children:"Mixed"}),S.map(X=>f.jsx("option",{value:X.value,children:f.jsxs(V.HStack,{gap:"12px",children:[f.jsx(X.icon,{size:20,"aria-hidden":"true",style:{flexShrink:0}}),f.jsx("span",{children:X.label})]})},X.value))]}),m("style")&&f.jsx(_b,{ids:e},e.join("\0")),m("outline")&&f.jsxs(f.Fragment,{children:[f.jsx(Et,{}),f.jsx(He,{label:E?"Restore node fill":"Remove node fill",children:f.jsx(Oe,{"aria-label":"Toggle node outline","aria-pressed":M?"mixed":E,icon:f.jsx(V.Icon,{as:E?Y.PiSquare:Y.PiSquareFill,boxSize:5}),size:"sm",variant:"ghost",color:E?i:d,onClick:()=>I(X=>{var H;return(H=n.onNodeOutlineChange)==null?void 0:H.call(n,X,!E)})})})]}),m("color")&&f.jsxs(f.Fragment,{children:[f.jsx(Et,{}),m("borderColor")&&f.jsx(He,{label:ne?"Edit node colors":"Edit node border",children:f.jsx(Oe,{"aria-label":"Edit node border","aria-pressed":ne,icon:f.jsx(V.Icon,{as:Y.PiBoundingBox,boxSize:5}),size:"sm",variant:"ghost",color:ne?i:d,bg:ne?o==="dark"?"whiteAlpha.200":"blackAlpha.100":void 0,onClick:()=>ae(X=>!X)})}),f.jsx(Lr,{label:ne?"Border color":"Background",colors:p,value:ne?((K=x==null?void 0:x.viewProps)==null?void 0:K.borderColor)??(g&&h.has(e[0])?(ie=s.parentNodeStyle)==null?void 0:ie.borderColor:void 0):(ye=x==null?void 0:x.viewProps)==null?void 0:ye.bgColor,onPick:D,onReset:()=>D("")}),ne&&m("style")&&f.jsxs(f.Fragment,{children:[f.jsx(Et,{}),f.jsx(He,{label:pe?"Solid border":"Dashed border",children:f.jsx(Oe,{"aria-label":"Toggle dashed border","aria-pressed":q?"mixed":pe,icon:f.jsx(V.Icon,{as:pe?Y.PiLineSegments:Y.PiLineSegment,boxSize:5}),size:"sm",variant:"ghost",color:pe?i:d,onClick:()=>I(X=>{var H;return(H=n.onNodeBorderStyleChange)==null?void 0:H.call(n,X,pe?"solid":"dashed")})})}),f.jsx(qr,{ariaLabel:"Border thickness",placeholder:g?"Auto":"Mixed",width:"64px",type:"number",min:0,value:G,onCommit:X=>I(H=>{var be;return(be=n.onNodeBorderWidthChange)==null?void 0:be.call(n,H,X===""?void 0:Number(X))})})]})]}),m("animation")&&f.jsxs(f.Fragment,{children:[f.jsx(Et,{}),f.jsx(He,{label:N?"Stop border animation":"Animate node border",children:f.jsx(Oe,{"aria-label":"Toggle node animation","aria-pressed":$?"mixed":N,icon:f.jsx(V.Icon,{as:Y.PiSpinnerGap,boxSize:5}),size:"sm",variant:"ghost",color:N?i:d,onClick:()=>I(X=>{var H;return(H=n.onNodeAnimationChange)==null?void 0:H.call(n,X,!N)})})}),(N||$)&&f.jsx(Cb,{label:"Node animation",value:O,options:[{value:"traveling",label:"Trace"},{value:"pulse",label:"Pulse"}],disabled:s.readOnly,onChange:X=>I(H=>{var be;return(be=n.onNodeAnimationVariantChange)==null?void 0:be.call(n,H,X)})})]}),!ne&&m("textColor")&&f.jsxs(f.Fragment,{children:[f.jsx(Et,{}),f.jsx(Lr,{label:"Text color",colors:Sb,value:(we=x==null?void 0:x.viewProps)==null?void 0:we.textColor,onPick:X=>I(H=>{var be;return(be=n.onNodeColorChange)==null?void 0:be.call(n,H,"text",X)}),onReset:()=>I(X=>{var H;return(H=n.onNodeColorChange)==null?void 0:H.call(n,X,"text","")})})]}),g&&m("icon")&&f.jsxs(f.Fragment,{children:[f.jsx(Et,{}),f.jsx(Fd,{nodeId:e[0],value:(fe=x==null?void 0:x.config)==null?void 0:fe.icon},e[0]),f.jsx(qr,{ariaLabel:"Node icon",placeholder:"(e.g. PiGear)",width:"120px",value:((ge=x==null?void 0:x.config)==null?void 0:ge.icon)||"",onCommit:X=>{var H;return(H=n.onNodeIconChange)==null?void 0:H.call(n,e[0],X)}})]}),g&&k&&m("collapse")&&P!==void 0&&f.jsxs(f.Fragment,{children:[f.jsx(Et,{}),f.jsx(He,{label:P?"Expand":"Collapse",children:f.jsx(Oe,{"aria-label":P?"Expand node":"Collapse node",icon:f.jsx(V.Icon,{as:P?Y.PiArrowsOutLineVertical:Y.PiArrowsInLineVertical,boxSize:5}),size:"sm",variant:"ghost",color:d,onClick:()=>{var X;return(X=n.onNodeCollapse)==null?void 0:X.call(n,e[0],!P)}})})]}),m("delete")&&f.jsxs(f.Fragment,{children:[f.jsx(Et,{}),f.jsx(He,{label:g?"Delete node":`Delete ${e.length} nodes`,children:f.jsx(Oe,{"aria-label":"Delete selected nodes",icon:f.jsx(V.Icon,{as:Y.PiTrash,boxSize:5}),size:"sm",variant:"ghost",color:o==="dark"?"red.300":"red.500",onClick:()=>{I(X=>{var H,be;return(be=n.onNodeDelete)==null?void 0:be.call(n,X,((H=u.get(X))==null?void 0:H.data)||{id:X})}),r()}})})]}),f.jsx(Et,{}),f.jsx(He,{label:"Copy selection",children:f.jsx(Oe,{"aria-label":"Copy selection",icon:f.jsx(Y.PiCopy,{size:20}),size:"sm",variant:"ghost",color:d,onClick:async()=>{var X;try{await((X=n.onNodesCopy)==null?void 0:X.call(n,e)),b("")}catch(H){b(String(H))}}})}),f.jsx(He,{label:"Duplicate selection",children:f.jsx(Oe,{"aria-label":"Duplicate selection",icon:f.jsx(Y.PiCopySimple,{size:20}),size:"sm",variant:"ghost",color:d,disabled:s.readOnly||s.editable===!1,onClick:()=>{var X;try{(X=n.onNodesDuplicate)==null||X.call(n,e),b("")}catch(H){b(String(H))}}})}),y&&f.jsx(V.Text,{role:"alert",fontSize:"xs",children:y})]})}async function kb(e){const{toSvg:r}=await Promise.resolve().then(()=>require("./index-sHQXTNv9.cjs"));await document.fonts.ready;const t=await r(e,{filter:o=>!(o instanceof Element)||!o.matches("button, iframe, [role=tooltip], .flow-sdk-handle, .flow-sdk-property-port, .flow-sdk-edge-hit, .flow-sdk-ghost, .flow-sdk-node-animation")}),n=new DOMParser().parseFromString(decodeURIComponent(t.slice(t.indexOf(",")+1)),"image/svg+xml");return n.querySelectorAll(".flow-sdk-edge-hit, .flow-sdk-handle, .flow-sdk-property-port, .flow-sdk-ghost").forEach(o=>o.remove()),n.querySelectorAll("[data-flow-preview-source]").forEach(o=>{o.setAttribute("style","display:block;white-space:pre-wrap;font:16px/1.5 monospace;overflow-wrap:anywhere")}),`data:image/svg+xml;charset=utf-8,${encodeURIComponent(new XMLSerializer().serializeToString(n))}`}async function Ab(e,r="squeed.svg"){const t=document.createElement("a");t.href=await kb(e),t.download=r.endsWith(".svg")?r:`${r}.svg`,t.click()}function Pb(){const{themeColor:e}=Je(),[r,t]=j.useState(!1),[n,o]=j.useState("");return f.jsxs(f.Fragment,{children:[f.jsx(He,{label:"Download SVG (current view)",children:f.jsx(Oe,{"aria-label":"Download SVG",icon:f.jsx(Y.PiDownloadSimpleFill,{size:20}),disabled:r,borderRadius:"30%",color:e,variant:"ghost",onClick:async i=>{var a;const s=(a=i.currentTarget.closest("[data-flow-diagram]"))==null?void 0:a.querySelector("[data-flow-background]");if(!s){o("Diagram not available for export.");return}t(!0),o("");try{await Ab(s)}catch(c){o(c instanceof Error?c.message:"Unable to export SVG.")}finally{t(!1)}}})}),n&&f.jsx("span",{role:"alert",style:{fontSize:12,maxWidth:220},children:n})]})}function vo({children:e,background:r,border:t,endElement:n,startElement:o,startElementWidth:i=44,framed:s=!0}){const a=j.useRef(null),[c,l]=j.useState({left:!1,right:!1});j.useLayoutEffect(()=>{const u=a.current;let h=u.parentElement.offsetWidth;const p=()=>{const y=u.parentElement.offsetWidth;if(y>0&&y!==h){const v=h/y;h=y,v>0&&!window.matchMedia("(prefers-reduced-motion: reduce)").matches&&u.parentElement.animate({transform:[`scaleX(${v})`,"scaleX(1)"],transformOrigin:[n?"right center":"left center",n?"right center":"left center"]},{duration:180,easing:"ease-out",id:"flow-toolbar-grow"})}const b=u.scrollLeft>1,x=u.scrollWidth-u.clientWidth-u.scrollLeft>1;l(v=>v.left===b&&v.right===x?v:{left:b,right:x})},m=y=>{const b=y.target instanceof Element?y.target:null;if((b==null?void 0:b.closest("[data-flow-toolbar-scroll]"))!==u||b.closest("[popover], [data-flow-floating-panel]")!==u.closest("[popover], [data-flow-floating-panel]")||y.defaultPrevented||y.ctrlKey||s&&y.deltaX!==0||!(y.deltaX||y.deltaY)||u.scrollWidth<=u.clientWidth)return;y.preventDefault();const x=y.deltaMode===WheelEvent.DOM_DELTA_LINE?16:y.deltaMode===WheelEvent.DOM_DELTA_PAGE?u.clientWidth:1;u.scrollLeft+=(y.deltaX||y.deltaY)*x},g=new ResizeObserver(p);return g.observe(u),u.firstElementChild&&g.observe(u.firstElementChild),u.addEventListener("scroll",p,{passive:!0}),u.addEventListener("wheel",m,{passive:!1}),p(),()=>{g.disconnect(),u.removeEventListener("scroll",p),u.removeEventListener("wheel",m)}},[]);const d=`var(--chakra-colors-${r.replace(".","-")})`;return f.jsxs(V.Box,{position:"relative",bg:s?r:"transparent",minW:0,maxW:"100%",flex:"0 1 auto",borderRadius:s?"30px":0,css:{...s?xr(d,`var(--chakra-colors-${t.replace(".","-")})`):{},...s||o?{"--flow-toolbar-start-width":o?`${i}px`:"0px"}:{}},children:[f.jsx(V.Box,{ref:a,"data-flow-toolbar-scroll":"",h:50,minH:50,alignContent:"center",overflowX:"auto",overflowY:"hidden",mr:n?"44px":void 0,ml:o?`${i}px`:void 0,borderRadius:"inherit",css:{scrollbarWidth:"none","&::-webkit-scrollbar":{display:"none"}},children:e}),["left","right"].map(u=>f.jsx(V.Box,{"data-flow-toolbar-fade":u,"aria-hidden":"true",position:"absolute",top:0,bottom:0,w:"20px",pointerEvents:"none",borderRadius:u==="left"?"30px 0 0 30px":"0 30px 30px 0",style:{[u]:u==="right"&&n?44:u==="left"&&o?i:0,opacity:c[u]?1:0,background:`linear-gradient(to ${u==="left"?"right":"left"}, ${d}, transparent)`}},u)),n&&f.jsx(V.Box,{position:"absolute",right:"6px",top:0,h:"50px",w:"32px",display:"flex",alignItems:"center",justifyContent:"center",children:n}),o&&f.jsx(V.Box,{position:"absolute",left:"6px",top:0,h:"50px",w:`${i-12}px`,display:"flex",alignItems:"center",justifyContent:"center",children:o})]})}async function $w(e,r){const t=new Set,n=[],o=(a,c)=>{var d,u,h;if(!a||typeof a!="object")return;const l=a;n.push(c),typeof((d=l.$form)==null?void 0:d.$type)=="string"&&t.add(l.$form.$type),typeof((h=(u=l.$form)==null?void 0:u.$create)==null?void 0:h.$type)=="string"&&t.add(l.$form.$create.$type);for(const[p,m]of Object.entries(l))p==="$"?o(m,c):p.startsWith("$")||o(m,`${c}.${p}`)};if(o(r,"root"),!t.size)return{contract:await mb(e)};const i=await qd(e,[...t]);for(const a of t)if(!Object.prototype.hasOwnProperty.call(i,a))throw new Error(`Missing form type: ${a}`);const s={};for(const a of n){const c=on(r,a,i);c&&(s[a]={type:c.type,optional:!1})}return{schema:i,contract:{name:e.name,nodes:s}}}function Mb({message:e,onDismiss:r}){const{background:t,colorText:n,border:o}=lt();return!e||typeof document>"u"?null:Jr.createPortal(f.jsxs(V.chakra.div,{role:"alert","aria-atomic":"true",css:xr(Me(t),Me(o)),onPointerDown:i=>i.stopPropagation(),onClick:i=>i.stopPropagation(),style:{position:"fixed",top:20,right:20,zIndex:1e4,width:360,maxWidth:"calc(100vw - 40px)",boxSizing:"border-box",display:"flex",alignItems:"flex-start",gap:10,padding:16,borderRadius:8,background:Me(t),color:Me(n),fontSize:14,lineHeight:1.5},children:[f.jsx(Y.PiWarningCircle,{size:20,"aria-hidden":"true",style:{flexShrink:0,color:"#ef4444"}}),f.jsxs("div",{style:{flex:1,minWidth:0,overflowWrap:"anywhere"},children:[f.jsx("strong",{children:"Interface upload failed"}),f.jsx("div",{children:e})]}),f.jsx(nn,{type:"button","aria-label":"Dismiss upload error",title:"Dismiss upload error",onClick:r,flexShrink:0,width:"24px",height:"24px",minWidth:"24px",padding:0})]}),document.body)}function zd({showDivider:e=!0,compact:r=!1}={}){const{edgeMode:t,setEdgeMode:n,workflowContract:o,setWorkflowContract:i,callbacks:s,readOnly:a,themeColor:c,colorMode:l}=Je(),{edgeById:d}=Kt(),{data:u,schema:h,setSchema:p,bindings:m,structured:g}=j.useContext(Tt),y=(g==null?void 0:g.sourceBindings)??m,b=(g==null?void 0:g.sourceSchema)??h,{colorText:x}=lt(),v=j.useRef(null),w=j.useRef(0),[C,S]=j.useState(!1),[R,P]=j.useState("");j.useEffect(()=>()=>{w.current++},[]),j.useEffect(()=>{w.current++,S(!1)},[a,u,y]);const k=o?[...d.values()].filter(M=>$d(o,M.data)).length:0,T=o?`${o.name}: ${b?`${Object.keys(b).length} form types loaded; `:""}${k} invalid or unverified connections`:"",E=po(f.jsx(zd,{showDivider:!1,compact:!0}));return f.jsx(Xr.Provider,{value:null,children:f.jsxs("span",{style:{display:"contents"},onClickCapture:E,children:[f.jsx(Mb,{message:R,onDismiss:()=>P("")}),e&&f.jsx(Sn,{}),f.jsxs(Mt,{"aria-label":"Edge mode",title:t==="auto"?"Connections: Auto":t==="properties"?"Connections: Properties":"Connections: Nodes",icon:t==="auto"?f.jsx(Y.PiGraph,{size:20}):t==="properties"?f.jsx(Y.PiTable,{size:20}):f.jsx(Y.PiTreeStructure,{size:20}),style:{width:36},value:t,disabled:a,footer:s.onWorkflowConfigurationOpen&&f.jsxs(f.Fragment,{children:[f.jsx("hr",{style:{border:0,borderTop:"1px solid currentColor",opacity:.2,margin:"8px 0"}}),f.jsxs(V.Button,{"data-flow-menu-action":"",variant:"ghost",width:"100%",justifyContent:"flex-start",color:"inherit",bg:"transparent",css:io,_hover:{bg:l==="dark"?"whiteAlpha.100":"blackAlpha.50"},_focusVisible:{bg:l==="dark"?"whiteAlpha.100":"blackAlpha.50"},onClick:M=>{var _,N;(_=M.currentTarget.closest("[popover]"))==null||_.hidePopover(),(N=s.onWorkflowConfigurationOpen)==null||N.call(s)},children:[f.jsx(Y.PiGear,{}),"Configuration"]})]}),onValueChange:M=>{var N;const _=M==="auto"?"auto":M==="properties"?"properties":"nodes";n(_),(N=s.onEdgeModeChange)==null||N.call(s,_)},children:[f.jsx("option",{value:"auto",children:"Auto"}),f.jsx("option",{value:"nodes",children:"Nodes"}),f.jsx("option",{value:"properties",children:"Properties"})]}),f.jsxs("span",{style:{display:t==="auto"||t==="properties"?"contents":"none"},children:[f.jsx(He,{label:o?`Replace ${o.name}`:"Upload workflow interface",children:f.jsx(Oe,{"aria-label":"Upload workflow interface",icon:f.jsx(Y.PiUploadSimple,{size:20}),color:Me(c),size:"sm",variant:"ghost",disabled:C||a,onClick:()=>{var M;return(M=v.current)==null?void 0:M.click()}})}),f.jsx("input",{ref:v,type:"file",hidden:!0,accept:".ts,.json","aria-label":"Workflow interface file",disabled:a||C,onChange:async M=>{var $,B;const _=($=M.target.files)==null?void 0:$[0];if(M.target.value="",!_)return;const N=++w.current;S(!0),P("");try{const O=y?await qd(_,[...new Set(Object.values(y).map(ae=>ae.schemaType??ae.type))]):void 0;if(y&&O){for(const ae of Object.values(y))if(!Object.prototype.hasOwnProperty.call(O,ae.schemaType??ae.type))throw new Error(`Missing form type: ${ae.schemaType??ae.type}`)}const{contract:I,schema:ee}=y&&O?{schema:O,contract:{name:_.name,nodes:Object.fromEntries(Object.entries(y).map(([ae,ne])=>[ae,{type:O[ne.schemaType??ne.type],optional:!1}]))}}:await $w(_,u);if(N!==w.current)return;p==null||p(ee),i(I),(B=s.onWorkflowContractChange)==null||B.call(s,I)}catch(O){N===w.current&&P(`${_.name}: ${O instanceof Error?O.message:"Unable to load interface."}`)}finally{N===w.current&&S(!1)}}}),!r&&(T||C)&&f.jsx("span",{role:"status",title:T,style:{color:Me(x),fontSize:12,maxWidth:180,whiteSpace:"nowrap",overflow:"hidden",textOverflow:"ellipsis"},children:C?"Loading interface...":T}),!r&&o&&f.jsx(He,{label:"Remove workflow interface",children:f.jsx(Oe,{"aria-label":"Remove workflow interface",icon:f.jsx(Y.PiX,{size:16}),size:"sm",variant:"ghost",disabled:a||C,onClick:()=>{var M;p==null||p(void 0),i(void 0),(M=s.onWorkflowContractChange)==null||M.call(s,void 0),P("")}})})]})]})})}const qw=[{value:"BT",label:"Bottom to Up",icon:Y.PiArrowUp,flowType:yn.BOTTOM_UP},{value:"TB",label:"Top to Bottom",icon:Y.PiArrowDown,flowType:yn.TOP_DOWN},{value:"LR",label:"Left to Right",icon:Y.PiArrowRight,flowType:yn.LEFT_RIGHT},{value:"RL",label:"Right to Left",icon:Y.PiArrowLeft,flowType:yn.RIGHT_LEFT}],Ib=({nodeGridControlsTarget:e}={})=>{const{engineRef:r,themeColor:t,setThemeColor:n,edgeColor:o,setEdgeColor:i,backgroundSelected:s,setBackgroundSelected:a,direction:c,edgeMode:l,allNodesIconLabel:d,setAllNodesIconLabel:u,nodeGridOptions:h,selectedNodeIds:p,setSelectedNodeIds:m,selectedEdgeId:g,setSelectedEdgeId:y,isZoomMode:b,setIsZoomMode:x,isMultiSelectMode:v,setIsMultiSelectMode:w,isDragMode:C,setIsDragMode:S,isEdgeHandlesEnabled:R,setIsEdgeHandlesEnabled:P,isArrayNodeMode:k,setIsArrayNodeMode:T,isPinned:E,setIsPinned:M,callbacks:_,config:N,readOnly:$}=Je(),{nodeById:B,edgeById:O,parentIds:I}=Kt(),ee=N.colorMode==="dark",{background:ae,border:ne,colorInactive:oe,colorText:pe,colorActive:q}=lt(),F=ee?ne:"gray.300",G=`var(--chakra-colors-${ae.replace(".","-")})`,D=`var(--chakra-colors-${(ee?ne:"gray.300").replace(".","-")})`,[ce,Q]=j.useState(!1),[K,ie]=j.useState(!0),ye=N.bottomBarCollapsed??K,we=j.useRef(null),fe=ho({edge:"bottom",enabled:!E,bounds:we,inside:[we]}),ge=j.useCallback(Pe=>{const Ze=r.current;if(!Ze)return;const Ye=N.minZoom??.01,at=N.maxZoom??1.5,Ot=.02;let Rt=Ze.zoom();switch(Pe){case"increase":Rt=Math.min(at,Rt+Ot),Ze.zoom(Rt),Ze.center(!1);break;case"decrease":Rt=Math.max(Ye,Rt-Ot),Ze.zoom(Rt),Ze.center(!1);break;case"reset":Ze.fit(50);break}},[r,N.minZoom,N.maxZoom]),X=N.renderSelectedNodeToolbar,H=p.length>0&&!!X,be=j.useMemo(()=>H?p.map(Pe=>{var Ye;return{...((Ye=B.get(Pe))==null?void 0:Ye.data)??{id:Pe},isParent:I.has(Pe)}}):[],[H,p,B,I]),J=j.useCallback(()=>{var Pe;m([]),(Pe=_.onNodeDeselect)==null||Pe.call(_)},[m,_]),xe=N.renderSelectedEdgeToolbar,Se=!!g&&!!xe,Fe=j.useMemo(()=>{var Pe;return!Se||!g?null:((Pe=O.get(g))==null?void 0:Pe.data)??{id:g}},[Se,g,O]),De=j.useCallback(()=>{var Pe;y(null),(Pe=_.onEdgeDeselect)==null||Pe.call(_)},[y,_]),he=N.selectionToolbar!==!1&&!$,Re=he&&!!g&&!xe,ze=he&&!Re&&p.length>0&&!X,Te=Re||ze,qe=E||fe||ce||Te||N.bottomBarCollapsed===!1;j.useEffect(()=>{p.length||g?a(!1):$||(s&&M(!0),N.bottomBarCollapsed===void 0&&ie(!s))},[s,p.length,g,$,a,M,N.bottomBarCollapsed]);const Qe=N.renderBottomBar,ct=dw();return Qe?f.jsxs(f.Fragment,{children:[H&&f.jsx(V.Box,{position:"absolute",bottom:5,left:"50%",transform:"translateX(-50%)",zIndex:101,children:X({selectedNodeIds:p,selectedNodeData:be,onDeselect:J})}),Se&&Fe&&f.jsx(V.Box,{position:"absolute",bottom:5,left:"50%",transform:"translateX(-50%)",zIndex:101,children:xe({edgeId:g,edgeData:Fe,onDeselect:De})}),f.jsx(V.Box,{position:"absolute",bottom:0,left:0,right:0,zIndex:100,w:"100%",children:Qe({zoomIn:()=>ge("increase"),zoomOut:()=>ge("decrease"),resetZoom:()=>ge("reset"),direction:c,isZoomMode:b,setIsZoomMode:x,isMultiSelectMode:v,setIsMultiSelectMode:w,isDragMode:C,setIsDragMode:S,isEdgeHandlesEnabled:R,setIsEdgeHandlesEnabled:P,isArrayNodeMode:k,setIsArrayNodeMode:T,selectedNodeIds:p,selectedNodeData:be,selectedEdgeId:g,selectedEdgeData:Fe,onNodeDeselect:J,onEdgeDeselect:De,callbacks:_})})]}):f.jsxs(Xr.Provider,{value:ct,children:[H&&f.jsx(V.Box,{position:"absolute",bottom:5,left:"50%",transform:"translateX(-50%)",zIndex:101,children:X({selectedNodeIds:p,selectedNodeData:be,onDeselect:J})}),Se&&Fe&&f.jsx(V.Box,{position:"absolute",bottom:5,left:"50%",transform:"translateX(-50%)",zIndex:101,children:xe({edgeId:g,edgeData:Fe,onDeselect:De})}),f.jsx(V.Box,{ref:we,role:"toolbar","aria-label":"Diagram controls",position:"absolute",bottom:0,left:0,right:0,zIndex:100,w:"100%",transition:"opacity 0.3s ease-in, transform 0.3s ease",transform:qe?"translateY(0)":"translateY(100%)",pointerEvents:qe?"auto":"none",visibility:qe?"visible":"hidden",opacity:qe?1:0,css:{"& button > svg:not([popover] *)":{width:"20px",height:"20px",minWidth:"20px",minHeight:"20px",flexShrink:0},"@media (hover: none)":{visibility:"visible",opacity:1,transform:"none",pointerEvents:"auto"}},children:f.jsxs(V.Flex,{w:"100%",px:5,position:"absolute",bottom:"calc(20px + env(safe-area-inset-bottom, 0px))",flexDirection:"row",justifyContent:"space-between",alignItems:"center",gap:"24px",css:{"@media (min-width: 1024px)":{"& > :first-of-type":{maxWidth:"50vw"}}},children:[f.jsx(vo,{background:ae,border:ee?ne:"gray.300",children:f.jsxs(V.HStack,{px:2,gap:1,flexWrap:"nowrap",w:"max-content",minW:"100%",h:"100%",css:{"& > *":{flexShrink:0}},children:[Re?f.jsx(Eb,{edgeId:g,onClose:De}):ze?f.jsx(Rb,{ids:p,onClose:J}):null,f.jsxs("div",{style:{display:Re||ze?"none":"contents"},children:[f.jsxs("span",{style:{display:N.bottomBarNavigation===!1?"none":"contents"},children:[f.jsx(He,{label:E?"Unpin":"Pin",children:f.jsx(Oe,{"aria-label":"Pin",icon:f.jsx(V.Icon,{as:E?Y.PiPushPinFill:Y.PiPushPin,boxSize:5}),size:"sm",variant:"ghost",color:E?t:oe,onClick:()=>{M(!E),Q(!1)}})}),f.jsx(V.Icon,{mx:-1,as:Y.PiLineVerticalThin,boxSize:5,color:F}),f.jsx(He,{label:"Zoom Out",children:f.jsx(Oe,{"aria-label":"Zoom out",rememberAction:!1,icon:f.jsx(V.Icon,{as:Y.PiMinus,boxSize:5}),size:"sm",variant:"ghost",color:pe,onClick:()=>ge("decrease")})}),f.jsx(He,{label:"Zoom In",children:f.jsx(Oe,{"aria-label":"Zoom in",rememberAction:!1,icon:f.jsx(V.Icon,{as:Y.PiPlus,boxSize:5}),size:"sm",variant:"ghost",color:pe,onClick:()=>ge("increase")})}),f.jsx(He,{label:"Reset Zoom",children:f.jsx(Oe,{"aria-label":"Reset zoom",rememberAction:!1,icon:f.jsx(V.Icon,{as:Y.PiArrowCounterClockwise,boxSize:5}),size:"sm",variant:"ghost",color:pe,onClick:()=>ge("reset")})}),ye&&f.jsx(uw,{visibleActions:h?["Collision mode","Fill",...h.fill?["Grid adjustment"]:[]]:[],divider:f.jsx(V.Icon,{mx:-1,as:Y.PiLineVerticalThin,boxSize:5,color:F,role:"separator","aria-orientation":"vertical"})})]}),f.jsxs("span",{style:{display:ye?"none":"contents"},children:[f.jsxs("span",{style:{display:N.bottomBarNavigation===!1?"none":"contents"},children:[N.edgeHandles!==!1&&f.jsx(He,{label:R?"Draw Mode On (V)":"Draw Mode Off (V)",children:f.jsx(Oe,{"aria-label":"Toggle draw mode","aria-keyshortcuts":"V","aria-pressed":R,icon:f.jsx(V.Icon,{as:Y.PiPencilSimpleLine,boxSize:5}),size:"sm",variant:"ghost",color:R?t:oe,onClick:()=>P(!R)})}),f.jsx(V.Icon,{mx:-1,as:Y.PiLineVerticalThin,boxSize:5,color:F}),f.jsx(He,{label:b?"Zoom Mode (z)":"Pan Mode (z)",children:f.jsx(Oe,{"aria-label":"Toggle zoom mode",icon:f.jsx(V.Icon,{as:b?Y.PiMagnifyingGlassPlus:Y.PiArrowsOutCardinal,boxSize:5}),size:"sm",variant:"ghost",color:b?t:oe,onClick:()=>x(!b)})}),f.jsx(V.Icon,{mx:-1,as:Y.PiLineVerticalThin,boxSize:5,color:F}),f.jsx(He,{label:v?"Multi-Select On (m)":"Multi-Select Off (m)",children:f.jsx(Oe,{"aria-label":"Toggle multi-select",icon:f.jsx(V.Icon,{as:Y.PiSelectionPlus,boxSize:5}),size:"sm",variant:"ghost",color:v?t:oe,onClick:()=>w(!v)})}),f.jsx(V.Icon,{mx:-1,as:Y.PiLineVerticalThin,boxSize:5,color:F}),f.jsx(He,{label:C?"Drag Mode On (d)":"Drag Mode Off (d)",children:f.jsx(Oe,{"aria-label":"Toggle drag mode",icon:f.jsx(V.Icon,{as:Y.PiHandGrabbing,boxSize:5}),size:"sm",variant:"ghost",color:C?t:oe,onClick:()=>S(!C)})})]}),N.bottomBarNavigation===!1&&(e===void 0?f.jsx(to,{}):e?Jr.createPortal(f.jsx(to,{}),e):null),N.bottomBarExtra&&f.jsxs(f.Fragment,{children:[N.bottomBarNavigation!==!1&&f.jsx(V.Icon,{mx:-1,as:Y.PiLineVerticalThin,boxSize:5,color:F,role:"separator","aria-orientation":"vertical"}),N.bottomBarExtra]}),f.jsx(V.Icon,{mx:-1,as:Y.PiLineVerticalThin,boxSize:5,color:F,role:"separator","aria-orientation":"vertical"}),f.jsx(ib,{})]}),f.jsx("span",{style:{display:N.bottomBarNavigation===!1||ye&&!h?"none":"contents"},children:f.jsx(to,{})}),f.jsxs("span",{style:{display:ye?"none":"contents"},children:[f.jsx(V.Icon,{mx:-1,as:Y.PiLineVerticalThin,boxSize:5,color:F,role:"separator","aria-orientation":"vertical"}),f.jsx(ob,{}),l!=="properties"&&f.jsxs(f.Fragment,{children:[f.jsx(V.Icon,{mx:-1,as:Y.PiLineVerticalThin,boxSize:5,color:F}),f.jsx(He,{label:k?"Array Mode [ ]":"Set Mode { }",children:f.jsx(Oe,{"aria-label":"Toggle array mode",icon:f.jsx(V.Icon,{as:k?Y.PiBracketsSquare:Y.PiBracketsCurly,boxSize:5}),size:"sm",variant:"ghost",color:k?t:oe,onClick:()=>{var Ze;const Pe=!k;T(Pe),(Ze=_.onArrayModeChange)==null||Ze.call(_,Pe)}})})]}),f.jsx(zd,{}),!$&&f.jsxs("span",{style:{display:s?"contents":"none"},children:[f.jsx(V.Icon,{mx:-1,as:Y.PiLineVerticalThin,boxSize:5,color:F}),f.jsx(Lr,{label:"Graph theme",colors:ao,value:t,includeTransparent:!1,onPick:Pe=>{var Ze;n(Pe),(Ze=_.onThemeColorChange)==null||Ze.call(_,Pe)}})]}),!$&&f.jsxs(f.Fragment,{children:[f.jsx(V.Icon,{as:Y.PiLineVerticalThin,boxSize:5,color:F,role:"separator","aria-orientation":"vertical"}),f.jsx(Lr,{label:"Graph edge color",colors:ao,value:o||(ee?"gray.500":rn),onPick:i,onReset:()=>i("")}),f.jsx(V.Icon,{as:Y.PiLineVerticalThin,boxSize:5,color:F,role:"separator","aria-orientation":"vertical"})]}),f.jsx(ab,{})]}),f.jsx(V.Icon,{mx:-1,as:Y.PiLineVerticalThin,boxSize:5,color:F}),f.jsx(He,{label:ye?"Expand toolbar":"Collapse toolbar",children:f.jsx(Oe,{"aria-label":"Toggle toolbar collapse",rememberAction:!1,icon:f.jsx(V.Icon,{as:ye?Y.PiCaretRight:Y.PiCaretLeft,boxSize:5}),size:"sm",variant:"ghost",color:oe,onClick:()=>{var Pe;N.bottomBarCollapsed===void 0&&ie(!ye),a(ye),(Pe=_.onBottomBarCollapsedChange)==null||Pe.call(_,!ye)}})}),!ye&&f.jsx(Pb,{})]})]})}),!Te&&f.jsxs(V.Box,{position:"relative",ml:"auto",flexShrink:0,children:[f.jsx(V.Box,{"data-flow-direction-control":"",bg:ae,borderRadius:"30px",h:50,css:xr(G,D),px:3,cursor:"pointer",onClick:()=>Q(!ce),children:f.jsxs(V.Flex,{align:"center",h:"100%",children:[f.jsx(He,{label:"Flow Direction",children:f.jsx(Oe,{"aria-label":"Direction",onClick:Pe=>{Pe.stopPropagation(),Q(!ce)},icon:f.jsx(V.Icon,{as:Y.PiCaretUp,boxSize:5}),size:"sm",variant:"ghost",color:oe})}),f.jsx(V.Text,{fontSize:"xs",textTransform:"uppercase !important",color:ee?"whiteAlpha.600":"blackAlpha.500",ml:1,children:c.toUpperCase()})]})}),ce&&f.jsx(V.Box,{position:"absolute",bottom:"100%",right:0,pb:"24px",zIndex:200,children:f.jsxs(V.Box,{bg:ae,borderRadius:"30px",p:2,minW:"180px",css:xr(G,D),children:[qw.map(Pe=>f.jsxs(V.Flex,{align:"center",gap:3,px:3,py:2,css:io,cursor:"pointer",_hover:{bg:ee?"whiteAlpha.100":"blackAlpha.50"},onClick:()=>{var Ze;(Ze=_.onDirectionChange)==null||Ze.call(_,Pe.value),Q(!1)},children:[f.jsx(V.Icon,{as:Pe.icon,boxSize:5,color:pe}),f.jsx(V.Text,{fontSize:"sm",color:pe,flex:1,whiteSpace:"nowrap",children:Pe.label}),c===Pe.value&&f.jsx(V.Icon,{as:Y.PiCheck,boxSize:4,color:q})]},Pe.value)),f.jsxs(V.Flex,{align:"center",gap:3,px:3,py:2,css:io,cursor:"pointer",_hover:{bg:ee?"whiteAlpha.100":"blackAlpha.50"},onClick:()=>{var Pe;(Pe=_.onDirectionChange)==null||Pe.call(_,"C"),Q(!1)},children:[f.jsx(V.Icon,{as:Y.PiAlignCenterHorizontal,boxSize:5,color:pe}),f.jsx(V.Text,{fontSize:"sm",color:pe,flex:1,whiteSpace:"nowrap",children:"Center"}),c==="C"&&f.jsx(V.Icon,{as:Y.PiCheck,boxSize:4,color:q})]})]})})]})]})})]})};Ib.displayName="BottomBar";const Tb=j.memo(Ib);function Lw({checked:e,onChange:r,disabled:t,label:n="Connected nodes"}){return f.jsx(Yr,{hideLabel:!0,label:n,helper:`${n}: isolate node and its connections`,checked:e,onChange:r,disabled:t,icon:f.jsx(V.Icon,{as:Y.PiGraph,boxSize:5})})}const Wu={$bgColor:"bgColor",$textColor:"textColor",$borderColor:"borderColor"};function Ob(e,r){const t=new Map,n=(i,s)=>{if(Object.is(i,s))return!0;if(!i||!s||typeof i!="object"||typeof s!="object"||Array.isArray(i)!==Array.isArray(s))return!1;const a=Object.keys(i);return a.length===Object.keys(s).length&&a.every(c=>Object.prototype.hasOwnProperty.call(s,c)&&n(i[c],s[c]))},o=(i,s,a)=>{if(i===s)return!0;if(!i||!s||typeof i!="object"||typeof s!="object"||Array.isArray(i)!==Array.isArray(s))return!1;const c=new Set([...Object.keys(i),...Object.keys(s)]);for(const l of c)if(!n(i[l],s[l])){if(Object.prototype.hasOwnProperty.call(Wu,l)){if(typeof s[l]!="string"||!s[l])return!1;t.set(a,{...t.get(a),[Wu[l]]:s[l]})}else if(l.startsWith("$")&&l!=="$"||!o(i[l],s[l],l==="$"?a:`${a}.${l}`))return!1}return!0};if(o(e,r,"root"))return t}function Fw(e,r){return Ob(e,r)!==void 0}function zw(e,r,t){if(e===r)return t;const n=Ob(e,r);if(!n)return;const o=new Set(t.nodes.map(i=>i.data.id));for(const i of n.keys())if(!o.has(i)||!Le(r,i))return;return{edges:t.edges,nodes:t.nodes.map(i=>{const s=n.get(i.data.id),a=Le(e,i.data.id),c=Le(r,i.data.id);return!s&&a===c?i:{...i,data:{...i.data,...typeof i.data.code=="string"?{code:JSON.stringify(c,null,2)}:{},...s?{viewProps:{...i.data.viewProps,...s},config:{...i.data.config,...s}}:{}}}})}}function xd(e){return e.kind==="literal"?e.value:e.kind==="union"?xd(e.types[0]):e.kind==="array"?[]:e.kind==="object"?Object.fromEntries(Object.entries(e.properties).filter(([,r])=>!r.optional).map(([r,t])=>[r,xd(t.type)])):e.kind==="boolean"?!1:e.kind==="number"||e.kind==="integer"?0:e.kind==="null"?null:""}function Nb(e,r,t){var y,b,x;const n=(y=Le(e,r))==null?void 0:y.$form,o=n==null?void 0:n.$create;if(!o)return;const i=o.$address.split(".");if(i.shift()!=="root"||!i.length||i.some(v=>!/^[A-Za-z0-9_-]+$/.test(v)||["__proto__","constructor","prototype"].includes(v)))throw new Error("Invalid form creation address.");if(!t||!Object.prototype.hasOwnProperty.call(t,o.$type))throw new Error(`Load form type: ${o.$type}`);const s=i.pop(),a=["root",...i].join("."),c=on(e,a,t),l=(b=c==null?void 0:c.type.properties[s])==null?void 0:b.type;if((l==null?void 0:l.kind)!=="array"||l.items.kind!=="object")throw new Error("Form creation must target an object-array field.");const d=t[o.$type],u=o.$defaults??{};for(const[v,w]of Object.entries(u))if(!Object.prototype.hasOwnProperty.call(d.properties,v)||Ut(d.properties[v].type,w,!d.properties[v].optional))throw new Error(`Invalid creation default: ${v}`);const h={...xd(d),...structuredClone(u)};((x=d.properties.id)==null?void 0:x.type.kind)==="string"&&(h.id=kd());let p=e;const m=Le(e,o.$address);if(m===void 0)p=_t(e,a,v=>({...v,[s]:[]}));else if(!Array.isArray(m)&&!Array.isArray(m==null?void 0:m.$))throw new Error("Form creation destination is not an array.");const g=Id(p,o.$address,{...h,$label:o.$label??o.$type,...o.$icon?{$icon:o.$icon}:{},$form:{$type:o.$type,$create:o}});return{address:g.address,json:Td(g.json,r,{target:g.address,label:o.$edgeLabel})}}function $b(e,r,t){var i;if(r==="root"||!Le(e,r)||!Le(e,t))throw new Error("The source or Parent no longer exists.");const n=new Set;let o=t;for(;o;){if(o===r||o.startsWith(`${r}.`)||n.has(o))throw new Error("A node cannot be moved inside itself or its descendants.");n.add(o);const s=(i=Le(e,o))==null?void 0:i.$parent;o=typeof s=="string"?s:o.includes(".")?o.slice(0,o.lastIndexOf(".")):void 0}return Md(_t(e,r,s=>({...s,$parent:t})),t,!1)}function qb(e,r){const t=new Set(r.filter(a=>Le(e,a)!==void 0)),n=[],o=(a,c)=>{if(!(!a||typeof a!="object")){n.push([c,a]);for(const[l,d]of Object.entries(a))l.startsWith("$")||o(d,`${c}.${l}`)}};o(e,"root");const i=a=>[...t].some(c=>a===c||a.startsWith(`${c}.`));let s=!0;for(;s;){s=!1;for(const[a,c]of n)!i(a)&&typeof c.$parent=="string"&&i(c.$parent)&&(t.add(a),s=!0)}return[...t].filter(a=>![...t].some(c=>c!==a&&a.startsWith(`${c}.`)))}function Bd(e,r){const t=qb(e,r),n=new Map(t.map((a,c)=>[a,`root.node_${c+1}`])),o=a=>{const c=t.find(l=>a===l||a.startsWith(`${l}.`));return c?`${n.get(c)}${a.slice(c.length)}`:void 0},i=a=>{if(!(!a||typeof a!="object")){Array.isArray(a.$connections)&&(a.$connections=a.$connections.flatMap(c=>{const l=typeof c.target=="string"&&o(c.target);return l?[{...c,id:void 0,target:l}]:[]}));for(const c of["$parent","$target"])if(typeof a[c]=="string"){const l=o(a[c]);l?a[c]=l:delete a[c]}for(const[c,l]of Object.entries(a))c.startsWith("$")||i(l)}},s={$hideRoot:!0};return t.forEach((a,c)=>{const l=structuredClone(Le(e,a));i(l),s[`node_${c+1}`]=l}),s}function Lb(e,r){const t=Bd(e,r),n=Object.keys(t).filter(a=>!a.startsWith("$")),o=new Map(n.map(a=>[a,`copy_${crypto.randomUUID()}`])),i=a=>{if(!a||typeof a!="object")return;const c=l=>{const d=l.split(".");return d[0]==="root"&&o.has(d[1])&&(d[1]=o.get(d[1])),d.join(".")};for(const l of a.$connections??[])l.target=c(l.target),l.id=crypto.randomUUID();for(const l of["$parent","$target"])typeof a[l]=="string"&&(a[l]=c(a[l]));for(const[l,d]of Object.entries(a))l.startsWith("$")||i(d)},s=Object.fromEntries(n.map(a=>{const c=t[a];return i(c),[o.get(a),c]}));return{json:_t(e,"root",a=>({...a,...s})),ids:[...o.values()].map(a=>`root.${a}`)}}function Bw(e,r){const t=o=>e&&typeof e=="object"&&o in e;let n=1;for(;t(`${r}_${n}`);)n++;return`${r}_${n}`}function Fb(e,r,t,n,o){const i=(a,c)=>{a!==e&&(e=a,n==null||n(a,c))},s=a=>{var l;const c=(l=r.find(d=>d.data.id===a))==null?void 0:l.data;return c&&{source:c.source,target:c.target,isInverted:c.isInverted,sourceProperty:c.sourceProperty,targetProperty:c.targetProperty,connection:c.connection}};return{...t,onNodeParentChange:(a,c)=>{var d;const l=$b(e,a,c);(d=t.onNodeParentChange)==null||d.call(t,a,c),i(l,{type:"nodeStyle",address:a,key:"$parent",value:c})},onNodesCopy:async a=>{var c;await((c=t.onNodesCopy)==null?void 0:c.call(t,a))!==!0&&await navigator.clipboard.writeText(JSON.stringify(Bd(e,a),null,2))},onNodesDuplicate:a=>{var l;if(((l=t.onNodesDuplicate)==null?void 0:l.call(t,a))===!0)return;const c=Lb(e,a);i(c.json,{type:"nodeCreate",address:c.ids[0]})},onFormChange:a=>{const c=Le(e,a.nodeAddress);if(!c||a.nodeId!==void 0&&c.id!==a.nodeId)throw new Error("This form node has moved. Retry the edit.");i(xo(e,a,t.onFormChange),{type:"form",address:a.address,value:a.value})},onNodeLabelChange:(a,c)=>{var l;(l=t.onNodeLabelChange)==null||l.call(t,a,c),i(xt(e,a,"$label",c),{type:"nodeLabel",address:a,key:"$label",value:c})},onNodeSubtitleChange:(a,c)=>{var l;(l=t.onNodeSubtitleChange)==null||l.call(t,a,c),i(xt(e,a,"$subtitle",c),{type:"nodeStyle",address:a,key:"$subtitle",value:c})},onNodeContentChange:(a,c)=>{var l;(l=t.onNodeContentChange)==null||l.call(t,a,c),i(xt(e,a,"$content",c),{type:"nodeContent",address:a,key:"$content",value:c})},onNodeTypeViewChange:(a,c)=>{var l;c!==void 0&&!Ed.includes(c)||((l=t.onNodeTypeViewChange)==null||l.call(t,a,c),i(xt(e,a,"$view",c),{type:"nodeStyle",address:a,key:"$view",value:c}))},onNodeColorChange:(a,c,l)=>{var u;(u=t.onNodeColorChange)==null||u.call(t,a,c,l);const d=c==="bg"?"$bgColor":"$textColor";i(xt(e,a,d,l),{type:"nodeColor",address:a,key:d,value:l})},onNodeBorderColorChange:(a,c)=>{var l;(l=t.onNodeBorderColorChange)==null||l.call(t,a,c),i(xt(e,a,"$borderColor",c),{type:"nodeColor",address:a,key:"$borderColor",value:c})},onNodeBorderStyleChange:(a,c)=>{var l;(l=t.onNodeBorderStyleChange)==null||l.call(t,a,c),i(xt(e,a,"$borderStyle",c),{type:"nodeStyle",address:a,key:"$borderStyle",value:c})},onNodeBorderWidthChange:(a,c)=>{var l;c!==void 0&&(!Number.isFinite(c)||c<0)||((l=t.onNodeBorderWidthChange)==null||l.call(t,a,c),i(xt(e,a,"$borderWidth",c),{type:"nodeStyle",address:a,key:"$borderWidth",value:c}))},onNodeBorderRadiusChange:(a,c)=>{var l;c!==void 0&&(!Number.isFinite(c)||c<0)||((l=t.onNodeBorderRadiusChange)==null||l.call(t,a,c),i(xt(e,a,"$borderRadius",c),{type:"nodeStyle",address:a,key:"$borderRadius",value:c}))},onNodeDimensionChange:(a,c,l)=>{var u;if(c!=="width"&&c!=="height"||l!==void 0&&(!Number.isFinite(l)||l<=0))return;(u=t.onNodeDimensionChange)==null||u.call(t,a,c,l);const d=c==="width"?"$width":"$height";i(xt(e,a,d,l),{type:"nodeStyle",address:a,key:d,value:l})},onNodeIconChange:(a,c)=>{var l;(l=t.onNodeIconChange)==null||l.call(t,a,c),i(xt(e,a,"$icon",c),{type:"nodeIcon",address:a,key:"$icon",value:c})},onNodeOutlineChange:(a,c)=>{var l;(l=t.onNodeOutlineChange)==null||l.call(t,a,c),i(xt(e,a,"$outline",c),{type:"nodeOutline",address:a,key:"$outline",value:c})},onNodeAnimationChange:(a,c)=>{var l;(l=t.onNodeAnimationChange)==null||l.call(t,a,c),i(xt(e,a,"$isNodeAnimated",c),{type:"nodeAnimation",address:a,key:"$isNodeAnimated",value:c})},onNodeAnimationVariantChange:(a,c)=>{var l;c!=="traveling"&&c!=="pulse"||((l=t.onNodeAnimationVariantChange)==null||l.call(t,a,c),i(xt(e,a,"$nodeAnimationVariant",c),{type:"nodeAnimation",address:a,key:"$nodeAnimationVariant",value:c}))},onNodeCollapse:(a,c)=>{var l;(l=t.onNodeCollapse)==null||l.call(t,a,c),i(Md(e,a,c),{type:"nodeCollapse",address:a,key:"$collapsed",value:c})},onNodeCreate:a=>{var p,m;if(((p=t.onNodeCreate)==null?void 0:p.call(t,a))===!0)return;const c=a.sourceNodeId||"root",l=!!a.sourceNodeId&&a.isArrayMode&&!((m=Le(e,c))!=null&&m.$arrayDrawInitialized);let d=e,u,h=a.isArrayMode?"array":"set";for(let g=0;g<(l?2:1);g++){const y=a.sourceNodeId&&Nb(d,a.sourceNodeId,o);if(y)d=y.json,u??(u=y.address),h="form";else{const b=Bw(Le(d,c),a.isArrayMode?"list":"node"),x=a.isArrayMode?{$bgColor:"gray.500",$:[]}:{$bgColor:"gray.500"},v=Id(d,c,x,b);d=v.json,u??(u=v.address)}}l&&(d=_t(d,c,g=>Array.isArray(g)?{$:g,$arrayDrawInitialized:!0}:{...g,$arrayDrawInitialized:!0})),i(d,{type:"nodeCreate",address:u,value:h})},onNodeDelete:(a,c)=>{var l;(l=t.onNodeDelete)==null||l.call(t,a,c),i(hb(e,a),{type:"nodeDelete",address:a})},onEdgeCreate:(a,c,l)=>{var u;(u=t.onEdgeCreate)==null||u.call(t,a,c,l);const d=l&&(l.sourceProperty!==void 0||l.targetProperty!==void 0)?{...l,target:c}:void 0;i(d?Td(e,a,d):pb(e,a,c),{type:"edgeCreate",address:a,key:d?"$connections":"$target",value:d??c})},onEdgeLabelChange:(a,c)=>{var d;(d=t.onEdgeLabelChange)==null||d.call(t,a,c);const l=s(a);l&&i(gr(e,l,"$sourceLabel",c),{type:"edgeLabel",edge:l,key:l.connection?"$connections":"$sourceLabel",value:c})},onEdgeStyleChange:(a,c)=>{var d;(d=t.onEdgeStyleChange)==null||d.call(t,a,c);const l=s(a);l&&i(fb(e,l,c),{type:"edgeStyle",edge:l,value:c})},onEdgeAnimationVariantChange:(a,c)=>{var d;if(c!=="dashed"&&c!=="traveling")return;(d=t.onEdgeAnimationVariantChange)==null||d.call(t,a,c);const l=s(a);l&&i(gr(e,l,"$edgeAnimationVariant",c),{type:"edgeStyle",edge:l,key:l.connection?"$connections":"$edgeAnimationVariant",value:c})},onEdgeTypeChange:(a,c)=>{var d;(d=t.onEdgeTypeChange)==null||d.call(t,a,c);const l=s(a);l&&i(gr(e,l,"$edgeType",c),{type:"edgeStyle",edge:l,key:l.connection?"$connections":"$edgeType",value:c})},onEdgeIconChange:(a,c)=>{var d;(d=t.onEdgeIconChange)==null||d.call(t,a,c);const l=s(a);l&&i(gr(e,l,"$edgeIcon",c||void 0),{type:"edgeStyle",edge:l,key:l.connection?"$connections":"$edgeIcon",value:c})},onEdgeColorChange:(a,c)=>{var d;(d=t.onEdgeColorChange)==null||d.call(t,a,c);const l=s(a);l&&i(gr(e,l,"$edgeColor",c),{type:"edgeColor",edge:l,key:l.connection?"$connections":"$edgeColor",value:c})},onEdgeDelete:(a,c)=>{var u;(u=t.onEdgeDelete)==null||u.call(t,a,c);const l=s(a);if(!l)return;const d=gb(e,l);d.removed&&i(d.json,{type:"edgeDelete",edge:l,key:l.connection?"$connections":"$target"})}}}const Dw=".flow-sdk-edge-reveal{animation:flow-sdk-edge-reveal var(--flow-edge-reveal-duration,600ms) linear both;animation-play-state:var(--flow-edge-reveal-state,running)}.flow-sdk-edge-reveal-end{animation:flow-sdk-edge-reveal-end var(--flow-edge-reveal-duration,600ms) steps(1,end) both;animation-play-state:var(--flow-edge-reveal-state,running)}@keyframes flow-sdk-edge-reveal{from{stroke-dashoffset:var(--flow-edge-reveal-from,100)}to{stroke-dashoffset:0}}@keyframes flow-sdk-edge-reveal-end{from{opacity:0}to{opacity:1}}@media(prefers-reduced-motion:reduce){.flow-sdk-edge-reveal{animation:none;stroke-dashoffset:0}.flow-sdk-edge-reveal-end{animation:none;opacity:1}}";function Vw({path:e,width:r,reversed:t,children:n,onComplete:o}){const i=`flow-edge-reveal-${j.useId().replace(/:/g,"")}`,s=j.useRef(null),[a,c]=j.useState({x:0,y:0,width:1,height:1});return j.useEffect(()=>{const l=matchMedia("(prefers-reduced-motion: reduce)"),d=()=>{l.matches&&(o==null||o())};return d(),l.addEventListener("change",d),()=>l.removeEventListener("change",d)},[o]),j.useLayoutEffect(()=>{var d;const l=(d=s.current)==null?void 0:d.getBBox();l&&c({x:l.x-r,y:l.y-r,width:l.width+r*2,height:l.height+r*2})},[e,r]),f.jsxs(f.Fragment,{children:[f.jsx("defs",{children:f.jsx("mask",{id:i,maskUnits:"userSpaceOnUse",...a,children:f.jsx("path",{ref:s,className:"flow-sdk-edge-reveal",onAnimationEnd:l=>{l.animationName==="flow-sdk-edge-reveal"&&(o==null||o())},"data-reveal-direction":t?"reverse":"forward",style:{"--flow-edge-reveal-from":t?-100:100},d:e,fill:"none",stroke:"white",strokeWidth:r,strokeLinecap:"butt",strokeLinejoin:"round",pathLength:100,strokeDasharray:"100 100"})})}),f.jsx("g",{mask:`url(#${i})`,children:n})]})}const Ww=".flow-sdk-edge-trace{pointer-events:none;animation:flow-sdk-edge-trace 2.4s linear infinite}.flow-sdk-edge-trace-reverse{animation-direction:reverse}@keyframes flow-sdk-edge-trace{from{stroke-dashoffset:18}to{stroke-dashoffset:-100}}@media(prefers-reduced-motion:reduce){.flow-sdk-edge-trace,.flow-sdk-edge-anim{animation:none}}";function Gw({path:e,color:r,width:t,reversed:n}){return f.jsx("path",{className:`flow-sdk-edge-trace${n?" flow-sdk-edge-trace-reverse":""}`,"data-animation-variant":"traveling","aria-hidden":"true",pointerEvents:"none",d:e,fill:"none",stroke:r,strokeWidth:t,strokeLinecap:"round",pathLength:100,strokeDasharray:"18 100"})}const zb=".flow-sdk-node-animation{position:absolute;inset:0;width:100%;height:100%;overflow:visible;pointer-events:none;z-index:1}.flow-sdk-node-border-animation{pointer-events:none;animation:flow-sdk-node-border 2.4s linear infinite}.flow-sdk-node-border-pulse{stroke-width:var(--flow-pulse-rest-width);animation:flow-sdk-node-pulse 1.8s ease-in-out infinite}@keyframes flow-sdk-node-border{from{stroke-dashoffset:0}to{stroke-dashoffset:-100}}@keyframes flow-sdk-node-pulse{0%,100%{stroke-width:var(--flow-pulse-rest-width)}50%{stroke-width:var(--flow-pulse-expanded-width)}}@media(prefers-reduced-motion:reduce){.flow-sdk-node-border-animation{animation:none}}";function so({x:e=0,y:r=0,width:t,height:n,radius:o,color:i,strokeWidth:s=8,path:a,variant:c="traveling"}){const l=j.useId(),d=`flow-sdk-node-border-animation${c==="pulse"?" flow-sdk-node-border-pulse":""}`;if(c==="pulse"){const u=a?"path":"rect",h=a?{d:a}:{x:e,y:r,width:Math.max(0,t),height:Math.max(0,n),rx:Math.max(0,Math.min(o,t/2,n/2))},p=s+36,m={x:e-p,y:r-p,width:t+2*p,height:n+2*p};return f.jsxs("g",{"aria-hidden":"true",pointerEvents:"none",children:[f.jsx("defs",{children:f.jsxs("mask",{id:l,maskUnits:"userSpaceOnUse",...m,style:{maskType:"luminance"},children:[f.jsx("rect",{...m,fill:"white"}),f.jsx(u,{...h,fill:"black",stroke:"black",strokeWidth:s,strokeLinejoin:"round"})]})}),f.jsx(u,{...h,className:d,"data-animation-variant":c,fill:"none",stroke:`color-mix(in srgb, ${i} 30%, transparent)`,strokeLinejoin:"round",mask:`url(#${l})`,style:{"--flow-pulse-rest-width":`${s+16}px`,"--flow-pulse-expanded-width":`${s+36}px`}})]})}return a?f.jsx("path",{className:d,"data-animation-variant":c,"aria-hidden":"true",pointerEvents:"none",d:a,fill:"none",stroke:i,strokeWidth:s,strokeLinecap:"round",pathLength:100,strokeDasharray:"18 82"}):f.jsx("rect",{className:d,"data-animation-variant":c,"aria-hidden":"true",pointerEvents:"none",x:e,y:r,width:Math.max(0,t),height:Math.max(0,n),rx:Math.max(0,Math.min(o,t/2,n/2)),fill:"none",stroke:i,strokeWidth:s,strokeLinecap:"round",pathLength:100,strokeDasharray:"18 82"})}const Uw=e=>{const n=1/(Math.cbrt(e)*.8);let o=Math.round(650*n),i=Math.round(350*n);return o=Math.max(40,Math.min(450,o)),i=Math.max(30,Math.min(300,i)),{edgeSep:o,rankSep:i}};function Bb(e,r=!1){return e&&!r&&typeof requestAnimationFrame<"u"&&!(typeof matchMedia<"u"&&matchMedia("(prefers-reduced-motion: reduce)").matches)}function Db(e,r,t=()=>{},n=300){let o,i,s=!1;const a=()=>{s=!0,o!==void 0&&cancelAnimationFrame(o),clearTimeout(i)},c=()=>{s||(a(),r(1),t())};if(!Bb(e))return c(),a;const l=performance.now(),d=u=>{if(s)return;const h=Math.max(0,Math.min(1,(u-l)/n));if(h>=1)return c();r(h<.5?4*h**3:1-(-2*h+2)**3/2),s||(o=requestAnimationFrame(d))};return o=requestAnimationFrame(d),i=setTimeout(c,n+100),a}function Gu(e,r,t){const n=new Set([e]),o=[e];for(;o.length;){const i=o.pop();for(const s of r)(s.parent===i||s.id.startsWith(`${i}.`)||t.some(c=>(c.inverted?c.target:c.source)===i&&(c.inverted?c.source:c.target)===s.id))&&!n.has(s.id)&&(n.add(s.id),o.push(s.id))}return n}function Hw(e,r,t){const n=t==="downward"||t==="upward",o=new Map;for(const s of e){if(s.source===s.target||s.sourceProperty||s.targetProperty)continue;const a=r(s.source),c=r(s.target);if(!a||!c)continue;const l=n?c.y-a.y:c.x-a.x,d=Math.abs(l)-(n?a.h+c.h:a.w+c.w)/2;if(d<=320)continue;const u=JSON.stringify([s.source,Math.sign(l)]),h=o.get(u)??[];h.push({edge:s,gap:d,cross:n?c.x-a.x:c.y-a.y}),o.set(u,h)}const i=new Map;for(const s of o.values()){if(new Set(s.map(({edge:c})=>c.target)).size<2)continue;const a=new Map;for(const{edge:c}of s)a.set(c.target,(a.get(c.target)??0)+1);for(const c of[-1,0,1]){const l=s.filter(({cross:u})=>Math.sign(u)===c);l.sort((u,h)=>Math.abs(h.cross)-Math.abs(u.cross)||u.edge.id.localeCompare(h.edge.id));const d=Math.min(...l.map(({gap:u})=>u));l.forEach(({edge:u,gap:h,cross:p},m)=>{const g=l.length===1?d/2:120+(d-280)*m/(l.length-1),y=l.find(b=>Math.abs(b.cross)<Math.abs(p));i.set(u.id,{turn:g/h,labelAtTarget:a.get(u.target)===1,labelFraction:p?(p+((y==null?void 0:y.cross)??0))/(2*p):.5})})}}return i}const tr=e=>({x1:e.x-e.w/2,y1:e.y-e.h/2,x2:e.x+e.w/2,y2:e.y+e.h/2}),Kw=e=>({x:(e.x1+e.x2)/2,y:(e.y1+e.y2)/2,w:e.x2-e.x1,h:e.y2-e.y1});function Ho(e){if(!e.length)return null;const r={...e[0]};for(let t=1;t<e.length;t++)r.x1=Math.min(r.x1,e[t].x1),r.y1=Math.min(r.y1,e[t].y1),r.x2=Math.max(r.x2,e[t].x2),r.y2=Math.max(r.y2,e[t].y2);return r}const Jw=(e,r)=>e.x1<=r.x2&&e.x2>=r.x1&&e.y1<=r.y2&&e.y2>=r.y1,Uu=(e,r)=>e.x>=r.x1&&e.x<=r.x2&&e.y>=r.y1&&e.y<=r.y2,Lt=e=>(Math.round(e*10)/10).toString(),yt=e=>`${Lt(e.x)} ${Lt(e.y)}`,Zw=e=>e>0?1:e<0?-1:0,Hu=(e,r)=>e>0?Math.max(e-r,0):Math.min(e+r,0);function Xw(e,r,t,n,o=10){const i=r.x-e.x,s=r.y-e.y,a=Hu(i,(e.w+r.w)/2),c=Hu(s,(e.h+r.h)/2),l=t==="downward"||t==="upward",d=l?c:a,u=l?s:i,h=Zw(u),p=n*d,m=x=>Math.abs(x)<o||Math.abs(x)>=Math.abs(d),g=m(p)||m(Math.abs(d)-Math.abs(p));let y;if(g)if(l)if(Math.abs(u)<=e.h/2){const x=(e.x+r.x)/2;y=[x,e.y,x,r.y]}else if(Math.abs(i)<=r.w/2){const x=(e.y+r.y)/2;y=[e.x,x,r.x,x]}else y=[e.x,r.y];else if(Math.abs(u)<=e.w/2){const x=(e.y+r.y)/2;y=[e.x,x,r.x,x]}else if(Math.abs(s)<=r.h/2){const x=(e.x+r.x)/2;y=[x,e.y,x,r.y]}else y=[r.x,e.y];else if(l){const x=e.y+p+e.h/2*h;y=[e.x,x,r.x,x]}else{const x=e.x+p+e.w/2*h;y=[x,e.y,x,r.y]}const b=[{x:e.x,y:e.y}];for(let x=0;x<y.length;x+=2)b.push({x:y[x],y:y[x+1]});return b.push({x:r.x,y:r.y}),b}function Yw(e,r,t){const n=r.x-e.x,o=r.y-e.y,i=n>0?(t.x2-e.x)/n:n<0?(t.x1-e.x)/n:1/0,s=o>0?(t.y2-e.y)/o:o<0?(t.y1-e.y)/o:1/0,a=Math.min(i,s);return!Number.isFinite(a)||a>=1||a<0?null:{x:e.x+n*a,y:e.y+o*a}}function en(e,r,t){var s;if(!((s=t.outline)!=null&&s.length))return Yw(e,r,tr(t));const n=r.x-e.x,o=r.y-e.y;let i=1/0;return t.outline.forEach((a,c,l)=>{const d=l[(c+1)%l.length],u=d.x-a.x,h=d.y-a.y,p=n*h-o*u;if(Math.abs(p)<1e-9)return;const m=a.x-e.x,g=a.y-e.y,y=(m*h-g*u)/p,b=(m*o-g*n)/p;y>=0&&y<1&&b>=-1e-9&&b<=1+1e-9&&(i=Math.min(i,y))}),Number.isFinite(i)?{x:e.x+n*i,y:e.y+o*i}:null}function Vb(e,r,t=.5){const n=Number.isFinite(t)?Math.max(0,Math.min(1,t)):.5,o=r==="top"||r==="bottom",i=r==="top"||r==="left"?-1:1,s={x:o?e.x-e.w/2+e.w*n:e.x,y:o?e.y:e.y-e.h/2+e.h*n},a=Math.max(e.w,e.h)*2+1;return{...en(s,{x:s.x+(o?0:i*a),y:s.y+(o?i*a:0)},e)??{x:o?s.x:e.x+i*e.w/2,y:o?e.y+i*e.h/2:s.y},side:r}}function Ur(e,r){return{x:e.x+(e.side==="right"?r:e.side==="left"?-r:0),y:e.y+(e.side==="bottom"?r:e.side==="top"?-r:0)}}function Qw(e,r,t,n){const o=Ur(e,t.srcDist),i=Ur(r,t.tgtDist);if(n==="straight")return Gb(o,i,t);const s=Math.max(80,Math.min(300,Math.hypot(i.x-o.x,i.y-o.y)/3)),a=e.side==="bottom"&&r.side==="top"?i.y-o.y:e.side==="top"&&r.side==="bottom"?o.y-i.y:e.side==="right"&&r.side==="left"?i.x-o.x:e.side==="left"&&r.side==="right"?o.x-i.x:void 0,c=a!==void 0&&a>0?Math.min(s,a/2):s,l=Ur({...o,side:e.side},c),d=Ur({...i,side:r.side},c),u=t.arrowAt==="source"?vt(o,l,t.arrowGap):o,h=t.arrowAt==="target"?vt(i,d,t.arrowGap):i,p=t.arrowAt==="source"?zt(o,l,t.arrowSize,t.headShape):t.arrowAt==="target"?zt(i,d,t.arrowSize,t.headShape):void 0;if(n==="bezier")return{d:`M${yt(u)} C${yt(l)} ${yt(d)} ${yt(h)}`,arrow:p,label:{x:(u.x+3*l.x+3*d.x+h.x)/8,y:(u.y+3*l.y+3*d.y+h.y)/8,angle:0}};const m=e.side==="left"||e.side==="right",g=r.side==="left"||r.side==="right";let y;if(m!==g){const x=m?{x:d.x,y:l.y}:{x:l.x,y:d.y},v=(x.x-l.x)*(l.x-o.x)+(x.y-l.y)*(l.y-o.y)>=0,w=(x.x-d.x)*(d.x-i.x)+(x.y-d.y)*(d.y-i.y)>=0;y=[v&&w?x:m?{x:l.x,y:d.y}:{x:d.x,y:l.y}]}else if(a!==void 0&&a<=0)if(m){const x=(l.y+d.y)/2;y=[{x:l.x,y:x},{x:d.x,y:x}]}else{const x=(l.x+d.x)/2;y=[{x,y:l.y},{x,y:d.y}]}else if(m){const x=e.side===r.side?e.side==="right"?Math.max(l.x,d.x):Math.min(l.x,d.x):(l.x+d.x)/2;y=[{x,y:l.y},{x,y:d.y}]}else{const x=e.side===r.side?e.side==="bottom"?Math.max(l.y,d.y):Math.min(l.y,d.y):(l.y+d.y)/2;y=[{x:l.x,y:x},{x:d.x,y:x}]}const b=[l,...y,d].filter((x,v,w)=>v===0||x.x!==w[v-1].x||x.y!==w[v-1].y);return wo(u,b,h,p,n==="orthogonal"?0:t.radius)}function vt(e,r,t){const n=e.x-r.x,o=e.y-r.y,i=Math.hypot(n,o);if(!i)return e;let s=(i-t)/i;return s<0&&(s=1e-5),{x:r.x+s*n,y:r.y+s*o}}function zt(e,r,t,n="triangle"){const o=e.x-r.x,i=e.y-r.y,s=Math.hypot(o,i)||1,a=o/s,c=i/s,l=(n==="square"?.15:.3)*t,d=.15*t,u=e.x-a*l,h=e.y-c*l;if(n==="square")return`M${yt(e)} L${Lt(e.x-c*d)} ${Lt(e.y+a*d)} L${Lt(u-c*d)} ${Lt(h+a*d)} L${Lt(u+c*d)} ${Lt(h-a*d)} L${Lt(e.x+c*d)} ${Lt(e.y-a*d)} Z`;const p=[e,{x:u-c*d,y:h+a*d},{x:u+c*d,y:h-a*d}];return p.map((g,y)=>{const b=p[(y+2)%3],x=p[(y+1)%3],v=Math.hypot(b.x-g.x,b.y-g.y),w=Math.hypot(x.x-g.x,x.y-g.y),C={x:(b.x-g.x)/v,y:(b.y-g.y)/v},S={x:(x.x-g.x)/w,y:(x.y-g.y)/w},R=Math.max(-1,Math.min(1,C.x*S.x+C.y*S.y)),P=Math.sqrt((1-R)/(1+R)),k=Math.min(1/P,v/2,w/2);return{start:{x:g.x+C.x*k,y:g.y+C.y*k},end:{x:g.x+S.x*k,y:g.y+S.y*k},radius:k*P}}).map((g,y)=>`${y?"L":"M"}${yt(g.start)} A${Lt(g.radius)} ${Lt(g.radius)} 0 0 1 ${yt(g.end)}`).join(" ")+" Z"}function pr(e,r){let t=Math.atan(r/e);return e===0&&t<0&&(t=-t),Number.isFinite(t)||(t=0),t*180/Math.PI}function e1(e,r,t,n){const o={x:r.x-e.x,y:r.y-e.y},i={x:t.x-r.x,y:t.y-r.y},s=Math.hypot(o.x,o.y),a=Math.hypot(i.x,i.y),c=o.x*i.y-o.y*i.x;if(s<1e-6||a<1e-6||Math.abs(c)<1e-6)return{p1:r,b:r,p2:r,r:0};const l=Math.min(n,s/2,a/2);return{p1:{x:r.x-o.x/s*l,y:r.y-o.y/s*l},b:r,p2:{x:r.x+i.x/a*l,y:r.y+i.y/a*l},r:l}}function Wb(e,r,t,n){let o=-1,i=null;for(let m=0;m<e.length-1;m++){const g=en(e[m],e[m+1],r);if(g){o=m,i=g;break}}let s=-1,a=null;for(let m=e.length-1;m>0;m--){const g=en(e[m],e[m-1],t);if(g){s=m,a=g;break}}if(!i||!a||o>=s)return null;const c=e.slice(o+1,s),l=c[0]??a,d=c[c.length-1]??i;let u,h,p;if(n.arrowAt==="source"){const m=vt(i,l,n.srcDist);u=vt(i,l,n.srcDist+n.arrowGap),p=zt(m,l,n.arrowSize,n.headShape)}else u=vt(i,l,n.srcDist);if(n.arrowAt==="target"){const m=vt(a,d,n.tgtDist);h=vt(a,d,n.tgtDist+n.arrowGap),p=zt(m,d,n.arrowSize,n.headShape)}else h=vt(a,d,n.tgtDist);return wo(u,c,h,p,n.radius,n.labelTargetLength,n.labelFraction)}function wo(e,r,t,n,o,i,s){var h;const a=[e,...r,t],c=[];let l=`M${yt(e)}`;for(let p=1;p<a.length-1;p++){const m=e1(a[p-1],a[p],a[p+1],o);c.push(m),m.r===0?l+=` L${yt(m.b)}`:l+=` L${yt(m.p1)} Q${yt(m.b)} ${yt(m.p2)}`}l+=` L${yt(t)}`;let d;const u=r.length;if(u===0)d={x:(e.x+t.x)/2,y:(e.y+t.y)/2,angle:pr(t.x-e.x,t.y-e.y)};else if(u%2===0){const p=r[u/2-1],m=r[u/2];d={x:(p.x+m.x)/2,y:(p.y+m.y)/2,angle:pr(m.x-p.x,m.y-p.y)}}else{const p=c[(u-1)/2];if(p.r===0){const m=a[(u-1)/2+2];d={x:p.b.x,y:p.b.y,angle:pr(m.x-p.b.x,m.y-p.b.y)}}else d={x:.25*p.p1.x+.5*p.b.x+.25*p.p2.x,y:.25*p.p1.y+.5*p.b.y+.25*p.p2.y,angle:pr(p.p2.x-p.p1.x,p.p2.y-p.p1.y)}}if(i!==void 0){if(s!==void 0&&c.length===2){const y=c[0].p2,b=c[1].p1,x=Math.hypot(b.x-y.x,b.y-y.y),v=Math.min(.5,i/(2*x)),w=Math.max(v,Math.min(1-v,s));d={x:y.x+(b.x-y.x)*w,y:y.y+(b.y-y.y)*w,angle:pr(b.x-y.x,b.y-y.y)}}const p=((h=c[c.length-1])==null?void 0:h.p2)??e,m=t.x-p.x,g=t.y-p.y;Math.hypot(m,g)>=i&&(d={x:(p.x+t.x)/2,y:(p.y+t.y)/2,angle:pr(m,g)})}return{d:l,arrow:n,label:d}}function Ku(e,r,t,n,o,i,s){const a=t==="leftward"?-1:1,c={x:e.x+a*(e.w/2+s.srcDist),y:n??e.y},l={x:r.x-a*(r.w/2+s.tgtDist),y:o??r.y},d=Math.max(80,s.arrowGap+s.arrowSize*.3),u=c.x+a*d,h=l.x-a*d;let p;if(a*(h-u)>=0){const b=c.x+(l.x-c.x)*i,x=Math.max(Math.min(u,h),Math.min(Math.max(u,h),b));p=[{x,y:c.y},{x,y:l.y}]}else{const b=Math.min(e.y-e.h/2,r.y-r.h/2)-d*(1+i);p=[{x:u,y:c.y},{x:u,y:b},{x:h,y:b},{x:h,y:l.y}]}const m=s.arrowAt==="source"?vt(c,p[0],s.arrowGap):c,g=s.arrowAt==="target"?vt(l,p[p.length-1],s.arrowGap):l,y=s.arrowAt==="source"?zt(c,p[0],s.arrowSize,s.headShape):s.arrowAt==="target"?zt(l,p[p.length-1],s.arrowSize,s.headShape):void 0;return wo(m,p,g,y,s.radius)}function Ju(e,r,t,n,o){return Wb(Xw(e,r,t,n),e,r,o)}function Zu(e,r,t,n,o,i){const s=n===void 0&&o===void 0&&(t==="downward"||t==="upward"),a=t==="leftward"||s&&t==="upward"?-1:1,c=(l,d,u)=>{const h={x:l.x,y:d??l.y},p=Math.max(l.w,l.h)*2+1,m=en(h,{x:h.x+(s?0:u*p),y:h.y+(s?u*p:0)},l);return m?{x:m.x+(s?0:u*i),y:m.y+(s?u*i:0)}:s?{x:l.x,y:l.y+u*(l.h/2+i)}:{x:l.x+u*(l.w/2+i),y:d??l.y}};return{sourcePoint:c(e,n,a),targetPoint:c(r,o,-a)}}function t1(e,r,t,n){const o=t==="downward"||t==="upward",i=t==="leftward"||t==="upward"?-1:1,s=Math.max(100,Math.abs(o?r.y-e.y:r.x-e.x)/2),a={x:e.x+(o?0:i*s),y:e.y+(o?i*s:0)},c={x:r.x-(o?0:i*s),y:r.y-(o?i*s:0)},l=n.arrowAt==="source"?vt(e,a,n.arrowGap):e,d=n.arrowAt==="target"?vt(r,c,n.arrowGap):r;return{d:`M${yt(l)} C${yt(a)} ${yt(c)} ${yt(d)}`,arrow:n.arrowAt==="source"?zt(e,a,n.arrowSize,n.headShape):n.arrowAt==="target"?zt(r,c,n.arrowSize,n.headShape):void 0,label:{x:(l.x+3*a.x+3*c.x+d.x)/8,y:(l.y+3*a.y+3*c.y+d.y)/8,angle:pr(d.x+c.x-a.x-l.x,d.y+c.y-a.y-l.y)}}}function Gb(e,r,t){const n=t.arrowAt==="source"?vt(e,r,t.arrowGap):e,o=t.arrowAt==="target"?vt(r,e,t.arrowGap):r,i=t.arrowAt==="source"?zt(e,r,t.arrowSize,t.headShape):t.arrowAt==="target"?zt(r,e,t.arrowSize,t.headShape):void 0;return wo(n,[],o,i,0)}function r1(e,r,t,n=-90,o=-60,i=350){const s=n*Math.PI/180,a=o*Math.PI/180,c=s-Math.PI/2,l=c-a/2,d=c+a/2,u=1.4*i*(r/3+1),h={x:e.x+Math.cos(l)*u,y:e.y+Math.sin(l)*u},p={x:e.x+Math.cos(d)*u,y:e.y+Math.sin(d)*u},m={x:e.x,y:e.y},g=en(m,h,e),y=en(m,p,e);if(!g||!y)return null;const b={x:(h.x+p.x)/2,y:(h.y+p.y)/2};let x=vt(g,h,t.srcDist),v=vt(y,p,t.tgtDist),w;if(t.arrowAt==="target"){const S=v;v=vt(y,p,t.tgtDist+t.arrowGap),w=zt(S,p,t.arrowSize,t.headShape)}else if(t.arrowAt==="source"){const S=x;x=vt(g,h,t.srcDist+t.arrowGap),w=zt(S,h,t.arrowSize,t.headShape)}return{d:`M${yt(x)} Q${yt(h)} ${yt(b)} Q${yt(p)} ${yt(v)}`,arrow:w,label:{x:b.x,y:b.y,angle:pr(p.x-h.x,p.y-h.y)}}}const Pr=e=>Math.round(e*1e3)/1e3;function Ub(e){var h,p;const r=e.querySelector("[data-flow-node-surface]");if(!r)return;const t=e.getBoundingClientRect(),n=t.width/e.offsetWidth;if(!Number.isFinite(n)||n<=0)return;const o=r.getBoundingClientRect();if(!o.width||!o.height)return;const i=(p=(h=r.closest("[data-flow-icon-label]"))==null?void 0:h.querySelector("[data-flow-icon-caption]"))==null?void 0:p.getBoundingClientRect(),s=r,a=typeof s.getScreenCTM=="function"?s.getScreenCTM():null,c=typeof s.getTotalLength=="function"?s.getTotalLength():0,l=s.points,d=(l==null?void 0:l.numberOfItems)||128,u=a&&c>0?Array.from({length:d},(m,g)=>{const y=l!=null&&l.numberOfItems?l.getItem(g):s.getPointAtLength(c*g/d);return{x:Pr((a.a*y.x+a.c*y.y+a.e-t.left)/n),y:Pr((a.b*y.x+a.d*y.y+a.f-t.top)/n)}}):void 0;return{left:Pr((o.left-t.left)/n),top:Pr((o.top-t.top)/n),width:r instanceof HTMLElement?r.offsetWidth:Pr(o.width/n),height:r instanceof HTMLElement?r.offsetHeight:Pr(o.height/n),radius:parseFloat(getComputedStyle(r).borderTopLeftRadius)||0,...i!=null&&i.height?{captionBottom:Pr((i.bottom-t.top)/n)}:{},...u?{outline:u}:{}}}function Pn(e,r){const t=e.x-e.w/2,n=e.y-e.h/2;return{x:t+r.left+r.width/2,y:n+r.top+r.height/2,w:r.width,h:r.height,...r.outline?{outline:r.outline.map(o=>({x:t+o.x,y:n+o.y}))}:{}}}function n1(e,r,t,n,o){var d;const i=o!=="TB"&&o!=="BT",s=i?"top":"left",a=i?"bottom":"right",c=new Map;for(const u of n)for(const[h,p,m]of[[u.source,u.sourceProperty,u.target],[u.target,u.targetProperty,u.source]]){const g=r.get(m);if(p===void 0||!g||m===h)continue;const y=t.get(m),b=JSON.stringify([h,p]),x=c.get(b)??[];x.push(y?Pn(g,y):g),c.set(b,x)}const l=new Map(e);for(const[u,h]of e){const p=r.get(u);if(!p||!h.some(v=>v.placement==="config"))continue;const m=t.get(u),g=m?Pn(p,m):p,y={x:p.w/2,y:p.h/2,w:p.w,h:p.h},b=m?Pn(y,m):y,x=new Map;for(const v of h){if(v.placement!=="config")continue;const C=(c.get(JSON.stringify([u,v.property]))??[]).reduce((R,P)=>R+(i?P.y-g.y:P.x-g.x),0),S=((d=v.anchor)==null?void 0:d.side)===a?a:s;x.set(v,C<-.001?s:C>.001?a:S)}l.set(u,h.map(v=>{const w=x.get(v);if(!w)return v;const C=h.filter(P=>x.get(P)===w),S=(C.indexOf(v)+1)/(C.length+1),R=Vb(b,w,S);return{...v,anchor:R,top:R.y,height:0}}))}return l}function Xu(e,r,t){const n=new Set(r.map(a=>a.id));if(!n.has(e))return new Set;const o=new Set([e]);let i=!0;for(;i;){i=!1;for(const a of r)!o.has(a.id)&&(o.has(a.parent??"")||a.id.startsWith(`${e}.`))&&(o.add(a.id),i=!0)}const s=new Set(o);for(const a of t)o.has(a.source)&&n.has(a.target)&&s.add(a.target),o.has(a.target)&&n.has(a.source)&&s.add(a.source);return s}const mr='"Helvetica Neue", Helvetica, sans-serif';let gn;const Yn=new Map;function Co(e,r){const t=`${r}|${e}`,n=Yn.get(t);if(n!==void 0)return n;gn===void 0&&(gn=typeof document<"u"?document.createElement("canvas").getContext("2d"):null);let o;return gn?(gn.font=r,o=gn.measureText(e).width):o=e.length*(parseFloat(r)||16)*.55,Yn.size>5e3&&Yn.clear(),Yn.set(t,o),o}function o1(e,r,t){const n=[];for(const o of String(e).split(`
|
|
210
|
-
`)){const i=o.split(/\s+/).filter(Boolean);if(!i.length){n.push("");continue}let s="";for(const a of i){const c=s?`${s} ${a}`:a;!s||Co(c,r)<=t?s=c:(n.push(s),s=a)}n.push(s)}return n}const Yu=e=>e.stopPropagation();function i1({id:e,rect:r,label:t,labelLayer:n,labelContent:o,style:i,onSelect:s,onCollapse:a,selected:c=!1}){const l=r.x2-r.x1,d=r.y2-r.y1,u=i.borderWidth,h=i.borderStyle==="dashed"?`${u*4} ${u*2}`:i.borderStyle==="dotted"?`${u} ${u}`:void 0,p=r.x1+l/2,m=i.labelPosition==="top"?r.y1+i.labelMargin-i.fontSize/2:i.labelPosition==="bottom"?r.y2-i.labelMargin+i.fontSize/2:r.y1+d/2,g=t?Co(t,`bold ${i.fontSize}px ${mr}`):0,y=i.fontSize/5,b=t||c&&a?f.jsxs("g",{className:"flow-sdk-container-label","data-node-id":e,children:[c&&a&&f.jsx("foreignObject",{x:p+g/2+y+8,y:m-24,width:48,height:48,"data-flow-content-toggle":"","data-flow-collapse-control":"",style:{pointerEvents:"auto"},children:f.jsx(He,{label:"Show icon",children:f.jsx(Oe,{"aria-label":"Show icon",icon:f.jsx(Y.PiCircleFill,{}),variant:"ghost",style:{width:48,height:48,color:i.textColor},onClick:x=>{x.stopPropagation(),a(e)}})})}),o?f.jsx("foreignObject",{x:p-g/2-y,y:m-i.fontSize/2-y,width:g+2*y,height:i.fontSize+2*y,style:{overflow:"visible"},onClick:Yu,children:o}):t&&f.jsxs(f.Fragment,{children:[f.jsx("rect",{x:p-g/2-y,y:m-i.fontSize/2-y,width:g+2*y,height:i.fontSize+2*y,fill:i.textColor==="transparent"?"transparent":i.labelBg}),f.jsx("text",{x:p,y:m,fill:i.textColor,fontSize:i.fontSize,fontWeight:"bold",fontFamily:mr,style:{fontSize:i.fontSize,fontWeight:"bold",fontFamily:mr},textAnchor:"middle",dominantBaseline:"central",children:t})]})]}):null;return f.jsxs("g",{className:"flow-sdk-container","data-node-id":e,onPointerDown:Yu,onClick:x=>{x.stopPropagation(),s==null||s(e,{shiftKey:x.shiftKey,ctrlKey:x.ctrlKey,metaKey:x.metaKey,altKey:x.altKey})},children:[f.jsx("rect",{x:r.x1,y:r.y1,width:l,height:d,rx:i.borderRadius,ry:i.borderRadius,fill:i.bgColor,fillOpacity:i.bgOpacity,stroke:i.borderColor,strokeWidth:i.borderStyle==="double"?u/3:u,strokeDasharray:h}),i.borderStyle==="double"&&f.jsx("rect",{x:r.x1+u*2/3,y:r.y1+u*2/3,width:Math.max(0,l-u*4/3),height:Math.max(0,d-u*4/3),rx:Math.max(0,i.borderRadius-u*2/3),ry:Math.max(0,i.borderRadius-u*2/3),fill:"none",stroke:i.borderColor,strokeWidth:u/3}),i.animated&&u>0&&f.jsx(so,{variant:i.animationVariant,x:r.x1,y:r.y1,width:l,height:d,radius:i.borderRadius,color:i.animationColor||i.borderColor,strokeWidth:Math.max(8,u*1.6)}),n&&b?Jr.createPortal(b,n):b]})}const a1=j.memo(i1),co=45,Hb=70,Ir=15,Kb=50;function Jb(e,r,t=co){const n=`${t}px ${mr}`,o=e?o1(e,n,200*t/co):[],i=r?48+(o.length?12:0):0,s=i+Math.max(0,...o.map(l=>Co(l,n))),a=Math.max(o.length*t,r?48:0),c=o.length||r?2*Ir:0;return{lines:o,iconWidth:i,contentWidth:s,contentHeight:a,width:s+c,height:a+c}}const Mn=6,Zb=3,Dd=.3,s1=8,Vd=Math.max(Math.pow(Mn*13.37,.9),29)*Zb-s1/Dd,Xb=Mn*Zb*2,ro=80,c1=2*ro+Vd*Dd+100,l1=36+2*Math.max(80,Xb+Vd*Dd);function vd(e){return e.sourceProperty!==void 0||e.targetProperty!==void 0}function wd(e,r){return r==="auto"||(r==="properties"?vd(e):!vd(e))}function rr(e,r,t){return t!=="properties"||e!=="root"||r.some(n=>(n.source===e||n.target===e)&&vd(n))}function d1(e,r,t,n=!1,o){if(!n)return{nodes:e,edges:r};const i=e.filter(a=>rr(a.id,r,t)&&(!o||o.has(a.id))),s=new Set(i.map(a=>a.id));return{nodes:i,edges:r.filter(a=>wd(a,t)&&s.has(a.source)&&s.has(a.target))}}const u1=500,f1="32 18",h1=e=>e.stopPropagation();function p1({id:e,reveal:r,onRevealComplete:t,edgeData:n,validationIssue:o,edgeType:i="rounded-orthogonal",edgeRadius:s,customEdgeTypes:a,source:c,target:l,sourceProperty:d,targetProperty:u,sourceY:h,targetY:p,sourcePort:m,targetPort:g,propertyMode:y=!1,dir:b,turn:x,labelAtTarget:v,labelFraction:w,color:C,connectorColor:S,labelBg:R,labelLayer:P,label:k,dashed:T,animated:E,inverted:M,loopIndex:_=0,onSelect:N}){const $=n==null?void 0:n.icon,B=y?co:Hb,{lines:O,iconWidth:I,contentWidth:ee,contentHeight:ae}=j.useMemo(()=>Jb(k,$,B),[k,$,B]),ne=j.useMemo(()=>{const we={srcDist:ro,tgtDist:ro,arrowGap:Xb,arrowSize:Vd,headShape:y&&(M?h!==void 0||m:p!==void 0||g)?"square":"triangle",radius:s??(v?40:u1),arrowAt:M?"source":"target",labelTargetLength:v?ee+2*Ir:void 0,labelFraction:v?w:void 0},fe=h!==void 0||p!==void 0||!!m||!!g,ge=Zu(c,l,b,h,p,0),X=h===void 0&&p===void 0&&(b==="downward"||b==="upward"),H=m??{...ge.sourcePoint,side:X?b==="upward"?"top":"bottom":b==="leftward"?"left":"right"},be=g??{...ge.targetPoint,side:X?b==="upward"?"bottom":"top":b==="leftward"?"right":"left"},J=c.x===l.x&&c.y===l.y,xe=m||g?Qw(H,be,{...we,srcDist:18,tgtDist:18},i):fe?Ku(c,l,b,h,p,x,{...we,srcDist:18,tgtDist:18,radius:s??Math.min(we.radius,40)}):J?r1(c,_,{...we,srcDist:0,tgtDist:0}):Ju(c,l,b,x,we);if(!xe)return null;const Se=Zu(c,l,b,h,p,fe?18:ro);m&&(Se.sourcePoint=Ur(m,18)),g&&(Se.targetPoint=Ur(g,18));const Fe=Object.prototype.hasOwnProperty.call(a??{},i)?a==null?void 0:a[i]:void 0;if(Fe){const De={rightward:"LR",leftward:"RL",downward:"TB",upward:"BT"};return Fe({edge:n??{id:e,source:"",target:""},source:{...c},target:{...l},...Se,direction:De[b],sourceY:h,targetY:p,inverted:!!M,defaultGeometry:xe})??xe}return J||m||g?xe:i==="straight"?fe?Gb(Se.sourcePoint,Se.targetPoint,we):Wb([c,l],c,l,we):i==="bezier"?t1(Se.sourcePoint,Se.targetPoint,fe?b==="leftward"?"leftward":"rightward":b,we):i==="orthogonal"?fe?Ku(c,l,b,h,p,x,{...we,srcDist:18,tgtDist:18,radius:0}):Ju(c,l,b,x,{...we,radius:0}):xe},[c,e,n,i,s,a,l,y,h,p,m,g,b,x,M,_,v,w,ee]);if(!ne)return null;const oe=(b==="rightward"||b==="leftward")&&!Object.prototype.hasOwnProperty.call(a??{},i)&&!(y&&(h!==void 0||p!==void 0||m||g)),pe=oe?`translate(${ne.label.x} ${ne.label.y-ae/2-2*Ir})`:`translate(${ne.label.x} ${ne.label.y}) rotate(${ne.label.angle}) translate(${b==="downward"||b==="upward"||v||Object.prototype.hasOwnProperty.call(a??{},i)?0:Kb} 0)`,q=o!=null&&o.startsWith("Unverified:")?"#b45309":"#dc2626",F=o?q:C,G=o?f.jsxs("g",{className:"flow-sdk-edge-validation",role:"img","aria-label":o,transform:`translate(${ne.label.x} ${ne.label.y-O.length*B/2-55})`,children:[f.jsx("title",{children:o}),f.jsx(or,{name:"PiWarningCircleFill",svg:!0,size:48,x:-24,y:-24,color:q})]}):null,D=E&&(n==null?void 0:n.edgeAnimationVariant)==="traveling",ce=!D&&(T||E)?f1:void 0,Q=E&&!D?`flow-sdk-edge-anim${M?" flow-sdk-edge-anim-rev":""}`:void 0;let K=null;const ie=r?{"--flow-edge-reveal-duration":`${r.durationMs??600}ms`,"--flow-edge-reveal-state":r.paused?"paused":"running"}:void 0;if(O.length||$){const we=ee,fe=ae;K=f.jsxs("g",{className:`flow-sdk-edge-label${r?" flow-sdk-edge-reveal-end":""}`,style:ie,"data-label-transform":pe,"data-label-horizontal":oe||void 0,"data-edge-id":e,"data-source-property":d,"data-target-property":u,transform:pe,children:[f.jsx("rect",{x:-we/2-Ir,y:-fe/2-Ir,width:we+2*Ir,height:fe+2*Ir,fill:C==="transparent"?"transparent":R}),f.jsx("text",{fill:C,fontSize:B,style:{fontSize:B,fontFamily:mr},fontFamily:mr,textAnchor:"middle",dominantBaseline:"central",children:O.map((ge,X)=>f.jsx("tspan",{x:I/2,y:(X-(O.length-1)/2)*B,children:ge},X))}),$&&f.jsxs("g",{className:"flow-sdk-edge-icon",opacity:C==="transparent"?0:1,children:[f.jsx("title",{children:k?`Edge icon: ${k}`:"Edge icon"}),f.jsx("rect",{x:-we/2,y:-24,width:48,height:48,fill:"transparent"}),f.jsx(or,{name:$,svg:!0,size:48,x:-we/2,y:-24,color:C})]})]})}const ye=f.jsxs(f.Fragment,{children:[f.jsx("path",{d:ne.d,fill:"none",stroke:F,strokeWidth:Mn,strokeOpacity:D?.35:void 0,strokeDasharray:ce,className:Q}),D&&f.jsx(Gw,{path:ne.d,color:F,width:Mn*1.6,reversed:M})]});return f.jsxs("g",{className:"flow-sdk-edge",style:ie,"data-edge-id":e,"data-source-property":d,"data-target-property":u,"data-validation":o?o.startsWith("Unverified:")?"unverified":"invalid":void 0,"aria-label":o,onPointerDown:h1,onClick:we=>{we.stopPropagation(),N==null||N(e)},children:[r?f.jsx(Vw,{path:ne.d,width:Mn*4,reversed:M,onComplete:()=>t==null?void 0:t(e),children:ye}):ye,ne.arrow&&f.jsx("path",{className:r?"flow-sdk-edge-reveal-end":void 0,d:ne.arrow,fill:o?q:S??F}),P&&K?Jr.createPortal(K,P):K,P&&G?Jr.createPortal(G,P):G,f.jsx("path",{className:"flow-sdk-edge-hit",d:ne.d,fill:"none",stroke:"transparent"})]})}const Qu=j.memo(p1);var Qn=typeof globalThis<"u"?globalThis:typeof window<"u"?window:typeof global<"u"?global:typeof self<"u"?self:{};function g1(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e}function Wd(e){throw new Error('Could not dynamically require "'+e+'". Please configure the dynamicRequireTargets or/and ignoreDynamicRequires option of @rollup/plugin-commonjs appropriately for this require call to work.')}var Ko,ef;function y1(){if(ef)return Ko;ef=1;function e(){this.__data__=[],this.size=0}return Ko=e,Ko}var Jo,tf;function an(){if(tf)return Jo;tf=1;function e(r,t){return r===t||r!==r&&t!==t}return Jo=e,Jo}var Zo,rf;function So(){if(rf)return Zo;rf=1;var e=an();function r(t,n){for(var o=t.length;o--;)if(e(t[o][0],n))return o;return-1}return Zo=r,Zo}var Xo,nf;function m1(){if(nf)return Xo;nf=1;var e=So(),r=Array.prototype,t=r.splice;function n(o){var i=this.__data__,s=e(i,o);if(s<0)return!1;var a=i.length-1;return s==a?i.pop():t.call(i,s,1),--this.size,!0}return Xo=n,Xo}var Yo,of;function b1(){if(of)return Yo;of=1;var e=So();function r(t){var n=this.__data__,o=e(n,t);return o<0?void 0:n[o][1]}return Yo=r,Yo}var Qo,af;function x1(){if(af)return Qo;af=1;var e=So();function r(t){return e(this.__data__,t)>-1}return Qo=r,Qo}var ei,sf;function v1(){if(sf)return ei;sf=1;var e=So();function r(t,n){var o=this.__data__,i=e(o,t);return i<0?(++this.size,o.push([t,n])):o[i][1]=n,this}return ei=r,ei}var ti,cf;function jo(){if(cf)return ti;cf=1;var e=y1(),r=m1(),t=b1(),n=x1(),o=v1();function i(s){var a=-1,c=s==null?0:s.length;for(this.clear();++a<c;){var l=s[a];this.set(l[0],l[1])}}return i.prototype.clear=e,i.prototype.delete=r,i.prototype.get=t,i.prototype.has=n,i.prototype.set=o,ti=i,ti}var ri,lf;function w1(){if(lf)return ri;lf=1;var e=jo();function r(){this.__data__=new e,this.size=0}return ri=r,ri}var ni,df;function C1(){if(df)return ni;df=1;function e(r){var t=this.__data__,n=t.delete(r);return this.size=t.size,n}return ni=e,ni}var oi,uf;function S1(){if(uf)return oi;uf=1;function e(r){return this.__data__.get(r)}return oi=e,oi}var ii,ff;function j1(){if(ff)return ii;ff=1;function e(r){return this.__data__.has(r)}return ii=e,ii}var ai,hf;function Yb(){if(hf)return ai;hf=1;var e=typeof Qn=="object"&&Qn&&Qn.Object===Object&&Qn;return ai=e,ai}var si,pf;function Jt(){if(pf)return si;pf=1;var e=Yb(),r=typeof self=="object"&&self&&self.Object===Object&&self,t=e||r||Function("return this")();return si=t,si}var ci,gf;function sn(){if(gf)return ci;gf=1;var e=Jt(),r=e.Symbol;return ci=r,ci}var li,yf;function E1(){if(yf)return li;yf=1;var e=sn(),r=Object.prototype,t=r.hasOwnProperty,n=r.toString,o=e?e.toStringTag:void 0;function i(s){var a=t.call(s,o),c=s[o];try{s[o]=void 0;var l=!0}catch{}var d=n.call(s);return l&&(a?s[o]=c:delete s[o]),d}return li=i,li}var di,mf;function _1(){if(mf)return di;mf=1;var e=Object.prototype,r=e.toString;function t(n){return r.call(n)}return di=t,di}var ui,bf;function Fr(){if(bf)return ui;bf=1;var e=sn(),r=E1(),t=_1(),n="[object Null]",o="[object Undefined]",i=e?e.toStringTag:void 0;function s(a){return a==null?a===void 0?o:n:i&&i in Object(a)?r(a):t(a)}return ui=s,ui}var fi,xf;function Bt(){if(xf)return fi;xf=1;function e(r){var t=typeof r;return r!=null&&(t=="object"||t=="function")}return fi=e,fi}var hi,vf;function zn(){if(vf)return hi;vf=1;var e=Fr(),r=Bt(),t="[object AsyncFunction]",n="[object Function]",o="[object GeneratorFunction]",i="[object Proxy]";function s(a){if(!r(a))return!1;var c=e(a);return c==n||c==o||c==t||c==i}return hi=s,hi}var pi,wf;function R1(){if(wf)return pi;wf=1;var e=Jt(),r=e["__core-js_shared__"];return pi=r,pi}var gi,Cf;function k1(){if(Cf)return gi;Cf=1;var e=R1(),r=(function(){var n=/[^.]+$/.exec(e&&e.keys&&e.keys.IE_PROTO||"");return n?"Symbol(src)_1."+n:""})();function t(n){return!!r&&r in n}return gi=t,gi}var yi,Sf;function Qb(){if(Sf)return yi;Sf=1;var e=Function.prototype,r=e.toString;function t(n){if(n!=null){try{return r.call(n)}catch{}try{return n+""}catch{}}return""}return yi=t,yi}var mi,jf;function A1(){if(jf)return mi;jf=1;var e=zn(),r=k1(),t=Bt(),n=Qb(),o=/[\\^$.*+?()[\]{}|]/g,i=/^\[object .+?Constructor\]$/,s=Function.prototype,a=Object.prototype,c=s.toString,l=a.hasOwnProperty,d=RegExp("^"+c.call(l).replace(o,"\\$&").replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g,"$1.*?")+"$");function u(h){if(!t(h)||r(h))return!1;var p=e(h)?d:i;return p.test(n(h))}return mi=u,mi}var bi,Ef;function P1(){if(Ef)return bi;Ef=1;function e(r,t){return r==null?void 0:r[t]}return bi=e,bi}var xi,_f;function zr(){if(_f)return xi;_f=1;var e=A1(),r=P1();function t(n,o){var i=r(n,o);return e(i)?i:void 0}return xi=t,xi}var vi,Rf;function Gd(){if(Rf)return vi;Rf=1;var e=zr(),r=Jt(),t=e(r,"Map");return vi=t,vi}var wi,kf;function Eo(){if(kf)return wi;kf=1;var e=zr(),r=e(Object,"create");return wi=r,wi}var Ci,Af;function M1(){if(Af)return Ci;Af=1;var e=Eo();function r(){this.__data__=e?e(null):{},this.size=0}return Ci=r,Ci}var Si,Pf;function I1(){if(Pf)return Si;Pf=1;function e(r){var t=this.has(r)&&delete this.__data__[r];return this.size-=t?1:0,t}return Si=e,Si}var ji,Mf;function T1(){if(Mf)return ji;Mf=1;var e=Eo(),r="__lodash_hash_undefined__",t=Object.prototype,n=t.hasOwnProperty;function o(i){var s=this.__data__;if(e){var a=s[i];return a===r?void 0:a}return n.call(s,i)?s[i]:void 0}return ji=o,ji}var Ei,If;function O1(){if(If)return Ei;If=1;var e=Eo(),r=Object.prototype,t=r.hasOwnProperty;function n(o){var i=this.__data__;return e?i[o]!==void 0:t.call(i,o)}return Ei=n,Ei}var _i,Tf;function N1(){if(Tf)return _i;Tf=1;var e=Eo(),r="__lodash_hash_undefined__";function t(n,o){var i=this.__data__;return this.size+=this.has(n)?0:1,i[n]=e&&o===void 0?r:o,this}return _i=t,_i}var Ri,Of;function $1(){if(Of)return Ri;Of=1;var e=M1(),r=I1(),t=T1(),n=O1(),o=N1();function i(s){var a=-1,c=s==null?0:s.length;for(this.clear();++a<c;){var l=s[a];this.set(l[0],l[1])}}return i.prototype.clear=e,i.prototype.delete=r,i.prototype.get=t,i.prototype.has=n,i.prototype.set=o,Ri=i,Ri}var ki,Nf;function q1(){if(Nf)return ki;Nf=1;var e=$1(),r=jo(),t=Gd();function n(){this.size=0,this.__data__={hash:new e,map:new(t||r),string:new e}}return ki=n,ki}var Ai,$f;function L1(){if($f)return Ai;$f=1;function e(r){var t=typeof r;return t=="string"||t=="number"||t=="symbol"||t=="boolean"?r!=="__proto__":r===null}return Ai=e,Ai}var Pi,qf;function _o(){if(qf)return Pi;qf=1;var e=L1();function r(t,n){var o=t.__data__;return e(n)?o[typeof n=="string"?"string":"hash"]:o.map}return Pi=r,Pi}var Mi,Lf;function F1(){if(Lf)return Mi;Lf=1;var e=_o();function r(t){var n=e(this,t).delete(t);return this.size-=n?1:0,n}return Mi=r,Mi}var Ii,Ff;function z1(){if(Ff)return Ii;Ff=1;var e=_o();function r(t){return e(this,t).get(t)}return Ii=r,Ii}var Ti,zf;function B1(){if(zf)return Ti;zf=1;var e=_o();function r(t){return e(this,t).has(t)}return Ti=r,Ti}var Oi,Bf;function D1(){if(Bf)return Oi;Bf=1;var e=_o();function r(t,n){var o=e(this,t),i=o.size;return o.set(t,n),this.size+=o.size==i?0:1,this}return Oi=r,Oi}var Ni,Df;function Ud(){if(Df)return Ni;Df=1;var e=q1(),r=F1(),t=z1(),n=B1(),o=D1();function i(s){var a=-1,c=s==null?0:s.length;for(this.clear();++a<c;){var l=s[a];this.set(l[0],l[1])}}return i.prototype.clear=e,i.prototype.delete=r,i.prototype.get=t,i.prototype.has=n,i.prototype.set=o,Ni=i,Ni}var $i,Vf;function V1(){if(Vf)return $i;Vf=1;var e=jo(),r=Gd(),t=Ud(),n=200;function o(i,s){var a=this.__data__;if(a instanceof e){var c=a.__data__;if(!r||c.length<n-1)return c.push([i,s]),this.size=++a.size,this;a=this.__data__=new t(c)}return a.set(i,s),this.size=a.size,this}return $i=o,$i}var qi,Wf;function Ro(){if(Wf)return qi;Wf=1;var e=jo(),r=w1(),t=C1(),n=S1(),o=j1(),i=V1();function s(a){var c=this.__data__=new e(a);this.size=c.size}return s.prototype.clear=r,s.prototype.delete=t,s.prototype.get=n,s.prototype.has=o,s.prototype.set=i,qi=s,qi}var Li,Gf;function Hd(){if(Gf)return Li;Gf=1;function e(r,t){for(var n=-1,o=r==null?0:r.length;++n<o&&t(r[n],n,r)!==!1;);return r}return Li=e,Li}var Fi,Uf;function ex(){if(Uf)return Fi;Uf=1;var e=zr(),r=(function(){try{var t=e(Object,"defineProperty");return t({},"",{}),t}catch{}})();return Fi=r,Fi}var zi,Hf;function ko(){if(Hf)return zi;Hf=1;var e=ex();function r(t,n,o){n=="__proto__"&&e?e(t,n,{configurable:!0,enumerable:!0,value:o,writable:!0}):t[n]=o}return zi=r,zi}var Bi,Kf;function Ao(){if(Kf)return Bi;Kf=1;var e=ko(),r=an(),t=Object.prototype,n=t.hasOwnProperty;function o(i,s,a){var c=i[s];(!(n.call(i,s)&&r(c,a))||a===void 0&&!(s in i))&&e(i,s,a)}return Bi=o,Bi}var Di,Jf;function Bn(){if(Jf)return Di;Jf=1;var e=Ao(),r=ko();function t(n,o,i,s){var a=!i;i||(i={});for(var c=-1,l=o.length;++c<l;){var d=o[c],u=s?s(i[d],n[d],d,i,n):void 0;u===void 0&&(u=n[d]),a?r(i,d,u):e(i,d,u)}return i}return Di=t,Di}var Vi,Zf;function W1(){if(Zf)return Vi;Zf=1;function e(r,t){for(var n=-1,o=Array(r);++n<r;)o[n]=t(n);return o}return Vi=e,Vi}var Wi,Xf;function ir(){if(Xf)return Wi;Xf=1;function e(r){return r!=null&&typeof r=="object"}return Wi=e,Wi}var Gi,Yf;function G1(){if(Yf)return Gi;Yf=1;var e=Fr(),r=ir(),t="[object Arguments]";function n(o){return r(o)&&e(o)==t}return Gi=n,Gi}var Ui,Qf;function Dn(){if(Qf)return Ui;Qf=1;var e=G1(),r=ir(),t=Object.prototype,n=t.hasOwnProperty,o=t.propertyIsEnumerable,i=e((function(){return arguments})())?e:function(s){return r(s)&&n.call(s,"callee")&&!o.call(s,"callee")};return Ui=i,Ui}var Hi,eh;function bt(){if(eh)return Hi;eh=1;var e=Array.isArray;return Hi=e,Hi}var vn={exports:{}},Ki,th;function U1(){if(th)return Ki;th=1;function e(){return!1}return Ki=e,Ki}vn.exports;var rh;function cn(){return rh||(rh=1,(function(e,r){var t=Jt(),n=U1(),o=r&&!r.nodeType&&r,i=o&&!0&&e&&!e.nodeType&&e,s=i&&i.exports===o,a=s?t.Buffer:void 0,c=a?a.isBuffer:void 0,l=c||n;e.exports=l})(vn,vn.exports)),vn.exports}var Ji,nh;function Po(){if(nh)return Ji;nh=1;var e=9007199254740991,r=/^(?:0|[1-9]\d*)$/;function t(n,o){var i=typeof n;return o=o??e,!!o&&(i=="number"||i!="symbol"&&r.test(n))&&n>-1&&n%1==0&&n<o}return Ji=t,Ji}var Zi,oh;function Kd(){if(oh)return Zi;oh=1;var e=9007199254740991;function r(t){return typeof t=="number"&&t>-1&&t%1==0&&t<=e}return Zi=r,Zi}var Xi,ih;function H1(){if(ih)return Xi;ih=1;var e=Fr(),r=Kd(),t=ir(),n="[object Arguments]",o="[object Array]",i="[object Boolean]",s="[object Date]",a="[object Error]",c="[object Function]",l="[object Map]",d="[object Number]",u="[object Object]",h="[object RegExp]",p="[object Set]",m="[object String]",g="[object WeakMap]",y="[object ArrayBuffer]",b="[object DataView]",x="[object Float32Array]",v="[object Float64Array]",w="[object Int8Array]",C="[object Int16Array]",S="[object Int32Array]",R="[object Uint8Array]",P="[object Uint8ClampedArray]",k="[object Uint16Array]",T="[object Uint32Array]",E={};E[x]=E[v]=E[w]=E[C]=E[S]=E[R]=E[P]=E[k]=E[T]=!0,E[n]=E[o]=E[y]=E[i]=E[b]=E[s]=E[a]=E[c]=E[l]=E[d]=E[u]=E[h]=E[p]=E[m]=E[g]=!1;function M(_){return t(_)&&r(_.length)&&!!E[e(_)]}return Xi=M,Xi}var Yi,ah;function Mo(){if(ah)return Yi;ah=1;function e(r){return function(t){return r(t)}}return Yi=e,Yi}var wn={exports:{}};wn.exports;var sh;function Jd(){return sh||(sh=1,(function(e,r){var t=Yb(),n=r&&!r.nodeType&&r,o=n&&!0&&e&&!e.nodeType&&e,i=o&&o.exports===n,s=i&&t.process,a=(function(){try{var c=o&&o.require&&o.require("util").types;return c||s&&s.binding&&s.binding("util")}catch{}})();e.exports=a})(wn,wn.exports)),wn.exports}var Qi,ch;function Vn(){if(ch)return Qi;ch=1;var e=H1(),r=Mo(),t=Jd(),n=t&&t.isTypedArray,o=n?r(n):e;return Qi=o,Qi}var ea,lh;function tx(){if(lh)return ea;lh=1;var e=W1(),r=Dn(),t=bt(),n=cn(),o=Po(),i=Vn(),s=Object.prototype,a=s.hasOwnProperty;function c(l,d){var u=t(l),h=!u&&r(l),p=!u&&!h&&n(l),m=!u&&!h&&!p&&i(l),g=u||h||p||m,y=g?e(l.length,String):[],b=y.length;for(var x in l)(d||a.call(l,x))&&!(g&&(x=="length"||p&&(x=="offset"||x=="parent")||m&&(x=="buffer"||x=="byteLength"||x=="byteOffset")||o(x,b)))&&y.push(x);return y}return ea=c,ea}var ta,dh;function Io(){if(dh)return ta;dh=1;var e=Object.prototype;function r(t){var n=t&&t.constructor,o=typeof n=="function"&&n.prototype||e;return t===o}return ta=r,ta}var ra,uh;function rx(){if(uh)return ra;uh=1;function e(r,t){return function(n){return r(t(n))}}return ra=e,ra}var na,fh;function K1(){if(fh)return na;fh=1;var e=rx(),r=e(Object.keys,Object);return na=r,na}var oa,hh;function Zd(){if(hh)return oa;hh=1;var e=Io(),r=K1(),t=Object.prototype,n=t.hasOwnProperty;function o(i){if(!e(i))return r(i);var s=[];for(var a in Object(i))n.call(i,a)&&a!="constructor"&&s.push(a);return s}return oa=o,oa}var ia,ph;function lr(){if(ph)return ia;ph=1;var e=zn(),r=Kd();function t(n){return n!=null&&r(n.length)&&!e(n)}return ia=t,ia}var aa,gh;function Sr(){if(gh)return aa;gh=1;var e=tx(),r=Zd(),t=lr();function n(o){return t(o)?e(o):r(o)}return aa=n,aa}var sa,yh;function J1(){if(yh)return sa;yh=1;var e=Bn(),r=Sr();function t(n,o){return n&&e(o,r(o),n)}return sa=t,sa}var ca,mh;function Z1(){if(mh)return ca;mh=1;function e(r){var t=[];if(r!=null)for(var n in Object(r))t.push(n);return t}return ca=e,ca}var la,bh;function X1(){if(bh)return la;bh=1;var e=Bt(),r=Io(),t=Z1(),n=Object.prototype,o=n.hasOwnProperty;function i(s){if(!e(s))return t(s);var a=r(s),c=[];for(var l in s)l=="constructor"&&(a||!o.call(s,l))||c.push(l);return c}return la=i,la}var da,xh;function Br(){if(xh)return da;xh=1;var e=tx(),r=X1(),t=lr();function n(o){return t(o)?e(o,!0):r(o)}return da=n,da}var ua,vh;function Y1(){if(vh)return ua;vh=1;var e=Bn(),r=Br();function t(n,o){return n&&e(o,r(o),n)}return ua=t,ua}var Cn={exports:{}};Cn.exports;var wh;function nx(){return wh||(wh=1,(function(e,r){var t=Jt(),n=r&&!r.nodeType&&r,o=n&&!0&&e&&!e.nodeType&&e,i=o&&o.exports===n,s=i?t.Buffer:void 0,a=s?s.allocUnsafe:void 0;function c(l,d){if(d)return l.slice();var u=l.length,h=a?a(u):new l.constructor(u);return l.copy(h),h}e.exports=c})(Cn,Cn.exports)),Cn.exports}var fa,Ch;function ox(){if(Ch)return fa;Ch=1;function e(r,t){var n=-1,o=r.length;for(t||(t=Array(o));++n<o;)t[n]=r[n];return t}return fa=e,fa}var ha,Sh;function ix(){if(Sh)return ha;Sh=1;function e(r,t){for(var n=-1,o=r==null?0:r.length,i=0,s=[];++n<o;){var a=r[n];t(a,n,r)&&(s[i++]=a)}return s}return ha=e,ha}var pa,jh;function ax(){if(jh)return pa;jh=1;function e(){return[]}return pa=e,pa}var ga,Eh;function Xd(){if(Eh)return ga;Eh=1;var e=ix(),r=ax(),t=Object.prototype,n=t.propertyIsEnumerable,o=Object.getOwnPropertySymbols,i=o?function(s){return s==null?[]:(s=Object(s),e(o(s),function(a){return n.call(s,a)}))}:r;return ga=i,ga}var ya,_h;function Q1(){if(_h)return ya;_h=1;var e=Bn(),r=Xd();function t(n,o){return e(n,r(n),o)}return ya=t,ya}var ma,Rh;function Yd(){if(Rh)return ma;Rh=1;function e(r,t){for(var n=-1,o=t.length,i=r.length;++n<o;)r[i+n]=t[n];return r}return ma=e,ma}var ba,kh;function To(){if(kh)return ba;kh=1;var e=rx(),r=e(Object.getPrototypeOf,Object);return ba=r,ba}var xa,Ah;function sx(){if(Ah)return xa;Ah=1;var e=Yd(),r=To(),t=Xd(),n=ax(),o=Object.getOwnPropertySymbols,i=o?function(s){for(var a=[];s;)e(a,t(s)),s=r(s);return a}:n;return xa=i,xa}var va,Ph;function eC(){if(Ph)return va;Ph=1;var e=Bn(),r=sx();function t(n,o){return e(n,r(n),o)}return va=t,va}var wa,Mh;function cx(){if(Mh)return wa;Mh=1;var e=Yd(),r=bt();function t(n,o,i){var s=o(n);return r(n)?s:e(s,i(n))}return wa=t,wa}var Ca,Ih;function lx(){if(Ih)return Ca;Ih=1;var e=cx(),r=Xd(),t=Sr();function n(o){return e(o,t,r)}return Ca=n,Ca}var Sa,Th;function tC(){if(Th)return Sa;Th=1;var e=cx(),r=sx(),t=Br();function n(o){return e(o,t,r)}return Sa=n,Sa}var ja,Oh;function rC(){if(Oh)return ja;Oh=1;var e=zr(),r=Jt(),t=e(r,"DataView");return ja=t,ja}var Ea,Nh;function nC(){if(Nh)return Ea;Nh=1;var e=zr(),r=Jt(),t=e(r,"Promise");return Ea=t,Ea}var _a,$h;function dx(){if($h)return _a;$h=1;var e=zr(),r=Jt(),t=e(r,"Set");return _a=t,_a}var Ra,qh;function oC(){if(qh)return Ra;qh=1;var e=zr(),r=Jt(),t=e(r,"WeakMap");return Ra=t,Ra}var ka,Lh;function ln(){if(Lh)return ka;Lh=1;var e=rC(),r=Gd(),t=nC(),n=dx(),o=oC(),i=Fr(),s=Qb(),a="[object Map]",c="[object Object]",l="[object Promise]",d="[object Set]",u="[object WeakMap]",h="[object DataView]",p=s(e),m=s(r),g=s(t),y=s(n),b=s(o),x=i;return(e&&x(new e(new ArrayBuffer(1)))!=h||r&&x(new r)!=a||t&&x(t.resolve())!=l||n&&x(new n)!=d||o&&x(new o)!=u)&&(x=function(v){var w=i(v),C=w==c?v.constructor:void 0,S=C?s(C):"";if(S)switch(S){case p:return h;case m:return a;case g:return l;case y:return d;case b:return u}return w}),ka=x,ka}var Aa,Fh;function iC(){if(Fh)return Aa;Fh=1;var e=Object.prototype,r=e.hasOwnProperty;function t(n){var o=n.length,i=new n.constructor(o);return o&&typeof n[0]=="string"&&r.call(n,"index")&&(i.index=n.index,i.input=n.input),i}return Aa=t,Aa}var Pa,zh;function ux(){if(zh)return Pa;zh=1;var e=Jt(),r=e.Uint8Array;return Pa=r,Pa}var Ma,Bh;function Qd(){if(Bh)return Ma;Bh=1;var e=ux();function r(t){var n=new t.constructor(t.byteLength);return new e(n).set(new e(t)),n}return Ma=r,Ma}var Ia,Dh;function aC(){if(Dh)return Ia;Dh=1;var e=Qd();function r(t,n){var o=n?e(t.buffer):t.buffer;return new t.constructor(o,t.byteOffset,t.byteLength)}return Ia=r,Ia}var Ta,Vh;function sC(){if(Vh)return Ta;Vh=1;var e=/\w*$/;function r(t){var n=new t.constructor(t.source,e.exec(t));return n.lastIndex=t.lastIndex,n}return Ta=r,Ta}var Oa,Wh;function cC(){if(Wh)return Oa;Wh=1;var e=sn(),r=e?e.prototype:void 0,t=r?r.valueOf:void 0;function n(o){return t?Object(t.call(o)):{}}return Oa=n,Oa}var Na,Gh;function fx(){if(Gh)return Na;Gh=1;var e=Qd();function r(t,n){var o=n?e(t.buffer):t.buffer;return new t.constructor(o,t.byteOffset,t.length)}return Na=r,Na}var $a,Uh;function lC(){if(Uh)return $a;Uh=1;var e=Qd(),r=aC(),t=sC(),n=cC(),o=fx(),i="[object Boolean]",s="[object Date]",a="[object Map]",c="[object Number]",l="[object RegExp]",d="[object Set]",u="[object String]",h="[object Symbol]",p="[object ArrayBuffer]",m="[object DataView]",g="[object Float32Array]",y="[object Float64Array]",b="[object Int8Array]",x="[object Int16Array]",v="[object Int32Array]",w="[object Uint8Array]",C="[object Uint8ClampedArray]",S="[object Uint16Array]",R="[object Uint32Array]";function P(k,T,E){var M=k.constructor;switch(T){case p:return e(k);case i:case s:return new M(+k);case m:return r(k,E);case g:case y:case b:case x:case v:case w:case C:case S:case R:return o(k,E);case a:return new M;case c:case u:return new M(k);case l:return t(k);case d:return new M;case h:return n(k)}}return $a=P,$a}var qa,Hh;function hx(){if(Hh)return qa;Hh=1;var e=Bt(),r=Object.create,t=(function(){function n(){}return function(o){if(!e(o))return{};if(r)return r(o);n.prototype=o;var i=new n;return n.prototype=void 0,i}})();return qa=t,qa}var La,Kh;function px(){if(Kh)return La;Kh=1;var e=hx(),r=To(),t=Io();function n(o){return typeof o.constructor=="function"&&!t(o)?e(r(o)):{}}return La=n,La}var Fa,Jh;function dC(){if(Jh)return Fa;Jh=1;var e=ln(),r=ir(),t="[object Map]";function n(o){return r(o)&&e(o)==t}return Fa=n,Fa}var za,Zh;function uC(){if(Zh)return za;Zh=1;var e=dC(),r=Mo(),t=Jd(),n=t&&t.isMap,o=n?r(n):e;return za=o,za}var Ba,Xh;function fC(){if(Xh)return Ba;Xh=1;var e=ln(),r=ir(),t="[object Set]";function n(o){return r(o)&&e(o)==t}return Ba=n,Ba}var Da,Yh;function hC(){if(Yh)return Da;Yh=1;var e=fC(),r=Mo(),t=Jd(),n=t&&t.isSet,o=n?r(n):e;return Da=o,Da}var Va,Qh;function gx(){if(Qh)return Va;Qh=1;var e=Ro(),r=Hd(),t=Ao(),n=J1(),o=Y1(),i=nx(),s=ox(),a=Q1(),c=eC(),l=lx(),d=tC(),u=ln(),h=iC(),p=lC(),m=px(),g=bt(),y=cn(),b=uC(),x=Bt(),v=hC(),w=Sr(),C=Br(),S=1,R=2,P=4,k="[object Arguments]",T="[object Array]",E="[object Boolean]",M="[object Date]",_="[object Error]",N="[object Function]",$="[object GeneratorFunction]",B="[object Map]",O="[object Number]",I="[object Object]",ee="[object RegExp]",ae="[object Set]",ne="[object String]",oe="[object Symbol]",pe="[object WeakMap]",q="[object ArrayBuffer]",F="[object DataView]",G="[object Float32Array]",D="[object Float64Array]",ce="[object Int8Array]",Q="[object Int16Array]",K="[object Int32Array]",ie="[object Uint8Array]",ye="[object Uint8ClampedArray]",we="[object Uint16Array]",fe="[object Uint32Array]",ge={};ge[k]=ge[T]=ge[q]=ge[F]=ge[E]=ge[M]=ge[G]=ge[D]=ge[ce]=ge[Q]=ge[K]=ge[B]=ge[O]=ge[I]=ge[ee]=ge[ae]=ge[ne]=ge[oe]=ge[ie]=ge[ye]=ge[we]=ge[fe]=!0,ge[_]=ge[N]=ge[pe]=!1;function X(H,be,J,xe,Se,Fe){var De,he=be&S,Re=be&R,ze=be&P;if(J&&(De=Se?J(H,xe,Se,Fe):J(H)),De!==void 0)return De;if(!x(H))return H;var Te=g(H);if(Te){if(De=h(H),!he)return s(H,De)}else{var qe=u(H),Qe=qe==N||qe==$;if(y(H))return i(H,he);if(qe==I||qe==k||Qe&&!Se){if(De=Re||Qe?{}:m(H),!he)return Re?c(H,o(De,H)):a(H,n(De,H))}else{if(!ge[qe])return Se?H:{};De=p(H,qe,he)}}Fe||(Fe=new e);var ct=Fe.get(H);if(ct)return ct;Fe.set(H,De),v(H)?H.forEach(function(Ye){De.add(X(Ye,be,J,Ye,H,Fe))}):b(H)&&H.forEach(function(Ye,at){De.set(at,X(Ye,be,J,at,H,Fe))});var Pe=ze?Re?d:l:Re?C:w,Ze=Te?void 0:Pe(H);return r(Ze||H,function(Ye,at){Ze&&(at=Ye,Ye=H[at]),t(De,at,X(Ye,be,J,at,H,Fe))}),De}return Va=X,Va}var Wa,ep;function pC(){if(ep)return Wa;ep=1;var e=gx(),r=4;function t(n){return e(n,r)}return Wa=t,Wa}var Ga,tp;function eu(){if(tp)return Ga;tp=1;function e(r){return function(){return r}}return Ga=e,Ga}var Ua,rp;function gC(){if(rp)return Ua;rp=1;function e(r){return function(t,n,o){for(var i=-1,s=Object(t),a=o(t),c=a.length;c--;){var l=a[r?c:++i];if(n(s[l],l,s)===!1)break}return t}}return Ua=e,Ua}var Ha,np;function tu(){if(np)return Ha;np=1;var e=gC(),r=e();return Ha=r,Ha}var Ka,op;function ru(){if(op)return Ka;op=1;var e=tu(),r=Sr();function t(n,o){return n&&e(n,o,r)}return Ka=t,Ka}var Ja,ip;function yC(){if(ip)return Ja;ip=1;var e=lr();function r(t,n){return function(o,i){if(o==null)return o;if(!e(o))return t(o,i);for(var s=o.length,a=n?s:-1,c=Object(o);(n?a--:++a<s)&&i(c[a],a,c)!==!1;);return o}}return Ja=r,Ja}var Za,ap;function Oo(){if(ap)return Za;ap=1;var e=ru(),r=yC(),t=r(e);return Za=t,Za}var Xa,sp;function Dr(){if(sp)return Xa;sp=1;function e(r){return r}return Xa=e,Xa}var Ya,cp;function yx(){if(cp)return Ya;cp=1;var e=Dr();function r(t){return typeof t=="function"?t:e}return Ya=r,Ya}var Qa,lp;function mx(){if(lp)return Qa;lp=1;var e=Hd(),r=Oo(),t=yx(),n=bt();function o(i,s){var a=n(i)?e:r;return a(i,t(s))}return Qa=o,Qa}var es,dp;function bx(){return dp||(dp=1,es=mx()),es}var ts,up;function mC(){if(up)return ts;up=1;var e=Oo();function r(t,n){var o=[];return e(t,function(i,s,a){n(i,s,a)&&o.push(i)}),o}return ts=r,ts}var rs,fp;function bC(){if(fp)return rs;fp=1;var e="__lodash_hash_undefined__";function r(t){return this.__data__.set(t,e),this}return rs=r,rs}var ns,hp;function xC(){if(hp)return ns;hp=1;function e(r){return this.__data__.has(r)}return ns=e,ns}var os,pp;function xx(){if(pp)return os;pp=1;var e=Ud(),r=bC(),t=xC();function n(o){var i=-1,s=o==null?0:o.length;for(this.__data__=new e;++i<s;)this.add(o[i])}return n.prototype.add=n.prototype.push=r,n.prototype.has=t,os=n,os}var is,gp;function vC(){if(gp)return is;gp=1;function e(r,t){for(var n=-1,o=r==null?0:r.length;++n<o;)if(t(r[n],n,r))return!0;return!1}return is=e,is}var as,yp;function vx(){if(yp)return as;yp=1;function e(r,t){return r.has(t)}return as=e,as}var ss,mp;function wx(){if(mp)return ss;mp=1;var e=xx(),r=vC(),t=vx(),n=1,o=2;function i(s,a,c,l,d,u){var h=c&n,p=s.length,m=a.length;if(p!=m&&!(h&&m>p))return!1;var g=u.get(s),y=u.get(a);if(g&&y)return g==a&&y==s;var b=-1,x=!0,v=c&o?new e:void 0;for(u.set(s,a),u.set(a,s);++b<p;){var w=s[b],C=a[b];if(l)var S=h?l(C,w,b,a,s,u):l(w,C,b,s,a,u);if(S!==void 0){if(S)continue;x=!1;break}if(v){if(!r(a,function(R,P){if(!t(v,P)&&(w===R||d(w,R,c,l,u)))return v.push(P)})){x=!1;break}}else if(!(w===C||d(w,C,c,l,u))){x=!1;break}}return u.delete(s),u.delete(a),x}return ss=i,ss}var cs,bp;function wC(){if(bp)return cs;bp=1;function e(r){var t=-1,n=Array(r.size);return r.forEach(function(o,i){n[++t]=[i,o]}),n}return cs=e,cs}var ls,xp;function nu(){if(xp)return ls;xp=1;function e(r){var t=-1,n=Array(r.size);return r.forEach(function(o){n[++t]=o}),n}return ls=e,ls}var ds,vp;function CC(){if(vp)return ds;vp=1;var e=sn(),r=ux(),t=an(),n=wx(),o=wC(),i=nu(),s=1,a=2,c="[object Boolean]",l="[object Date]",d="[object Error]",u="[object Map]",h="[object Number]",p="[object RegExp]",m="[object Set]",g="[object String]",y="[object Symbol]",b="[object ArrayBuffer]",x="[object DataView]",v=e?e.prototype:void 0,w=v?v.valueOf:void 0;function C(S,R,P,k,T,E,M){switch(P){case x:if(S.byteLength!=R.byteLength||S.byteOffset!=R.byteOffset)return!1;S=S.buffer,R=R.buffer;case b:return!(S.byteLength!=R.byteLength||!E(new r(S),new r(R)));case c:case l:case h:return t(+S,+R);case d:return S.name==R.name&&S.message==R.message;case p:case g:return S==R+"";case u:var _=o;case m:var N=k&s;if(_||(_=i),S.size!=R.size&&!N)return!1;var $=M.get(S);if($)return $==R;k|=a,M.set(S,R);var B=n(_(S),_(R),k,T,E,M);return M.delete(S),B;case y:if(w)return w.call(S)==w.call(R)}return!1}return ds=C,ds}var us,wp;function SC(){if(wp)return us;wp=1;var e=lx(),r=1,t=Object.prototype,n=t.hasOwnProperty;function o(i,s,a,c,l,d){var u=a&r,h=e(i),p=h.length,m=e(s),g=m.length;if(p!=g&&!u)return!1;for(var y=p;y--;){var b=h[y];if(!(u?b in s:n.call(s,b)))return!1}var x=d.get(i),v=d.get(s);if(x&&v)return x==s&&v==i;var w=!0;d.set(i,s),d.set(s,i);for(var C=u;++y<p;){b=h[y];var S=i[b],R=s[b];if(c)var P=u?c(R,S,b,s,i,d):c(S,R,b,i,s,d);if(!(P===void 0?S===R||l(S,R,a,c,d):P)){w=!1;break}C||(C=b=="constructor")}if(w&&!C){var k=i.constructor,T=s.constructor;k!=T&&"constructor"in i&&"constructor"in s&&!(typeof k=="function"&&k instanceof k&&typeof T=="function"&&T instanceof T)&&(w=!1)}return d.delete(i),d.delete(s),w}return us=o,us}var fs,Cp;function jC(){if(Cp)return fs;Cp=1;var e=Ro(),r=wx(),t=CC(),n=SC(),o=ln(),i=bt(),s=cn(),a=Vn(),c=1,l="[object Arguments]",d="[object Array]",u="[object Object]",h=Object.prototype,p=h.hasOwnProperty;function m(g,y,b,x,v,w){var C=i(g),S=i(y),R=C?d:o(g),P=S?d:o(y);R=R==l?u:R,P=P==l?u:P;var k=R==u,T=P==u,E=R==P;if(E&&s(g)){if(!s(y))return!1;C=!0,k=!1}if(E&&!k)return w||(w=new e),C||a(g)?r(g,y,b,x,v,w):t(g,y,R,b,x,v,w);if(!(b&c)){var M=k&&p.call(g,"__wrapped__"),_=T&&p.call(y,"__wrapped__");if(M||_){var N=M?g.value():g,$=_?y.value():y;return w||(w=new e),v(N,$,b,x,w)}}return E?(w||(w=new e),n(g,y,b,x,v,w)):!1}return fs=m,fs}var hs,Sp;function Cx(){if(Sp)return hs;Sp=1;var e=jC(),r=ir();function t(n,o,i,s,a){return n===o?!0:n==null||o==null||!r(n)&&!r(o)?n!==n&&o!==o:e(n,o,i,s,t,a)}return hs=t,hs}var ps,jp;function EC(){if(jp)return ps;jp=1;var e=Ro(),r=Cx(),t=1,n=2;function o(i,s,a,c){var l=a.length,d=l,u=!c;if(i==null)return!d;for(i=Object(i);l--;){var h=a[l];if(u&&h[2]?h[1]!==i[h[0]]:!(h[0]in i))return!1}for(;++l<d;){h=a[l];var p=h[0],m=i[p],g=h[1];if(u&&h[2]){if(m===void 0&&!(p in i))return!1}else{var y=new e;if(c)var b=c(m,g,p,i,s,y);if(!(b===void 0?r(g,m,t|n,c,y):b))return!1}}return!0}return ps=o,ps}var gs,Ep;function Sx(){if(Ep)return gs;Ep=1;var e=Bt();function r(t){return t===t&&!e(t)}return gs=r,gs}var ys,_p;function _C(){if(_p)return ys;_p=1;var e=Sx(),r=Sr();function t(n){for(var o=r(n),i=o.length;i--;){var s=o[i],a=n[s];o[i]=[s,a,e(a)]}return o}return ys=t,ys}var ms,Rp;function jx(){if(Rp)return ms;Rp=1;function e(r,t){return function(n){return n==null?!1:n[r]===t&&(t!==void 0||r in Object(n))}}return ms=e,ms}var bs,kp;function RC(){if(kp)return bs;kp=1;var e=EC(),r=_C(),t=jx();function n(o){var i=r(o);return i.length==1&&i[0][2]?t(i[0][0],i[0][1]):function(s){return s===o||e(s,o,i)}}return bs=n,bs}var xs,Ap;function dn(){if(Ap)return xs;Ap=1;var e=Fr(),r=ir(),t="[object Symbol]";function n(o){return typeof o=="symbol"||r(o)&&e(o)==t}return xs=n,xs}var vs,Pp;function ou(){if(Pp)return vs;Pp=1;var e=bt(),r=dn(),t=/\.|\[(?:[^[\]]*|(["'])(?:(?!\1)[^\\]|\\.)*?\1)\]/,n=/^\w*$/;function o(i,s){if(e(i))return!1;var a=typeof i;return a=="number"||a=="symbol"||a=="boolean"||i==null||r(i)?!0:n.test(i)||!t.test(i)||s!=null&&i in Object(s)}return vs=o,vs}var ws,Mp;function kC(){if(Mp)return ws;Mp=1;var e=Ud(),r="Expected a function";function t(n,o){if(typeof n!="function"||o!=null&&typeof o!="function")throw new TypeError(r);var i=function(){var s=arguments,a=o?o.apply(this,s):s[0],c=i.cache;if(c.has(a))return c.get(a);var l=n.apply(this,s);return i.cache=c.set(a,l)||c,l};return i.cache=new(t.Cache||e),i}return t.Cache=e,ws=t,ws}var Cs,Ip;function AC(){if(Ip)return Cs;Ip=1;var e=kC(),r=500;function t(n){var o=e(n,function(s){return i.size===r&&i.clear(),s}),i=o.cache;return o}return Cs=t,Cs}var Ss,Tp;function PC(){if(Tp)return Ss;Tp=1;var e=AC(),r=/[^.[\]]+|\[(?:(-?\d+(?:\.\d+)?)|(["'])((?:(?!\2)[^\\]|\\.)*?)\2)\]|(?=(?:\.|\[\])(?:\.|\[\]|$))/g,t=/\\(\\)?/g,n=e(function(o){var i=[];return o.charCodeAt(0)===46&&i.push(""),o.replace(r,function(s,a,c,l){i.push(c?l.replace(t,"$1"):a||s)}),i});return Ss=n,Ss}var js,Op;function No(){if(Op)return js;Op=1;function e(r,t){for(var n=-1,o=r==null?0:r.length,i=Array(o);++n<o;)i[n]=t(r[n],n,r);return i}return js=e,js}var Es,Np;function MC(){if(Np)return Es;Np=1;var e=sn(),r=No(),t=bt(),n=dn(),o=e?e.prototype:void 0,i=o?o.toString:void 0;function s(a){if(typeof a=="string")return a;if(t(a))return r(a,s)+"";if(n(a))return i?i.call(a):"";var c=a+"";return c=="0"&&1/a==-1/0?"-0":c}return Es=s,Es}var _s,$p;function Ex(){if($p)return _s;$p=1;var e=MC();function r(t){return t==null?"":e(t)}return _s=r,_s}var Rs,qp;function $o(){if(qp)return Rs;qp=1;var e=bt(),r=ou(),t=PC(),n=Ex();function o(i,s){return e(i)?i:r(i,s)?[i]:t(n(i))}return Rs=o,Rs}var ks,Lp;function Wn(){if(Lp)return ks;Lp=1;var e=dn();function r(t){if(typeof t=="string"||e(t))return t;var n=t+"";return n=="0"&&1/t==-1/0?"-0":n}return ks=r,ks}var As,Fp;function qo(){if(Fp)return As;Fp=1;var e=$o(),r=Wn();function t(n,o){o=e(o,n);for(var i=0,s=o.length;n!=null&&i<s;)n=n[r(o[i++])];return i&&i==s?n:void 0}return As=t,As}var Ps,zp;function IC(){if(zp)return Ps;zp=1;var e=qo();function r(t,n,o){var i=t==null?void 0:e(t,n);return i===void 0?o:i}return Ps=r,Ps}var Ms,Bp;function TC(){if(Bp)return Ms;Bp=1;function e(r,t){return r!=null&&t in Object(r)}return Ms=e,Ms}var Is,Dp;function _x(){if(Dp)return Is;Dp=1;var e=$o(),r=Dn(),t=bt(),n=Po(),o=Kd(),i=Wn();function s(a,c,l){c=e(c,a);for(var d=-1,u=c.length,h=!1;++d<u;){var p=i(c[d]);if(!(h=a!=null&&l(a,p)))break;a=a[p]}return h||++d!=u?h:(u=a==null?0:a.length,!!u&&o(u)&&n(p,u)&&(t(a)||r(a)))}return Is=s,Is}var Ts,Vp;function Rx(){if(Vp)return Ts;Vp=1;var e=TC(),r=_x();function t(n,o){return n!=null&&r(n,o,e)}return Ts=t,Ts}var Os,Wp;function OC(){if(Wp)return Os;Wp=1;var e=Cx(),r=IC(),t=Rx(),n=ou(),o=Sx(),i=jx(),s=Wn(),a=1,c=2;function l(d,u){return n(d)&&o(u)?i(s(d),u):function(h){var p=r(h,d);return p===void 0&&p===u?t(h,d):e(u,p,a|c)}}return Os=l,Os}var Ns,Gp;function kx(){if(Gp)return Ns;Gp=1;function e(r){return function(t){return t==null?void 0:t[r]}}return Ns=e,Ns}var $s,Up;function NC(){if(Up)return $s;Up=1;var e=qo();function r(t){return function(n){return e(n,t)}}return $s=r,$s}var qs,Hp;function $C(){if(Hp)return qs;Hp=1;var e=kx(),r=NC(),t=ou(),n=Wn();function o(i){return t(i)?e(n(i)):r(i)}return qs=o,qs}var Ls,Kp;function dr(){if(Kp)return Ls;Kp=1;var e=RC(),r=OC(),t=Dr(),n=bt(),o=$C();function i(s){return typeof s=="function"?s:s==null?t:typeof s=="object"?n(s)?r(s[0],s[1]):e(s):o(s)}return Ls=i,Ls}var Fs,Jp;function Ax(){if(Jp)return Fs;Jp=1;var e=ix(),r=mC(),t=dr(),n=bt();function o(i,s){var a=n(i)?e:r;return a(i,t(s,3))}return Fs=o,Fs}var zs,Zp;function qC(){if(Zp)return zs;Zp=1;var e=Object.prototype,r=e.hasOwnProperty;function t(n,o){return n!=null&&r.call(n,o)}return zs=t,zs}var Bs,Xp;function Px(){if(Xp)return Bs;Xp=1;var e=qC(),r=_x();function t(n,o){return n!=null&&r(n,o,e)}return Bs=t,Bs}var Ds,Yp;function LC(){if(Yp)return Ds;Yp=1;var e=Zd(),r=ln(),t=Dn(),n=bt(),o=lr(),i=cn(),s=Io(),a=Vn(),c="[object Map]",l="[object Set]",d=Object.prototype,u=d.hasOwnProperty;function h(p){if(p==null)return!0;if(o(p)&&(n(p)||typeof p=="string"||typeof p.splice=="function"||i(p)||a(p)||t(p)))return!p.length;var m=r(p);if(m==c||m==l)return!p.size;if(s(p))return!e(p).length;for(var g in p)if(u.call(p,g))return!1;return!0}return Ds=h,Ds}var Vs,Qp;function Mx(){if(Qp)return Vs;Qp=1;function e(r){return r===void 0}return Vs=e,Vs}var Ws,eg;function Ix(){if(eg)return Ws;eg=1;var e=Oo(),r=lr();function t(n,o){var i=-1,s=r(n)?Array(n.length):[];return e(n,function(a,c,l){s[++i]=o(a,c,l)}),s}return Ws=t,Ws}var Gs,tg;function Tx(){if(tg)return Gs;tg=1;var e=No(),r=dr(),t=Ix(),n=bt();function o(i,s){var a=n(i)?e:t;return a(i,r(s,3))}return Gs=o,Gs}var Us,rg;function FC(){if(rg)return Us;rg=1;function e(r,t,n,o){var i=-1,s=r==null?0:r.length;for(o&&s&&(n=r[++i]);++i<s;)n=t(n,r[i],i,r);return n}return Us=e,Us}var Hs,ng;function zC(){if(ng)return Hs;ng=1;function e(r,t,n,o,i){return i(r,function(s,a,c){n=o?(o=!1,s):t(n,s,a,c)}),n}return Hs=e,Hs}var Ks,og;function Ox(){if(og)return Ks;og=1;var e=FC(),r=Oo(),t=dr(),n=zC(),o=bt();function i(s,a,c){var l=o(s)?e:n,d=arguments.length<3;return l(s,t(a,4),c,d,r)}return Ks=i,Ks}var Js,ig;function BC(){if(ig)return Js;ig=1;var e=Fr(),r=bt(),t=ir(),n="[object String]";function o(i){return typeof i=="string"||!r(i)&&t(i)&&e(i)==n}return Js=o,Js}var Zs,ag;function DC(){if(ag)return Zs;ag=1;var e=kx(),r=e("length");return Zs=r,Zs}var Xs,sg;function VC(){if(sg)return Xs;sg=1;var e="\\ud800-\\udfff",r="\\u0300-\\u036f",t="\\ufe20-\\ufe2f",n="\\u20d0-\\u20ff",o=r+t+n,i="\\ufe0e\\ufe0f",s="\\u200d",a=RegExp("["+s+e+o+i+"]");function c(l){return a.test(l)}return Xs=c,Xs}var Ys,cg;function WC(){if(cg)return Ys;cg=1;var e="\\ud800-\\udfff",r="\\u0300-\\u036f",t="\\ufe20-\\ufe2f",n="\\u20d0-\\u20ff",o=r+t+n,i="\\ufe0e\\ufe0f",s="["+e+"]",a="["+o+"]",c="\\ud83c[\\udffb-\\udfff]",l="(?:"+a+"|"+c+")",d="[^"+e+"]",u="(?:\\ud83c[\\udde6-\\uddff]){2}",h="[\\ud800-\\udbff][\\udc00-\\udfff]",p="\\u200d",m=l+"?",g="["+i+"]?",y="(?:"+p+"(?:"+[d,u,h].join("|")+")"+g+m+")*",b=g+m+y,x="(?:"+[d+a+"?",a,u,h,s].join("|")+")",v=RegExp(c+"(?="+c+")|"+x+b,"g");function w(C){for(var S=v.lastIndex=0;v.test(C);)++S;return S}return Ys=w,Ys}var Qs,lg;function GC(){if(lg)return Qs;lg=1;var e=DC(),r=VC(),t=WC();function n(o){return r(o)?t(o):e(o)}return Qs=n,Qs}var ec,dg;function UC(){if(dg)return ec;dg=1;var e=Zd(),r=ln(),t=lr(),n=BC(),o=GC(),i="[object Map]",s="[object Set]";function a(c){if(c==null)return 0;if(t(c))return n(c)?o(c):c.length;var l=r(c);return l==i||l==s?c.size:e(c).length}return ec=a,ec}var tc,ug;function HC(){if(ug)return tc;ug=1;var e=Hd(),r=hx(),t=ru(),n=dr(),o=To(),i=bt(),s=cn(),a=zn(),c=Bt(),l=Vn();function d(u,h,p){var m=i(u),g=m||s(u)||l(u);if(h=n(h,4),p==null){var y=u&&u.constructor;g?p=m?new y:[]:c(u)?p=a(y)?r(o(u)):{}:p={}}return(g?e:t)(u,function(b,x,v){return h(p,b,x,v)}),p}return tc=d,tc}var rc,fg;function KC(){if(fg)return rc;fg=1;var e=sn(),r=Dn(),t=bt(),n=e?e.isConcatSpreadable:void 0;function o(i){return t(i)||r(i)||!!(n&&i&&i[n])}return rc=o,rc}var nc,hg;function iu(){if(hg)return nc;hg=1;var e=Yd(),r=KC();function t(n,o,i,s,a){var c=-1,l=n.length;for(i||(i=r),a||(a=[]);++c<l;){var d=n[c];o>0&&i(d)?o>1?t(d,o-1,i,s,a):e(a,d):s||(a[a.length]=d)}return a}return nc=t,nc}var oc,pg;function JC(){if(pg)return oc;pg=1;function e(r,t,n){switch(n.length){case 0:return r.call(t);case 1:return r.call(t,n[0]);case 2:return r.call(t,n[0],n[1]);case 3:return r.call(t,n[0],n[1],n[2])}return r.apply(t,n)}return oc=e,oc}var ic,gg;function Nx(){if(gg)return ic;gg=1;var e=JC(),r=Math.max;function t(n,o,i){return o=r(o===void 0?n.length-1:o,0),function(){for(var s=arguments,a=-1,c=r(s.length-o,0),l=Array(c);++a<c;)l[a]=s[o+a];a=-1;for(var d=Array(o+1);++a<o;)d[a]=s[a];return d[o]=i(l),e(n,this,d)}}return ic=t,ic}var ac,yg;function ZC(){if(yg)return ac;yg=1;var e=eu(),r=ex(),t=Dr(),n=r?function(o,i){return r(o,"toString",{configurable:!0,enumerable:!1,value:e(i),writable:!0})}:t;return ac=n,ac}var sc,mg;function XC(){if(mg)return sc;mg=1;var e=800,r=16,t=Date.now;function n(o){var i=0,s=0;return function(){var a=t(),c=r-(a-s);if(s=a,c>0){if(++i>=e)return arguments[0]}else i=0;return o.apply(void 0,arguments)}}return sc=n,sc}var cc,bg;function $x(){if(bg)return cc;bg=1;var e=ZC(),r=XC(),t=r(e);return cc=t,cc}var lc,xg;function Lo(){if(xg)return lc;xg=1;var e=Dr(),r=Nx(),t=$x();function n(o,i){return t(r(o,i,e),o+"")}return lc=n,lc}var dc,vg;function qx(){if(vg)return dc;vg=1;function e(r,t,n,o){for(var i=r.length,s=n+(o?1:-1);o?s--:++s<i;)if(t(r[s],s,r))return s;return-1}return dc=e,dc}var uc,wg;function YC(){if(wg)return uc;wg=1;function e(r){return r!==r}return uc=e,uc}var fc,Cg;function QC(){if(Cg)return fc;Cg=1;function e(r,t,n){for(var o=n-1,i=r.length;++o<i;)if(r[o]===t)return o;return-1}return fc=e,fc}var hc,Sg;function eS(){if(Sg)return hc;Sg=1;var e=qx(),r=YC(),t=QC();function n(o,i,s){return i===i?t(o,i,s):e(o,r,s)}return hc=n,hc}var pc,jg;function tS(){if(jg)return pc;jg=1;var e=eS();function r(t,n){var o=t==null?0:t.length;return!!o&&e(t,n,0)>-1}return pc=r,pc}var gc,Eg;function rS(){if(Eg)return gc;Eg=1;function e(r,t,n){for(var o=-1,i=r==null?0:r.length;++o<i;)if(n(t,r[o]))return!0;return!1}return gc=e,gc}var yc,_g;function nS(){if(_g)return yc;_g=1;function e(){}return yc=e,yc}var mc,Rg;function oS(){if(Rg)return mc;Rg=1;var e=dx(),r=nS(),t=nu(),n=1/0,o=e&&1/t(new e([,-0]))[1]==n?function(i){return new e(i)}:r;return mc=o,mc}var bc,kg;function iS(){if(kg)return bc;kg=1;var e=xx(),r=tS(),t=rS(),n=vx(),o=oS(),i=nu(),s=200;function a(c,l,d){var u=-1,h=r,p=c.length,m=!0,g=[],y=g;if(d)m=!1,h=t;else if(p>=s){var b=l?null:o(c);if(b)return i(b);m=!1,h=n,y=new e}else y=l?[]:g;e:for(;++u<p;){var x=c[u],v=l?l(x):x;if(x=d||x!==0?x:0,m&&v===v){for(var w=y.length;w--;)if(y[w]===v)continue e;l&&y.push(v),g.push(x)}else h(y,v,d)||(y!==g&&y.push(v),g.push(x))}return g}return bc=a,bc}var xc,Ag;function Lx(){if(Ag)return xc;Ag=1;var e=lr(),r=ir();function t(n){return r(n)&&e(n)}return xc=t,xc}var vc,Pg;function aS(){if(Pg)return vc;Pg=1;var e=iu(),r=Lo(),t=iS(),n=Lx(),o=r(function(i){return t(e(i,1,n,!0))});return vc=o,vc}var wc,Mg;function sS(){if(Mg)return wc;Mg=1;var e=No();function r(t,n){return e(n,function(o){return t[o]})}return wc=r,wc}var Cc,Ig;function Fx(){if(Ig)return Cc;Ig=1;var e=sS(),r=Sr();function t(n){return n==null?[]:e(n,r(n))}return Cc=t,Cc}var Sc,Tg;function Dt(){if(Tg)return Sc;Tg=1;var e;if(typeof Wd=="function")try{e={clone:pC(),constant:eu(),each:bx(),filter:Ax(),has:Px(),isArray:bt(),isEmpty:LC(),isFunction:zn(),isUndefined:Mx(),keys:Sr(),map:Tx(),reduce:Ox(),size:UC(),transform:HC(),union:aS(),values:Fx()}}catch{}return e||(e=window._),Sc=e,Sc}var jc,Og;function au(){if(Og)return jc;Og=1;var e=Dt();jc=o;var r="\0",t="\0",n="";function o(d){this._isDirected=e.has(d,"directed")?d.directed:!0,this._isMultigraph=e.has(d,"multigraph")?d.multigraph:!1,this._isCompound=e.has(d,"compound")?d.compound:!1,this._label=void 0,this._defaultNodeLabelFn=e.constant(void 0),this._defaultEdgeLabelFn=e.constant(void 0),this._nodes={},this._isCompound&&(this._parent={},this._children={},this._children[t]={}),this._in={},this._preds={},this._out={},this._sucs={},this._edgeObjs={},this._edgeLabels={}}o.prototype._nodeCount=0,o.prototype._edgeCount=0,o.prototype.isDirected=function(){return this._isDirected},o.prototype.isMultigraph=function(){return this._isMultigraph},o.prototype.isCompound=function(){return this._isCompound},o.prototype.setGraph=function(d){return this._label=d,this},o.prototype.graph=function(){return this._label},o.prototype.setDefaultNodeLabel=function(d){return e.isFunction(d)||(d=e.constant(d)),this._defaultNodeLabelFn=d,this},o.prototype.nodeCount=function(){return this._nodeCount},o.prototype.nodes=function(){return e.keys(this._nodes)},o.prototype.sources=function(){var d=this;return e.filter(this.nodes(),function(u){return e.isEmpty(d._in[u])})},o.prototype.sinks=function(){var d=this;return e.filter(this.nodes(),function(u){return e.isEmpty(d._out[u])})},o.prototype.setNodes=function(d,u){var h=arguments,p=this;return e.each(d,function(m){h.length>1?p.setNode(m,u):p.setNode(m)}),this},o.prototype.setNode=function(d,u){return e.has(this._nodes,d)?(arguments.length>1&&(this._nodes[d]=u),this):(this._nodes[d]=arguments.length>1?u:this._defaultNodeLabelFn(d),this._isCompound&&(this._parent[d]=t,this._children[d]={},this._children[t][d]=!0),this._in[d]={},this._preds[d]={},this._out[d]={},this._sucs[d]={},++this._nodeCount,this)},o.prototype.node=function(d){return this._nodes[d]},o.prototype.hasNode=function(d){return e.has(this._nodes,d)},o.prototype.removeNode=function(d){var u=this;if(e.has(this._nodes,d)){var h=function(p){u.removeEdge(u._edgeObjs[p])};delete this._nodes[d],this._isCompound&&(this._removeFromParentsChildList(d),delete this._parent[d],e.each(this.children(d),function(p){u.setParent(p)}),delete this._children[d]),e.each(e.keys(this._in[d]),h),delete this._in[d],delete this._preds[d],e.each(e.keys(this._out[d]),h),delete this._out[d],delete this._sucs[d],--this._nodeCount}return this},o.prototype.setParent=function(d,u){if(!this._isCompound)throw new Error("Cannot set parent in a non-compound graph");if(e.isUndefined(u))u=t;else{u+="";for(var h=u;!e.isUndefined(h);h=this.parent(h))if(h===d)throw new Error("Setting "+u+" as parent of "+d+" would create a cycle");this.setNode(u)}return this.setNode(d),this._removeFromParentsChildList(d),this._parent[d]=u,this._children[u][d]=!0,this},o.prototype._removeFromParentsChildList=function(d){delete this._children[this._parent[d]][d]},o.prototype.parent=function(d){if(this._isCompound){var u=this._parent[d];if(u!==t)return u}},o.prototype.children=function(d){if(e.isUndefined(d)&&(d=t),this._isCompound){var u=this._children[d];if(u)return e.keys(u)}else{if(d===t)return this.nodes();if(this.hasNode(d))return[]}},o.prototype.predecessors=function(d){var u=this._preds[d];if(u)return e.keys(u)},o.prototype.successors=function(d){var u=this._sucs[d];if(u)return e.keys(u)},o.prototype.neighbors=function(d){var u=this.predecessors(d);if(u)return e.union(u,this.successors(d))},o.prototype.isLeaf=function(d){var u;return this.isDirected()?u=this.successors(d):u=this.neighbors(d),u.length===0},o.prototype.filterNodes=function(d){var u=new this.constructor({directed:this._isDirected,multigraph:this._isMultigraph,compound:this._isCompound});u.setGraph(this.graph());var h=this;e.each(this._nodes,function(g,y){d(y)&&u.setNode(y,g)}),e.each(this._edgeObjs,function(g){u.hasNode(g.v)&&u.hasNode(g.w)&&u.setEdge(g,h.edge(g))});var p={};function m(g){var y=h.parent(g);return y===void 0||u.hasNode(y)?(p[g]=y,y):y in p?p[y]:m(y)}return this._isCompound&&e.each(u.nodes(),function(g){u.setParent(g,m(g))}),u},o.prototype.setDefaultEdgeLabel=function(d){return e.isFunction(d)||(d=e.constant(d)),this._defaultEdgeLabelFn=d,this},o.prototype.edgeCount=function(){return this._edgeCount},o.prototype.edges=function(){return e.values(this._edgeObjs)},o.prototype.setPath=function(d,u){var h=this,p=arguments;return e.reduce(d,function(m,g){return p.length>1?h.setEdge(m,g,u):h.setEdge(m,g),g}),this},o.prototype.setEdge=function(){var d,u,h,p,m=!1,g=arguments[0];typeof g=="object"&&g!==null&&"v"in g?(d=g.v,u=g.w,h=g.name,arguments.length===2&&(p=arguments[1],m=!0)):(d=g,u=arguments[1],h=arguments[3],arguments.length>2&&(p=arguments[2],m=!0)),d=""+d,u=""+u,e.isUndefined(h)||(h=""+h);var y=a(this._isDirected,d,u,h);if(e.has(this._edgeLabels,y))return m&&(this._edgeLabels[y]=p),this;if(!e.isUndefined(h)&&!this._isMultigraph)throw new Error("Cannot set a named edge when isMultigraph = false");this.setNode(d),this.setNode(u),this._edgeLabels[y]=m?p:this._defaultEdgeLabelFn(d,u,h);var b=c(this._isDirected,d,u,h);return d=b.v,u=b.w,Object.freeze(b),this._edgeObjs[y]=b,i(this._preds[u],d),i(this._sucs[d],u),this._in[u][y]=b,this._out[d][y]=b,this._edgeCount++,this},o.prototype.edge=function(d,u,h){var p=arguments.length===1?l(this._isDirected,arguments[0]):a(this._isDirected,d,u,h);return this._edgeLabels[p]},o.prototype.hasEdge=function(d,u,h){var p=arguments.length===1?l(this._isDirected,arguments[0]):a(this._isDirected,d,u,h);return e.has(this._edgeLabels,p)},o.prototype.removeEdge=function(d,u,h){var p=arguments.length===1?l(this._isDirected,arguments[0]):a(this._isDirected,d,u,h),m=this._edgeObjs[p];return m&&(d=m.v,u=m.w,delete this._edgeLabels[p],delete this._edgeObjs[p],s(this._preds[u],d),s(this._sucs[d],u),delete this._in[u][p],delete this._out[d][p],this._edgeCount--),this},o.prototype.inEdges=function(d,u){var h=this._in[d];if(h){var p=e.values(h);return u?e.filter(p,function(m){return m.v===u}):p}},o.prototype.outEdges=function(d,u){var h=this._out[d];if(h){var p=e.values(h);return u?e.filter(p,function(m){return m.w===u}):p}},o.prototype.nodeEdges=function(d,u){var h=this.inEdges(d,u);if(h)return h.concat(this.outEdges(d,u))};function i(d,u){d[u]?d[u]++:d[u]=1}function s(d,u){--d[u]||delete d[u]}function a(d,u,h,p){var m=""+u,g=""+h;if(!d&&m>g){var y=m;m=g,g=y}return m+n+g+n+(e.isUndefined(p)?r:p)}function c(d,u,h,p){var m=""+u,g=""+h;if(!d&&m>g){var y=m;m=g,g=y}var b={v:m,w:g};return p&&(b.name=p),b}function l(d,u){return a(d,u.v,u.w,u.name)}return jc}var Ec,Ng;function cS(){return Ng||(Ng=1,Ec="2.1.8"),Ec}var _c,$g;function lS(){return $g||($g=1,_c={Graph:au(),version:cS()}),_c}var Rc,qg;function dS(){if(qg)return Rc;qg=1;var e=Dt(),r=au();Rc={write:t,read:i};function t(s){var a={options:{directed:s.isDirected(),multigraph:s.isMultigraph(),compound:s.isCompound()},nodes:n(s),edges:o(s)};return e.isUndefined(s.graph())||(a.value=e.clone(s.graph())),a}function n(s){return e.map(s.nodes(),function(a){var c=s.node(a),l=s.parent(a),d={v:a};return e.isUndefined(c)||(d.value=c),e.isUndefined(l)||(d.parent=l),d})}function o(s){return e.map(s.edges(),function(a){var c=s.edge(a),l={v:a.v,w:a.w};return e.isUndefined(a.name)||(l.name=a.name),e.isUndefined(c)||(l.value=c),l})}function i(s){var a=new r(s.options).setGraph(s.value);return e.each(s.nodes,function(c){a.setNode(c.v,c.value),c.parent&&a.setParent(c.v,c.parent)}),e.each(s.edges,function(c){a.setEdge({v:c.v,w:c.w,name:c.name},c.value)}),a}return Rc}var kc,Lg;function uS(){if(Lg)return kc;Lg=1;var e=Dt();kc=r;function r(t){var n={},o=[],i;function s(a){e.has(n,a)||(n[a]=!0,i.push(a),e.each(t.successors(a),s),e.each(t.predecessors(a),s))}return e.each(t.nodes(),function(a){i=[],s(a),i.length&&o.push(i)}),o}return kc}var Ac,Fg;function zx(){if(Fg)return Ac;Fg=1;var e=Dt();Ac=r;function r(){this._arr=[],this._keyIndices={}}return r.prototype.size=function(){return this._arr.length},r.prototype.keys=function(){return this._arr.map(function(t){return t.key})},r.prototype.has=function(t){return e.has(this._keyIndices,t)},r.prototype.priority=function(t){var n=this._keyIndices[t];if(n!==void 0)return this._arr[n].priority},r.prototype.min=function(){if(this.size()===0)throw new Error("Queue underflow");return this._arr[0].key},r.prototype.add=function(t,n){var o=this._keyIndices;if(t=String(t),!e.has(o,t)){var i=this._arr,s=i.length;return o[t]=s,i.push({key:t,priority:n}),this._decrease(s),!0}return!1},r.prototype.removeMin=function(){this._swap(0,this._arr.length-1);var t=this._arr.pop();return delete this._keyIndices[t.key],this._heapify(0),t.key},r.prototype.decrease=function(t,n){var o=this._keyIndices[t];if(n>this._arr[o].priority)throw new Error("New priority is greater than current priority. Key: "+t+" Old: "+this._arr[o].priority+" New: "+n);this._arr[o].priority=n,this._decrease(o)},r.prototype._heapify=function(t){var n=this._arr,o=2*t,i=o+1,s=t;o<n.length&&(s=n[o].priority<n[s].priority?o:s,i<n.length&&(s=n[i].priority<n[s].priority?i:s),s!==t&&(this._swap(t,s),this._heapify(s)))},r.prototype._decrease=function(t){for(var n=this._arr,o=n[t].priority,i;t!==0&&(i=t>>1,!(n[i].priority<o));)this._swap(t,i),t=i},r.prototype._swap=function(t,n){var o=this._arr,i=this._keyIndices,s=o[t],a=o[n];o[t]=a,o[n]=s,i[a.key]=t,i[s.key]=n},Ac}var Pc,zg;function Bx(){if(zg)return Pc;zg=1;var e=Dt(),r=zx();Pc=n;var t=e.constant(1);function n(i,s,a,c){return o(i,String(s),a||t,c||function(l){return i.outEdges(l)})}function o(i,s,a,c){var l={},d=new r,u,h,p=function(m){var g=m.v!==u?m.v:m.w,y=l[g],b=a(m),x=h.distance+b;if(b<0)throw new Error("dijkstra does not allow negative edge weights. Bad edge: "+m+" Weight: "+b);x<y.distance&&(y.distance=x,y.predecessor=u,d.decrease(g,x))};for(i.nodes().forEach(function(m){var g=m===s?0:Number.POSITIVE_INFINITY;l[m]={distance:g},d.add(m,g)});d.size()>0&&(u=d.removeMin(),h=l[u],h.distance!==Number.POSITIVE_INFINITY);)c(u).forEach(p);return l}return Pc}var Mc,Bg;function fS(){if(Bg)return Mc;Bg=1;var e=Bx(),r=Dt();Mc=t;function t(n,o,i){return r.transform(n.nodes(),function(s,a){s[a]=e(n,a,o,i)},{})}return Mc}var Ic,Dg;function Dx(){if(Dg)return Ic;Dg=1;var e=Dt();Ic=r;function r(t){var n=0,o=[],i={},s=[];function a(c){var l=i[c]={onStack:!0,lowlink:n,index:n++};if(o.push(c),t.successors(c).forEach(function(h){e.has(i,h)?i[h].onStack&&(l.lowlink=Math.min(l.lowlink,i[h].index)):(a(h),l.lowlink=Math.min(l.lowlink,i[h].lowlink))}),l.lowlink===l.index){var d=[],u;do u=o.pop(),i[u].onStack=!1,d.push(u);while(c!==u);s.push(d)}}return t.nodes().forEach(function(c){e.has(i,c)||a(c)}),s}return Ic}var Tc,Vg;function hS(){if(Vg)return Tc;Vg=1;var e=Dt(),r=Dx();Tc=t;function t(n){return e.filter(r(n),function(o){return o.length>1||o.length===1&&n.hasEdge(o[0],o[0])})}return Tc}var Oc,Wg;function pS(){if(Wg)return Oc;Wg=1;var e=Dt();Oc=t;var r=e.constant(1);function t(o,i,s){return n(o,i||r,s||function(a){return o.outEdges(a)})}function n(o,i,s){var a={},c=o.nodes();return c.forEach(function(l){a[l]={},a[l][l]={distance:0},c.forEach(function(d){l!==d&&(a[l][d]={distance:Number.POSITIVE_INFINITY})}),s(l).forEach(function(d){var u=d.v===l?d.w:d.v,h=i(d);a[l][u]={distance:h,predecessor:l}})}),c.forEach(function(l){var d=a[l];c.forEach(function(u){var h=a[u];c.forEach(function(p){var m=h[l],g=d[p],y=h[p],b=m.distance+g.distance;b<y.distance&&(y.distance=b,y.predecessor=g.predecessor)})})}),a}return Oc}var Nc,Gg;function Vx(){if(Gg)return Nc;Gg=1;var e=Dt();Nc=r,r.CycleException=t;function r(n){var o={},i={},s=[];function a(c){if(e.has(i,c))throw new t;e.has(o,c)||(i[c]=!0,o[c]=!0,e.each(n.predecessors(c),a),delete i[c],s.push(c))}if(e.each(n.sinks(),a),e.size(o)!==n.nodeCount())throw new t;return s}function t(){}return t.prototype=new Error,Nc}var $c,Ug;function gS(){if(Ug)return $c;Ug=1;var e=Vx();$c=r;function r(t){try{e(t)}catch(n){if(n instanceof e.CycleException)return!1;throw n}return!0}return $c}var qc,Hg;function Wx(){if(Hg)return qc;Hg=1;var e=Dt();qc=r;function r(n,o,i){e.isArray(o)||(o=[o]);var s=(n.isDirected()?n.successors:n.neighbors).bind(n),a=[],c={};return e.each(o,function(l){if(!n.hasNode(l))throw new Error("Graph does not have node: "+l);t(n,l,i==="post",c,s,a)}),a}function t(n,o,i,s,a,c){e.has(s,o)||(s[o]=!0,i||c.push(o),e.each(a(o),function(l){t(n,l,i,s,a,c)}),i&&c.push(o))}return qc}var Lc,Kg;function yS(){if(Kg)return Lc;Kg=1;var e=Wx();Lc=r;function r(t,n){return e(t,n,"post")}return Lc}var Fc,Jg;function mS(){if(Jg)return Fc;Jg=1;var e=Wx();Fc=r;function r(t,n){return e(t,n,"pre")}return Fc}var zc,Zg;function bS(){if(Zg)return zc;Zg=1;var e=Dt(),r=au(),t=zx();zc=n;function n(o,i){var s=new r,a={},c=new t,l;function d(h){var p=h.v===l?h.w:h.v,m=c.priority(p);if(m!==void 0){var g=i(h);g<m&&(a[p]=l,c.decrease(p,g))}}if(o.nodeCount()===0)return s;e.each(o.nodes(),function(h){c.add(h,Number.POSITIVE_INFINITY),s.setNode(h)}),c.decrease(o.nodes()[0],0);for(var u=!1;c.size()>0;){if(l=c.removeMin(),e.has(a,l))s.setEdge(l,a[l]);else{if(u)throw new Error("Input graph is not connected: "+o);u=!0}o.nodeEdges(l).forEach(d)}return s}return zc}var Bc,Xg;function xS(){return Xg||(Xg=1,Bc={components:uS(),dijkstra:Bx(),dijkstraAll:fS(),findCycles:hS(),floydWarshall:pS(),isAcyclic:gS(),postorder:yS(),preorder:mS(),prim:bS(),tarjan:Dx(),topsort:Vx()}),Bc}var Dc,Yg;function vS(){if(Yg)return Dc;Yg=1;var e=lS();return Dc={Graph:e.Graph,json:dS(),alg:xS(),version:e.version},Dc}var Vc,Qg;function Ht(){if(Qg)return Vc;Qg=1;var e;if(typeof Wd=="function")try{e=vS()}catch{}return e||(e=window.graphlib),Vc=e,Vc}var Wc,ey;function wS(){if(ey)return Wc;ey=1;var e=gx(),r=1,t=4;function n(o){return e(o,r|t)}return Wc=n,Wc}var Gc,ty;function Fo(){if(ty)return Gc;ty=1;var e=an(),r=lr(),t=Po(),n=Bt();function o(i,s,a){if(!n(a))return!1;var c=typeof s;return(c=="number"?r(a)&&t(s,a.length):c=="string"&&s in a)?e(a[s],i):!1}return Gc=o,Gc}var Uc,ry;function CS(){if(ry)return Uc;ry=1;var e=Lo(),r=an(),t=Fo(),n=Br(),o=Object.prototype,i=o.hasOwnProperty,s=e(function(a,c){a=Object(a);var l=-1,d=c.length,u=d>2?c[2]:void 0;for(u&&t(c[0],c[1],u)&&(d=1);++l<d;)for(var h=c[l],p=n(h),m=-1,g=p.length;++m<g;){var y=p[m],b=a[y];(b===void 0||r(b,o[y])&&!i.call(a,y))&&(a[y]=h[y])}return a});return Uc=s,Uc}var Hc,ny;function SS(){if(ny)return Hc;ny=1;var e=dr(),r=lr(),t=Sr();function n(o){return function(i,s,a){var c=Object(i);if(!r(i)){var l=e(s,3);i=t(i),s=function(u){return l(c[u],u,c)}}var d=o(i,s,a);return d>-1?c[l?i[d]:d]:void 0}}return Hc=n,Hc}var Kc,oy;function jS(){if(oy)return Kc;oy=1;var e=/\s/;function r(t){for(var n=t.length;n--&&e.test(t.charAt(n)););return n}return Kc=r,Kc}var Jc,iy;function ES(){if(iy)return Jc;iy=1;var e=jS(),r=/^\s+/;function t(n){return n&&n.slice(0,e(n)+1).replace(r,"")}return Jc=t,Jc}var Zc,ay;function _S(){if(ay)return Zc;ay=1;var e=ES(),r=Bt(),t=dn(),n=NaN,o=/^[-+]0x[0-9a-f]+$/i,i=/^0b[01]+$/i,s=/^0o[0-7]+$/i,a=parseInt;function c(l){if(typeof l=="number")return l;if(t(l))return n;if(r(l)){var d=typeof l.valueOf=="function"?l.valueOf():l;l=r(d)?d+"":d}if(typeof l!="string")return l===0?l:+l;l=e(l);var u=i.test(l);return u||s.test(l)?a(l.slice(2),u?2:8):o.test(l)?n:+l}return Zc=c,Zc}var Xc,sy;function Gx(){if(sy)return Xc;sy=1;var e=_S(),r=1/0,t=17976931348623157e292;function n(o){if(!o)return o===0?o:0;if(o=e(o),o===r||o===-r){var i=o<0?-1:1;return i*t}return o===o?o:0}return Xc=n,Xc}var Yc,cy;function RS(){if(cy)return Yc;cy=1;var e=Gx();function r(t){var n=e(t),o=n%1;return n===n?o?n-o:n:0}return Yc=r,Yc}var Qc,ly;function kS(){if(ly)return Qc;ly=1;var e=qx(),r=dr(),t=RS(),n=Math.max;function o(i,s,a){var c=i==null?0:i.length;if(!c)return-1;var l=a==null?0:t(a);return l<0&&(l=n(c+l,0)),e(i,r(s,3),l)}return Qc=o,Qc}var el,dy;function AS(){if(dy)return el;dy=1;var e=SS(),r=kS(),t=e(r);return el=t,el}var tl,uy;function Ux(){if(uy)return tl;uy=1;var e=iu();function r(t){var n=t==null?0:t.length;return n?e(t,1):[]}return tl=r,tl}var rl,fy;function PS(){if(fy)return rl;fy=1;var e=tu(),r=yx(),t=Br();function n(o,i){return o==null?o:e(o,r(i),t)}return rl=n,rl}var nl,hy;function MS(){if(hy)return nl;hy=1;function e(r){var t=r==null?0:r.length;return t?r[t-1]:void 0}return nl=e,nl}var ol,py;function IS(){if(py)return ol;py=1;var e=ko(),r=ru(),t=dr();function n(o,i){var s={};return i=t(i,3),r(o,function(a,c,l){e(s,c,i(a,c,l))}),s}return ol=n,ol}var il,gy;function su(){if(gy)return il;gy=1;var e=dn();function r(t,n,o){for(var i=-1,s=t.length;++i<s;){var a=t[i],c=n(a);if(c!=null&&(l===void 0?c===c&&!e(c):o(c,l)))var l=c,d=a}return d}return il=r,il}var al,yy;function TS(){if(yy)return al;yy=1;function e(r,t){return r>t}return al=e,al}var sl,my;function OS(){if(my)return sl;my=1;var e=su(),r=TS(),t=Dr();function n(o){return o&&o.length?e(o,t,r):void 0}return sl=n,sl}var cl,by;function Hx(){if(by)return cl;by=1;var e=ko(),r=an();function t(n,o,i){(i!==void 0&&!r(n[o],i)||i===void 0&&!(o in n))&&e(n,o,i)}return cl=t,cl}var ll,xy;function NS(){if(xy)return ll;xy=1;var e=Fr(),r=To(),t=ir(),n="[object Object]",o=Function.prototype,i=Object.prototype,s=o.toString,a=i.hasOwnProperty,c=s.call(Object);function l(d){if(!t(d)||e(d)!=n)return!1;var u=r(d);if(u===null)return!0;var h=a.call(u,"constructor")&&u.constructor;return typeof h=="function"&&h instanceof h&&s.call(h)==c}return ll=l,ll}var dl,vy;function Kx(){if(vy)return dl;vy=1;function e(r,t){if(!(t==="constructor"&&typeof r[t]=="function")&&t!="__proto__")return r[t]}return dl=e,dl}var ul,wy;function $S(){if(wy)return ul;wy=1;var e=Bn(),r=Br();function t(n){return e(n,r(n))}return ul=t,ul}var fl,Cy;function qS(){if(Cy)return fl;Cy=1;var e=Hx(),r=nx(),t=fx(),n=ox(),o=px(),i=Dn(),s=bt(),a=Lx(),c=cn(),l=zn(),d=Bt(),u=NS(),h=Vn(),p=Kx(),m=$S();function g(y,b,x,v,w,C,S){var R=p(y,x),P=p(b,x),k=S.get(P);if(k){e(y,x,k);return}var T=C?C(R,P,x+"",y,b,S):void 0,E=T===void 0;if(E){var M=s(P),_=!M&&c(P),N=!M&&!_&&h(P);T=P,M||_||N?s(R)?T=R:a(R)?T=n(R):_?(E=!1,T=r(P,!0)):N?(E=!1,T=t(P,!0)):T=[]:u(P)||i(P)?(T=R,i(R)?T=m(R):(!d(R)||l(R))&&(T=o(P))):E=!1}E&&(S.set(P,T),w(T,P,v,C,S),S.delete(P)),e(y,x,T)}return fl=g,fl}var hl,Sy;function LS(){if(Sy)return hl;Sy=1;var e=Ro(),r=Hx(),t=tu(),n=qS(),o=Bt(),i=Br(),s=Kx();function a(c,l,d,u,h){c!==l&&t(l,function(p,m){if(h||(h=new e),o(p))n(c,l,m,d,a,u,h);else{var g=u?u(s(c,m),p,m+"",c,l,h):void 0;g===void 0&&(g=p),r(c,m,g)}},i)}return hl=a,hl}var pl,jy;function FS(){if(jy)return pl;jy=1;var e=Lo(),r=Fo();function t(n){return e(function(o,i){var s=-1,a=i.length,c=a>1?i[a-1]:void 0,l=a>2?i[2]:void 0;for(c=n.length>3&&typeof c=="function"?(a--,c):void 0,l&&r(i[0],i[1],l)&&(c=a<3?void 0:c,a=1),o=Object(o);++s<a;){var d=i[s];d&&n(o,d,s,c)}return o})}return pl=t,pl}var gl,Ey;function zS(){if(Ey)return gl;Ey=1;var e=LS(),r=FS(),t=r(function(n,o,i){e(n,o,i)});return gl=t,gl}var yl,_y;function Jx(){if(_y)return yl;_y=1;function e(r,t){return r<t}return yl=e,yl}var ml,Ry;function BS(){if(Ry)return ml;Ry=1;var e=su(),r=Jx(),t=Dr();function n(o){return o&&o.length?e(o,t,r):void 0}return ml=n,ml}var bl,ky;function DS(){if(ky)return bl;ky=1;var e=su(),r=dr(),t=Jx();function n(o,i){return o&&o.length?e(o,r(i,2),t):void 0}return bl=n,bl}var xl,Ay;function VS(){if(Ay)return xl;Ay=1;var e=Jt(),r=function(){return e.Date.now()};return xl=r,xl}var vl,Py;function WS(){if(Py)return vl;Py=1;var e=Ao(),r=$o(),t=Po(),n=Bt(),o=Wn();function i(s,a,c,l){if(!n(s))return s;a=r(a,s);for(var d=-1,u=a.length,h=u-1,p=s;p!=null&&++d<u;){var m=o(a[d]),g=c;if(m==="__proto__"||m==="constructor"||m==="prototype")return s;if(d!=h){var y=p[m];g=l?l(y,m,p):void 0,g===void 0&&(g=n(y)?y:t(a[d+1])?[]:{})}e(p,m,g),p=p[m]}return s}return vl=i,vl}var wl,My;function GS(){if(My)return wl;My=1;var e=qo(),r=WS(),t=$o();function n(o,i,s){for(var a=-1,c=i.length,l={};++a<c;){var d=i[a],u=e(o,d);s(u,d)&&r(l,t(d,o),u)}return l}return wl=n,wl}var Cl,Iy;function US(){if(Iy)return Cl;Iy=1;var e=GS(),r=Rx();function t(n,o){return e(n,o,function(i,s){return r(n,s)})}return Cl=t,Cl}var Sl,Ty;function HS(){if(Ty)return Sl;Ty=1;var e=Ux(),r=Nx(),t=$x();function n(o){return t(r(o,void 0,e),o+"")}return Sl=n,Sl}var jl,Oy;function KS(){if(Oy)return jl;Oy=1;var e=US(),r=HS(),t=r(function(n,o){return n==null?{}:e(n,o)});return jl=t,jl}var El,Ny;function JS(){if(Ny)return El;Ny=1;var e=Math.ceil,r=Math.max;function t(n,o,i,s){for(var a=-1,c=r(e((o-n)/(i||1)),0),l=Array(c);c--;)l[s?c:++a]=n,n+=i;return l}return El=t,El}var _l,$y;function ZS(){if($y)return _l;$y=1;var e=JS(),r=Fo(),t=Gx();function n(o){return function(i,s,a){return a&&typeof a!="number"&&r(i,s,a)&&(s=a=void 0),i=t(i),s===void 0?(s=i,i=0):s=t(s),a=a===void 0?i<s?1:-1:t(a),e(i,s,a,o)}}return _l=n,_l}var Rl,qy;function XS(){if(qy)return Rl;qy=1;var e=ZS(),r=e();return Rl=r,Rl}var kl,Ly;function YS(){if(Ly)return kl;Ly=1;function e(r,t){var n=r.length;for(r.sort(t);n--;)r[n]=r[n].value;return r}return kl=e,kl}var Al,Fy;function QS(){if(Fy)return Al;Fy=1;var e=dn();function r(t,n){if(t!==n){var o=t!==void 0,i=t===null,s=t===t,a=e(t),c=n!==void 0,l=n===null,d=n===n,u=e(n);if(!l&&!u&&!a&&t>n||a&&c&&d&&!l&&!u||i&&c&&d||!o&&d||!s)return 1;if(!i&&!a&&!u&&t<n||u&&o&&s&&!i&&!a||l&&o&&s||!c&&s||!d)return-1}return 0}return Al=r,Al}var Pl,zy;function ej(){if(zy)return Pl;zy=1;var e=QS();function r(t,n,o){for(var i=-1,s=t.criteria,a=n.criteria,c=s.length,l=o.length;++i<c;){var d=e(s[i],a[i]);if(d){if(i>=l)return d;var u=o[i];return d*(u=="desc"?-1:1)}}return t.index-n.index}return Pl=r,Pl}var Ml,By;function tj(){if(By)return Ml;By=1;var e=No(),r=qo(),t=dr(),n=Ix(),o=YS(),i=Mo(),s=ej(),a=Dr(),c=bt();function l(d,u,h){u.length?u=e(u,function(g){return c(g)?function(y){return r(y,g.length===1?g[0]:g)}:g}):u=[a];var p=-1;u=e(u,i(t));var m=n(d,function(g,y,b){var x=e(u,function(v){return v(g)});return{criteria:x,index:++p,value:g}});return o(m,function(g,y){return s(g,y,h)})}return Ml=l,Ml}var Il,Dy;function rj(){if(Dy)return Il;Dy=1;var e=iu(),r=tj(),t=Lo(),n=Fo(),o=t(function(i,s){if(i==null)return[];var a=s.length;return a>1&&n(i,s[0],s[1])?s=[]:a>2&&n(s[0],s[1],s[2])&&(s=[s[0]]),r(i,e(s,1),[])});return Il=o,Il}var Tl,Vy;function nj(){if(Vy)return Tl;Vy=1;var e=Ex(),r=0;function t(n){var o=++r;return e(n)+o}return Tl=t,Tl}var Ol,Wy;function oj(){if(Wy)return Ol;Wy=1;function e(r,t,n){for(var o=-1,i=r.length,s=t.length,a={};++o<i;){var c=o<s?t[o]:void 0;n(a,r[o],c)}return a}return Ol=e,Ol}var Nl,Gy;function ij(){if(Gy)return Nl;Gy=1;var e=Ao(),r=oj();function t(n,o){return r(n||[],o||[],e)}return Nl=t,Nl}var $l,Uy;function pt(){if(Uy)return $l;Uy=1;var e;if(typeof Wd=="function")try{e={cloneDeep:wS(),constant:eu(),defaults:CS(),each:bx(),filter:Ax(),find:AS(),flatten:Ux(),forEach:mx(),forIn:PS(),has:Px(),isUndefined:Mx(),last:MS(),map:Tx(),mapValues:IS(),max:OS(),merge:zS(),min:BS(),minBy:DS(),now:VS(),pick:KS(),range:XS(),reduce:Ox(),sortBy:rj(),uniqueId:nj(),values:Fx(),zipObject:ij()}}catch{}return e||(e=window._),$l=e,$l}var ql,Hy;function aj(){if(Hy)return ql;Hy=1,ql=e;function e(){var n={};n._next=n._prev=n,this._sentinel=n}e.prototype.dequeue=function(){var n=this._sentinel,o=n._prev;if(o!==n)return r(o),o},e.prototype.enqueue=function(n){var o=this._sentinel;n._prev&&n._next&&r(n),n._next=o._next,o._next._prev=n,o._next=n,n._prev=o},e.prototype.toString=function(){for(var n=[],o=this._sentinel,i=o._prev;i!==o;)n.push(JSON.stringify(i,t)),i=i._prev;return"["+n.join(", ")+"]"};function r(n){n._prev._next=n._next,n._next._prev=n._prev,delete n._next,delete n._prev}function t(n,o){if(n!=="_next"&&n!=="_prev")return o}return ql}var Ll,Ky;function sj(){if(Ky)return Ll;Ky=1;var e=pt(),r=Ht().Graph,t=aj();Ll=o;var n=e.constant(1);function o(l,d){if(l.nodeCount()<=1)return[];var u=a(l,d||n),h=i(u.graph,u.buckets,u.zeroIdx);return e.flatten(e.map(h,function(p){return l.outEdges(p.v,p.w)}),!0)}function i(l,d,u){for(var h=[],p=d[d.length-1],m=d[0],g;l.nodeCount();){for(;g=m.dequeue();)s(l,d,u,g);for(;g=p.dequeue();)s(l,d,u,g);if(l.nodeCount()){for(var y=d.length-2;y>0;--y)if(g=d[y].dequeue(),g){h=h.concat(s(l,d,u,g,!0));break}}}return h}function s(l,d,u,h,p){var m=p?[]:void 0;return e.forEach(l.inEdges(h.v),function(g){var y=l.edge(g),b=l.node(g.v);p&&m.push({v:g.v,w:g.w}),b.out-=y,c(d,u,b)}),e.forEach(l.outEdges(h.v),function(g){var y=l.edge(g),b=g.w,x=l.node(b);x.in-=y,c(d,u,x)}),l.removeNode(h.v),m}function a(l,d){var u=new r,h=0,p=0;e.forEach(l.nodes(),function(y){u.setNode(y,{v:y,in:0,out:0})}),e.forEach(l.edges(),function(y){var b=u.edge(y.v,y.w)||0,x=d(y),v=b+x;u.setEdge(y.v,y.w,v),p=Math.max(p,u.node(y.v).out+=x),h=Math.max(h,u.node(y.w).in+=x)});var m=e.range(p+h+3).map(function(){return new t}),g=h+1;return e.forEach(u.nodes(),function(y){c(m,g,u.node(y))}),{graph:u,buckets:m,zeroIdx:g}}function c(l,d,u){u.out?u.in?l[u.out-u.in+d].enqueue(u):l[l.length-1].enqueue(u):l[0].enqueue(u)}return Ll}var Fl,Jy;function cj(){if(Jy)return Fl;Jy=1;var e=pt(),r=sj();Fl={run:t,undo:o};function t(i){var s=i.graph().acyclicer==="greedy"?r(i,a(i)):n(i);e.forEach(s,function(c){var l=i.edge(c);i.removeEdge(c),l.forwardName=c.name,l.reversed=!0,i.setEdge(c.w,c.v,l,e.uniqueId("rev"))});function a(c){return function(l){return c.edge(l).weight}}}function n(i){var s=[],a={},c={};function l(d){e.has(c,d)||(c[d]=!0,a[d]=!0,e.forEach(i.outEdges(d),function(u){e.has(a,u.w)?s.push(u):l(u.w)}),delete a[d])}return e.forEach(i.nodes(),l),s}function o(i){e.forEach(i.edges(),function(s){var a=i.edge(s);if(a.reversed){i.removeEdge(s);var c=a.forwardName;delete a.reversed,delete a.forwardName,i.setEdge(s.w,s.v,a,c)}})}return Fl}var zl,Zy;function At(){if(Zy)return zl;Zy=1;var e=pt(),r=Ht().Graph;zl={addDummyNode:t,simplify:n,asNonCompoundGraph:o,successorWeights:i,predecessorWeights:s,intersectRect:a,buildLayerMatrix:c,normalizeRanks:l,removeEmptyRanks:d,addBorderNode:u,maxRank:h,partition:p,time:m,notime:g};function t(y,b,x,v){var w;do w=e.uniqueId(v);while(y.hasNode(w));return x.dummy=b,y.setNode(w,x),w}function n(y){var b=new r().setGraph(y.graph());return e.forEach(y.nodes(),function(x){b.setNode(x,y.node(x))}),e.forEach(y.edges(),function(x){var v=b.edge(x.v,x.w)||{weight:0,minlen:1},w=y.edge(x);b.setEdge(x.v,x.w,{weight:v.weight+w.weight,minlen:Math.max(v.minlen,w.minlen)})}),b}function o(y){var b=new r({multigraph:y.isMultigraph()}).setGraph(y.graph());return e.forEach(y.nodes(),function(x){y.children(x).length||b.setNode(x,y.node(x))}),e.forEach(y.edges(),function(x){b.setEdge(x,y.edge(x))}),b}function i(y){var b=e.map(y.nodes(),function(x){var v={};return e.forEach(y.outEdges(x),function(w){v[w.w]=(v[w.w]||0)+y.edge(w).weight}),v});return e.zipObject(y.nodes(),b)}function s(y){var b=e.map(y.nodes(),function(x){var v={};return e.forEach(y.inEdges(x),function(w){v[w.v]=(v[w.v]||0)+y.edge(w).weight}),v});return e.zipObject(y.nodes(),b)}function a(y,b){var x=y.x,v=y.y,w=b.x-x,C=b.y-v,S=y.width/2,R=y.height/2;if(!w&&!C)throw new Error("Not possible to find intersection inside of the rectangle");var P,k;return Math.abs(C)*S>Math.abs(w)*R?(C<0&&(R=-R),P=R*w/C,k=R):(w<0&&(S=-S),P=S,k=S*C/w),{x:x+P,y:v+k}}function c(y){var b=e.map(e.range(h(y)+1),function(){return[]});return e.forEach(y.nodes(),function(x){var v=y.node(x),w=v.rank;e.isUndefined(w)||(b[w][v.order]=x)}),b}function l(y){var b=e.min(e.map(y.nodes(),function(x){return y.node(x).rank}));e.forEach(y.nodes(),function(x){var v=y.node(x);e.has(v,"rank")&&(v.rank-=b)})}function d(y){var b=e.min(e.map(y.nodes(),function(C){return y.node(C).rank})),x=[];e.forEach(y.nodes(),function(C){var S=y.node(C).rank-b;x[S]||(x[S]=[]),x[S].push(C)});var v=0,w=y.graph().nodeRankFactor;e.forEach(x,function(C,S){e.isUndefined(C)&&S%w!==0?--v:v&&e.forEach(C,function(R){y.node(R).rank+=v})})}function u(y,b,x,v){var w={width:0,height:0};return arguments.length>=4&&(w.rank=x,w.order=v),t(y,"border",w,b)}function h(y){return e.max(e.map(y.nodes(),function(b){var x=y.node(b).rank;if(!e.isUndefined(x))return x}))}function p(y,b){var x={lhs:[],rhs:[]};return e.forEach(y,function(v){b(v)?x.lhs.push(v):x.rhs.push(v)}),x}function m(y,b){var x=e.now();try{return b()}finally{console.log(y+" time: "+(e.now()-x)+"ms")}}function g(y,b){return b()}return zl}var Bl,Xy;function lj(){if(Xy)return Bl;Xy=1;var e=pt(),r=At();Bl={run:t,undo:o};function t(i){i.graph().dummyChains=[],e.forEach(i.edges(),function(s){n(i,s)})}function n(i,s){var a=s.v,c=i.node(a).rank,l=s.w,d=i.node(l).rank,u=s.name,h=i.edge(s),p=h.labelRank;if(d!==c+1){i.removeEdge(s);var m,g,y;for(y=0,++c;c<d;++y,++c)h.points=[],g={width:0,height:0,edgeLabel:h,edgeObj:s,rank:c},m=r.addDummyNode(i,"edge",g,"_d"),c===p&&(g.width=h.width,g.height=h.height,g.dummy="edge-label",g.labelpos=h.labelpos),i.setEdge(a,m,{weight:h.weight},u),y===0&&i.graph().dummyChains.push(m),a=m;i.setEdge(a,l,{weight:h.weight},u)}}function o(i){e.forEach(i.graph().dummyChains,function(s){var a=i.node(s),c=a.edgeLabel,l;for(i.setEdge(a.edgeObj,c);a.dummy;)l=i.successors(s)[0],i.removeNode(s),c.points.push({x:a.x,y:a.y}),a.dummy==="edge-label"&&(c.x=a.x,c.y=a.y,c.width=a.width,c.height=a.height),s=l,a=i.node(s)})}return Bl}var Dl,Yy;function lo(){if(Yy)return Dl;Yy=1;var e=pt();Dl={longestPath:r,slack:t};function r(n){var o={};function i(s){var a=n.node(s);if(e.has(o,s))return a.rank;o[s]=!0;var c=e.min(e.map(n.outEdges(s),function(l){return i(l.w)-n.edge(l).minlen}));return(c===Number.POSITIVE_INFINITY||c===void 0||c===null)&&(c=0),a.rank=c}e.forEach(n.sources(),i)}function t(n,o){return n.node(o.w).rank-n.node(o.v).rank-n.edge(o).minlen}return Dl}var Vl,Qy;function Zx(){if(Qy)return Vl;Qy=1;var e=pt(),r=Ht().Graph,t=lo().slack;Vl=n;function n(a){var c=new r({directed:!1}),l=a.nodes()[0],d=a.nodeCount();c.setNode(l,{});for(var u,h;o(c,a)<d;)u=i(c,a),h=c.hasNode(u.v)?t(a,u):-t(a,u),s(c,a,h);return c}function o(a,c){function l(d){e.forEach(c.nodeEdges(d),function(u){var h=u.v,p=d===h?u.w:h;!a.hasNode(p)&&!t(c,u)&&(a.setNode(p,{}),a.setEdge(d,p,{}),l(p))})}return e.forEach(a.nodes(),l),a.nodeCount()}function i(a,c){return e.minBy(c.edges(),function(l){if(a.hasNode(l.v)!==a.hasNode(l.w))return t(c,l)})}function s(a,c,l){e.forEach(a.nodes(),function(d){c.node(d).rank+=l})}return Vl}var Wl,em;function dj(){if(em)return Wl;em=1;var e=pt(),r=Zx(),t=lo().slack,n=lo().longestPath,o=Ht().alg.preorder,i=Ht().alg.postorder,s=At().simplify;Wl=a,a.initLowLimValues=u,a.initCutValues=c,a.calcCutValue=d,a.leaveEdge=p,a.enterEdge=m,a.exchangeEdges=g;function a(v){v=s(v),n(v);var w=r(v);u(w),c(w,v);for(var C,S;C=p(w);)S=m(w,v,C),g(w,v,C,S)}function c(v,w){var C=i(v,v.nodes());C=C.slice(0,C.length-1),e.forEach(C,function(S){l(v,w,S)})}function l(v,w,C){var S=v.node(C),R=S.parent;v.edge(C,R).cutvalue=d(v,w,C)}function d(v,w,C){var S=v.node(C),R=S.parent,P=!0,k=w.edge(C,R),T=0;return k||(P=!1,k=w.edge(R,C)),T=k.weight,e.forEach(w.nodeEdges(C),function(E){var M=E.v===C,_=M?E.w:E.v;if(_!==R){var N=M===P,$=w.edge(E).weight;if(T+=N?$:-$,b(v,C,_)){var B=v.edge(C,_).cutvalue;T+=N?-B:B}}}),T}function u(v,w){arguments.length<2&&(w=v.nodes()[0]),h(v,{},1,w)}function h(v,w,C,S,R){var P=C,k=v.node(S);return w[S]=!0,e.forEach(v.neighbors(S),function(T){e.has(w,T)||(C=h(v,w,C,T,S))}),k.low=P,k.lim=C++,R?k.parent=R:delete k.parent,C}function p(v){return e.find(v.edges(),function(w){return v.edge(w).cutvalue<0})}function m(v,w,C){var S=C.v,R=C.w;w.hasEdge(S,R)||(S=C.w,R=C.v);var P=v.node(S),k=v.node(R),T=P,E=!1;P.lim>k.lim&&(T=k,E=!0);var M=e.filter(w.edges(),function(_){return E===x(v,v.node(_.v),T)&&E!==x(v,v.node(_.w),T)});return e.minBy(M,function(_){return t(w,_)})}function g(v,w,C,S){var R=C.v,P=C.w;v.removeEdge(R,P),v.setEdge(S.v,S.w,{}),u(v),c(v,w),y(v,w)}function y(v,w){var C=e.find(v.nodes(),function(R){return!w.node(R).parent}),S=o(v,C);S=S.slice(1),e.forEach(S,function(R){var P=v.node(R).parent,k=w.edge(R,P),T=!1;k||(k=w.edge(P,R),T=!0),w.node(R).rank=w.node(P).rank+(T?k.minlen:-k.minlen)})}function b(v,w,C){return v.hasEdge(w,C)}function x(v,w,C){return C.low<=w.lim&&w.lim<=C.lim}return Wl}var Gl,tm;function uj(){if(tm)return Gl;tm=1;var e=lo(),r=e.longestPath,t=Zx(),n=dj();Gl=o;function o(c){switch(c.graph().ranker){case"network-simplex":a(c);break;case"tight-tree":s(c);break;case"longest-path":i(c);break;default:a(c)}}var i=r;function s(c){r(c),t(c)}function a(c){n(c)}return Gl}var Ul,rm;function fj(){if(rm)return Ul;rm=1;var e=pt();Ul=r;function r(o){var i=n(o);e.forEach(o.graph().dummyChains,function(s){for(var a=o.node(s),c=a.edgeObj,l=t(o,i,c.v,c.w),d=l.path,u=l.lca,h=0,p=d[h],m=!0;s!==c.w;){if(a=o.node(s),m){for(;(p=d[h])!==u&&o.node(p).maxRank<a.rank;)h++;p===u&&(m=!1)}if(!m){for(;h<d.length-1&&o.node(p=d[h+1]).minRank<=a.rank;)h++;p=d[h]}o.setParent(s,p),s=o.successors(s)[0]}})}function t(o,i,s,a){var c=[],l=[],d=Math.min(i[s].low,i[a].low),u=Math.max(i[s].lim,i[a].lim),h,p;h=s;do h=o.parent(h),c.push(h);while(h&&(i[h].low>d||u>i[h].lim));for(p=h,h=a;(h=o.parent(h))!==p;)l.push(h);return{path:c.concat(l.reverse()),lca:p}}function n(o){var i={},s=0;function a(c){var l=s;e.forEach(o.children(c),a),i[c]={low:l,lim:s++}}return e.forEach(o.children(),a),i}return Ul}var Hl,nm;function hj(){if(nm)return Hl;nm=1;var e=pt(),r=At();Hl={run:t,cleanup:s};function t(a){var c=r.addDummyNode(a,"root",{},"_root"),l=o(a),d=e.max(e.values(l))-1,u=2*d+1;a.graph().nestingRoot=c,e.forEach(a.edges(),function(p){a.edge(p).minlen*=u});var h=i(a)+1;e.forEach(a.children(),function(p){n(a,c,u,h,d,l,p)}),a.graph().nodeRankFactor=u}function n(a,c,l,d,u,h,p){var m=a.children(p);if(!m.length){p!==c&&a.setEdge(c,p,{weight:0,minlen:l});return}var g=r.addBorderNode(a,"_bt"),y=r.addBorderNode(a,"_bb"),b=a.node(p);a.setParent(g,p),b.borderTop=g,a.setParent(y,p),b.borderBottom=y,e.forEach(m,function(x){n(a,c,l,d,u,h,x);var v=a.node(x),w=v.borderTop?v.borderTop:x,C=v.borderBottom?v.borderBottom:x,S=v.borderTop?d:2*d,R=w!==C?1:u-h[p]+1;a.setEdge(g,w,{weight:S,minlen:R,nestingEdge:!0}),a.setEdge(C,y,{weight:S,minlen:R,nestingEdge:!0})}),a.parent(p)||a.setEdge(c,g,{weight:0,minlen:u+h[p]})}function o(a){var c={};function l(d,u){var h=a.children(d);h&&h.length&&e.forEach(h,function(p){l(p,u+1)}),c[d]=u}return e.forEach(a.children(),function(d){l(d,1)}),c}function i(a){return e.reduce(a.edges(),function(c,l){return c+a.edge(l).weight},0)}function s(a){var c=a.graph();a.removeNode(c.nestingRoot),delete c.nestingRoot,e.forEach(a.edges(),function(l){var d=a.edge(l);d.nestingEdge&&a.removeEdge(l)})}return Hl}var Kl,om;function pj(){if(om)return Kl;om=1;var e=pt(),r=At();Kl=t;function t(o){function i(s){var a=o.children(s),c=o.node(s);if(a.length&&e.forEach(a,i),e.has(c,"minRank")){c.borderLeft=[],c.borderRight=[];for(var l=c.minRank,d=c.maxRank+1;l<d;++l)n(o,"borderLeft","_bl",s,c,l),n(o,"borderRight","_br",s,c,l)}}e.forEach(o.children(),i)}function n(o,i,s,a,c,l){var d={width:0,height:0,rank:l,borderType:i},u=c[i][l-1],h=r.addDummyNode(o,"border",d,s);c[i][l]=h,o.setParent(h,a),u&&o.setEdge(u,h,{weight:1})}return Kl}var Jl,im;function gj(){if(im)return Jl;im=1;var e=pt();Jl={adjust:r,undo:t};function r(l){var d=l.graph().rankdir.toLowerCase();(d==="lr"||d==="rl")&&n(l)}function t(l){var d=l.graph().rankdir.toLowerCase();(d==="bt"||d==="rl")&&i(l),(d==="lr"||d==="rl")&&(a(l),n(l))}function n(l){e.forEach(l.nodes(),function(d){o(l.node(d))}),e.forEach(l.edges(),function(d){o(l.edge(d))})}function o(l){var d=l.width;l.width=l.height,l.height=d}function i(l){e.forEach(l.nodes(),function(d){s(l.node(d))}),e.forEach(l.edges(),function(d){var u=l.edge(d);e.forEach(u.points,s),e.has(u,"y")&&s(u)})}function s(l){l.y=-l.y}function a(l){e.forEach(l.nodes(),function(d){c(l.node(d))}),e.forEach(l.edges(),function(d){var u=l.edge(d);e.forEach(u.points,c),e.has(u,"x")&&c(u)})}function c(l){var d=l.x;l.x=l.y,l.y=d}return Jl}var Zl,am;function yj(){if(am)return Zl;am=1;var e=pt();Zl=r;function r(t){var n={},o=e.filter(t.nodes(),function(l){return!t.children(l).length}),i=e.max(e.map(o,function(l){return t.node(l).rank})),s=e.map(e.range(i+1),function(){return[]});function a(l){if(!e.has(n,l)){n[l]=!0;var d=t.node(l);s[d.rank].push(l),e.forEach(t.successors(l),a)}}var c=e.sortBy(o,function(l){return t.node(l).rank});return e.forEach(c,a),s}return Zl}var Xl,sm;function mj(){if(sm)return Xl;sm=1;var e=pt();Xl=r;function r(n,o){for(var i=0,s=1;s<o.length;++s)i+=t(n,o[s-1],o[s]);return i}function t(n,o,i){for(var s=e.zipObject(i,e.map(i,function(h,p){return p})),a=e.flatten(e.map(o,function(h){return e.sortBy(e.map(n.outEdges(h),function(p){return{pos:s[p.w],weight:n.edge(p).weight}}),"pos")}),!0),c=1;c<i.length;)c<<=1;var l=2*c-1;c-=1;var d=e.map(new Array(l),function(){return 0}),u=0;return e.forEach(a.forEach(function(h){var p=h.pos+c;d[p]+=h.weight;for(var m=0;p>0;)p%2&&(m+=d[p+1]),p=p-1>>1,d[p]+=h.weight;u+=h.weight*m})),u}return Xl}var Yl,cm;function bj(){if(cm)return Yl;cm=1;var e=pt();Yl=r;function r(t,n){return e.map(n,function(o){var i=t.inEdges(o);if(i.length){var s=e.reduce(i,function(a,c){var l=t.edge(c),d=t.node(c.v);return{sum:a.sum+l.weight*d.order,weight:a.weight+l.weight}},{sum:0,weight:0});return{v:o,barycenter:s.sum/s.weight,weight:s.weight}}else return{v:o}})}return Yl}var Ql,lm;function xj(){if(lm)return Ql;lm=1;var e=pt();Ql=r;function r(o,i){var s={};e.forEach(o,function(c,l){var d=s[c.v]={indegree:0,in:[],out:[],vs:[c.v],i:l};e.isUndefined(c.barycenter)||(d.barycenter=c.barycenter,d.weight=c.weight)}),e.forEach(i.edges(),function(c){var l=s[c.v],d=s[c.w];!e.isUndefined(l)&&!e.isUndefined(d)&&(d.indegree++,l.out.push(s[c.w]))});var a=e.filter(s,function(c){return!c.indegree});return t(a)}function t(o){var i=[];function s(l){return function(d){d.merged||(e.isUndefined(d.barycenter)||e.isUndefined(l.barycenter)||d.barycenter>=l.barycenter)&&n(l,d)}}function a(l){return function(d){d.in.push(l),--d.indegree===0&&o.push(d)}}for(;o.length;){var c=o.pop();i.push(c),e.forEach(c.in.reverse(),s(c)),e.forEach(c.out,a(c))}return e.map(e.filter(i,function(l){return!l.merged}),function(l){return e.pick(l,["vs","i","barycenter","weight"])})}function n(o,i){var s=0,a=0;o.weight&&(s+=o.barycenter*o.weight,a+=o.weight),i.weight&&(s+=i.barycenter*i.weight,a+=i.weight),o.vs=i.vs.concat(o.vs),o.barycenter=s/a,o.weight=a,o.i=Math.min(i.i,o.i),i.merged=!0}return Ql}var ed,dm;function vj(){if(dm)return ed;dm=1;var e=pt(),r=At();ed=t;function t(i,s){var a=r.partition(i,function(g){return e.has(g,"barycenter")}),c=a.lhs,l=e.sortBy(a.rhs,function(g){return-g.i}),d=[],u=0,h=0,p=0;c.sort(o(!!s)),p=n(d,l,p),e.forEach(c,function(g){p+=g.vs.length,d.push(g.vs),u+=g.barycenter*g.weight,h+=g.weight,p=n(d,l,p)});var m={vs:e.flatten(d,!0)};return h&&(m.barycenter=u/h,m.weight=h),m}function n(i,s,a){for(var c;s.length&&(c=e.last(s)).i<=a;)s.pop(),i.push(c.vs),a++;return a}function o(i){return function(s,a){return s.barycenter<a.barycenter?-1:s.barycenter>a.barycenter?1:i?a.i-s.i:s.i-a.i}}return ed}var td,um;function wj(){if(um)return td;um=1;var e=pt(),r=bj(),t=xj(),n=vj();td=o;function o(a,c,l,d){var u=a.children(c),h=a.node(c),p=h?h.borderLeft:void 0,m=h?h.borderRight:void 0,g={};p&&(u=e.filter(u,function(C){return C!==p&&C!==m}));var y=r(a,u);e.forEach(y,function(C){if(a.children(C.v).length){var S=o(a,C.v,l,d);g[C.v]=S,e.has(S,"barycenter")&&s(C,S)}});var b=t(y,l);i(b,g);var x=n(b,d);if(p&&(x.vs=e.flatten([p,x.vs,m],!0),a.predecessors(p).length)){var v=a.node(a.predecessors(p)[0]),w=a.node(a.predecessors(m)[0]);e.has(x,"barycenter")||(x.barycenter=0,x.weight=0),x.barycenter=(x.barycenter*x.weight+v.order+w.order)/(x.weight+2),x.weight+=2}return x}function i(a,c){e.forEach(a,function(l){l.vs=e.flatten(l.vs.map(function(d){return c[d]?c[d].vs:d}),!0)})}function s(a,c){e.isUndefined(a.barycenter)?(a.barycenter=c.barycenter,a.weight=c.weight):(a.barycenter=(a.barycenter*a.weight+c.barycenter*c.weight)/(a.weight+c.weight),a.weight+=c.weight)}return td}var rd,fm;function Cj(){if(fm)return rd;fm=1;var e=pt(),r=Ht().Graph;rd=t;function t(o,i,s){var a=n(o),c=new r({compound:!0}).setGraph({root:a}).setDefaultNodeLabel(function(l){return o.node(l)});return e.forEach(o.nodes(),function(l){var d=o.node(l),u=o.parent(l);(d.rank===i||d.minRank<=i&&i<=d.maxRank)&&(c.setNode(l),c.setParent(l,u||a),e.forEach(o[s](l),function(h){var p=h.v===l?h.w:h.v,m=c.edge(p,l),g=e.isUndefined(m)?0:m.weight;c.setEdge(p,l,{weight:o.edge(h).weight+g})}),e.has(d,"minRank")&&c.setNode(l,{borderLeft:d.borderLeft[i],borderRight:d.borderRight[i]}))}),c}function n(o){for(var i;o.hasNode(i=e.uniqueId("_root")););return i}return rd}var nd,hm;function Sj(){if(hm)return nd;hm=1;var e=pt();nd=r;function r(t,n,o){var i={},s;e.forEach(o,function(a){for(var c=t.parent(a),l,d;c;){if(l=t.parent(c),l?(d=i[l],i[l]=c):(d=s,s=c),d&&d!==c){n.setEdge(d,c);return}c=l}})}return nd}var od,pm;function jj(){if(pm)return od;pm=1;var e=pt(),r=yj(),t=mj(),n=wj(),o=Cj(),i=Sj(),s=Ht().Graph,a=At();od=c;function c(h){var p=a.maxRank(h),m=l(h,e.range(1,p+1),"inEdges"),g=l(h,e.range(p-1,-1,-1),"outEdges"),y=r(h);u(h,y);for(var b=Number.POSITIVE_INFINITY,x,v=0,w=0;w<4;++v,++w){d(v%2?m:g,v%4>=2),y=a.buildLayerMatrix(h);var C=t(h,y);C<b&&(w=0,x=e.cloneDeep(y),b=C)}u(h,x)}function l(h,p,m){return e.map(p,function(g){return o(h,g,m)})}function d(h,p){var m=new s;e.forEach(h,function(g){var y=g.graph().root,b=n(g,y,m,p);e.forEach(b.vs,function(x,v){g.node(x).order=v}),i(g,m,b.vs)})}function u(h,p){e.forEach(p,function(m){e.forEach(m,function(g,y){h.node(g).order=y})})}return od}var id,gm;function Ej(){if(gm)return id;gm=1;var e=pt(),r=Ht().Graph,t=At();id={positionX:m,findType1Conflicts:n,findType2Conflicts:o,addConflict:s,hasConflict:a,verticalAlignment:c,horizontalCompaction:l,alignCoordinates:h,findSmallestWidthAlignment:u,balance:p};function n(b,x){var v={};function w(C,S){var R=0,P=0,k=C.length,T=e.last(S);return e.forEach(S,function(E,M){var _=i(b,E),N=_?b.node(_).order:k;(_||E===T)&&(e.forEach(S.slice(P,M+1),function($){e.forEach(b.predecessors($),function(B){var O=b.node(B),I=O.order;(I<R||N<I)&&!(O.dummy&&b.node($).dummy)&&s(v,B,$)})}),P=M+1,R=N)}),S}return e.reduce(x,w),v}function o(b,x){var v={};function w(S,R,P,k,T){var E;e.forEach(e.range(R,P),function(M){E=S[M],b.node(E).dummy&&e.forEach(b.predecessors(E),function(_){var N=b.node(_);N.dummy&&(N.order<k||N.order>T)&&s(v,_,E)})})}function C(S,R){var P=-1,k,T=0;return e.forEach(R,function(E,M){if(b.node(E).dummy==="border"){var _=b.predecessors(E);_.length&&(k=b.node(_[0]).order,w(R,T,M,P,k),T=M,P=k)}w(R,T,R.length,k,S.length)}),R}return e.reduce(x,C),v}function i(b,x){if(b.node(x).dummy)return e.find(b.predecessors(x),function(v){return b.node(v).dummy})}function s(b,x,v){if(x>v){var w=x;x=v,v=w}var C=b[x];C||(b[x]=C={}),C[v]=!0}function a(b,x,v){if(x>v){var w=x;x=v,v=w}return e.has(b[x],v)}function c(b,x,v,w){var C={},S={},R={};return e.forEach(x,function(P){e.forEach(P,function(k,T){C[k]=k,S[k]=k,R[k]=T})}),e.forEach(x,function(P){var k=-1;e.forEach(P,function(T){var E=w(T);if(E.length){E=e.sortBy(E,function(B){return R[B]});for(var M=(E.length-1)/2,_=Math.floor(M),N=Math.ceil(M);_<=N;++_){var $=E[_];S[T]===T&&k<R[$]&&!a(v,T,$)&&(S[$]=T,S[T]=C[T]=C[$],k=R[$])}}})}),{root:C,align:S}}function l(b,x,v,w,C){var S={},R=d(b,x,v,C),P=C?"borderLeft":"borderRight";function k(M,_){for(var N=R.nodes(),$=N.pop(),B={};$;)B[$]?M($):(B[$]=!0,N.push($),N=N.concat(_($))),$=N.pop()}function T(M){S[M]=R.inEdges(M).reduce(function(_,N){return Math.max(_,S[N.v]+R.edge(N))},0)}function E(M){var _=R.outEdges(M).reduce(function($,B){return Math.min($,S[B.w]-R.edge(B))},Number.POSITIVE_INFINITY),N=b.node(M);_!==Number.POSITIVE_INFINITY&&N.borderType!==P&&(S[M]=Math.max(S[M],_))}return k(T,R.predecessors.bind(R)),k(E,R.successors.bind(R)),e.forEach(w,function(M){S[M]=S[v[M]]}),S}function d(b,x,v,w){var C=new r,S=b.graph(),R=g(S.nodesep,S.edgesep,w);return e.forEach(x,function(P){var k;e.forEach(P,function(T){var E=v[T];if(C.setNode(E),k){var M=v[k],_=C.edge(M,E);C.setEdge(M,E,Math.max(R(b,T,k),_||0))}k=T})}),C}function u(b,x){return e.minBy(e.values(x),function(v){var w=Number.NEGATIVE_INFINITY,C=Number.POSITIVE_INFINITY;return e.forIn(v,function(S,R){var P=y(b,R)/2;w=Math.max(S+P,w),C=Math.min(S-P,C)}),w-C})}function h(b,x){var v=e.values(x),w=e.min(v),C=e.max(v);e.forEach(["u","d"],function(S){e.forEach(["l","r"],function(R){var P=S+R,k=b[P],T;if(k!==x){var E=e.values(k);T=R==="l"?w-e.min(E):C-e.max(E),T&&(b[P]=e.mapValues(k,function(M){return M+T}))}})})}function p(b,x){return e.mapValues(b.ul,function(v,w){if(x)return b[x.toLowerCase()][w];var C=e.sortBy(e.map(b,w));return(C[1]+C[2])/2})}function m(b){var x=t.buildLayerMatrix(b),v=e.merge(n(b,x),o(b,x)),w={},C;e.forEach(["u","d"],function(R){C=R==="u"?x:e.values(x).reverse(),e.forEach(["l","r"],function(P){P==="r"&&(C=e.map(C,function(M){return e.values(M).reverse()}));var k=(R==="u"?b.predecessors:b.successors).bind(b),T=c(b,C,v,k),E=l(b,C,T.root,T.align,P==="r");P==="r"&&(E=e.mapValues(E,function(M){return-M})),w[R+P]=E})});var S=u(b,w);return h(w,S),p(w,b.graph().align)}function g(b,x,v){return function(w,C,S){var R=w.node(C),P=w.node(S),k=0,T;if(k+=R.width/2,e.has(R,"labelpos"))switch(R.labelpos.toLowerCase()){case"l":T=-R.width/2;break;case"r":T=R.width/2;break}if(T&&(k+=v?T:-T),T=0,k+=(R.dummy?x:b)/2,k+=(P.dummy?x:b)/2,k+=P.width/2,e.has(P,"labelpos"))switch(P.labelpos.toLowerCase()){case"l":T=P.width/2;break;case"r":T=-P.width/2;break}return T&&(k+=v?T:-T),T=0,k}}function y(b,x){return b.node(x).width}return id}var ad,ym;function _j(){if(ym)return ad;ym=1;var e=pt(),r=At(),t=Ej().positionX;ad=n;function n(i){i=r.asNonCompoundGraph(i),o(i),e.forEach(t(i),function(s,a){i.node(a).x=s})}function o(i){var s=r.buildLayerMatrix(i),a=i.graph().ranksep,c=0;e.forEach(s,function(l){var d=e.max(e.map(l,function(u){return i.node(u).height}));e.forEach(l,function(u){i.node(u).y=c+d/2}),c+=d+a})}return ad}var sd,mm;function Rj(){if(mm)return sd;mm=1;var e=pt(),r=cj(),t=lj(),n=uj(),o=At().normalizeRanks,i=fj(),s=At().removeEmptyRanks,a=hj(),c=pj(),l=gj(),d=jj(),u=_j(),h=At(),p=Ht().Graph;sd=m;function m(q,F){var G=F&&F.debugTiming?h.time:h.notime;G("layout",function(){var D=G(" buildLayoutGraph",function(){return k(q)});G(" runLayout",function(){g(D,G)}),G(" updateInputGraph",function(){y(q,D)})})}function g(q,F){F(" makeSpaceForEdgeLabels",function(){T(q)}),F(" removeSelfEdges",function(){ee(q)}),F(" acyclic",function(){r.run(q)}),F(" nestingGraph.run",function(){a.run(q)}),F(" rank",function(){n(h.asNonCompoundGraph(q))}),F(" injectEdgeLabelProxies",function(){E(q)}),F(" removeEmptyRanks",function(){s(q)}),F(" nestingGraph.cleanup",function(){a.cleanup(q)}),F(" normalizeRanks",function(){o(q)}),F(" assignRankMinMax",function(){M(q)}),F(" removeEdgeLabelProxies",function(){_(q)}),F(" normalize.run",function(){t.run(q)}),F(" parentDummyChains",function(){i(q)}),F(" addBorderSegments",function(){c(q)}),F(" order",function(){d(q)}),F(" insertSelfEdges",function(){ae(q)}),F(" adjustCoordinateSystem",function(){l.adjust(q)}),F(" position",function(){u(q)}),F(" positionSelfEdges",function(){ne(q)}),F(" removeBorderNodes",function(){I(q)}),F(" normalize.undo",function(){t.undo(q)}),F(" fixupEdgeLabelCoords",function(){B(q)}),F(" undoCoordinateSystem",function(){l.undo(q)}),F(" translateGraph",function(){N(q)}),F(" assignNodeIntersects",function(){$(q)}),F(" reversePoints",function(){O(q)}),F(" acyclic.undo",function(){r.undo(q)})}function y(q,F){e.forEach(q.nodes(),function(G){var D=q.node(G),ce=F.node(G);D&&(D.x=ce.x,D.y=ce.y,F.children(G).length&&(D.width=ce.width,D.height=ce.height))}),e.forEach(q.edges(),function(G){var D=q.edge(G),ce=F.edge(G);D.points=ce.points,e.has(ce,"x")&&(D.x=ce.x,D.y=ce.y)}),q.graph().width=F.graph().width,q.graph().height=F.graph().height}var b=["nodesep","edgesep","ranksep","marginx","marginy"],x={ranksep:50,edgesep:20,nodesep:50,rankdir:"tb"},v=["acyclicer","ranker","rankdir","align"],w=["width","height"],C={width:0,height:0},S=["minlen","weight","width","height","labeloffset"],R={minlen:1,weight:1,width:0,height:0,labeloffset:10,labelpos:"r"},P=["labelpos"];function k(q){var F=new p({multigraph:!0,compound:!0}),G=pe(q.graph());return F.setGraph(e.merge({},x,oe(G,b),e.pick(G,v))),e.forEach(q.nodes(),function(D){var ce=pe(q.node(D));F.setNode(D,e.defaults(oe(ce,w),C)),F.setParent(D,q.parent(D))}),e.forEach(q.edges(),function(D){var ce=pe(q.edge(D));F.setEdge(D,e.merge({},R,oe(ce,S),e.pick(ce,P)))}),F}function T(q){var F=q.graph();F.ranksep/=2,e.forEach(q.edges(),function(G){var D=q.edge(G);D.minlen*=2,D.labelpos.toLowerCase()!=="c"&&(F.rankdir==="TB"||F.rankdir==="BT"?D.width+=D.labeloffset:D.height+=D.labeloffset)})}function E(q){e.forEach(q.edges(),function(F){var G=q.edge(F);if(G.width&&G.height){var D=q.node(F.v),ce=q.node(F.w),Q={rank:(ce.rank-D.rank)/2+D.rank,e:F};h.addDummyNode(q,"edge-proxy",Q,"_ep")}})}function M(q){var F=0;e.forEach(q.nodes(),function(G){var D=q.node(G);D.borderTop&&(D.minRank=q.node(D.borderTop).rank,D.maxRank=q.node(D.borderBottom).rank,F=e.max(F,D.maxRank))}),q.graph().maxRank=F}function _(q){e.forEach(q.nodes(),function(F){var G=q.node(F);G.dummy==="edge-proxy"&&(q.edge(G.e).labelRank=G.rank,q.removeNode(F))})}function N(q){var F=Number.POSITIVE_INFINITY,G=0,D=Number.POSITIVE_INFINITY,ce=0,Q=q.graph(),K=Q.marginx||0,ie=Q.marginy||0;function ye(we){var fe=we.x,ge=we.y,X=we.width,H=we.height;F=Math.min(F,fe-X/2),G=Math.max(G,fe+X/2),D=Math.min(D,ge-H/2),ce=Math.max(ce,ge+H/2)}e.forEach(q.nodes(),function(we){ye(q.node(we))}),e.forEach(q.edges(),function(we){var fe=q.edge(we);e.has(fe,"x")&&ye(fe)}),F-=K,D-=ie,e.forEach(q.nodes(),function(we){var fe=q.node(we);fe.x-=F,fe.y-=D}),e.forEach(q.edges(),function(we){var fe=q.edge(we);e.forEach(fe.points,function(ge){ge.x-=F,ge.y-=D}),e.has(fe,"x")&&(fe.x-=F),e.has(fe,"y")&&(fe.y-=D)}),Q.width=G-F+K,Q.height=ce-D+ie}function $(q){e.forEach(q.edges(),function(F){var G=q.edge(F),D=q.node(F.v),ce=q.node(F.w),Q,K;G.points?(Q=G.points[0],K=G.points[G.points.length-1]):(G.points=[],Q=ce,K=D),G.points.unshift(h.intersectRect(D,Q)),G.points.push(h.intersectRect(ce,K))})}function B(q){e.forEach(q.edges(),function(F){var G=q.edge(F);if(e.has(G,"x"))switch((G.labelpos==="l"||G.labelpos==="r")&&(G.width-=G.labeloffset),G.labelpos){case"l":G.x-=G.width/2+G.labeloffset;break;case"r":G.x+=G.width/2+G.labeloffset;break}})}function O(q){e.forEach(q.edges(),function(F){var G=q.edge(F);G.reversed&&G.points.reverse()})}function I(q){e.forEach(q.nodes(),function(F){if(q.children(F).length){var G=q.node(F),D=q.node(G.borderTop),ce=q.node(G.borderBottom),Q=q.node(e.last(G.borderLeft)),K=q.node(e.last(G.borderRight));G.width=Math.abs(K.x-Q.x),G.height=Math.abs(ce.y-D.y),G.x=Q.x+G.width/2,G.y=D.y+G.height/2}}),e.forEach(q.nodes(),function(F){q.node(F).dummy==="border"&&q.removeNode(F)})}function ee(q){e.forEach(q.edges(),function(F){if(F.v===F.w){var G=q.node(F.v);G.selfEdges||(G.selfEdges=[]),G.selfEdges.push({e:F,label:q.edge(F)}),q.removeEdge(F)}})}function ae(q){var F=h.buildLayerMatrix(q);e.forEach(F,function(G){var D=0;e.forEach(G,function(ce,Q){var K=q.node(ce);K.order=Q+D,e.forEach(K.selfEdges,function(ie){h.addDummyNode(q,"selfedge",{width:ie.label.width,height:ie.label.height,rank:K.rank,order:Q+ ++D,e:ie.e,label:ie.label},"_se")}),delete K.selfEdges})})}function ne(q){e.forEach(q.nodes(),function(F){var G=q.node(F);if(G.dummy==="selfedge"){var D=q.node(G.e.v),ce=D.x+D.width/2,Q=D.y,K=G.x-ce,ie=D.height/2;q.setEdge(G.e,G.label),q.removeNode(F),G.label.points=[{x:ce+2*K/3,y:Q-ie},{x:ce+5*K/6,y:Q-ie},{x:ce+K,y:Q},{x:ce+5*K/6,y:Q+ie},{x:ce+2*K/3,y:Q+ie}],G.label.x=G.x,G.label.y=G.y}})}function oe(q,F){return e.mapValues(e.pick(q,F),Number)}function pe(q){var F={};return e.forEach(q,function(G,D){F[D.toLowerCase()]=G}),F}return sd}var cd,bm;function kj(){if(bm)return cd;bm=1;var e=pt(),r=At(),t=Ht().Graph;cd={debugOrdering:n};function n(o){var i=r.buildLayerMatrix(o),s=new t({compound:!0,multigraph:!0}).setGraph({});return e.forEach(o.nodes(),function(a){s.setNode(a,{label:a}),s.setParent(a,"layer"+o.node(a).rank)}),e.forEach(o.edges(),function(a){s.setEdge(a.v,a.w,{},a.name)}),e.forEach(i,function(a,c){var l="layer"+c;s.setNode(l,{rank:"same"}),e.reduce(a,function(d,u){return s.setEdge(d,u,{style:"invis"}),u})}),s}return cd}var ld,xm;function Aj(){return xm||(xm=1,ld="0.8.5"),ld}var dd,vm;function Pj(){return vm||(vm=1,dd={graphlib:Ht(),layout:Rj(),debug:kj(),util:{time:At().time,notime:At().notime},version:Aj()}),dd}var Mj=Pj();const wm=g1(Mj);function Ij(e,r,t){var d;const n=new Set(e.map(u=>u.id)),o=new Set;for(const u of e)u.parent&&n.has(u.parent)&&o.add(u.parent);const i=new wm.graphlib.Graph({multigraph:!0,compound:!0}),s=t.compactSpacingScale??(t.spacingFactor>0?t.spacingFactor/1.3:1);i.setGraph({rankdir:t.rankDir,nodesep:t.compact?Math.max(t.nodeSep,24*s):t.nodeSep,edgesep:t.compact?Math.min(t.edgeSep,24*s):t.edgeSep,ranksep:t.compact?Math.min(t.rankSep,80*s):t.rankSep,ranker:"network-simplex"}),i.setDefaultEdgeLabel(()=>({})),i.setDefaultNodeLabel(()=>({}));for(const u of e)i.setNode(u.id,{width:u.width+2,height:u.height+2});for(const u of e)u.parent&&n.has(u.parent)&&i.setParent(u.id,u.parent);for(const u of r){if(!n.has(u.source)||!n.has(u.target)||o.has(u.source)||o.has(u.target))continue;const h=Jb(u.label,u.icon??((d=u.data)==null?void 0:d.icon),t.edgeLabelFontSize),p=t.rankDir==="LR"||t.rankDir==="RL",m=(h.width?h.width+2*Kb:0)+(u.connectorClearance??0);i.setEdge(u.source,u.target,{minlen:1,weight:1,...m?{width:p?m:Math.max(1,h.height),height:p?Math.max(1,h.height):m,labelpos:"c"}:{}},u.id)}wm.layout(i);const a=new Map;for(const u of e){if(o.has(u.id))continue;const h=i.node(u.id);h&&Number.isFinite(h.x)&&Number.isFinite(h.y)&&a.set(u.id,{x:h.x,y:h.y})}const c=t.compact?1:t.spacingFactor;if(c&&c!==1&&a.size){let u=1/0,h=1/0,p=-1/0,m=-1/0;a.forEach(b=>{u=Math.min(u,b.x),h=Math.min(h,b.y),p=Math.max(p,b.x),m=Math.max(m,b.y)});const g=(u+p)/2,y=(h+m)/2;a.forEach((b,x)=>a.set(x,{x:g+(b.x-g)*c,y:y+(b.y-y)*c}))}const l=t.nodeAlignment??"center";if(l!=="center"){const u=t.rankDir==="LR"||t.rankDir==="RL",h=u?"x":"y",p=u?"width":"height",m=t.rankDir==="RL"||t.rankDir==="BT"?-1:1,g=l==="leading"?-m:m,y=new Map;for(const b of e){const x=a.get(b.id);if(!x)continue;const v=x[h];y.set(v,Math.max(y.get(v)??0,b[p]))}for(const b of e){const x=a.get(b.id);if(!x)continue;const v=x[h],w=(y.get(v)-b[p])/2;a.set(b.id,{...x,[h]:v+g*w})}}return a}function Cd(e,r,t,n,o,i){const s=new Map,a=new Map(e.map(u=>[u.id,u]));for(const u of e){if(!u.parent||!a.has(u.parent))continue;const h=s.get(u.parent);h?h.push(u.id):s.set(u.parent,[u.id])}const c=(u,h=new Set)=>{var m;const p=(m=a.get(u))==null?void 0:m.parent;return!p||!a.has(p)||h.has(u)?0:(h.add(u),1+c(p,h))},l=[...s.keys()].sort((u,h)=>c(h)-c(u)),d=new Map;for(const u of l){const h=i==null?void 0:i.get(u),p=r.get(u);if(h&&p){d.set(u,{x1:p.x-h.w/2,y1:p.y-h.h/2,x2:p.x+h.w/2,y2:p.y+h.h/2});continue}let m=null;for(const b of s.get(u)||[]){let x=d.get(b);if(!x){const v=r.get(b);if(!v)continue;const w=t.get(b)||{w:60,h:60};x={x1:v.x-w.w/2,y1:v.y-w.h/2,x2:v.x+w.w/2,y2:v.y+w.h/2}}m=m?{x1:Math.min(m.x1,x.x1),y1:Math.min(m.y1,x.y1),x2:Math.max(m.x2,x.x2),y2:Math.max(m.y2,x.y2)}:{...x}}if(!m)continue;const g=n(u);m={x1:m.x1-g,y1:m.y1-g,x2:m.x2+g,y2:m.y2+g};const y=o(u);if(y){const b=m.x2-m.x1,x=m.y2-m.y1;if(y.w>b){const v=(y.w-b)/2;m.x1-=v,m.x2+=v}if(y.h>x){const v=(y.h-x)/2;m.y1-=v,m.y2+=v}}d.set(u,m)}return d}function Cm(e,r,t){var c,l,d;const n=[...r.weights],o=n.reduce((u,h)=>u+h,0),i=n[r.index]+n[r.index+1],s=Math.min(i*.95,Math.max(i*.05,n[r.index]+t/r.length*o));n[r.index]=s,n[r.index+1]=i-s;const a={...(l=(c=e.adjustment)==null?void 0:c.sections)==null?void 0:l[r.section]};if(r.axis==="y")a.rows=n;else{for(a.columns=[...a.columns??[]];a.columns.length<=r.row;)a.columns.push([]);a.columns[r.row]=n}return{...e,adjustment:{...e.adjustment,sections:{...(d=e.adjustment)==null?void 0:d.sections,[r.section]:a}}}}function Xx(e){if(e===void 0)return;if(!e||typeof e!="object"||Array.isArray(e)||e.enabled!==void 0&&typeof e.enabled!="boolean")throw new RangeError("Invalid grid adjustment.");const r=t=>Array.isArray(t)&&t.length<=1e4&&t.every(n=>typeof n=="number"&&Number.isFinite(n)&&n>0&&n<=1e6);if(e.sections!==void 0&&(!e.sections||typeof e.sections!="object"||Array.isArray(e.sections)))throw new RangeError("Invalid grid sections.");for(const[t,n]of Object.entries(e.sections??{}))if(["__proto__","constructor","prototype"].includes(t)||!n||typeof n!="object"||Array.isArray(n)||n.rows!==void 0&&!r(n.rows)||n.columns!==void 0&&(!Array.isArray(n.columns)||n.columns.length>1e4||!n.columns.every(r))||n.members!==void 0&&(!Array.isArray(n.members)||n.members.length>1e4||!n.members.every(o=>Array.isArray(o)&&o.length>0&&o.length<=1e4&&o.every(i=>typeof i=="string"&&i.length>0))||new Set(n.members.flat()).size!==n.members.flat().length))throw new RangeError("Invalid grid section proportions.")}function cu(e){const r=e.margin??15;if(!Number.isFinite(r)||r<0)throw new RangeError("Collision margin must be finite and non-negative.");return r}function Gn(e){const r=new Map(e.nodes.map(a=>[a.id,a])),t=new Map;for(const a of e.nodes){const c=a.parent&&r.has(a.parent)?a.parent:void 0,l=t.get(c)??[];l.push(a.id),t.set(c,l)}const n=[],o=new Map,i=a=>{const c=t.get(a),l=c?c.flatMap(i):e.positions.has(a)?[a]:[];return o.set(a,l),c&&n.push(c),l},s=t.get(void 0)??[];return s.forEach(i),n.push(s),{groups:n,leaves:o,children:t,roots:s}}function br(e,r,t=e.fixedSizes){const n=Cd(e.nodes,r,e.sizes,e.padding,e.minSize,t);for(const o of e.nodes){if(n.has(o.id))continue;const i=r.get(o.id),s=e.sizes.get(o.id);i&&s&&n.set(o.id,tr({...i,...s}))}return n}function Yx(e,r,t,n){const o=t.get(e),i=t.get(r);if(!o||!i)return;const s={x:Math.min(o.x2-i.x1,i.x2-o.x1)+n,y:Math.min(o.y2-i.y1,i.y2-o.y1)+n};if(s.x>.001&&s.y>.001)return{source:e,target:r,overlap:s}}function qn(e,r,t){const n=[];for(const o of e)for(let i=0;i<o.length;i++)for(let s=i+1;s<o.length;s++){const a=Yx(o[i],o[s],r,t);a&&n.push(a)}return n}function Qx(e,r={}){const t=cu(r),{groups:n}=Gn(e);return qn(n,br(e,e.positions),t)}function ev(e,r,t,n){var a,c,l;const o=new Set(e),i=(((l=(c=(a=r.adjustment)==null?void 0:a.sections)==null?void 0:c[t])==null?void 0:l.members)??[]).map(d=>d.filter(u=>o.delete(u))).filter(d=>d.length),s=e.filter(d=>o.has(d));for(let d=0;d<s.length;d+=n)i.push(s.slice(d,d+n));return i}function Tj(e,r,t,n,o){var x,v,w,C;if(t===n)return;const{groups:i,leaves:s}=Gn(e),a=i.find(S=>S.includes(t)&&S.includes(n));if(!a||a.some(S=>e.fixedIds.has(S)||(s.get(S)??[]).some(R=>e.fixedIds.has(R))))return;const c=br(e,e.positions);if(a.some(S=>!c.has(S)))return;const l=((x=e.nodes.find(S=>S.id===t))==null?void 0:x.parent)??"canvas",d=(w=(v=r.adjustment)==null?void 0:v.sections)==null?void 0:w[l],u=[],h=[...a].sort((S,R)=>{const P=c.get(S),k=c.get(R),T=(P.y1+P.y2-k.y1-k.y2)/2;return Math.abs(T)>1?T:P.x1-k.x1});for(const S of h){const R=u.at(-1),P=c.get(S),k=R&&c.get(R[0]);k&&Math.abs(P.y1+P.y2-k.y1-k.y2)<2?R.push(S):u.push([S])}const p=u.map((S,R)=>{var P;return{weight:((P=d==null?void 0:d.rows)==null?void 0:P[R])??1,cells:S.map((k,T)=>{var E,M;return{id:k,weight:((M=(E=d==null?void 0:d.columns)==null?void 0:E[R])==null?void 0:M[T])??1}})}});for(const S of p)S.cells=S.cells.filter(R=>R.id!==t);const m=p.filter(S=>S.cells.length),g=m.findIndex(S=>S.cells.some(R=>R.id===n)),y=m[g];if(!y)return;o==="above"||o==="below"?m.splice(g+(o==="below"?1:0),0,{weight:1,cells:[{id:t,weight:1}]}):y.cells.splice(y.cells.findIndex(S=>S.id===n)+(o==="after"?1:0),0,{id:t,weight:1});const b=m.map(S=>S.cells.map(R=>R.id));if(JSON.stringify(b)!==JSON.stringify(u))return{...r,adjustment:{...r.adjustment,sections:{...(C=r.adjustment)==null?void 0:C.sections,[l]:{...d,members:b,rows:m.map(S=>S.weight),columns:m.map(S=>S.cells.map(R=>R.weight))}}}}}function ud(e,r={}){var d;Xx(r.adjustment);const t=cu(r),n=typeof r.gaps=="object"?r.gaps:{x:r.gaps??t,y:r.gaps??t};if(!n||[n.x,n.y].some(u=>!Number.isFinite(u)||u<0))throw new RangeError("Grid gaps must be finite and non-negative.");const o=r.padding??0;if(!Number.isFinite(o)||o<0)throw new RangeError("Grid padding must be finite and non-negative.");if(r.columns!==void 0&&(!Number.isSafeInteger(r.columns)||r.columns<1))throw new RangeError("Grid columns must be a positive safe integer.");if(r.fill&&e.viewportSize)return Oj(e,r,n,o);const{groups:i,leaves:s}=Gn(e),a=new Map([...e.positions].map(([u,h])=>[u,{...h}])),c=new Set;for(const u of i){const h=br(e,a),p=u.filter(E=>h.has(E));if(p.length<2)continue;if(p.some(E=>e.fixedIds.has(E)||(s.get(E)??[]).some(M=>e.fixedIds.has(M)))){p.forEach(E=>c.add(E));continue}const g=p.map(E=>h.get(E)),y=Math.max(...g.map(E=>E.x2-E.x1)),b=Math.max(...g.map(E=>E.y2-E.y1)),x=Math.min(p.length,r.columns??Math.ceil(Math.sqrt(p.length))),v=((d=e.nodes.find(E=>E.id===p[0]))==null?void 0:d.parent)??"canvas",w=ev(p,r,v,x),C=Math.max(...w.map(E=>E.length)),S=y+n.x,R=b+n.y,P=g.map(E=>({x:(E.x1+E.x2)/2,y:(E.y1+E.y2)/2})),k=(Math.min(...P.map(E=>E.x))+Math.max(...P.map(E=>E.x)))/2,T=(Math.min(...P.map(E=>E.y))+Math.max(...P.map(E=>E.y)))/2;w.forEach((E,M)=>E.forEach((_,N)=>{const $=h.get(_),B={x:k+(N-(C-1)/2)*S-($.x1+$.x2)/2,y:T+(M-(w.length-1)/2)*R-($.y1+$.y2)/2};for(const O of s.get(_)??[]){const I=a.get(O);a.set(O,{x:I.x+B.x,y:I.y+B.y})}}))}const l=[...a].filter(([u,h])=>{const p=e.positions.get(u);return h.x!==p.x||h.y!==p.y}).map(([u])=>u);return{positions:a,movedNodeIds:l,skippedNodeIds:[...c],collisions:qn(i,br(e,a),Math.min(n.x,n.y))}}function Oj(e,r,t,n){const{groups:o,children:i,roots:s}=Gn(e),a=new Map([...e.positions].map(([y,b])=>[y,{...b}]));if(e.nodes.some(y=>e.fixedIds.has(y.id)))return{positions:a,movedNodeIds:[],skippedNodeIds:e.nodes.map(y=>y.id),collisions:Qx(e,{margin:Math.min(t.x,t.y)})};const c=e.viewportSize,l=Math.min(n,Math.max(0,(c.w-1)/2)),d=Math.min(n,Math.max(0,(c.h-1)/2)),u={x1:l,y1:d,x2:Math.max(l+1,c.w-l),y2:Math.max(d+1,c.h-d)},h=new Map,p=[],m=(y,b,x="canvas")=>{var N,$;if(!y.length)return;const v=b.x2-b.x1,w=b.y2-b.y1,C=Math.min(y.length,r.columns??Math.max(1,Math.round(Math.sqrt(y.length*v/w)))),S=ev(y,r,x,C),R=S.length,P=Math.min(t.y,w/(2*R)),k=($=(N=r.adjustment)==null?void 0:N.sections)==null?void 0:$[x],T=Array.from({length:R},(B,O)=>{var I;return((I=k==null?void 0:k.rows)==null?void 0:I[O])??1}),E=T.reduce((B,O)=>B+O,0),M=w-(R-1)*P;let _=b.y1;for(let B=0;B<R;B++){const O=M*T[B]/E,I=S[B].length,ee=Math.min(t.x,v/(2*I)),ae=Array.from({length:I},(q,F)=>{var G,D;return((D=(G=k==null?void 0:k.columns)==null?void 0:G[B])==null?void 0:D[F])??1}),ne=ae.reduce((q,F)=>q+F,0),oe=v-(I-1)*ee;let pe=b.x1;for(let q=0;q<I;q++){const F=S[B][q],G=oe*ae[q]/ne,D=i.get(F);if(D){a.set(F,{x:pe+G/2,y:_+O/2}),h.set(F,{w:G,h:O});const ce=Math.min(e.padding(F),Math.max(0,(Math.min(G,O)-1)/2));m(D,{x1:pe+ce,y1:_+ce,x2:pe+G-ce,y2:_+O-ce},F)}else a.has(F)&&(a.set(F,{x:pe+G/2,y:_+O/2}),h.set(F,{w:G,h:O}));q<I-1&&p.push({section:x,axis:"x",row:B,index:q,weights:ae,length:oe,position:{x:pe+G+ee/2,y:_+O/2}}),pe+=G+ee}B<R-1&&p.push({section:x,axis:"y",row:B,index:B,weights:T,length:M,position:{x:b.x1+v/2,y:_+O+P/2}}),_+=O+P}};m(s,u);const g=[...a].filter(([y,b])=>{const x=e.positions.get(y);return!x||b.x!==x.x||b.y!==x.y}).map(([y])=>y);return{positions:a,movedNodeIds:g,skippedNodeIds:[],bounds:u,sizes:h,dividers:p,collisions:qn(o,br({...e,sizes:h},a,h),0)}}function Nj(e,r={}){const t=cu(r),n=r.maxIterations??50;if(!Number.isInteger(n)||n<0||n>1e3)throw new RangeError("Collision maxIterations must be an integer between 0 and 1000.");const{groups:o,leaves:i}=Gn(e),s=new Map([...e.positions].map(([u,h])=>[u,{...h}])),a=u=>e.fixedIds.has(u)||(i.get(u)??[]).some(h=>e.fixedIds.has(h));let c=qn(o,br(e,s),t),l=0;for(;c.length&&l<n;){let u=!1;for(const h of o){if(h.length<2)continue;const p=br(e,s),m=(g,y,b)=>{for(const v of i.get(g)??[])s.get(v)[y]+=b;const x=p.get(g);y==="x"?(x.x1+=b,x.x2+=b):(x.y1+=b,x.y2+=b)};for(let g=0;g<h.length;g++)for(let y=g+1;y<h.length;y++){const b=h[g],x=h[y],v=Yx(b,x,p,t);if(!v)continue;const w=a(b),C=a(x);if(w&&C)continue;const S=v.overlap.x<=v.overlap.y?"x":"y",R=p.get(b),P=p.get(x),k=S==="x"?R.x1+R.x2<=P.x1+P.x2?-1:1:R.y1+R.y2<=P.y1+P.y2?-1:1,T=v.overlap[S];w||m(b,S,k*T/(C?1:2)),C||m(x,S,-k*T/(w?1:2)),u=!0}}if(l++,c=qn(o,br(e,s),t),!u)break}const d=[...s].filter(([u,h])=>{const p=e.positions.get(u);return h.x!==p.x||h.y!==p.y}).map(([u])=>u);return{positions:s,movedNodeIds:d,collisions:c,iterations:l,resolved:c.length===0}}function $j({dividers:e,options:r,zoom:t,onChange:n}){const o=j.useRef();return f.jsx(f.Fragment,{children:e.map(i=>{const s=i.axis==="x",a=s?Y.PiArrowsHorizontal:Y.PiArrowsVertical,c=`${s?"Column":"Row"} divider ${i.index+1}${s?` in row ${i.row+1}`:""}`;return f.jsx("button",{type:"button",role:"separator","aria-label":c,"aria-orientation":s?"vertical":"horizontal","aria-valuemin":5,"aria-valuemax":95,"aria-valuenow":Math.round(100*i.weights[i.index]/(i.weights[i.index]+i.weights[i.index+1])),title:c,"data-flow-grid-adjustment":"",style:{position:"absolute",left:i.position.x,top:i.position.y,transform:"translate(-50%, -50%)",width:28,height:28,padding:3,border:"1px solid currentColor",borderRadius:4,background:"var(--chakra-colors-gray-100)",color:"var(--chakra-colors-gray-800)",display:"grid",placeItems:"center",cursor:s?"col-resize":"row-resize",touchAction:"none",pointerEvents:"auto",zIndex:30},onPointerDown:l=>{if(l.button!==0)return;l.preventDefault(),l.stopPropagation();const d=l.currentTarget.closest(".flow-sdk-canvas"),u=d.getBoundingClientRect();o.current={pointerId:l.pointerId,start:s?l.clientX:l.clientY,scale:t*(s?u.width/d.clientWidth:u.height/d.clientHeight),divider:i,options:r},l.currentTarget.setPointerCapture(l.pointerId)},onPointerMove:l=>{const d=o.current;if(!d||d.pointerId!==l.pointerId)return;l.preventDefault(),l.stopPropagation();const u=((s?l.clientX:l.clientY)-d.start)/d.scale;n(Cm(d.options,d.divider,u))},onPointerUp:l=>{o.current&&(l.stopPropagation(),o.current=void 0,l.currentTarget.releasePointerCapture(l.pointerId))},onPointerCancel:()=>{o.current&&n(o.current.options),o.current=void 0},onLostPointerCapture:()=>{o.current=void 0},onClick:l=>l.stopPropagation(),onKeyDown:l=>{l.key==="Escape"&&o.current&&(n(o.current.options),o.current=void 0);const d=(s?["ArrowLeft","ArrowRight"]:["ArrowUp","ArrowDown"]).indexOf(l.key);d<0||(l.preventDefault(),l.stopPropagation(),n(Cm(r,i,i.length*(l.shiftKey?.1:.02)*(d===0?-1:1))))},children:f.jsx(a,{size:20,"aria-hidden":"true"})},`${i.section}:${i.axis}:${i.row}:${i.index}`)})})}const Sm=(e,r)=>e.left<r.right&&e.right>r.left&&e.top<r.bottom&&e.bottom>r.top,fd=new WeakMap;function jm(e,r){const t=[...r.querySelectorAll(".flow-sdk-edge-label")];if(!t.length){fd.delete(r);return}const n=r==null?void 0:r.getScreenCTM();if(!r||!n)return;const o=n.inverse(),i=(u,h=0)=>{const p=u.getBoundingClientRect(),m=new DOMPoint(p.left,p.top).matrixTransform(o),g=new DOMPoint(p.right,p.bottom).matrixTransform(o);return{left:m.x-h,right:g.x+h,top:m.y-h,bottom:g.y+h}},s=[...e.querySelectorAll(".flow-sdk-node, .flow-sdk-node button")].filter(u=>u.closest(".flow-sdk-canvas")===e).filter(u=>{const h=u.getBoundingClientRect(),p=getComputedStyle(u);return h.width>0&&h.height>0&&p.visibility!=="hidden"&&p.opacity!=="0"}).map(u=>i(u,24));for(const u of r.querySelectorAll(".flow-sdk-container-label"))s.push(i(u,12));const a=new Map([...e.querySelectorAll(".flow-sdk-edge")].filter(u=>u.closest(".flow-sdk-canvas")===e).map(u=>[u.dataset.edgeId,u.querySelector("path")])),c=JSON.stringify([s,[...a].map(([u,h])=>[u,h==null?void 0:h.getAttribute("d")]),t.map(u=>{var m;const h=u.getBBox(),p=(m=u.querySelector("rect"))==null?void 0:m.getBBox();return[u.dataset.edgeId,u.dataset.labelTransform,u.dataset.labelHorizontal,h.x,h.y,h.width,h.height,p==null?void 0:p.width,p==null?void 0:p.height]})],(u,h)=>typeof h=="number"?Math.round(h*1e3)/1e3:h),l=fd.get(r);if((l==null?void 0:l.geometry)===c&&t.every(u=>l.transforms.has(u))){for(const u of t){const h=l.transforms.get(u);u.getAttribute("transform")!==h&&u.setAttribute("transform",h)}return}for(const u of t)u.setAttribute("transform",u.dataset.labelTransform??"");const d=new Map(t.map(u=>[u,i(u,8)]));for(const u of t){const h=u.dataset.labelHorizontal==="true",p=d.get(u);d.delete(u);const m=k=>s.some(T=>Sm(k,T))||[...d.values()].some(T=>Sm(k,T));if(!h&&!m(p)){d.set(u,p);continue}const g=a.get(u.dataset.edgeId),y=u.querySelector("rect");if(!g||!y)continue;const b=y.getBBox(),x=g.getTotalLength();if(!Number.isFinite(x)||x<=0)continue;const v=(p.left+p.right)/2,w=(p.top+p.bottom)/2,C=Math.min(256,Math.max(16,Math.ceil(x/24))),S=Array.from({length:C+1},(k,T)=>g.getPointAtLength(x*T/C)),P=Array.from({length:C+1},(k,T)=>{const E=x*T/C,M=S[T],_=h?{x:M.x,y:M.y-b.height/2-15}:M,N=g.getPointAtLength(Math.max(0,E-2)),$=g.getPointAtLength(Math.min(x,E+2));let B=Math.atan2($.y-N.y,$.x-N.x)*180/Math.PI;B>90&&(B-=180),B<-90&&(B+=180);const O=Math.abs(B)<1;h&&(B=0);const I=B*Math.PI/180,ee=Math.abs(Math.cos(I))*b.width+Math.abs(Math.sin(I))*b.height,ae=Math.abs(Math.sin(I))*b.width+Math.abs(Math.cos(I))*b.height;return{point:_,angle:B,straight:O,score:Math.hypot(_.x-v,_.y-w),bounds:{left:_.x-ee/2-8,right:_.x+ee/2+8,top:_.y-ae/2-8,bottom:_.y+ae/2+8}}}).sort((k,T)=>k.score-T.score).find(k=>!m(k.bounds)&&(!h||k.straight&&!S.some(T=>T.x>k.bounds.left&&T.x<k.bounds.right&&T.y>k.bounds.top&&T.y<k.bounds.bottom)));P?(u.setAttribute("transform",`translate(${P.point.x} ${P.point.y}) rotate(${P.angle})`),d.set(u,P.bounds)):d.set(u,p)}fd.set(r,{geometry:c,transforms:new Map(t.map(u=>[u,u.getAttribute("transform")??""]))})}function qj(e){const r=e.getBoundingClientRect(),t=r.height/e.offsetHeight;if(!Number.isFinite(t)||t<=0)return[];const n=Ub(e),o={x:e.offsetWidth/2,y:e.offsetHeight/2,w:e.offsetWidth,h:e.offsetHeight},i=[...e.querySelectorAll("[data-flow-property]")],s=new Set(i.filter(a=>a.hasAttribute("data-flow-inspection-row")&&a.getBoundingClientRect().height>0).map(a=>a.dataset.flowProperty));return i.flatMap(a=>{if(a.closest(".flow-sdk-node")!==e)return[];if(s.has(a.dataset.flowProperty)&&!a.hasAttribute("data-flow-inspection-row"))return[];const c=a.dataset.flowPortSide;if(c&&["top","right","bottom","left"].includes(c)){const d=Vb(n?Pn(o,n):o,c,Number(a.dataset.flowPortPosition??.5));return[{property:a.getAttribute("data-flow-property"),top:d.y,height:0,anchor:d,...a.dataset.flowPortPlacement==="config"?{placement:"config"}:{},...a.dataset.flowPortRole==="source"||a.dataset.flowPortRole==="target"?{role:a.dataset.flowPortRole}:{}}]}const l=a.getBoundingClientRect();return!l.width||!l.height?[]:[{property:a.getAttribute("data-flow-property"),top:Math.round((l.top-r.top)/t*1e3)/1e3,height:Math.round(l.height/t*1e3)/1e3,...a.dataset.flowPortRole==="source"||a.dataset.flowPortRole==="target"?{role:a.dataset.flowPortRole}:{}}]})}function Lj({id:e,x:r,y:t,placed:n,hidden:o,gridDraggable:i,gridDragging:s,gridDropTarget:a,gridSize:c,gridPreview:l,onMount:d,drawHandles:u,drawMode:h,connectedPorts:p,resolvedRows:m,hasCollapseControl:g,handleColor:y,animated:b,animationColor:x,animationWidth:v=8,animationVariant:w,width:C=0,height:S=0,propertyMode:R,reversePorts:P,direction:k="LR",onPropertyRows:T,onSurface:E,children:M}){var D,ce;const _=j.useRef(null),[N,$]=j.useState([]),B=m??N,[O,I]=j.useState(),ee=j.useId(),ae=j.useRef(),ne=!!l,oe=!!(l!=null&&l.floating);j.useLayoutEffect(()=>{var we;const Q=_.current;if(!Q||!ne)return;const K=Q.cloneNode(!0);K.removeAttribute("data-node-id"),K.removeAttribute("data-grid-dragging"),K.removeAttribute("data-grid-draggable"),K.removeAttribute("data-grid-drop-target"),K.setAttribute("data-grid-preview",e),K.setAttribute("aria-hidden","true"),K.setAttribute("inert","");const ie=[K,...K.querySelectorAll("*")],ye=new Map(ie.filter(fe=>fe.id).map(fe=>[fe.id,`${fe.id}-${ee}`]));for(const fe of ie){fe.id&&(fe.id=ye.get(fe.id));for(const ge of[...fe.attributes]){if(ge.name==="id")continue;let X=ge.value;for(const[H,be]of ye)X===`#${H}`&&(X=`#${be}`),X=X.split(`url(#${H})`).join(`url(#${be})`);X!==ge.value&&fe.setAttribute(ge.name,X)}}if(Object.assign(K.style,{opacity:"0.35",zIndex:oe?"2147483647":"11",pointerEvents:"none",outline:"none",visibility:"visible"}),oe){const fe=getComputedStyle(Q);K.setAttribute("data-grid-preview-floating",""),Object.assign(K.style,{position:"fixed",left:"0",top:"0",transformOrigin:"top left",font:fe.font,color:fe.color});for(const ge of ie)ge.removeAttribute("data-node-id"),ge.style.pointerEvents="none"}return K.querySelectorAll(".flow-sdk-node-animation, .flow-sdk-handle, .flow-sdk-property-port, [data-flow-collapse-control]").forEach(fe=>fe.remove()),(we=oe?document.body:Q.parentElement)==null||we.appendChild(K),ae.current=K,()=>{K.remove(),ae.current=void 0}},[e,ee,ne,oe]),j.useLayoutEffect(()=>{const Q=ae.current;if(!Q||!l)return;const{x:K,y:ie,size:ye}=l;if(oe&&_.current){const ge=_.current,X=ge.getBoundingClientRect(),H=X.width/ge.offsetWidth||1,be=X.height/ge.offsetHeight||1,J=X.left+(K-r)*H,xe=X.top+(ie-t)*be;Q.style.transform=`translate3d(${J}px, ${xe}px, 0) scale(${H}, ${be})`,Q.style.width=`${ge.offsetWidth}px`,Q.style.height=`${ge.offsetHeight}px`;return}const we=ye?Math.round(K-ye.w/2):K,fe=ye?Math.round(ie-ye.h/2):ie;Q.style.transform=ye?`translate3d(${we}px, ${fe}px, 0)`:`translate(-50%, -50%) translate3d(${we}px, ${fe}px, 0)`,Q.style.width=ye?`${Math.round(K+ye.w/2)-we}px`:"",Q.style.height=ye?`${Math.round(ie+ye.h/2)-fe}px`:"",ye&&(Q.style.setProperty("--flow-grid-width",`${ye.w}px`),Q.style.setProperty("--flow-grid-height",`${ye.h}px`),Q.style.setProperty("--flow-grid-font",`${Math.max(12,Math.min(48,ye.w/8,ye.h/5))}px`))},[l==null?void 0:l.x,l==null?void 0:l.y,(D=l==null?void 0:l.size)==null?void 0:D.w,(ce=l==null?void 0:l.size)==null?void 0:ce.h,oe,r,t]),j.useLayoutEffect(()=>{const Q=_.current;if(!Q)return;const K=()=>{const we=Ub(Q);I(fe=>JSON.stringify(fe)===JSON.stringify(we)?fe:we),E==null||E(e,we)};K();const ie=new ResizeObserver(K);ie.observe(Q);const ye=Q.querySelector("[data-flow-node-surface]");return ye&&ie.observe(ye),()=>ie.disconnect()},[e,M,E]),j.useLayoutEffect(()=>(d(e,_.current),()=>{d(e,null),E==null||E(e,void 0)}),[e,d,E]),j.useLayoutEffect(()=>{const Q=_.current;if(!Q)return;let K="";const ie=()=>{const ge=qj(Q),X=R?ge:ge.filter(be=>be.anchor),H=JSON.stringify(X);H!==K&&(K=H,$(X),T==null||T(e,X))};if(ie(),!R&&!Q.querySelector("[data-flow-port-side]"))return;const ye=new ResizeObserver(ie),we=()=>{ye.disconnect(),ye.observe(Q),Q.querySelectorAll("[data-flow-property]").forEach(ge=>ye.observe(ge)),ie()};we();const fe=new MutationObserver(we);return fe.observe(Q,{childList:!0,subtree:!0,characterData:!0,attributes:!0,attributeFilter:["data-flow-property","data-flow-port-role","data-flow-port-side","data-flow-port-position","data-flow-port-placement"]}),Q.addEventListener("scroll",ie,!0),()=>{ye.disconnect(),fe.disconnect(),Q.removeEventListener("scroll",ie,!0)}},[e,R,T,M]);const pe=c?Math.round(r-c.w/2):0,q=c?Math.round(t-c.h/2):0,F=c?Math.round(r+c.w/2)-pe:void 0,G=c?Math.round(t+c.h/2)-q:void 0;return f.jsxs("div",{ref:_,className:"flow-sdk-node","data-node-id":e,"data-grid-draggable":i||void 0,"data-grid-dragging":s||void 0,"data-grid-drop-target":a||void 0,"data-grid-fill":c?"":void 0,style:{transform:c?`translate3d(${pe}px, ${q}px, 0)`:`translate(-50%, -50%) translate3d(${r.toFixed(2)}px, ${t.toFixed(2)}px, 0)`,visibility:n&&!o?void 0:"hidden",cursor:i?s?"grabbing":"grab":void 0,zIndex:s?12:void 0,opacity:l?0:s?.75:void 0,outline:a?`2px solid ${y||"currentColor"}`:void 0,outlineOffset:a?8:void 0,width:F,height:G,...c?{"--flow-grid-width":`${c.w}px`,"--flow-grid-height":`${c.h}px`,"--flow-grid-font":`${Math.max(12,Math.min(48,c.w/8,c.h/5))}px`}:{}},children:[M,!c&&b&&v>0&&C>0&&S>0&&f.jsx("svg",{className:"flow-sdk-node-animation","aria-hidden":"true",pointerEvents:"none",children:f.jsx(so,{variant:w,x:((O==null?void 0:O.left)??0)+v/2,y:((O==null?void 0:O.top)??0)+v/2,width:((O==null?void 0:O.width)??C)-v,height:((O==null?void 0:O.height)??S)-v,radius:((O==null?void 0:O.radius)??0)-v/2,path:O!=null&&O.outline?`M${O.outline.map(Q=>`${Q.x} ${Q.y}`).join(" L")} Z`:void 0,color:x||y||"currentColor",strokeWidth:v})}),u&&R&&B.map(Q=>["source","target"].filter(K=>!Q.role||Q.role===K).filter(K=>h||(p==null?void 0:p.has(`${K}:${Q.property}`))).map(K=>{var ie;return f.jsx("button",{type:"button",className:"flow-sdk-property-port","data-property":Q.property,"data-port-role":K,"data-port-side":(ie=Q.anchor)==null?void 0:ie.side,"aria-label":`${K==="source"?"Connect":"Input"} ${Q.property}`,title:`${K==="source"?"Connect":"Input"} ${Q.property}`,style:{color:y,...Q.anchor?{top:Q.anchor.y,left:Q.anchor.x-16}:{top:Q.top+Q.height/2,[K==="source"!=!!P?"right":"left"]:-16}},onClick:ye=>ye.stopPropagation()},`${Q.property}:${K}`)})),u&&!g&&(!R||!B.length)&&(!R||!B.some(Q=>Q.anchor))&&f.jsx("button",{type:"button",className:"flow-sdk-handle","aria-label":"Draw edge",title:"Draw edge",style:{color:y,left:((O==null?void 0:O.left)??0)+(k==="RL"?-36:k==="LR"?(O==null?void 0:O.width)??C:((O==null?void 0:O.width)??C)/2),top:((O==null?void 0:O.top)??0)+(k==="BT"?-36:k==="TB"?(O==null?void 0:O.height)??S:((O==null?void 0:O.height)??S)/2),transform:k==="BT"||k==="TB"?"translateX(-50%)":"translateY(-50%)"},onClick:Q=>Q.stopPropagation(),children:f.jsx(Y.PiPlusBold,{size:24})})]})}const Fj=j.memo(Lj);function zj(e,r,t){const[n,o]=j.useState(()=>({nodes:new Set,edges:new Set})),i=j.useMemo(()=>{const a=new Set(e.map(p=>p.id)),c=r.filter(p=>a.has(p.source)&&a.has(p.target)).map(p=>({id:p.id,source:p.inverted?p.target:p.source,target:p.inverted?p.source:p.target})),l=new Set(c.map(p=>p.id)),d=new Set([...n.nodes].filter(p=>a.has(p))),u=new Set([...n.edges].filter(p=>l.has(p)));if(!t)return{nodes:a,edges:l,ready:l};for(const p of e)c.filter(g=>g.target===p.id&&g.source!==g.target).every(g=>u.has(g.id))&&d.add(p.id);let h=new Set(c.filter(p=>d.has(p.source)).map(p=>p.id));if(d.size<a.size&&!c.some(p=>h.has(p.id)&&!u.has(p.id))){const p=e.find(m=>!d.has(m.id));p&&d.add(p.id),h=new Set(c.filter(m=>d.has(m.source)).map(m=>m.id))}return{nodes:d,edges:u,ready:h}},[e,r,t,n]);j.useLayoutEffect(()=>{o(a=>{const c=t?i:{nodes:new Set,edges:new Set},l=(d,u)=>d.size===u.size&&[...d].every(h=>u.has(h));return l(a.nodes,c.nodes)&&l(a.edges,c.edges)?a:{nodes:c.nodes,edges:c.edges}})},[i,t]);const s=j.useCallback(a=>{o(c=>c.edges.has(a)?c:{...c,edges:new Set([...c.edges,a])})},[]);return{shown:i.nodes,ready:i.ready,complete:s}}class Bj{constructor(r,t,n){qt(this,"_pan");qt(this,"_zoom");qt(this,"minZoom");qt(this,"maxZoom");qt(this,"size",{w:0,h:0});qt(this,"listeners",new Set);qt(this,"cancelTransition");qt(this,"animationVersion",0);qt(this,"captureTransition");qt(this,"animationsDisabled",!1);qt(this,"finishTransition");this.minZoom=t,this.maxZoom=n,this._pan={...r.pan},this._zoom=this.clamp(r.zoom)}setAnimationsDisabled(r){var t;r!==this.animationsDisabled&&(this.animationsDisabled=r,r&&((t=this.finishTransition)==null||t.call(this),this.cancelAnimation()))}cancelAnimation(){var r;(r=this.cancelTransition)==null||r.call(this),this.cancelTransition=void 0,this.finishTransition=void 0,this.animationVersion++}coordinate(r){let t;this.captureTransition=n=>{t=n};try{r()}finally{this.captureTransition=void 0}return t}transition(r,t=!1){this.cancelAnimation();const n=this.state,o={pan:{...r.pan},zoom:this.clamp(r.zoom)},i=this.animationVersion,s=Bb(t,this.animationsDisabled),a=c=>{if(i!==this.animationVersion)return;const l=s?c:1;this.apply({x:n.pan.x+(o.pan.x-n.pan.x)*l,y:n.pan.y+(o.pan.y-n.pan.y)*l},n.zoom+(o.zoom-n.zoom)*l)};this.finishTransition=()=>a(1),this.captureTransition?this.captureTransition(a):this.cancelTransition=Db(s,a,void 0,300/1.4)}get pan(){return{...this._pan}}get zoom(){return this._zoom}get state(){return{pan:this.pan,zoom:this._zoom}}clamp(r){return Number.isFinite(r)?Math.max(this.minZoom,Math.min(this.maxZoom,r)):this.minZoom}set(r,t){this.cancelAnimation(),this.apply(r,t)}apply(r,t){let n=!1;if(r&&(r.x!==this._pan.x||r.y!==this._pan.y)&&(this._pan={x:r.x,y:r.y},n=!0),t!==void 0){const o=this.clamp(t);o!==this._zoom&&(this._zoom=o,n=!0)}n&&this.emit()}zoomAt(r,t){const n=this.clamp(r),o=this._zoom;if(n===o)return;const i=n/o;this.set({x:t.x-(t.x-this._pan.x)*i,y:t.y-(t.y-this._pan.y)*i},n)}fit(r,t=0,n=!1,o=1){const i=r.x2-r.x1,s=r.y2-r.y1;if(!(i>0)||!(s>0)||!this.size.w||!this.size.h)return;const a=this.clamp(this.clamp(Math.min((this.size.w-2*t)/i,(this.size.h-2*t)/s))*o);this.transition({pan:{x:(this.size.w-a*(r.x1+r.x2))/2,y:(this.size.h-a*(r.y1+r.y2))/2},zoom:a},n)}center(r,t=!1){if(!this.size.w||!this.size.h)return;const n=this._zoom;this.transition({pan:{x:(this.size.w-n*(r.x1+r.x2))/2,y:(this.size.h-n*(r.y1+r.y2))/2},zoom:n},t)}renderedToModel(r){return{x:(r.x-this._pan.x)/this._zoom,y:(r.y-this._pan.y)/this._zoom}}modelToRendered(r){return{x:r.x*this._zoom+this._pan.x,y:r.y*this._zoom+this._pan.y}}onChange(r){return this.listeners.add(r),()=>{this.listeners.delete(r)}}emit(){const r=this.state;this.listeners.forEach(t=>t(r))}}const Dj={LR:"rightward",RL:"leftward",TB:"downward",BT:"upward"},eo={w:60,h:60},hd=4,Vj=30,Wj=500,Gj=45;function Em(e){const[r,t]=[...e.values()];return!r||!t?null:{center:{x:(r.x+t.x)/2,y:(r.y+t.y)/2},distance:Math.max(1,Math.hypot(t.x-r.x,t.y-r.y))}}function Uj(e){var xu,vu,wu,Cu,Su;const{nodes:r,edges:t,direction:n,nodeAlignment:o="center",edgeMode:i="auto",compactPropertyLayout:s=!1,rankSep:a,edgeSep:c,spacingFactor:l=1.3,compactSpacingScale:d,minZoom:u,maxZoom:h,initialViewport:p,containerStyle:m,lineColor:g,drawMode:y,dragMode:b,multiSelect:x,isPerformanceMode:v,disableAnimations:w=!1}=e,[C,S]=j.useState(null),R=j.useMemo(()=>C?(C.mode==="connections"?Xu:Gu)(C.id,r,t):null,[C,r,t]),P=i==="auto"||i==="properties",k=j.useMemo(()=>t.filter(A=>wd(A,i)&&(!R||R.has(A.source)&&R.has(A.target))),[t,i,R]),T=j.useMemo(()=>d1(r,t,i,s,R),[r,t,i,s,R]),E=j.useRef(T);E.current=T;const M=j.useRef(e);M.current=e;const _=j.useRef(null),N=j.useRef(null),$=j.useRef(null),B=j.useRef(null),O=j.useMemo(()=>new Bj(p,u,h),[]);j.useEffect(()=>{O.minZoom=u,O.maxZoom=h},[O,u,h]),j.useLayoutEffect(()=>{O.setAnimationsDisabled(w)},[O,w]);const I=j.useRef(new Map),ee=j.useRef(new Map),ae=j.useRef(new Map),ne=j.useRef(null),[oe,pe]=j.useState(new Map),q=j.useCallback((A,L)=>{pe(z=>{if(JSON.stringify(z.get(A))===JSON.stringify(L))return z;const Z=new Map(z);return L?Z.set(A,L):Z.delete(A),Z})},[]),[F,G]=j.useState(new Map),D=j.useRef(F),ce=j.useCallback((A,L)=>{G(z=>{if(JSON.stringify(z.get(A)??[])===JSON.stringify(L))return z;const Z=new Map(z);return L.length?Z.set(A,L):Z.delete(A),Z})},[]),[Q,K]=j.useState(()=>new Map),ie=j.useRef(Q);ie.current=Q;const[ye,we]=j.useState(new Map),fe=j.useRef(ye),ge=()=>{fe.current=new Map,we(fe.current)},X=j.useRef(new Map),H=j.useRef(null),be=j.useRef(!1),[J,xe]=j.useState(0),Se=j.useRef(),Fe=j.useRef(),De=j.useRef(null),he=j.useRef(),Re=j.useRef(!1),ze=j.useRef(null),Te=j.useRef(null),qe=j.useRef(),Qe=j.useRef(l),ct=s,Pe=j.useRef(ct),[Ze,Ye]=j.useState(!0),[at,Ot]=j.useState(!!((xu=e.initialNodeGrid)!=null&&xu.enabled)),[Rt,Vr]=j.useState([]),rt=j.useRef((vu=e.initialNodeGrid)!=null&&vu.enabled?{options:{...e.initialNodeGrid.options,animate:!1},order:[...e.initialNodeGrid.order??e.initialNodeGrid.options.order??r.map(A=>A.id)],previousPositions:new Map,previousViewport:p,previousSize:{w:0,h:0},ready:!1}:null),[Ke,Zt]=j.useState(null),ft=j.useRef(null);ft.current=R;const jr=j.useRef(1);jr.current=(C==null?void 0:C.mode)==="connections"?1.25:1;const Pt=j.useRef(null),Er=j.useRef(r),Vt=j.useRef([]),Xt=j.useRef(!1),ar=()=>{var A;(A=De.current)==null||A.call(De),De.current=null,he.current=void 0},We=()=>{Te.current=null,Vt.current.length&&(Xt.current=!0),!be.current&&M.current.fitOnInit!==!1&&(Re.current=!0),clearTimeout(Fe.current),Fe.current=setTimeout(()=>{be.current=ie.current.size>0,xe(A=>A+1)},Wj)},de=(A,L,z,Z=We,ue)=>{ar();const Ie=new Map(ie.current),Ee=new Map([...I.current,...fe.current]);De.current=Db(L,ke=>{const et=new Map;if(A.forEach((ve,$e)=>{const Ge=Ie.get($e);et.set($e,Ge?{x:Ge.x+(ve.x-Ge.x)*ke,y:Ge.y+(ve.y-Ge.y)*ke}:ve)}),ie.current=et,K(et),ue){const ve=new Map;for(const[$e,Ge]of ue){const te=Ee.get($e)??Ge;ve.set($e,{w:te.w+(Ge.w-te.w)*ke,h:te.h+(Ge.h-te.h)*ke})}fe.current=ve,we(ve)}z==null||z(ke)},Z)},W=()=>{var et;if(clearTimeout(Se.current),rt.current){mt.arrangeNodesInGrid(rt.current.options);return}fe.current.size&&ge();const A=M.current,L=jr.current,z=E.current,Z=z.nodes.map(ve=>{const $e=ee.current.get(ve.id);$e&&($e.offsetWidth||$e.offsetHeight)&&I.current.set(ve.id,{w:$e.offsetWidth,h:$e.offsetHeight});const Ge=I.current.get(ve.id)||eo;return{id:ve.id,parent:ve.parent,width:Ge.w,height:Ge.h}});let ue;try{const ve=A.compactPropertyLayout,$e=A.edgeMode!=="nodes"&&A.edgeMode!=="workflow",Ge=z.edges.map(te=>({...te,connectorClearance:ve?$e&&(te.sourceProperty!==void 0||te.targetProperty!==void 0)?l1:c1:0}));ue=Ij(Z,Ge,{edgeLabelFontSize:A.edgeMode==="nodes"||A.edgeMode==="workflow"?Hb:co,rankDir:A.direction,compact:ve,nodeAlignment:A.nodeAlignment,rankSep:A.rankSep*L,edgeSep:A.edgeSep*L,nodeSep:5*L,spacingFactor:A.spacingFactor??1.3,compactSpacingScale:(A.compactSpacingScale??(A.spacingFactor??1.3)/1.3)*L})}catch(ve){console.warn("[flow-sdk] layout failed",ve);return}const Ie=Te.current?null:H.current;H.current=null;const Ee=Ie&&ue.get(Ie.id);if(Ie&&Ee){const ve={x:Ie.position.x-Ee.x,y:Ie.position.y-Ee.y};ue=new Map([...ue].map(([$e,Ge])=>[$e,{x:Ge.x+ve.x,y:Ge.y+ve.y}]))}for(const[ve,$e]of X.current)ue.has(ve)?ue.set(ve,$e):A.nodes.some(Ge=>Ge.id===ve)||X.current.delete(ve);if(Te.current){const ve=JSON.stringify([Z,[...ue],O.size,A.isPerformanceMode,A.disableAnimations]);if(((et=qe.current)==null?void 0:et.focus)===Te.current&&qe.current.geometry===ve)return;qe.current={focus:Te.current,geometry:ve}}else qe.current=void 0;const ke=O.coordinate(()=>{var ve;return(ve=Te.current)==null?void 0:ve.call(Te,ue)});de(ue,be.current&&!A.isPerformanceMode&&!A.disableAnimations,ke)},se=j.useCallback(()=>{clearTimeout(Fe.current),clearTimeout(Se.current),Se.current=setTimeout(W,M.current.layoutDebounce)},[]);j.useLayoutEffect(()=>{const A=new Map(Er.current.map(L=>[L.id,L]));r.some(L=>{var z;return((z=A.get(L.id))==null?void 0:z.collapsed)===!0&&!L.collapsed})&&(Vt.current=r.filter(L=>!A.has(L.id)).map(L=>L.id)),Er.current=r,Qe.current!==l&&ie.current.size>0&&(be.current=!0,Re.current=!1,clearTimeout(Fe.current)),Qe.current=l,Pe.current!==ct&&(Re.current=!ze.current),Pe.current=ct,se()},[r,t,T.nodes,T.edges,ct,n,o,a,c,se,l,d,w,e.nodeGridSpacing]),j.useEffect(()=>()=>{clearTimeout(Se.current),clearTimeout(Fe.current),ar()},[]);const Be=j.useCallback((A,L)=>{var z,Z;if(!ne.current&&typeof ResizeObserver<"u"&&(ne.current=new ResizeObserver(ue=>{let Ie=!1;for(const Ee of ue){const ke=ae.current.get(Ee.target);if(!ke||fe.current.has(ke))continue;const et=Ee.target,ve=et.offsetWidth,$e=et.offsetHeight;if(!ve&&!$e)continue;const Ge=I.current.get(ke);if(Ge&&Ge.w===ve&&Ge.h===$e)continue;const te=ie.current.get(ke);Ge&&te&&be.current&&!H.current&&(H.current={id:ke,position:{...te}}),I.current.set(ke,{w:ve,h:$e}),Ie=!0}Ie&&se()})),L){ee.current.set(A,L),ae.current.set(L,A),(z=ne.current)==null||z.observe(L);const ue=L.offsetWidth,Ie=L.offsetHeight;!fe.current.has(A)&&(ue||Ie)&&I.current.set(A,{w:ue,h:Ie})}else{const ue=ee.current.get(A);ue&&((Z=ne.current)==null||Z.unobserve(ue),ae.current.delete(ue)),ee.current.delete(A),I.current.delete(A),D.current.has(A)&&ce(A,[])}se()},[se,ce]);j.useEffect(()=>()=>{var A;return(A=ne.current)==null?void 0:A.disconnect()},[]);const U=A=>{var Z;const L=(Z=M.current.nodes.find(ue=>ue.id===A))==null?void 0:Z.label;if(!L)return;const z=M.current.containerStyle(A);return{w:Co(L,`bold ${z.fontSize}px ${mr}`)+2*Gj,h:0}},Ce=j.useMemo(()=>{const A=new Map;for(const L of r)L.label&&A.set(L.id,L.label);return A},[r]),Ne=j.useMemo(()=>Cd(T.nodes,Q,new Map([...I.current,...ye]),A=>m(A).padding,U,ye),[T.nodes,Q,m,Ce,ye]),je=j.useRef(Ne);je.current=Ne;const Ve=j.useCallback(A=>{const L=je.current.get(A);if(L)return Kw(L);const z=ie.current.get(A);if(!z)return;const Z=fe.current.get(A)||I.current.get(A)||eo;return{x:z.x,y:z.y,w:Z.w,h:Z.h}},[]),nt=j.useMemo(()=>{const A=new Map;for(const L of r){const z=Ve(L.id);z&&A.set(L.id,z)}return n1(F,A,oe,t,n)},[F,r,Q,Ne,oe,t,n,Ve]);D.current=nt;const Xe=(A,L)=>{var ue;if(!P||L===void 0)return;const z=(ue=nt.get(A))==null?void 0:ue.find(Ie=>Ie.property===L),Z=Ve(A);return z&&!z.anchor&&Z?Z.y-Z.h/2+z.top+z.height/2:void 0},St=(A,L)=>{var ue,Ie;if(L===void 0)return;const z=(Ie=(ue=nt.get(A))==null?void 0:ue.find(Ee=>Ee.property===L))==null?void 0:Ie.anchor,Z=Ve(A);return z&&Z?{x:Z.x-Z.w/2+z.x,y:Z.y-Z.h/2+z.y,side:z.side}:void 0},kt=(A,L)=>{const z=Ve(A),Z=oe.get(A);return z&&Z&&!Ne.has(A)&&Xe(A,L)===void 0?Pn(z,(n==="TB"||n==="BT")&&Z.captionBottom!==void 0?{...Z,height:Math.max(Z.height,Z.captionBottom-Z.top),outline:void 0}:Z):z},Nt=()=>{const A=[];ie.current.forEach((L,z)=>{if(je.current.has(z))return;const Z=Ve(z);Z&&A.push(tr(Z))}),je.current.forEach(L=>A.push(L));try{for(const L of[N.current,$.current]){const z=L==null?void 0:L.getBBox();z&&z.width>0&&z.height>0&&A.push({x1:z.x,y1:z.y,x2:z.x+z.width,y2:z.y+z.height})}}catch{}return Ho(A)},$t=()=>{var z,Z;const{pan:A,zoom:L}=O;B.current&&(B.current.style.transform=`translate3d(${A.x}px, ${A.y}px, 0) scale(${L})`),(z=N.current)==null||z.setAttribute("transform",`translate(${A.x} ${A.y}) scale(${L})`),(Z=$.current)==null||Z.setAttribute("transform",`translate(${A.x} ${A.y}) scale(${L})`)};j.useEffect(()=>{$t();let A=null,L;const z=O.onChange(()=>{$t();const Z=_.current;Z&&(Z.classList.add("flow-sdk-busy"),clearTimeout(L),L=setTimeout(()=>Z.classList.remove("flow-sdk-busy"),150)),A===null&&(A=requestAnimationFrame(()=>{var ue,Ie;A=null,(Ie=(ue=M.current).onViewportChange)==null||Ie.call(ue,O.state)}))});return()=>{z(),clearTimeout(L),A!==null&&cancelAnimationFrame(A)}},[]),j.useLayoutEffect(()=>{const A=_.current;if(!A)return;const L=()=>{var Ee;if(!A.getClientRects().length)return;let Z=A.clientWidth,ue=A.clientHeight;ue||(ue=Math.max(0,window.innerHeight-A.getBoundingClientRect().top-100),ue&&(A.style.height=`${ue}px`)),Z||(Z=window.innerWidth,Z&&(A.style.width=`${Z}px`));const Ie=O.size.w!==Z||O.size.h!==ue;O.size={w:Z,h:ue},Ie&&((Ee=rt.current)!=null&&Ee.options.fill)&&(!be.current&&Z>0&&ue>0?W():se()),!be.current&&!ie.current.size&&M.current.fitOnInit!==!1&&(O.set({x:Z/2,y:ue/2}),$t())};if(L(),typeof ResizeObserver>"u")return;const z=new ResizeObserver(L);return z.observe(A),()=>z.disconnect()},[O]),j.useLayoutEffect(()=>{if(Xt.current){Xt.current=!1;const L=Vt.current.flatMap(Z=>{const ue=Ve(Z);return ue?[tr(ue)]:[]});Vt.current=[];const z=Ho(L);if(z){Re.current=!1,O.center(z,M.current.animateViewport);return}}if(!Re.current)return;Re.current=!1;const A=Nt();A&&(O.fit(A,50,be.current&&M.current.animateViewport),be.current||$t())},[Q]);const mt=j.useMemo(()=>{const A=te=>{const re=M.current;if(re.nodeGridSpacing!=="layout")return te;const me=re.direction==="LR"||re.direction==="RL";return{...te,gaps:{x:me?re.rankSep:re.edgeSep,y:me?re.edgeSep:re.rankSep}}},L=()=>{const te=M.current,re=E.current.nodes.filter(me=>rr(me.id,te.edges,te.edgeMode)&&(!ft.current||ft.current.has(me.id)));return{nodes:re,positions:ie.current,sizes:new Map(re.map(me=>[me.id,I.current.get(me.id)??eo])),padding:me=>M.current.containerStyle(me).padding,minSize:U,fixedIds:new Set(X.current.keys()),viewportSize:{...O.size}}},z=te=>Gu(te,M.current.nodes,M.current.edges),Z=(te,re=!0,me=()=>{},le,Ue,_e=!1)=>{clearTimeout(Se.current),clearTimeout(Fe.current),_e||(Te.current=null),ze.current=null,Re.current=!1,Vt.current=[],Xt.current=!1;const Ae=re&&!M.current.isPerformanceMode&&!M.current.disableAnimations,tt=O.coordinate(()=>{var ot;le?le(Ae):_e&&((ot=Te.current)==null||ot.call(Te,te))});de(new Map([...te].map(([ot,st])=>[ot,{...st}])),Ae,tt,me,Ue)},ue=(te,re=50,me=M.current.animateViewport,le=1,Ue=!1,_e)=>{const Ae=tt=>{const ot=E.current,st=te??new Set(ot.nodes.map(gt=>gt.id)),Yt=new Set(ot.nodes.map(gt=>gt.parent).filter(Boolean));if(!tt&&(!te||[...te].some(gt=>Yt.has(gt))))return;const sr=tt&&Cd(ot.nodes,tt,I.current,gt=>M.current.containerStyle(gt).padding,U),hn=new Map([...st].flatMap(gt=>{const er=sr==null?void 0:sr.get(gt);if(er)return[[gt,er]];const Wt=tt==null?void 0:tt.get(gt),fr=I.current.get(gt)||eo,ju=Wt?{...Wt,...fr}:Ve(gt);return ju?[[gt,tr(ju)]]:[]}));let Qt=Ho([...hn.values()]);if(!Qt)return;const ur=_e?hn.get(_e):void 0;if(ur){const gt=(ur.x1+ur.x2)/2,er=(ur.y1+ur.y2)/2,Wt=Math.max(gt-Qt.x1,Qt.x2-gt),fr=Math.max(er-Qt.y1,Qt.y2-er);Qt={x1:gt-Wt,x2:gt+Wt,y1:er-fr,y2:er+fr}}Re.current=!1,Vt.current=[],Xt.current=!1,O.fit(Qt,Number.isFinite(re)?Math.max(0,re):50,me,le)};Te.current=Ue?Ae:null,Ue||Ae(ie.current)},Ie=(te,re,me,le)=>{var _e;if(!Ve(te))return;const Ue=re==="connections"?ke(te):z(te);if(re==="connections"&&jr.current===1.25&&((_e=ft.current)==null?void 0:_e.size)===Ue.size&&[...Ue].every(Ae=>ft.current.has(Ae))){S({id:te,mode:re});return}Pt.current||(Pt.current={pan:{...O.pan},zoom:O.zoom}),ft.current=Ue,M.current.compactPropertyLayout&&(Re.current=!1,ze.current=()=>ue(ft.current??Ue,me,le)),S({id:te,mode:re}),M.current.compactPropertyLayout||ue(Ue,me,le)},Ee=te=>{ze.current?ze.current=te:te()},ke=te=>Xu(te,M.current.nodes,M.current.edges),et=(te=>{var re,me,le;if(te===void 0)return O.zoom;te<O.zoom&&((re=rt.current)!=null&&re.options.fill)&&!M.current.readOnly&&((le=(me=M.current).onNodeGridZoomOut)==null?void 0:le.call(me,rt.current.options))===!0||(Te.current=null,O.set(void 0,te))}),ve=(te=>{if(te===void 0)return O.pan;Te.current=null,O.set(te)}),$e=(te,re)=>{var le;const me=(le=_.current)==null?void 0:le.getBoundingClientRect();return{x:te-((me==null?void 0:me.left)??0),y:re-((me==null?void 0:me.top)??0)}},Ge=(te=0,re=M.current.animateViewport,me=!1)=>{if(me){ue(void 0,te,re,1,!0);return}Te.current=null,Ee(()=>{const le=Nt();le&&O.fit(le,te,re)})};return{zoom:et,pan:ve,setEdgesVisible:Ye,focusNode:(te,re,me,le)=>Ee(()=>ue(new Set([te]),re,me,.6,le)),focusBranch:(te,re,me,le,Ue=!1)=>Ee(()=>ue(z(te),re,me,1,le,Ue?te:void 0)),focusConnections:(te,re,me,le)=>Ee(()=>ue(ke(te),re,me,1,le)),isolateConnections:(te,re,me)=>Ie(te,"connections",re,me),isolateBranch:(te,re,me)=>Ie(te,"branch",re,me),restoreView:(te=M.current.animateViewport,re,me=!1)=>{Te.current=null;const le=me&&!rt.current&&!ft.current,Ue=M.current.compactPropertyLayout&&!!ft.current;ft.current=null,S(null);const _e=re??Pt.current;Pt.current=null,_e&&le?(Re.current=!1,ze.current=null,H.current=null,Te.current=()=>O.transition(_e,te),se()):Ue?ze.current=()=>{_e&&O.transition(_e,te)}:_e&&Ee(()=>O.transition(_e,te))},zoomAt:(te,re)=>{var me,le,Ue;te<O.zoom&&((me=rt.current)!=null&&me.options.fill)&&!M.current.readOnly&&((Ue=(le=M.current).onNodeGridZoomOut)==null?void 0:Ue.call(le,rt.current.options))===!0||(Te.current=null,O.zoomAt(te,re))},fit:Ge,centerAndFit:Ge,center:(te=M.current.animateViewport)=>{Te.current=null;const re=Nt();re&&O.center(re,te)},clientToModel:(te,re)=>O.renderedToModel($e(te,re)),modelToClient:te=>{var le;const re=(le=_.current)==null?void 0:le.getBoundingClientRect(),me=O.modelToRendered(te);return{x:me.x+((re==null?void 0:re.left)??0),y:me.y+((re==null?void 0:re.top)??0)}},getNodeBox:te=>Ve(te),detectNodeCollisions:te=>{const re=L();return Qx({...re,sizes:new Map([...re.sizes,...fe.current]),fixedSizes:fe.current},te)},resolveNodeCollisions:(te={})=>{const re=Nj(L(),te);return re.movedNodeIds.length&&Z(re.positions,te.animate),re},arrangeNodesInGrid:(te={})=>{const re=L(),me=rt.current;if(me){re.positions=new Map(re.positions);for(const st of re.nodes)re.positions.has(st.id)||re.positions.set(st.id,O.renderedToModel({x:O.size.w/2,y:O.size.h/2}));const Ae=new Set(re.nodes.map(st=>st.id));me.order=me.order.filter(st=>Ae.has(st));const tt=new Set(me.order);me.order.push(...re.nodes.filter(st=>!tt.has(st.id)).map(st=>st.id));const ot=new Map(me.order.map((st,Yt)=>[st,Yt]));re.nodes=[...re.nodes].sort((st,Yt)=>ot.get(st.id)-ot.get(Yt.id))}const le=ud(re,A(te)),Ue=le.sizes?JSON.stringify([[...le.positions],[...le.sizes]]):void 0;if(Ue&&Ue===he.current&&te.animate!==!1&&!Te.current)return le;Vr(le.dividers??[]),me&&(me.ready=!1);const _e=()=>{me&&(me.ready=!0),me&&re.nodes.length&&!be.current&&(be.current=!0,M.current.fitOnInit!==!1&&!te.fill?mt.centerAndFit(50,!1):M.current.fitOnInit===!1&&O.transition(p,!1)),xe(Ae=>Ae+1)};return!le.sizes&&fe.current.size&&ge(),re.nodes.some(Ae=>!ie.current.has(Ae.id))||le.movedNodeIds.length||le.bounds||Te.current?Z(le.positions,te.animate,_e,le.bounds&&(!me||!fe.current.size)?Ae=>O.transition({zoom:1,pan:{x:0,y:0}},Ae):void 0,le.sizes,!!me&&!le.bounds):_e(),he.current=Ue,le},setNodeGridMode:(te,re={})=>{var me,le,Ue,_e;if(re.order&&(!Array.isArray(re.order)||re.order.some(Ae=>typeof Ae!="string")||new Set(re.order).size!==re.order.length))throw new Error("Invalid grid node order.");if(te){ud(L(),A(re));const Ae=!rt.current||rt.current.options.fill&&!re.fill;Te.current=null,rt.current||(rt.current={options:re,order:L().nodes.map(tt=>tt.id),previousPositions:new Map([...ie.current].map(([tt,ot])=>[tt,{...ot}])),previousViewport:{zoom:O.zoom,pan:{...O.pan}},previousSize:{...O.size},ready:!1}),Ae&&mt.centerAndFit(80,re.animate,!0),re.order&&(rt.current.order=[...re.order]),rt.current.options={...re},Ot(!0),mt.arrangeNodesInGrid(re),(le=(me=M.current).onNodeGridModeChange)==null||le.call(me,{...re,order:[...rt.current.order]})}else{const Ae=rt.current;if(!Ae)return;if(O.size.w===Ae.previousSize.w&&O.size.h===Ae.previousSize.h&&ie.current.size===Ae.previousPositions.size&&[...ie.current.keys()].every(st=>Ae.previousPositions.has(st))?Te.current=()=>O.transition(Ae.previousViewport,re.animate!==!1&&!M.current.disableAnimations&&!M.current.isPerformanceMode):mt.centerAndFit(80,re.animate,!0),rt.current=null,Ot(!1),ge(),(_e=(Ue=M.current).onNodeGridModeChange)==null||_e.call(Ue,null),Zt(null),!Ae.previousPositions.size){se();return}const ot=new Map([...ie.current].map(([st,Yt])=>[st,Ae.previousPositions.get(st)??Yt]));Z(ot,re.animate,void 0,void 0,void 0,!0)}},swapGridNodes:(te,re,me)=>{var hn,Qt,ur,gt,er;const le=rt.current;if(!le||!le.ready||M.current.readOnly||te===re)return!1;const Ue=L(),_e=Ue.nodes.find(Wt=>Wt.id===te),Ae=Ue.nodes.find(Wt=>Wt.id===re);if(!_e||!Ae||_e.parent!==Ae.parent)return!1;const tt=ud(Ue,A(le.options));if(tt.skippedNodeIds.includes(te)||tt.skippedNodeIds.includes(re))return!1;const ot=le.order.indexOf(te),st=le.order.indexOf(re);if(ot<0||st<0)return!1;[le.order[ot],le.order[st]]=[le.order[st],le.order[ot]],Te.current=null,le.options={...le.options,order:[...le.order]};const Yt=_e.parent??"canvas",sr=(Qt=(hn=le.options.adjustment)==null?void 0:hn.sections)==null?void 0:Qt[Yt];return sr!=null&&sr.members&&(le.options={...le.options,adjustment:{...le.options.adjustment,sections:{...(ur=le.options.adjustment)==null?void 0:ur.sections,[Yt]:{...sr,members:sr.members.map(Wt=>Wt.map(fr=>fr===te?re:fr===re?te:fr))}}}}),mt.arrangeNodesInGrid({...le.options,animate:me??le.options.animate}),(er=(gt=M.current).onNodeGridModeChange)==null||er.call(gt,{...le.options}),!0},setNodePosition:(te,re,me)=>{if(!ie.current.has(te)||re&&(!Number.isFinite(re.x)||!Number.isFinite(re.y)))return!1;if(ar(),!re)return X.current.delete(te),se(),!0;const le=new Map(ie.current);return le.set(te,{...re}),(me==null?void 0:me.persist)===!1?X.current.delete(te):X.current.set(te,{...re}),ie.current=le,K(le),(me==null?void 0:me.persist)===!1&&se(),!0},onViewportChange:te=>O.onChange(te)}},[]);j.useEffect(()=>{var A,L;return(L=(A=M.current).onInit)==null||L.call(A,mt),()=>O.cancelAnimation()},[mt]),j.useEffect(()=>{var A,L;if(J>0){const z=ze.current;ze.current=null,z==null||z(),(L=(A=M.current).onLayoutComplete)==null||L.call(A,mt)}},[mt,J]);const ht=j.useRef(null),jt=j.useRef(new Map),_r=j.useRef(!1),[Rr,Kn]=j.useState(null),[ut,un]=j.useState(null),Jn=A=>{const L=_.current.getBoundingClientRect();return{x:(A.clientX-L.left)*(_.current.clientWidth/L.width||1),y:(A.clientY-L.top)*(_.current.clientHeight/L.height||1)}},Zn=(A,L)=>{const z=M.current.nodes;for(let Z=z.length-1;Z>=0;Z--){const ue=z[Z].id;if(!rr(ue,M.current.edges,M.current.edgeMode)||ft.current&&!ft.current.has(ue)||ue===L||je.current.has(ue))continue;const Ie=Ve(ue);if(Ie&&Uu(A,tr(Ie)))return ue}for(const[Z,ue]of je.current)if(rr(Z,M.current.edges,M.current.edgeMode)&&!(ft.current&&!ft.current.has(Z))&&Z!==L&&Uu(A,ue))return Z;return null},pu=(A,L)=>{const z=M.current.nodes.find(ke=>ke.id===A),Z=Ve(A);if(!z||!Z)return null;const ue=tr({...Z,x:Z.x+L.x,y:Z.y+L.y});let Ie=null,Ee=0;for(const ke of M.current.nodes){if(ke.id===A||ke.parent!==z.parent||X.current.has(ke.id)||je.current.has(ke.id)||!rr(ke.id,M.current.edges,M.current.edgeMode)||ft.current&&!ft.current.has(ke.id))continue;const et=Ve(ke.id);if(!et)continue;const ve=tr(et),$e=Math.max(0,Math.min(ue.x2,ve.x2)-Math.max(ue.x1,ve.x1))*Math.max(0,Math.min(ue.y2,ve.y2)-Math.max(ue.y1,ve.y1));$e>Ee&&(Ee=$e,Ie=ke.id)}return Ie},gu=(A,L)=>{const z=rt.current;if(!(z!=null&&z.ready)||M.current.readOnly)return;const Z=M.current.nodes.filter($e=>rr($e.id,M.current.edges,M.current.edgeMode)&&(!ft.current||ft.current.has($e.id))),ue=Z.find($e=>$e.id===A);if(!ue)return;const Ie=_.current,Ee=O.zoom*(Ie&&Ie.clientWidth?Ie.getBoundingClientRect().width/Ie.clientWidth:1),ke=24/Ee;let et;for(const $e of Z){if($e.id===A||$e.parent!==ue.parent)continue;const Ge=Ve($e.id);if(!Ge)continue;const te=tr(Ge),re=Math.min(Ge.w/4,ke),me=Math.min(Ge.h/4,ke),le=3/Ee,Ue=[];if(L.y>te.y1+me&&L.y<te.y2-me)for(const _e of["before","after"]){const Ae=_e==="before"?te.x1:te.x2,tt=Math.abs(L.x-Ae),ot=_e==="before"?L.x<Ae:L.x>Ae;tt<=(ot?ke:re)&&Ue.push({side:_e,distance:tt,marker:{x1:Ae-le/2,x2:Ae+le/2,y1:te.y1,y2:te.y2}})}if(L.x>=te.x1&&L.x<=te.x2)for(const _e of["above","below"]){const Ae=_e==="above"?te.y1:te.y2,tt=Math.abs(L.y-Ae),ot=_e==="above"?L.y<Ae:L.y>Ae;tt<=(ot?ke:me)&&Ue.push({side:_e,distance:tt,marker:{x1:te.x1,x2:te.x2,y1:Ae-le/2,y2:Ae+le/2}})}for(const _e of Ue)(!et||_e.distance<et.distance)&&(et={id:$e.id,..._e})}if(!et)return;const ve=Tj({nodes:Z,positions:ie.current,sizes:new Map([...I.current,...fe.current]),fixedSizes:fe.current,padding:$e=>M.current.containerStyle($e).padding,minSize:U,fixedIds:new Set(X.current.keys())},z.options,A,et.id,et.side);return ve?{options:ve,marker:et.marker}:void 0},zo=(A,L)=>{if(M.current.edgeMode==="nodes"||M.current.edgeMode==="workflow")return null;const z=M.current.direction==="RL",Z=Math.max(16,6/O.zoom);let ue=null;for(const Ie of[...M.current.nodes].reverse()){if(!rr(Ie.id,M.current.edges,M.current.edgeMode)||ft.current&&!ft.current.has(Ie.id))continue;const Ee=Ve(Ie.id),ke=D.current.get(Ie.id);if(!Ee||!ke||je.current.has(Ie.id))continue;const et=Ee.x+(L==="source"!==z?1:-1)*Ee.w/2;for(const ve of ke){if(ve.role&&ve.role!==L)continue;const $e=Ee.y-Ee.h/2+ve.top,Ge=Math.hypot(A.x-(ve.anchor?Ee.x-Ee.w/2+ve.anchor.x:et),A.y-$e-ve.height/2);if(!ve.anchor&&A.x>=Ee.x-Ee.w/2&&A.x<=Ee.x+Ee.w/2&&A.y>=$e&&A.y<=$e+ve.height)return{nodeId:Ie.id,property:ve.property};Ge<=Z&&(!ue||Ge<ue.distance)&&(ue={nodeId:Ie.id,property:ve.property,distance:Ge})}}return ue},dv=A=>{var ke,et;if(!A.currentTarget.contains(A.target)||(ht.current||(_r.current=!1),A.target.closest(".flow-sdk-canvas")!==A.currentTarget)||A.button!==0||M.current.readOnly)return;const L=A.target;if(L.closest('input, textarea, select, [contenteditable="true"], [data-flow-content-toggle]'))return;const z=M.current,Z=Jn(A);if(A.pointerType==="touch"){jt.current.set(A.pointerId,Z);const ve=Em(jt.current);if(ve){Zt(null),ht.current={kind:"pinch",distance:ve.distance,zoom:O.zoom,anchor:O.renderedToModel(ve.center)},un(null),Kn(null),_r.current=!0;for(const $e of jt.current.keys())A.currentTarget.setPointerCapture($e);return}}if(ht.current)return;const ue=!rt.current||!!z.nodeGridConnections,Ie=z.drawHandles&&L.closest(".flow-sdk-handle"),Ee=z.drawHandles&&L.closest(".flow-sdk-property-port");if((!ue||!Ie&&!Ee&&(!z.drawMode||A.shiftKey))&&(rt.current||A.shiftKey&&(z.onNodeGridDrop||z.onNodeParentChange))){if(rt.current&&!rt.current.ready||L.closest("button, input, textarea, select, a, [contenteditable=true], [data-flow-content]"))return;const ve=(ke=L.closest("[data-node-id]"))==null?void 0:ke.dataset.nodeId;if(ve&&!X.current.has(ve)){L.setPointerCapture(A.pointerId),ht.current={kind:"grid",pointerId:A.pointerId,captureTarget:L,source:ve,start:Z,moved:!1};return}if(ve)return}if(ue&&(z.drawMode||Ie||Ee)){const ve=O.renderedToModel(Z),$e=z.drawMode?zo(ve,"source"):null,Ge=Ee||Ie,te=Ge?(et=Ge.closest("[data-node-id]"))==null?void 0:et.dataset.nodeId:($e==null?void 0:$e.nodeId)??Zn(ve),re=Ee?Ee.dataset.property:$e==null?void 0:$e.property;if(te){ht.current={kind:"draw",pointerId:A.pointerId,source:te,sourceProperty:re,reverse:(Ee==null?void 0:Ee.dataset.portRole)==="target",startClient:{x:A.clientX,y:A.clientY}},_r.current=!0,un({source:te,sourceProperty:re,point:ve,target:null}),A.currentTarget.setPointerCapture(A.pointerId);return}}L.closest(".flow-sdk-node, .flow-sdk-container, .flow-sdk-edge, .flow-sdk-edge-label, .flow-sdk-container-label")||(Te.current=null,z.multiSelect?ht.current={kind:"box",pointerId:A.pointerId,start:Z,current:Z}:z.dragMode?ht.current={kind:"pan",pointerId:A.pointerId,start:Z,pan0:O.pan,moved:!1}:ht.current={kind:"tap",pointerId:A.pointerId,start:Z,moved:!1},A.currentTarget.setPointerCapture(A.pointerId))},uv=A=>{var Z,ue,Ie;const L=ht.current;if(!L||M.current.readOnly)return;const z=Jn(A);if(jt.current.has(A.pointerId)&&jt.current.set(A.pointerId,z),L.kind==="pinch"){const Ee=Em(jt.current);if(!Ee)return;const ke=Math.max(O.minZoom,Math.min(O.maxZoom,L.zoom*Ee.distance/L.distance));if(ke<O.zoom&&((Z=rt.current)!=null&&Z.options.fill)&&((Ie=(ue=M.current).onNodeGridZoomOut)==null?void 0:Ie.call(ue,rt.current.options))===!0)return;O.set({x:Ee.center.x-L.anchor.x*ke,y:Ee.center.y-L.anchor.y*ke},ke);return}if(L.pointerId===A.pointerId)switch(L.kind){case"grid":{const Ee={x:z.x-L.start.x,y:z.y-L.start.y};if(!L.moved&&Math.hypot(Ee.x,Ee.y)<=hd)return;L.moved||(ar(),Te.current=null,O.cancelAnimation()),L.moved=!0,_r.current=!0,A.preventDefault();const ke={x:Ee.x/O.zoom,y:Ee.y/O.zoom},et=!A.shiftKey&&z.x>=0&&z.y>=0&&z.x<=O.size.w&&z.y<=O.size.h?gu(L.source,O.renderedToModel(z)):void 0;Zt({source:L.source,offset:ke,target:A.shiftKey||et?null:pu(L.source,ke),shiftKey:A.shiftKey,insertion:et});break}case"pan":{const Ee=z.x-L.start.x,ke=z.y-L.start.y;if(!L.moved&&Math.hypot(Ee,ke)<=hd)return;L.moved=!0,_r.current=!0,O.set({x:L.pan0.x+Ee,y:L.pan0.y+ke});break}case"tap":{Math.hypot(z.x-L.start.x,z.y-L.start.y)>hd&&(L.moved=!0);break}case"box":{_r.current=!0,L.current=z,Kn({x1:Math.min(L.start.x,z.x),y1:Math.min(L.start.y,z.y),x2:Math.max(L.start.x,z.x),y2:Math.max(L.start.y,z.y)});break}case"draw":{const Ee=O.renderedToModel(z),ke=zo(Ee,L.reverse?"source":"target");un(L.reverse&&ke?{source:ke.nodeId,sourceProperty:ke.property,point:Ee,target:L.source,targetProperty:L.sourceProperty}:{source:L.source,sourceProperty:L.sourceProperty,point:Ee,target:(ke==null?void 0:ke.nodeId)??Zn(Ee,L.source),targetProperty:ke==null?void 0:ke.property});break}}},yu=(A,L)=>{var ue,Ie,Ee,ke,et,ve,$e,Ge,te,re,me;jt.current.delete(A.pointerId);const z=ht.current;if(!z)return;if(z.kind==="pinch"){const le=[...jt.current][0];ht.current=le&&M.current.dragMode&&!L?{kind:"pan",pointerId:le[0],start:le[1],pan0:O.pan,moved:!0}:null;return}if(z.pointerId!==A.pointerId)return;ht.current=null;try{(z.kind==="grid"?z.captureTarget:A.currentTarget).releasePointerCapture(A.pointerId)}catch{}const Z=M.current;switch(L=L||!!Z.readOnly,z.kind){case"grid":{if(Zt(null),L||!z.moved)break;const le=Jn(A);if(!A.shiftKey&&le.x>=0&&le.y>=0&&le.x<=O.size.w&&le.y<=O.size.h){const _e=gu(z.source,O.renderedToModel(le));if(_e){mt.setNodeGridMode(!0,{..._e.options,animate:!1});break}}if(((ue=Z.onNodeGridDrop)==null?void 0:ue.call(Z,z.source,{x:A.clientX,y:A.clientY},{shiftKey:A.shiftKey,ctrlKey:A.ctrlKey,metaKey:A.metaKey,altKey:A.altKey}))===!0||le.x<0||le.y<0||le.x>O.size.w||le.y>O.size.h)break;if(A.shiftKey){const _e=new Map(Z.nodes.map(ot=>[ot.id,ot]));let Ae=Zn(O.renderedToModel(le),z.source);const tt=new Set;for(;Ae&&!((Ie=_e.get(Ae))!=null&&Ie.acceptsChildren)&&!tt.has(Ae);)tt.add(Ae),Ae=((Ee=_e.get(Ae))==null?void 0:Ee.parent)??null;if(Ae&&((ke=_e.get(Ae))!=null&&ke.acceptsChildren)){let ot=Ae;const st=new Set;for(;ot&&!st.has(ot);)st.add(ot),ot=(et=_e.get(ot))==null?void 0:et.parent;st.has(z.source)||(ve=Z.onNodeParentChange)==null||ve.call(Z,z.source,Ae)}break}if(!rt.current)break;const Ue=pu(z.source,{x:(le.x-z.start.x)/O.zoom,y:(le.y-z.start.y)/O.zoom});Ue&&mt.swapGridNodes(z.source,Ue,!1);break}case"pan":case"tap":!L&&!z.moved&&(($e=Z.onBackgroundTap)==null||$e.call(Z));break;case"box":{if(Kn(null),L)break;const le=O.renderedToModel(z.start),Ue=O.renderedToModel(z.current),_e={x1:Math.min(le.x,Ue.x),y1:Math.min(le.y,Ue.y),x2:Math.max(le.x,Ue.x),y2:Math.max(le.y,Ue.y)};if(_e.x2-_e.x1<1&&_e.y2-_e.y1<1){(Ge=Z.onBackgroundTap)==null||Ge.call(Z);break}const Ae=[];for(const tt of Z.nodes){const ot=Ve(tt.id);ot&&Jw(tr(ot),_e)&&Ae.push(tt.id)}Ae.length&&((te=Z.onBoxSelect)==null||te.call(Z,Ae));break}case"draw":{if(un(null),L)break;const le=Jn(A),Ue=O.renderedToModel(le),_e=zo(Ue,z.reverse?"source":"target"),Ae=(_e==null?void 0:_e.nodeId)??Zn(Ue);if(Ae===z.source&&(z.sourceProperty===void 0||(_e==null?void 0:_e.property)===void 0||_e.property===z.sourceProperty))break;Ae?(re=Z.onEdgeDraw)==null||re.call(Z,z.reverse?Ae:z.source,z.reverse?z.source:Ae,z.sourceProperty!==void 0||(_e==null?void 0:_e.property)!==void 0?{sourceProperty:z.reverse?_e==null?void 0:_e.property:z.sourceProperty,targetProperty:z.reverse?z.sourceProperty:_e==null?void 0:_e.property}:void 0):Math.max(Math.abs(A.clientX-z.startClient.x),Math.abs(A.clientY-z.startClient.y))>Vj&&((me=Z.onDrawIntoSpace)==null||me.call(Z,z.source,Ue,z.sourceProperty,z.reverse));break}}},kr=j.useCallback(()=>{var z;const A=ht.current,L=[...jt.current.keys()];A&&A.kind!=="pinch"&&L.push(A.pointerId),ht.current=null,jt.current.clear(),Zt(null),un(null),Kn(null);for(const Z of L)(A==null?void 0:A.kind)==="grid"&&A.captureTarget.hasPointerCapture(Z)&&A.captureTarget.releasePointerCapture(Z),(z=_.current)!=null&&z.hasPointerCapture(Z)&&_.current.releasePointerCapture(Z)},[]);j.useEffect(()=>{const A=L=>{L.key==="Escape"&&kr()};return window.addEventListener("keydown",A),window.addEventListener("blur",kr),()=>{window.removeEventListener("keydown",A),window.removeEventListener("blur",kr),ht.current=null,jt.current.clear()}},[kr]),j.useEffect(()=>{kr()},[y,b,x,i,n,e.drawHandles,e.readOnly,at,kr]);const fv=j.useMemo(()=>{const A=new Map,L=new Map;for(const z of k){if(z.source!==z.target)continue;const Z=A.get(z.source)??0;A.set(z.source,Z+1),L.set(z.id,Z)}return L},[k]),Bo=Dj[n],[Ar,hv]=j.useState(null),Do=zj(r,k,!!((wu=e.edgeReveal)!=null&&wu.revealNodes));j.useLayoutEffect(()=>{_.current&&Ar&&jm(_.current,Ar)}),j.useEffect(()=>{const A=_.current;if(!A||!Ar)return;const L=A.ownerDocument.fonts,z=()=>jm(A,Ar);return L==null||L.addEventListener("loadingdone",z),()=>L==null?void 0:L.removeEventListener("loadingdone",z)},[Ar]);const Vo=Hw(k,kt,Bo),pv=e.onEdgeSelect,gv=e.onContainerSelect,mu=ut?ut.target&&kt(ut.target,ut.targetProperty)||{x:ut.point.x,y:ut.point.y,w:1,h:1}:null,bu=ut?kt(ut.source,ut.sourceProperty):null,fn=!at||!!e.nodeGridConnections,yv=["flow-sdk-canvas",y&&fn?"flow-sdk-draw":"",v?"flow-sdk-perf":""].filter(Boolean).join(" ");return f.jsxs("div",{ref:_,className:yv,"data-edge-mode":i,"data-node-grid":at||void 0,"data-grid-connections":e.nodeGridConnections||void 0,onPointerDownCapture:dv,onPointerMove:uv,onPointerUp:A=>yu(A,!1),onPointerCancel:A=>yu(A,!0),onLostPointerCapture:A=>{const L=ht.current;L&&(L.kind==="pinch"||L.pointerId===A.pointerId)&&kr()},onClickCapture:A=>{if(!A.currentTarget.contains(A.target))return;const L=A.target instanceof Element&&A.target.closest("button[data-flow-fullscreen], button[data-flow-content-navigation]");(_r.current||e.readOnly&&!L)&&(A.preventDefault(),A.stopPropagation())},children:[f.jsx("svg",{className:"flow-sdk-svg",children:f.jsxs("g",{ref:N,children:[f.jsx("g",{className:"flow-sdk-containers",children:[...Ne].filter(([A])=>rr(A,t,i)).filter(([A])=>!R||R.has(A)).map(([A,L])=>{var z,Z;return f.jsx(a1,{id:A,rect:L,label:Ce.get(A),labelLayer:Ar,labelContent:(z=r.find(ue=>ue.id===A&&ue.label!==void 0))==null?void 0:z.element,style:m(A),onSelect:gv,onCollapse:e.readOnly?void 0:e.onContainerCollapse,selected:(Z=e.selectedNodeIds)==null?void 0:Z.includes(A)},A)})}),f.jsx("g",{className:"flow-sdk-edges",children:Ze&&fn&&k.map(A=>{var Z,ue,Ie;if(!Do.ready.has(A.id)||R&&(!R.has(A.source)||!R.has(A.target)))return null;const L=kt(A.source,A.sourceProperty),z=kt(A.target,A.targetProperty);return!L||!z?null:f.jsx(Qu,{id:A.id,edgeData:A.data,validationIssue:A.validationIssue,edgeType:A.type,edgeRadius:e.edgeRadius,propertyMode:P,customEdgeTypes:e.customEdgeTypes,reveal:e.edgeReveal,onRevealComplete:Do.complete,source:L,target:z,sourceProperty:A.sourceProperty,targetProperty:A.targetProperty,sourceY:Xe(A.source,A.sourceProperty),targetY:Xe(A.target,A.targetProperty),sourcePort:St(A.source,A.sourceProperty),targetPort:St(A.target,A.targetProperty),dir:Bo,turn:((Z=Vo.get(A.id))==null?void 0:Z.turn)??A.turn,labelAtTarget:(ue=Vo.get(A.id))==null?void 0:ue.labelAtTarget,labelFraction:(Ie=Vo.get(A.id))==null?void 0:Ie.labelFraction,color:A.color,connectorColor:A.connectorColor,labelBg:A.labelBg,label:A.label,labelLayer:Ar,dashed:A.dashed,animated:A.animated&&!v,inverted:A.inverted,loopIndex:fv.get(A.id)??0,onSelect:pv},A.id)})}),Ze&&fn&&ut&&wd(ut,i)&&bu&&mu&&f.jsx("g",{className:"flow-sdk-ghost",pointerEvents:"none",children:f.jsx(Qu,{id:"__flow-sdk-ghost",edgeData:{id:"__flow-sdk-ghost",source:ut.source,target:ut.target??"",sourceProperty:ut.sourceProperty,targetProperty:ut.targetProperty},edgeType:e.edgeType,edgeRadius:e.edgeRadius,propertyMode:P,customEdgeTypes:e.customEdgeTypes,source:bu,target:mu,sourceProperty:ut.sourceProperty,targetProperty:ut.targetProperty,sourceY:Xe(ut.source,ut.sourceProperty),sourcePort:St(ut.source,ut.sourceProperty),targetPort:ut.target?St(ut.target,ut.targetProperty):void 0,targetY:ut.target?Xe(ut.target,ut.targetProperty):void 0,dir:Bo,turn:.5,color:g,labelBg:g})})]})}),f.jsxs("div",{ref:B,className:"flow-sdk-nodes",children:[(Ke==null?void 0:Ke.insertion)&&f.jsx("div",{className:"flow-sdk-box","data-grid-insertion":"",style:{left:Ke.insertion.marker.x1,top:Ke.insertion.marker.y1,width:Ke.insertion.marker.x2-Ke.insertion.marker.x1,height:Ke.insertion.marker.y2-Ke.insertion.marker.y1,background:g,border:0}}),at&&((Cu=rt.current)==null?void 0:Cu.options.fill)&&((Su=rt.current.options.adjustment)==null?void 0:Su.enabled)&&!e.readOnly&&f.jsx($j,{dividers:Rt,options:rt.current.options,zoom:O.zoom,onChange:A=>mt.setNodeGridMode(!0,{...A,animate:!1})}),r.map(A=>{var Ue,_e,Ae;if((Ue=rt.current)!=null&&Ue.options.fill&&!be.current)return null;const L=Q.get(A.id),z=Ne.get(A.id);if(z&&A.label!==void 0)return null;const Z=(L==null?void 0:L.x)??(z?(z.x1+z.x2)/2:0),ue=(L==null?void 0:L.y)??(z?(z.y1+z.y2)/2:0),Ie=Ke!=null&&Ke.target?A.id===Ke.source?Ke.target:A.id===Ke.target?Ke.source:void 0:void 0,Ee=Ie?Q.get(Ie):void 0,ke=Ke?Q.get(Ke.source):void 0,et=Ke!=null&&Ke.target?Q.get(Ke.target):void 0,ve=ke&&et?{x:et.x-ke.x,y:et.y-ke.y}:void 0,$e=ve?ve.x**2+ve.y**2:0,Ge=$e&&Ke&&ve?Math.max(0,Math.min(1,(Ke.offset.x*ve.x+Ke.offset.y*ve.y)/$e)):0,te=Ee?{x:Z+(Ee.x-Z)*Ge,y:ue+(Ee.y-ue)*Ge}:(Ke==null?void 0:Ke.source)===A.id?{x:Z+Ke.offset.x,y:ue+Ke.offset.y}:void 0,re=ye.get(A.id),me=Ie?ye.get(Ie):void 0,le=re&&me?{w:re.w+(me.w-re.w)*Ge,h:re.h+(me.h-re.h)*Ge}:re;return f.jsx(Fj,{id:A.id,x:Z,y:ue,gridDraggable:at&&!e.readOnly&&!X.current.has(A.id),gridDragging:(Ke==null?void 0:Ke.source)===A.id,gridDropTarget:(Ke==null?void 0:Ke.target)===A.id,gridSize:ye.get(A.id),gridPreview:te?{...te,size:le,floating:Ke==null?void 0:Ke.shiftKey}:void 0,placed:!!L||!!z,hidden:!at&&!Do.shown.has(A.id)||!rr(A.id,t,i)||!!R&&!R.has(A.id),onMount:Be,drawHandles:e.drawHandles&&!e.readOnly&&fn,drawMode:y&&fn,connectedPorts:new Set(k.flatMap(tt=>[...tt.source===A.id&&tt.sourceProperty!==void 0?[`source:${tt.sourceProperty}`]:[],...tt.target===A.id&&tt.targetProperty!==void 0?[`target:${tt.targetProperty}`]:[]])),hasCollapseControl:A.hasCollapseControl,handleColor:g,animated:A.animated&&!z&&!v&&!at,animationColor:A.animationColor,animationWidth:A.animationWidth,animationVariant:A.animationVariant,width:(_e=I.current.get(A.id))==null?void 0:_e.w,height:(Ae=I.current.get(A.id))==null?void 0:Ae.h,propertyMode:P,resolvedRows:nt.get(A.id),reversePorts:n==="RL",direction:n,onPropertyRows:ce,onSurface:q,children:re?A.fillElement??A.element:A.element},A.id)})]}),Rr&&f.jsx("div",{className:"flow-sdk-box",style:{left:Rr.x1,top:Rr.y1,width:Rr.x2-Rr.x1,height:Rr.y2-Rr.y1}}),f.jsx("svg",{className:"flow-sdk-svg flow-sdk-label-overlay",style:{zIndex:11,pointerEvents:"none"},children:f.jsx("g",{ref:$,transform:`translate(${O.pan.x} ${O.pan.y}) scale(${O.zoom})`,children:f.jsx("g",{ref:hv,className:"flow-sdk-labels",style:{pointerEvents:y?"none":"visiblePainted",outline:"none"}})})})]})}const Hj=j.memo(Uj);function lu(e=!0){const r=j.useRef(null);return j.useEffect(()=>{if(!e||!r.current)return;const t=i=>{i.stopPropagation()},n=r.current,o=["mousedown","mouseup","click","dblclick","pointerdown","pointerup","wheel"];return o.forEach(i=>n.addEventListener(i,t)),()=>{o.forEach(i=>n.removeEventListener(i,t))}},[e]),r}const tn=({nodeId:e,label:r,color:t,fontWeight:n="bold",fontSize:o="5xl",wrap:i=!1,isEditing:s,onEditStart:a,onEditEnd:c})=>{const{callbacks:l,config:d,readOnly:u}=Je(),h=d.editable&&!u,[p,m]=j.useState(r),[g,y]=j.useState(),b=j.useRef(null),x=j.useRef(!1),v=lu(s);j.useEffect(()=>{if(s&&(x.current=!1,b.current)){b.current.focus();const C=b.current.value.length;b.current.setSelectionRange(C,C)}},[s]);const w=()=>{var S;if(x.current)return;x.current=!0;const C=p.trim();C&&C!==r&&((S=l.onNodeLabelChange)==null||S.call(l,e,C)),c()};return!h||!s?f.jsx(V.Text,{color:t,fontWeight:n,fontSize:o,minW:0,maxW:"100%",whiteSpace:i?"normal":"nowrap",overflowWrap:i?"anywhere":void 0,overflow:"hidden",textOverflow:"ellipsis",title:r,onDoubleClick:h?C=>{C.stopPropagation(),y({width:C.currentTarget.offsetWidth,height:C.currentTarget.offsetHeight}),m(r),a()}:void 0,cursor:h?"text":void 0,children:r}):f.jsxs("div",{ref:v,style:{position:"relative",width:"max-content",minWidth:g==null?void 0:g.width,maxWidth:900,height:g==null?void 0:g.height},children:[f.jsx(V.Text,{as:"span","aria-hidden":"true",display:"block",visibility:"hidden",fontWeight:n,fontSize:o,lineHeight:"normal",whiteSpace:"pre",overflow:"hidden",children:p||" "}),f.jsx(V.Input,{ref:b,value:p,onChange:C=>m(C.target.value),onBlur:w,onKeyDown:C=>{C.key==="Enter"&&w(),C.key==="Escape"&&(x.current=!0,c())},color:t,fontWeight:n,fontSize:o,bg:"transparent",borderWidth:0,_focus:{outline:"none",boxShadow:"none"},_focusVisible:{outline:"none",boxShadow:"none"},p:0,display:"block",position:"absolute",top:0,left:0,w:"100%",h:"100%",minW:0,minH:0,lineHeight:"normal"})]})};function tv({id:e,label:r,role:t,side:n,position:o=.5,placement:i,children:s,style:a}){return f.jsx("div",{"data-flow-property":e,"data-flow-port-role":t,"data-flow-port-side":n,"data-flow-port-position":n?o:void 0,"data-flow-port-placement":i,style:{minHeight:32,display:"flex",alignItems:"center",justifyContent:t==="source"?"flex-end":"flex-start",...a,...n?{display:"none"}:{}},children:s??r??e})}const Kj=fo.default.dialog`
|
|
209
|
+
`;function Wu({request:e,property:r,config:t,value:n,disabled:o}){var he,ge,X,H,be;const{callbacks:i,structured:s,references:a}=j.useContext(Tt),{themeColor:c}=Ze(),{background:l}=lt(),d=j.useId(),u=r.type.kind==="object"||r.type.kind==="array"||r.type.kind==="json",h=n===void 0?"":u?JSON.stringify(n,null,2):String(n),[p,m]=j.useState(h),[g,y]=j.useState(""),[b,x]=j.useState(0),v=j.useRef(null),w=j.useRef(),[C,S]=j.useState(!1),[R,P]=j.useState(!1),[k,T]=j.useState(),E=((he=t.$options)==null?void 0:he.$source)==="callback",M=i.resolveFormOptions,{data:_,address:O,nodeAddress:$,nodeId:B}=e;j.useEffect(()=>(S(!1),P(!1),()=>{var J;(J=w.current)==null||J.abort(),w.current=void 0}),[O,$,B,o,h,t.$control,(ge=t.$upload)==null?void 0:ge.accept,(X=t.$upload)==null?void 0:X.maxSizeBytes]);const N=j.useRef(_);N.current=_;const I=JSON.stringify([O,B,(H=t.$options)!=null&&H.$dependsOn?t.$options.$dependsOn.map(J=>Le(_,J)):Le(_,$)]);j.useEffect(()=>{m(h),y("")},[h,O,B]),j.useEffect(()=>{if(!E)return;const J=new AbortController;return Promise.resolve().then(()=>{if(!M)throw new Error("No options resolver configured");return M({address:O,nodeAddress:$,nodeId:B,data:Qr(N.current),signal:J.signal})}).then(xe=>{if(!Array.isArray(xe)||xe.some(Se=>!Se||typeof Se.label!="string"||!["string","number","boolean"].includes(typeof Se.value)&&Se.value!==null))throw new Error("Invalid options response");J.signal.aborted||T({key:I,options:xe})}).catch(xe=>{J.signal.aborted||T({key:I,options:[],error:xe instanceof Error?xe.message:"Options unavailable"})}),()=>J.abort()},[E,M,I,O,$,B,b]);const ee=E&&(k==null?void 0:k.key)!==I,ae=E?(k==null?void 0:k.key)===I?k.options:[]:r.type.kind==="null"?[{label:"Null",value:null}]:r.type.kind==="boolean"?[{label:"Yes",value:!0},{label:"No",value:!1}]:kn(r.type),ne=r.type.kind==="array",oe=(t.$control==="upload"?"upload":s&&u||t.$control==="checkbox"?"pills":t.$control)??(ae?ne||r.type.kind==="boolean"?"pills":"select":r.type.kind==="boolean"?"checkbox":u?"textarea":"input"),pe=!r.optional||!!t.$requiredWhen&&bo(t.$requiredWhen,_),q=pe?"Required":"Optional",F=oe!=="upload"&&!!(a!=null&&a.length)&&typeof n=="string"&&n.includes("{{"),G=g||E&&(k==null?void 0:k.key)===I&&k.error||!F&&Ut(r.type,n,pe),D=Ft(t.$label??O.split(".").pop()),ce=J=>{var xe;if(!(o||Object.is(J,n)))try{(xe=i.onFormChange)==null||xe.call(i,{...e,previousValue:n,value:J}),y("")}catch(Se){y(Se instanceof Error?Se.message:"Unable to update field")}},Q=j.useRef(ce);j.useLayoutEffect(()=>{Q.current=ce});const K=()=>{if(u){try{const Fe=p===""&&r.optional?void 0:JSON.parse(p),De=Ut(r.type,Fe,pe);if(De){y(De);return}ce(Fe)}catch{y("Enter valid JSON")}return}const J=r.type.kind==="number"||r.type.kind==="integer",xe=p===""&&r.optional?void 0:J&&p!==""?Number(p):p,Se=Ut(r.type,xe,pe);if(J&&Se&&p!==""){y(Se);return}ce(xe)},ie=async J=>{var Se,Fe,De;if(o||w.current||!J.length)return;const xe=new AbortController;w.current=xe,y(""),S(!0);try{if(r.type.kind!=="string"&&!(r.type.kind==="array"&&r.type.items.kind==="string"))throw new Error("Uploads require a string or string-array field.");if(!ne&&J.length!==1)throw new Error("Choose one file for this field.");if(!i.uploadFormFile)throw new Error("No file upload handler configured.");const ue=(Fe=(Se=t.$upload)==null?void 0:Se.accept)==null?void 0:Fe.split(",").map(qe=>qe.trim().toLowerCase()).filter(Boolean);for(const qe of J){if(((De=t.$upload)==null?void 0:De.maxSizeBytes)!==void 0&&qe.size>t.$upload.maxSizeBytes)throw new Error(`${qe.name} exceeds the file size limit.`);if(ue!=null&&ue.length&&!ue.some(Qe=>Qe.startsWith(".")?qe.name.toLowerCase().endsWith(Qe):Qe.endsWith("/*")?qe.type.toLowerCase().startsWith(Qe.slice(0,-1)):qe.type.toLowerCase()===Qe))throw new Error(`${qe.name} is not an accepted file type.`)}const Re=await Promise.all(J.map(async qe=>{const Qe=await i.uploadFormFile({...e,data:Qr(_),file:qe,signal:xe.signal});if(typeof Qe!="string")throw new Error("Upload handler must return an HTTP or HTTPS URL.");let ct;try{ct=new URL(Qe)}catch{throw new Error("Upload handler must return an HTTP or HTTPS URL.")}if(!["http:","https:"].includes(ct.protocol)||ct.username||ct.password)throw new Error("Upload handler must return an HTTP or HTTPS URL.");return Qe}));if(xe.signal.aborted||w.current!==xe)return;const ze=ne?[...Array.isArray(n)?n:[],...Re]:Re[0],Te=Ut(r.type,ze,pe);if(Te)throw new Error(Te);Q.current(ze)}catch(ue){xe.signal.aborted||y(ue instanceof Error?ue.message:"Unable to upload file."),xe.abort()}finally{w.current===xe&&(w.current=void 0,S(!1))}},ye={id:d,disabled:o,"aria-label":D,"aria-required":pe,"aria-invalid":!!G,"aria-describedby":G?`${d}-error`:void 0},we=Me(c);return f.jsxs("div",{"data-form-field":O,"data-flow-property":O.slice($.length+1),children:[f.jsxs("div",{style:{display:"flex",justifyContent:"space-between",alignItems:"center"},children:[f.jsxs("label",{htmlFor:d,children:[D,pe?" *":""]}),r.optional&&n!==void 0&&f.jsx("button",{type:"button","aria-label":`Reset ${D}`,title:`Reset ${D}`,disabled:o||C,style:{width:24,height:24,padding:0,display:"inline-flex",alignItems:"center",justifyContent:"center",flexShrink:0,border:0,background:"transparent",color:"inherit"},onClick:()=>ce(void 0),children:f.jsx(Y.PiArrowCounterClockwise,{size:14})})]}),!!(a!=null&&a.length)&&!u&&oe!=="upload"&&f.jsx(Tw,{label:D,value:n,references:a,disabled:o,onChange:ce}),oe==="upload"?f.jsxs("div",{"data-form-upload":ne?"multiple":"single","aria-busy":C,style:{"--flow-upload-surface":Me(l),outline:R?"2px dashed var(--flow-form-input-background)":void 0,borderRadius:"var(--flow-form-input-radius)"},onDragOver:J=>{J.preventDefault(),J.stopPropagation(),!o&&!C&&(J.dataTransfer.dropEffect="copy",P(!0))},onDragLeave:J=>{J.currentTarget.contains(J.relatedTarget)||P(!1)},onDrop:J=>{J.preventDefault(),J.stopPropagation(),P(!1),ie(Array.from(J.dataTransfer.files))},children:[f.jsx("input",{ref:v,type:"file",hidden:!0,"aria-label":`Upload ${D}`,accept:(be=t.$upload)==null?void 0:be.accept,multiple:ne,disabled:o||C,onChange:J=>{const xe=Array.from(J.target.files??[]);J.target.value="",ie(xe)}}),f.jsxs("div",{"data-upload-items":"",children:[(ne?Array.isArray(n)?n:[]:n?[n]:[]).map((J,xe)=>f.jsxs("div",{"data-upload-preview":"",children:[typeof J=="string"&&hr(J)&&f.jsxs("a",{href:J,target:"_blank",rel:"noopener noreferrer","aria-label":`${D} file ${xe+1}`,children:[f.jsx(Y.PiFile,{size:32,"aria-hidden":"true"}),f.jsx(or,{name:J,size:120,onError:Se=>{Se.currentTarget.style.visibility="hidden"}})]}),f.jsxs("div",{"data-upload-actions":"",children:[!ne&&f.jsx(Ne,{"aria-label":`Replace ${D}`,title:`Replace ${D}`,icon:f.jsx(Y.PiUploadSimple,{}),size:"xs",variant:"ghost",disabled:o||C,onClick:()=>{var Se;return(Se=v.current)==null?void 0:Se.click()}}),f.jsx(Ne,{"aria-label":`Remove ${D} file ${xe+1}`,title:"Remove file",icon:f.jsx(Y.PiTrash,{}),size:"xs",variant:"ghost",disabled:o||C,onClick:()=>ce(ne&&Array.isArray(n)?n.filter((Se,Fe)=>Fe!==xe):"")})]})]},`${xe}:${J}`)),(ne||!n)&&f.jsx("button",{...ye,type:"button","data-upload-drop":"",title:`Upload ${D}`,disabled:o||C,onClick:()=>{var J;return(J=v.current)==null?void 0:J.click()},children:f.jsx(Y.PiPlus,{size:28,"aria-hidden":"true"})})]}),C&&f.jsx("span",{role:"status",children:"Uploading..."})]}):F?null:oe==="select"?f.jsx("div",{"data-form-select":"",children:f.jsxs(Mt,{...ye,disabled:o||ee||!!(k!=null&&k.error),labelCase:"preserve",value:String((ae==null?void 0:ae.findIndex(J=>Object.is(J.value,n)))??-1),onValueChange:J=>{const xe=ae==null?void 0:ae[Number(J)];xe&&ce(xe.value)},children:[f.jsx("option",{value:-1,disabled:!0,children:n!==void 0&&n!==""?String(n):q}),ae==null?void 0:ae.map((J,xe)=>f.jsx("option",{value:xe,children:Ft(J.label)||J.label},xe))]})}):oe==="pills"?f.jsxs("div",{id:d,role:"group","aria-label":D,"aria-describedby":ye["aria-describedby"],style:{display:"flex",flexWrap:"wrap",gap:8},children:[ae==null?void 0:ae.map((J,xe)=>{const Se=ne?Array.isArray(n)&&n.includes(J.value):Object.is(n,J.value);return f.jsx("button",{type:"button",disabled:o||ee,"aria-pressed":Se,style:{padding:"8px 16px",borderRadius:24,border:0,color:Se?we:"inherit",background:Se?"color-mix(in srgb, currentColor 12%, transparent)":"color-mix(in srgb, currentColor 7%, transparent)"},onClick:()=>ce(ne?Se?n.filter(Fe=>Fe!==J.value):[...Array.isArray(n)?n:[],J.value]:J.value),children:Ft(J.label)||J.label},xe)}),ee&&f.jsx("span",{role:"status",children:"Loading..."})]}):oe==="textarea"?f.jsx("textarea",{...ye,placeholder:q,value:p,onChange:J=>m(J.target.value),onBlur:K}):f.jsx("input",{...ye,placeholder:q,type:r.type.kind==="number"||r.type.kind==="integer"?"number":"text",step:r.type.kind==="integer"?1:"any",value:p,onChange:J=>m(J.target.value),onBlur:K,onKeyDown:J=>{J.key==="Enter"&&K(),J.key==="Escape"&&m(n===void 0?"":String(n))}}),G&&f.jsx("div",{role:"alert",id:`${d}-error`,children:G}),E&&(k==null?void 0:k.error)&&f.jsx("button",{type:"button",disabled:o,onClick:()=>{T(void 0),x(b+1)},children:"Retry"})]})}function Ld({nodeAddress:e,structured:r=!1}){return r?f.jsx(Ow,{nodeAddress:e},e):f.jsx(bd,{nodeAddress:e})}function Ow({nodeAddress:e}){var u,h,p;const r=j.useContext(Tt),[t,n]=j.useState([]),o=((u=r.structured)==null?void 0:u.sourceSchema)??r.schema,i=((h=r.structured)==null?void 0:h.sourceBindings)??r.bindings,s=j.useMemo(()=>{if(!(!r.data||!o||!i))return xb(r.data,i,o,[{data:{id:e,type:"objectView"}}])},[r.data,i,o,e]);if(!s)return f.jsx(bd,{nodeAddress:e});const a=t.findIndex(m=>!s.containers.has(m)),c=a<0?t:t.slice(0,a),l=c.at(-1)??e,d=(p=[...s.slots.values()].find(m=>m.nodeId===l))==null?void 0:p.label;return f.jsxs(Tt.Provider,{value:{...r,structured:s,schema:s.schema,bindings:s.bindings,renderForm:void 0,onFieldCreate:l===e?r.onFieldCreate:void 0},children:[!!c.length&&f.jsxs("div",{style:{display:"flex",alignItems:"center",gap:8,marginBottom:8},children:[f.jsx(Ne,{"aria-label":"Back to parent fields",title:"Back to parent fields",icon:f.jsx(Y.PiArrowLeft,{size:18}),size:"sm",variant:"ghost",onClick:()=>n(c.slice(0,-1))}),f.jsx("strong",{style:{minWidth:0,overflowWrap:"anywhere"},children:Ft(d)})]}),f.jsx(bd,{nodeAddress:l,onOpen:m=>n([...c,m])},l)]})}function bd({nodeAddress:e,onOpen:r}){var S,R;const{data:t,schema:n,callbacks:o,bindings:i,editable:s,renderForm:a,structured:c}=j.useContext(Tt),{readOnly:l,config:d,colorMode:u}=Ze(),h=a==null?void 0:a(e);if(h!==void 0)return f.jsx("fieldset",{"data-flow-form":e,disabled:l||d.editable===!1||!s,style:{border:0,margin:0,padding:0,minWidth:0},children:h});if(!t)return f.jsx(Xn,{$colorMode:u,role:"alert",children:"Forms require a JSON document."});const p=i?Fn(i,e,n):void 0,m=i?p:n&&on(t,e,n);if(!m)return f.jsx(Xn,{$colorMode:u,role:"status",children:"Form schema unavailable."});const g=(p==null?void 0:p.address)??e,y=Le(t,g),b=(S=c==null?void 0:c.containers.get(e))==null?void 0:S.scalar;if(y===void 0||typeof y!="object"&&!b)return f.jsx(Xn,{$colorMode:u,role:"alert",children:"Bound form state is unavailable."});const x=Object.entries(m.type.properties).filter(([P])=>{var k;return bo((k=m.fields[P])==null?void 0:k.$visibleWhen,t)}),v=x.length>8||x.some(([P])=>{var k;return(k=m.fields[P])==null?void 0:k.$section}),w=new Map;for(const P of x){const[k,T]=P,E=v?Ft(((R=m.fields[k])==null?void 0:R.$section)??(T.type.kind==="object"||T.type.kind==="array"?k:T.optional?"Options":"General")):"";w.has(E)||w.set(E,[]),w.get(E).push(P)}const C=([P,k])=>f.jsx(Wu,{request:{data:t,address:b?g:`${g}.${P}`,nodeAddress:g,nodeId:typeof(y==null?void 0:y.id)=="string"?y.id:void 0},property:k,config:m.fields[P]??{},value:b?y:y==null?void 0:y[P],disabled:l||d.editable===!1||!(s??!!o.onJsonChange)},`${(y==null?void 0:y.id)??e}:${P}`);return f.jsxs(Xn,{$colorMode:u,"data-flow-form":e,onClick:P=>P.stopPropagation(),onDoubleClick:P=>P.stopPropagation(),children:[c&&f.jsx(Nw,{nodeAddress:e,onOpen:r}),!c&&p&&m.type.additionalProperties&&x.length===0&&f.jsx(Wu,{request:{data:t,address:g,nodeAddress:g},property:{type:m.type,optional:!1},config:{$label:"Configuration",$control:"textarea"},value:y,disabled:l||d.editable===!1||!s}),[...w].map(([P,k])=>v&&k.length>1?f.jsxs("details",{open:!0,children:[f.jsxs("summary",{children:[f.jsx("span",{children:P}),f.jsx(Y.PiCaretDown,{size:16,"aria-hidden":"true"})]}),k.map(C)]},P):k.map(C))]})}function wb(e){const{viewData:r}=j.useContext(Tt),{nodeById:t,edgeById:n,parentIds:o}=Kt();if(r){const i=Le(r,e),s=i&&typeof i=="object"&&!Array.isArray(i)&&"$"in i?i.$:i;return Array.isArray(s)?s.length>0:!!s&&typeof s=="object"&&Object.entries(s).some(([a,c])=>!a.startsWith("$")&&c!==null&&typeof c=="object")}return o.has(e)?!0:[...n.values()].some(({data:i})=>{const s=i.isInverted?i.target:i.source,a=i.isInverted?i.source:i.target;return s===e&&a!==e&&t.has(a)})}function On(e,r){return typeof e=="number"&&Number.isFinite(e)&&e>=0?e:r}function $n(e,r,t,n){return{borderColor:r,borderWidth:On(e==null?void 0:e.borderWidth,n),borderStyle:(e==null?void 0:e.borderStyle)??"solid",...Mm(r==="transparent"?"currentColor":r,t,".flow-sdk-node:hover &",!t)}}function Cb({label:e,value:r,options:t,onChange:n,disabled:o}){var i;return f.jsxs(Mt,{"aria-label":e,title:`Animation: ${((i=t.find(s=>s.value===r))==null?void 0:i.label)??"Mixed"}`,value:r,style:{width:104},disabled:o,onValueChange:s=>{const a=t.find(c=>c.value===s);a&&n(a.value)},children:[r===""&&f.jsx("option",{value:"",disabled:!0,children:"Mixed"}),t.map(s=>f.jsx("option",{value:s.value,children:s.label},s.value))]})}function Fd({nodeId:e,edgeId:r,value:t,open:n,onOpenChange:o}){const{callbacks:i,readOnly:s,themeColor:a,colorMode:c}=Ze(),{background:l,backgroundSecondary:d,border:u,colorText:h,colorInactive:p}=lt(),m=c==="dark"?rn:Me(p),g=j.useRef(null),y=j.useRef(null),b=j.useRef(0),[x,v]=j.useState(!1),[w,C]=j.useState("icons"),[S,R]=j.useState([]),[P,k]=j.useState("loading"),[T,E]=j.useState(""),[M,_]=j.useState(0),[O,$]=j.useState(""),[B,N]=j.useState(""),[I,ee]=j.useState(!1);j.useEffect(()=>()=>{b.current++},[]),j.useEffect(()=>{if(!x)return;let D=!0;return import("react-icons/pi").then(ce=>{D&&(R(Object.keys(ce).filter(Q=>Q.startsWith("Pi")).sort()),k("ready"))}).catch(()=>{D&&k("unavailable")}),()=>{D=!1}},[x]),j.useEffect(()=>{var D;s&&((D=g.current)==null||D.close())},[s]),j.useEffect(()=>{var D,ce,Q;if(n!==void 0){if(!n||s){(D=g.current)==null||D.close();return}(ce=g.current)!=null&&ce.open||(N(""),C(t==="PiFileSvg"||t&&hr(t)?"custom":"icons"),$(t&&!t.startsWith(An)&&hr(t)?t:""),v(!0),(Q=g.current)==null||Q.showModal())}},[n,s,t]);const ae=D=>{var ce,Q,K;s||(r?(ce=i.onEdgeIconChange)==null||ce.call(i,r,D):e&&((Q=i.onNodeIconChange)==null||Q.call(i,e,D)),o==null||o(!1),(K=g.current)==null||K.close())},ne=S.filter(D=>D.replace(/([a-z])([A-Z])/g,"$1 $2").toLowerCase().includes(T.trim().toLowerCase())),oe=36,pe=Math.max(1,Math.ceil(ne.length/oe)),q=Math.min(M,pe-1),F=ne.slice(q*oe,(q+1)*oe),G={width:"100%",padding:"8px 14px",background:"transparent",color:"inherit",border:`1px solid ${Me(u)}`,borderRadius:30};return f.jsxs(f.Fragment,{children:[n===void 0&&f.jsx(He,{label:r?"Choose edge icon":"Choose node icon",children:f.jsx(Ne,{"aria-label":r?"Choose edge icon":"Choose node icon",icon:f.jsx(Y.PiShapes,{size:20}),size:"sm",variant:"ghost",color:Me(a),disabled:s,onClick:()=>{var D;N(""),C(t&&hr(t)?"custom":"icons"),$(t&&!t.startsWith(An)&&hr(t)?t:""),v(!0),(D=g.current)==null||D.showModal()}})}),f.jsx(W.chakra.dialog,{ref:g,"aria-label":r?"Choose edge icon":"Choose node icon",css:xr(Me(l),Me(u)),onClose:()=>{v(!1),o==null||o(!1),b.current++,ee(!1)},onClick:D=>{D.stopPropagation(),D.target===D.currentTarget&&D.currentTarget.close()},onKeyDown:D=>D.stopPropagation(),style:{margin:"auto",padding:12,width:336,maxWidth:"calc(100vw - 32px)",maxHeight:"calc(100vh - 32px)",overflowY:"auto",borderRadius:30,background:Me(l),color:Me(h)},children:x&&f.jsxs("div",{style:{display:"grid",gap:8},children:[f.jsxs("div",{style:{display:"flex",alignItems:"center",justifyContent:"space-between",gap:8},children:[f.jsx("strong",{children:r?"Edge icon":"Node icon"}),f.jsxs("div",{style:{display:"flex",alignItems:"center",marginLeft:"auto",gap:4},children:[t&&f.jsx(He,{label:"Remove icon",children:f.jsx(Ne,{"aria-label":r?"Remove edge icon":"Remove node icon",icon:f.jsx(Y.PiTrash,{size:18}),size:"sm",variant:"ghost",disabled:s||I,onClick:()=>ae("")})}),f.jsx(nn,{"aria-label":"Close icon picker",onClick:()=>{var D;return(D=g.current)==null?void 0:D.close()}})]})]}),f.jsxs(W.Tabs.Root,{value:w,onValueChange:({value:D})=>{C(D),N("")},display:"contents",css:{"--indicator-thickness":"1px"},children:[f.jsx(W.Tabs.List,{"aria-label":"Icon source",width:"100%",borderBottomWidth:0,children:["icons","custom"].map(D=>f.jsx(W.Tabs.Trigger,{value:D,flex:1,minW:0,justifyContent:"center",px:3,py:2,fontSize:"13px",_selected:{color:a,borderColor:m,"--indicator-color":m},children:D==="icons"?"React icons":"Custom SVG"},D))}),f.jsx("input",{ref:y,type:"file",accept:".svg,image/svg+xml","aria-label":"Upload SVG icon",hidden:!0,disabled:I||s,onChange:async D=>{var K;const ce=(K=D.target.files)==null?void 0:K[0];if(D.target.value="",!ce)return;const Q=++b.current;ee(!0),N("");try{const ie=await Ew(ce);Q===b.current&&ae(ie)}catch(ie){Q===b.current&&N(ie instanceof Error?ie.message:"Unable to read SVG.")}finally{Q===b.current&&ee(!1)}}}),f.jsx(W.Tabs.Content,{value:w,p:0,style:{display:"grid",gap:8},children:w==="icons"?f.jsxs(f.Fragment,{children:[f.jsx("input",{"aria-label":"Search icons",placeholder:"Search icons...",value:T,onChange:D=>{E(D.target.value),_(0)},style:G}),f.jsxs("div",{style:{height:244,overflowY:"auto",display:"grid",gridTemplateColumns:"repeat(6, minmax(0, 1fr))",gridAutoRows:36,gap:4},children:[F.map(D=>f.jsx("button",{type:"button","aria-label":`Choose ${D}`,"aria-pressed":t===D,title:D,onClick:()=>ae(D),style:{display:"grid",placeItems:"center",borderRadius:5,border:`${t===D?2:1}px solid ${Me(t===D?a:u)}`,background:Me(t===D?l:d),color:"inherit",cursor:"pointer"},children:f.jsx(or,{name:D,size:24})},D)),F.length===0&&f.jsx("span",{role:"status",style:{gridColumn:"1 / -1"},children:P==="loading"?"Loading icons...":P==="unavailable"?"React icons unavailable":"No icons found"})]}),f.jsxs("div",{style:{display:"flex",alignItems:"center",justifyContent:"space-between",gap:8},children:[f.jsxs("span",{role:"status",style:{fontSize:12},children:[ne.length," icons · ",q+1," / ",pe]}),f.jsxs("div",{style:{display:"flex",gap:4},children:[f.jsx(He,{label:"Previous icons",children:f.jsx(Ne,{"aria-label":"Previous icons",icon:f.jsx(Y.PiCaretLeft,{size:18}),size:"sm",variant:"ghost",disabled:q===0,onClick:()=>_(q-1)})}),f.jsx(He,{label:"Next icons",children:f.jsx(Ne,{"aria-label":"Next icons",icon:f.jsx(Y.PiCaretRight,{size:18}),size:"sm",variant:"ghost",disabled:q+1>=pe,onClick:()=>_(q+1)})})]})]})]}):f.jsxs(f.Fragment,{children:[t&&hr(t)&&f.jsx(or,{name:t,size:64}),f.jsxs("button",{type:"button",disabled:I||s,onClick:()=>{var D;return(D=y.current)==null?void 0:D.click()},style:{...G,display:"flex",justifyContent:"center",gap:8,alignItems:"center",cursor:"pointer"},children:[f.jsx(Y.PiUploadSimple,{}),I?"Uploading...":"Upload SVG"]}),f.jsxs("form",{style:{display:"flex",alignItems:"center",gap:6,minWidth:0},onSubmit:D=>{D.preventDefault(),!(I||s)&&(!hr(O.trim())||O.trim().startsWith(An)?N("Enter an HTTP or HTTPS image URL."):ae(O.trim()))},children:[f.jsx("input",{type:"url","aria-label":"SVG URL",placeholder:"https://example.com/icon.svg",value:O,disabled:I||s,onChange:D=>$(D.target.value),style:{...G,flex:1,minWidth:0}}),f.jsx(He,{label:"Apply URL",children:f.jsx(Ne,{type:"submit","aria-label":"Apply URL",icon:f.jsx(Y.PiArrowRight,{size:20}),size:"sm",variant:"ghost",disabled:I||s||!O.trim(),style:{flexShrink:0}})})]})]})})]}),B&&f.jsx("div",{role:"alert",style:{fontSize:13},children:B})]})})]})}const ao=["white","blue.500","teal.500","green.500","yellow.500","orange.500","red.500","purple.500","pink.500","gray.500",rn],Sb=["gray.900",rn,"gray.600","gray.200","white"];function jb(){const{config:e}=Ze(),r=e.selectionToolbar||{},t=new Set(r.hide||[]);return{palette:r.palette||ao,show:n=>!t.has(n)}}function Et(){const{border:e}=lt();return f.jsx(W.Icon,{mx:-1,as:Y.PiLineVerticalThin,boxSize:5,color:e})}function qr({value:e,placeholder:r,ariaLabel:t,width:n="140px",type:o="text",min:i,disabled:s=!1,onCommit:a}){const{colorText:c}=lt(),[l,d]=j.useState(e),u=j.useRef(!1);j.useEffect(()=>d(e),[e]);const h=()=>{if(u.current)return;u.current=!0;const p=l.trim();if(o==="number"&&p!==""&&(!Number.isFinite(Number(p))||Number(p)<(i??0))){d(e);return}p!==e&&a(p)};return f.jsx(W.Input,{"aria-label":t,type:o,min:i,disabled:s,size:"xs",fontSize:"16px",w:n,value:l,placeholder:r,color:c,borderWidth:0,_focusVisible:{boxShadow:"none",outline:"none"},borderRadius:"8px",onFocus:()=>{u.current=!1},onChange:p=>d(p.target.value),onBlur:h,onKeyDown:p=>{p.key==="Enter"&&(h(),p.target.blur()),p.key==="Escape"&&(u.current=!0,d(e),p.target.blur())}})}function Lr({colors:e,value:r,label:t,onPick:n,onReset:o,includeTransparent:i=!0}){const{colorInactive:s,colorText:a}=lt(),[c,l]=j.useState(!1),d=j.useId(),u=j.useRef(null),h=r??e[0]??"transparent",p=po(f.jsx(Lr,{colors:e,value:r,label:t,onPick:n,onReset:o,includeTransparent:i}));return f.jsx(Xr.Provider,{value:null,children:f.jsxs(W.HStack,{gap:1,"aria-label":t,role:"group",onClickCapture:p,onKeyDown:m=>{var g;m.key==="Escape"&&(l(!1),(g=u.current)==null||g.focus())},children:[f.jsx(He,{label:`${t}: ${h}`,children:f.jsx(W.chakra.button,{ref:u,type:"button","aria-label":`${t} colors`,"aria-expanded":c,"aria-controls":d,w:4,h:4,flexShrink:0,borderRadius:"full",cursor:"pointer",style:{backgroundColor:Me(h),...h==="transparent"?{backgroundImage:"conic-gradient(#fff 25%, #a0aec0 0 50%, #fff 0 75%, #a0aec0 0)",backgroundSize:"8px 8px"}:{}},outline:`2px solid ${Me(a)}`,outlineOffset:"1px",onClick:()=>l(m=>!m)})}),c&&f.jsxs(W.HStack,{id:d,gap:1,children:[[...new Set([...e,...i?["transparent"]:[]])].map(m=>{const g=r===m;return f.jsx(He,{label:`${t}: ${m}`,children:f.jsx(W.Box,{as:"button","aria-label":`${t} ${m}`,"aria-pressed":g,w:4,h:4,borderRadius:"full",cursor:"pointer",style:{backgroundColor:Me(m),...m==="transparent"?{backgroundImage:"conic-gradient(#fff 25%, #a0aec0 0 50%, #fff 0 75%, #a0aec0 0)",backgroundSize:"8px 8px"}:{}},outline:g?`2px solid ${Me(a)}`:"none",outlineOffset:"1px",_hover:{transform:"scale(1.15)"},onClick:()=>n(m),onDoubleClick:y=>{var b;y.stopPropagation(),l(!1),(b=u.current)==null||b.focus()}})},m)}),o&&f.jsx(He,{label:`Reset ${t.toLowerCase()}`,children:f.jsx(Ne,{"aria-label":`Reset ${t}`,icon:f.jsx(W.Icon,{as:Y.PiEraser,boxSize:4}),size:"xs",variant:"ghost",color:s,onClick:()=>{var m;o(),l(!1),(m=u.current)==null||m.focus()}})})]})]})})}function Eb({edgeId:e,onClose:r}){var p;const{callbacks:t,themeColor:n,config:o}=Ze(),{colorInactive:i}=lt(),{edgeById:s}=Kt(),{palette:a,show:c}=jb(),l=(p=s.get(e))==null?void 0:p.data,d=[...new Set(["rounded-orthogonal","orthogonal","straight","bezier",...Object.keys(o.customEdgeTypes??{}),...l!=null&&l.type?[l.type]:[]])],u=l!=null&&l.isEdgeAnimated?"animated":l!=null&&l.isEdgeDashed?"dashed":"solid",h=[{key:"solid",icon:Y.PiLineSegment,label:"Solid"},{key:"dashed",icon:Y.PiLineSegments,label:"Dashed"},{key:"animated",icon:Y.PiFastForward,label:"Animated"}];return f.jsxs(f.Fragment,{children:[f.jsx(nn,{onClick:r}),c("label")&&f.jsxs(f.Fragment,{children:[f.jsx(Et,{}),f.jsx(qr,{ariaLabel:"Edge label",placeholder:"Edge label",value:(l==null?void 0:l.label)||"",onCommit:m=>{var g;return(g=t.onEdgeLabelChange)==null?void 0:g.call(t,e,m)}})]}),c("style")&&f.jsxs(f.Fragment,{children:[f.jsx(Et,{}),h.map(m=>f.jsx(He,{label:m.label,children:f.jsx(Ne,{"aria-label":`Edge style ${m.key}`,"aria-pressed":u===m.key,icon:f.jsx(W.Icon,{as:m.icon,boxSize:5}),size:"sm",variant:"ghost",color:u===m.key?n:i,onClick:()=>{var g;return(g=t.onEdgeStyleChange)==null?void 0:g.call(t,e,m.key)}})},m.key)),u==="animated"&&f.jsx(Cb,{label:"Edge animation",value:(l==null?void 0:l.edgeAnimationVariant)??"dashed",options:[{value:"dashed",label:"Dash"},{value:"traveling",label:"Trace"}],disabled:o.readOnly,onChange:m=>{var g;return(g=t.onEdgeAnimationVariantChange)==null?void 0:g.call(t,e,m)}}),f.jsxs(Mt,{"aria-label":"Edge shape",title:`Edge shape: ${(l==null?void 0:l.type)??"Default"}`,icon:f.jsx(Y.PiBezierCurve,{size:20}),style:{width:36},value:(l==null?void 0:l.type)??"",disabled:o.readOnly,onValueChange:m=>{var g;return(g=t.onEdgeTypeChange)==null?void 0:g.call(t,e,m||void 0)},children:[f.jsx("option",{value:"",children:"Default"}),d.map(m=>f.jsx("option",{value:m,children:m},m))]})]}),c("icon")&&f.jsxs(f.Fragment,{children:[f.jsx(Et,{}),f.jsx(Fd,{edgeId:e,value:l==null?void 0:l.icon},e),f.jsx(qr,{ariaLabel:"Edge icon",placeholder:"Icon name or SVG URL",value:(l==null?void 0:l.icon)??"",onCommit:m=>{var g;return(g=t.onEdgeIconChange)==null?void 0:g.call(t,e,m)}})]}),c("color")&&f.jsxs(f.Fragment,{children:[f.jsx(Et,{}),f.jsx(Lr,{label:"Edge color",colors:a,value:l==null?void 0:l.color,onPick:m=>{var g;return(g=t.onEdgeColorChange)==null?void 0:g.call(t,e,m)},onReset:()=>{var m;return(m=t.onEdgeColorChange)==null?void 0:m.call(t,e,"")}})]}),c("delete")&&f.jsxs(f.Fragment,{children:[f.jsx(Et,{}),f.jsx(He,{label:"Delete edge",children:f.jsx(Ne,{"aria-label":"Delete edge",icon:f.jsx(W.Icon,{as:Y.PiTrash,boxSize:5}),size:"sm",variant:"ghost",color:"red.400",onClick:()=>{var m;(m=t.onEdgeDelete)==null||m.call(t,e,l),r()}})})]})]})}function _b({ids:e,showDivider:r=!0}){const{callbacks:t,config:n,nodeGridOptions:o,fillRadiusEditedIds:i,setNodeRadiusPreview:s}=Ze(),{colorInactive:a}=lt(),{nodeById:c}=Kt(),[l,d]=j.useState(),u=j.useRef(),h=j.useRef(),p=j.useRef({callbacks:t,readOnly:n.readOnly,nodeById:c});p.current={callbacks:t,readOnly:n.readOnly,nodeById:c};const m=()=>{var C,S;clearTimeout(h.current);const w=u.current;if(u.current=void 0,!!w){if(!p.current.readOnly)for(const R of w.ids)p.current.nodeById.has(R)&&((S=(C=p.current.callbacks).onNodeBorderRadiusChange)==null||S.call(C,R,w.radius));s(w.ids,void 0),d(void 0)}},g=j.useRef(m);g.current=m,j.useEffect(()=>{const w=()=>g.current();return window.addEventListener("pagehide",w),()=>{window.removeEventListener("pagehide",w),w()}},[]);const y=e.map(w=>{var C,S;return o!=null&&o.fill&&!i.has(w)?0:(S=(C=c.get(w))==null?void 0:C.data.viewProps)==null?void 0:S.borderRadius}),b=!y.every(w=>w===y[0]),x=l??y[0]??0,v=w=>{n.readOnly||(w!==void 0&&e.every(C=>{var S;return((S=c.get(C))==null?void 0:S.data.type)==="grid"})?(d(w),s(e,w),u.current={ids:[...e],radius:w},clearTimeout(h.current),h.current=setTimeout(m,150)):(clearTimeout(h.current),u.current=void 0,d(void 0),s(e,void 0),e.forEach(C=>{var S;return(S=t.onNodeBorderRadiusChange)==null?void 0:S.call(t,C,w)})))};return f.jsxs(f.Fragment,{children:[r&&f.jsx(Et,{}),f.jsx(W.Box,{position:"relative",w:"36px",h:"30px",display:"grid",placeItems:"center",children:f.jsx(Mt,{icon:f.jsx(W.Icon,{as:Ev.TbBorderRadius,boxSize:5,color:a,"aria-hidden":"true"}),"aria-label":"Node border radius",title:`Border radius: ${b?"Mixed":y[0]===void 0?"Default":`${y[0]}px`}`,style:{position:"absolute",inset:0,width:"100%",height:"100%",cursor:"pointer"},value:"radius",disabled:n.readOnly,onValueChange:()=>{},popupContent:f.jsxs(f.Fragment,{children:[f.jsx(yd,{label:"Border radius",inputLabel:"Node corner radius",min:0,max:Math.max(500,...y.map(w=>w??0)),step:1,value:x,displayValue:l!==void 0?`${l}px`:b?"Mixed":y[0]===void 0?"Default":`${x}px`,onChange:v,onChangeEnd:m}),f.jsx(He,{label:"Reset border radius",children:f.jsx(Ne,{"aria-label":"Reset border radius",icon:f.jsx(Y.PiEraser,{size:20}),size:"sm",variant:"ghost",color:a,disabled:n.readOnly,onClick:()=>v(void 0)})})]}),children:f.jsx("option",{value:"radius",children:"Border radius"})})})]})}function Rb({ids:e,onClose:r,afterLabel:t}){var ce,Q,K,ie,ye,we,he,ge;const{callbacks:n,colorMode:o,themeColor:i,config:s,setNodeViewMode:a,nodeViewModes:c}=Ze(),{colorText:l,colorInactive:d}=lt(),{nodeById:u,parentIds:h}=Kt(),{palette:p,show:m}=jb(),g=e.length===1,[y,b]=j.useState(""),x=g?(ce=u.get(e[0]))==null?void 0:ce.data:void 0,v=e.map(X=>{var J,xe,Se,Fe,De,ue;const H=(J=u.get(X))==null?void 0:J.data,be=((xe=H==null?void 0:H.config)==null?void 0:xe.typeView)??"";return be==="object"&&((Se=H==null?void 0:H.config)==null?void 0:Se.content)!==void 0&&c[X]!=="properties"?"content":be==="icon-label"&&((Fe=H==null?void 0:H.viewProps)==null?void 0:Fe.bgColor)==="transparent"&&((De=H==null?void 0:H.viewProps)==null?void 0:De.borderWidth)===0&&((ue=H==null?void 0:H.viewProps)==null?void 0:ue.outline)===!1?"media":be}),w=v.some(X=>X!==v[0]),C=w?"mixed":v[0]??"",S=[{value:"text",label:"Text",view:"text",icon:Y.PiTextT},{value:"icon-label",label:"Icon Label",view:"icon-label",icon:Y.PiShapes},{value:"object",label:"Object",view:"object",icon:Y.PiBracketsCurly},{value:"grid",label:"Grid",view:"grid",icon:Y.PiGridFour},{value:"parent",label:"Parent",view:"parent",icon:Y.PiStack},{value:"media",label:"Media",view:"icon-label",icon:Y.PiFileSvg},{value:"content",label:"Content",view:"object",icon:Y.PiTextAlignLeft}],R=e.some(X=>{var be,J,xe,Se;const H=(be=u.get(X))==null?void 0:be.data;return H&&((J=H.config)==null?void 0:J.typeView)!=="grid"&&((xe=H.config)==null?void 0:xe.typeView)!=="parent"&&(h.has(X)||((Se=H.config)==null?void 0:Se.parentContainer)||Object.prototype.hasOwnProperty.call(s.customViews??{},H.type))}),P=(Q=x==null?void 0:x.config)==null?void 0:Q.collapsed,k=wb(e[0]),T=X=>{var H,be,J;return(((be=(H=u.get(X))==null?void 0:H.data.viewProps)==null?void 0:be.outline)??(h.has(X)?(J=s.parentNodeStyle)==null?void 0:J.outline:!1))===!0},E=e.every(T),M=!E&&e.some(T),_=X=>{var H;return((H=u.get(X))==null?void 0:H.data.isNodeAnimated)===!0},O=e.every(_),$=!O&&e.some(_),B=e.map(X=>{var H;return((H=u.get(X))==null?void 0:H.data.nodeAnimationVariant)??"traveling"}),N=B.every(X=>X===B[0])?B[0]:"",I=X=>e.forEach(X),[ee,ae]=j.useState(!1),ne=ee&&m("color")&&m("borderColor"),oe=X=>{var H,be,J;return(((be=(H=u.get(X))==null?void 0:H.data.viewProps)==null?void 0:be.borderStyle)??(h.has(X)?(J=s.parentNodeStyle)==null?void 0:J.borderStyle:"solid"))==="dashed"},pe=e.every(oe),q=!pe&&e.some(oe),F=e.map(X=>{var J,xe,Se;const H=(J=u.get(X))==null?void 0:J.data,be=h.has(X)?On((xe=s.parentNodeStyle)==null?void 0:xe.borderWidth,6):(H==null?void 0:H.type)==="objectView"?3:2;return On((Se=H==null?void 0:H.viewProps)==null?void 0:Se.borderWidth,be)}),G=F.every(X=>X===F[0])?String(F[0]??""):"",D=X=>I(H=>{var be,J;ne?(be=n.onNodeBorderColorChange)==null||be.call(n,H,X):(J=n.onNodeColorChange)==null||J.call(n,H,"bg",X)});return f.jsxs(f.Fragment,{children:[f.jsx(nn,{onClick:r}),f.jsx(Et,{}),g&&m("label")?f.jsx(qr,{ariaLabel:"Node label",placeholder:"Node label",value:(x==null?void 0:x.label)??(x==null?void 0:x.headerTitle)??"",onCommit:X=>{var H;return(H=n.onNodeLabelChange)==null?void 0:H.call(n,e[0],X)}}):f.jsxs(W.Text,{fontSize:"xs",color:l,whiteSpace:"nowrap",px:1,children:[e.length," selected"]}),t,m("typeView")&&f.jsxs(Mt,{"aria-label":"Type view",title:R?"Type view is managed by the custom renderer or container":`Type view: ${C||"None (default)"}`,icon:f.jsx(Y.PiCards,{size:20}),style:{width:36},value:C,disabled:s.readOnly||s.editable===!1||R,onValueChange:X=>{var be;const H=(be=S.find(J=>J.value===X))==null?void 0:be.view;H&&I(J=>{var Se,Fe,De,ue,Re,ze,Te,qe,Qe,ct,Pe,Je,Ye;const xe=(Se=u.get(J))==null?void 0:Se.data;X==="media"?((Fe=n.onNodeColorChange)==null||Fe.call(n,J,"bg","transparent"),(De=n.onNodeBorderColorChange)==null||De.call(n,J,"#00000000"),(ue=n.onNodeBorderWidthChange)==null||ue.call(n,J,0),(Re=n.onNodeOutlineChange)==null||Re.call(n,J,!1)):v[e.indexOf(J)]==="media"&&((ze=n.onNodeColorChange)==null||ze.call(n,J,"bg",""),(Te=n.onNodeBorderColorChange)==null||Te.call(n,J,""),(qe=n.onNodeBorderWidthChange)==null||qe.call(n,J,void 0)),X==="content"&&((Qe=xe==null?void 0:xe.config)==null?void 0:Qe.content)===void 0&&((ct=n.onNodeContentChange)==null||ct.call(n,J,"")),(Pe=n.onNodeTypeViewChange)==null||Pe.call(n,J,H),a(J,X==="object"&&((Je=xe==null?void 0:xe.config)==null?void 0:Je.content)!==void 0?"properties":"default"),(Ye=n.onNodeViewToggle)==null||Ye.call(n,J)})},children:[w&&f.jsx("option",{value:"mixed",disabled:!0,children:"Mixed"}),S.map(X=>f.jsx("option",{value:X.value,children:f.jsxs(W.HStack,{gap:"12px",children:[f.jsx(X.icon,{size:20,"aria-hidden":"true",style:{flexShrink:0}}),f.jsx("span",{children:X.label})]})},X.value))]}),m("style")&&f.jsx(_b,{ids:e},e.join("\0")),m("outline")&&f.jsxs(f.Fragment,{children:[f.jsx(Et,{}),f.jsx(He,{label:E?"Restore node fill":"Remove node fill",children:f.jsx(Ne,{"aria-label":"Toggle node outline","aria-pressed":M?"mixed":E,icon:f.jsx(W.Icon,{as:E?Y.PiSquare:Y.PiSquareFill,boxSize:5}),size:"sm",variant:"ghost",color:E?i:d,onClick:()=>I(X=>{var H;return(H=n.onNodeOutlineChange)==null?void 0:H.call(n,X,!E)})})})]}),m("color")&&f.jsxs(f.Fragment,{children:[f.jsx(Et,{}),m("borderColor")&&f.jsx(He,{label:ne?"Edit node colors":"Edit node border",children:f.jsx(Ne,{"aria-label":"Edit node border","aria-pressed":ne,icon:f.jsx(W.Icon,{as:Y.PiBoundingBox,boxSize:5}),size:"sm",variant:"ghost",color:ne?i:d,bg:ne?o==="dark"?"whiteAlpha.200":"blackAlpha.100":void 0,onClick:()=>ae(X=>!X)})}),f.jsx(Lr,{label:ne?"Border color":"Background",colors:p,value:ne?((K=x==null?void 0:x.viewProps)==null?void 0:K.borderColor)??(g&&h.has(e[0])?(ie=s.parentNodeStyle)==null?void 0:ie.borderColor:void 0):(ye=x==null?void 0:x.viewProps)==null?void 0:ye.bgColor,onPick:D,onReset:()=>D("")}),ne&&m("style")&&f.jsxs(f.Fragment,{children:[f.jsx(Et,{}),f.jsx(He,{label:pe?"Solid border":"Dashed border",children:f.jsx(Ne,{"aria-label":"Toggle dashed border","aria-pressed":q?"mixed":pe,icon:f.jsx(W.Icon,{as:pe?Y.PiLineSegments:Y.PiLineSegment,boxSize:5}),size:"sm",variant:"ghost",color:pe?i:d,onClick:()=>I(X=>{var H;return(H=n.onNodeBorderStyleChange)==null?void 0:H.call(n,X,pe?"solid":"dashed")})})}),f.jsx(qr,{ariaLabel:"Border thickness",placeholder:g?"Auto":"Mixed",width:"64px",type:"number",min:0,value:G,onCommit:X=>I(H=>{var be;return(be=n.onNodeBorderWidthChange)==null?void 0:be.call(n,H,X===""?void 0:Number(X))})})]})]}),m("animation")&&f.jsxs(f.Fragment,{children:[f.jsx(Et,{}),f.jsx(He,{label:O?"Stop border animation":"Animate node border",children:f.jsx(Ne,{"aria-label":"Toggle node animation","aria-pressed":$?"mixed":O,icon:f.jsx(W.Icon,{as:Y.PiSpinnerGap,boxSize:5}),size:"sm",variant:"ghost",color:O?i:d,onClick:()=>I(X=>{var H;return(H=n.onNodeAnimationChange)==null?void 0:H.call(n,X,!O)})})}),(O||$)&&f.jsx(Cb,{label:"Node animation",value:N,options:[{value:"traveling",label:"Trace"},{value:"pulse",label:"Pulse"}],disabled:s.readOnly,onChange:X=>I(H=>{var be;return(be=n.onNodeAnimationVariantChange)==null?void 0:be.call(n,H,X)})})]}),!ne&&m("textColor")&&f.jsxs(f.Fragment,{children:[f.jsx(Et,{}),f.jsx(Lr,{label:"Text color",colors:Sb,value:(we=x==null?void 0:x.viewProps)==null?void 0:we.textColor,onPick:X=>I(H=>{var be;return(be=n.onNodeColorChange)==null?void 0:be.call(n,H,"text",X)}),onReset:()=>I(X=>{var H;return(H=n.onNodeColorChange)==null?void 0:H.call(n,X,"text","")})})]}),g&&m("icon")&&f.jsxs(f.Fragment,{children:[f.jsx(Et,{}),f.jsx(Fd,{nodeId:e[0],value:(he=x==null?void 0:x.config)==null?void 0:he.icon},e[0]),f.jsx(qr,{ariaLabel:"Node icon",placeholder:"(e.g. PiGear)",width:"120px",value:((ge=x==null?void 0:x.config)==null?void 0:ge.icon)||"",onCommit:X=>{var H;return(H=n.onNodeIconChange)==null?void 0:H.call(n,e[0],X)}})]}),g&&k&&m("collapse")&&P!==void 0&&f.jsxs(f.Fragment,{children:[f.jsx(Et,{}),f.jsx(He,{label:P?"Expand":"Collapse",children:f.jsx(Ne,{"aria-label":P?"Expand node":"Collapse node",icon:f.jsx(W.Icon,{as:P?Y.PiArrowsOutLineVertical:Y.PiArrowsInLineVertical,boxSize:5}),size:"sm",variant:"ghost",color:d,onClick:()=>{var X;return(X=n.onNodeCollapse)==null?void 0:X.call(n,e[0],!P)}})})]}),m("delete")&&f.jsxs(f.Fragment,{children:[f.jsx(Et,{}),f.jsx(He,{label:g?"Delete node":`Delete ${e.length} nodes`,children:f.jsx(Ne,{"aria-label":"Delete selected nodes",icon:f.jsx(W.Icon,{as:Y.PiTrash,boxSize:5}),size:"sm",variant:"ghost",color:o==="dark"?"red.300":"red.500",onClick:()=>{I(X=>{var H,be;return(be=n.onNodeDelete)==null?void 0:be.call(n,X,((H=u.get(X))==null?void 0:H.data)||{id:X})}),r()}})})]}),f.jsx(Et,{}),f.jsx(He,{label:"Copy selection",children:f.jsx(Ne,{"aria-label":"Copy selection",icon:f.jsx(Y.PiCopy,{size:20}),size:"sm",variant:"ghost",color:d,onClick:async()=>{var X;try{await((X=n.onNodesCopy)==null?void 0:X.call(n,e)),b("")}catch(H){b(String(H))}}})}),f.jsx(He,{label:"Duplicate selection",children:f.jsx(Ne,{"aria-label":"Duplicate selection",icon:f.jsx(Y.PiCopySimple,{size:20}),size:"sm",variant:"ghost",color:d,disabled:s.readOnly||s.editable===!1,onClick:()=>{var X;try{(X=n.onNodesDuplicate)==null||X.call(n,e),b("")}catch(H){b(String(H))}}})}),y&&f.jsx(W.Text,{role:"alert",fontSize:"xs",children:y})]})}async function kb(e){const{toSvg:r}=await Promise.resolve().then(()=>require("./index-sHQXTNv9.cjs"));await document.fonts.ready;const t=await r(e,{filter:o=>!(o instanceof Element)||!o.matches("button, iframe, [role=tooltip], .flow-sdk-handle, .flow-sdk-property-port, .flow-sdk-edge-hit, .flow-sdk-ghost, .flow-sdk-node-animation")}),n=new DOMParser().parseFromString(decodeURIComponent(t.slice(t.indexOf(",")+1)),"image/svg+xml");return n.querySelectorAll(".flow-sdk-edge-hit, .flow-sdk-handle, .flow-sdk-property-port, .flow-sdk-ghost").forEach(o=>o.remove()),n.querySelectorAll("[data-flow-preview-source]").forEach(o=>{o.setAttribute("style","display:block;white-space:pre-wrap;font:16px/1.5 monospace;overflow-wrap:anywhere")}),`data:image/svg+xml;charset=utf-8,${encodeURIComponent(new XMLSerializer().serializeToString(n))}`}async function Ab(e,r="squeed.svg"){const t=document.createElement("a");t.href=await kb(e),t.download=r.endsWith(".svg")?r:`${r}.svg`,t.click()}function Pb(){const{themeColor:e}=Ze(),[r,t]=j.useState(!1),[n,o]=j.useState("");return f.jsxs(f.Fragment,{children:[f.jsx(He,{label:"Download SVG (current view)",children:f.jsx(Ne,{"aria-label":"Download SVG",icon:f.jsx(Y.PiDownloadSimpleFill,{size:20}),disabled:r,borderRadius:"30%",color:e,variant:"ghost",onClick:async i=>{var a;const s=(a=i.currentTarget.closest("[data-flow-diagram]"))==null?void 0:a.querySelector("[data-flow-background]");if(!s){o("Diagram not available for export.");return}t(!0),o("");try{await Ab(s)}catch(c){o(c instanceof Error?c.message:"Unable to export SVG.")}finally{t(!1)}}})}),n&&f.jsx("span",{role:"alert",style:{fontSize:12,maxWidth:220},children:n})]})}function vo({children:e,background:r,border:t,endElement:n,startElement:o,startElementWidth:i=44,framed:s=!0}){const a=j.useRef(null),[c,l]=j.useState({left:!1,right:!1});j.useLayoutEffect(()=>{const u=a.current;let h=u.parentElement.offsetWidth;const p=()=>{const y=u.parentElement.offsetWidth;if(y>0&&y!==h){const v=h/y;h=y,v>0&&!window.matchMedia("(prefers-reduced-motion: reduce)").matches&&u.parentElement.animate({transform:[`scaleX(${v})`,"scaleX(1)"],transformOrigin:[n?"right center":"left center",n?"right center":"left center"]},{duration:180,easing:"ease-out",id:"flow-toolbar-grow"})}const b=u.scrollLeft>1,x=u.scrollWidth-u.clientWidth-u.scrollLeft>1;l(v=>v.left===b&&v.right===x?v:{left:b,right:x})},m=y=>{const b=y.target instanceof Element?y.target:null;if((b==null?void 0:b.closest("[data-flow-toolbar-scroll]"))!==u||b.closest("[popover], [data-flow-floating-panel]")!==u.closest("[popover], [data-flow-floating-panel]")||y.defaultPrevented||y.ctrlKey||s&&y.deltaX!==0||!(y.deltaX||y.deltaY)||u.scrollWidth<=u.clientWidth)return;y.preventDefault();const x=y.deltaMode===WheelEvent.DOM_DELTA_LINE?16:y.deltaMode===WheelEvent.DOM_DELTA_PAGE?u.clientWidth:1;u.scrollLeft+=(y.deltaX||y.deltaY)*x},g=new ResizeObserver(p);return g.observe(u),u.firstElementChild&&g.observe(u.firstElementChild),u.addEventListener("scroll",p,{passive:!0}),u.addEventListener("wheel",m,{passive:!1}),p(),()=>{g.disconnect(),u.removeEventListener("scroll",p),u.removeEventListener("wheel",m)}},[]);const d=`var(--chakra-colors-${r.replace(".","-")})`;return f.jsxs(W.Box,{position:"relative",bg:s?r:"transparent",minW:0,maxW:"100%",flex:"0 1 auto",borderRadius:s?"30px":0,css:{...s?xr(d,`var(--chakra-colors-${t.replace(".","-")})`):{},...s||o?{"--flow-toolbar-start-width":o?`${i}px`:"0px"}:{}},children:[f.jsx(W.Box,{ref:a,"data-flow-toolbar-scroll":"",h:50,minH:50,alignContent:"center",overflowX:"auto",overflowY:"hidden",mr:n?"44px":void 0,ml:o?`${i}px`:void 0,borderRadius:"inherit",css:{scrollbarWidth:"none","&::-webkit-scrollbar":{display:"none"}},children:e}),["left","right"].map(u=>f.jsx(W.Box,{"data-flow-toolbar-fade":u,"aria-hidden":"true",position:"absolute",top:0,bottom:0,w:"20px",pointerEvents:"none",borderRadius:u==="left"?"30px 0 0 30px":"0 30px 30px 0",style:{[u]:u==="right"&&n?44:u==="left"&&o?i:0,opacity:c[u]?1:0,background:`linear-gradient(to ${u==="left"?"right":"left"}, ${d}, transparent)`}},u)),n&&f.jsx(W.Box,{position:"absolute",right:"6px",top:0,h:"50px",w:"32px",display:"flex",alignItems:"center",justifyContent:"center",children:n}),o&&f.jsx(W.Box,{position:"absolute",left:"6px",top:0,h:"50px",w:`${i-12}px`,display:"flex",alignItems:"center",justifyContent:"center",children:o})]})}async function $w(e,r){const t=new Set,n=[],o=(a,c)=>{var d,u,h;if(!a||typeof a!="object")return;const l=a;n.push(c),typeof((d=l.$form)==null?void 0:d.$type)=="string"&&t.add(l.$form.$type),typeof((h=(u=l.$form)==null?void 0:u.$create)==null?void 0:h.$type)=="string"&&t.add(l.$form.$create.$type);for(const[p,m]of Object.entries(l))p==="$"?o(m,c):p.startsWith("$")||o(m,`${c}.${p}`)};if(o(r,"root"),!t.size)return{contract:await mb(e)};const i=await qd(e,[...t]);for(const a of t)if(!Object.prototype.hasOwnProperty.call(i,a))throw new Error(`Missing form type: ${a}`);const s={};for(const a of n){const c=on(r,a,i);c&&(s[a]={type:c.type,optional:!1})}return{schema:i,contract:{name:e.name,nodes:s}}}function Mb({message:e,onDismiss:r}){const{background:t,colorText:n,border:o}=lt();return!e||typeof document>"u"?null:Jr.createPortal(f.jsxs(W.chakra.div,{role:"alert","aria-atomic":"true",css:xr(Me(t),Me(o)),onPointerDown:i=>i.stopPropagation(),onClick:i=>i.stopPropagation(),style:{position:"fixed",top:20,right:20,zIndex:1e4,width:360,maxWidth:"calc(100vw - 40px)",boxSizing:"border-box",display:"flex",alignItems:"flex-start",gap:10,padding:16,borderRadius:8,background:Me(t),color:Me(n),fontSize:14,lineHeight:1.5},children:[f.jsx(Y.PiWarningCircle,{size:20,"aria-hidden":"true",style:{flexShrink:0,color:"#ef4444"}}),f.jsxs("div",{style:{flex:1,minWidth:0,overflowWrap:"anywhere"},children:[f.jsx("strong",{children:"Interface upload failed"}),f.jsx("div",{children:e})]}),f.jsx(nn,{type:"button","aria-label":"Dismiss upload error",title:"Dismiss upload error",onClick:r,flexShrink:0,width:"24px",height:"24px",minWidth:"24px",padding:0})]}),document.body)}function zd({showDivider:e=!0,compact:r=!1}={}){const{edgeMode:t,setEdgeMode:n,workflowContract:o,setWorkflowContract:i,callbacks:s,readOnly:a,themeColor:c,colorMode:l}=Ze(),{edgeById:d}=Kt(),{data:u,schema:h,setSchema:p,bindings:m,structured:g}=j.useContext(Tt),y=(g==null?void 0:g.sourceBindings)??m,b=(g==null?void 0:g.sourceSchema)??h,{colorText:x}=lt(),v=j.useRef(null),w=j.useRef(0),[C,S]=j.useState(!1),[R,P]=j.useState("");j.useEffect(()=>()=>{w.current++},[]),j.useEffect(()=>{w.current++,S(!1)},[a,u,y]);const k=o?[...d.values()].filter(M=>$d(o,M.data)).length:0,T=o?`${o.name}: ${b?`${Object.keys(b).length} form types loaded; `:""}${k} invalid or unverified connections`:"",E=po(f.jsx(zd,{showDivider:!1,compact:!0}));return f.jsx(Xr.Provider,{value:null,children:f.jsxs("span",{style:{display:"contents"},onClickCapture:E,children:[f.jsx(Mb,{message:R,onDismiss:()=>P("")}),e&&f.jsx(Sn,{}),f.jsxs(Mt,{"aria-label":"Edge mode",title:t==="auto"?"Connections: Auto":t==="properties"?"Connections: Properties":"Connections: Nodes",icon:t==="auto"?f.jsx(Y.PiGraph,{size:20}):t==="properties"?f.jsx(Y.PiTable,{size:20}):f.jsx(Y.PiTreeStructure,{size:20}),style:{width:36},value:t,disabled:a,footer:s.onWorkflowConfigurationOpen&&f.jsxs(f.Fragment,{children:[f.jsx("hr",{style:{border:0,borderTop:"1px solid currentColor",opacity:.2,margin:"8px 0"}}),f.jsxs(W.Button,{"data-flow-menu-action":"",variant:"ghost",width:"100%",justifyContent:"flex-start",color:"inherit",bg:"transparent",css:io,_hover:{bg:l==="dark"?"whiteAlpha.100":"blackAlpha.50"},_focusVisible:{bg:l==="dark"?"whiteAlpha.100":"blackAlpha.50"},onClick:M=>{var _,O;(_=M.currentTarget.closest("[popover]"))==null||_.hidePopover(),(O=s.onWorkflowConfigurationOpen)==null||O.call(s)},children:[f.jsx(Y.PiGear,{}),"Configuration"]})]}),onValueChange:M=>{var O;const _=M==="auto"?"auto":M==="properties"?"properties":"nodes";n(_),(O=s.onEdgeModeChange)==null||O.call(s,_)},children:[f.jsx("option",{value:"auto",children:"Auto"}),f.jsx("option",{value:"nodes",children:"Nodes"}),f.jsx("option",{value:"properties",children:"Properties"})]}),f.jsxs("span",{style:{display:t==="auto"||t==="properties"?"contents":"none"},children:[f.jsx(He,{label:o?`Replace ${o.name}`:"Upload workflow interface",children:f.jsx(Ne,{"aria-label":"Upload workflow interface",icon:f.jsx(Y.PiUploadSimple,{size:20}),color:Me(c),size:"sm",variant:"ghost",disabled:C||a,onClick:()=>{var M;return(M=v.current)==null?void 0:M.click()}})}),f.jsx("input",{ref:v,type:"file",hidden:!0,accept:".ts,.json","aria-label":"Workflow interface file",disabled:a||C,onChange:async M=>{var $,B;const _=($=M.target.files)==null?void 0:$[0];if(M.target.value="",!_)return;const O=++w.current;S(!0),P("");try{const N=y?await qd(_,[...new Set(Object.values(y).map(ae=>ae.schemaType??ae.type))]):void 0;if(y&&N){for(const ae of Object.values(y))if(!Object.prototype.hasOwnProperty.call(N,ae.schemaType??ae.type))throw new Error(`Missing form type: ${ae.schemaType??ae.type}`)}const{contract:I,schema:ee}=y&&N?{schema:N,contract:{name:_.name,nodes:Object.fromEntries(Object.entries(y).map(([ae,ne])=>[ae,{type:N[ne.schemaType??ne.type],optional:!1}]))}}:await $w(_,u);if(O!==w.current)return;p==null||p(ee),i(I),(B=s.onWorkflowContractChange)==null||B.call(s,I)}catch(N){O===w.current&&P(`${_.name}: ${N instanceof Error?N.message:"Unable to load interface."}`)}finally{O===w.current&&S(!1)}}}),!r&&(T||C)&&f.jsx("span",{role:"status",title:T,style:{color:Me(x),fontSize:12,maxWidth:180,whiteSpace:"nowrap",overflow:"hidden",textOverflow:"ellipsis"},children:C?"Loading interface...":T}),!r&&o&&f.jsx(He,{label:"Remove workflow interface",children:f.jsx(Ne,{"aria-label":"Remove workflow interface",icon:f.jsx(Y.PiX,{size:16}),size:"sm",variant:"ghost",disabled:a||C,onClick:()=>{var M;p==null||p(void 0),i(void 0),(M=s.onWorkflowContractChange)==null||M.call(s,void 0),P("")}})})]})]})})}const qw=[{value:"BT",label:"Bottom to Up",icon:Y.PiArrowUp,flowType:yn.BOTTOM_UP},{value:"TB",label:"Top to Bottom",icon:Y.PiArrowDown,flowType:yn.TOP_DOWN},{value:"LR",label:"Left to Right",icon:Y.PiArrowRight,flowType:yn.LEFT_RIGHT},{value:"RL",label:"Right to Left",icon:Y.PiArrowLeft,flowType:yn.RIGHT_LEFT}],Ib=({nodeGridControlsTarget:e}={})=>{const{engineRef:r,themeColor:t,setThemeColor:n,edgeColor:o,setEdgeColor:i,backgroundSelected:s,setBackgroundSelected:a,direction:c,edgeMode:l,allNodesIconLabel:d,setAllNodesIconLabel:u,nodeGridOptions:h,selectedNodeIds:p,setSelectedNodeIds:m,selectedEdgeId:g,setSelectedEdgeId:y,isZoomMode:b,setIsZoomMode:x,isMultiSelectMode:v,setIsMultiSelectMode:w,isDragMode:C,setIsDragMode:S,isEdgeHandlesEnabled:R,setIsEdgeHandlesEnabled:P,isArrayNodeMode:k,setIsArrayNodeMode:T,isPinned:E,setIsPinned:M,callbacks:_,config:O,readOnly:$}=Ze(),{nodeById:B,edgeById:N,parentIds:I}=Kt(),ee=O.colorMode==="dark",{background:ae,border:ne,colorInactive:oe,colorText:pe,colorActive:q}=lt(),F=ee?ne:"gray.300",G=`var(--chakra-colors-${ae.replace(".","-")})`,D=`var(--chakra-colors-${(ee?ne:"gray.300").replace(".","-")})`,[ce,Q]=j.useState(!1),[K,ie]=j.useState(!0),ye=O.bottomBarCollapsed??K,we=j.useRef(null),he=ho({edge:"bottom",enabled:!E,bounds:we,inside:[we]}),ge=j.useCallback(Pe=>{const Je=r.current;if(!Je)return;const Ye=O.minZoom??.01,nt=O.maxZoom??1.5,Nt=.02;let Rt=Je.zoom();switch(Pe){case"increase":Rt=Math.min(nt,Rt+Nt),Je.zoom(Rt),Je.center(!1);break;case"decrease":Rt=Math.max(Ye,Rt-Nt),Je.zoom(Rt),Je.center(!1);break;case"reset":Je.fit(50);break}},[r,O.minZoom,O.maxZoom]),X=O.renderSelectedNodeToolbar,H=p.length>0&&!!X,be=j.useMemo(()=>H?p.map(Pe=>{var Ye;return{...((Ye=B.get(Pe))==null?void 0:Ye.data)??{id:Pe},isParent:I.has(Pe)}}):[],[H,p,B,I]),J=j.useCallback(()=>{var Pe;m([]),(Pe=_.onNodeDeselect)==null||Pe.call(_)},[m,_]),xe=O.renderSelectedEdgeToolbar,Se=!!g&&!!xe,Fe=j.useMemo(()=>{var Pe;return!Se||!g?null:((Pe=N.get(g))==null?void 0:Pe.data)??{id:g}},[Se,g,N]),De=j.useCallback(()=>{var Pe;y(null),(Pe=_.onEdgeDeselect)==null||Pe.call(_)},[y,_]),ue=O.selectionToolbar!==!1&&!$,Re=ue&&!!g&&!xe,ze=ue&&!Re&&p.length>0&&!X,Te=Re||ze,qe=E||he||ce||Te||O.bottomBarCollapsed===!1;j.useEffect(()=>{p.length||g?a(!1):$||(s&&M(!0),O.bottomBarCollapsed===void 0&&ie(!s))},[s,p.length,g,$,a,M,O.bottomBarCollapsed]);const Qe=O.renderBottomBar,ct=dw();return Qe?f.jsxs(f.Fragment,{children:[H&&f.jsx(W.Box,{position:"absolute",bottom:5,left:"50%",transform:"translateX(-50%)",zIndex:101,children:X({selectedNodeIds:p,selectedNodeData:be,onDeselect:J})}),Se&&Fe&&f.jsx(W.Box,{position:"absolute",bottom:5,left:"50%",transform:"translateX(-50%)",zIndex:101,children:xe({edgeId:g,edgeData:Fe,onDeselect:De})}),f.jsx(W.Box,{position:"absolute",bottom:0,left:0,right:0,zIndex:100,w:"100%",children:Qe({zoomIn:()=>ge("increase"),zoomOut:()=>ge("decrease"),resetZoom:()=>ge("reset"),direction:c,isZoomMode:b,setIsZoomMode:x,isMultiSelectMode:v,setIsMultiSelectMode:w,isDragMode:C,setIsDragMode:S,isEdgeHandlesEnabled:R,setIsEdgeHandlesEnabled:P,isArrayNodeMode:k,setIsArrayNodeMode:T,selectedNodeIds:p,selectedNodeData:be,selectedEdgeId:g,selectedEdgeData:Fe,onNodeDeselect:J,onEdgeDeselect:De,callbacks:_})})]}):f.jsxs(Xr.Provider,{value:ct,children:[H&&f.jsx(W.Box,{position:"absolute",bottom:5,left:"50%",transform:"translateX(-50%)",zIndex:101,children:X({selectedNodeIds:p,selectedNodeData:be,onDeselect:J})}),Se&&Fe&&f.jsx(W.Box,{position:"absolute",bottom:5,left:"50%",transform:"translateX(-50%)",zIndex:101,children:xe({edgeId:g,edgeData:Fe,onDeselect:De})}),f.jsx(W.Box,{ref:we,role:"toolbar","aria-label":"Diagram controls",position:"absolute",bottom:0,left:0,right:0,zIndex:100,w:"100%",transition:"opacity 0.3s ease-in, transform 0.3s ease",transform:qe?"translateY(0)":"translateY(100%)",pointerEvents:qe?"auto":"none",visibility:qe?"visible":"hidden",opacity:qe?1:0,css:{"& button > svg:not([popover] *)":{width:"20px",height:"20px",minWidth:"20px",minHeight:"20px",flexShrink:0},"@media (hover: none)":{visibility:"visible",opacity:1,transform:"none",pointerEvents:"auto"}},children:f.jsxs(W.Flex,{w:"100%",px:5,position:"absolute",bottom:"calc(20px + env(safe-area-inset-bottom, 0px))",flexDirection:"row",justifyContent:"space-between",alignItems:"center",gap:"24px",css:{"@media (min-width: 1024px)":{"& > :first-of-type":{maxWidth:"50vw"}}},children:[f.jsx(vo,{background:ae,border:ee?ne:"gray.300",children:f.jsxs(W.HStack,{px:2,gap:1,flexWrap:"nowrap",w:"max-content",minW:"100%",h:"100%",css:{"& > *":{flexShrink:0}},children:[Re?f.jsx(Eb,{edgeId:g,onClose:De}):ze?f.jsx(Rb,{ids:p,onClose:J}):null,f.jsxs("div",{style:{display:Re||ze?"none":"contents"},children:[f.jsxs("span",{style:{display:O.bottomBarNavigation===!1?"none":"contents"},children:[f.jsx(He,{label:E?"Unpin":"Pin",children:f.jsx(Ne,{"aria-label":"Pin",icon:f.jsx(W.Icon,{as:E?Y.PiPushPinFill:Y.PiPushPin,boxSize:5}),size:"sm",variant:"ghost",color:E?t:oe,onClick:()=>{M(!E),Q(!1)}})}),f.jsx(W.Icon,{mx:-1,as:Y.PiLineVerticalThin,boxSize:5,color:F}),f.jsx(He,{label:"Zoom Out",children:f.jsx(Ne,{"aria-label":"Zoom out",rememberAction:!1,icon:f.jsx(W.Icon,{as:Y.PiMinus,boxSize:5}),size:"sm",variant:"ghost",color:pe,onClick:()=>ge("decrease")})}),f.jsx(He,{label:"Zoom In",children:f.jsx(Ne,{"aria-label":"Zoom in",rememberAction:!1,icon:f.jsx(W.Icon,{as:Y.PiPlus,boxSize:5}),size:"sm",variant:"ghost",color:pe,onClick:()=>ge("increase")})}),f.jsx(He,{label:"Reset Zoom",children:f.jsx(Ne,{"aria-label":"Reset zoom",rememberAction:!1,icon:f.jsx(W.Icon,{as:Y.PiArrowCounterClockwise,boxSize:5}),size:"sm",variant:"ghost",color:pe,onClick:()=>ge("reset")})}),ye&&f.jsx(uw,{visibleActions:h?["Collision mode","Fill",...h.fill?["Grid adjustment"]:[]]:[],divider:f.jsx(W.Icon,{mx:-1,as:Y.PiLineVerticalThin,boxSize:5,color:F,role:"separator","aria-orientation":"vertical"})})]}),f.jsxs("span",{style:{display:ye?"none":"contents"},children:[f.jsxs("span",{style:{display:O.bottomBarNavigation===!1?"none":"contents"},children:[O.edgeHandles!==!1&&f.jsx(He,{label:R?"Draw Mode On (V)":"Draw Mode Off (V)",children:f.jsx(Ne,{"aria-label":"Toggle draw mode","aria-keyshortcuts":"V","aria-pressed":R,icon:f.jsx(W.Icon,{as:Y.PiPencilSimpleLine,boxSize:5}),size:"sm",variant:"ghost",color:R?t:oe,onClick:()=>P(!R)})}),f.jsx(W.Icon,{mx:-1,as:Y.PiLineVerticalThin,boxSize:5,color:F}),f.jsx(He,{label:b?"Zoom Mode (z)":"Pan Mode (z)",children:f.jsx(Ne,{"aria-label":"Toggle zoom mode",icon:f.jsx(W.Icon,{as:b?Y.PiMagnifyingGlassPlus:Y.PiArrowsOutCardinal,boxSize:5}),size:"sm",variant:"ghost",color:b?t:oe,onClick:()=>x(!b)})}),f.jsx(W.Icon,{mx:-1,as:Y.PiLineVerticalThin,boxSize:5,color:F}),f.jsx(He,{label:v?"Multi-Select On (m)":"Multi-Select Off (m)",children:f.jsx(Ne,{"aria-label":"Toggle multi-select",icon:f.jsx(W.Icon,{as:Y.PiSelectionPlus,boxSize:5}),size:"sm",variant:"ghost",color:v?t:oe,onClick:()=>w(!v)})}),f.jsx(W.Icon,{mx:-1,as:Y.PiLineVerticalThin,boxSize:5,color:F}),f.jsx(He,{label:C?"Drag Mode On (d)":"Drag Mode Off (d)",children:f.jsx(Ne,{"aria-label":"Toggle drag mode",icon:f.jsx(W.Icon,{as:Y.PiHandGrabbing,boxSize:5}),size:"sm",variant:"ghost",color:C?t:oe,onClick:()=>S(!C)})})]}),O.bottomBarNavigation===!1&&(e===void 0?f.jsx(to,{}):e?Jr.createPortal(f.jsx(to,{}),e):null),O.bottomBarExtra&&f.jsxs(f.Fragment,{children:[O.bottomBarNavigation!==!1&&f.jsx(W.Icon,{mx:-1,as:Y.PiLineVerticalThin,boxSize:5,color:F,role:"separator","aria-orientation":"vertical"}),O.bottomBarExtra]}),f.jsx(W.Icon,{mx:-1,as:Y.PiLineVerticalThin,boxSize:5,color:F,role:"separator","aria-orientation":"vertical"}),f.jsx(ib,{})]}),f.jsx("span",{style:{display:O.bottomBarNavigation===!1||ye&&!h?"none":"contents"},children:f.jsx(to,{})}),f.jsxs("span",{style:{display:ye?"none":"contents"},children:[f.jsx(W.Icon,{mx:-1,as:Y.PiLineVerticalThin,boxSize:5,color:F,role:"separator","aria-orientation":"vertical"}),f.jsx(ob,{}),l!=="properties"&&f.jsxs(f.Fragment,{children:[f.jsx(W.Icon,{mx:-1,as:Y.PiLineVerticalThin,boxSize:5,color:F}),f.jsx(He,{label:k?"Array Mode [ ]":"Set Mode { }",children:f.jsx(Ne,{"aria-label":"Toggle array mode",icon:f.jsx(W.Icon,{as:k?Y.PiBracketsSquare:Y.PiBracketsCurly,boxSize:5}),size:"sm",variant:"ghost",color:k?t:oe,onClick:()=>{var Je;const Pe=!k;T(Pe),(Je=_.onArrayModeChange)==null||Je.call(_,Pe)}})})]}),f.jsx(zd,{}),!$&&f.jsxs("span",{style:{display:s?"contents":"none"},children:[f.jsx(W.Icon,{mx:-1,as:Y.PiLineVerticalThin,boxSize:5,color:F}),f.jsx(Lr,{label:"Graph theme",colors:ao,value:t,includeTransparent:!1,onPick:Pe=>{var Je;n(Pe),(Je=_.onThemeColorChange)==null||Je.call(_,Pe)}})]}),!$&&f.jsxs(f.Fragment,{children:[f.jsx(W.Icon,{as:Y.PiLineVerticalThin,boxSize:5,color:F,role:"separator","aria-orientation":"vertical"}),f.jsx(Lr,{label:"Graph edge color",colors:ao,value:o||(ee?"gray.500":rn),onPick:i,onReset:()=>i("")}),f.jsx(W.Icon,{as:Y.PiLineVerticalThin,boxSize:5,color:F,role:"separator","aria-orientation":"vertical"})]}),f.jsx(ab,{})]}),f.jsx(W.Icon,{mx:-1,as:Y.PiLineVerticalThin,boxSize:5,color:F}),f.jsx(He,{label:ye?"Expand toolbar":"Collapse toolbar",children:f.jsx(Ne,{"aria-label":"Toggle toolbar collapse",rememberAction:!1,icon:f.jsx(W.Icon,{as:ye?Y.PiCaretRight:Y.PiCaretLeft,boxSize:5}),size:"sm",variant:"ghost",color:oe,onClick:()=>{var Pe;O.bottomBarCollapsed===void 0&&ie(!ye),a(ye),(Pe=_.onBottomBarCollapsedChange)==null||Pe.call(_,!ye)}})}),!ye&&f.jsx(Pb,{})]})]})}),!Te&&f.jsxs(W.Box,{position:"relative",ml:"auto",flexShrink:0,children:[f.jsx(W.Box,{"data-flow-direction-control":"",bg:ae,borderRadius:"30px",h:50,css:xr(G,D),px:3,cursor:"pointer",onClick:()=>Q(!ce),children:f.jsxs(W.Flex,{align:"center",h:"100%",children:[f.jsx(He,{label:"Flow Direction",children:f.jsx(Ne,{"aria-label":"Direction",onClick:Pe=>{Pe.stopPropagation(),Q(!ce)},icon:f.jsx(W.Icon,{as:Y.PiCaretUp,boxSize:5}),size:"sm",variant:"ghost",color:oe})}),f.jsx(W.Text,{fontSize:"xs",textTransform:"uppercase !important",color:ee?"whiteAlpha.600":"blackAlpha.500",ml:1,children:c.toUpperCase()})]})}),ce&&f.jsx(W.Box,{position:"absolute",bottom:"100%",right:0,pb:"24px",zIndex:200,children:f.jsxs(W.Box,{bg:ae,borderRadius:"30px",p:2,minW:"180px",css:xr(G,D),children:[qw.map(Pe=>f.jsxs(W.Flex,{align:"center",gap:3,px:3,py:2,css:io,cursor:"pointer",_hover:{bg:ee?"whiteAlpha.100":"blackAlpha.50"},onClick:()=>{var Je;(Je=_.onDirectionChange)==null||Je.call(_,Pe.value),Q(!1)},children:[f.jsx(W.Icon,{as:Pe.icon,boxSize:5,color:pe}),f.jsx(W.Text,{fontSize:"sm",color:pe,flex:1,whiteSpace:"nowrap",children:Pe.label}),c===Pe.value&&f.jsx(W.Icon,{as:Y.PiCheck,boxSize:4,color:q})]},Pe.value)),f.jsxs(W.Flex,{align:"center",gap:3,px:3,py:2,css:io,cursor:"pointer",_hover:{bg:ee?"whiteAlpha.100":"blackAlpha.50"},onClick:()=>{var Pe;(Pe=_.onDirectionChange)==null||Pe.call(_,"C"),Q(!1)},children:[f.jsx(W.Icon,{as:Y.PiAlignCenterHorizontal,boxSize:5,color:pe}),f.jsx(W.Text,{fontSize:"sm",color:pe,flex:1,whiteSpace:"nowrap",children:"Center"}),c==="C"&&f.jsx(W.Icon,{as:Y.PiCheck,boxSize:4,color:q})]})]})})]})]})})]})};Ib.displayName="BottomBar";const Tb=j.memo(Ib);function Lw({checked:e,onChange:r,disabled:t,label:n="Connected nodes"}){return f.jsx(Yr,{hideLabel:!0,label:n,helper:`${n}: isolate node and its connections`,checked:e,onChange:r,disabled:t,icon:f.jsx(W.Icon,{as:Y.PiGraph,boxSize:5})})}const Vu={$bgColor:"bgColor",$textColor:"textColor",$borderColor:"borderColor"};function Nb(e,r){const t=new Map,n=(i,s)=>{if(Object.is(i,s))return!0;if(!i||!s||typeof i!="object"||typeof s!="object"||Array.isArray(i)!==Array.isArray(s))return!1;const a=Object.keys(i);return a.length===Object.keys(s).length&&a.every(c=>Object.prototype.hasOwnProperty.call(s,c)&&n(i[c],s[c]))},o=(i,s,a)=>{if(i===s)return!0;if(!i||!s||typeof i!="object"||typeof s!="object"||Array.isArray(i)!==Array.isArray(s))return!1;const c=new Set([...Object.keys(i),...Object.keys(s)]);for(const l of c)if(!n(i[l],s[l])){if(Object.prototype.hasOwnProperty.call(Vu,l)){if(typeof s[l]!="string"||!s[l])return!1;t.set(a,{...t.get(a),[Vu[l]]:s[l]})}else if(l.startsWith("$")&&l!=="$"||!o(i[l],s[l],l==="$"?a:`${a}.${l}`))return!1}return!0};if(o(e,r,"root"))return t}function Fw(e,r){return Nb(e,r)!==void 0}function zw(e,r,t){if(e===r)return t;const n=Nb(e,r);if(!n)return;const o=new Set(t.nodes.map(i=>i.data.id));for(const i of n.keys())if(!o.has(i)||!Le(r,i))return;return{edges:t.edges,nodes:t.nodes.map(i=>{const s=n.get(i.data.id),a=Le(e,i.data.id),c=Le(r,i.data.id);return!s&&a===c?i:{...i,data:{...i.data,...typeof i.data.code=="string"?{code:JSON.stringify(c,null,2)}:{},...s?{viewProps:{...i.data.viewProps,...s},config:{...i.data.config,...s}}:{}}}})}}function xd(e){return e.kind==="literal"?e.value:e.kind==="union"?xd(e.types[0]):e.kind==="array"?[]:e.kind==="object"?Object.fromEntries(Object.entries(e.properties).filter(([,r])=>!r.optional).map(([r,t])=>[r,xd(t.type)])):e.kind==="boolean"?!1:e.kind==="number"||e.kind==="integer"?0:e.kind==="null"?null:""}function Ob(e,r,t){var y,b,x;const n=(y=Le(e,r))==null?void 0:y.$form,o=n==null?void 0:n.$create;if(!o)return;const i=o.$address.split(".");if(i.shift()!=="root"||!i.length||i.some(v=>!/^[A-Za-z0-9_-]+$/.test(v)||["__proto__","constructor","prototype"].includes(v)))throw new Error("Invalid form creation address.");if(!t||!Object.prototype.hasOwnProperty.call(t,o.$type))throw new Error(`Load form type: ${o.$type}`);const s=i.pop(),a=["root",...i].join("."),c=on(e,a,t),l=(b=c==null?void 0:c.type.properties[s])==null?void 0:b.type;if((l==null?void 0:l.kind)!=="array"||l.items.kind!=="object")throw new Error("Form creation must target an object-array field.");const d=t[o.$type],u=o.$defaults??{};for(const[v,w]of Object.entries(u))if(!Object.prototype.hasOwnProperty.call(d.properties,v)||Ut(d.properties[v].type,w,!d.properties[v].optional))throw new Error(`Invalid creation default: ${v}`);const h={...xd(d),...structuredClone(u)};((x=d.properties.id)==null?void 0:x.type.kind)==="string"&&(h.id=kd());let p=e;const m=Le(e,o.$address);if(m===void 0)p=_t(e,a,v=>({...v,[s]:[]}));else if(!Array.isArray(m)&&!Array.isArray(m==null?void 0:m.$))throw new Error("Form creation destination is not an array.");const g=Id(p,o.$address,{...h,$label:o.$label??o.$type,...o.$icon?{$icon:o.$icon}:{},$form:{$type:o.$type,$create:o}});return{address:g.address,json:Td(g.json,r,{target:g.address,label:o.$edgeLabel})}}function $b(e,r,t){var i;if(r==="root"||!Le(e,r)||!Le(e,t))throw new Error("The source or Parent no longer exists.");const n=new Set;let o=t;for(;o;){if(o===r||o.startsWith(`${r}.`)||n.has(o))throw new Error("A node cannot be moved inside itself or its descendants.");n.add(o);const s=(i=Le(e,o))==null?void 0:i.$parent;o=typeof s=="string"?s:o.includes(".")?o.slice(0,o.lastIndexOf(".")):void 0}return Md(_t(e,r,s=>({...s,$parent:t})),t,!1)}function qb(e,r){const t=new Set(r.filter(a=>Le(e,a)!==void 0)),n=[],o=(a,c)=>{if(!(!a||typeof a!="object")){n.push([c,a]);for(const[l,d]of Object.entries(a))l.startsWith("$")||o(d,`${c}.${l}`)}};o(e,"root");const i=a=>[...t].some(c=>a===c||a.startsWith(`${c}.`));let s=!0;for(;s;){s=!1;for(const[a,c]of n)!i(a)&&typeof c.$parent=="string"&&i(c.$parent)&&(t.add(a),s=!0)}return[...t].filter(a=>![...t].some(c=>c!==a&&a.startsWith(`${c}.`)))}function Bd(e,r){const t=qb(e,r),n=new Map(t.map((a,c)=>[a,`root.node_${c+1}`])),o=a=>{const c=t.find(l=>a===l||a.startsWith(`${l}.`));return c?`${n.get(c)}${a.slice(c.length)}`:void 0},i=a=>{if(!(!a||typeof a!="object")){Array.isArray(a.$connections)&&(a.$connections=a.$connections.flatMap(c=>{const l=typeof c.target=="string"&&o(c.target);return l?[{...c,id:void 0,target:l}]:[]}));for(const c of["$parent","$target"])if(typeof a[c]=="string"){const l=o(a[c]);l?a[c]=l:delete a[c]}for(const[c,l]of Object.entries(a))c.startsWith("$")||i(l)}},s={$hideRoot:!0};return t.forEach((a,c)=>{const l=structuredClone(Le(e,a));i(l),s[`node_${c+1}`]=l}),s}function Lb(e,r){const t=Bd(e,r),n=Object.keys(t).filter(a=>!a.startsWith("$")),o=new Map(n.map(a=>[a,`copy_${crypto.randomUUID()}`])),i=a=>{if(!a||typeof a!="object")return;const c=l=>{const d=l.split(".");return d[0]==="root"&&o.has(d[1])&&(d[1]=o.get(d[1])),d.join(".")};for(const l of a.$connections??[])l.target=c(l.target),l.id=crypto.randomUUID();for(const l of["$parent","$target"])typeof a[l]=="string"&&(a[l]=c(a[l]));for(const[l,d]of Object.entries(a))l.startsWith("$")||i(d)},s=Object.fromEntries(n.map(a=>{const c=t[a];return i(c),[o.get(a),c]}));return{json:_t(e,"root",a=>({...a,...s})),ids:[...o.values()].map(a=>`root.${a}`)}}function Bw(e,r){const t=o=>e&&typeof e=="object"&&o in e;let n=1;for(;t(`${r}_${n}`);)n++;return`${r}_${n}`}function Fb(e,r,t,n,o){const i=(a,c)=>{a!==e&&(e=a,n==null||n(a,c))},s=a=>{var l;const c=(l=r.find(d=>d.data.id===a))==null?void 0:l.data;return c&&{source:c.source,target:c.target,isInverted:c.isInverted,sourceProperty:c.sourceProperty,targetProperty:c.targetProperty,connection:c.connection}};return{...t,onNodeParentChange:(a,c)=>{var d;const l=$b(e,a,c);(d=t.onNodeParentChange)==null||d.call(t,a,c),i(l,{type:"nodeStyle",address:a,key:"$parent",value:c})},onNodesCopy:async a=>{var c;await((c=t.onNodesCopy)==null?void 0:c.call(t,a))!==!0&&await navigator.clipboard.writeText(JSON.stringify(Bd(e,a),null,2))},onNodesDuplicate:a=>{var l;if(((l=t.onNodesDuplicate)==null?void 0:l.call(t,a))===!0)return;const c=Lb(e,a);i(c.json,{type:"nodeCreate",address:c.ids[0]})},onFormChange:a=>{const c=Le(e,a.nodeAddress);if(!c||a.nodeId!==void 0&&c.id!==a.nodeId)throw new Error("This form node has moved. Retry the edit.");i(xo(e,a,t.onFormChange),{type:"form",address:a.address,value:a.value})},onNodeLabelChange:(a,c)=>{var l;(l=t.onNodeLabelChange)==null||l.call(t,a,c),i(xt(e,a,"$label",c),{type:"nodeLabel",address:a,key:"$label",value:c})},onNodeSubtitleChange:(a,c)=>{var l;(l=t.onNodeSubtitleChange)==null||l.call(t,a,c),i(xt(e,a,"$subtitle",c),{type:"nodeStyle",address:a,key:"$subtitle",value:c})},onNodeContentChange:(a,c)=>{var l;(l=t.onNodeContentChange)==null||l.call(t,a,c),i(xt(e,a,"$content",c),{type:"nodeContent",address:a,key:"$content",value:c})},onNodeTypeViewChange:(a,c)=>{var l;c!==void 0&&!Ed.includes(c)||((l=t.onNodeTypeViewChange)==null||l.call(t,a,c),i(xt(e,a,"$view",c),{type:"nodeStyle",address:a,key:"$view",value:c}))},onNodeColorChange:(a,c,l)=>{var u;(u=t.onNodeColorChange)==null||u.call(t,a,c,l);const d=c==="bg"?"$bgColor":"$textColor";i(xt(e,a,d,l),{type:"nodeColor",address:a,key:d,value:l})},onNodeBorderColorChange:(a,c)=>{var l;(l=t.onNodeBorderColorChange)==null||l.call(t,a,c),i(xt(e,a,"$borderColor",c),{type:"nodeColor",address:a,key:"$borderColor",value:c})},onNodeBorderStyleChange:(a,c)=>{var l;(l=t.onNodeBorderStyleChange)==null||l.call(t,a,c),i(xt(e,a,"$borderStyle",c),{type:"nodeStyle",address:a,key:"$borderStyle",value:c})},onNodeBorderWidthChange:(a,c)=>{var l;c!==void 0&&(!Number.isFinite(c)||c<0)||((l=t.onNodeBorderWidthChange)==null||l.call(t,a,c),i(xt(e,a,"$borderWidth",c),{type:"nodeStyle",address:a,key:"$borderWidth",value:c}))},onNodeBorderRadiusChange:(a,c)=>{var l;c!==void 0&&(!Number.isFinite(c)||c<0)||((l=t.onNodeBorderRadiusChange)==null||l.call(t,a,c),i(xt(e,a,"$borderRadius",c),{type:"nodeStyle",address:a,key:"$borderRadius",value:c}))},onNodeDimensionChange:(a,c,l)=>{var u;if(c!=="width"&&c!=="height"||l!==void 0&&(!Number.isFinite(l)||l<=0))return;(u=t.onNodeDimensionChange)==null||u.call(t,a,c,l);const d=c==="width"?"$width":"$height";i(xt(e,a,d,l),{type:"nodeStyle",address:a,key:d,value:l})},onNodeIconChange:(a,c)=>{var l;(l=t.onNodeIconChange)==null||l.call(t,a,c),i(xt(e,a,"$icon",c),{type:"nodeIcon",address:a,key:"$icon",value:c})},onNodeOutlineChange:(a,c)=>{var l;(l=t.onNodeOutlineChange)==null||l.call(t,a,c),i(xt(e,a,"$outline",c),{type:"nodeOutline",address:a,key:"$outline",value:c})},onNodeAnimationChange:(a,c)=>{var l;(l=t.onNodeAnimationChange)==null||l.call(t,a,c),i(xt(e,a,"$isNodeAnimated",c),{type:"nodeAnimation",address:a,key:"$isNodeAnimated",value:c})},onNodeAnimationVariantChange:(a,c)=>{var l;c!=="traveling"&&c!=="pulse"||((l=t.onNodeAnimationVariantChange)==null||l.call(t,a,c),i(xt(e,a,"$nodeAnimationVariant",c),{type:"nodeAnimation",address:a,key:"$nodeAnimationVariant",value:c}))},onNodeCollapse:(a,c)=>{var l;(l=t.onNodeCollapse)==null||l.call(t,a,c),i(Md(e,a,c),{type:"nodeCollapse",address:a,key:"$collapsed",value:c})},onNodeCreate:a=>{var p,m;if(((p=t.onNodeCreate)==null?void 0:p.call(t,a))===!0)return;const c=a.sourceNodeId||"root",l=!!a.sourceNodeId&&a.isArrayMode&&!((m=Le(e,c))!=null&&m.$arrayDrawInitialized);let d=e,u,h=a.isArrayMode?"array":"set";for(let g=0;g<(l?2:1);g++){const y=a.sourceNodeId&&Ob(d,a.sourceNodeId,o);if(y)d=y.json,u??(u=y.address),h="form";else{const b=Bw(Le(d,c),a.isArrayMode?"list":"node"),x=a.isArrayMode?{$bgColor:"gray.500",$:[]}:{$bgColor:"gray.500"},v=Id(d,c,x,b);d=v.json,u??(u=v.address)}}l&&(d=_t(d,c,g=>Array.isArray(g)?{$:g,$arrayDrawInitialized:!0}:{...g,$arrayDrawInitialized:!0})),i(d,{type:"nodeCreate",address:u,value:h})},onNodeDelete:(a,c)=>{var l;(l=t.onNodeDelete)==null||l.call(t,a,c),i(hb(e,a),{type:"nodeDelete",address:a})},onEdgeCreate:(a,c,l)=>{var u;(u=t.onEdgeCreate)==null||u.call(t,a,c,l);const d=l&&(l.sourceProperty!==void 0||l.targetProperty!==void 0)?{...l,target:c}:void 0;i(d?Td(e,a,d):pb(e,a,c),{type:"edgeCreate",address:a,key:d?"$connections":"$target",value:d??c})},onEdgeLabelChange:(a,c)=>{var d;(d=t.onEdgeLabelChange)==null||d.call(t,a,c);const l=s(a);l&&i(gr(e,l,"$sourceLabel",c),{type:"edgeLabel",edge:l,key:l.connection?"$connections":"$sourceLabel",value:c})},onEdgeStyleChange:(a,c)=>{var d;(d=t.onEdgeStyleChange)==null||d.call(t,a,c);const l=s(a);l&&i(fb(e,l,c),{type:"edgeStyle",edge:l,value:c})},onEdgeAnimationVariantChange:(a,c)=>{var d;if(c!=="dashed"&&c!=="traveling")return;(d=t.onEdgeAnimationVariantChange)==null||d.call(t,a,c);const l=s(a);l&&i(gr(e,l,"$edgeAnimationVariant",c),{type:"edgeStyle",edge:l,key:l.connection?"$connections":"$edgeAnimationVariant",value:c})},onEdgeTypeChange:(a,c)=>{var d;(d=t.onEdgeTypeChange)==null||d.call(t,a,c);const l=s(a);l&&i(gr(e,l,"$edgeType",c),{type:"edgeStyle",edge:l,key:l.connection?"$connections":"$edgeType",value:c})},onEdgeIconChange:(a,c)=>{var d;(d=t.onEdgeIconChange)==null||d.call(t,a,c);const l=s(a);l&&i(gr(e,l,"$edgeIcon",c||void 0),{type:"edgeStyle",edge:l,key:l.connection?"$connections":"$edgeIcon",value:c})},onEdgeColorChange:(a,c)=>{var d;(d=t.onEdgeColorChange)==null||d.call(t,a,c);const l=s(a);l&&i(gr(e,l,"$edgeColor",c),{type:"edgeColor",edge:l,key:l.connection?"$connections":"$edgeColor",value:c})},onEdgeDelete:(a,c)=>{var u;(u=t.onEdgeDelete)==null||u.call(t,a,c);const l=s(a);if(!l)return;const d=gb(e,l);d.removed&&i(d.json,{type:"edgeDelete",edge:l,key:l.connection?"$connections":"$target"})}}}const Dw=".flow-sdk-edge-reveal{animation:flow-sdk-edge-reveal var(--flow-edge-reveal-duration,600ms) linear both;animation-play-state:var(--flow-edge-reveal-state,running)}.flow-sdk-edge-reveal-end{animation:flow-sdk-edge-reveal-end var(--flow-edge-reveal-duration,600ms) steps(1,end) both;animation-play-state:var(--flow-edge-reveal-state,running)}@keyframes flow-sdk-edge-reveal{from{stroke-dashoffset:var(--flow-edge-reveal-from,100)}to{stroke-dashoffset:0}}@keyframes flow-sdk-edge-reveal-end{from{opacity:0}to{opacity:1}}@media(prefers-reduced-motion:reduce){.flow-sdk-edge-reveal{animation:none;stroke-dashoffset:0}.flow-sdk-edge-reveal-end{animation:none;opacity:1}}";function Ww({path:e,width:r,reversed:t,children:n,onComplete:o}){const i=`flow-edge-reveal-${j.useId().replace(/:/g,"")}`,s=j.useRef(null),[a,c]=j.useState({x:0,y:0,width:1,height:1});return j.useEffect(()=>{const l=matchMedia("(prefers-reduced-motion: reduce)"),d=()=>{l.matches&&(o==null||o())};return d(),l.addEventListener("change",d),()=>l.removeEventListener("change",d)},[o]),j.useLayoutEffect(()=>{var d;const l=(d=s.current)==null?void 0:d.getBBox();l&&c({x:l.x-r,y:l.y-r,width:l.width+r*2,height:l.height+r*2})},[e,r]),f.jsxs(f.Fragment,{children:[f.jsx("defs",{children:f.jsx("mask",{id:i,maskUnits:"userSpaceOnUse",...a,children:f.jsx("path",{ref:s,className:"flow-sdk-edge-reveal",onAnimationEnd:l=>{l.animationName==="flow-sdk-edge-reveal"&&(o==null||o())},"data-reveal-direction":t?"reverse":"forward",style:{"--flow-edge-reveal-from":t?-100:100},d:e,fill:"none",stroke:"white",strokeWidth:r,strokeLinecap:"butt",strokeLinejoin:"round",pathLength:100,strokeDasharray:"100 100"})})}),f.jsx("g",{mask:`url(#${i})`,children:n})]})}const Vw=".flow-sdk-edge-trace{pointer-events:none;animation:flow-sdk-edge-trace 2.4s linear infinite}.flow-sdk-edge-trace-reverse{animation-direction:reverse}@keyframes flow-sdk-edge-trace{from{stroke-dashoffset:18}to{stroke-dashoffset:-100}}@media(prefers-reduced-motion:reduce){.flow-sdk-edge-trace,.flow-sdk-edge-anim{animation:none}}";function Gw({path:e,color:r,width:t,reversed:n}){return f.jsx("path",{className:`flow-sdk-edge-trace${n?" flow-sdk-edge-trace-reverse":""}`,"data-animation-variant":"traveling","aria-hidden":"true",pointerEvents:"none",d:e,fill:"none",stroke:r,strokeWidth:t,strokeLinecap:"round",pathLength:100,strokeDasharray:"18 100"})}const zb=".flow-sdk-node-animation{position:absolute;inset:0;width:100%;height:100%;overflow:visible;pointer-events:none;z-index:1}.flow-sdk-node-border-animation{pointer-events:none;animation:flow-sdk-node-border 2.4s linear infinite}.flow-sdk-node-border-pulse{stroke-width:var(--flow-pulse-rest-width);animation:flow-sdk-node-pulse 1.8s ease-in-out infinite}@keyframes flow-sdk-node-border{from{stroke-dashoffset:0}to{stroke-dashoffset:-100}}@keyframes flow-sdk-node-pulse{0%,100%{stroke-width:var(--flow-pulse-rest-width)}50%{stroke-width:var(--flow-pulse-expanded-width)}}@media(prefers-reduced-motion:reduce){.flow-sdk-node-border-animation{animation:none}}";function so({x:e=0,y:r=0,width:t,height:n,radius:o,color:i,strokeWidth:s=8,path:a,variant:c="traveling"}){const l=j.useId(),d=`flow-sdk-node-border-animation${c==="pulse"?" flow-sdk-node-border-pulse":""}`;if(c==="pulse"){const u=a?"path":"rect",h=a?{d:a}:{x:e,y:r,width:Math.max(0,t),height:Math.max(0,n),rx:Math.max(0,Math.min(o,t/2,n/2))},p=s+36,m={x:e-p,y:r-p,width:t+2*p,height:n+2*p};return f.jsxs("g",{"aria-hidden":"true",pointerEvents:"none",children:[f.jsx("defs",{children:f.jsxs("mask",{id:l,maskUnits:"userSpaceOnUse",...m,style:{maskType:"luminance"},children:[f.jsx("rect",{...m,fill:"white"}),f.jsx(u,{...h,fill:"black",stroke:"black",strokeWidth:s,strokeLinejoin:"round"})]})}),f.jsx(u,{...h,className:d,"data-animation-variant":c,fill:"none",stroke:`color-mix(in srgb, ${i} 30%, transparent)`,strokeLinejoin:"round",mask:`url(#${l})`,style:{"--flow-pulse-rest-width":`${s+16}px`,"--flow-pulse-expanded-width":`${s+36}px`}})]})}return a?f.jsx("path",{className:d,"data-animation-variant":c,"aria-hidden":"true",pointerEvents:"none",d:a,fill:"none",stroke:i,strokeWidth:s,strokeLinecap:"round",pathLength:100,strokeDasharray:"18 82"}):f.jsx("rect",{className:d,"data-animation-variant":c,"aria-hidden":"true",pointerEvents:"none",x:e,y:r,width:Math.max(0,t),height:Math.max(0,n),rx:Math.max(0,Math.min(o,t/2,n/2)),fill:"none",stroke:i,strokeWidth:s,strokeLinecap:"round",pathLength:100,strokeDasharray:"18 82"})}const Uw=e=>{const n=1/(Math.cbrt(e)*.8);let o=Math.round(650*n),i=Math.round(350*n);return o=Math.max(40,Math.min(450,o)),i=Math.max(30,Math.min(300,i)),{edgeSep:o,rankSep:i}};function Bb(e,r=!1){return e&&!r&&typeof requestAnimationFrame<"u"&&!(typeof matchMedia<"u"&&matchMedia("(prefers-reduced-motion: reduce)").matches)}function Db(e,r,t=()=>{},n=300){let o,i,s=!1;const a=()=>{s=!0,o!==void 0&&cancelAnimationFrame(o),clearTimeout(i)},c=()=>{s||(a(),r(1),t())};if(!Bb(e))return c(),a;const l=performance.now(),d=u=>{if(s)return;const h=Math.max(0,Math.min(1,(u-l)/n));if(h>=1)return c();r(h<.5?4*h**3:1-(-2*h+2)**3/2),s||(o=requestAnimationFrame(d))};return o=requestAnimationFrame(d),i=setTimeout(c,n+100),a}function Gu(e,r,t){const n=new Set([e]),o=[e];for(;o.length;){const i=o.pop();for(const s of r)(s.parent===i||s.id.startsWith(`${i}.`)||t.some(c=>(c.inverted?c.target:c.source)===i&&(c.inverted?c.source:c.target)===s.id))&&!n.has(s.id)&&(n.add(s.id),o.push(s.id))}return n}function Hw(e,r,t){const n=t==="downward"||t==="upward",o=new Map;for(const s of e){if(s.source===s.target||s.sourceProperty||s.targetProperty)continue;const a=r(s.source),c=r(s.target);if(!a||!c)continue;const l=n?c.y-a.y:c.x-a.x,d=Math.abs(l)-(n?a.h+c.h:a.w+c.w)/2;if(d<=320)continue;const u=JSON.stringify([s.source,Math.sign(l)]),h=o.get(u)??[];h.push({edge:s,gap:d,cross:n?c.x-a.x:c.y-a.y}),o.set(u,h)}const i=new Map;for(const s of o.values()){if(new Set(s.map(({edge:c})=>c.target)).size<2)continue;const a=new Map;for(const{edge:c}of s)a.set(c.target,(a.get(c.target)??0)+1);for(const c of[-1,0,1]){const l=s.filter(({cross:u})=>Math.sign(u)===c);l.sort((u,h)=>Math.abs(h.cross)-Math.abs(u.cross)||u.edge.id.localeCompare(h.edge.id));const d=Math.min(...l.map(({gap:u})=>u));l.forEach(({edge:u,gap:h,cross:p},m)=>{const g=l.length===1?d/2:120+(d-280)*m/(l.length-1),y=l.find(b=>Math.abs(b.cross)<Math.abs(p));i.set(u.id,{turn:g/h,labelAtTarget:a.get(u.target)===1,labelFraction:p?(p+((y==null?void 0:y.cross)??0))/(2*p):.5})})}}return i}const tr=e=>({x1:e.x-e.w/2,y1:e.y-e.h/2,x2:e.x+e.w/2,y2:e.y+e.h/2}),Kw=e=>({x:(e.x1+e.x2)/2,y:(e.y1+e.y2)/2,w:e.x2-e.x1,h:e.y2-e.y1});function Ho(e){if(!e.length)return null;const r={...e[0]};for(let t=1;t<e.length;t++)r.x1=Math.min(r.x1,e[t].x1),r.y1=Math.min(r.y1,e[t].y1),r.x2=Math.max(r.x2,e[t].x2),r.y2=Math.max(r.y2,e[t].y2);return r}const Jw=(e,r)=>e.x1<=r.x2&&e.x2>=r.x1&&e.y1<=r.y2&&e.y2>=r.y1,Uu=(e,r)=>e.x>=r.x1&&e.x<=r.x2&&e.y>=r.y1&&e.y<=r.y2,Lt=e=>(Math.round(e*10)/10).toString(),yt=e=>`${Lt(e.x)} ${Lt(e.y)}`,Zw=e=>e>0?1:e<0?-1:0,Hu=(e,r)=>e>0?Math.max(e-r,0):Math.min(e+r,0);function Xw(e,r,t,n,o=10){const i=r.x-e.x,s=r.y-e.y,a=Hu(i,(e.w+r.w)/2),c=Hu(s,(e.h+r.h)/2),l=t==="downward"||t==="upward",d=l?c:a,u=l?s:i,h=Zw(u),p=n*d,m=x=>Math.abs(x)<o||Math.abs(x)>=Math.abs(d),g=m(p)||m(Math.abs(d)-Math.abs(p));let y;if(g)if(l)if(Math.abs(u)<=e.h/2){const x=(e.x+r.x)/2;y=[x,e.y,x,r.y]}else if(Math.abs(i)<=r.w/2){const x=(e.y+r.y)/2;y=[e.x,x,r.x,x]}else y=[e.x,r.y];else if(Math.abs(u)<=e.w/2){const x=(e.y+r.y)/2;y=[e.x,x,r.x,x]}else if(Math.abs(s)<=r.h/2){const x=(e.x+r.x)/2;y=[x,e.y,x,r.y]}else y=[r.x,e.y];else if(l){const x=e.y+p+e.h/2*h;y=[e.x,x,r.x,x]}else{const x=e.x+p+e.w/2*h;y=[x,e.y,x,r.y]}const b=[{x:e.x,y:e.y}];for(let x=0;x<y.length;x+=2)b.push({x:y[x],y:y[x+1]});return b.push({x:r.x,y:r.y}),b}function Yw(e,r,t){const n=r.x-e.x,o=r.y-e.y,i=n>0?(t.x2-e.x)/n:n<0?(t.x1-e.x)/n:1/0,s=o>0?(t.y2-e.y)/o:o<0?(t.y1-e.y)/o:1/0,a=Math.min(i,s);return!Number.isFinite(a)||a>=1||a<0?null:{x:e.x+n*a,y:e.y+o*a}}function en(e,r,t){var s;if(!((s=t.outline)!=null&&s.length))return Yw(e,r,tr(t));const n=r.x-e.x,o=r.y-e.y;let i=1/0;return t.outline.forEach((a,c,l)=>{const d=l[(c+1)%l.length],u=d.x-a.x,h=d.y-a.y,p=n*h-o*u;if(Math.abs(p)<1e-9)return;const m=a.x-e.x,g=a.y-e.y,y=(m*h-g*u)/p,b=(m*o-g*n)/p;y>=0&&y<1&&b>=-1e-9&&b<=1+1e-9&&(i=Math.min(i,y))}),Number.isFinite(i)?{x:e.x+n*i,y:e.y+o*i}:null}function Wb(e,r,t=.5){const n=Number.isFinite(t)?Math.max(0,Math.min(1,t)):.5,o=r==="top"||r==="bottom",i=r==="top"||r==="left"?-1:1,s={x:o?e.x-e.w/2+e.w*n:e.x,y:o?e.y:e.y-e.h/2+e.h*n},a=Math.max(e.w,e.h)*2+1;return{...en(s,{x:s.x+(o?0:i*a),y:s.y+(o?i*a:0)},e)??{x:o?s.x:e.x+i*e.w/2,y:o?e.y+i*e.h/2:s.y},side:r}}function Ur(e,r){return{x:e.x+(e.side==="right"?r:e.side==="left"?-r:0),y:e.y+(e.side==="bottom"?r:e.side==="top"?-r:0)}}function Qw(e,r,t,n){const o=Ur(e,t.srcDist),i=Ur(r,t.tgtDist);if(n==="straight")return Gb(o,i,t);const s=Math.max(80,Math.min(300,Math.hypot(i.x-o.x,i.y-o.y)/3)),a=e.side==="bottom"&&r.side==="top"?i.y-o.y:e.side==="top"&&r.side==="bottom"?o.y-i.y:e.side==="right"&&r.side==="left"?i.x-o.x:e.side==="left"&&r.side==="right"?o.x-i.x:void 0,c=a!==void 0&&a>0?Math.min(s,a/2):s,l=Ur({...o,side:e.side},c),d=Ur({...i,side:r.side},c),u=t.arrowAt==="source"?vt(o,l,t.arrowGap):o,h=t.arrowAt==="target"?vt(i,d,t.arrowGap):i,p=t.arrowAt==="source"?zt(o,l,t.arrowSize,t.headShape):t.arrowAt==="target"?zt(i,d,t.arrowSize,t.headShape):void 0;if(n==="bezier")return{d:`M${yt(u)} C${yt(l)} ${yt(d)} ${yt(h)}`,arrow:p,label:{x:(u.x+3*l.x+3*d.x+h.x)/8,y:(u.y+3*l.y+3*d.y+h.y)/8,angle:0}};const m=e.side==="left"||e.side==="right",g=r.side==="left"||r.side==="right";let y;if(m!==g){const x=m?{x:d.x,y:l.y}:{x:l.x,y:d.y},v=(x.x-l.x)*(l.x-o.x)+(x.y-l.y)*(l.y-o.y)>=0,w=(x.x-d.x)*(d.x-i.x)+(x.y-d.y)*(d.y-i.y)>=0;y=[v&&w?x:m?{x:l.x,y:d.y}:{x:d.x,y:l.y}]}else if(a!==void 0&&a<=0)if(m){const x=(l.y+d.y)/2;y=[{x:l.x,y:x},{x:d.x,y:x}]}else{const x=(l.x+d.x)/2;y=[{x,y:l.y},{x,y:d.y}]}else if(m){const x=e.side===r.side?e.side==="right"?Math.max(l.x,d.x):Math.min(l.x,d.x):(l.x+d.x)/2;y=[{x,y:l.y},{x,y:d.y}]}else{const x=e.side===r.side?e.side==="bottom"?Math.max(l.y,d.y):Math.min(l.y,d.y):(l.y+d.y)/2;y=[{x:l.x,y:x},{x:d.x,y:x}]}const b=[l,...y,d].filter((x,v,w)=>v===0||x.x!==w[v-1].x||x.y!==w[v-1].y);return wo(u,b,h,p,n==="orthogonal"?0:t.radius)}function vt(e,r,t){const n=e.x-r.x,o=e.y-r.y,i=Math.hypot(n,o);if(!i)return e;let s=(i-t)/i;return s<0&&(s=1e-5),{x:r.x+s*n,y:r.y+s*o}}function zt(e,r,t,n="triangle"){const o=e.x-r.x,i=e.y-r.y,s=Math.hypot(o,i)||1,a=o/s,c=i/s,l=(n==="square"?.15:.3)*t,d=.15*t,u=e.x-a*l,h=e.y-c*l;if(n==="square")return`M${yt(e)} L${Lt(e.x-c*d)} ${Lt(e.y+a*d)} L${Lt(u-c*d)} ${Lt(h+a*d)} L${Lt(u+c*d)} ${Lt(h-a*d)} L${Lt(e.x+c*d)} ${Lt(e.y-a*d)} Z`;const p=[e,{x:u-c*d,y:h+a*d},{x:u+c*d,y:h-a*d}];return p.map((g,y)=>{const b=p[(y+2)%3],x=p[(y+1)%3],v=Math.hypot(b.x-g.x,b.y-g.y),w=Math.hypot(x.x-g.x,x.y-g.y),C={x:(b.x-g.x)/v,y:(b.y-g.y)/v},S={x:(x.x-g.x)/w,y:(x.y-g.y)/w},R=Math.max(-1,Math.min(1,C.x*S.x+C.y*S.y)),P=Math.sqrt((1-R)/(1+R)),k=Math.min(1/P,v/2,w/2);return{start:{x:g.x+C.x*k,y:g.y+C.y*k},end:{x:g.x+S.x*k,y:g.y+S.y*k},radius:k*P}}).map((g,y)=>`${y?"L":"M"}${yt(g.start)} A${Lt(g.radius)} ${Lt(g.radius)} 0 0 1 ${yt(g.end)}`).join(" ")+" Z"}function pr(e,r){let t=Math.atan(r/e);return e===0&&t<0&&(t=-t),Number.isFinite(t)||(t=0),t*180/Math.PI}function e1(e,r,t,n){const o={x:r.x-e.x,y:r.y-e.y},i={x:t.x-r.x,y:t.y-r.y},s=Math.hypot(o.x,o.y),a=Math.hypot(i.x,i.y),c=o.x*i.y-o.y*i.x;if(s<1e-6||a<1e-6||Math.abs(c)<1e-6)return{p1:r,b:r,p2:r,r:0};const l=Math.min(n,s/2,a/2);return{p1:{x:r.x-o.x/s*l,y:r.y-o.y/s*l},b:r,p2:{x:r.x+i.x/a*l,y:r.y+i.y/a*l},r:l}}function Vb(e,r,t,n){let o=-1,i=null;for(let m=0;m<e.length-1;m++){const g=en(e[m],e[m+1],r);if(g){o=m,i=g;break}}let s=-1,a=null;for(let m=e.length-1;m>0;m--){const g=en(e[m],e[m-1],t);if(g){s=m,a=g;break}}if(!i||!a||o>=s)return null;const c=e.slice(o+1,s),l=c[0]??a,d=c[c.length-1]??i;let u,h,p;if(n.arrowAt==="source"){const m=vt(i,l,n.srcDist);u=vt(i,l,n.srcDist+n.arrowGap),p=zt(m,l,n.arrowSize,n.headShape)}else u=vt(i,l,n.srcDist);if(n.arrowAt==="target"){const m=vt(a,d,n.tgtDist);h=vt(a,d,n.tgtDist+n.arrowGap),p=zt(m,d,n.arrowSize,n.headShape)}else h=vt(a,d,n.tgtDist);return wo(u,c,h,p,n.radius,n.labelTargetLength,n.labelFraction)}function wo(e,r,t,n,o,i,s){var h;const a=[e,...r,t],c=[];let l=`M${yt(e)}`;for(let p=1;p<a.length-1;p++){const m=e1(a[p-1],a[p],a[p+1],o);c.push(m),m.r===0?l+=` L${yt(m.b)}`:l+=` L${yt(m.p1)} Q${yt(m.b)} ${yt(m.p2)}`}l+=` L${yt(t)}`;let d;const u=r.length;if(u===0)d={x:(e.x+t.x)/2,y:(e.y+t.y)/2,angle:pr(t.x-e.x,t.y-e.y)};else if(u%2===0){const p=r[u/2-1],m=r[u/2];d={x:(p.x+m.x)/2,y:(p.y+m.y)/2,angle:pr(m.x-p.x,m.y-p.y)}}else{const p=c[(u-1)/2];if(p.r===0){const m=a[(u-1)/2+2];d={x:p.b.x,y:p.b.y,angle:pr(m.x-p.b.x,m.y-p.b.y)}}else d={x:.25*p.p1.x+.5*p.b.x+.25*p.p2.x,y:.25*p.p1.y+.5*p.b.y+.25*p.p2.y,angle:pr(p.p2.x-p.p1.x,p.p2.y-p.p1.y)}}if(i!==void 0){if(s!==void 0&&c.length===2){const y=c[0].p2,b=c[1].p1,x=Math.hypot(b.x-y.x,b.y-y.y),v=Math.min(.5,i/(2*x)),w=Math.max(v,Math.min(1-v,s));d={x:y.x+(b.x-y.x)*w,y:y.y+(b.y-y.y)*w,angle:pr(b.x-y.x,b.y-y.y)}}const p=((h=c[c.length-1])==null?void 0:h.p2)??e,m=t.x-p.x,g=t.y-p.y;Math.hypot(m,g)>=i&&(d={x:(p.x+t.x)/2,y:(p.y+t.y)/2,angle:pr(m,g)})}return{d:l,arrow:n,label:d}}function Ku(e,r,t,n,o,i,s){const a=t==="leftward"?-1:1,c={x:e.x+a*(e.w/2+s.srcDist),y:n??e.y},l={x:r.x-a*(r.w/2+s.tgtDist),y:o??r.y},d=Math.max(80,s.arrowGap+s.arrowSize*.3),u=c.x+a*d,h=l.x-a*d;let p;if(a*(h-u)>=0){const b=c.x+(l.x-c.x)*i,x=Math.max(Math.min(u,h),Math.min(Math.max(u,h),b));p=[{x,y:c.y},{x,y:l.y}]}else{const b=Math.min(e.y-e.h/2,r.y-r.h/2)-d*(1+i);p=[{x:u,y:c.y},{x:u,y:b},{x:h,y:b},{x:h,y:l.y}]}const m=s.arrowAt==="source"?vt(c,p[0],s.arrowGap):c,g=s.arrowAt==="target"?vt(l,p[p.length-1],s.arrowGap):l,y=s.arrowAt==="source"?zt(c,p[0],s.arrowSize,s.headShape):s.arrowAt==="target"?zt(l,p[p.length-1],s.arrowSize,s.headShape):void 0;return wo(m,p,g,y,s.radius)}function Ju(e,r,t,n,o){return Vb(Xw(e,r,t,n),e,r,o)}function Zu(e,r,t,n,o,i){const s=n===void 0&&o===void 0&&(t==="downward"||t==="upward"),a=t==="leftward"||s&&t==="upward"?-1:1,c=(l,d,u)=>{const h={x:l.x,y:d??l.y},p=Math.max(l.w,l.h)*2+1,m=en(h,{x:h.x+(s?0:u*p),y:h.y+(s?u*p:0)},l);return m?{x:m.x+(s?0:u*i),y:m.y+(s?u*i:0)}:s?{x:l.x,y:l.y+u*(l.h/2+i)}:{x:l.x+u*(l.w/2+i),y:d??l.y}};return{sourcePoint:c(e,n,a),targetPoint:c(r,o,-a)}}function t1(e,r,t,n){const o=t==="downward"||t==="upward",i=t==="leftward"||t==="upward"?-1:1,s=Math.max(100,Math.abs(o?r.y-e.y:r.x-e.x)/2),a={x:e.x+(o?0:i*s),y:e.y+(o?i*s:0)},c={x:r.x-(o?0:i*s),y:r.y-(o?i*s:0)},l=n.arrowAt==="source"?vt(e,a,n.arrowGap):e,d=n.arrowAt==="target"?vt(r,c,n.arrowGap):r;return{d:`M${yt(l)} C${yt(a)} ${yt(c)} ${yt(d)}`,arrow:n.arrowAt==="source"?zt(e,a,n.arrowSize,n.headShape):n.arrowAt==="target"?zt(r,c,n.arrowSize,n.headShape):void 0,label:{x:(l.x+3*a.x+3*c.x+d.x)/8,y:(l.y+3*a.y+3*c.y+d.y)/8,angle:pr(d.x+c.x-a.x-l.x,d.y+c.y-a.y-l.y)}}}function Gb(e,r,t){const n=t.arrowAt==="source"?vt(e,r,t.arrowGap):e,o=t.arrowAt==="target"?vt(r,e,t.arrowGap):r,i=t.arrowAt==="source"?zt(e,r,t.arrowSize,t.headShape):t.arrowAt==="target"?zt(r,e,t.arrowSize,t.headShape):void 0;return wo(n,[],o,i,0)}function r1(e,r,t,n=-90,o=-60,i=350){const s=n*Math.PI/180,a=o*Math.PI/180,c=s-Math.PI/2,l=c-a/2,d=c+a/2,u=1.4*i*(r/3+1),h={x:e.x+Math.cos(l)*u,y:e.y+Math.sin(l)*u},p={x:e.x+Math.cos(d)*u,y:e.y+Math.sin(d)*u},m={x:e.x,y:e.y},g=en(m,h,e),y=en(m,p,e);if(!g||!y)return null;const b={x:(h.x+p.x)/2,y:(h.y+p.y)/2};let x=vt(g,h,t.srcDist),v=vt(y,p,t.tgtDist),w;if(t.arrowAt==="target"){const S=v;v=vt(y,p,t.tgtDist+t.arrowGap),w=zt(S,p,t.arrowSize,t.headShape)}else if(t.arrowAt==="source"){const S=x;x=vt(g,h,t.srcDist+t.arrowGap),w=zt(S,h,t.arrowSize,t.headShape)}return{d:`M${yt(x)} Q${yt(h)} ${yt(b)} Q${yt(p)} ${yt(v)}`,arrow:w,label:{x:b.x,y:b.y,angle:pr(p.x-h.x,p.y-h.y)}}}const Pr=e=>Math.round(e*1e3)/1e3;function Ub(e){var h,p;const r=e.querySelector("[data-flow-node-surface]");if(!r)return;const t=e.getBoundingClientRect(),n=t.width/e.offsetWidth;if(!Number.isFinite(n)||n<=0)return;const o=r.getBoundingClientRect();if(!o.width||!o.height)return;const i=(p=(h=r.closest("[data-flow-icon-label]"))==null?void 0:h.querySelector("[data-flow-icon-caption]"))==null?void 0:p.getBoundingClientRect(),s=r,a=typeof s.getScreenCTM=="function"?s.getScreenCTM():null,c=typeof s.getTotalLength=="function"?s.getTotalLength():0,l=s.points,d=(l==null?void 0:l.numberOfItems)||128,u=a&&c>0?Array.from({length:d},(m,g)=>{const y=l!=null&&l.numberOfItems?l.getItem(g):s.getPointAtLength(c*g/d);return{x:Pr((a.a*y.x+a.c*y.y+a.e-t.left)/n),y:Pr((a.b*y.x+a.d*y.y+a.f-t.top)/n)}}):void 0;return{left:Pr((o.left-t.left)/n),top:Pr((o.top-t.top)/n),width:r instanceof HTMLElement?r.offsetWidth:Pr(o.width/n),height:r instanceof HTMLElement?r.offsetHeight:Pr(o.height/n),radius:parseFloat(getComputedStyle(r).borderTopLeftRadius)||0,...i!=null&&i.height?{captionBottom:Pr((i.bottom-t.top)/n)}:{},...u?{outline:u}:{}}}function Pn(e,r){const t=e.x-e.w/2,n=e.y-e.h/2;return{x:t+r.left+r.width/2,y:n+r.top+r.height/2,w:r.width,h:r.height,...r.outline?{outline:r.outline.map(o=>({x:t+o.x,y:n+o.y}))}:{}}}function n1(e,r,t,n,o){var d;const i=o!=="TB"&&o!=="BT",s=i?"top":"left",a=i?"bottom":"right",c=new Map;for(const u of n)for(const[h,p,m]of[[u.source,u.sourceProperty,u.target],[u.target,u.targetProperty,u.source]]){const g=r.get(m);if(p===void 0||!g||m===h)continue;const y=t.get(m),b=JSON.stringify([h,p]),x=c.get(b)??[];x.push(y?Pn(g,y):g),c.set(b,x)}const l=new Map(e);for(const[u,h]of e){const p=r.get(u);if(!p||!h.some(v=>v.placement==="config"))continue;const m=t.get(u),g=m?Pn(p,m):p,y={x:p.w/2,y:p.h/2,w:p.w,h:p.h},b=m?Pn(y,m):y,x=new Map;for(const v of h){if(v.placement!=="config")continue;const C=(c.get(JSON.stringify([u,v.property]))??[]).reduce((R,P)=>R+(i?P.y-g.y:P.x-g.x),0),S=((d=v.anchor)==null?void 0:d.side)===a?a:s;x.set(v,C<-.001?s:C>.001?a:S)}l.set(u,h.map(v=>{const w=x.get(v);if(!w)return v;const C=h.filter(P=>x.get(P)===w),S=(C.indexOf(v)+1)/(C.length+1),R=Wb(b,w,S);return{...v,anchor:R,top:R.y,height:0}}))}return l}function Xu(e,r,t){const n=new Set(r.map(a=>a.id));if(!n.has(e))return new Set;const o=new Set([e]);let i=!0;for(;i;){i=!1;for(const a of r)!o.has(a.id)&&(o.has(a.parent??"")||a.id.startsWith(`${e}.`))&&(o.add(a.id),i=!0)}const s=new Set(o);for(const a of t)o.has(a.source)&&n.has(a.target)&&s.add(a.target),o.has(a.target)&&n.has(a.source)&&s.add(a.source);return s}const mr='"Helvetica Neue", Helvetica, sans-serif';let gn;const Yn=new Map;function Co(e,r){const t=`${r}|${e}`,n=Yn.get(t);if(n!==void 0)return n;gn===void 0&&(gn=typeof document<"u"?document.createElement("canvas").getContext("2d"):null);let o;return gn?(gn.font=r,o=gn.measureText(e).width):o=e.length*(parseFloat(r)||16)*.55,Yn.size>5e3&&Yn.clear(),Yn.set(t,o),o}function o1(e,r,t){const n=[];for(const o of String(e).split(`
|
|
210
|
+
`)){const i=o.split(/\s+/).filter(Boolean);if(!i.length){n.push("");continue}let s="";for(const a of i){const c=s?`${s} ${a}`:a;!s||Co(c,r)<=t?s=c:(n.push(s),s=a)}n.push(s)}return n}const Yu=e=>e.stopPropagation();function i1({id:e,rect:r,label:t,labelLayer:n,labelContent:o,style:i,onSelect:s,onCollapse:a,selected:c=!1}){const l=r.x2-r.x1,d=r.y2-r.y1,u=i.borderWidth,h=i.borderStyle==="dashed"?`${u*4} ${u*2}`:i.borderStyle==="dotted"?`${u} ${u}`:void 0,p=r.x1+l/2,m=i.labelPosition==="top"?r.y1+i.labelMargin-i.fontSize/2:i.labelPosition==="bottom"?r.y2-i.labelMargin+i.fontSize/2:r.y1+d/2,g=t?Co(t,`bold ${i.fontSize}px ${mr}`):0,y=i.fontSize/5,b=t||c&&a?f.jsxs("g",{className:"flow-sdk-container-label","data-node-id":e,children:[c&&a&&f.jsx("foreignObject",{x:p+g/2+y+8,y:m-24,width:48,height:48,"data-flow-content-toggle":"","data-flow-collapse-control":"",style:{pointerEvents:"auto"},children:f.jsx(He,{label:"Show icon",children:f.jsx(Ne,{"aria-label":"Show icon",icon:f.jsx(Y.PiCircleFill,{}),variant:"ghost",style:{width:48,height:48,color:i.textColor},onClick:x=>{x.stopPropagation(),a(e)}})})}),o?f.jsx("foreignObject",{x:p-g/2-y,y:m-i.fontSize/2-y,width:g+2*y,height:i.fontSize+2*y,style:{overflow:"visible"},onClick:Yu,children:o}):t&&f.jsxs(f.Fragment,{children:[f.jsx("rect",{x:p-g/2-y,y:m-i.fontSize/2-y,width:g+2*y,height:i.fontSize+2*y,fill:i.textColor==="transparent"?"transparent":i.labelBg}),f.jsx("text",{x:p,y:m,fill:i.textColor,fontSize:i.fontSize,fontWeight:"bold",fontFamily:mr,style:{fontSize:i.fontSize,fontWeight:"bold",fontFamily:mr},textAnchor:"middle",dominantBaseline:"central",children:t})]})]}):null;return f.jsxs("g",{className:"flow-sdk-container","data-node-id":e,onPointerDown:Yu,onClick:x=>{x.stopPropagation(),s==null||s(e,{shiftKey:x.shiftKey,ctrlKey:x.ctrlKey,metaKey:x.metaKey,altKey:x.altKey})},children:[f.jsx("rect",{x:r.x1,y:r.y1,width:l,height:d,rx:i.borderRadius,ry:i.borderRadius,fill:i.bgColor,fillOpacity:i.bgOpacity,stroke:i.borderColor,strokeWidth:i.borderStyle==="double"?u/3:u,strokeDasharray:h}),i.borderStyle==="double"&&f.jsx("rect",{x:r.x1+u*2/3,y:r.y1+u*2/3,width:Math.max(0,l-u*4/3),height:Math.max(0,d-u*4/3),rx:Math.max(0,i.borderRadius-u*2/3),ry:Math.max(0,i.borderRadius-u*2/3),fill:"none",stroke:i.borderColor,strokeWidth:u/3}),i.animated&&u>0&&f.jsx(so,{variant:i.animationVariant,x:r.x1,y:r.y1,width:l,height:d,radius:i.borderRadius,color:i.animationColor||i.borderColor,strokeWidth:Math.max(8,u*1.6)}),n&&b?Jr.createPortal(b,n):b]})}const a1=j.memo(i1),co=45,Hb=70,Ir=15,Kb=50;function Jb(e,r,t=co){const n=`${t}px ${mr}`,o=e?o1(e,n,200*t/co):[],i=r?48+(o.length?12:0):0,s=i+Math.max(0,...o.map(l=>Co(l,n))),a=Math.max(o.length*t,r?48:0),c=o.length||r?2*Ir:0;return{lines:o,iconWidth:i,contentWidth:s,contentHeight:a,width:s+c,height:a+c}}const Mn=6,Zb=3,Dd=.3,s1=8,Wd=Math.max(Math.pow(Mn*13.37,.9),29)*Zb-s1/Dd,Xb=Mn*Zb*2,ro=80,c1=2*ro+Wd*Dd+100,l1=36+2*Math.max(80,Xb+Wd*Dd);function vd(e){return e.sourceProperty!==void 0||e.targetProperty!==void 0}function wd(e,r){return r==="auto"||(r==="properties"?vd(e):!vd(e))}function rr(e,r,t){return t!=="properties"||e!=="root"||r.some(n=>(n.source===e||n.target===e)&&vd(n))}function d1(e,r,t,n=!1,o){if(!n)return{nodes:e,edges:r};const i=e.filter(a=>rr(a.id,r,t)&&(!o||o.has(a.id))),s=new Set(i.map(a=>a.id));return{nodes:i,edges:r.filter(a=>wd(a,t)&&s.has(a.source)&&s.has(a.target))}}const u1=500,f1="32 18",h1=e=>e.stopPropagation();function p1({id:e,reveal:r,onRevealComplete:t,edgeData:n,validationIssue:o,edgeType:i="rounded-orthogonal",edgeRadius:s,customEdgeTypes:a,source:c,target:l,sourceProperty:d,targetProperty:u,sourceY:h,targetY:p,sourcePort:m,targetPort:g,propertyMode:y=!1,dir:b,turn:x,labelAtTarget:v,labelFraction:w,color:C,connectorColor:S,labelBg:R,labelLayer:P,label:k,dashed:T,animated:E,inverted:M,loopIndex:_=0,onSelect:O}){const $=n==null?void 0:n.icon,B=y?co:Hb,{lines:N,iconWidth:I,contentWidth:ee,contentHeight:ae}=j.useMemo(()=>Jb(k,$,B),[k,$,B]),ne=j.useMemo(()=>{const we={srcDist:ro,tgtDist:ro,arrowGap:Xb,arrowSize:Wd,headShape:y&&(M?h!==void 0||m:p!==void 0||g)?"square":"triangle",radius:s??(v?40:u1),arrowAt:M?"source":"target",labelTargetLength:v?ee+2*Ir:void 0,labelFraction:v?w:void 0},he=h!==void 0||p!==void 0||!!m||!!g,ge=Zu(c,l,b,h,p,0),X=h===void 0&&p===void 0&&(b==="downward"||b==="upward"),H=m??{...ge.sourcePoint,side:X?b==="upward"?"top":"bottom":b==="leftward"?"left":"right"},be=g??{...ge.targetPoint,side:X?b==="upward"?"bottom":"top":b==="leftward"?"right":"left"},J=c.x===l.x&&c.y===l.y,xe=m||g?Qw(H,be,{...we,srcDist:18,tgtDist:18},i):he?Ku(c,l,b,h,p,x,{...we,srcDist:18,tgtDist:18,radius:s??Math.min(we.radius,40)}):J?r1(c,_,{...we,srcDist:0,tgtDist:0}):Ju(c,l,b,x,we);if(!xe)return null;const Se=Zu(c,l,b,h,p,he?18:ro);m&&(Se.sourcePoint=Ur(m,18)),g&&(Se.targetPoint=Ur(g,18));const Fe=Object.prototype.hasOwnProperty.call(a??{},i)?a==null?void 0:a[i]:void 0;if(Fe){const De={rightward:"LR",leftward:"RL",downward:"TB",upward:"BT"};return Fe({edge:n??{id:e,source:"",target:""},source:{...c},target:{...l},...Se,direction:De[b],sourceY:h,targetY:p,inverted:!!M,defaultGeometry:xe})??xe}return J||m||g?xe:i==="straight"?he?Gb(Se.sourcePoint,Se.targetPoint,we):Vb([c,l],c,l,we):i==="bezier"?t1(Se.sourcePoint,Se.targetPoint,he?b==="leftward"?"leftward":"rightward":b,we):i==="orthogonal"?he?Ku(c,l,b,h,p,x,{...we,srcDist:18,tgtDist:18,radius:0}):Ju(c,l,b,x,{...we,radius:0}):xe},[c,e,n,i,s,a,l,y,h,p,m,g,b,x,M,_,v,w,ee]);if(!ne)return null;const oe=(b==="rightward"||b==="leftward")&&!Object.prototype.hasOwnProperty.call(a??{},i)&&!(y&&(h!==void 0||p!==void 0||m||g)),pe=oe?`translate(${ne.label.x} ${ne.label.y-ae/2-2*Ir})`:`translate(${ne.label.x} ${ne.label.y}) rotate(${ne.label.angle}) translate(${b==="downward"||b==="upward"||v||Object.prototype.hasOwnProperty.call(a??{},i)?0:Kb} 0)`,q=o!=null&&o.startsWith("Unverified:")?"#b45309":"#dc2626",F=o?q:C,G=o?f.jsxs("g",{className:"flow-sdk-edge-validation",role:"img","aria-label":o,transform:`translate(${ne.label.x} ${ne.label.y-N.length*B/2-55})`,children:[f.jsx("title",{children:o}),f.jsx(or,{name:"PiWarningCircleFill",svg:!0,size:48,x:-24,y:-24,color:q})]}):null,D=E&&(n==null?void 0:n.edgeAnimationVariant)==="traveling",ce=!D&&(T||E)?f1:void 0,Q=E&&!D?`flow-sdk-edge-anim${M?" flow-sdk-edge-anim-rev":""}`:void 0;let K=null;const ie=r?{"--flow-edge-reveal-duration":`${r.durationMs??600}ms`,"--flow-edge-reveal-state":r.paused?"paused":"running"}:void 0;if(N.length||$){const we=ee,he=ae;K=f.jsxs("g",{className:`flow-sdk-edge-label${r?" flow-sdk-edge-reveal-end":""}`,style:ie,"data-label-transform":pe,"data-label-horizontal":oe||void 0,"data-edge-id":e,"data-source-property":d,"data-target-property":u,transform:pe,children:[f.jsx("rect",{x:-we/2-Ir,y:-he/2-Ir,width:we+2*Ir,height:he+2*Ir,fill:C==="transparent"?"transparent":R}),f.jsx("text",{fill:C,fontSize:B,style:{fontSize:B,fontFamily:mr},fontFamily:mr,textAnchor:"middle",dominantBaseline:"central",children:N.map((ge,X)=>f.jsx("tspan",{x:I/2,y:(X-(N.length-1)/2)*B,children:ge},X))}),$&&f.jsxs("g",{className:"flow-sdk-edge-icon",opacity:C==="transparent"?0:1,children:[f.jsx("title",{children:k?`Edge icon: ${k}`:"Edge icon"}),f.jsx("rect",{x:-we/2,y:-24,width:48,height:48,fill:"transparent"}),f.jsx(or,{name:$,svg:!0,size:48,x:-we/2,y:-24,color:C})]})]})}const ye=f.jsxs(f.Fragment,{children:[f.jsx("path",{d:ne.d,fill:"none",stroke:F,strokeWidth:Mn,strokeOpacity:D?.35:void 0,strokeDasharray:ce,className:Q}),D&&f.jsx(Gw,{path:ne.d,color:F,width:Mn*1.6,reversed:M})]});return f.jsxs("g",{className:"flow-sdk-edge",style:ie,"data-edge-id":e,"data-source-property":d,"data-target-property":u,"data-validation":o?o.startsWith("Unverified:")?"unverified":"invalid":void 0,"aria-label":o,onPointerDown:h1,onClick:we=>{we.stopPropagation(),O==null||O(e)},children:[r?f.jsx(Ww,{path:ne.d,width:Mn*4,reversed:M,onComplete:()=>t==null?void 0:t(e),children:ye}):ye,ne.arrow&&f.jsx("path",{className:r?"flow-sdk-edge-reveal-end":void 0,d:ne.arrow,fill:o?q:S??F}),P&&K?Jr.createPortal(K,P):K,P&&G?Jr.createPortal(G,P):G,f.jsx("path",{className:"flow-sdk-edge-hit",d:ne.d,fill:"none",stroke:"transparent"})]})}const Qu=j.memo(p1);var Qn=typeof globalThis<"u"?globalThis:typeof window<"u"?window:typeof global<"u"?global:typeof self<"u"?self:{};function g1(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e}function Vd(e){throw new Error('Could not dynamically require "'+e+'". Please configure the dynamicRequireTargets or/and ignoreDynamicRequires option of @rollup/plugin-commonjs appropriately for this require call to work.')}var Ko,ef;function y1(){if(ef)return Ko;ef=1;function e(){this.__data__=[],this.size=0}return Ko=e,Ko}var Jo,tf;function an(){if(tf)return Jo;tf=1;function e(r,t){return r===t||r!==r&&t!==t}return Jo=e,Jo}var Zo,rf;function So(){if(rf)return Zo;rf=1;var e=an();function r(t,n){for(var o=t.length;o--;)if(e(t[o][0],n))return o;return-1}return Zo=r,Zo}var Xo,nf;function m1(){if(nf)return Xo;nf=1;var e=So(),r=Array.prototype,t=r.splice;function n(o){var i=this.__data__,s=e(i,o);if(s<0)return!1;var a=i.length-1;return s==a?i.pop():t.call(i,s,1),--this.size,!0}return Xo=n,Xo}var Yo,of;function b1(){if(of)return Yo;of=1;var e=So();function r(t){var n=this.__data__,o=e(n,t);return o<0?void 0:n[o][1]}return Yo=r,Yo}var Qo,af;function x1(){if(af)return Qo;af=1;var e=So();function r(t){return e(this.__data__,t)>-1}return Qo=r,Qo}var ei,sf;function v1(){if(sf)return ei;sf=1;var e=So();function r(t,n){var o=this.__data__,i=e(o,t);return i<0?(++this.size,o.push([t,n])):o[i][1]=n,this}return ei=r,ei}var ti,cf;function jo(){if(cf)return ti;cf=1;var e=y1(),r=m1(),t=b1(),n=x1(),o=v1();function i(s){var a=-1,c=s==null?0:s.length;for(this.clear();++a<c;){var l=s[a];this.set(l[0],l[1])}}return i.prototype.clear=e,i.prototype.delete=r,i.prototype.get=t,i.prototype.has=n,i.prototype.set=o,ti=i,ti}var ri,lf;function w1(){if(lf)return ri;lf=1;var e=jo();function r(){this.__data__=new e,this.size=0}return ri=r,ri}var ni,df;function C1(){if(df)return ni;df=1;function e(r){var t=this.__data__,n=t.delete(r);return this.size=t.size,n}return ni=e,ni}var oi,uf;function S1(){if(uf)return oi;uf=1;function e(r){return this.__data__.get(r)}return oi=e,oi}var ii,ff;function j1(){if(ff)return ii;ff=1;function e(r){return this.__data__.has(r)}return ii=e,ii}var ai,hf;function Yb(){if(hf)return ai;hf=1;var e=typeof Qn=="object"&&Qn&&Qn.Object===Object&&Qn;return ai=e,ai}var si,pf;function Jt(){if(pf)return si;pf=1;var e=Yb(),r=typeof self=="object"&&self&&self.Object===Object&&self,t=e||r||Function("return this")();return si=t,si}var ci,gf;function sn(){if(gf)return ci;gf=1;var e=Jt(),r=e.Symbol;return ci=r,ci}var li,yf;function E1(){if(yf)return li;yf=1;var e=sn(),r=Object.prototype,t=r.hasOwnProperty,n=r.toString,o=e?e.toStringTag:void 0;function i(s){var a=t.call(s,o),c=s[o];try{s[o]=void 0;var l=!0}catch{}var d=n.call(s);return l&&(a?s[o]=c:delete s[o]),d}return li=i,li}var di,mf;function _1(){if(mf)return di;mf=1;var e=Object.prototype,r=e.toString;function t(n){return r.call(n)}return di=t,di}var ui,bf;function Fr(){if(bf)return ui;bf=1;var e=sn(),r=E1(),t=_1(),n="[object Null]",o="[object Undefined]",i=e?e.toStringTag:void 0;function s(a){return a==null?a===void 0?o:n:i&&i in Object(a)?r(a):t(a)}return ui=s,ui}var fi,xf;function Bt(){if(xf)return fi;xf=1;function e(r){var t=typeof r;return r!=null&&(t=="object"||t=="function")}return fi=e,fi}var hi,vf;function zn(){if(vf)return hi;vf=1;var e=Fr(),r=Bt(),t="[object AsyncFunction]",n="[object Function]",o="[object GeneratorFunction]",i="[object Proxy]";function s(a){if(!r(a))return!1;var c=e(a);return c==n||c==o||c==t||c==i}return hi=s,hi}var pi,wf;function R1(){if(wf)return pi;wf=1;var e=Jt(),r=e["__core-js_shared__"];return pi=r,pi}var gi,Cf;function k1(){if(Cf)return gi;Cf=1;var e=R1(),r=(function(){var n=/[^.]+$/.exec(e&&e.keys&&e.keys.IE_PROTO||"");return n?"Symbol(src)_1."+n:""})();function t(n){return!!r&&r in n}return gi=t,gi}var yi,Sf;function Qb(){if(Sf)return yi;Sf=1;var e=Function.prototype,r=e.toString;function t(n){if(n!=null){try{return r.call(n)}catch{}try{return n+""}catch{}}return""}return yi=t,yi}var mi,jf;function A1(){if(jf)return mi;jf=1;var e=zn(),r=k1(),t=Bt(),n=Qb(),o=/[\\^$.*+?()[\]{}|]/g,i=/^\[object .+?Constructor\]$/,s=Function.prototype,a=Object.prototype,c=s.toString,l=a.hasOwnProperty,d=RegExp("^"+c.call(l).replace(o,"\\$&").replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g,"$1.*?")+"$");function u(h){if(!t(h)||r(h))return!1;var p=e(h)?d:i;return p.test(n(h))}return mi=u,mi}var bi,Ef;function P1(){if(Ef)return bi;Ef=1;function e(r,t){return r==null?void 0:r[t]}return bi=e,bi}var xi,_f;function zr(){if(_f)return xi;_f=1;var e=A1(),r=P1();function t(n,o){var i=r(n,o);return e(i)?i:void 0}return xi=t,xi}var vi,Rf;function Gd(){if(Rf)return vi;Rf=1;var e=zr(),r=Jt(),t=e(r,"Map");return vi=t,vi}var wi,kf;function Eo(){if(kf)return wi;kf=1;var e=zr(),r=e(Object,"create");return wi=r,wi}var Ci,Af;function M1(){if(Af)return Ci;Af=1;var e=Eo();function r(){this.__data__=e?e(null):{},this.size=0}return Ci=r,Ci}var Si,Pf;function I1(){if(Pf)return Si;Pf=1;function e(r){var t=this.has(r)&&delete this.__data__[r];return this.size-=t?1:0,t}return Si=e,Si}var ji,Mf;function T1(){if(Mf)return ji;Mf=1;var e=Eo(),r="__lodash_hash_undefined__",t=Object.prototype,n=t.hasOwnProperty;function o(i){var s=this.__data__;if(e){var a=s[i];return a===r?void 0:a}return n.call(s,i)?s[i]:void 0}return ji=o,ji}var Ei,If;function N1(){if(If)return Ei;If=1;var e=Eo(),r=Object.prototype,t=r.hasOwnProperty;function n(o){var i=this.__data__;return e?i[o]!==void 0:t.call(i,o)}return Ei=n,Ei}var _i,Tf;function O1(){if(Tf)return _i;Tf=1;var e=Eo(),r="__lodash_hash_undefined__";function t(n,o){var i=this.__data__;return this.size+=this.has(n)?0:1,i[n]=e&&o===void 0?r:o,this}return _i=t,_i}var Ri,Nf;function $1(){if(Nf)return Ri;Nf=1;var e=M1(),r=I1(),t=T1(),n=N1(),o=O1();function i(s){var a=-1,c=s==null?0:s.length;for(this.clear();++a<c;){var l=s[a];this.set(l[0],l[1])}}return i.prototype.clear=e,i.prototype.delete=r,i.prototype.get=t,i.prototype.has=n,i.prototype.set=o,Ri=i,Ri}var ki,Of;function q1(){if(Of)return ki;Of=1;var e=$1(),r=jo(),t=Gd();function n(){this.size=0,this.__data__={hash:new e,map:new(t||r),string:new e}}return ki=n,ki}var Ai,$f;function L1(){if($f)return Ai;$f=1;function e(r){var t=typeof r;return t=="string"||t=="number"||t=="symbol"||t=="boolean"?r!=="__proto__":r===null}return Ai=e,Ai}var Pi,qf;function _o(){if(qf)return Pi;qf=1;var e=L1();function r(t,n){var o=t.__data__;return e(n)?o[typeof n=="string"?"string":"hash"]:o.map}return Pi=r,Pi}var Mi,Lf;function F1(){if(Lf)return Mi;Lf=1;var e=_o();function r(t){var n=e(this,t).delete(t);return this.size-=n?1:0,n}return Mi=r,Mi}var Ii,Ff;function z1(){if(Ff)return Ii;Ff=1;var e=_o();function r(t){return e(this,t).get(t)}return Ii=r,Ii}var Ti,zf;function B1(){if(zf)return Ti;zf=1;var e=_o();function r(t){return e(this,t).has(t)}return Ti=r,Ti}var Ni,Bf;function D1(){if(Bf)return Ni;Bf=1;var e=_o();function r(t,n){var o=e(this,t),i=o.size;return o.set(t,n),this.size+=o.size==i?0:1,this}return Ni=r,Ni}var Oi,Df;function Ud(){if(Df)return Oi;Df=1;var e=q1(),r=F1(),t=z1(),n=B1(),o=D1();function i(s){var a=-1,c=s==null?0:s.length;for(this.clear();++a<c;){var l=s[a];this.set(l[0],l[1])}}return i.prototype.clear=e,i.prototype.delete=r,i.prototype.get=t,i.prototype.has=n,i.prototype.set=o,Oi=i,Oi}var $i,Wf;function W1(){if(Wf)return $i;Wf=1;var e=jo(),r=Gd(),t=Ud(),n=200;function o(i,s){var a=this.__data__;if(a instanceof e){var c=a.__data__;if(!r||c.length<n-1)return c.push([i,s]),this.size=++a.size,this;a=this.__data__=new t(c)}return a.set(i,s),this.size=a.size,this}return $i=o,$i}var qi,Vf;function Ro(){if(Vf)return qi;Vf=1;var e=jo(),r=w1(),t=C1(),n=S1(),o=j1(),i=W1();function s(a){var c=this.__data__=new e(a);this.size=c.size}return s.prototype.clear=r,s.prototype.delete=t,s.prototype.get=n,s.prototype.has=o,s.prototype.set=i,qi=s,qi}var Li,Gf;function Hd(){if(Gf)return Li;Gf=1;function e(r,t){for(var n=-1,o=r==null?0:r.length;++n<o&&t(r[n],n,r)!==!1;);return r}return Li=e,Li}var Fi,Uf;function ex(){if(Uf)return Fi;Uf=1;var e=zr(),r=(function(){try{var t=e(Object,"defineProperty");return t({},"",{}),t}catch{}})();return Fi=r,Fi}var zi,Hf;function ko(){if(Hf)return zi;Hf=1;var e=ex();function r(t,n,o){n=="__proto__"&&e?e(t,n,{configurable:!0,enumerable:!0,value:o,writable:!0}):t[n]=o}return zi=r,zi}var Bi,Kf;function Ao(){if(Kf)return Bi;Kf=1;var e=ko(),r=an(),t=Object.prototype,n=t.hasOwnProperty;function o(i,s,a){var c=i[s];(!(n.call(i,s)&&r(c,a))||a===void 0&&!(s in i))&&e(i,s,a)}return Bi=o,Bi}var Di,Jf;function Bn(){if(Jf)return Di;Jf=1;var e=Ao(),r=ko();function t(n,o,i,s){var a=!i;i||(i={});for(var c=-1,l=o.length;++c<l;){var d=o[c],u=s?s(i[d],n[d],d,i,n):void 0;u===void 0&&(u=n[d]),a?r(i,d,u):e(i,d,u)}return i}return Di=t,Di}var Wi,Zf;function V1(){if(Zf)return Wi;Zf=1;function e(r,t){for(var n=-1,o=Array(r);++n<r;)o[n]=t(n);return o}return Wi=e,Wi}var Vi,Xf;function ir(){if(Xf)return Vi;Xf=1;function e(r){return r!=null&&typeof r=="object"}return Vi=e,Vi}var Gi,Yf;function G1(){if(Yf)return Gi;Yf=1;var e=Fr(),r=ir(),t="[object Arguments]";function n(o){return r(o)&&e(o)==t}return Gi=n,Gi}var Ui,Qf;function Dn(){if(Qf)return Ui;Qf=1;var e=G1(),r=ir(),t=Object.prototype,n=t.hasOwnProperty,o=t.propertyIsEnumerable,i=e((function(){return arguments})())?e:function(s){return r(s)&&n.call(s,"callee")&&!o.call(s,"callee")};return Ui=i,Ui}var Hi,eh;function bt(){if(eh)return Hi;eh=1;var e=Array.isArray;return Hi=e,Hi}var vn={exports:{}},Ki,th;function U1(){if(th)return Ki;th=1;function e(){return!1}return Ki=e,Ki}vn.exports;var rh;function cn(){return rh||(rh=1,(function(e,r){var t=Jt(),n=U1(),o=r&&!r.nodeType&&r,i=o&&!0&&e&&!e.nodeType&&e,s=i&&i.exports===o,a=s?t.Buffer:void 0,c=a?a.isBuffer:void 0,l=c||n;e.exports=l})(vn,vn.exports)),vn.exports}var Ji,nh;function Po(){if(nh)return Ji;nh=1;var e=9007199254740991,r=/^(?:0|[1-9]\d*)$/;function t(n,o){var i=typeof n;return o=o??e,!!o&&(i=="number"||i!="symbol"&&r.test(n))&&n>-1&&n%1==0&&n<o}return Ji=t,Ji}var Zi,oh;function Kd(){if(oh)return Zi;oh=1;var e=9007199254740991;function r(t){return typeof t=="number"&&t>-1&&t%1==0&&t<=e}return Zi=r,Zi}var Xi,ih;function H1(){if(ih)return Xi;ih=1;var e=Fr(),r=Kd(),t=ir(),n="[object Arguments]",o="[object Array]",i="[object Boolean]",s="[object Date]",a="[object Error]",c="[object Function]",l="[object Map]",d="[object Number]",u="[object Object]",h="[object RegExp]",p="[object Set]",m="[object String]",g="[object WeakMap]",y="[object ArrayBuffer]",b="[object DataView]",x="[object Float32Array]",v="[object Float64Array]",w="[object Int8Array]",C="[object Int16Array]",S="[object Int32Array]",R="[object Uint8Array]",P="[object Uint8ClampedArray]",k="[object Uint16Array]",T="[object Uint32Array]",E={};E[x]=E[v]=E[w]=E[C]=E[S]=E[R]=E[P]=E[k]=E[T]=!0,E[n]=E[o]=E[y]=E[i]=E[b]=E[s]=E[a]=E[c]=E[l]=E[d]=E[u]=E[h]=E[p]=E[m]=E[g]=!1;function M(_){return t(_)&&r(_.length)&&!!E[e(_)]}return Xi=M,Xi}var Yi,ah;function Mo(){if(ah)return Yi;ah=1;function e(r){return function(t){return r(t)}}return Yi=e,Yi}var wn={exports:{}};wn.exports;var sh;function Jd(){return sh||(sh=1,(function(e,r){var t=Yb(),n=r&&!r.nodeType&&r,o=n&&!0&&e&&!e.nodeType&&e,i=o&&o.exports===n,s=i&&t.process,a=(function(){try{var c=o&&o.require&&o.require("util").types;return c||s&&s.binding&&s.binding("util")}catch{}})();e.exports=a})(wn,wn.exports)),wn.exports}var Qi,ch;function Wn(){if(ch)return Qi;ch=1;var e=H1(),r=Mo(),t=Jd(),n=t&&t.isTypedArray,o=n?r(n):e;return Qi=o,Qi}var ea,lh;function tx(){if(lh)return ea;lh=1;var e=V1(),r=Dn(),t=bt(),n=cn(),o=Po(),i=Wn(),s=Object.prototype,a=s.hasOwnProperty;function c(l,d){var u=t(l),h=!u&&r(l),p=!u&&!h&&n(l),m=!u&&!h&&!p&&i(l),g=u||h||p||m,y=g?e(l.length,String):[],b=y.length;for(var x in l)(d||a.call(l,x))&&!(g&&(x=="length"||p&&(x=="offset"||x=="parent")||m&&(x=="buffer"||x=="byteLength"||x=="byteOffset")||o(x,b)))&&y.push(x);return y}return ea=c,ea}var ta,dh;function Io(){if(dh)return ta;dh=1;var e=Object.prototype;function r(t){var n=t&&t.constructor,o=typeof n=="function"&&n.prototype||e;return t===o}return ta=r,ta}var ra,uh;function rx(){if(uh)return ra;uh=1;function e(r,t){return function(n){return r(t(n))}}return ra=e,ra}var na,fh;function K1(){if(fh)return na;fh=1;var e=rx(),r=e(Object.keys,Object);return na=r,na}var oa,hh;function Zd(){if(hh)return oa;hh=1;var e=Io(),r=K1(),t=Object.prototype,n=t.hasOwnProperty;function o(i){if(!e(i))return r(i);var s=[];for(var a in Object(i))n.call(i,a)&&a!="constructor"&&s.push(a);return s}return oa=o,oa}var ia,ph;function lr(){if(ph)return ia;ph=1;var e=zn(),r=Kd();function t(n){return n!=null&&r(n.length)&&!e(n)}return ia=t,ia}var aa,gh;function Sr(){if(gh)return aa;gh=1;var e=tx(),r=Zd(),t=lr();function n(o){return t(o)?e(o):r(o)}return aa=n,aa}var sa,yh;function J1(){if(yh)return sa;yh=1;var e=Bn(),r=Sr();function t(n,o){return n&&e(o,r(o),n)}return sa=t,sa}var ca,mh;function Z1(){if(mh)return ca;mh=1;function e(r){var t=[];if(r!=null)for(var n in Object(r))t.push(n);return t}return ca=e,ca}var la,bh;function X1(){if(bh)return la;bh=1;var e=Bt(),r=Io(),t=Z1(),n=Object.prototype,o=n.hasOwnProperty;function i(s){if(!e(s))return t(s);var a=r(s),c=[];for(var l in s)l=="constructor"&&(a||!o.call(s,l))||c.push(l);return c}return la=i,la}var da,xh;function Br(){if(xh)return da;xh=1;var e=tx(),r=X1(),t=lr();function n(o){return t(o)?e(o,!0):r(o)}return da=n,da}var ua,vh;function Y1(){if(vh)return ua;vh=1;var e=Bn(),r=Br();function t(n,o){return n&&e(o,r(o),n)}return ua=t,ua}var Cn={exports:{}};Cn.exports;var wh;function nx(){return wh||(wh=1,(function(e,r){var t=Jt(),n=r&&!r.nodeType&&r,o=n&&!0&&e&&!e.nodeType&&e,i=o&&o.exports===n,s=i?t.Buffer:void 0,a=s?s.allocUnsafe:void 0;function c(l,d){if(d)return l.slice();var u=l.length,h=a?a(u):new l.constructor(u);return l.copy(h),h}e.exports=c})(Cn,Cn.exports)),Cn.exports}var fa,Ch;function ox(){if(Ch)return fa;Ch=1;function e(r,t){var n=-1,o=r.length;for(t||(t=Array(o));++n<o;)t[n]=r[n];return t}return fa=e,fa}var ha,Sh;function ix(){if(Sh)return ha;Sh=1;function e(r,t){for(var n=-1,o=r==null?0:r.length,i=0,s=[];++n<o;){var a=r[n];t(a,n,r)&&(s[i++]=a)}return s}return ha=e,ha}var pa,jh;function ax(){if(jh)return pa;jh=1;function e(){return[]}return pa=e,pa}var ga,Eh;function Xd(){if(Eh)return ga;Eh=1;var e=ix(),r=ax(),t=Object.prototype,n=t.propertyIsEnumerable,o=Object.getOwnPropertySymbols,i=o?function(s){return s==null?[]:(s=Object(s),e(o(s),function(a){return n.call(s,a)}))}:r;return ga=i,ga}var ya,_h;function Q1(){if(_h)return ya;_h=1;var e=Bn(),r=Xd();function t(n,o){return e(n,r(n),o)}return ya=t,ya}var ma,Rh;function Yd(){if(Rh)return ma;Rh=1;function e(r,t){for(var n=-1,o=t.length,i=r.length;++n<o;)r[i+n]=t[n];return r}return ma=e,ma}var ba,kh;function To(){if(kh)return ba;kh=1;var e=rx(),r=e(Object.getPrototypeOf,Object);return ba=r,ba}var xa,Ah;function sx(){if(Ah)return xa;Ah=1;var e=Yd(),r=To(),t=Xd(),n=ax(),o=Object.getOwnPropertySymbols,i=o?function(s){for(var a=[];s;)e(a,t(s)),s=r(s);return a}:n;return xa=i,xa}var va,Ph;function eC(){if(Ph)return va;Ph=1;var e=Bn(),r=sx();function t(n,o){return e(n,r(n),o)}return va=t,va}var wa,Mh;function cx(){if(Mh)return wa;Mh=1;var e=Yd(),r=bt();function t(n,o,i){var s=o(n);return r(n)?s:e(s,i(n))}return wa=t,wa}var Ca,Ih;function lx(){if(Ih)return Ca;Ih=1;var e=cx(),r=Xd(),t=Sr();function n(o){return e(o,t,r)}return Ca=n,Ca}var Sa,Th;function tC(){if(Th)return Sa;Th=1;var e=cx(),r=sx(),t=Br();function n(o){return e(o,t,r)}return Sa=n,Sa}var ja,Nh;function rC(){if(Nh)return ja;Nh=1;var e=zr(),r=Jt(),t=e(r,"DataView");return ja=t,ja}var Ea,Oh;function nC(){if(Oh)return Ea;Oh=1;var e=zr(),r=Jt(),t=e(r,"Promise");return Ea=t,Ea}var _a,$h;function dx(){if($h)return _a;$h=1;var e=zr(),r=Jt(),t=e(r,"Set");return _a=t,_a}var Ra,qh;function oC(){if(qh)return Ra;qh=1;var e=zr(),r=Jt(),t=e(r,"WeakMap");return Ra=t,Ra}var ka,Lh;function ln(){if(Lh)return ka;Lh=1;var e=rC(),r=Gd(),t=nC(),n=dx(),o=oC(),i=Fr(),s=Qb(),a="[object Map]",c="[object Object]",l="[object Promise]",d="[object Set]",u="[object WeakMap]",h="[object DataView]",p=s(e),m=s(r),g=s(t),y=s(n),b=s(o),x=i;return(e&&x(new e(new ArrayBuffer(1)))!=h||r&&x(new r)!=a||t&&x(t.resolve())!=l||n&&x(new n)!=d||o&&x(new o)!=u)&&(x=function(v){var w=i(v),C=w==c?v.constructor:void 0,S=C?s(C):"";if(S)switch(S){case p:return h;case m:return a;case g:return l;case y:return d;case b:return u}return w}),ka=x,ka}var Aa,Fh;function iC(){if(Fh)return Aa;Fh=1;var e=Object.prototype,r=e.hasOwnProperty;function t(n){var o=n.length,i=new n.constructor(o);return o&&typeof n[0]=="string"&&r.call(n,"index")&&(i.index=n.index,i.input=n.input),i}return Aa=t,Aa}var Pa,zh;function ux(){if(zh)return Pa;zh=1;var e=Jt(),r=e.Uint8Array;return Pa=r,Pa}var Ma,Bh;function Qd(){if(Bh)return Ma;Bh=1;var e=ux();function r(t){var n=new t.constructor(t.byteLength);return new e(n).set(new e(t)),n}return Ma=r,Ma}var Ia,Dh;function aC(){if(Dh)return Ia;Dh=1;var e=Qd();function r(t,n){var o=n?e(t.buffer):t.buffer;return new t.constructor(o,t.byteOffset,t.byteLength)}return Ia=r,Ia}var Ta,Wh;function sC(){if(Wh)return Ta;Wh=1;var e=/\w*$/;function r(t){var n=new t.constructor(t.source,e.exec(t));return n.lastIndex=t.lastIndex,n}return Ta=r,Ta}var Na,Vh;function cC(){if(Vh)return Na;Vh=1;var e=sn(),r=e?e.prototype:void 0,t=r?r.valueOf:void 0;function n(o){return t?Object(t.call(o)):{}}return Na=n,Na}var Oa,Gh;function fx(){if(Gh)return Oa;Gh=1;var e=Qd();function r(t,n){var o=n?e(t.buffer):t.buffer;return new t.constructor(o,t.byteOffset,t.length)}return Oa=r,Oa}var $a,Uh;function lC(){if(Uh)return $a;Uh=1;var e=Qd(),r=aC(),t=sC(),n=cC(),o=fx(),i="[object Boolean]",s="[object Date]",a="[object Map]",c="[object Number]",l="[object RegExp]",d="[object Set]",u="[object String]",h="[object Symbol]",p="[object ArrayBuffer]",m="[object DataView]",g="[object Float32Array]",y="[object Float64Array]",b="[object Int8Array]",x="[object Int16Array]",v="[object Int32Array]",w="[object Uint8Array]",C="[object Uint8ClampedArray]",S="[object Uint16Array]",R="[object Uint32Array]";function P(k,T,E){var M=k.constructor;switch(T){case p:return e(k);case i:case s:return new M(+k);case m:return r(k,E);case g:case y:case b:case x:case v:case w:case C:case S:case R:return o(k,E);case a:return new M;case c:case u:return new M(k);case l:return t(k);case d:return new M;case h:return n(k)}}return $a=P,$a}var qa,Hh;function hx(){if(Hh)return qa;Hh=1;var e=Bt(),r=Object.create,t=(function(){function n(){}return function(o){if(!e(o))return{};if(r)return r(o);n.prototype=o;var i=new n;return n.prototype=void 0,i}})();return qa=t,qa}var La,Kh;function px(){if(Kh)return La;Kh=1;var e=hx(),r=To(),t=Io();function n(o){return typeof o.constructor=="function"&&!t(o)?e(r(o)):{}}return La=n,La}var Fa,Jh;function dC(){if(Jh)return Fa;Jh=1;var e=ln(),r=ir(),t="[object Map]";function n(o){return r(o)&&e(o)==t}return Fa=n,Fa}var za,Zh;function uC(){if(Zh)return za;Zh=1;var e=dC(),r=Mo(),t=Jd(),n=t&&t.isMap,o=n?r(n):e;return za=o,za}var Ba,Xh;function fC(){if(Xh)return Ba;Xh=1;var e=ln(),r=ir(),t="[object Set]";function n(o){return r(o)&&e(o)==t}return Ba=n,Ba}var Da,Yh;function hC(){if(Yh)return Da;Yh=1;var e=fC(),r=Mo(),t=Jd(),n=t&&t.isSet,o=n?r(n):e;return Da=o,Da}var Wa,Qh;function gx(){if(Qh)return Wa;Qh=1;var e=Ro(),r=Hd(),t=Ao(),n=J1(),o=Y1(),i=nx(),s=ox(),a=Q1(),c=eC(),l=lx(),d=tC(),u=ln(),h=iC(),p=lC(),m=px(),g=bt(),y=cn(),b=uC(),x=Bt(),v=hC(),w=Sr(),C=Br(),S=1,R=2,P=4,k="[object Arguments]",T="[object Array]",E="[object Boolean]",M="[object Date]",_="[object Error]",O="[object Function]",$="[object GeneratorFunction]",B="[object Map]",N="[object Number]",I="[object Object]",ee="[object RegExp]",ae="[object Set]",ne="[object String]",oe="[object Symbol]",pe="[object WeakMap]",q="[object ArrayBuffer]",F="[object DataView]",G="[object Float32Array]",D="[object Float64Array]",ce="[object Int8Array]",Q="[object Int16Array]",K="[object Int32Array]",ie="[object Uint8Array]",ye="[object Uint8ClampedArray]",we="[object Uint16Array]",he="[object Uint32Array]",ge={};ge[k]=ge[T]=ge[q]=ge[F]=ge[E]=ge[M]=ge[G]=ge[D]=ge[ce]=ge[Q]=ge[K]=ge[B]=ge[N]=ge[I]=ge[ee]=ge[ae]=ge[ne]=ge[oe]=ge[ie]=ge[ye]=ge[we]=ge[he]=!0,ge[_]=ge[O]=ge[pe]=!1;function X(H,be,J,xe,Se,Fe){var De,ue=be&S,Re=be&R,ze=be&P;if(J&&(De=Se?J(H,xe,Se,Fe):J(H)),De!==void 0)return De;if(!x(H))return H;var Te=g(H);if(Te){if(De=h(H),!ue)return s(H,De)}else{var qe=u(H),Qe=qe==O||qe==$;if(y(H))return i(H,ue);if(qe==I||qe==k||Qe&&!Se){if(De=Re||Qe?{}:m(H),!ue)return Re?c(H,o(De,H)):a(H,n(De,H))}else{if(!ge[qe])return Se?H:{};De=p(H,qe,ue)}}Fe||(Fe=new e);var ct=Fe.get(H);if(ct)return ct;Fe.set(H,De),v(H)?H.forEach(function(Ye){De.add(X(Ye,be,J,Ye,H,Fe))}):b(H)&&H.forEach(function(Ye,nt){De.set(nt,X(Ye,be,J,nt,H,Fe))});var Pe=ze?Re?d:l:Re?C:w,Je=Te?void 0:Pe(H);return r(Je||H,function(Ye,nt){Je&&(nt=Ye,Ye=H[nt]),t(De,nt,X(Ye,be,J,nt,H,Fe))}),De}return Wa=X,Wa}var Va,ep;function pC(){if(ep)return Va;ep=1;var e=gx(),r=4;function t(n){return e(n,r)}return Va=t,Va}var Ga,tp;function eu(){if(tp)return Ga;tp=1;function e(r){return function(){return r}}return Ga=e,Ga}var Ua,rp;function gC(){if(rp)return Ua;rp=1;function e(r){return function(t,n,o){for(var i=-1,s=Object(t),a=o(t),c=a.length;c--;){var l=a[r?c:++i];if(n(s[l],l,s)===!1)break}return t}}return Ua=e,Ua}var Ha,np;function tu(){if(np)return Ha;np=1;var e=gC(),r=e();return Ha=r,Ha}var Ka,op;function ru(){if(op)return Ka;op=1;var e=tu(),r=Sr();function t(n,o){return n&&e(n,o,r)}return Ka=t,Ka}var Ja,ip;function yC(){if(ip)return Ja;ip=1;var e=lr();function r(t,n){return function(o,i){if(o==null)return o;if(!e(o))return t(o,i);for(var s=o.length,a=n?s:-1,c=Object(o);(n?a--:++a<s)&&i(c[a],a,c)!==!1;);return o}}return Ja=r,Ja}var Za,ap;function No(){if(ap)return Za;ap=1;var e=ru(),r=yC(),t=r(e);return Za=t,Za}var Xa,sp;function Dr(){if(sp)return Xa;sp=1;function e(r){return r}return Xa=e,Xa}var Ya,cp;function yx(){if(cp)return Ya;cp=1;var e=Dr();function r(t){return typeof t=="function"?t:e}return Ya=r,Ya}var Qa,lp;function mx(){if(lp)return Qa;lp=1;var e=Hd(),r=No(),t=yx(),n=bt();function o(i,s){var a=n(i)?e:r;return a(i,t(s))}return Qa=o,Qa}var es,dp;function bx(){return dp||(dp=1,es=mx()),es}var ts,up;function mC(){if(up)return ts;up=1;var e=No();function r(t,n){var o=[];return e(t,function(i,s,a){n(i,s,a)&&o.push(i)}),o}return ts=r,ts}var rs,fp;function bC(){if(fp)return rs;fp=1;var e="__lodash_hash_undefined__";function r(t){return this.__data__.set(t,e),this}return rs=r,rs}var ns,hp;function xC(){if(hp)return ns;hp=1;function e(r){return this.__data__.has(r)}return ns=e,ns}var os,pp;function xx(){if(pp)return os;pp=1;var e=Ud(),r=bC(),t=xC();function n(o){var i=-1,s=o==null?0:o.length;for(this.__data__=new e;++i<s;)this.add(o[i])}return n.prototype.add=n.prototype.push=r,n.prototype.has=t,os=n,os}var is,gp;function vC(){if(gp)return is;gp=1;function e(r,t){for(var n=-1,o=r==null?0:r.length;++n<o;)if(t(r[n],n,r))return!0;return!1}return is=e,is}var as,yp;function vx(){if(yp)return as;yp=1;function e(r,t){return r.has(t)}return as=e,as}var ss,mp;function wx(){if(mp)return ss;mp=1;var e=xx(),r=vC(),t=vx(),n=1,o=2;function i(s,a,c,l,d,u){var h=c&n,p=s.length,m=a.length;if(p!=m&&!(h&&m>p))return!1;var g=u.get(s),y=u.get(a);if(g&&y)return g==a&&y==s;var b=-1,x=!0,v=c&o?new e:void 0;for(u.set(s,a),u.set(a,s);++b<p;){var w=s[b],C=a[b];if(l)var S=h?l(C,w,b,a,s,u):l(w,C,b,s,a,u);if(S!==void 0){if(S)continue;x=!1;break}if(v){if(!r(a,function(R,P){if(!t(v,P)&&(w===R||d(w,R,c,l,u)))return v.push(P)})){x=!1;break}}else if(!(w===C||d(w,C,c,l,u))){x=!1;break}}return u.delete(s),u.delete(a),x}return ss=i,ss}var cs,bp;function wC(){if(bp)return cs;bp=1;function e(r){var t=-1,n=Array(r.size);return r.forEach(function(o,i){n[++t]=[i,o]}),n}return cs=e,cs}var ls,xp;function nu(){if(xp)return ls;xp=1;function e(r){var t=-1,n=Array(r.size);return r.forEach(function(o){n[++t]=o}),n}return ls=e,ls}var ds,vp;function CC(){if(vp)return ds;vp=1;var e=sn(),r=ux(),t=an(),n=wx(),o=wC(),i=nu(),s=1,a=2,c="[object Boolean]",l="[object Date]",d="[object Error]",u="[object Map]",h="[object Number]",p="[object RegExp]",m="[object Set]",g="[object String]",y="[object Symbol]",b="[object ArrayBuffer]",x="[object DataView]",v=e?e.prototype:void 0,w=v?v.valueOf:void 0;function C(S,R,P,k,T,E,M){switch(P){case x:if(S.byteLength!=R.byteLength||S.byteOffset!=R.byteOffset)return!1;S=S.buffer,R=R.buffer;case b:return!(S.byteLength!=R.byteLength||!E(new r(S),new r(R)));case c:case l:case h:return t(+S,+R);case d:return S.name==R.name&&S.message==R.message;case p:case g:return S==R+"";case u:var _=o;case m:var O=k&s;if(_||(_=i),S.size!=R.size&&!O)return!1;var $=M.get(S);if($)return $==R;k|=a,M.set(S,R);var B=n(_(S),_(R),k,T,E,M);return M.delete(S),B;case y:if(w)return w.call(S)==w.call(R)}return!1}return ds=C,ds}var us,wp;function SC(){if(wp)return us;wp=1;var e=lx(),r=1,t=Object.prototype,n=t.hasOwnProperty;function o(i,s,a,c,l,d){var u=a&r,h=e(i),p=h.length,m=e(s),g=m.length;if(p!=g&&!u)return!1;for(var y=p;y--;){var b=h[y];if(!(u?b in s:n.call(s,b)))return!1}var x=d.get(i),v=d.get(s);if(x&&v)return x==s&&v==i;var w=!0;d.set(i,s),d.set(s,i);for(var C=u;++y<p;){b=h[y];var S=i[b],R=s[b];if(c)var P=u?c(R,S,b,s,i,d):c(S,R,b,i,s,d);if(!(P===void 0?S===R||l(S,R,a,c,d):P)){w=!1;break}C||(C=b=="constructor")}if(w&&!C){var k=i.constructor,T=s.constructor;k!=T&&"constructor"in i&&"constructor"in s&&!(typeof k=="function"&&k instanceof k&&typeof T=="function"&&T instanceof T)&&(w=!1)}return d.delete(i),d.delete(s),w}return us=o,us}var fs,Cp;function jC(){if(Cp)return fs;Cp=1;var e=Ro(),r=wx(),t=CC(),n=SC(),o=ln(),i=bt(),s=cn(),a=Wn(),c=1,l="[object Arguments]",d="[object Array]",u="[object Object]",h=Object.prototype,p=h.hasOwnProperty;function m(g,y,b,x,v,w){var C=i(g),S=i(y),R=C?d:o(g),P=S?d:o(y);R=R==l?u:R,P=P==l?u:P;var k=R==u,T=P==u,E=R==P;if(E&&s(g)){if(!s(y))return!1;C=!0,k=!1}if(E&&!k)return w||(w=new e),C||a(g)?r(g,y,b,x,v,w):t(g,y,R,b,x,v,w);if(!(b&c)){var M=k&&p.call(g,"__wrapped__"),_=T&&p.call(y,"__wrapped__");if(M||_){var O=M?g.value():g,$=_?y.value():y;return w||(w=new e),v(O,$,b,x,w)}}return E?(w||(w=new e),n(g,y,b,x,v,w)):!1}return fs=m,fs}var hs,Sp;function Cx(){if(Sp)return hs;Sp=1;var e=jC(),r=ir();function t(n,o,i,s,a){return n===o?!0:n==null||o==null||!r(n)&&!r(o)?n!==n&&o!==o:e(n,o,i,s,t,a)}return hs=t,hs}var ps,jp;function EC(){if(jp)return ps;jp=1;var e=Ro(),r=Cx(),t=1,n=2;function o(i,s,a,c){var l=a.length,d=l,u=!c;if(i==null)return!d;for(i=Object(i);l--;){var h=a[l];if(u&&h[2]?h[1]!==i[h[0]]:!(h[0]in i))return!1}for(;++l<d;){h=a[l];var p=h[0],m=i[p],g=h[1];if(u&&h[2]){if(m===void 0&&!(p in i))return!1}else{var y=new e;if(c)var b=c(m,g,p,i,s,y);if(!(b===void 0?r(g,m,t|n,c,y):b))return!1}}return!0}return ps=o,ps}var gs,Ep;function Sx(){if(Ep)return gs;Ep=1;var e=Bt();function r(t){return t===t&&!e(t)}return gs=r,gs}var ys,_p;function _C(){if(_p)return ys;_p=1;var e=Sx(),r=Sr();function t(n){for(var o=r(n),i=o.length;i--;){var s=o[i],a=n[s];o[i]=[s,a,e(a)]}return o}return ys=t,ys}var ms,Rp;function jx(){if(Rp)return ms;Rp=1;function e(r,t){return function(n){return n==null?!1:n[r]===t&&(t!==void 0||r in Object(n))}}return ms=e,ms}var bs,kp;function RC(){if(kp)return bs;kp=1;var e=EC(),r=_C(),t=jx();function n(o){var i=r(o);return i.length==1&&i[0][2]?t(i[0][0],i[0][1]):function(s){return s===o||e(s,o,i)}}return bs=n,bs}var xs,Ap;function dn(){if(Ap)return xs;Ap=1;var e=Fr(),r=ir(),t="[object Symbol]";function n(o){return typeof o=="symbol"||r(o)&&e(o)==t}return xs=n,xs}var vs,Pp;function ou(){if(Pp)return vs;Pp=1;var e=bt(),r=dn(),t=/\.|\[(?:[^[\]]*|(["'])(?:(?!\1)[^\\]|\\.)*?\1)\]/,n=/^\w*$/;function o(i,s){if(e(i))return!1;var a=typeof i;return a=="number"||a=="symbol"||a=="boolean"||i==null||r(i)?!0:n.test(i)||!t.test(i)||s!=null&&i in Object(s)}return vs=o,vs}var ws,Mp;function kC(){if(Mp)return ws;Mp=1;var e=Ud(),r="Expected a function";function t(n,o){if(typeof n!="function"||o!=null&&typeof o!="function")throw new TypeError(r);var i=function(){var s=arguments,a=o?o.apply(this,s):s[0],c=i.cache;if(c.has(a))return c.get(a);var l=n.apply(this,s);return i.cache=c.set(a,l)||c,l};return i.cache=new(t.Cache||e),i}return t.Cache=e,ws=t,ws}var Cs,Ip;function AC(){if(Ip)return Cs;Ip=1;var e=kC(),r=500;function t(n){var o=e(n,function(s){return i.size===r&&i.clear(),s}),i=o.cache;return o}return Cs=t,Cs}var Ss,Tp;function PC(){if(Tp)return Ss;Tp=1;var e=AC(),r=/[^.[\]]+|\[(?:(-?\d+(?:\.\d+)?)|(["'])((?:(?!\2)[^\\]|\\.)*?)\2)\]|(?=(?:\.|\[\])(?:\.|\[\]|$))/g,t=/\\(\\)?/g,n=e(function(o){var i=[];return o.charCodeAt(0)===46&&i.push(""),o.replace(r,function(s,a,c,l){i.push(c?l.replace(t,"$1"):a||s)}),i});return Ss=n,Ss}var js,Np;function Oo(){if(Np)return js;Np=1;function e(r,t){for(var n=-1,o=r==null?0:r.length,i=Array(o);++n<o;)i[n]=t(r[n],n,r);return i}return js=e,js}var Es,Op;function MC(){if(Op)return Es;Op=1;var e=sn(),r=Oo(),t=bt(),n=dn(),o=e?e.prototype:void 0,i=o?o.toString:void 0;function s(a){if(typeof a=="string")return a;if(t(a))return r(a,s)+"";if(n(a))return i?i.call(a):"";var c=a+"";return c=="0"&&1/a==-1/0?"-0":c}return Es=s,Es}var _s,$p;function Ex(){if($p)return _s;$p=1;var e=MC();function r(t){return t==null?"":e(t)}return _s=r,_s}var Rs,qp;function $o(){if(qp)return Rs;qp=1;var e=bt(),r=ou(),t=PC(),n=Ex();function o(i,s){return e(i)?i:r(i,s)?[i]:t(n(i))}return Rs=o,Rs}var ks,Lp;function Vn(){if(Lp)return ks;Lp=1;var e=dn();function r(t){if(typeof t=="string"||e(t))return t;var n=t+"";return n=="0"&&1/t==-1/0?"-0":n}return ks=r,ks}var As,Fp;function qo(){if(Fp)return As;Fp=1;var e=$o(),r=Vn();function t(n,o){o=e(o,n);for(var i=0,s=o.length;n!=null&&i<s;)n=n[r(o[i++])];return i&&i==s?n:void 0}return As=t,As}var Ps,zp;function IC(){if(zp)return Ps;zp=1;var e=qo();function r(t,n,o){var i=t==null?void 0:e(t,n);return i===void 0?o:i}return Ps=r,Ps}var Ms,Bp;function TC(){if(Bp)return Ms;Bp=1;function e(r,t){return r!=null&&t in Object(r)}return Ms=e,Ms}var Is,Dp;function _x(){if(Dp)return Is;Dp=1;var e=$o(),r=Dn(),t=bt(),n=Po(),o=Kd(),i=Vn();function s(a,c,l){c=e(c,a);for(var d=-1,u=c.length,h=!1;++d<u;){var p=i(c[d]);if(!(h=a!=null&&l(a,p)))break;a=a[p]}return h||++d!=u?h:(u=a==null?0:a.length,!!u&&o(u)&&n(p,u)&&(t(a)||r(a)))}return Is=s,Is}var Ts,Wp;function Rx(){if(Wp)return Ts;Wp=1;var e=TC(),r=_x();function t(n,o){return n!=null&&r(n,o,e)}return Ts=t,Ts}var Ns,Vp;function NC(){if(Vp)return Ns;Vp=1;var e=Cx(),r=IC(),t=Rx(),n=ou(),o=Sx(),i=jx(),s=Vn(),a=1,c=2;function l(d,u){return n(d)&&o(u)?i(s(d),u):function(h){var p=r(h,d);return p===void 0&&p===u?t(h,d):e(u,p,a|c)}}return Ns=l,Ns}var Os,Gp;function kx(){if(Gp)return Os;Gp=1;function e(r){return function(t){return t==null?void 0:t[r]}}return Os=e,Os}var $s,Up;function OC(){if(Up)return $s;Up=1;var e=qo();function r(t){return function(n){return e(n,t)}}return $s=r,$s}var qs,Hp;function $C(){if(Hp)return qs;Hp=1;var e=kx(),r=OC(),t=ou(),n=Vn();function o(i){return t(i)?e(n(i)):r(i)}return qs=o,qs}var Ls,Kp;function dr(){if(Kp)return Ls;Kp=1;var e=RC(),r=NC(),t=Dr(),n=bt(),o=$C();function i(s){return typeof s=="function"?s:s==null?t:typeof s=="object"?n(s)?r(s[0],s[1]):e(s):o(s)}return Ls=i,Ls}var Fs,Jp;function Ax(){if(Jp)return Fs;Jp=1;var e=ix(),r=mC(),t=dr(),n=bt();function o(i,s){var a=n(i)?e:r;return a(i,t(s,3))}return Fs=o,Fs}var zs,Zp;function qC(){if(Zp)return zs;Zp=1;var e=Object.prototype,r=e.hasOwnProperty;function t(n,o){return n!=null&&r.call(n,o)}return zs=t,zs}var Bs,Xp;function Px(){if(Xp)return Bs;Xp=1;var e=qC(),r=_x();function t(n,o){return n!=null&&r(n,o,e)}return Bs=t,Bs}var Ds,Yp;function LC(){if(Yp)return Ds;Yp=1;var e=Zd(),r=ln(),t=Dn(),n=bt(),o=lr(),i=cn(),s=Io(),a=Wn(),c="[object Map]",l="[object Set]",d=Object.prototype,u=d.hasOwnProperty;function h(p){if(p==null)return!0;if(o(p)&&(n(p)||typeof p=="string"||typeof p.splice=="function"||i(p)||a(p)||t(p)))return!p.length;var m=r(p);if(m==c||m==l)return!p.size;if(s(p))return!e(p).length;for(var g in p)if(u.call(p,g))return!1;return!0}return Ds=h,Ds}var Ws,Qp;function Mx(){if(Qp)return Ws;Qp=1;function e(r){return r===void 0}return Ws=e,Ws}var Vs,eg;function Ix(){if(eg)return Vs;eg=1;var e=No(),r=lr();function t(n,o){var i=-1,s=r(n)?Array(n.length):[];return e(n,function(a,c,l){s[++i]=o(a,c,l)}),s}return Vs=t,Vs}var Gs,tg;function Tx(){if(tg)return Gs;tg=1;var e=Oo(),r=dr(),t=Ix(),n=bt();function o(i,s){var a=n(i)?e:t;return a(i,r(s,3))}return Gs=o,Gs}var Us,rg;function FC(){if(rg)return Us;rg=1;function e(r,t,n,o){var i=-1,s=r==null?0:r.length;for(o&&s&&(n=r[++i]);++i<s;)n=t(n,r[i],i,r);return n}return Us=e,Us}var Hs,ng;function zC(){if(ng)return Hs;ng=1;function e(r,t,n,o,i){return i(r,function(s,a,c){n=o?(o=!1,s):t(n,s,a,c)}),n}return Hs=e,Hs}var Ks,og;function Nx(){if(og)return Ks;og=1;var e=FC(),r=No(),t=dr(),n=zC(),o=bt();function i(s,a,c){var l=o(s)?e:n,d=arguments.length<3;return l(s,t(a,4),c,d,r)}return Ks=i,Ks}var Js,ig;function BC(){if(ig)return Js;ig=1;var e=Fr(),r=bt(),t=ir(),n="[object String]";function o(i){return typeof i=="string"||!r(i)&&t(i)&&e(i)==n}return Js=o,Js}var Zs,ag;function DC(){if(ag)return Zs;ag=1;var e=kx(),r=e("length");return Zs=r,Zs}var Xs,sg;function WC(){if(sg)return Xs;sg=1;var e="\\ud800-\\udfff",r="\\u0300-\\u036f",t="\\ufe20-\\ufe2f",n="\\u20d0-\\u20ff",o=r+t+n,i="\\ufe0e\\ufe0f",s="\\u200d",a=RegExp("["+s+e+o+i+"]");function c(l){return a.test(l)}return Xs=c,Xs}var Ys,cg;function VC(){if(cg)return Ys;cg=1;var e="\\ud800-\\udfff",r="\\u0300-\\u036f",t="\\ufe20-\\ufe2f",n="\\u20d0-\\u20ff",o=r+t+n,i="\\ufe0e\\ufe0f",s="["+e+"]",a="["+o+"]",c="\\ud83c[\\udffb-\\udfff]",l="(?:"+a+"|"+c+")",d="[^"+e+"]",u="(?:\\ud83c[\\udde6-\\uddff]){2}",h="[\\ud800-\\udbff][\\udc00-\\udfff]",p="\\u200d",m=l+"?",g="["+i+"]?",y="(?:"+p+"(?:"+[d,u,h].join("|")+")"+g+m+")*",b=g+m+y,x="(?:"+[d+a+"?",a,u,h,s].join("|")+")",v=RegExp(c+"(?="+c+")|"+x+b,"g");function w(C){for(var S=v.lastIndex=0;v.test(C);)++S;return S}return Ys=w,Ys}var Qs,lg;function GC(){if(lg)return Qs;lg=1;var e=DC(),r=WC(),t=VC();function n(o){return r(o)?t(o):e(o)}return Qs=n,Qs}var ec,dg;function UC(){if(dg)return ec;dg=1;var e=Zd(),r=ln(),t=lr(),n=BC(),o=GC(),i="[object Map]",s="[object Set]";function a(c){if(c==null)return 0;if(t(c))return n(c)?o(c):c.length;var l=r(c);return l==i||l==s?c.size:e(c).length}return ec=a,ec}var tc,ug;function HC(){if(ug)return tc;ug=1;var e=Hd(),r=hx(),t=ru(),n=dr(),o=To(),i=bt(),s=cn(),a=zn(),c=Bt(),l=Wn();function d(u,h,p){var m=i(u),g=m||s(u)||l(u);if(h=n(h,4),p==null){var y=u&&u.constructor;g?p=m?new y:[]:c(u)?p=a(y)?r(o(u)):{}:p={}}return(g?e:t)(u,function(b,x,v){return h(p,b,x,v)}),p}return tc=d,tc}var rc,fg;function KC(){if(fg)return rc;fg=1;var e=sn(),r=Dn(),t=bt(),n=e?e.isConcatSpreadable:void 0;function o(i){return t(i)||r(i)||!!(n&&i&&i[n])}return rc=o,rc}var nc,hg;function iu(){if(hg)return nc;hg=1;var e=Yd(),r=KC();function t(n,o,i,s,a){var c=-1,l=n.length;for(i||(i=r),a||(a=[]);++c<l;){var d=n[c];o>0&&i(d)?o>1?t(d,o-1,i,s,a):e(a,d):s||(a[a.length]=d)}return a}return nc=t,nc}var oc,pg;function JC(){if(pg)return oc;pg=1;function e(r,t,n){switch(n.length){case 0:return r.call(t);case 1:return r.call(t,n[0]);case 2:return r.call(t,n[0],n[1]);case 3:return r.call(t,n[0],n[1],n[2])}return r.apply(t,n)}return oc=e,oc}var ic,gg;function Ox(){if(gg)return ic;gg=1;var e=JC(),r=Math.max;function t(n,o,i){return o=r(o===void 0?n.length-1:o,0),function(){for(var s=arguments,a=-1,c=r(s.length-o,0),l=Array(c);++a<c;)l[a]=s[o+a];a=-1;for(var d=Array(o+1);++a<o;)d[a]=s[a];return d[o]=i(l),e(n,this,d)}}return ic=t,ic}var ac,yg;function ZC(){if(yg)return ac;yg=1;var e=eu(),r=ex(),t=Dr(),n=r?function(o,i){return r(o,"toString",{configurable:!0,enumerable:!1,value:e(i),writable:!0})}:t;return ac=n,ac}var sc,mg;function XC(){if(mg)return sc;mg=1;var e=800,r=16,t=Date.now;function n(o){var i=0,s=0;return function(){var a=t(),c=r-(a-s);if(s=a,c>0){if(++i>=e)return arguments[0]}else i=0;return o.apply(void 0,arguments)}}return sc=n,sc}var cc,bg;function $x(){if(bg)return cc;bg=1;var e=ZC(),r=XC(),t=r(e);return cc=t,cc}var lc,xg;function Lo(){if(xg)return lc;xg=1;var e=Dr(),r=Ox(),t=$x();function n(o,i){return t(r(o,i,e),o+"")}return lc=n,lc}var dc,vg;function qx(){if(vg)return dc;vg=1;function e(r,t,n,o){for(var i=r.length,s=n+(o?1:-1);o?s--:++s<i;)if(t(r[s],s,r))return s;return-1}return dc=e,dc}var uc,wg;function YC(){if(wg)return uc;wg=1;function e(r){return r!==r}return uc=e,uc}var fc,Cg;function QC(){if(Cg)return fc;Cg=1;function e(r,t,n){for(var o=n-1,i=r.length;++o<i;)if(r[o]===t)return o;return-1}return fc=e,fc}var hc,Sg;function eS(){if(Sg)return hc;Sg=1;var e=qx(),r=YC(),t=QC();function n(o,i,s){return i===i?t(o,i,s):e(o,r,s)}return hc=n,hc}var pc,jg;function tS(){if(jg)return pc;jg=1;var e=eS();function r(t,n){var o=t==null?0:t.length;return!!o&&e(t,n,0)>-1}return pc=r,pc}var gc,Eg;function rS(){if(Eg)return gc;Eg=1;function e(r,t,n){for(var o=-1,i=r==null?0:r.length;++o<i;)if(n(t,r[o]))return!0;return!1}return gc=e,gc}var yc,_g;function nS(){if(_g)return yc;_g=1;function e(){}return yc=e,yc}var mc,Rg;function oS(){if(Rg)return mc;Rg=1;var e=dx(),r=nS(),t=nu(),n=1/0,o=e&&1/t(new e([,-0]))[1]==n?function(i){return new e(i)}:r;return mc=o,mc}var bc,kg;function iS(){if(kg)return bc;kg=1;var e=xx(),r=tS(),t=rS(),n=vx(),o=oS(),i=nu(),s=200;function a(c,l,d){var u=-1,h=r,p=c.length,m=!0,g=[],y=g;if(d)m=!1,h=t;else if(p>=s){var b=l?null:o(c);if(b)return i(b);m=!1,h=n,y=new e}else y=l?[]:g;e:for(;++u<p;){var x=c[u],v=l?l(x):x;if(x=d||x!==0?x:0,m&&v===v){for(var w=y.length;w--;)if(y[w]===v)continue e;l&&y.push(v),g.push(x)}else h(y,v,d)||(y!==g&&y.push(v),g.push(x))}return g}return bc=a,bc}var xc,Ag;function Lx(){if(Ag)return xc;Ag=1;var e=lr(),r=ir();function t(n){return r(n)&&e(n)}return xc=t,xc}var vc,Pg;function aS(){if(Pg)return vc;Pg=1;var e=iu(),r=Lo(),t=iS(),n=Lx(),o=r(function(i){return t(e(i,1,n,!0))});return vc=o,vc}var wc,Mg;function sS(){if(Mg)return wc;Mg=1;var e=Oo();function r(t,n){return e(n,function(o){return t[o]})}return wc=r,wc}var Cc,Ig;function Fx(){if(Ig)return Cc;Ig=1;var e=sS(),r=Sr();function t(n){return n==null?[]:e(n,r(n))}return Cc=t,Cc}var Sc,Tg;function Dt(){if(Tg)return Sc;Tg=1;var e;if(typeof Vd=="function")try{e={clone:pC(),constant:eu(),each:bx(),filter:Ax(),has:Px(),isArray:bt(),isEmpty:LC(),isFunction:zn(),isUndefined:Mx(),keys:Sr(),map:Tx(),reduce:Nx(),size:UC(),transform:HC(),union:aS(),values:Fx()}}catch{}return e||(e=window._),Sc=e,Sc}var jc,Ng;function au(){if(Ng)return jc;Ng=1;var e=Dt();jc=o;var r="\0",t="\0",n="";function o(d){this._isDirected=e.has(d,"directed")?d.directed:!0,this._isMultigraph=e.has(d,"multigraph")?d.multigraph:!1,this._isCompound=e.has(d,"compound")?d.compound:!1,this._label=void 0,this._defaultNodeLabelFn=e.constant(void 0),this._defaultEdgeLabelFn=e.constant(void 0),this._nodes={},this._isCompound&&(this._parent={},this._children={},this._children[t]={}),this._in={},this._preds={},this._out={},this._sucs={},this._edgeObjs={},this._edgeLabels={}}o.prototype._nodeCount=0,o.prototype._edgeCount=0,o.prototype.isDirected=function(){return this._isDirected},o.prototype.isMultigraph=function(){return this._isMultigraph},o.prototype.isCompound=function(){return this._isCompound},o.prototype.setGraph=function(d){return this._label=d,this},o.prototype.graph=function(){return this._label},o.prototype.setDefaultNodeLabel=function(d){return e.isFunction(d)||(d=e.constant(d)),this._defaultNodeLabelFn=d,this},o.prototype.nodeCount=function(){return this._nodeCount},o.prototype.nodes=function(){return e.keys(this._nodes)},o.prototype.sources=function(){var d=this;return e.filter(this.nodes(),function(u){return e.isEmpty(d._in[u])})},o.prototype.sinks=function(){var d=this;return e.filter(this.nodes(),function(u){return e.isEmpty(d._out[u])})},o.prototype.setNodes=function(d,u){var h=arguments,p=this;return e.each(d,function(m){h.length>1?p.setNode(m,u):p.setNode(m)}),this},o.prototype.setNode=function(d,u){return e.has(this._nodes,d)?(arguments.length>1&&(this._nodes[d]=u),this):(this._nodes[d]=arguments.length>1?u:this._defaultNodeLabelFn(d),this._isCompound&&(this._parent[d]=t,this._children[d]={},this._children[t][d]=!0),this._in[d]={},this._preds[d]={},this._out[d]={},this._sucs[d]={},++this._nodeCount,this)},o.prototype.node=function(d){return this._nodes[d]},o.prototype.hasNode=function(d){return e.has(this._nodes,d)},o.prototype.removeNode=function(d){var u=this;if(e.has(this._nodes,d)){var h=function(p){u.removeEdge(u._edgeObjs[p])};delete this._nodes[d],this._isCompound&&(this._removeFromParentsChildList(d),delete this._parent[d],e.each(this.children(d),function(p){u.setParent(p)}),delete this._children[d]),e.each(e.keys(this._in[d]),h),delete this._in[d],delete this._preds[d],e.each(e.keys(this._out[d]),h),delete this._out[d],delete this._sucs[d],--this._nodeCount}return this},o.prototype.setParent=function(d,u){if(!this._isCompound)throw new Error("Cannot set parent in a non-compound graph");if(e.isUndefined(u))u=t;else{u+="";for(var h=u;!e.isUndefined(h);h=this.parent(h))if(h===d)throw new Error("Setting "+u+" as parent of "+d+" would create a cycle");this.setNode(u)}return this.setNode(d),this._removeFromParentsChildList(d),this._parent[d]=u,this._children[u][d]=!0,this},o.prototype._removeFromParentsChildList=function(d){delete this._children[this._parent[d]][d]},o.prototype.parent=function(d){if(this._isCompound){var u=this._parent[d];if(u!==t)return u}},o.prototype.children=function(d){if(e.isUndefined(d)&&(d=t),this._isCompound){var u=this._children[d];if(u)return e.keys(u)}else{if(d===t)return this.nodes();if(this.hasNode(d))return[]}},o.prototype.predecessors=function(d){var u=this._preds[d];if(u)return e.keys(u)},o.prototype.successors=function(d){var u=this._sucs[d];if(u)return e.keys(u)},o.prototype.neighbors=function(d){var u=this.predecessors(d);if(u)return e.union(u,this.successors(d))},o.prototype.isLeaf=function(d){var u;return this.isDirected()?u=this.successors(d):u=this.neighbors(d),u.length===0},o.prototype.filterNodes=function(d){var u=new this.constructor({directed:this._isDirected,multigraph:this._isMultigraph,compound:this._isCompound});u.setGraph(this.graph());var h=this;e.each(this._nodes,function(g,y){d(y)&&u.setNode(y,g)}),e.each(this._edgeObjs,function(g){u.hasNode(g.v)&&u.hasNode(g.w)&&u.setEdge(g,h.edge(g))});var p={};function m(g){var y=h.parent(g);return y===void 0||u.hasNode(y)?(p[g]=y,y):y in p?p[y]:m(y)}return this._isCompound&&e.each(u.nodes(),function(g){u.setParent(g,m(g))}),u},o.prototype.setDefaultEdgeLabel=function(d){return e.isFunction(d)||(d=e.constant(d)),this._defaultEdgeLabelFn=d,this},o.prototype.edgeCount=function(){return this._edgeCount},o.prototype.edges=function(){return e.values(this._edgeObjs)},o.prototype.setPath=function(d,u){var h=this,p=arguments;return e.reduce(d,function(m,g){return p.length>1?h.setEdge(m,g,u):h.setEdge(m,g),g}),this},o.prototype.setEdge=function(){var d,u,h,p,m=!1,g=arguments[0];typeof g=="object"&&g!==null&&"v"in g?(d=g.v,u=g.w,h=g.name,arguments.length===2&&(p=arguments[1],m=!0)):(d=g,u=arguments[1],h=arguments[3],arguments.length>2&&(p=arguments[2],m=!0)),d=""+d,u=""+u,e.isUndefined(h)||(h=""+h);var y=a(this._isDirected,d,u,h);if(e.has(this._edgeLabels,y))return m&&(this._edgeLabels[y]=p),this;if(!e.isUndefined(h)&&!this._isMultigraph)throw new Error("Cannot set a named edge when isMultigraph = false");this.setNode(d),this.setNode(u),this._edgeLabels[y]=m?p:this._defaultEdgeLabelFn(d,u,h);var b=c(this._isDirected,d,u,h);return d=b.v,u=b.w,Object.freeze(b),this._edgeObjs[y]=b,i(this._preds[u],d),i(this._sucs[d],u),this._in[u][y]=b,this._out[d][y]=b,this._edgeCount++,this},o.prototype.edge=function(d,u,h){var p=arguments.length===1?l(this._isDirected,arguments[0]):a(this._isDirected,d,u,h);return this._edgeLabels[p]},o.prototype.hasEdge=function(d,u,h){var p=arguments.length===1?l(this._isDirected,arguments[0]):a(this._isDirected,d,u,h);return e.has(this._edgeLabels,p)},o.prototype.removeEdge=function(d,u,h){var p=arguments.length===1?l(this._isDirected,arguments[0]):a(this._isDirected,d,u,h),m=this._edgeObjs[p];return m&&(d=m.v,u=m.w,delete this._edgeLabels[p],delete this._edgeObjs[p],s(this._preds[u],d),s(this._sucs[d],u),delete this._in[u][p],delete this._out[d][p],this._edgeCount--),this},o.prototype.inEdges=function(d,u){var h=this._in[d];if(h){var p=e.values(h);return u?e.filter(p,function(m){return m.v===u}):p}},o.prototype.outEdges=function(d,u){var h=this._out[d];if(h){var p=e.values(h);return u?e.filter(p,function(m){return m.w===u}):p}},o.prototype.nodeEdges=function(d,u){var h=this.inEdges(d,u);if(h)return h.concat(this.outEdges(d,u))};function i(d,u){d[u]?d[u]++:d[u]=1}function s(d,u){--d[u]||delete d[u]}function a(d,u,h,p){var m=""+u,g=""+h;if(!d&&m>g){var y=m;m=g,g=y}return m+n+g+n+(e.isUndefined(p)?r:p)}function c(d,u,h,p){var m=""+u,g=""+h;if(!d&&m>g){var y=m;m=g,g=y}var b={v:m,w:g};return p&&(b.name=p),b}function l(d,u){return a(d,u.v,u.w,u.name)}return jc}var Ec,Og;function cS(){return Og||(Og=1,Ec="2.1.8"),Ec}var _c,$g;function lS(){return $g||($g=1,_c={Graph:au(),version:cS()}),_c}var Rc,qg;function dS(){if(qg)return Rc;qg=1;var e=Dt(),r=au();Rc={write:t,read:i};function t(s){var a={options:{directed:s.isDirected(),multigraph:s.isMultigraph(),compound:s.isCompound()},nodes:n(s),edges:o(s)};return e.isUndefined(s.graph())||(a.value=e.clone(s.graph())),a}function n(s){return e.map(s.nodes(),function(a){var c=s.node(a),l=s.parent(a),d={v:a};return e.isUndefined(c)||(d.value=c),e.isUndefined(l)||(d.parent=l),d})}function o(s){return e.map(s.edges(),function(a){var c=s.edge(a),l={v:a.v,w:a.w};return e.isUndefined(a.name)||(l.name=a.name),e.isUndefined(c)||(l.value=c),l})}function i(s){var a=new r(s.options).setGraph(s.value);return e.each(s.nodes,function(c){a.setNode(c.v,c.value),c.parent&&a.setParent(c.v,c.parent)}),e.each(s.edges,function(c){a.setEdge({v:c.v,w:c.w,name:c.name},c.value)}),a}return Rc}var kc,Lg;function uS(){if(Lg)return kc;Lg=1;var e=Dt();kc=r;function r(t){var n={},o=[],i;function s(a){e.has(n,a)||(n[a]=!0,i.push(a),e.each(t.successors(a),s),e.each(t.predecessors(a),s))}return e.each(t.nodes(),function(a){i=[],s(a),i.length&&o.push(i)}),o}return kc}var Ac,Fg;function zx(){if(Fg)return Ac;Fg=1;var e=Dt();Ac=r;function r(){this._arr=[],this._keyIndices={}}return r.prototype.size=function(){return this._arr.length},r.prototype.keys=function(){return this._arr.map(function(t){return t.key})},r.prototype.has=function(t){return e.has(this._keyIndices,t)},r.prototype.priority=function(t){var n=this._keyIndices[t];if(n!==void 0)return this._arr[n].priority},r.prototype.min=function(){if(this.size()===0)throw new Error("Queue underflow");return this._arr[0].key},r.prototype.add=function(t,n){var o=this._keyIndices;if(t=String(t),!e.has(o,t)){var i=this._arr,s=i.length;return o[t]=s,i.push({key:t,priority:n}),this._decrease(s),!0}return!1},r.prototype.removeMin=function(){this._swap(0,this._arr.length-1);var t=this._arr.pop();return delete this._keyIndices[t.key],this._heapify(0),t.key},r.prototype.decrease=function(t,n){var o=this._keyIndices[t];if(n>this._arr[o].priority)throw new Error("New priority is greater than current priority. Key: "+t+" Old: "+this._arr[o].priority+" New: "+n);this._arr[o].priority=n,this._decrease(o)},r.prototype._heapify=function(t){var n=this._arr,o=2*t,i=o+1,s=t;o<n.length&&(s=n[o].priority<n[s].priority?o:s,i<n.length&&(s=n[i].priority<n[s].priority?i:s),s!==t&&(this._swap(t,s),this._heapify(s)))},r.prototype._decrease=function(t){for(var n=this._arr,o=n[t].priority,i;t!==0&&(i=t>>1,!(n[i].priority<o));)this._swap(t,i),t=i},r.prototype._swap=function(t,n){var o=this._arr,i=this._keyIndices,s=o[t],a=o[n];o[t]=a,o[n]=s,i[a.key]=t,i[s.key]=n},Ac}var Pc,zg;function Bx(){if(zg)return Pc;zg=1;var e=Dt(),r=zx();Pc=n;var t=e.constant(1);function n(i,s,a,c){return o(i,String(s),a||t,c||function(l){return i.outEdges(l)})}function o(i,s,a,c){var l={},d=new r,u,h,p=function(m){var g=m.v!==u?m.v:m.w,y=l[g],b=a(m),x=h.distance+b;if(b<0)throw new Error("dijkstra does not allow negative edge weights. Bad edge: "+m+" Weight: "+b);x<y.distance&&(y.distance=x,y.predecessor=u,d.decrease(g,x))};for(i.nodes().forEach(function(m){var g=m===s?0:Number.POSITIVE_INFINITY;l[m]={distance:g},d.add(m,g)});d.size()>0&&(u=d.removeMin(),h=l[u],h.distance!==Number.POSITIVE_INFINITY);)c(u).forEach(p);return l}return Pc}var Mc,Bg;function fS(){if(Bg)return Mc;Bg=1;var e=Bx(),r=Dt();Mc=t;function t(n,o,i){return r.transform(n.nodes(),function(s,a){s[a]=e(n,a,o,i)},{})}return Mc}var Ic,Dg;function Dx(){if(Dg)return Ic;Dg=1;var e=Dt();Ic=r;function r(t){var n=0,o=[],i={},s=[];function a(c){var l=i[c]={onStack:!0,lowlink:n,index:n++};if(o.push(c),t.successors(c).forEach(function(h){e.has(i,h)?i[h].onStack&&(l.lowlink=Math.min(l.lowlink,i[h].index)):(a(h),l.lowlink=Math.min(l.lowlink,i[h].lowlink))}),l.lowlink===l.index){var d=[],u;do u=o.pop(),i[u].onStack=!1,d.push(u);while(c!==u);s.push(d)}}return t.nodes().forEach(function(c){e.has(i,c)||a(c)}),s}return Ic}var Tc,Wg;function hS(){if(Wg)return Tc;Wg=1;var e=Dt(),r=Dx();Tc=t;function t(n){return e.filter(r(n),function(o){return o.length>1||o.length===1&&n.hasEdge(o[0],o[0])})}return Tc}var Nc,Vg;function pS(){if(Vg)return Nc;Vg=1;var e=Dt();Nc=t;var r=e.constant(1);function t(o,i,s){return n(o,i||r,s||function(a){return o.outEdges(a)})}function n(o,i,s){var a={},c=o.nodes();return c.forEach(function(l){a[l]={},a[l][l]={distance:0},c.forEach(function(d){l!==d&&(a[l][d]={distance:Number.POSITIVE_INFINITY})}),s(l).forEach(function(d){var u=d.v===l?d.w:d.v,h=i(d);a[l][u]={distance:h,predecessor:l}})}),c.forEach(function(l){var d=a[l];c.forEach(function(u){var h=a[u];c.forEach(function(p){var m=h[l],g=d[p],y=h[p],b=m.distance+g.distance;b<y.distance&&(y.distance=b,y.predecessor=g.predecessor)})})}),a}return Nc}var Oc,Gg;function Wx(){if(Gg)return Oc;Gg=1;var e=Dt();Oc=r,r.CycleException=t;function r(n){var o={},i={},s=[];function a(c){if(e.has(i,c))throw new t;e.has(o,c)||(i[c]=!0,o[c]=!0,e.each(n.predecessors(c),a),delete i[c],s.push(c))}if(e.each(n.sinks(),a),e.size(o)!==n.nodeCount())throw new t;return s}function t(){}return t.prototype=new Error,Oc}var $c,Ug;function gS(){if(Ug)return $c;Ug=1;var e=Wx();$c=r;function r(t){try{e(t)}catch(n){if(n instanceof e.CycleException)return!1;throw n}return!0}return $c}var qc,Hg;function Vx(){if(Hg)return qc;Hg=1;var e=Dt();qc=r;function r(n,o,i){e.isArray(o)||(o=[o]);var s=(n.isDirected()?n.successors:n.neighbors).bind(n),a=[],c={};return e.each(o,function(l){if(!n.hasNode(l))throw new Error("Graph does not have node: "+l);t(n,l,i==="post",c,s,a)}),a}function t(n,o,i,s,a,c){e.has(s,o)||(s[o]=!0,i||c.push(o),e.each(a(o),function(l){t(n,l,i,s,a,c)}),i&&c.push(o))}return qc}var Lc,Kg;function yS(){if(Kg)return Lc;Kg=1;var e=Vx();Lc=r;function r(t,n){return e(t,n,"post")}return Lc}var Fc,Jg;function mS(){if(Jg)return Fc;Jg=1;var e=Vx();Fc=r;function r(t,n){return e(t,n,"pre")}return Fc}var zc,Zg;function bS(){if(Zg)return zc;Zg=1;var e=Dt(),r=au(),t=zx();zc=n;function n(o,i){var s=new r,a={},c=new t,l;function d(h){var p=h.v===l?h.w:h.v,m=c.priority(p);if(m!==void 0){var g=i(h);g<m&&(a[p]=l,c.decrease(p,g))}}if(o.nodeCount()===0)return s;e.each(o.nodes(),function(h){c.add(h,Number.POSITIVE_INFINITY),s.setNode(h)}),c.decrease(o.nodes()[0],0);for(var u=!1;c.size()>0;){if(l=c.removeMin(),e.has(a,l))s.setEdge(l,a[l]);else{if(u)throw new Error("Input graph is not connected: "+o);u=!0}o.nodeEdges(l).forEach(d)}return s}return zc}var Bc,Xg;function xS(){return Xg||(Xg=1,Bc={components:uS(),dijkstra:Bx(),dijkstraAll:fS(),findCycles:hS(),floydWarshall:pS(),isAcyclic:gS(),postorder:yS(),preorder:mS(),prim:bS(),tarjan:Dx(),topsort:Wx()}),Bc}var Dc,Yg;function vS(){if(Yg)return Dc;Yg=1;var e=lS();return Dc={Graph:e.Graph,json:dS(),alg:xS(),version:e.version},Dc}var Wc,Qg;function Ht(){if(Qg)return Wc;Qg=1;var e;if(typeof Vd=="function")try{e=vS()}catch{}return e||(e=window.graphlib),Wc=e,Wc}var Vc,ey;function wS(){if(ey)return Vc;ey=1;var e=gx(),r=1,t=4;function n(o){return e(o,r|t)}return Vc=n,Vc}var Gc,ty;function Fo(){if(ty)return Gc;ty=1;var e=an(),r=lr(),t=Po(),n=Bt();function o(i,s,a){if(!n(a))return!1;var c=typeof s;return(c=="number"?r(a)&&t(s,a.length):c=="string"&&s in a)?e(a[s],i):!1}return Gc=o,Gc}var Uc,ry;function CS(){if(ry)return Uc;ry=1;var e=Lo(),r=an(),t=Fo(),n=Br(),o=Object.prototype,i=o.hasOwnProperty,s=e(function(a,c){a=Object(a);var l=-1,d=c.length,u=d>2?c[2]:void 0;for(u&&t(c[0],c[1],u)&&(d=1);++l<d;)for(var h=c[l],p=n(h),m=-1,g=p.length;++m<g;){var y=p[m],b=a[y];(b===void 0||r(b,o[y])&&!i.call(a,y))&&(a[y]=h[y])}return a});return Uc=s,Uc}var Hc,ny;function SS(){if(ny)return Hc;ny=1;var e=dr(),r=lr(),t=Sr();function n(o){return function(i,s,a){var c=Object(i);if(!r(i)){var l=e(s,3);i=t(i),s=function(u){return l(c[u],u,c)}}var d=o(i,s,a);return d>-1?c[l?i[d]:d]:void 0}}return Hc=n,Hc}var Kc,oy;function jS(){if(oy)return Kc;oy=1;var e=/\s/;function r(t){for(var n=t.length;n--&&e.test(t.charAt(n)););return n}return Kc=r,Kc}var Jc,iy;function ES(){if(iy)return Jc;iy=1;var e=jS(),r=/^\s+/;function t(n){return n&&n.slice(0,e(n)+1).replace(r,"")}return Jc=t,Jc}var Zc,ay;function _S(){if(ay)return Zc;ay=1;var e=ES(),r=Bt(),t=dn(),n=NaN,o=/^[-+]0x[0-9a-f]+$/i,i=/^0b[01]+$/i,s=/^0o[0-7]+$/i,a=parseInt;function c(l){if(typeof l=="number")return l;if(t(l))return n;if(r(l)){var d=typeof l.valueOf=="function"?l.valueOf():l;l=r(d)?d+"":d}if(typeof l!="string")return l===0?l:+l;l=e(l);var u=i.test(l);return u||s.test(l)?a(l.slice(2),u?2:8):o.test(l)?n:+l}return Zc=c,Zc}var Xc,sy;function Gx(){if(sy)return Xc;sy=1;var e=_S(),r=1/0,t=17976931348623157e292;function n(o){if(!o)return o===0?o:0;if(o=e(o),o===r||o===-r){var i=o<0?-1:1;return i*t}return o===o?o:0}return Xc=n,Xc}var Yc,cy;function RS(){if(cy)return Yc;cy=1;var e=Gx();function r(t){var n=e(t),o=n%1;return n===n?o?n-o:n:0}return Yc=r,Yc}var Qc,ly;function kS(){if(ly)return Qc;ly=1;var e=qx(),r=dr(),t=RS(),n=Math.max;function o(i,s,a){var c=i==null?0:i.length;if(!c)return-1;var l=a==null?0:t(a);return l<0&&(l=n(c+l,0)),e(i,r(s,3),l)}return Qc=o,Qc}var el,dy;function AS(){if(dy)return el;dy=1;var e=SS(),r=kS(),t=e(r);return el=t,el}var tl,uy;function Ux(){if(uy)return tl;uy=1;var e=iu();function r(t){var n=t==null?0:t.length;return n?e(t,1):[]}return tl=r,tl}var rl,fy;function PS(){if(fy)return rl;fy=1;var e=tu(),r=yx(),t=Br();function n(o,i){return o==null?o:e(o,r(i),t)}return rl=n,rl}var nl,hy;function MS(){if(hy)return nl;hy=1;function e(r){var t=r==null?0:r.length;return t?r[t-1]:void 0}return nl=e,nl}var ol,py;function IS(){if(py)return ol;py=1;var e=ko(),r=ru(),t=dr();function n(o,i){var s={};return i=t(i,3),r(o,function(a,c,l){e(s,c,i(a,c,l))}),s}return ol=n,ol}var il,gy;function su(){if(gy)return il;gy=1;var e=dn();function r(t,n,o){for(var i=-1,s=t.length;++i<s;){var a=t[i],c=n(a);if(c!=null&&(l===void 0?c===c&&!e(c):o(c,l)))var l=c,d=a}return d}return il=r,il}var al,yy;function TS(){if(yy)return al;yy=1;function e(r,t){return r>t}return al=e,al}var sl,my;function NS(){if(my)return sl;my=1;var e=su(),r=TS(),t=Dr();function n(o){return o&&o.length?e(o,t,r):void 0}return sl=n,sl}var cl,by;function Hx(){if(by)return cl;by=1;var e=ko(),r=an();function t(n,o,i){(i!==void 0&&!r(n[o],i)||i===void 0&&!(o in n))&&e(n,o,i)}return cl=t,cl}var ll,xy;function OS(){if(xy)return ll;xy=1;var e=Fr(),r=To(),t=ir(),n="[object Object]",o=Function.prototype,i=Object.prototype,s=o.toString,a=i.hasOwnProperty,c=s.call(Object);function l(d){if(!t(d)||e(d)!=n)return!1;var u=r(d);if(u===null)return!0;var h=a.call(u,"constructor")&&u.constructor;return typeof h=="function"&&h instanceof h&&s.call(h)==c}return ll=l,ll}var dl,vy;function Kx(){if(vy)return dl;vy=1;function e(r,t){if(!(t==="constructor"&&typeof r[t]=="function")&&t!="__proto__")return r[t]}return dl=e,dl}var ul,wy;function $S(){if(wy)return ul;wy=1;var e=Bn(),r=Br();function t(n){return e(n,r(n))}return ul=t,ul}var fl,Cy;function qS(){if(Cy)return fl;Cy=1;var e=Hx(),r=nx(),t=fx(),n=ox(),o=px(),i=Dn(),s=bt(),a=Lx(),c=cn(),l=zn(),d=Bt(),u=OS(),h=Wn(),p=Kx(),m=$S();function g(y,b,x,v,w,C,S){var R=p(y,x),P=p(b,x),k=S.get(P);if(k){e(y,x,k);return}var T=C?C(R,P,x+"",y,b,S):void 0,E=T===void 0;if(E){var M=s(P),_=!M&&c(P),O=!M&&!_&&h(P);T=P,M||_||O?s(R)?T=R:a(R)?T=n(R):_?(E=!1,T=r(P,!0)):O?(E=!1,T=t(P,!0)):T=[]:u(P)||i(P)?(T=R,i(R)?T=m(R):(!d(R)||l(R))&&(T=o(P))):E=!1}E&&(S.set(P,T),w(T,P,v,C,S),S.delete(P)),e(y,x,T)}return fl=g,fl}var hl,Sy;function LS(){if(Sy)return hl;Sy=1;var e=Ro(),r=Hx(),t=tu(),n=qS(),o=Bt(),i=Br(),s=Kx();function a(c,l,d,u,h){c!==l&&t(l,function(p,m){if(h||(h=new e),o(p))n(c,l,m,d,a,u,h);else{var g=u?u(s(c,m),p,m+"",c,l,h):void 0;g===void 0&&(g=p),r(c,m,g)}},i)}return hl=a,hl}var pl,jy;function FS(){if(jy)return pl;jy=1;var e=Lo(),r=Fo();function t(n){return e(function(o,i){var s=-1,a=i.length,c=a>1?i[a-1]:void 0,l=a>2?i[2]:void 0;for(c=n.length>3&&typeof c=="function"?(a--,c):void 0,l&&r(i[0],i[1],l)&&(c=a<3?void 0:c,a=1),o=Object(o);++s<a;){var d=i[s];d&&n(o,d,s,c)}return o})}return pl=t,pl}var gl,Ey;function zS(){if(Ey)return gl;Ey=1;var e=LS(),r=FS(),t=r(function(n,o,i){e(n,o,i)});return gl=t,gl}var yl,_y;function Jx(){if(_y)return yl;_y=1;function e(r,t){return r<t}return yl=e,yl}var ml,Ry;function BS(){if(Ry)return ml;Ry=1;var e=su(),r=Jx(),t=Dr();function n(o){return o&&o.length?e(o,t,r):void 0}return ml=n,ml}var bl,ky;function DS(){if(ky)return bl;ky=1;var e=su(),r=dr(),t=Jx();function n(o,i){return o&&o.length?e(o,r(i,2),t):void 0}return bl=n,bl}var xl,Ay;function WS(){if(Ay)return xl;Ay=1;var e=Jt(),r=function(){return e.Date.now()};return xl=r,xl}var vl,Py;function VS(){if(Py)return vl;Py=1;var e=Ao(),r=$o(),t=Po(),n=Bt(),o=Vn();function i(s,a,c,l){if(!n(s))return s;a=r(a,s);for(var d=-1,u=a.length,h=u-1,p=s;p!=null&&++d<u;){var m=o(a[d]),g=c;if(m==="__proto__"||m==="constructor"||m==="prototype")return s;if(d!=h){var y=p[m];g=l?l(y,m,p):void 0,g===void 0&&(g=n(y)?y:t(a[d+1])?[]:{})}e(p,m,g),p=p[m]}return s}return vl=i,vl}var wl,My;function GS(){if(My)return wl;My=1;var e=qo(),r=VS(),t=$o();function n(o,i,s){for(var a=-1,c=i.length,l={};++a<c;){var d=i[a],u=e(o,d);s(u,d)&&r(l,t(d,o),u)}return l}return wl=n,wl}var Cl,Iy;function US(){if(Iy)return Cl;Iy=1;var e=GS(),r=Rx();function t(n,o){return e(n,o,function(i,s){return r(n,s)})}return Cl=t,Cl}var Sl,Ty;function HS(){if(Ty)return Sl;Ty=1;var e=Ux(),r=Ox(),t=$x();function n(o){return t(r(o,void 0,e),o+"")}return Sl=n,Sl}var jl,Ny;function KS(){if(Ny)return jl;Ny=1;var e=US(),r=HS(),t=r(function(n,o){return n==null?{}:e(n,o)});return jl=t,jl}var El,Oy;function JS(){if(Oy)return El;Oy=1;var e=Math.ceil,r=Math.max;function t(n,o,i,s){for(var a=-1,c=r(e((o-n)/(i||1)),0),l=Array(c);c--;)l[s?c:++a]=n,n+=i;return l}return El=t,El}var _l,$y;function ZS(){if($y)return _l;$y=1;var e=JS(),r=Fo(),t=Gx();function n(o){return function(i,s,a){return a&&typeof a!="number"&&r(i,s,a)&&(s=a=void 0),i=t(i),s===void 0?(s=i,i=0):s=t(s),a=a===void 0?i<s?1:-1:t(a),e(i,s,a,o)}}return _l=n,_l}var Rl,qy;function XS(){if(qy)return Rl;qy=1;var e=ZS(),r=e();return Rl=r,Rl}var kl,Ly;function YS(){if(Ly)return kl;Ly=1;function e(r,t){var n=r.length;for(r.sort(t);n--;)r[n]=r[n].value;return r}return kl=e,kl}var Al,Fy;function QS(){if(Fy)return Al;Fy=1;var e=dn();function r(t,n){if(t!==n){var o=t!==void 0,i=t===null,s=t===t,a=e(t),c=n!==void 0,l=n===null,d=n===n,u=e(n);if(!l&&!u&&!a&&t>n||a&&c&&d&&!l&&!u||i&&c&&d||!o&&d||!s)return 1;if(!i&&!a&&!u&&t<n||u&&o&&s&&!i&&!a||l&&o&&s||!c&&s||!d)return-1}return 0}return Al=r,Al}var Pl,zy;function ej(){if(zy)return Pl;zy=1;var e=QS();function r(t,n,o){for(var i=-1,s=t.criteria,a=n.criteria,c=s.length,l=o.length;++i<c;){var d=e(s[i],a[i]);if(d){if(i>=l)return d;var u=o[i];return d*(u=="desc"?-1:1)}}return t.index-n.index}return Pl=r,Pl}var Ml,By;function tj(){if(By)return Ml;By=1;var e=Oo(),r=qo(),t=dr(),n=Ix(),o=YS(),i=Mo(),s=ej(),a=Dr(),c=bt();function l(d,u,h){u.length?u=e(u,function(g){return c(g)?function(y){return r(y,g.length===1?g[0]:g)}:g}):u=[a];var p=-1;u=e(u,i(t));var m=n(d,function(g,y,b){var x=e(u,function(v){return v(g)});return{criteria:x,index:++p,value:g}});return o(m,function(g,y){return s(g,y,h)})}return Ml=l,Ml}var Il,Dy;function rj(){if(Dy)return Il;Dy=1;var e=iu(),r=tj(),t=Lo(),n=Fo(),o=t(function(i,s){if(i==null)return[];var a=s.length;return a>1&&n(i,s[0],s[1])?s=[]:a>2&&n(s[0],s[1],s[2])&&(s=[s[0]]),r(i,e(s,1),[])});return Il=o,Il}var Tl,Wy;function nj(){if(Wy)return Tl;Wy=1;var e=Ex(),r=0;function t(n){var o=++r;return e(n)+o}return Tl=t,Tl}var Nl,Vy;function oj(){if(Vy)return Nl;Vy=1;function e(r,t,n){for(var o=-1,i=r.length,s=t.length,a={};++o<i;){var c=o<s?t[o]:void 0;n(a,r[o],c)}return a}return Nl=e,Nl}var Ol,Gy;function ij(){if(Gy)return Ol;Gy=1;var e=Ao(),r=oj();function t(n,o){return r(n||[],o||[],e)}return Ol=t,Ol}var $l,Uy;function pt(){if(Uy)return $l;Uy=1;var e;if(typeof Vd=="function")try{e={cloneDeep:wS(),constant:eu(),defaults:CS(),each:bx(),filter:Ax(),find:AS(),flatten:Ux(),forEach:mx(),forIn:PS(),has:Px(),isUndefined:Mx(),last:MS(),map:Tx(),mapValues:IS(),max:NS(),merge:zS(),min:BS(),minBy:DS(),now:WS(),pick:KS(),range:XS(),reduce:Nx(),sortBy:rj(),uniqueId:nj(),values:Fx(),zipObject:ij()}}catch{}return e||(e=window._),$l=e,$l}var ql,Hy;function aj(){if(Hy)return ql;Hy=1,ql=e;function e(){var n={};n._next=n._prev=n,this._sentinel=n}e.prototype.dequeue=function(){var n=this._sentinel,o=n._prev;if(o!==n)return r(o),o},e.prototype.enqueue=function(n){var o=this._sentinel;n._prev&&n._next&&r(n),n._next=o._next,o._next._prev=n,o._next=n,n._prev=o},e.prototype.toString=function(){for(var n=[],o=this._sentinel,i=o._prev;i!==o;)n.push(JSON.stringify(i,t)),i=i._prev;return"["+n.join(", ")+"]"};function r(n){n._prev._next=n._next,n._next._prev=n._prev,delete n._next,delete n._prev}function t(n,o){if(n!=="_next"&&n!=="_prev")return o}return ql}var Ll,Ky;function sj(){if(Ky)return Ll;Ky=1;var e=pt(),r=Ht().Graph,t=aj();Ll=o;var n=e.constant(1);function o(l,d){if(l.nodeCount()<=1)return[];var u=a(l,d||n),h=i(u.graph,u.buckets,u.zeroIdx);return e.flatten(e.map(h,function(p){return l.outEdges(p.v,p.w)}),!0)}function i(l,d,u){for(var h=[],p=d[d.length-1],m=d[0],g;l.nodeCount();){for(;g=m.dequeue();)s(l,d,u,g);for(;g=p.dequeue();)s(l,d,u,g);if(l.nodeCount()){for(var y=d.length-2;y>0;--y)if(g=d[y].dequeue(),g){h=h.concat(s(l,d,u,g,!0));break}}}return h}function s(l,d,u,h,p){var m=p?[]:void 0;return e.forEach(l.inEdges(h.v),function(g){var y=l.edge(g),b=l.node(g.v);p&&m.push({v:g.v,w:g.w}),b.out-=y,c(d,u,b)}),e.forEach(l.outEdges(h.v),function(g){var y=l.edge(g),b=g.w,x=l.node(b);x.in-=y,c(d,u,x)}),l.removeNode(h.v),m}function a(l,d){var u=new r,h=0,p=0;e.forEach(l.nodes(),function(y){u.setNode(y,{v:y,in:0,out:0})}),e.forEach(l.edges(),function(y){var b=u.edge(y.v,y.w)||0,x=d(y),v=b+x;u.setEdge(y.v,y.w,v),p=Math.max(p,u.node(y.v).out+=x),h=Math.max(h,u.node(y.w).in+=x)});var m=e.range(p+h+3).map(function(){return new t}),g=h+1;return e.forEach(u.nodes(),function(y){c(m,g,u.node(y))}),{graph:u,buckets:m,zeroIdx:g}}function c(l,d,u){u.out?u.in?l[u.out-u.in+d].enqueue(u):l[l.length-1].enqueue(u):l[0].enqueue(u)}return Ll}var Fl,Jy;function cj(){if(Jy)return Fl;Jy=1;var e=pt(),r=sj();Fl={run:t,undo:o};function t(i){var s=i.graph().acyclicer==="greedy"?r(i,a(i)):n(i);e.forEach(s,function(c){var l=i.edge(c);i.removeEdge(c),l.forwardName=c.name,l.reversed=!0,i.setEdge(c.w,c.v,l,e.uniqueId("rev"))});function a(c){return function(l){return c.edge(l).weight}}}function n(i){var s=[],a={},c={};function l(d){e.has(c,d)||(c[d]=!0,a[d]=!0,e.forEach(i.outEdges(d),function(u){e.has(a,u.w)?s.push(u):l(u.w)}),delete a[d])}return e.forEach(i.nodes(),l),s}function o(i){e.forEach(i.edges(),function(s){var a=i.edge(s);if(a.reversed){i.removeEdge(s);var c=a.forwardName;delete a.reversed,delete a.forwardName,i.setEdge(s.w,s.v,a,c)}})}return Fl}var zl,Zy;function At(){if(Zy)return zl;Zy=1;var e=pt(),r=Ht().Graph;zl={addDummyNode:t,simplify:n,asNonCompoundGraph:o,successorWeights:i,predecessorWeights:s,intersectRect:a,buildLayerMatrix:c,normalizeRanks:l,removeEmptyRanks:d,addBorderNode:u,maxRank:h,partition:p,time:m,notime:g};function t(y,b,x,v){var w;do w=e.uniqueId(v);while(y.hasNode(w));return x.dummy=b,y.setNode(w,x),w}function n(y){var b=new r().setGraph(y.graph());return e.forEach(y.nodes(),function(x){b.setNode(x,y.node(x))}),e.forEach(y.edges(),function(x){var v=b.edge(x.v,x.w)||{weight:0,minlen:1},w=y.edge(x);b.setEdge(x.v,x.w,{weight:v.weight+w.weight,minlen:Math.max(v.minlen,w.minlen)})}),b}function o(y){var b=new r({multigraph:y.isMultigraph()}).setGraph(y.graph());return e.forEach(y.nodes(),function(x){y.children(x).length||b.setNode(x,y.node(x))}),e.forEach(y.edges(),function(x){b.setEdge(x,y.edge(x))}),b}function i(y){var b=e.map(y.nodes(),function(x){var v={};return e.forEach(y.outEdges(x),function(w){v[w.w]=(v[w.w]||0)+y.edge(w).weight}),v});return e.zipObject(y.nodes(),b)}function s(y){var b=e.map(y.nodes(),function(x){var v={};return e.forEach(y.inEdges(x),function(w){v[w.v]=(v[w.v]||0)+y.edge(w).weight}),v});return e.zipObject(y.nodes(),b)}function a(y,b){var x=y.x,v=y.y,w=b.x-x,C=b.y-v,S=y.width/2,R=y.height/2;if(!w&&!C)throw new Error("Not possible to find intersection inside of the rectangle");var P,k;return Math.abs(C)*S>Math.abs(w)*R?(C<0&&(R=-R),P=R*w/C,k=R):(w<0&&(S=-S),P=S,k=S*C/w),{x:x+P,y:v+k}}function c(y){var b=e.map(e.range(h(y)+1),function(){return[]});return e.forEach(y.nodes(),function(x){var v=y.node(x),w=v.rank;e.isUndefined(w)||(b[w][v.order]=x)}),b}function l(y){var b=e.min(e.map(y.nodes(),function(x){return y.node(x).rank}));e.forEach(y.nodes(),function(x){var v=y.node(x);e.has(v,"rank")&&(v.rank-=b)})}function d(y){var b=e.min(e.map(y.nodes(),function(C){return y.node(C).rank})),x=[];e.forEach(y.nodes(),function(C){var S=y.node(C).rank-b;x[S]||(x[S]=[]),x[S].push(C)});var v=0,w=y.graph().nodeRankFactor;e.forEach(x,function(C,S){e.isUndefined(C)&&S%w!==0?--v:v&&e.forEach(C,function(R){y.node(R).rank+=v})})}function u(y,b,x,v){var w={width:0,height:0};return arguments.length>=4&&(w.rank=x,w.order=v),t(y,"border",w,b)}function h(y){return e.max(e.map(y.nodes(),function(b){var x=y.node(b).rank;if(!e.isUndefined(x))return x}))}function p(y,b){var x={lhs:[],rhs:[]};return e.forEach(y,function(v){b(v)?x.lhs.push(v):x.rhs.push(v)}),x}function m(y,b){var x=e.now();try{return b()}finally{console.log(y+" time: "+(e.now()-x)+"ms")}}function g(y,b){return b()}return zl}var Bl,Xy;function lj(){if(Xy)return Bl;Xy=1;var e=pt(),r=At();Bl={run:t,undo:o};function t(i){i.graph().dummyChains=[],e.forEach(i.edges(),function(s){n(i,s)})}function n(i,s){var a=s.v,c=i.node(a).rank,l=s.w,d=i.node(l).rank,u=s.name,h=i.edge(s),p=h.labelRank;if(d!==c+1){i.removeEdge(s);var m,g,y;for(y=0,++c;c<d;++y,++c)h.points=[],g={width:0,height:0,edgeLabel:h,edgeObj:s,rank:c},m=r.addDummyNode(i,"edge",g,"_d"),c===p&&(g.width=h.width,g.height=h.height,g.dummy="edge-label",g.labelpos=h.labelpos),i.setEdge(a,m,{weight:h.weight},u),y===0&&i.graph().dummyChains.push(m),a=m;i.setEdge(a,l,{weight:h.weight},u)}}function o(i){e.forEach(i.graph().dummyChains,function(s){var a=i.node(s),c=a.edgeLabel,l;for(i.setEdge(a.edgeObj,c);a.dummy;)l=i.successors(s)[0],i.removeNode(s),c.points.push({x:a.x,y:a.y}),a.dummy==="edge-label"&&(c.x=a.x,c.y=a.y,c.width=a.width,c.height=a.height),s=l,a=i.node(s)})}return Bl}var Dl,Yy;function lo(){if(Yy)return Dl;Yy=1;var e=pt();Dl={longestPath:r,slack:t};function r(n){var o={};function i(s){var a=n.node(s);if(e.has(o,s))return a.rank;o[s]=!0;var c=e.min(e.map(n.outEdges(s),function(l){return i(l.w)-n.edge(l).minlen}));return(c===Number.POSITIVE_INFINITY||c===void 0||c===null)&&(c=0),a.rank=c}e.forEach(n.sources(),i)}function t(n,o){return n.node(o.w).rank-n.node(o.v).rank-n.edge(o).minlen}return Dl}var Wl,Qy;function Zx(){if(Qy)return Wl;Qy=1;var e=pt(),r=Ht().Graph,t=lo().slack;Wl=n;function n(a){var c=new r({directed:!1}),l=a.nodes()[0],d=a.nodeCount();c.setNode(l,{});for(var u,h;o(c,a)<d;)u=i(c,a),h=c.hasNode(u.v)?t(a,u):-t(a,u),s(c,a,h);return c}function o(a,c){function l(d){e.forEach(c.nodeEdges(d),function(u){var h=u.v,p=d===h?u.w:h;!a.hasNode(p)&&!t(c,u)&&(a.setNode(p,{}),a.setEdge(d,p,{}),l(p))})}return e.forEach(a.nodes(),l),a.nodeCount()}function i(a,c){return e.minBy(c.edges(),function(l){if(a.hasNode(l.v)!==a.hasNode(l.w))return t(c,l)})}function s(a,c,l){e.forEach(a.nodes(),function(d){c.node(d).rank+=l})}return Wl}var Vl,em;function dj(){if(em)return Vl;em=1;var e=pt(),r=Zx(),t=lo().slack,n=lo().longestPath,o=Ht().alg.preorder,i=Ht().alg.postorder,s=At().simplify;Vl=a,a.initLowLimValues=u,a.initCutValues=c,a.calcCutValue=d,a.leaveEdge=p,a.enterEdge=m,a.exchangeEdges=g;function a(v){v=s(v),n(v);var w=r(v);u(w),c(w,v);for(var C,S;C=p(w);)S=m(w,v,C),g(w,v,C,S)}function c(v,w){var C=i(v,v.nodes());C=C.slice(0,C.length-1),e.forEach(C,function(S){l(v,w,S)})}function l(v,w,C){var S=v.node(C),R=S.parent;v.edge(C,R).cutvalue=d(v,w,C)}function d(v,w,C){var S=v.node(C),R=S.parent,P=!0,k=w.edge(C,R),T=0;return k||(P=!1,k=w.edge(R,C)),T=k.weight,e.forEach(w.nodeEdges(C),function(E){var M=E.v===C,_=M?E.w:E.v;if(_!==R){var O=M===P,$=w.edge(E).weight;if(T+=O?$:-$,b(v,C,_)){var B=v.edge(C,_).cutvalue;T+=O?-B:B}}}),T}function u(v,w){arguments.length<2&&(w=v.nodes()[0]),h(v,{},1,w)}function h(v,w,C,S,R){var P=C,k=v.node(S);return w[S]=!0,e.forEach(v.neighbors(S),function(T){e.has(w,T)||(C=h(v,w,C,T,S))}),k.low=P,k.lim=C++,R?k.parent=R:delete k.parent,C}function p(v){return e.find(v.edges(),function(w){return v.edge(w).cutvalue<0})}function m(v,w,C){var S=C.v,R=C.w;w.hasEdge(S,R)||(S=C.w,R=C.v);var P=v.node(S),k=v.node(R),T=P,E=!1;P.lim>k.lim&&(T=k,E=!0);var M=e.filter(w.edges(),function(_){return E===x(v,v.node(_.v),T)&&E!==x(v,v.node(_.w),T)});return e.minBy(M,function(_){return t(w,_)})}function g(v,w,C,S){var R=C.v,P=C.w;v.removeEdge(R,P),v.setEdge(S.v,S.w,{}),u(v),c(v,w),y(v,w)}function y(v,w){var C=e.find(v.nodes(),function(R){return!w.node(R).parent}),S=o(v,C);S=S.slice(1),e.forEach(S,function(R){var P=v.node(R).parent,k=w.edge(R,P),T=!1;k||(k=w.edge(P,R),T=!0),w.node(R).rank=w.node(P).rank+(T?k.minlen:-k.minlen)})}function b(v,w,C){return v.hasEdge(w,C)}function x(v,w,C){return C.low<=w.lim&&w.lim<=C.lim}return Vl}var Gl,tm;function uj(){if(tm)return Gl;tm=1;var e=lo(),r=e.longestPath,t=Zx(),n=dj();Gl=o;function o(c){switch(c.graph().ranker){case"network-simplex":a(c);break;case"tight-tree":s(c);break;case"longest-path":i(c);break;default:a(c)}}var i=r;function s(c){r(c),t(c)}function a(c){n(c)}return Gl}var Ul,rm;function fj(){if(rm)return Ul;rm=1;var e=pt();Ul=r;function r(o){var i=n(o);e.forEach(o.graph().dummyChains,function(s){for(var a=o.node(s),c=a.edgeObj,l=t(o,i,c.v,c.w),d=l.path,u=l.lca,h=0,p=d[h],m=!0;s!==c.w;){if(a=o.node(s),m){for(;(p=d[h])!==u&&o.node(p).maxRank<a.rank;)h++;p===u&&(m=!1)}if(!m){for(;h<d.length-1&&o.node(p=d[h+1]).minRank<=a.rank;)h++;p=d[h]}o.setParent(s,p),s=o.successors(s)[0]}})}function t(o,i,s,a){var c=[],l=[],d=Math.min(i[s].low,i[a].low),u=Math.max(i[s].lim,i[a].lim),h,p;h=s;do h=o.parent(h),c.push(h);while(h&&(i[h].low>d||u>i[h].lim));for(p=h,h=a;(h=o.parent(h))!==p;)l.push(h);return{path:c.concat(l.reverse()),lca:p}}function n(o){var i={},s=0;function a(c){var l=s;e.forEach(o.children(c),a),i[c]={low:l,lim:s++}}return e.forEach(o.children(),a),i}return Ul}var Hl,nm;function hj(){if(nm)return Hl;nm=1;var e=pt(),r=At();Hl={run:t,cleanup:s};function t(a){var c=r.addDummyNode(a,"root",{},"_root"),l=o(a),d=e.max(e.values(l))-1,u=2*d+1;a.graph().nestingRoot=c,e.forEach(a.edges(),function(p){a.edge(p).minlen*=u});var h=i(a)+1;e.forEach(a.children(),function(p){n(a,c,u,h,d,l,p)}),a.graph().nodeRankFactor=u}function n(a,c,l,d,u,h,p){var m=a.children(p);if(!m.length){p!==c&&a.setEdge(c,p,{weight:0,minlen:l});return}var g=r.addBorderNode(a,"_bt"),y=r.addBorderNode(a,"_bb"),b=a.node(p);a.setParent(g,p),b.borderTop=g,a.setParent(y,p),b.borderBottom=y,e.forEach(m,function(x){n(a,c,l,d,u,h,x);var v=a.node(x),w=v.borderTop?v.borderTop:x,C=v.borderBottom?v.borderBottom:x,S=v.borderTop?d:2*d,R=w!==C?1:u-h[p]+1;a.setEdge(g,w,{weight:S,minlen:R,nestingEdge:!0}),a.setEdge(C,y,{weight:S,minlen:R,nestingEdge:!0})}),a.parent(p)||a.setEdge(c,g,{weight:0,minlen:u+h[p]})}function o(a){var c={};function l(d,u){var h=a.children(d);h&&h.length&&e.forEach(h,function(p){l(p,u+1)}),c[d]=u}return e.forEach(a.children(),function(d){l(d,1)}),c}function i(a){return e.reduce(a.edges(),function(c,l){return c+a.edge(l).weight},0)}function s(a){var c=a.graph();a.removeNode(c.nestingRoot),delete c.nestingRoot,e.forEach(a.edges(),function(l){var d=a.edge(l);d.nestingEdge&&a.removeEdge(l)})}return Hl}var Kl,om;function pj(){if(om)return Kl;om=1;var e=pt(),r=At();Kl=t;function t(o){function i(s){var a=o.children(s),c=o.node(s);if(a.length&&e.forEach(a,i),e.has(c,"minRank")){c.borderLeft=[],c.borderRight=[];for(var l=c.minRank,d=c.maxRank+1;l<d;++l)n(o,"borderLeft","_bl",s,c,l),n(o,"borderRight","_br",s,c,l)}}e.forEach(o.children(),i)}function n(o,i,s,a,c,l){var d={width:0,height:0,rank:l,borderType:i},u=c[i][l-1],h=r.addDummyNode(o,"border",d,s);c[i][l]=h,o.setParent(h,a),u&&o.setEdge(u,h,{weight:1})}return Kl}var Jl,im;function gj(){if(im)return Jl;im=1;var e=pt();Jl={adjust:r,undo:t};function r(l){var d=l.graph().rankdir.toLowerCase();(d==="lr"||d==="rl")&&n(l)}function t(l){var d=l.graph().rankdir.toLowerCase();(d==="bt"||d==="rl")&&i(l),(d==="lr"||d==="rl")&&(a(l),n(l))}function n(l){e.forEach(l.nodes(),function(d){o(l.node(d))}),e.forEach(l.edges(),function(d){o(l.edge(d))})}function o(l){var d=l.width;l.width=l.height,l.height=d}function i(l){e.forEach(l.nodes(),function(d){s(l.node(d))}),e.forEach(l.edges(),function(d){var u=l.edge(d);e.forEach(u.points,s),e.has(u,"y")&&s(u)})}function s(l){l.y=-l.y}function a(l){e.forEach(l.nodes(),function(d){c(l.node(d))}),e.forEach(l.edges(),function(d){var u=l.edge(d);e.forEach(u.points,c),e.has(u,"x")&&c(u)})}function c(l){var d=l.x;l.x=l.y,l.y=d}return Jl}var Zl,am;function yj(){if(am)return Zl;am=1;var e=pt();Zl=r;function r(t){var n={},o=e.filter(t.nodes(),function(l){return!t.children(l).length}),i=e.max(e.map(o,function(l){return t.node(l).rank})),s=e.map(e.range(i+1),function(){return[]});function a(l){if(!e.has(n,l)){n[l]=!0;var d=t.node(l);s[d.rank].push(l),e.forEach(t.successors(l),a)}}var c=e.sortBy(o,function(l){return t.node(l).rank});return e.forEach(c,a),s}return Zl}var Xl,sm;function mj(){if(sm)return Xl;sm=1;var e=pt();Xl=r;function r(n,o){for(var i=0,s=1;s<o.length;++s)i+=t(n,o[s-1],o[s]);return i}function t(n,o,i){for(var s=e.zipObject(i,e.map(i,function(h,p){return p})),a=e.flatten(e.map(o,function(h){return e.sortBy(e.map(n.outEdges(h),function(p){return{pos:s[p.w],weight:n.edge(p).weight}}),"pos")}),!0),c=1;c<i.length;)c<<=1;var l=2*c-1;c-=1;var d=e.map(new Array(l),function(){return 0}),u=0;return e.forEach(a.forEach(function(h){var p=h.pos+c;d[p]+=h.weight;for(var m=0;p>0;)p%2&&(m+=d[p+1]),p=p-1>>1,d[p]+=h.weight;u+=h.weight*m})),u}return Xl}var Yl,cm;function bj(){if(cm)return Yl;cm=1;var e=pt();Yl=r;function r(t,n){return e.map(n,function(o){var i=t.inEdges(o);if(i.length){var s=e.reduce(i,function(a,c){var l=t.edge(c),d=t.node(c.v);return{sum:a.sum+l.weight*d.order,weight:a.weight+l.weight}},{sum:0,weight:0});return{v:o,barycenter:s.sum/s.weight,weight:s.weight}}else return{v:o}})}return Yl}var Ql,lm;function xj(){if(lm)return Ql;lm=1;var e=pt();Ql=r;function r(o,i){var s={};e.forEach(o,function(c,l){var d=s[c.v]={indegree:0,in:[],out:[],vs:[c.v],i:l};e.isUndefined(c.barycenter)||(d.barycenter=c.barycenter,d.weight=c.weight)}),e.forEach(i.edges(),function(c){var l=s[c.v],d=s[c.w];!e.isUndefined(l)&&!e.isUndefined(d)&&(d.indegree++,l.out.push(s[c.w]))});var a=e.filter(s,function(c){return!c.indegree});return t(a)}function t(o){var i=[];function s(l){return function(d){d.merged||(e.isUndefined(d.barycenter)||e.isUndefined(l.barycenter)||d.barycenter>=l.barycenter)&&n(l,d)}}function a(l){return function(d){d.in.push(l),--d.indegree===0&&o.push(d)}}for(;o.length;){var c=o.pop();i.push(c),e.forEach(c.in.reverse(),s(c)),e.forEach(c.out,a(c))}return e.map(e.filter(i,function(l){return!l.merged}),function(l){return e.pick(l,["vs","i","barycenter","weight"])})}function n(o,i){var s=0,a=0;o.weight&&(s+=o.barycenter*o.weight,a+=o.weight),i.weight&&(s+=i.barycenter*i.weight,a+=i.weight),o.vs=i.vs.concat(o.vs),o.barycenter=s/a,o.weight=a,o.i=Math.min(i.i,o.i),i.merged=!0}return Ql}var ed,dm;function vj(){if(dm)return ed;dm=1;var e=pt(),r=At();ed=t;function t(i,s){var a=r.partition(i,function(g){return e.has(g,"barycenter")}),c=a.lhs,l=e.sortBy(a.rhs,function(g){return-g.i}),d=[],u=0,h=0,p=0;c.sort(o(!!s)),p=n(d,l,p),e.forEach(c,function(g){p+=g.vs.length,d.push(g.vs),u+=g.barycenter*g.weight,h+=g.weight,p=n(d,l,p)});var m={vs:e.flatten(d,!0)};return h&&(m.barycenter=u/h,m.weight=h),m}function n(i,s,a){for(var c;s.length&&(c=e.last(s)).i<=a;)s.pop(),i.push(c.vs),a++;return a}function o(i){return function(s,a){return s.barycenter<a.barycenter?-1:s.barycenter>a.barycenter?1:i?a.i-s.i:s.i-a.i}}return ed}var td,um;function wj(){if(um)return td;um=1;var e=pt(),r=bj(),t=xj(),n=vj();td=o;function o(a,c,l,d){var u=a.children(c),h=a.node(c),p=h?h.borderLeft:void 0,m=h?h.borderRight:void 0,g={};p&&(u=e.filter(u,function(C){return C!==p&&C!==m}));var y=r(a,u);e.forEach(y,function(C){if(a.children(C.v).length){var S=o(a,C.v,l,d);g[C.v]=S,e.has(S,"barycenter")&&s(C,S)}});var b=t(y,l);i(b,g);var x=n(b,d);if(p&&(x.vs=e.flatten([p,x.vs,m],!0),a.predecessors(p).length)){var v=a.node(a.predecessors(p)[0]),w=a.node(a.predecessors(m)[0]);e.has(x,"barycenter")||(x.barycenter=0,x.weight=0),x.barycenter=(x.barycenter*x.weight+v.order+w.order)/(x.weight+2),x.weight+=2}return x}function i(a,c){e.forEach(a,function(l){l.vs=e.flatten(l.vs.map(function(d){return c[d]?c[d].vs:d}),!0)})}function s(a,c){e.isUndefined(a.barycenter)?(a.barycenter=c.barycenter,a.weight=c.weight):(a.barycenter=(a.barycenter*a.weight+c.barycenter*c.weight)/(a.weight+c.weight),a.weight+=c.weight)}return td}var rd,fm;function Cj(){if(fm)return rd;fm=1;var e=pt(),r=Ht().Graph;rd=t;function t(o,i,s){var a=n(o),c=new r({compound:!0}).setGraph({root:a}).setDefaultNodeLabel(function(l){return o.node(l)});return e.forEach(o.nodes(),function(l){var d=o.node(l),u=o.parent(l);(d.rank===i||d.minRank<=i&&i<=d.maxRank)&&(c.setNode(l),c.setParent(l,u||a),e.forEach(o[s](l),function(h){var p=h.v===l?h.w:h.v,m=c.edge(p,l),g=e.isUndefined(m)?0:m.weight;c.setEdge(p,l,{weight:o.edge(h).weight+g})}),e.has(d,"minRank")&&c.setNode(l,{borderLeft:d.borderLeft[i],borderRight:d.borderRight[i]}))}),c}function n(o){for(var i;o.hasNode(i=e.uniqueId("_root")););return i}return rd}var nd,hm;function Sj(){if(hm)return nd;hm=1;var e=pt();nd=r;function r(t,n,o){var i={},s;e.forEach(o,function(a){for(var c=t.parent(a),l,d;c;){if(l=t.parent(c),l?(d=i[l],i[l]=c):(d=s,s=c),d&&d!==c){n.setEdge(d,c);return}c=l}})}return nd}var od,pm;function jj(){if(pm)return od;pm=1;var e=pt(),r=yj(),t=mj(),n=wj(),o=Cj(),i=Sj(),s=Ht().Graph,a=At();od=c;function c(h){var p=a.maxRank(h),m=l(h,e.range(1,p+1),"inEdges"),g=l(h,e.range(p-1,-1,-1),"outEdges"),y=r(h);u(h,y);for(var b=Number.POSITIVE_INFINITY,x,v=0,w=0;w<4;++v,++w){d(v%2?m:g,v%4>=2),y=a.buildLayerMatrix(h);var C=t(h,y);C<b&&(w=0,x=e.cloneDeep(y),b=C)}u(h,x)}function l(h,p,m){return e.map(p,function(g){return o(h,g,m)})}function d(h,p){var m=new s;e.forEach(h,function(g){var y=g.graph().root,b=n(g,y,m,p);e.forEach(b.vs,function(x,v){g.node(x).order=v}),i(g,m,b.vs)})}function u(h,p){e.forEach(p,function(m){e.forEach(m,function(g,y){h.node(g).order=y})})}return od}var id,gm;function Ej(){if(gm)return id;gm=1;var e=pt(),r=Ht().Graph,t=At();id={positionX:m,findType1Conflicts:n,findType2Conflicts:o,addConflict:s,hasConflict:a,verticalAlignment:c,horizontalCompaction:l,alignCoordinates:h,findSmallestWidthAlignment:u,balance:p};function n(b,x){var v={};function w(C,S){var R=0,P=0,k=C.length,T=e.last(S);return e.forEach(S,function(E,M){var _=i(b,E),O=_?b.node(_).order:k;(_||E===T)&&(e.forEach(S.slice(P,M+1),function($){e.forEach(b.predecessors($),function(B){var N=b.node(B),I=N.order;(I<R||O<I)&&!(N.dummy&&b.node($).dummy)&&s(v,B,$)})}),P=M+1,R=O)}),S}return e.reduce(x,w),v}function o(b,x){var v={};function w(S,R,P,k,T){var E;e.forEach(e.range(R,P),function(M){E=S[M],b.node(E).dummy&&e.forEach(b.predecessors(E),function(_){var O=b.node(_);O.dummy&&(O.order<k||O.order>T)&&s(v,_,E)})})}function C(S,R){var P=-1,k,T=0;return e.forEach(R,function(E,M){if(b.node(E).dummy==="border"){var _=b.predecessors(E);_.length&&(k=b.node(_[0]).order,w(R,T,M,P,k),T=M,P=k)}w(R,T,R.length,k,S.length)}),R}return e.reduce(x,C),v}function i(b,x){if(b.node(x).dummy)return e.find(b.predecessors(x),function(v){return b.node(v).dummy})}function s(b,x,v){if(x>v){var w=x;x=v,v=w}var C=b[x];C||(b[x]=C={}),C[v]=!0}function a(b,x,v){if(x>v){var w=x;x=v,v=w}return e.has(b[x],v)}function c(b,x,v,w){var C={},S={},R={};return e.forEach(x,function(P){e.forEach(P,function(k,T){C[k]=k,S[k]=k,R[k]=T})}),e.forEach(x,function(P){var k=-1;e.forEach(P,function(T){var E=w(T);if(E.length){E=e.sortBy(E,function(B){return R[B]});for(var M=(E.length-1)/2,_=Math.floor(M),O=Math.ceil(M);_<=O;++_){var $=E[_];S[T]===T&&k<R[$]&&!a(v,T,$)&&(S[$]=T,S[T]=C[T]=C[$],k=R[$])}}})}),{root:C,align:S}}function l(b,x,v,w,C){var S={},R=d(b,x,v,C),P=C?"borderLeft":"borderRight";function k(M,_){for(var O=R.nodes(),$=O.pop(),B={};$;)B[$]?M($):(B[$]=!0,O.push($),O=O.concat(_($))),$=O.pop()}function T(M){S[M]=R.inEdges(M).reduce(function(_,O){return Math.max(_,S[O.v]+R.edge(O))},0)}function E(M){var _=R.outEdges(M).reduce(function($,B){return Math.min($,S[B.w]-R.edge(B))},Number.POSITIVE_INFINITY),O=b.node(M);_!==Number.POSITIVE_INFINITY&&O.borderType!==P&&(S[M]=Math.max(S[M],_))}return k(T,R.predecessors.bind(R)),k(E,R.successors.bind(R)),e.forEach(w,function(M){S[M]=S[v[M]]}),S}function d(b,x,v,w){var C=new r,S=b.graph(),R=g(S.nodesep,S.edgesep,w);return e.forEach(x,function(P){var k;e.forEach(P,function(T){var E=v[T];if(C.setNode(E),k){var M=v[k],_=C.edge(M,E);C.setEdge(M,E,Math.max(R(b,T,k),_||0))}k=T})}),C}function u(b,x){return e.minBy(e.values(x),function(v){var w=Number.NEGATIVE_INFINITY,C=Number.POSITIVE_INFINITY;return e.forIn(v,function(S,R){var P=y(b,R)/2;w=Math.max(S+P,w),C=Math.min(S-P,C)}),w-C})}function h(b,x){var v=e.values(x),w=e.min(v),C=e.max(v);e.forEach(["u","d"],function(S){e.forEach(["l","r"],function(R){var P=S+R,k=b[P],T;if(k!==x){var E=e.values(k);T=R==="l"?w-e.min(E):C-e.max(E),T&&(b[P]=e.mapValues(k,function(M){return M+T}))}})})}function p(b,x){return e.mapValues(b.ul,function(v,w){if(x)return b[x.toLowerCase()][w];var C=e.sortBy(e.map(b,w));return(C[1]+C[2])/2})}function m(b){var x=t.buildLayerMatrix(b),v=e.merge(n(b,x),o(b,x)),w={},C;e.forEach(["u","d"],function(R){C=R==="u"?x:e.values(x).reverse(),e.forEach(["l","r"],function(P){P==="r"&&(C=e.map(C,function(M){return e.values(M).reverse()}));var k=(R==="u"?b.predecessors:b.successors).bind(b),T=c(b,C,v,k),E=l(b,C,T.root,T.align,P==="r");P==="r"&&(E=e.mapValues(E,function(M){return-M})),w[R+P]=E})});var S=u(b,w);return h(w,S),p(w,b.graph().align)}function g(b,x,v){return function(w,C,S){var R=w.node(C),P=w.node(S),k=0,T;if(k+=R.width/2,e.has(R,"labelpos"))switch(R.labelpos.toLowerCase()){case"l":T=-R.width/2;break;case"r":T=R.width/2;break}if(T&&(k+=v?T:-T),T=0,k+=(R.dummy?x:b)/2,k+=(P.dummy?x:b)/2,k+=P.width/2,e.has(P,"labelpos"))switch(P.labelpos.toLowerCase()){case"l":T=P.width/2;break;case"r":T=-P.width/2;break}return T&&(k+=v?T:-T),T=0,k}}function y(b,x){return b.node(x).width}return id}var ad,ym;function _j(){if(ym)return ad;ym=1;var e=pt(),r=At(),t=Ej().positionX;ad=n;function n(i){i=r.asNonCompoundGraph(i),o(i),e.forEach(t(i),function(s,a){i.node(a).x=s})}function o(i){var s=r.buildLayerMatrix(i),a=i.graph().ranksep,c=0;e.forEach(s,function(l){var d=e.max(e.map(l,function(u){return i.node(u).height}));e.forEach(l,function(u){i.node(u).y=c+d/2}),c+=d+a})}return ad}var sd,mm;function Rj(){if(mm)return sd;mm=1;var e=pt(),r=cj(),t=lj(),n=uj(),o=At().normalizeRanks,i=fj(),s=At().removeEmptyRanks,a=hj(),c=pj(),l=gj(),d=jj(),u=_j(),h=At(),p=Ht().Graph;sd=m;function m(q,F){var G=F&&F.debugTiming?h.time:h.notime;G("layout",function(){var D=G(" buildLayoutGraph",function(){return k(q)});G(" runLayout",function(){g(D,G)}),G(" updateInputGraph",function(){y(q,D)})})}function g(q,F){F(" makeSpaceForEdgeLabels",function(){T(q)}),F(" removeSelfEdges",function(){ee(q)}),F(" acyclic",function(){r.run(q)}),F(" nestingGraph.run",function(){a.run(q)}),F(" rank",function(){n(h.asNonCompoundGraph(q))}),F(" injectEdgeLabelProxies",function(){E(q)}),F(" removeEmptyRanks",function(){s(q)}),F(" nestingGraph.cleanup",function(){a.cleanup(q)}),F(" normalizeRanks",function(){o(q)}),F(" assignRankMinMax",function(){M(q)}),F(" removeEdgeLabelProxies",function(){_(q)}),F(" normalize.run",function(){t.run(q)}),F(" parentDummyChains",function(){i(q)}),F(" addBorderSegments",function(){c(q)}),F(" order",function(){d(q)}),F(" insertSelfEdges",function(){ae(q)}),F(" adjustCoordinateSystem",function(){l.adjust(q)}),F(" position",function(){u(q)}),F(" positionSelfEdges",function(){ne(q)}),F(" removeBorderNodes",function(){I(q)}),F(" normalize.undo",function(){t.undo(q)}),F(" fixupEdgeLabelCoords",function(){B(q)}),F(" undoCoordinateSystem",function(){l.undo(q)}),F(" translateGraph",function(){O(q)}),F(" assignNodeIntersects",function(){$(q)}),F(" reversePoints",function(){N(q)}),F(" acyclic.undo",function(){r.undo(q)})}function y(q,F){e.forEach(q.nodes(),function(G){var D=q.node(G),ce=F.node(G);D&&(D.x=ce.x,D.y=ce.y,F.children(G).length&&(D.width=ce.width,D.height=ce.height))}),e.forEach(q.edges(),function(G){var D=q.edge(G),ce=F.edge(G);D.points=ce.points,e.has(ce,"x")&&(D.x=ce.x,D.y=ce.y)}),q.graph().width=F.graph().width,q.graph().height=F.graph().height}var b=["nodesep","edgesep","ranksep","marginx","marginy"],x={ranksep:50,edgesep:20,nodesep:50,rankdir:"tb"},v=["acyclicer","ranker","rankdir","align"],w=["width","height"],C={width:0,height:0},S=["minlen","weight","width","height","labeloffset"],R={minlen:1,weight:1,width:0,height:0,labeloffset:10,labelpos:"r"},P=["labelpos"];function k(q){var F=new p({multigraph:!0,compound:!0}),G=pe(q.graph());return F.setGraph(e.merge({},x,oe(G,b),e.pick(G,v))),e.forEach(q.nodes(),function(D){var ce=pe(q.node(D));F.setNode(D,e.defaults(oe(ce,w),C)),F.setParent(D,q.parent(D))}),e.forEach(q.edges(),function(D){var ce=pe(q.edge(D));F.setEdge(D,e.merge({},R,oe(ce,S),e.pick(ce,P)))}),F}function T(q){var F=q.graph();F.ranksep/=2,e.forEach(q.edges(),function(G){var D=q.edge(G);D.minlen*=2,D.labelpos.toLowerCase()!=="c"&&(F.rankdir==="TB"||F.rankdir==="BT"?D.width+=D.labeloffset:D.height+=D.labeloffset)})}function E(q){e.forEach(q.edges(),function(F){var G=q.edge(F);if(G.width&&G.height){var D=q.node(F.v),ce=q.node(F.w),Q={rank:(ce.rank-D.rank)/2+D.rank,e:F};h.addDummyNode(q,"edge-proxy",Q,"_ep")}})}function M(q){var F=0;e.forEach(q.nodes(),function(G){var D=q.node(G);D.borderTop&&(D.minRank=q.node(D.borderTop).rank,D.maxRank=q.node(D.borderBottom).rank,F=e.max(F,D.maxRank))}),q.graph().maxRank=F}function _(q){e.forEach(q.nodes(),function(F){var G=q.node(F);G.dummy==="edge-proxy"&&(q.edge(G.e).labelRank=G.rank,q.removeNode(F))})}function O(q){var F=Number.POSITIVE_INFINITY,G=0,D=Number.POSITIVE_INFINITY,ce=0,Q=q.graph(),K=Q.marginx||0,ie=Q.marginy||0;function ye(we){var he=we.x,ge=we.y,X=we.width,H=we.height;F=Math.min(F,he-X/2),G=Math.max(G,he+X/2),D=Math.min(D,ge-H/2),ce=Math.max(ce,ge+H/2)}e.forEach(q.nodes(),function(we){ye(q.node(we))}),e.forEach(q.edges(),function(we){var he=q.edge(we);e.has(he,"x")&&ye(he)}),F-=K,D-=ie,e.forEach(q.nodes(),function(we){var he=q.node(we);he.x-=F,he.y-=D}),e.forEach(q.edges(),function(we){var he=q.edge(we);e.forEach(he.points,function(ge){ge.x-=F,ge.y-=D}),e.has(he,"x")&&(he.x-=F),e.has(he,"y")&&(he.y-=D)}),Q.width=G-F+K,Q.height=ce-D+ie}function $(q){e.forEach(q.edges(),function(F){var G=q.edge(F),D=q.node(F.v),ce=q.node(F.w),Q,K;G.points?(Q=G.points[0],K=G.points[G.points.length-1]):(G.points=[],Q=ce,K=D),G.points.unshift(h.intersectRect(D,Q)),G.points.push(h.intersectRect(ce,K))})}function B(q){e.forEach(q.edges(),function(F){var G=q.edge(F);if(e.has(G,"x"))switch((G.labelpos==="l"||G.labelpos==="r")&&(G.width-=G.labeloffset),G.labelpos){case"l":G.x-=G.width/2+G.labeloffset;break;case"r":G.x+=G.width/2+G.labeloffset;break}})}function N(q){e.forEach(q.edges(),function(F){var G=q.edge(F);G.reversed&&G.points.reverse()})}function I(q){e.forEach(q.nodes(),function(F){if(q.children(F).length){var G=q.node(F),D=q.node(G.borderTop),ce=q.node(G.borderBottom),Q=q.node(e.last(G.borderLeft)),K=q.node(e.last(G.borderRight));G.width=Math.abs(K.x-Q.x),G.height=Math.abs(ce.y-D.y),G.x=Q.x+G.width/2,G.y=D.y+G.height/2}}),e.forEach(q.nodes(),function(F){q.node(F).dummy==="border"&&q.removeNode(F)})}function ee(q){e.forEach(q.edges(),function(F){if(F.v===F.w){var G=q.node(F.v);G.selfEdges||(G.selfEdges=[]),G.selfEdges.push({e:F,label:q.edge(F)}),q.removeEdge(F)}})}function ae(q){var F=h.buildLayerMatrix(q);e.forEach(F,function(G){var D=0;e.forEach(G,function(ce,Q){var K=q.node(ce);K.order=Q+D,e.forEach(K.selfEdges,function(ie){h.addDummyNode(q,"selfedge",{width:ie.label.width,height:ie.label.height,rank:K.rank,order:Q+ ++D,e:ie.e,label:ie.label},"_se")}),delete K.selfEdges})})}function ne(q){e.forEach(q.nodes(),function(F){var G=q.node(F);if(G.dummy==="selfedge"){var D=q.node(G.e.v),ce=D.x+D.width/2,Q=D.y,K=G.x-ce,ie=D.height/2;q.setEdge(G.e,G.label),q.removeNode(F),G.label.points=[{x:ce+2*K/3,y:Q-ie},{x:ce+5*K/6,y:Q-ie},{x:ce+K,y:Q},{x:ce+5*K/6,y:Q+ie},{x:ce+2*K/3,y:Q+ie}],G.label.x=G.x,G.label.y=G.y}})}function oe(q,F){return e.mapValues(e.pick(q,F),Number)}function pe(q){var F={};return e.forEach(q,function(G,D){F[D.toLowerCase()]=G}),F}return sd}var cd,bm;function kj(){if(bm)return cd;bm=1;var e=pt(),r=At(),t=Ht().Graph;cd={debugOrdering:n};function n(o){var i=r.buildLayerMatrix(o),s=new t({compound:!0,multigraph:!0}).setGraph({});return e.forEach(o.nodes(),function(a){s.setNode(a,{label:a}),s.setParent(a,"layer"+o.node(a).rank)}),e.forEach(o.edges(),function(a){s.setEdge(a.v,a.w,{},a.name)}),e.forEach(i,function(a,c){var l="layer"+c;s.setNode(l,{rank:"same"}),e.reduce(a,function(d,u){return s.setEdge(d,u,{style:"invis"}),u})}),s}return cd}var ld,xm;function Aj(){return xm||(xm=1,ld="0.8.5"),ld}var dd,vm;function Pj(){return vm||(vm=1,dd={graphlib:Ht(),layout:Rj(),debug:kj(),util:{time:At().time,notime:At().notime},version:Aj()}),dd}var Mj=Pj();const wm=g1(Mj);function Ij(e,r,t){var d;const n=new Set(e.map(u=>u.id)),o=new Set;for(const u of e)u.parent&&n.has(u.parent)&&o.add(u.parent);const i=new wm.graphlib.Graph({multigraph:!0,compound:!0}),s=t.compactSpacingScale??(t.spacingFactor>0?t.spacingFactor/1.3:1);i.setGraph({rankdir:t.rankDir,nodesep:t.compact?Math.max(t.nodeSep,24*s):t.nodeSep,edgesep:t.compact?Math.min(t.edgeSep,24*s):t.edgeSep,ranksep:t.compact?Math.min(t.rankSep,80*s):t.rankSep,ranker:"network-simplex"}),i.setDefaultEdgeLabel(()=>({})),i.setDefaultNodeLabel(()=>({}));for(const u of e)i.setNode(u.id,{width:u.width+2,height:u.height+2});for(const u of e)u.parent&&n.has(u.parent)&&i.setParent(u.id,u.parent);for(const u of r){if(!n.has(u.source)||!n.has(u.target)||o.has(u.source)||o.has(u.target))continue;const h=Jb(u.label,u.icon??((d=u.data)==null?void 0:d.icon),t.edgeLabelFontSize),p=t.rankDir==="LR"||t.rankDir==="RL",m=(h.width?h.width+2*Kb:0)+(u.connectorClearance??0);i.setEdge(u.source,u.target,{minlen:1,weight:1,...m?{width:p?m:Math.max(1,h.height),height:p?Math.max(1,h.height):m,labelpos:"c"}:{}},u.id)}wm.layout(i);const a=new Map;for(const u of e){if(o.has(u.id))continue;const h=i.node(u.id);h&&Number.isFinite(h.x)&&Number.isFinite(h.y)&&a.set(u.id,{x:h.x,y:h.y})}const c=t.compact?1:t.spacingFactor;if(c&&c!==1&&a.size){let u=1/0,h=1/0,p=-1/0,m=-1/0;a.forEach(b=>{u=Math.min(u,b.x),h=Math.min(h,b.y),p=Math.max(p,b.x),m=Math.max(m,b.y)});const g=(u+p)/2,y=(h+m)/2;a.forEach((b,x)=>a.set(x,{x:g+(b.x-g)*c,y:y+(b.y-y)*c}))}const l=t.nodeAlignment??"center";if(l!=="center"){const u=t.rankDir==="LR"||t.rankDir==="RL",h=u?"x":"y",p=u?"width":"height",m=t.rankDir==="RL"||t.rankDir==="BT"?-1:1,g=l==="leading"?-m:m,y=new Map;for(const b of e){const x=a.get(b.id);if(!x)continue;const v=x[h];y.set(v,Math.max(y.get(v)??0,b[p]))}for(const b of e){const x=a.get(b.id);if(!x)continue;const v=x[h],w=(y.get(v)-b[p])/2;a.set(b.id,{...x,[h]:v+g*w})}}return a}function Cd(e,r,t,n,o,i){const s=new Map,a=new Map(e.map(u=>[u.id,u]));for(const u of e){if(!u.parent||!a.has(u.parent))continue;const h=s.get(u.parent);h?h.push(u.id):s.set(u.parent,[u.id])}const c=(u,h=new Set)=>{var m;const p=(m=a.get(u))==null?void 0:m.parent;return!p||!a.has(p)||h.has(u)?0:(h.add(u),1+c(p,h))},l=[...s.keys()].sort((u,h)=>c(h)-c(u)),d=new Map;for(const u of l){const h=i==null?void 0:i.get(u),p=r.get(u);if(h&&p){d.set(u,{x1:p.x-h.w/2,y1:p.y-h.h/2,x2:p.x+h.w/2,y2:p.y+h.h/2});continue}let m=null;for(const b of s.get(u)||[]){let x=d.get(b);if(!x){const v=r.get(b);if(!v)continue;const w=t.get(b)||{w:60,h:60};x={x1:v.x-w.w/2,y1:v.y-w.h/2,x2:v.x+w.w/2,y2:v.y+w.h/2}}m=m?{x1:Math.min(m.x1,x.x1),y1:Math.min(m.y1,x.y1),x2:Math.max(m.x2,x.x2),y2:Math.max(m.y2,x.y2)}:{...x}}if(!m)continue;const g=n(u);m={x1:m.x1-g,y1:m.y1-g,x2:m.x2+g,y2:m.y2+g};const y=o(u);if(y){const b=m.x2-m.x1,x=m.y2-m.y1;if(y.w>b){const v=(y.w-b)/2;m.x1-=v,m.x2+=v}if(y.h>x){const v=(y.h-x)/2;m.y1-=v,m.y2+=v}}d.set(u,m)}return d}function Cm(e,r,t){var c,l,d;const n=[...r.weights],o=n.reduce((u,h)=>u+h,0),i=n[r.index]+n[r.index+1],s=Math.min(i*.95,Math.max(i*.05,n[r.index]+t/r.length*o));n[r.index]=s,n[r.index+1]=i-s;const a={...(l=(c=e.adjustment)==null?void 0:c.sections)==null?void 0:l[r.section]};if(r.axis==="y")a.rows=n;else{for(a.columns=[...a.columns??[]];a.columns.length<=r.row;)a.columns.push([]);a.columns[r.row]=n}return{...e,adjustment:{...e.adjustment,sections:{...(d=e.adjustment)==null?void 0:d.sections,[r.section]:a}}}}function Xx(e){if(e===void 0)return;if(!e||typeof e!="object"||Array.isArray(e)||e.enabled!==void 0&&typeof e.enabled!="boolean")throw new RangeError("Invalid grid adjustment.");const r=t=>Array.isArray(t)&&t.length<=1e4&&t.every(n=>typeof n=="number"&&Number.isFinite(n)&&n>0&&n<=1e6);if(e.sections!==void 0&&(!e.sections||typeof e.sections!="object"||Array.isArray(e.sections)))throw new RangeError("Invalid grid sections.");for(const[t,n]of Object.entries(e.sections??{}))if(["__proto__","constructor","prototype"].includes(t)||!n||typeof n!="object"||Array.isArray(n)||n.rows!==void 0&&!r(n.rows)||n.columns!==void 0&&(!Array.isArray(n.columns)||n.columns.length>1e4||!n.columns.every(r))||n.members!==void 0&&(!Array.isArray(n.members)||n.members.length>1e4||!n.members.every(o=>Array.isArray(o)&&o.length>0&&o.length<=1e4&&o.every(i=>typeof i=="string"&&i.length>0))||new Set(n.members.flat()).size!==n.members.flat().length))throw new RangeError("Invalid grid section proportions.")}function cu(e){const r=e.margin??15;if(!Number.isFinite(r)||r<0)throw new RangeError("Collision margin must be finite and non-negative.");return r}function Gn(e){const r=new Map(e.nodes.map(a=>[a.id,a])),t=new Map;for(const a of e.nodes){const c=a.parent&&r.has(a.parent)?a.parent:void 0,l=t.get(c)??[];l.push(a.id),t.set(c,l)}const n=[],o=new Map,i=a=>{const c=t.get(a),l=c?c.flatMap(i):e.positions.has(a)?[a]:[];return o.set(a,l),c&&n.push(c),l},s=t.get(void 0)??[];return s.forEach(i),n.push(s),{groups:n,leaves:o,children:t,roots:s}}function br(e,r,t=e.fixedSizes){const n=Cd(e.nodes,r,e.sizes,e.padding,e.minSize,t);for(const o of e.nodes){if(n.has(o.id))continue;const i=r.get(o.id),s=e.sizes.get(o.id);i&&s&&n.set(o.id,tr({...i,...s}))}return n}function Yx(e,r,t,n){const o=t.get(e),i=t.get(r);if(!o||!i)return;const s={x:Math.min(o.x2-i.x1,i.x2-o.x1)+n,y:Math.min(o.y2-i.y1,i.y2-o.y1)+n};if(s.x>.001&&s.y>.001)return{source:e,target:r,overlap:s}}function qn(e,r,t){const n=[];for(const o of e)for(let i=0;i<o.length;i++)for(let s=i+1;s<o.length;s++){const a=Yx(o[i],o[s],r,t);a&&n.push(a)}return n}function Qx(e,r={}){const t=cu(r),{groups:n}=Gn(e);return qn(n,br(e,e.positions),t)}function ev(e,r,t,n){var a,c,l;const o=new Set(e),i=(((l=(c=(a=r.adjustment)==null?void 0:a.sections)==null?void 0:c[t])==null?void 0:l.members)??[]).map(d=>d.filter(u=>o.delete(u))).filter(d=>d.length),s=e.filter(d=>o.has(d));for(let d=0;d<s.length;d+=n)i.push(s.slice(d,d+n));return i}function Tj(e,r,t,n,o){var x,v,w,C;if(t===n)return;const{groups:i,leaves:s}=Gn(e),a=i.find(S=>S.includes(t)&&S.includes(n));if(!a||a.some(S=>e.fixedIds.has(S)||(s.get(S)??[]).some(R=>e.fixedIds.has(R))))return;const c=br(e,e.positions);if(a.some(S=>!c.has(S)))return;const l=((x=e.nodes.find(S=>S.id===t))==null?void 0:x.parent)??"canvas",d=(w=(v=r.adjustment)==null?void 0:v.sections)==null?void 0:w[l],u=[],h=[...a].sort((S,R)=>{const P=c.get(S),k=c.get(R),T=(P.y1+P.y2-k.y1-k.y2)/2;return Math.abs(T)>1?T:P.x1-k.x1});for(const S of h){const R=u.at(-1),P=c.get(S),k=R&&c.get(R[0]);k&&Math.abs(P.y1+P.y2-k.y1-k.y2)<2?R.push(S):u.push([S])}const p=u.map((S,R)=>{var P;return{weight:((P=d==null?void 0:d.rows)==null?void 0:P[R])??1,cells:S.map((k,T)=>{var E,M;return{id:k,weight:((M=(E=d==null?void 0:d.columns)==null?void 0:E[R])==null?void 0:M[T])??1}})}});for(const S of p)S.cells=S.cells.filter(R=>R.id!==t);const m=p.filter(S=>S.cells.length),g=m.findIndex(S=>S.cells.some(R=>R.id===n)),y=m[g];if(!y)return;o==="above"||o==="below"?m.splice(g+(o==="below"?1:0),0,{weight:1,cells:[{id:t,weight:1}]}):y.cells.splice(y.cells.findIndex(S=>S.id===n)+(o==="after"?1:0),0,{id:t,weight:1});const b=m.map(S=>S.cells.map(R=>R.id));if(JSON.stringify(b)!==JSON.stringify(u))return{...r,adjustment:{...r.adjustment,sections:{...(C=r.adjustment)==null?void 0:C.sections,[l]:{...d,members:b,rows:m.map(S=>S.weight),columns:m.map(S=>S.cells.map(R=>R.weight))}}}}}function ud(e,r={}){var d;Xx(r.adjustment);const t=cu(r),n=typeof r.gaps=="object"?r.gaps:{x:r.gaps??t,y:r.gaps??t};if(!n||[n.x,n.y].some(u=>!Number.isFinite(u)||u<0))throw new RangeError("Grid gaps must be finite and non-negative.");const o=r.padding??0;if(!Number.isFinite(o)||o<0)throw new RangeError("Grid padding must be finite and non-negative.");if(r.columns!==void 0&&(!Number.isSafeInteger(r.columns)||r.columns<1))throw new RangeError("Grid columns must be a positive safe integer.");if(r.fill&&e.viewportSize)return Nj(e,r,n,o);const{groups:i,leaves:s}=Gn(e),a=new Map([...e.positions].map(([u,h])=>[u,{...h}])),c=new Set;for(const u of i){const h=br(e,a),p=u.filter(E=>h.has(E));if(p.length<2)continue;if(p.some(E=>e.fixedIds.has(E)||(s.get(E)??[]).some(M=>e.fixedIds.has(M)))){p.forEach(E=>c.add(E));continue}const g=p.map(E=>h.get(E)),y=Math.max(...g.map(E=>E.x2-E.x1)),b=Math.max(...g.map(E=>E.y2-E.y1)),x=Math.min(p.length,r.columns??Math.ceil(Math.sqrt(p.length))),v=((d=e.nodes.find(E=>E.id===p[0]))==null?void 0:d.parent)??"canvas",w=ev(p,r,v,x),C=Math.max(...w.map(E=>E.length)),S=y+n.x,R=b+n.y,P=g.map(E=>({x:(E.x1+E.x2)/2,y:(E.y1+E.y2)/2})),k=(Math.min(...P.map(E=>E.x))+Math.max(...P.map(E=>E.x)))/2,T=(Math.min(...P.map(E=>E.y))+Math.max(...P.map(E=>E.y)))/2;w.forEach((E,M)=>E.forEach((_,O)=>{const $=h.get(_),B={x:k+(O-(C-1)/2)*S-($.x1+$.x2)/2,y:T+(M-(w.length-1)/2)*R-($.y1+$.y2)/2};for(const N of s.get(_)??[]){const I=a.get(N);a.set(N,{x:I.x+B.x,y:I.y+B.y})}}))}const l=[...a].filter(([u,h])=>{const p=e.positions.get(u);return h.x!==p.x||h.y!==p.y}).map(([u])=>u);return{positions:a,movedNodeIds:l,skippedNodeIds:[...c],collisions:qn(i,br(e,a),Math.min(n.x,n.y))}}function Nj(e,r,t,n){const{groups:o,children:i,roots:s}=Gn(e),a=new Map([...e.positions].map(([y,b])=>[y,{...b}]));if(e.nodes.some(y=>e.fixedIds.has(y.id)))return{positions:a,movedNodeIds:[],skippedNodeIds:e.nodes.map(y=>y.id),collisions:Qx(e,{margin:Math.min(t.x,t.y)})};const c=e.viewportSize,l=Math.min(n,Math.max(0,(c.w-1)/2)),d=Math.min(n,Math.max(0,(c.h-1)/2)),u={x1:l,y1:d,x2:Math.max(l+1,c.w-l),y2:Math.max(d+1,c.h-d)},h=new Map,p=[],m=(y,b,x="canvas")=>{var O,$;if(!y.length)return;const v=b.x2-b.x1,w=b.y2-b.y1,C=Math.min(y.length,r.columns??Math.max(1,Math.round(Math.sqrt(y.length*v/w)))),S=ev(y,r,x,C),R=S.length,P=Math.min(t.y,w/(2*R)),k=($=(O=r.adjustment)==null?void 0:O.sections)==null?void 0:$[x],T=Array.from({length:R},(B,N)=>{var I;return((I=k==null?void 0:k.rows)==null?void 0:I[N])??1}),E=T.reduce((B,N)=>B+N,0),M=w-(R-1)*P;let _=b.y1;for(let B=0;B<R;B++){const N=M*T[B]/E,I=S[B].length,ee=Math.min(t.x,v/(2*I)),ae=Array.from({length:I},(q,F)=>{var G,D;return((D=(G=k==null?void 0:k.columns)==null?void 0:G[B])==null?void 0:D[F])??1}),ne=ae.reduce((q,F)=>q+F,0),oe=v-(I-1)*ee;let pe=b.x1;for(let q=0;q<I;q++){const F=S[B][q],G=oe*ae[q]/ne,D=i.get(F);if(D){a.set(F,{x:pe+G/2,y:_+N/2}),h.set(F,{w:G,h:N});const ce=Math.min(e.padding(F),Math.max(0,(Math.min(G,N)-1)/2));m(D,{x1:pe+ce,y1:_+ce,x2:pe+G-ce,y2:_+N-ce},F)}else a.has(F)&&(a.set(F,{x:pe+G/2,y:_+N/2}),h.set(F,{w:G,h:N}));q<I-1&&p.push({section:x,axis:"x",row:B,index:q,weights:ae,length:oe,position:{x:pe+G+ee/2,y:_+N/2}}),pe+=G+ee}B<R-1&&p.push({section:x,axis:"y",row:B,index:B,weights:T,length:M,position:{x:b.x1+v/2,y:_+N+P/2}}),_+=N+P}};m(s,u);const g=[...a].filter(([y,b])=>{const x=e.positions.get(y);return!x||b.x!==x.x||b.y!==x.y}).map(([y])=>y);return{positions:a,movedNodeIds:g,skippedNodeIds:[],bounds:u,sizes:h,dividers:p,collisions:qn(o,br({...e,sizes:h},a,h),0)}}function Oj(e,r={}){const t=cu(r),n=r.maxIterations??50;if(!Number.isInteger(n)||n<0||n>1e3)throw new RangeError("Collision maxIterations must be an integer between 0 and 1000.");const{groups:o,leaves:i}=Gn(e),s=new Map([...e.positions].map(([u,h])=>[u,{...h}])),a=u=>e.fixedIds.has(u)||(i.get(u)??[]).some(h=>e.fixedIds.has(h));let c=qn(o,br(e,s),t),l=0;for(;c.length&&l<n;){let u=!1;for(const h of o){if(h.length<2)continue;const p=br(e,s),m=(g,y,b)=>{for(const v of i.get(g)??[])s.get(v)[y]+=b;const x=p.get(g);y==="x"?(x.x1+=b,x.x2+=b):(x.y1+=b,x.y2+=b)};for(let g=0;g<h.length;g++)for(let y=g+1;y<h.length;y++){const b=h[g],x=h[y],v=Yx(b,x,p,t);if(!v)continue;const w=a(b),C=a(x);if(w&&C)continue;const S=v.overlap.x<=v.overlap.y?"x":"y",R=p.get(b),P=p.get(x),k=S==="x"?R.x1+R.x2<=P.x1+P.x2?-1:1:R.y1+R.y2<=P.y1+P.y2?-1:1,T=v.overlap[S];w||m(b,S,k*T/(C?1:2)),C||m(x,S,-k*T/(w?1:2)),u=!0}}if(l++,c=qn(o,br(e,s),t),!u)break}const d=[...s].filter(([u,h])=>{const p=e.positions.get(u);return h.x!==p.x||h.y!==p.y}).map(([u])=>u);return{positions:s,movedNodeIds:d,collisions:c,iterations:l,resolved:c.length===0}}function $j({dividers:e,options:r,zoom:t,onChange:n}){const o=j.useRef();return f.jsx(f.Fragment,{children:e.map(i=>{const s=i.axis==="x",a=s?Y.PiArrowsHorizontal:Y.PiArrowsVertical,c=`${s?"Column":"Row"} divider ${i.index+1}${s?` in row ${i.row+1}`:""}`;return f.jsx("button",{type:"button",role:"separator","aria-label":c,"aria-orientation":s?"vertical":"horizontal","aria-valuemin":5,"aria-valuemax":95,"aria-valuenow":Math.round(100*i.weights[i.index]/(i.weights[i.index]+i.weights[i.index+1])),title:c,"data-flow-grid-adjustment":"",style:{position:"absolute",left:i.position.x,top:i.position.y,transform:"translate(-50%, -50%)",width:28,height:28,padding:3,border:"1px solid currentColor",borderRadius:4,background:"var(--chakra-colors-gray-100)",color:"var(--chakra-colors-gray-800)",display:"grid",placeItems:"center",cursor:s?"col-resize":"row-resize",touchAction:"none",pointerEvents:"auto",zIndex:30},onPointerDown:l=>{if(l.button!==0)return;l.preventDefault(),l.stopPropagation();const d=l.currentTarget.closest(".flow-sdk-canvas"),u=d.getBoundingClientRect();o.current={pointerId:l.pointerId,start:s?l.clientX:l.clientY,scale:t*(s?u.width/d.clientWidth:u.height/d.clientHeight),divider:i,options:r},l.currentTarget.setPointerCapture(l.pointerId)},onPointerMove:l=>{const d=o.current;if(!d||d.pointerId!==l.pointerId)return;l.preventDefault(),l.stopPropagation();const u=((s?l.clientX:l.clientY)-d.start)/d.scale;n(Cm(d.options,d.divider,u))},onPointerUp:l=>{o.current&&(l.stopPropagation(),o.current=void 0,l.currentTarget.releasePointerCapture(l.pointerId))},onPointerCancel:()=>{o.current&&n(o.current.options),o.current=void 0},onLostPointerCapture:()=>{o.current=void 0},onClick:l=>l.stopPropagation(),onKeyDown:l=>{l.key==="Escape"&&o.current&&(n(o.current.options),o.current=void 0);const d=(s?["ArrowLeft","ArrowRight"]:["ArrowUp","ArrowDown"]).indexOf(l.key);d<0||(l.preventDefault(),l.stopPropagation(),n(Cm(r,i,i.length*(l.shiftKey?.1:.02)*(d===0?-1:1))))},children:f.jsx(a,{size:20,"aria-hidden":"true"})},`${i.section}:${i.axis}:${i.row}:${i.index}`)})})}const Sm=(e,r)=>e.left<r.right&&e.right>r.left&&e.top<r.bottom&&e.bottom>r.top,fd=new WeakMap;function jm(e,r){const t=[...r.querySelectorAll(".flow-sdk-edge-label")];if(!t.length){fd.delete(r);return}const n=r==null?void 0:r.getScreenCTM();if(!r||!n)return;const o=n.inverse(),i=(u,h=0)=>{const p=u.getBoundingClientRect(),m=new DOMPoint(p.left,p.top).matrixTransform(o),g=new DOMPoint(p.right,p.bottom).matrixTransform(o);return{left:m.x-h,right:g.x+h,top:m.y-h,bottom:g.y+h}},s=[...e.querySelectorAll(".flow-sdk-node, .flow-sdk-node button")].filter(u=>u.closest(".flow-sdk-canvas")===e).filter(u=>{const h=u.getBoundingClientRect(),p=getComputedStyle(u);return h.width>0&&h.height>0&&p.visibility!=="hidden"&&p.opacity!=="0"}).map(u=>i(u,24));for(const u of r.querySelectorAll(".flow-sdk-container-label"))s.push(i(u,12));const a=new Map([...e.querySelectorAll(".flow-sdk-edge")].filter(u=>u.closest(".flow-sdk-canvas")===e).map(u=>[u.dataset.edgeId,u.querySelector("path")])),c=JSON.stringify([s,[...a].map(([u,h])=>[u,h==null?void 0:h.getAttribute("d")]),t.map(u=>{var m;const h=u.getBBox(),p=(m=u.querySelector("rect"))==null?void 0:m.getBBox();return[u.dataset.edgeId,u.dataset.labelTransform,u.dataset.labelHorizontal,h.x,h.y,h.width,h.height,p==null?void 0:p.width,p==null?void 0:p.height]})],(u,h)=>typeof h=="number"?Math.round(h*1e3)/1e3:h),l=fd.get(r);if((l==null?void 0:l.geometry)===c&&t.every(u=>l.transforms.has(u))){for(const u of t){const h=l.transforms.get(u);u.getAttribute("transform")!==h&&u.setAttribute("transform",h)}return}for(const u of t)u.setAttribute("transform",u.dataset.labelTransform??"");const d=new Map(t.map(u=>[u,i(u,8)]));for(const u of t){const h=u.dataset.labelHorizontal==="true",p=d.get(u);d.delete(u);const m=k=>s.some(T=>Sm(k,T))||[...d.values()].some(T=>Sm(k,T));if(!h&&!m(p)){d.set(u,p);continue}const g=a.get(u.dataset.edgeId),y=u.querySelector("rect");if(!g||!y)continue;const b=y.getBBox(),x=g.getTotalLength();if(!Number.isFinite(x)||x<=0)continue;const v=(p.left+p.right)/2,w=(p.top+p.bottom)/2,C=Math.min(256,Math.max(16,Math.ceil(x/24))),S=Array.from({length:C+1},(k,T)=>g.getPointAtLength(x*T/C)),P=Array.from({length:C+1},(k,T)=>{const E=x*T/C,M=S[T],_=h?{x:M.x,y:M.y-b.height/2-15}:M,O=g.getPointAtLength(Math.max(0,E-2)),$=g.getPointAtLength(Math.min(x,E+2));let B=Math.atan2($.y-O.y,$.x-O.x)*180/Math.PI;B>90&&(B-=180),B<-90&&(B+=180);const N=Math.abs(B)<1;h&&(B=0);const I=B*Math.PI/180,ee=Math.abs(Math.cos(I))*b.width+Math.abs(Math.sin(I))*b.height,ae=Math.abs(Math.sin(I))*b.width+Math.abs(Math.cos(I))*b.height;return{point:_,angle:B,straight:N,score:Math.hypot(_.x-v,_.y-w),bounds:{left:_.x-ee/2-8,right:_.x+ee/2+8,top:_.y-ae/2-8,bottom:_.y+ae/2+8}}}).sort((k,T)=>k.score-T.score).find(k=>!m(k.bounds)&&(!h||k.straight&&!S.some(T=>T.x>k.bounds.left&&T.x<k.bounds.right&&T.y>k.bounds.top&&T.y<k.bounds.bottom)));P?(u.setAttribute("transform",`translate(${P.point.x} ${P.point.y}) rotate(${P.angle})`),d.set(u,P.bounds)):d.set(u,p)}fd.set(r,{geometry:c,transforms:new Map(t.map(u=>[u,u.getAttribute("transform")??""]))})}function qj(e){const r=e.getBoundingClientRect(),t=r.height/e.offsetHeight;if(!Number.isFinite(t)||t<=0)return[];const n=Ub(e),o={x:e.offsetWidth/2,y:e.offsetHeight/2,w:e.offsetWidth,h:e.offsetHeight},i=[...e.querySelectorAll("[data-flow-property]")],s=new Set(i.filter(a=>a.hasAttribute("data-flow-inspection-row")&&a.getBoundingClientRect().height>0).map(a=>a.dataset.flowProperty));return i.flatMap(a=>{if(a.closest(".flow-sdk-node")!==e)return[];if(s.has(a.dataset.flowProperty)&&!a.hasAttribute("data-flow-inspection-row"))return[];const c=a.dataset.flowPortSide;if(c&&["top","right","bottom","left"].includes(c)){const d=Wb(n?Pn(o,n):o,c,Number(a.dataset.flowPortPosition??.5));return[{property:a.getAttribute("data-flow-property"),top:d.y,height:0,anchor:d,...a.dataset.flowPortPlacement==="config"?{placement:"config"}:{},...a.dataset.flowPortRole==="source"||a.dataset.flowPortRole==="target"?{role:a.dataset.flowPortRole}:{}}]}const l=a.getBoundingClientRect();return!l.width||!l.height?[]:[{property:a.getAttribute("data-flow-property"),top:Math.round((l.top-r.top)/t*1e3)/1e3,height:Math.round(l.height/t*1e3)/1e3,...a.dataset.flowPortRole==="source"||a.dataset.flowPortRole==="target"?{role:a.dataset.flowPortRole}:{}}]})}function Lj({id:e,x:r,y:t,placed:n,hidden:o,gridDraggable:i,gridDragging:s,gridDropTarget:a,gridSize:c,gridPreview:l,onMount:d,drawHandles:u,drawMode:h,connectedPorts:p,resolvedRows:m,hasCollapseControl:g,handleColor:y,animated:b,animationColor:x,animationWidth:v=8,animationVariant:w,width:C=0,height:S=0,propertyMode:R,reversePorts:P,direction:k="LR",onPropertyRows:T,onSurface:E,children:M}){var D,ce;const _=j.useRef(null),[O,$]=j.useState([]),B=m??O,[N,I]=j.useState(),ee=j.useId(),ae=j.useRef(),ne=!!l,oe=!!(l!=null&&l.floating);j.useLayoutEffect(()=>{var we;const Q=_.current;if(!Q||!ne)return;const K=Q.cloneNode(!0);K.removeAttribute("data-node-id"),K.removeAttribute("data-grid-dragging"),K.removeAttribute("data-grid-draggable"),K.removeAttribute("data-grid-drop-target"),K.setAttribute("data-grid-preview",e),K.setAttribute("aria-hidden","true"),K.setAttribute("inert","");const ie=[K,...K.querySelectorAll("*")],ye=new Map(ie.filter(he=>he.id).map(he=>[he.id,`${he.id}-${ee}`]));for(const he of ie){he.id&&(he.id=ye.get(he.id));for(const ge of[...he.attributes]){if(ge.name==="id")continue;let X=ge.value;for(const[H,be]of ye)X===`#${H}`&&(X=`#${be}`),X=X.split(`url(#${H})`).join(`url(#${be})`);X!==ge.value&&he.setAttribute(ge.name,X)}}if(Object.assign(K.style,{opacity:"0.35",zIndex:oe?"2147483647":"11",pointerEvents:"none",outline:"none",visibility:"visible"}),oe){const he=getComputedStyle(Q);K.setAttribute("data-grid-preview-floating",""),Object.assign(K.style,{position:"fixed",left:"0",top:"0",transformOrigin:"top left",font:he.font,color:he.color});for(const ge of ie)ge.removeAttribute("data-node-id"),ge.style.pointerEvents="none"}return K.querySelectorAll(".flow-sdk-node-animation, .flow-sdk-handle, .flow-sdk-property-port, [data-flow-collapse-control]").forEach(he=>he.remove()),(we=oe?document.body:Q.parentElement)==null||we.appendChild(K),ae.current=K,()=>{K.remove(),ae.current=void 0}},[e,ee,ne,oe]),j.useLayoutEffect(()=>{const Q=ae.current;if(!Q||!l)return;const{x:K,y:ie,size:ye}=l;if(oe&&_.current){const ge=_.current,X=ge.getBoundingClientRect(),H=X.width/ge.offsetWidth||1,be=X.height/ge.offsetHeight||1,J=X.left+(K-r)*H,xe=X.top+(ie-t)*be;Q.style.transform=`translate3d(${J}px, ${xe}px, 0) scale(${H}, ${be})`,Q.style.width=`${ge.offsetWidth}px`,Q.style.height=`${ge.offsetHeight}px`;return}const we=ye?Math.round(K-ye.w/2):K,he=ye?Math.round(ie-ye.h/2):ie;Q.style.transform=ye?`translate3d(${we}px, ${he}px, 0)`:`translate(-50%, -50%) translate3d(${we}px, ${he}px, 0)`,Q.style.width=ye?`${Math.round(K+ye.w/2)-we}px`:"",Q.style.height=ye?`${Math.round(ie+ye.h/2)-he}px`:"",ye&&(Q.style.setProperty("--flow-grid-width",`${ye.w}px`),Q.style.setProperty("--flow-grid-height",`${ye.h}px`),Q.style.setProperty("--flow-grid-font",`${Math.max(12,Math.min(48,ye.w/8,ye.h/5))}px`))},[l==null?void 0:l.x,l==null?void 0:l.y,(D=l==null?void 0:l.size)==null?void 0:D.w,(ce=l==null?void 0:l.size)==null?void 0:ce.h,oe,r,t]),j.useLayoutEffect(()=>{const Q=_.current;if(!Q)return;const K=()=>{const we=Ub(Q);I(he=>JSON.stringify(he)===JSON.stringify(we)?he:we),E==null||E(e,we)};K();const ie=new ResizeObserver(K);ie.observe(Q);const ye=Q.querySelector("[data-flow-node-surface]");return ye&&ie.observe(ye),()=>ie.disconnect()},[e,M,E]),j.useLayoutEffect(()=>(d(e,_.current),()=>{d(e,null),E==null||E(e,void 0)}),[e,d,E]),j.useLayoutEffect(()=>{const Q=_.current;if(!Q)return;let K="";const ie=()=>{const ge=qj(Q),X=R?ge:ge.filter(be=>be.anchor),H=JSON.stringify(X);H!==K&&(K=H,$(X),T==null||T(e,X))};if(ie(),!R&&!Q.querySelector("[data-flow-port-side]"))return;const ye=new ResizeObserver(ie),we=()=>{ye.disconnect(),ye.observe(Q),Q.querySelectorAll("[data-flow-property]").forEach(ge=>ye.observe(ge)),ie()};we();const he=new MutationObserver(we);return he.observe(Q,{childList:!0,subtree:!0,characterData:!0,attributes:!0,attributeFilter:["data-flow-property","data-flow-port-role","data-flow-port-side","data-flow-port-position","data-flow-port-placement"]}),Q.addEventListener("scroll",ie,!0),()=>{ye.disconnect(),he.disconnect(),Q.removeEventListener("scroll",ie,!0)}},[e,R,T,M]);const pe=c?Math.round(r-c.w/2):0,q=c?Math.round(t-c.h/2):0,F=c?Math.round(r+c.w/2)-pe:void 0,G=c?Math.round(t+c.h/2)-q:void 0;return f.jsxs("div",{ref:_,className:"flow-sdk-node","data-node-id":e,"data-grid-draggable":i||void 0,"data-grid-dragging":s||void 0,"data-grid-drop-target":a||void 0,"data-grid-fill":c?"":void 0,style:{transform:c?`translate3d(${pe}px, ${q}px, 0)`:`translate(-50%, -50%) translate3d(${r.toFixed(2)}px, ${t.toFixed(2)}px, 0)`,visibility:n&&!o?void 0:"hidden",cursor:i?s?"grabbing":"grab":void 0,zIndex:s?12:void 0,opacity:l?0:s?.75:void 0,outline:a?`2px solid ${y||"currentColor"}`:void 0,outlineOffset:a?8:void 0,width:F,height:G,...c?{"--flow-grid-width":`${c.w}px`,"--flow-grid-height":`${c.h}px`,"--flow-grid-font":`${Math.max(12,Math.min(48,c.w/8,c.h/5))}px`}:{}},children:[M,!c&&b&&v>0&&C>0&&S>0&&f.jsx("svg",{className:"flow-sdk-node-animation","aria-hidden":"true",pointerEvents:"none",children:f.jsx(so,{variant:w,x:((N==null?void 0:N.left)??0)+v/2,y:((N==null?void 0:N.top)??0)+v/2,width:((N==null?void 0:N.width)??C)-v,height:((N==null?void 0:N.height)??S)-v,radius:((N==null?void 0:N.radius)??0)-v/2,path:N!=null&&N.outline?`M${N.outline.map(Q=>`${Q.x} ${Q.y}`).join(" L")} Z`:void 0,color:x||y||"currentColor",strokeWidth:v})}),u&&R&&B.map(Q=>["source","target"].filter(K=>!Q.role||Q.role===K).filter(K=>h||(p==null?void 0:p.has(`${K}:${Q.property}`))).map(K=>{var ie;return f.jsx("button",{type:"button",className:"flow-sdk-property-port","data-property":Q.property,"data-port-role":K,"data-port-side":(ie=Q.anchor)==null?void 0:ie.side,"aria-label":`${K==="source"?"Connect":"Input"} ${Q.property}`,title:`${K==="source"?"Connect":"Input"} ${Q.property}`,style:{color:y,...Q.anchor?{top:Q.anchor.y,left:Q.anchor.x-16}:{top:Q.top+Q.height/2,[K==="source"!=!!P?"right":"left"]:-16}},onClick:ye=>ye.stopPropagation()},`${Q.property}:${K}`)})),u&&!g&&(!R||!B.length)&&(!R||!B.some(Q=>Q.anchor))&&f.jsx("button",{type:"button",className:"flow-sdk-handle","aria-label":"Draw edge",title:"Draw edge",style:{color:y,left:((N==null?void 0:N.left)??0)+(k==="RL"?-36:k==="LR"?(N==null?void 0:N.width)??C:((N==null?void 0:N.width)??C)/2),top:((N==null?void 0:N.top)??0)+(k==="BT"?-36:k==="TB"?(N==null?void 0:N.height)??S:((N==null?void 0:N.height)??S)/2),transform:k==="BT"||k==="TB"?"translateX(-50%)":"translateY(-50%)"},onClick:Q=>Q.stopPropagation(),children:f.jsx(Y.PiPlusBold,{size:24})})]})}const Fj=j.memo(Lj);function zj(e,r,t){const[n,o]=j.useState(()=>({nodes:new Set,edges:new Set})),i=j.useMemo(()=>{const a=new Set(e.map(p=>p.id)),c=r.filter(p=>a.has(p.source)&&a.has(p.target)).map(p=>({id:p.id,source:p.inverted?p.target:p.source,target:p.inverted?p.source:p.target})),l=new Set(c.map(p=>p.id)),d=new Set([...n.nodes].filter(p=>a.has(p))),u=new Set([...n.edges].filter(p=>l.has(p)));if(!t)return{nodes:a,edges:l,ready:l};for(const p of e)c.filter(g=>g.target===p.id&&g.source!==g.target).every(g=>u.has(g.id))&&d.add(p.id);let h=new Set(c.filter(p=>d.has(p.source)).map(p=>p.id));if(d.size<a.size&&!c.some(p=>h.has(p.id)&&!u.has(p.id))){const p=e.find(m=>!d.has(m.id));p&&d.add(p.id),h=new Set(c.filter(m=>d.has(m.source)).map(m=>m.id))}return{nodes:d,edges:u,ready:h}},[e,r,t,n]);j.useLayoutEffect(()=>{o(a=>{const c=t?i:{nodes:new Set,edges:new Set},l=(d,u)=>d.size===u.size&&[...d].every(h=>u.has(h));return l(a.nodes,c.nodes)&&l(a.edges,c.edges)?a:{nodes:c.nodes,edges:c.edges}})},[i,t]);const s=j.useCallback(a=>{o(c=>c.edges.has(a)?c:{...c,edges:new Set([...c.edges,a])})},[]);return{shown:i.nodes,ready:i.ready,complete:s}}class Bj{constructor(r,t,n){qt(this,"_pan");qt(this,"_zoom");qt(this,"minZoom");qt(this,"maxZoom");qt(this,"size",{w:0,h:0});qt(this,"listeners",new Set);qt(this,"cancelTransition");qt(this,"animationVersion",0);qt(this,"captureTransition");qt(this,"animationsDisabled",!1);qt(this,"finishTransition");this.minZoom=t,this.maxZoom=n,this._pan={...r.pan},this._zoom=this.clamp(r.zoom)}setAnimationsDisabled(r){var t;r!==this.animationsDisabled&&(this.animationsDisabled=r,r&&((t=this.finishTransition)==null||t.call(this),this.cancelAnimation()))}cancelAnimation(){var r;(r=this.cancelTransition)==null||r.call(this),this.cancelTransition=void 0,this.finishTransition=void 0,this.animationVersion++}coordinate(r){let t;this.captureTransition=n=>{t=n};try{r()}finally{this.captureTransition=void 0}return t}transition(r,t=!1){this.cancelAnimation();const n=this.state,o={pan:{...r.pan},zoom:this.clamp(r.zoom)},i=this.animationVersion,s=Bb(t,this.animationsDisabled),a=c=>{if(i!==this.animationVersion)return;const l=s?c:1;this.apply({x:n.pan.x+(o.pan.x-n.pan.x)*l,y:n.pan.y+(o.pan.y-n.pan.y)*l},n.zoom+(o.zoom-n.zoom)*l)};this.finishTransition=()=>a(1),this.captureTransition?this.captureTransition(a):this.cancelTransition=Db(s,a,void 0,300/1.4)}get pan(){return{...this._pan}}get zoom(){return this._zoom}get state(){return{pan:this.pan,zoom:this._zoom}}clamp(r){return Number.isFinite(r)?Math.max(this.minZoom,Math.min(this.maxZoom,r)):this.minZoom}set(r,t){this.cancelAnimation(),this.apply(r,t)}apply(r,t){let n=!1;if(r&&(r.x!==this._pan.x||r.y!==this._pan.y)&&(this._pan={x:r.x,y:r.y},n=!0),t!==void 0){const o=this.clamp(t);o!==this._zoom&&(this._zoom=o,n=!0)}n&&this.emit()}zoomAt(r,t){const n=this.clamp(r),o=this._zoom;if(n===o)return;const i=n/o;this.set({x:t.x-(t.x-this._pan.x)*i,y:t.y-(t.y-this._pan.y)*i},n)}fit(r,t=0,n=!1,o=1){const i=r.x2-r.x1,s=r.y2-r.y1;if(!(i>0)||!(s>0)||!this.size.w||!this.size.h)return;const a=this.clamp(this.clamp(Math.min((this.size.w-2*t)/i,(this.size.h-2*t)/s))*o);this.transition({pan:{x:(this.size.w-a*(r.x1+r.x2))/2,y:(this.size.h-a*(r.y1+r.y2))/2},zoom:a},n)}center(r,t=!1){if(!this.size.w||!this.size.h)return;const n=this._zoom;this.transition({pan:{x:(this.size.w-n*(r.x1+r.x2))/2,y:(this.size.h-n*(r.y1+r.y2))/2},zoom:n},t)}renderedToModel(r){return{x:(r.x-this._pan.x)/this._zoom,y:(r.y-this._pan.y)/this._zoom}}modelToRendered(r){return{x:r.x*this._zoom+this._pan.x,y:r.y*this._zoom+this._pan.y}}onChange(r){return this.listeners.add(r),()=>{this.listeners.delete(r)}}emit(){const r=this.state;this.listeners.forEach(t=>t(r))}}const Dj={LR:"rightward",RL:"leftward",TB:"downward",BT:"upward"},eo={w:60,h:60},hd=4,Wj=30,Vj=500,Gj=45;function Em(e){const[r,t]=[...e.values()];return!r||!t?null:{center:{x:(r.x+t.x)/2,y:(r.y+t.y)/2},distance:Math.max(1,Math.hypot(t.x-r.x,t.y-r.y))}}function Uj(e){var xu,vu,wu,Cu,Su;const{nodes:r,edges:t,direction:n,nodeAlignment:o="center",edgeMode:i="auto",compactPropertyLayout:s=!1,rankSep:a,edgeSep:c,spacingFactor:l=1.3,compactSpacingScale:d,minZoom:u,maxZoom:h,initialViewport:p,containerStyle:m,lineColor:g,drawMode:y,dragMode:b,multiSelect:x,isPerformanceMode:v,disableAnimations:w=!1}=e,[C,S]=j.useState(null),R=j.useMemo(()=>C?(C.mode==="connections"?Xu:Gu)(C.id,r,t):null,[C,r,t]),P=i==="auto"||i==="properties",k=j.useMemo(()=>t.filter(A=>wd(A,i)&&(!R||R.has(A.source)&&R.has(A.target))),[t,i,R]),T=j.useMemo(()=>d1(r,t,i,s,R),[r,t,i,s,R]),E=j.useRef(T);E.current=T;const M=j.useRef(e);M.current=e;const _=j.useRef(null),O=j.useRef(null),$=j.useRef(null),B=j.useRef(null),N=j.useMemo(()=>new Bj(p,u,h),[]);j.useEffect(()=>{N.minZoom=u,N.maxZoom=h},[N,u,h]),j.useLayoutEffect(()=>{N.setAnimationsDisabled(w)},[N,w]);const I=j.useRef(new Map),ee=j.useRef(new Map),ae=j.useRef(new Map),ne=j.useRef(null),[oe,pe]=j.useState(new Map),q=j.useCallback((A,L)=>{pe(z=>{if(JSON.stringify(z.get(A))===JSON.stringify(L))return z;const Z=new Map(z);return L?Z.set(A,L):Z.delete(A),Z})},[]),[F,G]=j.useState(new Map),D=j.useRef(F),ce=j.useCallback((A,L)=>{G(z=>{if(JSON.stringify(z.get(A)??[])===JSON.stringify(L))return z;const Z=new Map(z);return L.length?Z.set(A,L):Z.delete(A),Z})},[]),[Q,K]=j.useState(()=>new Map),ie=j.useRef(Q);ie.current=Q;const[ye,we]=j.useState(new Map),he=j.useRef(ye),ge=()=>{he.current=new Map,we(he.current)},X=j.useRef(new Map),H=j.useRef(null),be=j.useRef(!1),[J,xe]=j.useState(0),Se=j.useRef(),Fe=j.useRef(),De=j.useRef(null),ue=j.useRef(),Re=j.useRef(!1),ze=j.useRef(null),Te=j.useRef(null),qe=j.useRef(),Qe=j.useRef(l),ct=s,Pe=j.useRef(ct),[Je,Ye]=j.useState(!0),[nt,Nt]=j.useState(!!((xu=e.initialNodeGrid)!=null&&xu.enabled)),[Rt,Wr]=j.useState([]),rt=j.useRef((vu=e.initialNodeGrid)!=null&&vu.enabled?{options:{...e.initialNodeGrid.options,animate:!1},order:[...e.initialNodeGrid.order??e.initialNodeGrid.options.order??r.map(A=>A.id)],previousPositions:new Map,previousViewport:p,previousSize:{w:0,h:0},ready:!1}:null),[Ke,Zt]=j.useState(null),ft=j.useRef(null);ft.current=R;const jr=j.useRef(1);jr.current=(C==null?void 0:C.mode)==="connections"?1.25:1;const Pt=j.useRef(null),Er=j.useRef(r),Wt=j.useRef([]),Xt=j.useRef(!1),ar=()=>{var A;(A=De.current)==null||A.call(De),De.current=null,ue.current=void 0},Ve=()=>{Te.current=null,Wt.current.length&&(Xt.current=!0),!be.current&&M.current.fitOnInit!==!1&&(Re.current=!0),clearTimeout(Fe.current),Fe.current=setTimeout(()=>{be.current=ie.current.size>0,xe(A=>A+1)},Vj)},de=(A,L,z,Z=Ve,fe)=>{ar();const Ie=new Map(ie.current),_e=new Map([...I.current,...he.current]);De.current=Db(L,ke=>{const et=new Map;if(A.forEach((ve,$e)=>{const Ge=Ie.get($e);et.set($e,Ge?{x:Ge.x+(ve.x-Ge.x)*ke,y:Ge.y+(ve.y-Ge.y)*ke}:ve)}),ie.current=et,K(et),fe){const ve=new Map;for(const[$e,Ge]of fe){const te=_e.get($e)??Ge;ve.set($e,{w:te.w+(Ge.w-te.w)*ke,h:te.h+(Ge.h-te.h)*ke})}he.current=ve,we(ve)}z==null||z(ke)},Z)},V=()=>{var et;if(clearTimeout(Se.current),rt.current){mt.arrangeNodesInGrid(rt.current.options);return}he.current.size&&ge();const A=M.current,L=jr.current,z=E.current,Z=z.nodes.map(ve=>{const $e=ee.current.get(ve.id);$e&&($e.offsetWidth||$e.offsetHeight)&&I.current.set(ve.id,{w:$e.offsetWidth,h:$e.offsetHeight});const Ge=I.current.get(ve.id)||eo;return{id:ve.id,parent:ve.parent,width:Ge.w,height:Ge.h}});let fe;try{const ve=A.compactPropertyLayout,$e=A.edgeMode!=="nodes"&&A.edgeMode!=="workflow",Ge=z.edges.map(te=>({...te,connectorClearance:ve?$e&&(te.sourceProperty!==void 0||te.targetProperty!==void 0)?l1:c1:0}));fe=Ij(Z,Ge,{edgeLabelFontSize:A.edgeMode==="nodes"||A.edgeMode==="workflow"?Hb:co,rankDir:A.direction,compact:ve,nodeAlignment:A.nodeAlignment,rankSep:A.rankSep*L,edgeSep:A.edgeSep*L,nodeSep:5*L,spacingFactor:A.spacingFactor??1.3,compactSpacingScale:(A.compactSpacingScale??(A.spacingFactor??1.3)/1.3)*L})}catch(ve){console.warn("[flow-sdk] layout failed",ve);return}const Ie=Te.current?null:H.current;H.current=null;const _e=Ie&&fe.get(Ie.id);if(Ie&&_e){const ve={x:Ie.position.x-_e.x,y:Ie.position.y-_e.y};fe=new Map([...fe].map(([$e,Ge])=>[$e,{x:Ge.x+ve.x,y:Ge.y+ve.y}]))}for(const[ve,$e]of X.current)fe.has(ve)?fe.set(ve,$e):A.nodes.some(Ge=>Ge.id===ve)||X.current.delete(ve);if(Te.current){const ve=JSON.stringify([Z,[...fe],N.size,A.isPerformanceMode,A.disableAnimations]);if(((et=qe.current)==null?void 0:et.focus)===Te.current&&qe.current.geometry===ve)return;qe.current={focus:Te.current,geometry:ve}}else qe.current=void 0;const ke=N.coordinate(()=>{var ve;return(ve=Te.current)==null?void 0:ve.call(Te,fe)});de(fe,be.current&&!A.isPerformanceMode&&!A.disableAnimations,ke)},se=j.useCallback(()=>{clearTimeout(Fe.current),clearTimeout(Se.current),Se.current=setTimeout(V,M.current.layoutDebounce)},[]);j.useLayoutEffect(()=>{const A=new Map(Er.current.map(L=>[L.id,L]));r.some(L=>{var z;return((z=A.get(L.id))==null?void 0:z.collapsed)===!0&&!L.collapsed})&&(Wt.current=r.filter(L=>!A.has(L.id)).map(L=>L.id)),Er.current=r,Qe.current!==l&&ie.current.size>0&&(be.current=!0,Re.current=!1,clearTimeout(Fe.current)),Qe.current=l,Pe.current!==ct&&(Re.current=!ze.current),Pe.current=ct,se()},[r,t,T.nodes,T.edges,ct,n,o,a,c,se,l,d,w,e.nodeGridSpacing]),j.useEffect(()=>()=>{clearTimeout(Se.current),clearTimeout(Fe.current),ar()},[]);const Be=j.useCallback((A,L)=>{var z,Z;if(!ne.current&&typeof ResizeObserver<"u"&&(ne.current=new ResizeObserver(fe=>{let Ie=!1;for(const _e of fe){const ke=ae.current.get(_e.target);if(!ke||he.current.has(ke))continue;const et=_e.target,ve=et.offsetWidth,$e=et.offsetHeight;if(!ve&&!$e)continue;const Ge=I.current.get(ke);if(Ge&&Ge.w===ve&&Ge.h===$e)continue;const te=ie.current.get(ke);Ge&&te&&be.current&&!H.current&&(H.current={id:ke,position:{...te}}),I.current.set(ke,{w:ve,h:$e}),Ie=!0}Ie&&se()})),L){ee.current.set(A,L),ae.current.set(L,A),(z=ne.current)==null||z.observe(L);const fe=L.offsetWidth,Ie=L.offsetHeight;!he.current.has(A)&&(fe||Ie)&&I.current.set(A,{w:fe,h:Ie})}else{const fe=ee.current.get(A);fe&&((Z=ne.current)==null||Z.unobserve(fe),ae.current.delete(fe)),ee.current.delete(A),I.current.delete(A),D.current.has(A)&&ce(A,[])}se()},[se,ce]);j.useEffect(()=>()=>{var A;return(A=ne.current)==null?void 0:A.disconnect()},[]);const U=A=>{var Z;const L=(Z=M.current.nodes.find(fe=>fe.id===A))==null?void 0:Z.label;if(!L)return;const z=M.current.containerStyle(A);return{w:Co(L,`bold ${z.fontSize}px ${mr}`)+2*Gj,h:0}},Ce=j.useMemo(()=>{const A=new Map;for(const L of r)L.label&&A.set(L.id,L.label);return A},[r]),Oe=j.useMemo(()=>Cd(T.nodes,Q,new Map([...I.current,...ye]),A=>m(A).padding,U,ye),[T.nodes,Q,m,Ce,ye]),je=j.useRef(Oe);je.current=Oe;const We=j.useCallback(A=>{const L=je.current.get(A);if(L)return Kw(L);const z=ie.current.get(A);if(!z)return;const Z=he.current.get(A)||I.current.get(A)||eo;return{x:z.x,y:z.y,w:Z.w,h:Z.h}},[]),ot=j.useMemo(()=>{const A=new Map;for(const L of r){const z=We(L.id);z&&A.set(L.id,z)}return n1(F,A,oe,t,n)},[F,r,Q,Oe,oe,t,n,We]);D.current=ot;const Xe=(A,L)=>{var fe;if(!P||L===void 0)return;const z=(fe=ot.get(A))==null?void 0:fe.find(Ie=>Ie.property===L),Z=We(A);return z&&!z.anchor&&Z?Z.y-Z.h/2+z.top+z.height/2:void 0},St=(A,L)=>{var fe,Ie;if(L===void 0)return;const z=(Ie=(fe=ot.get(A))==null?void 0:fe.find(_e=>_e.property===L))==null?void 0:Ie.anchor,Z=We(A);return z&&Z?{x:Z.x-Z.w/2+z.x,y:Z.y-Z.h/2+z.y,side:z.side}:void 0},kt=(A,L)=>{const z=We(A),Z=oe.get(A);return z&&Z&&!Oe.has(A)&&Xe(A,L)===void 0?Pn(z,(n==="TB"||n==="BT")&&Z.captionBottom!==void 0?{...Z,height:Math.max(Z.height,Z.captionBottom-Z.top),outline:void 0}:Z):z},Ot=()=>{const A=[];ie.current.forEach((L,z)=>{if(je.current.has(z))return;const Z=We(z);Z&&A.push(tr(Z))}),je.current.forEach(L=>A.push(L));try{for(const L of[O.current,$.current]){const z=L==null?void 0:L.getBBox();z&&z.width>0&&z.height>0&&A.push({x1:z.x,y1:z.y,x2:z.x+z.width,y2:z.y+z.height})}}catch{}return Ho(A)},$t=()=>{var z,Z;const{pan:A,zoom:L}=N;B.current&&(B.current.style.transform=`translate3d(${A.x}px, ${A.y}px, 0) scale(${L})`),(z=O.current)==null||z.setAttribute("transform",`translate(${A.x} ${A.y}) scale(${L})`),(Z=$.current)==null||Z.setAttribute("transform",`translate(${A.x} ${A.y}) scale(${L})`)};j.useEffect(()=>{$t();let A=null,L;const z=N.onChange(()=>{$t();const Z=_.current;Z&&(Z.classList.add("flow-sdk-busy"),clearTimeout(L),L=setTimeout(()=>Z.classList.remove("flow-sdk-busy"),150)),A===null&&(A=requestAnimationFrame(()=>{var fe,Ie;A=null,(Ie=(fe=M.current).onViewportChange)==null||Ie.call(fe,N.state)}))});return()=>{z(),clearTimeout(L),A!==null&&cancelAnimationFrame(A)}},[]),j.useLayoutEffect(()=>{const A=_.current;if(!A)return;const L=()=>{var _e;if(!A.getClientRects().length)return;let Z=A.clientWidth,fe=A.clientHeight;fe||(fe=Math.max(0,window.innerHeight-A.getBoundingClientRect().top-100),fe&&(A.style.height=`${fe}px`)),Z||(Z=window.innerWidth,Z&&(A.style.width=`${Z}px`));const Ie=N.size.w!==Z||N.size.h!==fe;N.size={w:Z,h:fe},Ie&&((_e=rt.current)!=null&&_e.options.fill)&&(!be.current&&Z>0&&fe>0?V():se()),!be.current&&!ie.current.size&&M.current.fitOnInit!==!1&&(N.set({x:Z/2,y:fe/2}),$t())};if(L(),typeof ResizeObserver>"u")return;const z=new ResizeObserver(L);return z.observe(A),()=>z.disconnect()},[N]),j.useLayoutEffect(()=>{if(Xt.current){Xt.current=!1;const L=Wt.current.flatMap(Z=>{const fe=We(Z);return fe?[tr(fe)]:[]});Wt.current=[];const z=Ho(L);if(z){Re.current=!1,N.center(z,M.current.animateViewport);return}}if(!Re.current)return;Re.current=!1;const A=Ot();A&&(N.fit(A,50,be.current&&M.current.animateViewport),be.current||$t())},[Q]);const mt=j.useMemo(()=>{const A=te=>{const re=M.current;if(re.nodeGridSpacing!=="layout")return te;const me=re.direction==="LR"||re.direction==="RL";return{...te,gaps:{x:me?re.rankSep:re.edgeSep,y:me?re.edgeSep:re.rankSep}}},L=()=>{const te=M.current,re=E.current.nodes.filter(me=>rr(me.id,te.edges,te.edgeMode)&&(!ft.current||ft.current.has(me.id)));return{nodes:re,positions:ie.current,sizes:new Map(re.map(me=>[me.id,I.current.get(me.id)??eo])),padding:me=>M.current.containerStyle(me).padding,minSize:U,fixedIds:new Set(X.current.keys()),viewportSize:{...N.size}}},z=te=>Gu(te,M.current.nodes,M.current.edges),Z=(te,re=!0,me=()=>{},le,Ue,Ee=!1)=>{clearTimeout(Se.current),clearTimeout(Fe.current),Ee||(Te.current=null),ze.current=null,Re.current=!1,Wt.current=[],Xt.current=!1;const Ae=re&&!M.current.isPerformanceMode&&!M.current.disableAnimations,tt=N.coordinate(()=>{var it;le?le(Ae):Ee&&((it=Te.current)==null||it.call(Te,te))});de(new Map([...te].map(([it,st])=>[it,{...st}])),Ae,tt,me,Ue)},fe=(te,re=50,me=M.current.animateViewport,le=1,Ue=!1,Ee)=>{const Ae=tt=>{const it=E.current,st=te??new Set(it.nodes.map(gt=>gt.id)),Yt=new Set(it.nodes.map(gt=>gt.parent).filter(Boolean));if(!tt&&(!te||[...te].some(gt=>Yt.has(gt))))return;const sr=tt&&Cd(it.nodes,tt,I.current,gt=>M.current.containerStyle(gt).padding,U),hn=new Map([...st].flatMap(gt=>{const er=sr==null?void 0:sr.get(gt);if(er)return[[gt,er]];const Vt=tt==null?void 0:tt.get(gt),fr=I.current.get(gt)||eo,ju=Vt?{...Vt,...fr}:We(gt);return ju?[[gt,tr(ju)]]:[]}));let Qt=Ho([...hn.values()]);if(!Qt)return;const ur=Ee?hn.get(Ee):void 0;if(ur){const gt=(ur.x1+ur.x2)/2,er=(ur.y1+ur.y2)/2,Vt=Math.max(gt-Qt.x1,Qt.x2-gt),fr=Math.max(er-Qt.y1,Qt.y2-er);Qt={x1:gt-Vt,x2:gt+Vt,y1:er-fr,y2:er+fr}}Re.current=!1,Wt.current=[],Xt.current=!1,N.fit(Qt,Number.isFinite(re)?Math.max(0,re):50,me,le)};Te.current=Ue?Ae:null,Ue||Ae(ie.current)},Ie=(te,re,me,le)=>{var Ee;if(!We(te))return;const Ue=re==="connections"?ke(te):z(te);if(re==="connections"&&jr.current===1.25&&((Ee=ft.current)==null?void 0:Ee.size)===Ue.size&&[...Ue].every(Ae=>ft.current.has(Ae))){S({id:te,mode:re});return}Pt.current||(Pt.current={pan:{...N.pan},zoom:N.zoom}),ft.current=Ue,M.current.compactPropertyLayout&&(Re.current=!1,ze.current=()=>fe(ft.current??Ue,me,le)),S({id:te,mode:re}),M.current.compactPropertyLayout||fe(Ue,me,le)},_e=te=>{ze.current?ze.current=te:te()},ke=te=>Xu(te,M.current.nodes,M.current.edges),et=(te=>{var re,me,le;if(te===void 0)return N.zoom;te<N.zoom&&((re=rt.current)!=null&&re.options.fill)&&!M.current.readOnly&&((le=(me=M.current).onNodeGridZoomOut)==null?void 0:le.call(me,rt.current.options))===!0||(Te.current=null,N.set(void 0,te))}),ve=(te=>{if(te===void 0)return N.pan;Te.current=null,N.set(te)}),$e=(te,re)=>{var le;const me=(le=_.current)==null?void 0:le.getBoundingClientRect();return{x:te-((me==null?void 0:me.left)??0),y:re-((me==null?void 0:me.top)??0)}},Ge=(te=0,re=M.current.animateViewport,me=!1)=>{if(me){fe(void 0,te,re,1,!0);return}Te.current=null,_e(()=>{const le=Ot();le&&N.fit(le,te,re)})};return{zoom:et,pan:ve,setEdgesVisible:Ye,focusNode:(te,re,me,le)=>_e(()=>fe(new Set([te]),re,me,.6,le)),focusBranch:(te,re,me,le,Ue=!1,Ee=1)=>_e(()=>fe(z(te),re,me,Ee,le,Ue?te:void 0)),focusConnections:(te,re,me,le)=>_e(()=>fe(ke(te),re,me,1,le)),isolateConnections:(te,re,me)=>Ie(te,"connections",re,me),isolateBranch:(te,re,me)=>Ie(te,"branch",re,me),restoreView:(te=M.current.animateViewport,re,me=!1)=>{Te.current=null;const le=me&&!rt.current&&!ft.current,Ue=M.current.compactPropertyLayout&&!!ft.current;ft.current=null,S(null);const Ee=re??Pt.current;Pt.current=null,Ee&&le?(Re.current=!1,ze.current=null,H.current=null,Te.current=()=>N.transition(Ee,te),se()):Ue?ze.current=()=>{Ee&&N.transition(Ee,te)}:Ee&&_e(()=>N.transition(Ee,te))},zoomAt:(te,re)=>{var me,le,Ue;te<N.zoom&&((me=rt.current)!=null&&me.options.fill)&&!M.current.readOnly&&((Ue=(le=M.current).onNodeGridZoomOut)==null?void 0:Ue.call(le,rt.current.options))===!0||(Te.current=null,N.zoomAt(te,re))},fit:Ge,centerAndFit:Ge,center:(te=M.current.animateViewport)=>{Te.current=null;const re=Ot();re&&N.center(re,te)},clientToModel:(te,re)=>N.renderedToModel($e(te,re)),modelToClient:te=>{var le;const re=(le=_.current)==null?void 0:le.getBoundingClientRect(),me=N.modelToRendered(te);return{x:me.x+((re==null?void 0:re.left)??0),y:me.y+((re==null?void 0:re.top)??0)}},getNodeBox:te=>We(te),detectNodeCollisions:te=>{const re=L();return Qx({...re,sizes:new Map([...re.sizes,...he.current]),fixedSizes:he.current},te)},resolveNodeCollisions:(te={})=>{const re=Oj(L(),te);return re.movedNodeIds.length&&Z(re.positions,te.animate),re},arrangeNodesInGrid:(te={})=>{const re=L(),me=rt.current;if(me){re.positions=new Map(re.positions);for(const st of re.nodes)re.positions.has(st.id)||re.positions.set(st.id,N.renderedToModel({x:N.size.w/2,y:N.size.h/2}));const Ae=new Set(re.nodes.map(st=>st.id));me.order=me.order.filter(st=>Ae.has(st));const tt=new Set(me.order);me.order.push(...re.nodes.filter(st=>!tt.has(st.id)).map(st=>st.id));const it=new Map(me.order.map((st,Yt)=>[st,Yt]));re.nodes=[...re.nodes].sort((st,Yt)=>it.get(st.id)-it.get(Yt.id))}const le=ud(re,A(te)),Ue=le.sizes?JSON.stringify([[...le.positions],[...le.sizes]]):void 0;if(Ue&&Ue===ue.current&&te.animate!==!1&&!Te.current)return le;Wr(le.dividers??[]),me&&(me.ready=!1);const Ee=()=>{me&&(me.ready=!0),me&&re.nodes.length&&!be.current&&(be.current=!0,M.current.fitOnInit!==!1&&!te.fill?mt.centerAndFit(50,!1):M.current.fitOnInit===!1&&N.transition(p,!1)),xe(Ae=>Ae+1)};return!le.sizes&&he.current.size&&ge(),re.nodes.some(Ae=>!ie.current.has(Ae.id))||le.movedNodeIds.length||le.bounds||Te.current?Z(le.positions,te.animate,Ee,le.bounds&&(!me||!he.current.size)?Ae=>N.transition({zoom:1,pan:{x:0,y:0}},Ae):void 0,le.sizes,!!me&&!le.bounds):Ee(),ue.current=Ue,le},setNodeGridMode:(te,re={})=>{var me,le,Ue,Ee;if(re.order&&(!Array.isArray(re.order)||re.order.some(Ae=>typeof Ae!="string")||new Set(re.order).size!==re.order.length))throw new Error("Invalid grid node order.");if(te){ud(L(),A(re));const Ae=!rt.current||rt.current.options.fill&&!re.fill;Te.current=null,rt.current||(rt.current={options:re,order:L().nodes.map(tt=>tt.id),previousPositions:new Map([...ie.current].map(([tt,it])=>[tt,{...it}])),previousViewport:{zoom:N.zoom,pan:{...N.pan}},previousSize:{...N.size},ready:!1}),Ae&&mt.centerAndFit(80,re.animate,!0),re.order&&(rt.current.order=[...re.order]),rt.current.options={...re},Nt(!0),mt.arrangeNodesInGrid(re),(le=(me=M.current).onNodeGridModeChange)==null||le.call(me,{...re,order:[...rt.current.order]})}else{const Ae=rt.current;if(!Ae)return;if(N.size.w===Ae.previousSize.w&&N.size.h===Ae.previousSize.h&&ie.current.size===Ae.previousPositions.size&&[...ie.current.keys()].every(st=>Ae.previousPositions.has(st))?Te.current=()=>N.transition(Ae.previousViewport,re.animate!==!1&&!M.current.disableAnimations&&!M.current.isPerformanceMode):mt.centerAndFit(80,re.animate,!0),rt.current=null,Nt(!1),ge(),(Ee=(Ue=M.current).onNodeGridModeChange)==null||Ee.call(Ue,null),Zt(null),!Ae.previousPositions.size){se();return}const it=new Map([...ie.current].map(([st,Yt])=>[st,Ae.previousPositions.get(st)??Yt]));Z(it,re.animate,void 0,void 0,void 0,!0)}},swapGridNodes:(te,re,me)=>{var hn,Qt,ur,gt,er;const le=rt.current;if(!le||!le.ready||M.current.readOnly||te===re)return!1;const Ue=L(),Ee=Ue.nodes.find(Vt=>Vt.id===te),Ae=Ue.nodes.find(Vt=>Vt.id===re);if(!Ee||!Ae||Ee.parent!==Ae.parent)return!1;const tt=ud(Ue,A(le.options));if(tt.skippedNodeIds.includes(te)||tt.skippedNodeIds.includes(re))return!1;const it=le.order.indexOf(te),st=le.order.indexOf(re);if(it<0||st<0)return!1;[le.order[it],le.order[st]]=[le.order[st],le.order[it]],Te.current=null,le.options={...le.options,order:[...le.order]};const Yt=Ee.parent??"canvas",sr=(Qt=(hn=le.options.adjustment)==null?void 0:hn.sections)==null?void 0:Qt[Yt];return sr!=null&&sr.members&&(le.options={...le.options,adjustment:{...le.options.adjustment,sections:{...(ur=le.options.adjustment)==null?void 0:ur.sections,[Yt]:{...sr,members:sr.members.map(Vt=>Vt.map(fr=>fr===te?re:fr===re?te:fr))}}}}),mt.arrangeNodesInGrid({...le.options,animate:me??le.options.animate}),(er=(gt=M.current).onNodeGridModeChange)==null||er.call(gt,{...le.options}),!0},setNodePosition:(te,re,me)=>{if(!ie.current.has(te)||re&&(!Number.isFinite(re.x)||!Number.isFinite(re.y)))return!1;if(ar(),!re)return X.current.delete(te),se(),!0;const le=new Map(ie.current);return le.set(te,{...re}),(me==null?void 0:me.persist)===!1?X.current.delete(te):X.current.set(te,{...re}),ie.current=le,K(le),(me==null?void 0:me.persist)===!1&&se(),!0},onViewportChange:te=>N.onChange(te)}},[]);j.useEffect(()=>{var A,L;return(L=(A=M.current).onInit)==null||L.call(A,mt),()=>N.cancelAnimation()},[mt]),j.useEffect(()=>{var A,L;if(J>0){const z=ze.current;ze.current=null,z==null||z(),(L=(A=M.current).onLayoutComplete)==null||L.call(A,mt)}},[mt,J]);const ht=j.useRef(null),jt=j.useRef(new Map),_r=j.useRef(!1),[Rr,Kn]=j.useState(null),[ut,un]=j.useState(null),Jn=A=>{const L=_.current.getBoundingClientRect();return{x:(A.clientX-L.left)*(_.current.clientWidth/L.width||1),y:(A.clientY-L.top)*(_.current.clientHeight/L.height||1)}},Zn=(A,L)=>{const z=M.current.nodes;for(let Z=z.length-1;Z>=0;Z--){const fe=z[Z].id;if(!rr(fe,M.current.edges,M.current.edgeMode)||ft.current&&!ft.current.has(fe)||fe===L||je.current.has(fe))continue;const Ie=We(fe);if(Ie&&Uu(A,tr(Ie)))return fe}for(const[Z,fe]of je.current)if(rr(Z,M.current.edges,M.current.edgeMode)&&!(ft.current&&!ft.current.has(Z))&&Z!==L&&Uu(A,fe))return Z;return null},pu=(A,L)=>{const z=M.current.nodes.find(ke=>ke.id===A),Z=We(A);if(!z||!Z)return null;const fe=tr({...Z,x:Z.x+L.x,y:Z.y+L.y});let Ie=null,_e=0;for(const ke of M.current.nodes){if(ke.id===A||ke.parent!==z.parent||X.current.has(ke.id)||je.current.has(ke.id)||!rr(ke.id,M.current.edges,M.current.edgeMode)||ft.current&&!ft.current.has(ke.id))continue;const et=We(ke.id);if(!et)continue;const ve=tr(et),$e=Math.max(0,Math.min(fe.x2,ve.x2)-Math.max(fe.x1,ve.x1))*Math.max(0,Math.min(fe.y2,ve.y2)-Math.max(fe.y1,ve.y1));$e>_e&&(_e=$e,Ie=ke.id)}return Ie},gu=(A,L)=>{const z=rt.current;if(!(z!=null&&z.ready)||M.current.readOnly)return;const Z=M.current.nodes.filter($e=>rr($e.id,M.current.edges,M.current.edgeMode)&&(!ft.current||ft.current.has($e.id))),fe=Z.find($e=>$e.id===A);if(!fe)return;const Ie=_.current,_e=N.zoom*(Ie&&Ie.clientWidth?Ie.getBoundingClientRect().width/Ie.clientWidth:1),ke=24/_e;let et;for(const $e of Z){if($e.id===A||$e.parent!==fe.parent)continue;const Ge=We($e.id);if(!Ge)continue;const te=tr(Ge),re=Math.min(Ge.w/4,ke),me=Math.min(Ge.h/4,ke),le=3/_e,Ue=[];if(L.y>te.y1+me&&L.y<te.y2-me)for(const Ee of["before","after"]){const Ae=Ee==="before"?te.x1:te.x2,tt=Math.abs(L.x-Ae),it=Ee==="before"?L.x<Ae:L.x>Ae;tt<=(it?ke:re)&&Ue.push({side:Ee,distance:tt,marker:{x1:Ae-le/2,x2:Ae+le/2,y1:te.y1,y2:te.y2}})}if(L.x>=te.x1&&L.x<=te.x2)for(const Ee of["above","below"]){const Ae=Ee==="above"?te.y1:te.y2,tt=Math.abs(L.y-Ae),it=Ee==="above"?L.y<Ae:L.y>Ae;tt<=(it?ke:me)&&Ue.push({side:Ee,distance:tt,marker:{x1:te.x1,x2:te.x2,y1:Ae-le/2,y2:Ae+le/2}})}for(const Ee of Ue)(!et||Ee.distance<et.distance)&&(et={id:$e.id,...Ee})}if(!et)return;const ve=Tj({nodes:Z,positions:ie.current,sizes:new Map([...I.current,...he.current]),fixedSizes:he.current,padding:$e=>M.current.containerStyle($e).padding,minSize:U,fixedIds:new Set(X.current.keys())},z.options,A,et.id,et.side);return ve?{options:ve,marker:et.marker}:void 0},zo=(A,L)=>{if(M.current.edgeMode==="nodes"||M.current.edgeMode==="workflow")return null;const z=M.current.direction==="RL",Z=Math.max(16,6/N.zoom);let fe=null;for(const Ie of[...M.current.nodes].reverse()){if(!rr(Ie.id,M.current.edges,M.current.edgeMode)||ft.current&&!ft.current.has(Ie.id))continue;const _e=We(Ie.id),ke=D.current.get(Ie.id);if(!_e||!ke||je.current.has(Ie.id))continue;const et=_e.x+(L==="source"!==z?1:-1)*_e.w/2;for(const ve of ke){if(ve.role&&ve.role!==L)continue;const $e=_e.y-_e.h/2+ve.top,Ge=Math.hypot(A.x-(ve.anchor?_e.x-_e.w/2+ve.anchor.x:et),A.y-$e-ve.height/2);if(!ve.anchor&&A.x>=_e.x-_e.w/2&&A.x<=_e.x+_e.w/2&&A.y>=$e&&A.y<=$e+ve.height)return{nodeId:Ie.id,property:ve.property};Ge<=Z&&(!fe||Ge<fe.distance)&&(fe={nodeId:Ie.id,property:ve.property,distance:Ge})}}return fe},dv=A=>{var ke,et;if(!A.currentTarget.contains(A.target)||(ht.current||(_r.current=!1),A.target.closest(".flow-sdk-canvas")!==A.currentTarget)||A.button!==0||M.current.readOnly)return;const L=A.target;if(L.closest('input, textarea, select, [contenteditable="true"], [data-flow-content-toggle]'))return;const z=M.current,Z=Jn(A);if(A.pointerType==="touch"){jt.current.set(A.pointerId,Z);const ve=Em(jt.current);if(ve){Zt(null),ht.current={kind:"pinch",distance:ve.distance,zoom:N.zoom,anchor:N.renderedToModel(ve.center)},un(null),Kn(null),_r.current=!0;for(const $e of jt.current.keys())A.currentTarget.setPointerCapture($e);return}}if(ht.current)return;const fe=!rt.current||!!z.nodeGridConnections,Ie=z.drawHandles&&L.closest(".flow-sdk-handle"),_e=z.drawHandles&&L.closest(".flow-sdk-property-port");if((!fe||!Ie&&!_e&&(!z.drawMode||A.shiftKey))&&(rt.current||A.shiftKey&&(z.onNodeGridDrop||z.onNodeParentChange))){if(rt.current&&!rt.current.ready||L.closest("button, input, textarea, select, a, [contenteditable=true], [data-flow-content]"))return;const ve=(ke=L.closest("[data-node-id]"))==null?void 0:ke.dataset.nodeId;if(ve&&!X.current.has(ve)){L.setPointerCapture(A.pointerId),ht.current={kind:"grid",pointerId:A.pointerId,captureTarget:L,source:ve,start:Z,moved:!1};return}if(ve)return}if(fe&&(z.drawMode||Ie||_e)){const ve=N.renderedToModel(Z),$e=z.drawMode?zo(ve,"source"):null,Ge=_e||Ie,te=Ge?(et=Ge.closest("[data-node-id]"))==null?void 0:et.dataset.nodeId:($e==null?void 0:$e.nodeId)??Zn(ve),re=_e?_e.dataset.property:$e==null?void 0:$e.property;if(te){ht.current={kind:"draw",pointerId:A.pointerId,source:te,sourceProperty:re,reverse:(_e==null?void 0:_e.dataset.portRole)==="target",startClient:{x:A.clientX,y:A.clientY}},_r.current=!0,un({source:te,sourceProperty:re,point:ve,target:null}),A.currentTarget.setPointerCapture(A.pointerId);return}}L.closest(".flow-sdk-node, .flow-sdk-container, .flow-sdk-edge, .flow-sdk-edge-label, .flow-sdk-container-label")||(Te.current=null,z.multiSelect?ht.current={kind:"box",pointerId:A.pointerId,start:Z,current:Z}:z.dragMode?ht.current={kind:"pan",pointerId:A.pointerId,start:Z,pan0:N.pan,moved:!1}:ht.current={kind:"tap",pointerId:A.pointerId,start:Z,moved:!1},A.currentTarget.setPointerCapture(A.pointerId))},uv=A=>{var Z,fe,Ie;const L=ht.current;if(!L||M.current.readOnly)return;const z=Jn(A);if(jt.current.has(A.pointerId)&&jt.current.set(A.pointerId,z),L.kind==="pinch"){const _e=Em(jt.current);if(!_e)return;const ke=Math.max(N.minZoom,Math.min(N.maxZoom,L.zoom*_e.distance/L.distance));if(ke<N.zoom&&((Z=rt.current)!=null&&Z.options.fill)&&((Ie=(fe=M.current).onNodeGridZoomOut)==null?void 0:Ie.call(fe,rt.current.options))===!0)return;N.set({x:_e.center.x-L.anchor.x*ke,y:_e.center.y-L.anchor.y*ke},ke);return}if(L.pointerId===A.pointerId)switch(L.kind){case"grid":{const _e={x:z.x-L.start.x,y:z.y-L.start.y};if(!L.moved&&Math.hypot(_e.x,_e.y)<=hd)return;L.moved||(ar(),Te.current=null,N.cancelAnimation()),L.moved=!0,_r.current=!0,A.preventDefault();const ke={x:_e.x/N.zoom,y:_e.y/N.zoom},et=!A.shiftKey&&z.x>=0&&z.y>=0&&z.x<=N.size.w&&z.y<=N.size.h?gu(L.source,N.renderedToModel(z)):void 0;Zt({source:L.source,offset:ke,target:A.shiftKey||et?null:pu(L.source,ke),shiftKey:A.shiftKey,insertion:et});break}case"pan":{const _e=z.x-L.start.x,ke=z.y-L.start.y;if(!L.moved&&Math.hypot(_e,ke)<=hd)return;L.moved=!0,_r.current=!0,N.set({x:L.pan0.x+_e,y:L.pan0.y+ke});break}case"tap":{Math.hypot(z.x-L.start.x,z.y-L.start.y)>hd&&(L.moved=!0);break}case"box":{_r.current=!0,L.current=z,Kn({x1:Math.min(L.start.x,z.x),y1:Math.min(L.start.y,z.y),x2:Math.max(L.start.x,z.x),y2:Math.max(L.start.y,z.y)});break}case"draw":{const _e=N.renderedToModel(z),ke=zo(_e,L.reverse?"source":"target");un(L.reverse&&ke?{source:ke.nodeId,sourceProperty:ke.property,point:_e,target:L.source,targetProperty:L.sourceProperty}:{source:L.source,sourceProperty:L.sourceProperty,point:_e,target:(ke==null?void 0:ke.nodeId)??Zn(_e,L.source),targetProperty:ke==null?void 0:ke.property});break}}},yu=(A,L)=>{var fe,Ie,_e,ke,et,ve,$e,Ge,te,re,me;jt.current.delete(A.pointerId);const z=ht.current;if(!z)return;if(z.kind==="pinch"){const le=[...jt.current][0];ht.current=le&&M.current.dragMode&&!L?{kind:"pan",pointerId:le[0],start:le[1],pan0:N.pan,moved:!0}:null;return}if(z.pointerId!==A.pointerId)return;ht.current=null;try{(z.kind==="grid"?z.captureTarget:A.currentTarget).releasePointerCapture(A.pointerId)}catch{}const Z=M.current;switch(L=L||!!Z.readOnly,z.kind){case"grid":{if(Zt(null),L||!z.moved)break;const le=Jn(A);if(!A.shiftKey&&le.x>=0&&le.y>=0&&le.x<=N.size.w&&le.y<=N.size.h){const Ee=gu(z.source,N.renderedToModel(le));if(Ee){mt.setNodeGridMode(!0,{...Ee.options,animate:!1});break}}if(((fe=Z.onNodeGridDrop)==null?void 0:fe.call(Z,z.source,{x:A.clientX,y:A.clientY},{shiftKey:A.shiftKey,ctrlKey:A.ctrlKey,metaKey:A.metaKey,altKey:A.altKey}))===!0||le.x<0||le.y<0||le.x>N.size.w||le.y>N.size.h)break;if(A.shiftKey){const Ee=new Map(Z.nodes.map(it=>[it.id,it]));let Ae=Zn(N.renderedToModel(le),z.source);const tt=new Set;for(;Ae&&!((Ie=Ee.get(Ae))!=null&&Ie.acceptsChildren)&&!tt.has(Ae);)tt.add(Ae),Ae=((_e=Ee.get(Ae))==null?void 0:_e.parent)??null;if(Ae&&((ke=Ee.get(Ae))!=null&&ke.acceptsChildren)){let it=Ae;const st=new Set;for(;it&&!st.has(it);)st.add(it),it=(et=Ee.get(it))==null?void 0:et.parent;st.has(z.source)||(ve=Z.onNodeParentChange)==null||ve.call(Z,z.source,Ae)}break}if(!rt.current)break;const Ue=pu(z.source,{x:(le.x-z.start.x)/N.zoom,y:(le.y-z.start.y)/N.zoom});Ue&&mt.swapGridNodes(z.source,Ue,!1);break}case"pan":case"tap":!L&&!z.moved&&(($e=Z.onBackgroundTap)==null||$e.call(Z));break;case"box":{if(Kn(null),L)break;const le=N.renderedToModel(z.start),Ue=N.renderedToModel(z.current),Ee={x1:Math.min(le.x,Ue.x),y1:Math.min(le.y,Ue.y),x2:Math.max(le.x,Ue.x),y2:Math.max(le.y,Ue.y)};if(Ee.x2-Ee.x1<1&&Ee.y2-Ee.y1<1){(Ge=Z.onBackgroundTap)==null||Ge.call(Z);break}const Ae=[];for(const tt of Z.nodes){const it=We(tt.id);it&&Jw(tr(it),Ee)&&Ae.push(tt.id)}Ae.length&&((te=Z.onBoxSelect)==null||te.call(Z,Ae));break}case"draw":{if(un(null),L)break;const le=Jn(A),Ue=N.renderedToModel(le),Ee=zo(Ue,z.reverse?"source":"target"),Ae=(Ee==null?void 0:Ee.nodeId)??Zn(Ue);if(Ae===z.source&&(z.sourceProperty===void 0||(Ee==null?void 0:Ee.property)===void 0||Ee.property===z.sourceProperty))break;Ae?(re=Z.onEdgeDraw)==null||re.call(Z,z.reverse?Ae:z.source,z.reverse?z.source:Ae,z.sourceProperty!==void 0||(Ee==null?void 0:Ee.property)!==void 0?{sourceProperty:z.reverse?Ee==null?void 0:Ee.property:z.sourceProperty,targetProperty:z.reverse?z.sourceProperty:Ee==null?void 0:Ee.property}:void 0):Math.max(Math.abs(A.clientX-z.startClient.x),Math.abs(A.clientY-z.startClient.y))>Wj&&((me=Z.onDrawIntoSpace)==null||me.call(Z,z.source,Ue,z.sourceProperty,z.reverse));break}}},kr=j.useCallback(()=>{var z;const A=ht.current,L=[...jt.current.keys()];A&&A.kind!=="pinch"&&L.push(A.pointerId),ht.current=null,jt.current.clear(),Zt(null),un(null),Kn(null);for(const Z of L)(A==null?void 0:A.kind)==="grid"&&A.captureTarget.hasPointerCapture(Z)&&A.captureTarget.releasePointerCapture(Z),(z=_.current)!=null&&z.hasPointerCapture(Z)&&_.current.releasePointerCapture(Z)},[]);j.useEffect(()=>{const A=L=>{L.key==="Escape"&&kr()};return window.addEventListener("keydown",A),window.addEventListener("blur",kr),()=>{window.removeEventListener("keydown",A),window.removeEventListener("blur",kr),ht.current=null,jt.current.clear()}},[kr]),j.useEffect(()=>{kr()},[y,b,x,i,n,e.drawHandles,e.readOnly,nt,kr]);const fv=j.useMemo(()=>{const A=new Map,L=new Map;for(const z of k){if(z.source!==z.target)continue;const Z=A.get(z.source)??0;A.set(z.source,Z+1),L.set(z.id,Z)}return L},[k]),Bo=Dj[n],[Ar,hv]=j.useState(null),Do=zj(r,k,!!((wu=e.edgeReveal)!=null&&wu.revealNodes));j.useLayoutEffect(()=>{_.current&&Ar&&jm(_.current,Ar)}),j.useEffect(()=>{const A=_.current;if(!A||!Ar)return;const L=A.ownerDocument.fonts,z=()=>jm(A,Ar);return L==null||L.addEventListener("loadingdone",z),()=>L==null?void 0:L.removeEventListener("loadingdone",z)},[Ar]);const Wo=Hw(k,kt,Bo),pv=e.onEdgeSelect,gv=e.onContainerSelect,mu=ut?ut.target&&kt(ut.target,ut.targetProperty)||{x:ut.point.x,y:ut.point.y,w:1,h:1}:null,bu=ut?kt(ut.source,ut.sourceProperty):null,fn=!nt||!!e.nodeGridConnections,yv=["flow-sdk-canvas",y&&fn?"flow-sdk-draw":"",v?"flow-sdk-perf":""].filter(Boolean).join(" ");return f.jsxs("div",{ref:_,className:yv,"data-edge-mode":i,"data-node-grid":nt||void 0,"data-grid-connections":e.nodeGridConnections||void 0,onPointerDownCapture:dv,onPointerMove:uv,onPointerUp:A=>yu(A,!1),onPointerCancel:A=>yu(A,!0),onLostPointerCapture:A=>{const L=ht.current;L&&(L.kind==="pinch"||L.pointerId===A.pointerId)&&kr()},onClickCapture:A=>{if(!A.currentTarget.contains(A.target))return;const L=A.target instanceof Element&&A.target.closest("button[data-flow-fullscreen], button[data-flow-content-navigation]");(_r.current||e.readOnly&&!L)&&(A.preventDefault(),A.stopPropagation())},children:[f.jsx("svg",{className:"flow-sdk-svg",children:f.jsxs("g",{ref:O,children:[f.jsx("g",{className:"flow-sdk-containers",children:[...Oe].filter(([A])=>rr(A,t,i)).filter(([A])=>!R||R.has(A)).map(([A,L])=>{var z,Z;return f.jsx(a1,{id:A,rect:L,label:Ce.get(A),labelLayer:Ar,labelContent:(z=r.find(fe=>fe.id===A&&fe.label!==void 0))==null?void 0:z.element,style:m(A),onSelect:gv,onCollapse:e.readOnly?void 0:e.onContainerCollapse,selected:(Z=e.selectedNodeIds)==null?void 0:Z.includes(A)},A)})}),f.jsx("g",{className:"flow-sdk-edges",children:Je&&fn&&k.map(A=>{var Z,fe,Ie;if(!Do.ready.has(A.id)||R&&(!R.has(A.source)||!R.has(A.target)))return null;const L=kt(A.source,A.sourceProperty),z=kt(A.target,A.targetProperty);return!L||!z?null:f.jsx(Qu,{id:A.id,edgeData:A.data,validationIssue:A.validationIssue,edgeType:A.type,edgeRadius:e.edgeRadius,propertyMode:P,customEdgeTypes:e.customEdgeTypes,reveal:e.edgeReveal,onRevealComplete:Do.complete,source:L,target:z,sourceProperty:A.sourceProperty,targetProperty:A.targetProperty,sourceY:Xe(A.source,A.sourceProperty),targetY:Xe(A.target,A.targetProperty),sourcePort:St(A.source,A.sourceProperty),targetPort:St(A.target,A.targetProperty),dir:Bo,turn:((Z=Wo.get(A.id))==null?void 0:Z.turn)??A.turn,labelAtTarget:(fe=Wo.get(A.id))==null?void 0:fe.labelAtTarget,labelFraction:(Ie=Wo.get(A.id))==null?void 0:Ie.labelFraction,color:A.color,connectorColor:A.connectorColor,labelBg:A.labelBg,label:A.label,labelLayer:Ar,dashed:A.dashed,animated:A.animated&&!v,inverted:A.inverted,loopIndex:fv.get(A.id)??0,onSelect:pv},A.id)})}),Je&&fn&&ut&&wd(ut,i)&&bu&&mu&&f.jsx("g",{className:"flow-sdk-ghost",pointerEvents:"none",children:f.jsx(Qu,{id:"__flow-sdk-ghost",edgeData:{id:"__flow-sdk-ghost",source:ut.source,target:ut.target??"",sourceProperty:ut.sourceProperty,targetProperty:ut.targetProperty},edgeType:e.edgeType,edgeRadius:e.edgeRadius,propertyMode:P,customEdgeTypes:e.customEdgeTypes,source:bu,target:mu,sourceProperty:ut.sourceProperty,targetProperty:ut.targetProperty,sourceY:Xe(ut.source,ut.sourceProperty),sourcePort:St(ut.source,ut.sourceProperty),targetPort:ut.target?St(ut.target,ut.targetProperty):void 0,targetY:ut.target?Xe(ut.target,ut.targetProperty):void 0,dir:Bo,turn:.5,color:g,labelBg:g})})]})}),f.jsxs("div",{ref:B,className:"flow-sdk-nodes",children:[(Ke==null?void 0:Ke.insertion)&&f.jsx("div",{className:"flow-sdk-box","data-grid-insertion":"",style:{left:Ke.insertion.marker.x1,top:Ke.insertion.marker.y1,width:Ke.insertion.marker.x2-Ke.insertion.marker.x1,height:Ke.insertion.marker.y2-Ke.insertion.marker.y1,background:g,border:0}}),nt&&((Cu=rt.current)==null?void 0:Cu.options.fill)&&((Su=rt.current.options.adjustment)==null?void 0:Su.enabled)&&!e.readOnly&&f.jsx($j,{dividers:Rt,options:rt.current.options,zoom:N.zoom,onChange:A=>mt.setNodeGridMode(!0,{...A,animate:!1})}),r.map(A=>{var Ue,Ee,Ae;if((Ue=rt.current)!=null&&Ue.options.fill&&!be.current)return null;const L=Q.get(A.id),z=Oe.get(A.id);if(z&&A.label!==void 0)return null;const Z=(L==null?void 0:L.x)??(z?(z.x1+z.x2)/2:0),fe=(L==null?void 0:L.y)??(z?(z.y1+z.y2)/2:0),Ie=Ke!=null&&Ke.target?A.id===Ke.source?Ke.target:A.id===Ke.target?Ke.source:void 0:void 0,_e=Ie?Q.get(Ie):void 0,ke=Ke?Q.get(Ke.source):void 0,et=Ke!=null&&Ke.target?Q.get(Ke.target):void 0,ve=ke&&et?{x:et.x-ke.x,y:et.y-ke.y}:void 0,$e=ve?ve.x**2+ve.y**2:0,Ge=$e&&Ke&&ve?Math.max(0,Math.min(1,(Ke.offset.x*ve.x+Ke.offset.y*ve.y)/$e)):0,te=_e?{x:Z+(_e.x-Z)*Ge,y:fe+(_e.y-fe)*Ge}:(Ke==null?void 0:Ke.source)===A.id?{x:Z+Ke.offset.x,y:fe+Ke.offset.y}:void 0,re=ye.get(A.id),me=Ie?ye.get(Ie):void 0,le=re&&me?{w:re.w+(me.w-re.w)*Ge,h:re.h+(me.h-re.h)*Ge}:re;return f.jsx(Fj,{id:A.id,x:Z,y:fe,gridDraggable:nt&&!e.readOnly&&!X.current.has(A.id),gridDragging:(Ke==null?void 0:Ke.source)===A.id,gridDropTarget:(Ke==null?void 0:Ke.target)===A.id,gridSize:ye.get(A.id),gridPreview:te?{...te,size:le,floating:Ke==null?void 0:Ke.shiftKey}:void 0,placed:!!L||!!z,hidden:!nt&&!Do.shown.has(A.id)||!rr(A.id,t,i)||!!R&&!R.has(A.id),onMount:Be,drawHandles:e.drawHandles&&!e.readOnly&&fn,drawMode:y&&fn,connectedPorts:new Set(k.flatMap(tt=>[...tt.source===A.id&&tt.sourceProperty!==void 0?[`source:${tt.sourceProperty}`]:[],...tt.target===A.id&&tt.targetProperty!==void 0?[`target:${tt.targetProperty}`]:[]])),hasCollapseControl:A.hasCollapseControl,handleColor:g,animated:A.animated&&!z&&!v&&!nt,animationColor:A.animationColor,animationWidth:A.animationWidth,animationVariant:A.animationVariant,width:(Ee=I.current.get(A.id))==null?void 0:Ee.w,height:(Ae=I.current.get(A.id))==null?void 0:Ae.h,propertyMode:P,resolvedRows:ot.get(A.id),reversePorts:n==="RL",direction:n,onPropertyRows:ce,onSurface:q,children:re?A.fillElement??A.element:A.element},A.id)})]}),Rr&&f.jsx("div",{className:"flow-sdk-box",style:{left:Rr.x1,top:Rr.y1,width:Rr.x2-Rr.x1,height:Rr.y2-Rr.y1}}),f.jsx("svg",{className:"flow-sdk-svg flow-sdk-label-overlay",style:{zIndex:11,pointerEvents:"none"},children:f.jsx("g",{ref:$,transform:`translate(${N.pan.x} ${N.pan.y}) scale(${N.zoom})`,children:f.jsx("g",{ref:hv,className:"flow-sdk-labels",style:{pointerEvents:y?"none":"visiblePainted",outline:"none"}})})})]})}const Hj=j.memo(Uj);function lu(e=!0){const r=j.useRef(null);return j.useEffect(()=>{if(!e||!r.current)return;const t=i=>{i.stopPropagation()},n=r.current,o=["mousedown","mouseup","click","dblclick","pointerdown","pointerup","wheel"];return o.forEach(i=>n.addEventListener(i,t)),()=>{o.forEach(i=>n.removeEventListener(i,t))}},[e]),r}const tn=({nodeId:e,label:r,color:t,fontWeight:n="bold",fontSize:o="5xl",wrap:i=!1,isEditing:s,onEditStart:a,onEditEnd:c})=>{const{callbacks:l,config:d,readOnly:u}=Ze(),h=d.editable&&!u,[p,m]=j.useState(r),[g,y]=j.useState(),b=j.useRef(null),x=j.useRef(!1),v=lu(s);j.useEffect(()=>{if(s&&(x.current=!1,b.current)){b.current.focus();const C=b.current.value.length;b.current.setSelectionRange(C,C)}},[s]);const w=()=>{var S;if(x.current)return;x.current=!0;const C=p.trim();C&&C!==r&&((S=l.onNodeLabelChange)==null||S.call(l,e,C)),c()};return!h||!s?f.jsx(W.Text,{color:t,fontWeight:n,fontSize:o,minW:0,maxW:"100%",whiteSpace:i?"normal":"nowrap",overflowWrap:i?"anywhere":void 0,overflow:"hidden",textOverflow:"ellipsis",title:r,onDoubleClick:h?C=>{C.stopPropagation(),y({width:C.currentTarget.offsetWidth,height:C.currentTarget.offsetHeight}),m(r),a()}:void 0,cursor:h?"text":void 0,children:r}):f.jsxs("div",{ref:v,style:{position:"relative",width:"max-content",minWidth:g==null?void 0:g.width,maxWidth:900,height:g==null?void 0:g.height},children:[f.jsx(W.Text,{as:"span","aria-hidden":"true",display:"block",visibility:"hidden",fontWeight:n,fontSize:o,lineHeight:"normal",whiteSpace:"pre",overflow:"hidden",children:p||" "}),f.jsx(W.Input,{ref:b,value:p,onChange:C=>m(C.target.value),onBlur:w,onKeyDown:C=>{C.key==="Enter"&&w(),C.key==="Escape"&&(x.current=!0,c())},color:t,fontWeight:n,fontSize:o,bg:"transparent",borderWidth:0,_focus:{outline:"none",boxShadow:"none"},_focusVisible:{outline:"none",boxShadow:"none"},p:0,display:"block",position:"absolute",top:0,left:0,w:"100%",h:"100%",minW:0,minH:0,lineHeight:"normal"})]})};function tv({id:e,label:r,role:t,side:n,position:o=.5,placement:i,children:s,style:a}){return f.jsx("div",{"data-flow-property":e,"data-flow-port-role":t,"data-flow-port-side":n,"data-flow-port-position":n?o:void 0,"data-flow-port-placement":i,style:{minHeight:32,display:"flex",alignItems:"center",justifyContent:t==="source"?"flex-end":"flex-start",...a,...n?{display:"none"}:{}},children:s??r??e})}const Kj=fo.default.dialog`
|
|
211
211
|
${e=>xr(e.$surface,e.$border)}
|
|
212
212
|
&,
|
|
213
213
|
&:hover {
|
|
@@ -277,8 +277,8 @@
|
|
|
277
277
|
black calc(100% - 32px),
|
|
278
278
|
transparent
|
|
279
279
|
);
|
|
280
|
-
`;function du({nodeAddress:e,active:r,label:t,open:n=!1,onClose:o,children:i,filter:s,height:a,width:c}){const{background:l,border:d,colorText:u}=lt(),{colorMode:h}=
|
|
280
|
+
`;function du({nodeAddress:e,active:r,label:t,open:n=!1,onClose:o,children:i,filter:s,height:a,width:c}){const{background:l,border:d,colorText:u}=lt(),{colorMode:h}=Ze(),p=j.useRef(null),m=j.useId(),{data:g,schema:y,bindings:b}=j.useContext(Tt),x=i!==void 0||!!(g&&y&&(b?Fn(b,e,y):on(g,e,y)));j.useEffect(()=>{var w,C,S,R,P;!r||!x||!n?(w=p.current)==null||w.close():(C=p.current)!=null&&C.open||((S=p.current)==null||S.showModal(),(P=(R=p.current)==null?void 0:R.querySelector("[data-form-filter] input"))==null||P.focus())},[r,x,n]);const v=Me(l);return x?f.jsx(f.Fragment,{children:typeof document<"u"&&Jr.createPortal(f.jsx(Kj,{ref:p,id:m,$surface:v,$border:Me(d),"aria-label":`Configure ${t}`,onClose:o,onPointerDown:w=>w.stopPropagation(),onWheel:w=>w.stopPropagation(),onKeyDown:w=>w.stopPropagation(),onClick:w=>{var C;w.stopPropagation(),w.target===w.currentTarget&&((C=p.current)==null||C.close())},style:{position:"fixed",inset:"94px 20px auto auto",margin:0,padding:20,width:c??"var(--top-toolbar-width, 360px)",boxSizing:"border-box",maxWidth:"calc(100vw - 40px)",maxHeight:"calc(100dvh - 114px)",height:a,overflow:"hidden",borderRadius:30,background:v,color:Me(u),fontSize:16,textTransform:"none"},children:n&&f.jsxs(f.Fragment,{children:[f.jsxs("div",{style:{display:"flex",alignItems:"center",justifyContent:"space-between",gap:12,flexShrink:0},children:[f.jsx("strong",{style:{overflowWrap:"anywhere",minWidth:0},children:t}),f.jsx(nn,{"aria-label":"Close node configuration",onClick:()=>{var w;return(w=p.current)==null?void 0:w.close()}})]}),s&&f.jsx("div",{"data-form-filter":"",style:{flexShrink:0},children:s}),f.jsx(Jj,{$divider:`var(--chakra-colors-gray-${h==="dark"?"700":"200"})`,"data-form-scroll":"",style:a?{flex:1}:void 0,children:i??f.jsx(Ld,{nodeAddress:e})})]})}),document.body)}):null}const Sd=({icon:e,label:r,onClick:t,color:n,boxSize:o=6,...i})=>{const{background:s,border:a,colorText:c}=lt();return f.jsx(He,{label:r,children:f.jsx(W.Flex,{asChild:!0,p:0,border:0,bg:"transparent",children:f.jsx("button",{type:"button","aria-label":r,onClick:t,children:f.jsx(W.Icon,{as:e,boxSize:o,color:n,cursor:t?"pointer":void 0})})})})},Zj=`${zb}
|
|
281
281
|
[data-flow-loading-border][data-flow-loading-border] .flow-sdk-node-border-animation{animation:flow-sdk-node-border 2.4s linear infinite!important}
|
|
282
282
|
[data-flow-loading-border][data-flow-loading-border][data-motion-disabled] .flow-sdk-node-border-animation{animation:none!important}
|
|
283
|
-
@media(prefers-reduced-motion:reduce){[data-flow-loading-border][data-flow-loading-border] .flow-sdk-node-border-animation{animation:none!important}}`;function rv({active:e=!0,label:r="Loading content",radius:t}){const{config:n,themeColor:o}=Je(),{colorText:i}=lt(),s=j.useRef(null),[a,c]=j.useState({width:0,height:0,radius:0});if(j.useLayoutEffect(()=>{const u=s.current;if(!e||!u)return;const h=()=>{const m=u.parentElement,g={width:u.clientWidth,height:u.clientHeight,radius:t??(m&&parseFloat(getComputedStyle(m).borderTopLeftRadius)||0)};c(y=>y.width===g.width&&y.height===g.height&&y.radius===g.radius?y:g)},p=new ResizeObserver(h);return p.observe(u),h(),()=>p.disconnect()},[e,t]),!e)return null;const l=Me(o||i),d={x:4,y:4,width:a.width-8,height:a.height-8,radius:Math.max(0,a.radius-4),color:l,strokeWidth:2};return f.jsxs("div",{ref:s,role:"status","aria-label":r,"data-flow-loading-border":"","data-motion-disabled":n.disableAnimations||void 0,style:{position:"absolute",inset:0,pointerEvents:"none",borderRadius:"inherit",overflow:"hidden",zIndex:2},children:[f.jsx("style",{children:Zj}),f.jsxs("svg",{width:"100%",height:"100%","aria-hidden":"true",style:{display:"block",pointerEvents:"none"},children:[f.jsx("g",{opacity:.5,style:{filter:"blur(3px)"},children:f.jsx(so,{...d,strokeWidth:6})}),f.jsx(so,{...d})]})]})}function Xj({nodeId:e}){var E,M;const{nodeById:r}=Kt(),{callbacks:t,config:n,readOnly:o,colorMode:i,isPerformanceMode:s}=Je(),{background:a,border:c,colorInactive:l,colorText:d}=lt(),u=[...r.values()].filter(({data:_})=>{var N,$,B,O,I;return _.type!=="grid"&&!((N=_.config)!=null&&N.parentContainer)&&((($=_.config)==null?void 0:$.contentFormat)==="html"||((B=_.config)==null?void 0:B.contentFormat)==="jsx")&&(typeof((O=_.config)==null?void 0:O.content)=="string"||Array.isArray((I=_.config)==null?void 0:I.content))}),[h,p]=j.useState(e),[m,g]=j.useState(!1),y=j.useRef(null),b=ho({edge:"top",enabled:!0,bounds:y,inside:[y],threshold:90}),x=j.useRef(null),v=j.useRef(1),w=u.find(_=>_.data.id===h)??u.find(_=>_.data.id===e)??u[0],C=u.indexOf(w),S=!!n.editable&&!o,R=_=>typeof _=="number"?_>0&&Number.isFinite(_)?String(_):"":typeof _=="string"&&/^\d+(\.\d+)?px$/.test(_)?String(parseFloat(_)):"",P=R((E=w==null?void 0:w.data.viewProps)==null?void 0:E.width),k=R((M=w==null?void 0:w.data.viewProps)==null?void 0:M.height);j.useLayoutEffect(()=>{const _=x.current;if(!_||n.disableAnimations||s||matchMedia("(prefers-reduced-motion: reduce)").matches)return;const N=_.animate({transform:[`translateX(${v.current*100}%)`,"translateX(0)"]},{duration:240,easing:"ease-out",id:"flow-content-slide"});return()=>N.cancel()},[w==null?void 0:w.data.id,n.disableAnimations,s]);const T=_=>{const N=u[C+_];!N||m||(v.current=_,p(N.data.id))};return w?f.jsxs(V.Box,{"data-content-gallery":"",position:"relative",h:"100%",display:"flex",flexDirection:"column",minH:0,color:d,onClick:_=>_.stopPropagation(),onDoubleClick:_=>_.stopPropagation(),onPointerDown:_=>_.stopPropagation(),children:[f.jsx(V.Box,{ref:y,role:"toolbar","aria-label":"Preview controls",position:"absolute",top:"8px",left:"8px",w:"max-content",maxW:"calc(100% - 76px)",zIndex:2,css:{"@media (hover: hover) and (pointer: fine)":{opacity:b?1:0},"&:hover, &:focus-within":{opacity:1}},children:f.jsx(vo,{background:a,border:i==="dark"?c:"gray.300",children:f.jsxs(V.HStack,{px:2,gap:2,width:"max-content",height:"100%",children:[f.jsx(He,{label:"Previous content",children:f.jsx(Oe,{"data-flow-content-navigation":"","aria-label":"Previous content",icon:f.jsx(Y.PiCaretLeft,{size:20}),disabled:C<=0||m,onClick:()=>T(-1),rememberAction:!1,size:"sm",variant:"ghost"})}),f.jsxs(V.Text,{"aria-live":"polite",fontSize:"12px",minW:"42px",textAlign:"center",children:[C+1," / ",u.length]}),f.jsx(He,{label:"Next content",children:f.jsx(Oe,{"data-flow-content-navigation":"","aria-label":"Next content",icon:f.jsx(Y.PiCaretRight,{size:20}),disabled:C>=u.length-1||m,onClick:()=>T(1),rememberAction:!1,size:"sm",variant:"ghost"})}),["width","height"].map(_=>f.jsxs(V.Box,{as:"label",display:"flex",alignItems:"center",gap:1,fontSize:"12px",opacity:S?1:.5,children:[_==="width"?"W":"H",f.jsx(qr,{value:_==="width"?P:k,placeholder:"Auto",ariaLabel:`Content ${_}`,type:"number",min:1,width:"72px",disabled:!S||!t.onNodeDimensionChange||m,onCommit:N=>{var $;S&&(($=t.onNodeDimensionChange)==null||$.call(t,w.data.id,_,N===""?void 0:Number(N)))}})]},`${w.data.id}:${_}`)),S&&!m&&f.jsx(He,{label:"Edit content source",children:f.jsx(Oe,{"aria-label":"Edit content source",icon:f.jsx(Y.PiCode,{size:20}),onClick:()=>g(!0),rememberAction:!1,size:"sm",variant:"ghost",color:l})})]})})}),f.jsx(V.Box,{flex:1,minH:0,overflow:"auto",position:"relative","data-content-slide-viewport":"",children:f.jsx(V.Box,{ref:x,"data-content-slide":w.data.id,width:P?`${P}px`:"100%",height:k?`${k}px`:"100%",minH:k?void 0:"100%",mx:"auto",overflow:"auto",children:f.jsx(uu,{nodeId:w.data.id,content:w.data.config.content,format:w.data.config.contentFormat,color:d,previewControls:!1,editOnMount:m,onEditEnd:()=>g(!1)},`${w.data.id}:${m}`)},w.data.id)})]}):f.jsx(V.Box,{role:"status",p:4,children:"No HTML or JSX content available."})}const nv=j.forwardRef(function({fullscreen:r,onClick:t},n){const{colorInactive:o}=lt();return f.jsx(Oe,{ref:n,"data-flow-fullscreen":"","aria-label":r?"Exit fullscreen":"Expand preview",title:r?"Exit fullscreen":"Expand preview","aria-expanded":r,icon:r?f.jsx(Y.PiArrowsIn,{size:20}):f.jsx(Y.PiArrowsOut,{size:20}),size:"sm",variant:"plain",bg:"transparent",color:o,borderRadius:"30px",w:"32px",h:"32px",minW:"32px",p:0,onClick:t})});function Yj({content:e,format:r,onEdit:t,autoHeight:n=!1,nodeId:o,controls:i=!0}){var F,G,D,ce,Q;const{config:s,colorMode:a}=Je(),{nodeById:c}=Kt(),l=o?(G=(F=c.get(o))==null?void 0:F.data.viewProps)==null?void 0:G.height:void 0,d=typeof l=="number"?`${l}px`:typeof l=="string"&&/^\d+(\.\d+)?px$/.test(l)?l:void 0;n=n&&!d;const{background:u,border:h,colorInactive:p}=lt(),m=(D=s.customViews)==null?void 0:D.jsxContent,g=typeof e=="string"?e:JSON.stringify(e,null,2);let y,b=r==="jsx"&&o?(Q=(ce=c.get(o))==null?void 0:ce.data.config)==null?void 0:Q.contentReferenceError:void 0;if(r==="jsx"&&!b)try{const K=typeof e=="string"?JSON.parse(e):e;if(!Array.isArray(K)||K.some(ie=>!ie||typeof ie!="object"||Array.isArray(ie)||typeof ie.type!="string"))throw new Error("JSX content must be an array of components with a type.");y=K}catch(K){b=K instanceof Error?K.message:"Invalid components array."}const x=j.useRef(null),v=j.useRef(null),w=j.useRef(null),C=j.useRef(!1),[S,R]=j.useState(!1),P=j.useRef(null),k=ho({edge:"top",enabled:S,bounds:P,inside:[P],threshold:90}),[T,E]=j.useState(""),[M,_]=j.useState(),N=!!t;j.useEffect(()=>{const K=()=>{var ye;const ie=document.fullscreenElement===v.current;R(ie),C.current&&!ie&&!document.fullscreenElement&&((ye=w.current)==null||ye.focus({preventScroll:!0})),C.current=ie};return document.addEventListener("fullscreenchange",K),()=>document.removeEventListener("fullscreenchange",K)},[]);const $=async()=>{var K;E("");try{if(document.fullscreenElement===v.current)await document.exitFullscreen();else if((K=v.current)!=null&&K.requestFullscreen)await v.current.requestFullscreen();else throw new Error("Fullscreen is not supported in this browser.")}catch(ie){E(ie instanceof Error?ie.message:"Unable to change fullscreen.")}},[B,O]=j.useState(),[I,ee]=j.useState(),[ae,ne]=j.useState();j.useEffect(()=>{if(r==="jsx")return;let K=!1;return Promise.resolve().then(()=>require("./contentPreviewDocument-i1zWN5gw.cjs")).then(({contentPreviewDocument:ie})=>ie(g,r,N,n)).then(ie=>{K||O({content:g,format:r,editable:N,autoHeight:n,document:ie})},ie=>{K||O({content:g,format:r,editable:N,autoHeight:n,error:ie instanceof Error?ie.message:String(ie)})}),()=>{K=!0}},[g,r,N,n]),j.useEffect(()=>{if(!t)return;const K=async ie=>{var ye,we;if(!(!((ye=x.current)!=null&&ye.contentWindow)||ie.source!==x.current.contentWindow||((we=ie.data)==null?void 0:we.type)!=="squeed:content-edit"))try{document.fullscreenElement===v.current&&await document.exitFullscreen(),t()}catch(fe){E(fe instanceof Error?fe.message:"Unable to close fullscreen.")}};return window.addEventListener("message",K),()=>window.removeEventListener("message",K)},[t]);const oe=(B==null?void 0:B.content)===g&&B.format===r&&B.editable===N&&B.autoHeight===n?B:void 0;j.useEffect(()=>{if(!n||r!=="html"||!(oe!=null&&oe.document))return;const K=oe.document,ie=ye=>{var fe,ge,X;const we=(fe=ye.data)==null?void 0:fe.height;!((ge=x.current)!=null&&ge.contentWindow)||ye.source!==x.current.contentWindow||((X=ye.data)==null?void 0:X.type)!=="squeed:content-size"||typeof we!="number"||!Number.isFinite(we)||we<=0||we>1e5||document.fullscreenElement===v.current||_(H=>(H==null?void 0:H.document)===K&&H.height===we?H:{document:K,height:we})};return window.addEventListener("message",ie),()=>window.removeEventListener("message",ie)},[n,r,oe==null?void 0:oe.document]);const pe=!!oe&&oe===ae,q=r!=="jsx"&&!(oe!=null&&oe.error)&&!pe&&(!oe||I!==oe);return f.jsxs("div",{"data-flow-content-preview":"",style:{width:"100%",height:i?d??(n?r==="jsx"?"auto":(M==null?void 0:M.document)===(oe==null?void 0:oe.document)?M==null?void 0:M.height:360:360):n?"auto":"100%",fontSize:16,overflow:"auto"},children:[f.jsx("pre",{"data-flow-preview-source":"",style:{display:"none",whiteSpace:"pre-wrap"},children:g}),f.jsxs(V.Box,{ref:v,position:"relative",w:"100%",h:n&&r==="jsx"?"auto":"100%","aria-busy":!S&&r!=="jsx"?q:void 0,bg:r==="jsx"&&a==="dark"?"gray.900":"white",onDoubleClick:K=>{r!=="jsx"||!t||K.defaultPrevented||K.target.closest('button, a, input, textarea, select, [contenteditable], [role="button"], [role="textbox"]')||(K.stopPropagation(),(async()=>{document.fullscreenElement===v.current&&await document.exitFullscreen(),t()})().catch(ie=>E(String(ie))))},onKeyDownCapture:K=>{K.key!=="Escape"||document.fullscreenElement!==v.current||K.target instanceof Element&&K.target.closest('input, textarea, select, [contenteditable="true"]')||(K.preventDefault(),K.stopPropagation(),$())},css:{"&:fullscreen":{width:"100vw",height:"100dvh",maxWidth:"none",maxHeight:"none",padding:0},"&:not(:fullscreen):hover > [data-flow-content-toolbar], &:not(:fullscreen):focus-within > [data-flow-content-toolbar]":{opacity:1,pointerEvents:"auto"},"@media (hover: none)":{"& > [data-flow-content-toolbar]":{opacity:1,pointerEvents:"auto"}}},children:[i&&f.jsx(V.Box,{ref:P,role:"toolbar","aria-label":"Content controls","data-flow-content-toolbar":"",position:"absolute",top:"8px",right:"8px",zIndex:1,w:"max-content",maxW:"calc(100% - 16px)",opacity:S?1:0,pointerEvents:S?"auto":"none",css:S?{"@media (hover: hover) and (pointer: fine)":{opacity:k?1:0},"&:hover, &:focus-within":{opacity:1}}:void 0,children:f.jsx(vo,{background:u,border:a==="dark"?h:"gray.300",children:f.jsxs(V.HStack,{px:"8px",gap:"8px",h:"100%",w:"max-content",css:{"& button > svg":{width:"20px",height:"20px",minWidth:"20px",minHeight:"20px",flexShrink:0}},children:[t&&(!S||!o)&&f.jsx(Oe,{"data-flow-content-edit":"","aria-label":"Edit content source",title:"Edit content source",icon:f.jsx(Y.PiCode,{size:20}),size:"sm",variant:"plain",bg:"transparent",color:p,borderRadius:"30px",w:"32px",h:"32px",minW:"32px",p:0,onClick:K=>{K.stopPropagation(),(async()=>{document.fullscreenElement===v.current&&await document.exitFullscreen(),t()})().catch(ie=>E(String(ie)))}}),f.jsx(nv,{ref:w,fullscreen:S,onClick:K=>{K.stopPropagation(),$()}})]})})}),T&&f.jsx(V.Box,{role:"alert",position:"absolute",bottom:0,insetInline:0,bg:"white",color:"red.700",fontSize:"14px",children:T}),S&&o?f.jsx(Xj,{nodeId:o}):r==="jsx"?b?f.jsx("pre",{role:"alert",style:{whiteSpace:"pre-wrap"},children:b}):m&&y?f.jsx(m,{components:y,colorMode:a,fillHeight:!n||S}):f.jsx(V.Box,{role:"status",fontSize:"14px",children:"JSX content renderer is not available."}):oe!=null&&oe.error||pe?f.jsx("pre",{role:"alert",style:{whiteSpace:"pre-wrap"},children:(oe==null?void 0:oe.error)||"Content preview could not be loaded."}):oe!=null&&oe.document?f.jsx("iframe",{ref:x,title:`${r.toUpperCase()} content preview`,sandbox:N||n?"allow-scripts":"",allowFullScreen:!0,referrerPolicy:"no-referrer",srcDoc:oe.document,onLoad:()=>ee(oe),onError:()=>ne(oe),style:{width:"100%",height:"100%",border:0,display:"block",background:"white",visibility:q?"hidden":"visible"}},oe.document):null,f.jsx(rv,{active:!S&&q,label:"Loading HTML content"})]})]})}const _m=1.55;function uu({nodeId:e,content:r,color:t,format:n="markdown",fillBody:o=!1,autoHeight:i=!1,previewControls:s=!0,editOnMount:a=!1,onChange:c,onEditEnd:l}){var B,O;const{callbacks:d,config:u,readOnly:h,nodeGridOptions:p}=Je(),m=!!u.editable&&!h,g=m&&(!p||o&&p.fill&&n==="markdown"),{nodeById:y}=Kt(),b=n==="jsx"&&!c?((O=(B=y.get(e))==null?void 0:B.data.config)==null?void 0:O.contentSource)??r:r,x=typeof b=="string"?b:JSON.stringify(b,null,2),[v,w]=j.useState(a&&m),[C,S]=j.useState(x),[R,P]=j.useState(""),[k,T]=j.useState(),E=j.useRef(null),M=j.useRef(!1),_=lu(v);j.useLayoutEffect(()=>{const I=E.current;!v||!I||(I.style.height="auto",I.style.height=`${Math.max((k==null?void 0:k.height)??0,I.scrollHeight)}px`)},[C,v,k]),j.useEffect(()=>{var I,ee;m?v&&(M.current=!1,(I=E.current)==null||I.focus({preventScroll:!0}),(ee=E.current)==null||ee.select()):w(!1)},[v,m]);const N=(I,ee=!1)=>{!m||p&&!g&&!ee||(T({width:I.offsetWidth,height:I.offsetHeight}),S(x),P(""),w(!0))},$=()=>{var ee;if(M.current||!m)return;let I=C;if(n==="jsx")try{if(I=JSON.parse(C),!Array.isArray(I)||I.some(ae=>!ae||typeof ae!="object"||Array.isArray(ae)||typeof ae.type!="string"&&typeof ae.$contentRef!="string"))throw new Error("JSX content must be an array of components with a type.")}catch(ae){P(ae instanceof Error?ae.message:"Invalid components array.");return}M.current=!0,C!==x&&(c?c(I):(ee=d.onNodeContentChange)==null||ee.call(d,e,I)),w(!1),l==null||l()};return(!v||!m)&&n!=="markdown"?f.jsx(V.Box,{ref:_,w:"100%",h:!s&&!i?"100%":void 0,position:"relative","data-flow-content":"",children:f.jsx(Yj,{nodeId:e,content:r,format:n,controls:s,autoHeight:i&&!(p!=null&&p.fill),onEdit:g?()=>{_.current&&N(_.current)}:void 0})}):!v||!m?f.jsx(V.Box,{"data-flow-content":"",color:t,opacity:r?void 0:.6,w:"100%",minH:"1.2em",whiteSpace:"normal",lineHeight:_m,overflowWrap:"anywhere",css:{"& > :first-of-type":{marginTop:0},"& > :last-of-type":{marginBottom:0},"& h1, & h2, & h3, & h4, & h5, & h6":{fontWeight:700,lineHeight:1.2,margin:"1em 0 0.45em"},"& h1":{fontSize:"1.5em"},"& h2":{fontSize:"1.3em"},"& h3":{fontSize:"1.1em"},"& p":{margin:"0.65em 0",whiteSpace:"pre-wrap"},"& ul, & ol":{margin:"0.65em 0",paddingInlineStart:"1.6em"},"& ul":{listStyleType:"disc"},"& ol":{listStyleType:"decimal"},"& li":{display:"list-item",margin:"0.3em 0",paddingInlineStart:"0.15em"},"& li > ul, & li > ol":{margin:"0.25em 0"},"& li > p":{margin:0},"& a":{color:"inherit",textDecoration:"underline"},"& code":{fontFamily:"monospace",fontSize:"0.85em"},"& :not(pre) > code":{background:"color-mix(in srgb, currentColor 10%, transparent)",padding:"0.1em 0.25em",borderRadius:"0.2em"},"& pre":{margin:"0.75em 0",padding:"0.75em",background:"color-mix(in srgb, currentColor 8%, transparent)",border:0,borderRadius:"6px",maxWidth:"100%",overflowX:"auto",whiteSpace:"pre",overflowWrap:"normal",lineHeight:1.5},"& pre code":{background:"transparent",padding:0,whiteSpace:"inherit"},"& strong":{fontWeight:700},"& em":{fontStyle:"italic"},"& blockquote":{margin:"0.4em 0",borderInlineStart:"0.1em solid currentColor",paddingInlineStart:"0.6em"},"& table":{width:"100%",tableLayout:"fixed",borderCollapse:"collapse",margin:"0.4em 0"},"& th, & td":{border:"1px solid currentColor",padding:"0.2em 0.3em",textAlign:"left"},"& th":{fontWeight:700},"& img":{maxWidth:"100%",height:"auto"}},cursor:g?"text":void 0,tabIndex:g?0:void 0,outline:"none",_focusVisible:{outline:"none",boxShadow:"none"},onClick:I=>{!m||p&&!g&&!I.shiftKey||I.target instanceof Element&&I.target.closest("a, button, input")||(I.stopPropagation(),N(I.currentTarget,I.shiftKey))},onDoubleClick:I=>{I.stopPropagation(),N(I.currentTarget,I.shiftKey)},onKeyDown:I=>{m&&(g||I.shiftKey)&&I.key==="Enter"&&I.target===I.currentTarget&&(I.preventDefault(),I.stopPropagation(),N(I.currentTarget,I.shiftKey))},children:f.jsx(Rv.default,{options:{forceBlock:!0,wrapper:j.Fragment,disableParsingRawHTML:!0,overrides:{a:{props:{target:"_blank",rel:"noopener noreferrer"}},img:{props:{loading:"lazy",referrerPolicy:"no-referrer"}}}},children:x||(u.editable&&!h?"Write your content here":"")})}):f.jsxs("div",{ref:_,style:{width:k==null?void 0:k.width,minHeight:k==null?void 0:k.height,maxWidth:"100%"},children:[f.jsx(V.Textarea,{ref:E,"aria-label":"Node content",placeholder:"Write your content here",value:C,"aria-invalid":!!R,onChange:I=>S(I.target.value),onBlur:$,onKeyDown:I=>{I.stopPropagation(),!I.nativeEvent.isComposing&&(I.key==="Enter"&&(I.ctrlKey||I.metaKey)&&(I.preventDefault(),$()),I.key==="Escape"&&(M.current=!0,w(!1),l==null||l()))},color:t,fontFamily:"inherit",fontSize:"inherit",lineHeight:_m,overflowWrap:"anywhere",whiteSpace:"pre-wrap",rows:1,bg:"transparent",display:"block",style:{border:0,outline:"none",boxShadow:"none"},_focus:{border:0,outline:"none",boxShadow:"none"},_focusVisible:{border:0,outline:"none",boxShadow:"none"},p:0,w:"100%",h:"100%",minW:0,minH:0,resize:"none"}),R&&f.jsx(V.Box,{role:"alert",fontSize:"14px",color:"red.500",children:R})]})}const Qj=({data:e,children:r,isInverted:t,isParent:n,onOpenView:o,editOnMount:i=!1,hoverLeaveDelay:s=0})=>{var fe,ge,X,H,be,J,xe,Se,Fe,De;const{selectedNodeIds:a,setSelectedNodeIds:c,selectedEdgeId:l,setSelectedEdgeId:d,isMultiSelectMode:u,nodeGridOptions:h,isPerformanceMode:p,engineRef:m,callbacks:g,config:y,themeColor:b,direction:x,nodeViewModes:v}=Je(),{background:w,border:C,colorText:S}=lt(),R=j.useRef(null),P=j.useRef(null);j.useEffect(()=>()=>{P.current&&clearTimeout(P.current)},[]);const[k,T]=j.useState(!1),[E,M]=j.useState(i&&!!y.editable&&!y.readOnly),[_,N]=j.useState(!1),$=e==null?void 0:e.id,B=wb($),O=a.includes($);j.useEffect(()=>{if(!O||a.length!==1||y.readOnly||E||_)return;const he=Re=>{var qe,Qe,ct,Pe,Ze;if(Re.key!=="Enter"||Re.defaultPrevented||Re.isComposing||Re.ctrlKey||Re.metaKey||Re.altKey||Re.shiftKey||Re.target instanceof Element&&Re.target.closest('button, input, textarea, select, a, [contenteditable], [role="textbox"], [role="dialog"], [role="menu"], [role="listbox"], [popover], [data-flow-content]')||Array.from(document.querySelectorAll('dialog[open], :popover-open, [role="dialog"], [role="menu"], [role="listbox"]')).some(Ye=>Ye.getClientRects().length&&getComputedStyle(Ye).visibility!=="hidden"))return;const ze=Array.from(((qe=R.current)==null?void 0:qe.querySelectorAll("[data-flow-content-toggle] button, button[data-flow-collapse-control]"))??[]).find(Ye=>{var at;return((at=Ye.closest("[data-node-id]"))==null?void 0:at.getAttribute("data-node-id"))===$&&!Ye.disabled&&Ye.getClientRects().length&&getComputedStyle(Ye).visibility!=="hidden"}),Te=!ze&&(e==null?void 0:e.type)==="grid"&&((Qe=e.config)==null?void 0:Qe.documentId)&&((ct=R.current)==null?void 0:ct.getClientRects().length)&&g.onNodeHoverAction&&((Pe=y.nodeOverlayActions)==null?void 0:Pe.find(Ye=>Ye.id==="open-document"&&(!Ye.nodeTypes||Ye.nodeTypes.includes(e.type))));!ze&&!Te||(Re.preventDefault(),Re.stopPropagation(),Re.repeat||(ze?ze.click():(Ze=g.onNodeHoverAction)==null||Ze.call(g,Te.id,$,e)))};return window.addEventListener("keydown",he,!0),()=>window.removeEventListener("keydown",he,!0)},[$,O,a.length,y.readOnly,E,_,e,g.onNodeHoverAction,y.nodeOverlayActions]);const I=(fe=y.nodeOverlayActions)==null?void 0:fe.filter(he=>!he.nodeTypes||he.nodeTypes.includes(e==null?void 0:e.type)),ee=y.renderNodeOverlay,ae=(e==null?void 0:e.type)==="grid"?(ge=y.customViews)==null?void 0:ge.gridHoverControls:void 0,ne=(e==null?void 0:e.type)==="grid"?"20px":"-100px",oe=(e==null?void 0:e.type)==="grid"?"top center":void 0,pe=(e==null?void 0:e.type)==="grid"?"translateX(-50%) scale3d(1.8, 1.8, 1)":"translateX(-50%) scale3d(3, 3, 1)",q=(()=>{var he;try{const Re=(he=m.current)==null?void 0:he.zoom();return Re!==void 0&&Re<.08}catch{return!1}})(),F=j.useCallback((he,Re=!1)=>{var Te,qe,Qe,ct;if(E||y.readOnly||h!=null&&h.fill&&!he.shiftKey)return;const ze={shiftKey:he.shiftKey,ctrlKey:he.ctrlKey,metaKey:he.metaKey,altKey:he.altKey,...Re?{viewToggle:!0}:{}};if(l&&(d(null),(Te=g.onEdgeDeselect)==null||Te.call(g)),u||he.shiftKey&&(h!=null&&h.fill)){const Pe=a.includes($),Ze=Pe?a.filter(Ye=>Ye!==$):[...a,$];c(Ze),Pe?(qe=g.onNodeDeselect)==null||qe.call(g):(Qe=g.onNodeSelect)==null||Qe.call(g,$,e,ze)}else c([$]),(ct=g.onNodeSelect)==null||ct.call(g,$,e,ze)},[$,e,a,l,u,h,E,c,d,g,y]),G=j.useCallback(()=>{var he;E||y.readOnly||(he=g.onNodeDoubleClick)==null||he.call(g,$,e)},[$,e,E,g,y]),D=j.useCallback(()=>{P.current&&clearTimeout(P.current),P.current=setTimeout(()=>T(!0),100)},[]),ce=j.useCallback(he=>{var Re;he.relatedTarget instanceof Node&&((Re=R.current)!=null&&Re.contains(he.relatedTarget))||(P.current&&clearTimeout(P.current),s?P.current=setTimeout(()=>T(!1),s):T(!1))},[s]),Q=(e==null?void 0:e.type)==="text"&&!((X=e==null?void 0:e.config)!=null&&X.parentContainer)&&!((H=e==null?void 0:e.config)!=null&&H.form),K=!!((be=e==null?void 0:e.config)!=null&&be.form)||Q,ie={tabIndex:K?0:void 0,"aria-haspopup":K?"dialog":void 0,"aria-expanded":K?_:void 0,onDoubleClickCapture:he=>{var Re;!K&&!o||y.readOnly||Q&&!y.editable||E||!he.currentTarget.contains(he.target)||he.target instanceof Element&&he.target.closest("button, input, textarea, select, a, [contenteditable=true], [data-flow-content]")||(he.preventDefault(),he.stopPropagation(),c([$]),o?o():N(!0),(Re=g.onNodeDoubleClick)==null||Re.call(g,$,e))},onKeyDown:he=>{!K&&!o||y.readOnly||Q&&!y.editable||he.target!==he.currentTarget||he.key!=="Enter"||(he.preventDefault(),he.stopPropagation(),c([$]),o?o():N(!0))}},ye=K&&f.jsx(du,{nodeAddress:$,active:O,label:e.label||e.headerTitle||"Node",open:_&&(!Q||!!y.editable&&!y.readOnly),onClose:()=>{var he;N(!1),O&&((he=R.current)==null||he.focus({preventScroll:!0}))},children:Q?f.jsx(uu,{nodeId:$,content:e.label??e.text??"",color:Me(S),editOnMount:!0,onChange:he=>{var Re;return(Re=g.onNodeLabelChange)==null?void 0:Re.call(g,$,String(he))},onEditEnd:()=>N(!1)}):void 0}),we=Array.isArray((J=e==null?void 0:e.config)==null?void 0:J.ports)?e.config.ports.map(he=>f.jsx(tv,{...he},`${he.id}:${he.role}`)):null;return n?f.jsxs(V.Box,{ref:R,...ie,onClick:F,onDoubleClick:G,onMouseEnter:D,onMouseLeave:ce,cursor:"pointer",position:"relative",children:[ye,!p&&(ee||I&&I.length>0)&&k&&!q&&f.jsxs(f.Fragment,{children:[f.jsx(V.Box,{position:"absolute",top:-150,left:"0",right:"0",height:"150px",pointerEvents:"auto",onMouseEnter:()=>T(!0),onMouseLeave:ce}),ee?f.jsx(V.Box,{position:"absolute",zIndex:1e3,top:ne,transformOrigin:oe,left:"50%",pointerEvents:"auto",transform:pe,onMouseEnter:()=>T(!0),onMouseLeave:ce,willChange:"transform",children:ee({nodeId:$,nodeData:e,isRoot:$==="root",isParent:!0,isHovered:k,setIsHovered:T})}):f.jsx(V.Box,{position:"absolute",zIndex:1e3,top:ne,transformOrigin:oe,left:"50%",bg:w,p:3,borderColor:C,borderWidth:1,borderRadius:"30px",pointerEvents:"auto",transform:pe,boxShadow:"lg",onMouseEnter:()=>T(!0),onMouseLeave:ce,willChange:"transform",children:f.jsxs(V.HStack,{px:2,gap:2,"data-flow-grid-toolbar":(e==null?void 0:e.type)==="grid"?"":void 0,css:(e==null?void 0:e.type)==="grid"?{"& button svg":{width:"22px",height:"22px",minWidth:"22px",minHeight:"22px"}}:void 0,children:[I.map((he,Re)=>f.jsxs(V.Box,{display:"contents",children:[Re>0&&f.jsx(V.Box,{borderColor:C,height:5,borderRightWidth:1}),f.jsx(Sd,{icon:he.icon,label:he.label,color:S,bgColor:w,borderColor:C,textColor:S,boxSize:5,onClick:ze=>{var Te;ze.stopPropagation(),(Te=g.onNodeHoverAction)==null||Te.call(g,he.id,$,e)}})]},he.id)),ae&&f.jsx(ae,{data:e})]})})]}),r({id:$,data:e,isActive:O,isHovered:k,isLowZoom:q,isEditing:E,onSelect:F,onEditStart:()=>M(!0),onEditEnd:()=>M(!1)}),B&&!((xe=e==null?void 0:e.config)!=null&&xe.parentContainer)&&((Se=e==null?void 0:e.config)==null?void 0:Se.collapsed)!==void 0&&(()=>{var ze;const he=x==="TB"||x==="BT",Re=t||x==="RL";return f.jsx(V.IconButton,{position:"absolute",...he?{[x==="BT"?"top":"bottom"]:"-75px",left:"50%",transform:"translateX(-50%)"}:{right:Re?void 0:"-75px",left:Re?"-75px":void 0,top:"50%",transform:"translateY(-50%)"},"data-flow-collapse-control":"","aria-label":e.config.collapsed?"Expand":"Collapse",disabled:y.readOnly,onClick:Te=>{var qe;Te.stopPropagation(),(qe=g.onNodeCollapse)==null||qe.call(g,$,!e.config.collapsed)},bgColor:Me(((ze=e==null?void 0:e.viewProps)==null?void 0:ze.bgColor)||b),size:"md",color:"gray.100",rounded:"full",mr:2,px:2,py:4,children:e.config.collapsed?f.jsx(Y.PiPlusBold,{size:30,color:Me("gray.800")}):f.jsx(Y.PiMinusBold,{size:30,color:Me("gray.800")})})})()]}):f.jsxs(V.Box,{ref:R,...ie,onClick:F,onDoubleClick:G,onMouseEnter:D,onMouseLeave:ce,cursor:"pointer",transition:"transform 0.1s ease",position:"relative",children:[ye,we,!p&&(ee||I&&I.length>0)&&k&&!q&&f.jsxs(f.Fragment,{children:[f.jsx(V.Box,{position:"absolute",top:-150,left:"0",right:"0",height:"150px",pointerEvents:"auto",onMouseEnter:()=>T(!0),onMouseLeave:ce}),ee?f.jsx(V.Box,{position:"absolute",zIndex:1e3,top:ne,transformOrigin:oe,left:"50%",pointerEvents:"auto",transform:pe,onMouseEnter:()=>T(!0),onMouseLeave:ce,willChange:"transform",children:ee({nodeId:$,nodeData:e,isRoot:$==="root",isParent:!!n,isHovered:k,setIsHovered:T})}):f.jsx(V.Box,{position:"absolute",zIndex:1e3,top:ne,transformOrigin:oe,left:"50%",bg:w,p:3,borderColor:C,borderWidth:1,borderRadius:"30px",pointerEvents:"auto",transform:pe,boxShadow:"lg",onMouseEnter:()=>T(!0),onMouseLeave:ce,willChange:"transform",children:f.jsxs(V.HStack,{px:2,gap:2,"data-flow-grid-toolbar":(e==null?void 0:e.type)==="grid"?"":void 0,css:(e==null?void 0:e.type)==="grid"?{"& button svg":{width:"22px",height:"22px",minWidth:"22px",minHeight:"22px"}}:void 0,children:[I.map((he,Re)=>f.jsxs(V.Box,{display:"contents",children:[Re>0&&f.jsx(V.Box,{borderColor:C,height:5,borderRightWidth:1}),f.jsx(Sd,{icon:he.icon,label:he.label,color:S,bgColor:w,borderColor:C,textColor:S,boxSize:5,onClick:ze=>{var Te;ze.stopPropagation(),(Te=g.onNodeHoverAction)==null||Te.call(g,he.id,$,e)}})]},he.id)),ae&&f.jsx(ae,{data:e})]})})]}),f.jsxs(V.Box,{position:"relative",display:"flex",h:"100%",w:"100%",children:[B&&!((Fe=e==null?void 0:e.config)!=null&&Fe.parentContainer)&&((De=e==null?void 0:e.config)==null?void 0:De.collapsed)!==void 0&&!n&&(()=>{var Te,qe,Qe;const he=x==="TB"||x==="BT",Re=t||x==="RL",ze=(Te=e==null?void 0:e.config)!=null&&Te.labelBelow&&v[$]!=="properties"?((((qe=e==null?void 0:e.viewProps)==null?void 0:qe.fontSize)||1)*100+100)/2:void 0;return f.jsx(V.IconButton,{position:"absolute",...he?{[x==="BT"?"top":"bottom"]:"-75px",left:"50%",transform:"translateX(-50%)"}:{right:Re?void 0:ze===void 0?"-75px":`calc(50% - ${ze+75}px)`,left:Re?ze===void 0?"-75px":`calc(50% - ${ze+75}px)`:void 0,alignSelf:ze===void 0?"center":void 0,top:ze===void 0?void 0:`${ze}px`,transform:ze===void 0?void 0:"translateY(-50%)",zIndex:ze===void 0?void 0:1},"data-flow-collapse-control":"","aria-label":e.config.collapsed?"Expand":"Collapse",disabled:y.readOnly,onClick:ct=>{var Pe;ct.stopPropagation(),(Pe=g.onNodeCollapse)==null||Pe.call(g,$,!e.config.collapsed)},bgColor:Me(((Qe=e==null?void 0:e.viewProps)==null?void 0:Qe.bgColor)||b),size:"md",color:"gray.100",rounded:"full",mr:2,px:2,py:4,children:e.config.collapsed?f.jsx(Y.PiPlusBold,{size:30,color:Me("gray.800")}):f.jsx(Y.PiMinusBold,{size:30,color:Me("gray.800")})})})(),r({id:$,data:e,isActive:O,isHovered:k,isLowZoom:q,isEditing:E,onSelect:F,onEditStart:()=>M(!0),onEditEnd:()=>M(!1)})]})]})},Un=j.memo(Qj),eE=({id:e,data:r,isActive:t,isEditing:n,onEditStart:o,onEditEnd:i})=>{var g,y,b,x,v,w,C,S;const{themeColor:s}=Je(),{colorText:a}=lt(),c=((g=r==null?void 0:r.viewProps)==null?void 0:g.bgColor)==="transparent",l=((y=r==null?void 0:r.viewProps)==null?void 0:y.outline)===!0,{highlightColor:d,borderColor:u,textColor:h}=Ln(((b=r==null?void 0:r.viewProps)==null?void 0:b.bgColor)||s),p=Me(((x=r==null?void 0:r.viewProps)==null?void 0:x.textColor)||(c||l?a:h)),m=((v=r==null?void 0:r.viewProps)==null?void 0:v.borderColor)||(l?!c&&((w=r==null?void 0:r.viewProps)==null?void 0:w.bgColor)||s:u);return f.jsx(V.Box,{"data-flow-node-surface":"",borderRadius:(C=r==null?void 0:r.viewProps)==null?void 0:C.borderRadius,bgColor:l?"transparent":d,...$n(r==null?void 0:r.viewProps,m,t,2),py:14,px:20,whiteSpace:"nowrap",w:"fit-content",children:f.jsxs(V.Flex,{justifyContent:"start",alignItems:"center",gap:8,w:"fit-content",maxW:900,minW:0,fontSize:"5xl",lineHeight:"normal",children:[((S=r==null?void 0:r.config)==null?void 0:S.icon)&&f.jsx(V.Box,{flexShrink:0,children:f.jsx(or,{name:r.config.icon,size:80,color:p})}),f.jsx(tn,{nodeId:e,label:(r==null?void 0:r.label)||(r==null?void 0:r.text)||"",color:p,isEditing:n,onEditStart:o,onEditEnd:i})]})})};function fu(e,r,t){const{readOnly:n,selectedNodeIds:o}=Je(),i=o.includes(e),s=j.useRef(i),a=j.useRef(t);a.current=t,j.useEffect(()=>{s.current&&!i&&r&&!n&&a.current(),s.current=i},[i,r,n])}function Hn(){const{nodeViewModes:e,setNodeViewMode:r,allNodesIconLabel:t,setAllNodesIconLabel:n}=Je();return{allNodesIconLabel:t,setAllNodesIconLabel:n,getNodeViewMode:o=>e[o]??"default",showNodeProperties:o=>r(o,"properties"),restoreNodeView:o=>r(o,"default"),toggleNodeView:o=>r(o,e[o]==="properties"?"default":"properties"),setNodeViewMode:r}}const tE=({id:e,isActive:r,data:t,isEditing:n,onEditStart:o,onEditEnd:i})=>{var v,w,C,S,R,P,k,T,E,M,_,N,$,B,O;const{themeColor:s}=Je(),{colorText:a}=lt(),c=((v=t==null?void 0:t.viewProps)==null?void 0:v.bgColor)==="transparent",l=((w=t==null?void 0:t.viewProps)==null?void 0:w.outline)===!0,d=!c&&((C=t==null?void 0:t.viewProps)==null?void 0:C.bgColor)||s,{borderColor:u,highlightColor:h,textColor:p}=Ln(d),m=Me(((S=t==null?void 0:t.viewProps)==null?void 0:S.textColor)||(c||l?a:p)),g=c&&!l&&!((R=t==null?void 0:t.viewProps)!=null&&R.borderColor)?"transparent":Me(((P=t==null?void 0:t.viewProps)==null?void 0:P.borderColor)||(l?d:u)),y=c||l?"transparent":d!=null&&d.startsWith("#")?d:Me(h),b=(k=t==null?void 0:t.config)==null?void 0:k.icon,x=(t==null?void 0:t.label)??(t==null?void 0:t.text)??"";if((T=t==null?void 0:t.config)!=null&&T.labelBelow){const I=(((E=t==null?void 0:t.viewProps)==null?void 0:E.fontSize)||1)*100;return f.jsxs(V.Flex,{"data-flow-icon-label":"",css:{"--flow-grid-on-surface-color":m},direction:"column",align:"center",gap:"24px",width:`${Math.max(I+200,360)}px`,position:"relative",children:[f.jsx(V.Flex,{"data-flow-node-surface":"",align:"center",justify:"center",width:`${I+100}px`,height:`${I+100}px`,flexShrink:0,borderRadius:(M=t==null?void 0:t.viewProps)==null?void 0:M.borderRadius,backgroundColor:y,...$n(t==null?void 0:t.viewProps,g,r,2),children:!!b&&f.jsx(or,{name:b,size:I,color:m})}),f.jsxs(V.Flex,{"data-flow-icon-caption":"",direction:"column",align:"center",gap:"8px",justify:"center",width:"100%",minW:0,textAlign:"center",children:[f.jsx(tn,{nodeId:e,label:x,color:`var(--flow-grid-caption-color, ${Me(((_=t==null?void 0:t.viewProps)==null?void 0:_.textColor)||a)})`,isEditing:n,onEditStart:o,onEditEnd:i,wrap:!0}),typeof((N=t.config)==null?void 0:N.subtitle)=="string"&&t.config.subtitle!==""&&f.jsx(V.Text,{"data-flow-node-subtitle":"",color:Me((($=t==null?void 0:t.viewProps)==null?void 0:$.textColor)||a),opacity:.65,fontSize:"32px",fontWeight:"normal",lineHeight:1.3,width:"100%",whiteSpace:"nowrap",overflow:"hidden",textOverflow:"ellipsis",title:t.config.subtitle,children:t.config.subtitle})]})]})}return f.jsxs(V.Flex,{"data-flow-node-surface":"",align:"center",borderRadius:(B=t==null?void 0:t.viewProps)==null?void 0:B.borderRadius,bgColor:y,style:{backgroundColor:y},textTransform:"capitalize",...$n(t==null?void 0:t.viewProps,g,r,2),px:50,w:"fit-content",whiteSpace:"nowrap",children:[!!b&&f.jsx(V.Flex,{align:"center",py:14,mr:x?8:0,flexShrink:0,children:f.jsx(or,{name:b,size:(((O=t==null?void 0:t.viewProps)==null?void 0:O.fontSize)||1)*100,color:m},m)}),(x||!b)&&f.jsx(V.Flex,{justifyContent:"start",py:14,fontSize:"5xl",lineHeight:"normal",w:"fit-content",maxW:900,minW:0,children:f.jsx(tn,{nodeId:e,label:x,color:m,isEditing:n,onEditStart:o,onEditEnd:i})})]})};function uo({onExpand:e,toggleLabel:r="Show properties",toggleDisabled:t=!1,renderCompact:n=tE,...o}){const{colorMode:i,callbacks:s}=Je();return f.jsx(Un,{...o,hoverLeaveDelay:e?350:0,children:a=>f.jsxs(V.Box,{position:"relative",children:[f.jsx(n,{...a}),e&&(a.isHovered||a.isActive)&&f.jsx(V.Box,{position:"absolute",top:"-24px",right:"-48px","data-flow-content-toggle":"",children:f.jsx(He,{label:r,children:f.jsx(Oe,{"aria-label":r,icon:f.jsx(V.Icon,{as:Y.PiCircleFill,boxSize:4}),variant:"ghost",w:12,h:12,minW:12,color:i==="dark"?"gray.100":"gray.800",disabled:t,onClick:c=>{var l;c.stopPropagation(),a.isActive||a.onSelect(c,!0),(l=s.onNodeViewToggle)==null||l.call(s,o.data.id),e()}})})})]})})}const rE=(e,r,t)=>{var h,p,m,g;const n=((h=e==null?void 0:e.viewProps)==null?void 0:h.bgColor)||r,[o]=n.split("."),i=Ln(n),s=((p=e==null?void 0:e.viewProps)==null?void 0:p.outline)===!0,a=n==="transparent"||s,c=t==="dark"?"gray.200":"gray.900",l=a?"transparent":n!=null&&n.startsWith("#")?Me(n):Me(i.bgColor),d=Me(((m=e==null?void 0:e.viewProps)==null?void 0:m.textColor)||(a?c:i.textColor)),u=Me(((g=e==null?void 0:e.viewProps)==null?void 0:g.borderColor)||(s?n==="transparent"?r:n:i.borderColor));return{...i,bgColor:a?"transparent":i.bgColor,highlightColor:a?"transparent":i.highlightColor,isTransparent:a,propertyColor:a?c:i.propertyColor,bg:n,wordBeforeDot:o,hexbgColor:l,hextextColor:d,hexborderColor:u}},nE=(e,r=350)=>`${String(e).substring(0,r)}${String(e).length>r?"...":""}`,oE=e=>e!=null&&e.includes("root")?e.replace("root","untitled"):e,ov=600,iE=3,aE=e=>{const r=Math.max(...Object.keys(e||{}).map(n=>n.length),0);return Math.max(r*28+30,200)};function sE({headerTitle:e,hasContent:r,data:t,icon:n,colors:o,hasConfig:i,id:s,isActive:a,isHovered:c,isEditing:l,onSelect:d,onEditStart:u,onEditEnd:h,props:p,objVisible:m,setObjVisible:g,onShowNativeIcon:y}){var w,C,S,R;const{callbacks:b}=Je();if(r&&!m&&t.label===""&&(((w=t.config)==null?void 0:w.contentFormat)==="html"||((C=t.config)==null?void 0:C.contentFormat)==="jsx"))return null;const x=p.onShowIcon??y,v=x?"Show icon":m?"Show content":"Show properties";return f.jsx(f.Fragment,{children:(e||r||((S=t.config)==null?void 0:S.form)||(a||c)&&y)&&f.jsxs(V.Flex,{justify:"flex-start",direction:"row",p:r||Object.entries(t.description||{}).length?8:20,borderBottomWidth:1,minWidth:"max-content !important",width:"100%",textTransform:"capitalize",align:"center",textOverflow:"ellipsis",alignItems:"center",fontWeight:"bold",color:o.propertyColor,bgColor:o.highlightColor,borderBottomColor:!i&&!r?"transparent":o.hexborderColor,children:[!!n&&f.jsx(V.Flex,{mr:6,alignItems:"center",flexShrink:0,children:f.jsx(or,{name:n,size:64,color:o.hextextColor},o.hextextColor)}),f.jsx(tn,{nodeId:s,label:oE(e),color:((R=t==null?void 0:t.viewProps)==null?void 0:R.textColor)||o.propertyColor,isEditing:l,onEditStart:u,onEditEnd:h}),(a||c)&&(r||x)&&f.jsx(V.Box,{ml:"auto",pl:6,flexShrink:0,"data-flow-content-toggle":"",children:f.jsx(He,{label:v,children:f.jsx(Oe,{"aria-label":v,icon:f.jsx(V.Icon,{as:Y.PiCircleFill,boxSize:4}),variant:"ghost",w:12,h:12,minW:12,color:o.hextextColor,onClick:P=>{var k;P.stopPropagation(),a||d(P),x?x():g(!m),(k=b.onNodeViewToggle)==null||k.call(b,s)}})})})]})})}function cE({data:e,resourcePorts:r,inspecting:t,form:n,inspectionPorts:o,extraPorts:i,colors:s,direction:a,uniformKeyWidth:c}){const{edgeById:l}=Kt(),d=new Set;for(const{data:u}of l.values())u.source===e.id&&u.sourceProperty!==void 0&&d.add(`source:${u.sourceProperty}`),u.target===e.id&&u.targetProperty!==void 0&&d.add(`target:${u.targetProperty}`);return f.jsx(V.Box,{children:Object.entries(e.description||{}).map(([u,h],p)=>{var _,N,$;const m=r&&Object.keys(r).find(B=>B.slice(B.indexOf(":")+1)===u),g=t&&((_=n==null?void 0:n.type.ports)==null?void 0:_[u]),y=m??(g?`${g.kind}:${u}`:u),b=o.find(B=>B.id===y),x=m?"source":b==null?void 0:b.role,v=d.has(`source:${y}`),w=d.has(`target:${y}`),C=i.some(B=>B.id===u),S=h===""&&(C||(x?d.has(`${x}:${y}`):v||w)),R=x??(v!==w?v?"source":"target":void 0),P=(b==null?void 0:b.side)??(R?R==="source"!=(a==="RL")?"right":"left":void 0),k=S&&P==="right"?"right":"left",T=(b==null?void 0:b.label)??(g==null?void 0:g.label)??(C?u.replace(/^(template|input|output|config|error):/,""):u),E=nr(s.wordBeforeDot)[typeof h],M=nr(s.wordBeforeDot).property;return f.jsxs(V.Box,{"data-flow-property":m&&(a==="TB"||a==="BT")?void 0:y,"data-flow-port-role":x,"data-flow-inspection-row":t?"":void 0,children:[f.jsxs(V.Flex,{flexWrap:"nowrap",overflow:"hidden",children:[f.jsx(V.Flex,{justifyContent:"start",align:"center",background:s.highlightColor,width:S?"100%":`${c}px`,minWidth:`${c}px`,borderRightColor:s.hexborderColor,borderRightWidth:S?0:1,children:f.jsx(V.Text,{py:5,px:10,w:"100%",textAlign:k,whiteSpace:"nowrap",fontWeight:"bold",fontSize:"4xl",color:((N=e==null?void 0:e.viewProps)==null?void 0:N.textColor)||(s.isTransparent?s.hextextColor:M),children:T})}),!S&&f.jsx(V.Flex,{flex:1,justifyContent:"start",overflow:"hidden",p:4,background:s.hexbgColor,w:ov,maxH:200,children:f.jsx(V.Text,{overflow:"hidden",py:3,px:4,whiteSpace:"normal",textOverflow:"ellipsis",fontSize:"4xl",color:(($=e==null?void 0:e.viewProps)==null?void 0:$.textColor)||(s.isTransparent?s.hextextColor:E),fontWeight:400,children:nE(h)})})]}),p!==Object.entries(e.description||{}).length-1&&f.jsx(V.Box,{borderTopWidth:1,my:0,borderColor:s.hexborderColor})]},u)})})}function lE(e){var v,w,C,S,R;const{themeColor:r,colorMode:t,direction:n}=Je(),o=Hn(),i=o.getNodeViewMode(e.data.id)==="properties",s=P=>o.setNodeViewMode(e.data.id,P?"properties":"default"),a=!!e.onShowIcon||i||typeof((v=e.data.config)==null?void 0:v.content)!="string"&&!(((w=e.data.config)==null?void 0:w.contentFormat)==="jsx"&&Array.isArray((C=e.data.config)==null?void 0:C.content)),{bindings:c,data:l,schema:d}=j.useContext(Tt),u=(S=c==null?void 0:c[e.data.id])==null?void 0:S.portResources,h=c?Fn(c,e.data.id,d):l&&d?on(l,e.data.id,d):void 0,p=h&&Le(l,"address"in h?h.address:e.data.id),m=p&&typeof p=="object"&&h?Object.fromEntries(Object.keys(h.type.properties).filter(P=>{var k;return Object.prototype.hasOwnProperty.call(p,P)&&bo((k=h.fields[P])==null?void 0:k.$visibleWhen,l)}).map(P=>[P,p[P]!==null&&typeof p[P]=="object"?JSON.stringify(p[P],null,2):p[P]===null?"null":p[P]])):{},g=u?Object.fromEntries(Object.entries(u).map(([P,k])=>{var T;return[P.slice(P.indexOf(":")+1),((T=Le(l,k))==null?void 0:T.name)??k.split(".").at(-1)]})):Object.keys(e.data.description??{}).length?e.data.description:m,y=a&&!u?((R=e.data.config)==null?void 0:R.ports)??[]:[],b=y.filter(P=>!Object.prototype.hasOwnProperty.call(g,P.id)&&!Object.entries((h==null?void 0:h.type.ports)??{}).some(([k,T])=>`${T.kind}:${k}`===P.id&&Object.prototype.hasOwnProperty.call(g,k))),x={...g,...Object.fromEntries(b.map(P=>[P.id,""]))};return{themeColor:r,colorMode:t,direction:n,objVisible:i,setObjVisible:s,inspecting:a,resourcePorts:u,form:h,description:x,inspectionPorts:y,extraPorts:b}}const hu=e=>{var x,v,w,C,S,R,P,k;const{themeColor:r,colorMode:t,direction:n,objVisible:o,setObjVisible:i,inspecting:s,resourcePorts:a,form:c,description:l,inspectionPorts:d,extraPorts:u}=lE(e),h=Hn(),p=h.getNodeViewMode(e.data.id)==="icon-label",m=!e.onShowIcon&&(typeof((x=e.data.config)==null?void 0:x.content)=="string"||((v=e.data.config)==null?void 0:v.contentFormat)==="jsx"&&Array.isArray((w=e.data.config)==null?void 0:w.content)),g=j.useRef(p);p&&(g.current=!0),fu(e.data.id,m&&!((C=e.data.config)!=null&&C.parentContainer)&&h.allNodesIconLabel&&!p&&g.current,()=>h.setNodeViewMode(e.data.id,"icon-label"));const b=!e.onShowIcon&&!((S=e.data.config)!=null&&S.parentContainer)?()=>h.setNodeViewMode(e.data.id,"icon-label"):void 0;return!e.onShowIcon&&p?f.jsx(uo,{...e,data:{...e.data,label:e.data.label??e.data.headerTitle,config:{...e.data.config,labelBelow:!0,icon:((R=e.data.config)==null?void 0:R.icon)||(m?((P=e.data.config)==null?void 0:P.contentFormat)==="html"?"PiFileHtml":((k=e.data.config)==null?void 0:k.contentFormat)==="jsx"?"PiFileJsx":"PiMarkdownLogo":"PiBracketsCurly")}},onExpand:()=>h.restoreNodeView(e.data.id)}):f.jsx(Un,{...e,data:{...e.data,description:l},hoverLeaveDelay:m||e.onShowIcon||b?350:0,children:({id:T,data:E,isActive:M,isHovered:_,isEditing:N,onSelect:$,onEditStart:B,onEditEnd:O})=>{var ce,Q,K,ie,ye,we,fe,ge,X,H,be,J,xe,Se,Fe,De;const I=rE(E,r,t),ee=E.label??E.headerTitle,ae=Object.entries(E.description||{}).length>0,ne=aE(E.description),oe=(Q=(ce=e.data)==null?void 0:ce.config)==null?void 0:Q.icon,pe=(ie=(K=e.data)==null?void 0:K.config)==null?void 0:ie.content,q=m&&!o&&E.label===""&&(((ye=E.config)==null?void 0:ye.contentFormat)==="html"||((we=E.config)==null?void 0:we.contentFormat)==="jsx"),F=m&&!o&&(((fe=E.config)==null?void 0:fe.contentFormat)==="html"||((ge=E.config)==null?void 0:ge.contentFormat)==="jsx")&&((X=E.viewProps)==null?void 0:X.width)!==void 0&&E.viewProps.width!=="100%",G=((H=E==null?void 0:E.viewProps)==null?void 0:H.borderRadius)??"53px",D=$n(E==null?void 0:E.viewProps,I.hexborderColor,M,iE);return f.jsx(V.Flex,{justifyContent:"space-between",...E==null?void 0:E.viewProps,"data-flow-node-surface":"",direction:"column",p:0,borderRadius:G,overflow:"hidden",alignItems:"center",style:{backgroundColor:I.hexbgColor,transition:"border-color 0.2s ease-in-out"},width:q||F?((be=E.viewProps)==null?void 0:be.width)!==void 0&&E.viewProps.width!=="100%"?E.viewProps.width:"max-content":"100%",maxW:q?"calc(100vw - 40px)":void 0,minW:q||F?0:m||e.onShowIcon?ne+ov+D.borderWidth*2:void 0,...D,children:f.jsxs(V.Flex,{width:"100%",direction:"column",borderRadius:G,borderColor:I.hexborderColor,borderWidth:0,overflow:"hidden",children:[!e.fillBody&&f.jsx(sE,{headerTitle:ee,hasContent:m,data:E,icon:oe,colors:I,hasConfig:ae,id:T,isActive:M,isHovered:_,isEditing:N,onSelect:$,onEditStart:B,onEditEnd:O,props:e,objVisible:o,setObjVisible:i,onShowNativeIcon:b}),m&&!o?f.jsx(V.Flex,{w:"100%",overflow:"auto",justifyContent:"start",background:I.highlightColor,p:["html","jsx"].includes((xe=(J=e.data)==null?void 0:J.config)==null?void 0:xe.contentFormat)?0:12,fontSize:"5xl",lineHeight:"normal",children:f.jsx(uu,{nodeId:T,content:pe,format:(Fe=(Se=e.data)==null?void 0:Se.config)==null?void 0:Fe.contentFormat,fillBody:e.fillBody,autoHeight:q,color:((De=E==null?void 0:E.viewProps)==null?void 0:De.textColor)||I.hextextColor})}):f.jsx(cE,{data:E,resourcePorts:a,inspecting:s,form:c,inspectionPorts:d,extraPorts:u,colors:I,direction:n,uniformKeyWidth:ne})]})})}})};hu.displayName="NodeJsonObjectView";const iv=e=>{var h,p,m,g,y,b,x,v,w,C,S,R;const r=Hn(),[t,n]=j.useState(!1),o=r.getNodeViewMode(e.data.id)==="properties",i=P=>{n(P),r.setNodeViewMode(e.data.id,P?"properties":"default")},{callbacks:s,readOnly:a}=Je(),c=(p=(h=e.data)==null?void 0:h.config)==null?void 0:p.parentContainer;fu(e.data.id,o&&((g=(m=e.data)==null?void 0:m.config)==null?void 0:g.labelBelow)&&!c,()=>i(!1));const l=c?"Show parent":"Show properties",d=c||((b=(y=e.data)==null?void 0:y.config)==null?void 0:b.form)||((w=(v=(x=e.data)==null?void 0:x.config)==null?void 0:v.ports)==null?void 0:w.length),u=d?()=>{var P;c?(P=s.onNodeCollapse)==null||P.call(s,e.data.id,!1):i(!0)}:void 0;return!c&&e.data.type==="text"&&r.getNodeViewMode(e.data.id)==="icon-label"?f.jsx(uo,{...e,renderCompact:void 0,data:{...e.data,config:{...e.data.config,labelBelow:!0,icon:((C=e.data.config)==null?void 0:C.icon)||"PiTextT"}},toggleLabel:"Show text",onExpand:()=>r.restoreNodeView(e.data.id)}):!c&&d&&o?f.jsx(hu,{...e,editOnMount:t,onShowIcon:()=>i(!1)}):f.jsx(uo,{...e,onOpenView:u&&(c||(R=(S=e.data)==null?void 0:S.config)!=null&&R.labelBelow)?()=>{var P;u(),(P=s.onNodeViewToggle)==null||P.call(s,e.data.id)}:void 0,toggleLabel:!c&&e.data.type==="text"?"Show icon":l,toggleDisabled:c&&a,onExpand:!c&&e.data.type==="text"?()=>r.setNodeViewMode(e.data.id,"icon-label"):u})};function dE(e){var b,x,v,w,C,S;const{config:r,callbacks:t,readOnly:n,selectedNodeIds:o,nodeRadiusPreviews:i,nodeViewModes:s,allNodesIconLabel:a}=Je(),c=i[e.data.id]??((b=e.data.viewProps)==null?void 0:b.borderRadius),[l,d]=j.useState(!1),u=Hn(),{border:h,colorText:p}=lt(),m=(x=r.customViews)==null?void 0:x.gridContent,g=(s[e.data.id]??(a?"icon-label":"default"))==="icon-label",y=j.useRef(g);return g&&(y.current=!0),fu(e.data.id,a&&!g&&y.current,()=>u.setNodeViewMode(e.data.id,"icon-label")),g?f.jsx(V.Box,{"data-grid-document":((v=e.data.config)==null?void 0:v.documentId)??"",children:f.jsx(uo,{...e,data:{...e.data,viewProps:{...e.data.viewProps,borderRadius:c},config:{...e.data.config,labelBelow:!0,icon:((w=e.data.config)==null?void 0:w.icon)||"PiGridFour"}},toggleLabel:"Show grid",onExpand:()=>u.restoreNodeView(e.data.id)})}):f.jsxs(f.Fragment,{children:[f.jsx(Un,{...e,onOpenView:()=>d(!0),children:({data:R,isActive:P})=>{var k,T,E,M,_,N,$,B;return f.jsx(V.Box,{"data-flow-node-surface":"","data-grid-document":((k=R.config)==null?void 0:k.documentId)??"",width:`${((E=(T=R.config)==null?void 0:T.gridSize)==null?void 0:E.width)??600}px`,height:`${((_=(M=R.config)==null?void 0:M.gridSize)==null?void 0:_.height)??440}px`,overflow:"hidden",position:"relative",bg:((N=R.viewProps)==null?void 0:N.bgColor)??"transparent",color:(($=R.viewProps)==null?void 0:$.textColor)??p,borderRadius:`${c??0}px`,...$n(R.viewProps,Me(((B=R.viewProps)==null?void 0:B.borderColor)??h),P,0),children:m?f.jsx(m,{...e}):f.jsx(V.Box,{p:4,children:R.label??"Grid"})})}}),f.jsx(du,{nodeAddress:e.data.id,active:o.includes(e.data.id),label:e.data.label??"Grid",open:l&&!n,onClose:()=>d(!1),children:f.jsx(Tt.Provider,{value:{data:{metadata:{label:e.data.label??"",subtitle:((C=e.data.config)==null?void 0:C.subtitle)??"",icon:((S=e.data.config)==null?void 0:S.icon)??"PiGridFour"}},bindings:{[e.data.id]:{address:"root.metadata",type:"GridMetadata"}},schema:{GridMetadata:{kind:"object",properties:{label:{optional:!0,type:{kind:"string"}},subtitle:{optional:!0,type:{kind:"string"}},icon:{optional:!0,type:{kind:"string"}}}}},editable:!!r.editable&&!n,callbacks:{onFormChange:R=>{var k,T,E;if(n||!r.editable)return;const P=String(R.value??"");R.address==="root.metadata.label"?(k=t.onNodeLabelChange)==null||k.call(t,e.data.id,P):R.address==="root.metadata.subtitle"?(T=t.onNodeSubtitleChange)==null||T.call(t,e.data.id,P):R.address==="root.metadata.icon"&&((E=t.onNodeIconChange)==null||E.call(t,e.data.id,P))}}},children:f.jsx(Ld,{nodeAddress:e.data.id})})})]})}const av=e=>f.jsx(iv,{...e,renderCompact:eE}),sv=e=>f.jsx(iv,{...e}),cv=({containerStyle:e,...r})=>{const{selectedNodeIds:t}=Je();return f.jsx(Un,{...r,editOnMount:t.includes(r.data.id),children:n=>f.jsx(V.Box,{bg:e.textColor==="transparent"?"transparent":e.labelBg,p:`${e.fontSize/5}px`,fontFamily:mr,lineHeight:1,w:"fit-content",children:f.jsx(tn,{nodeId:n.id,label:n.data.label??n.data.headerTitle??"Container",color:e.textColor,fontSize:`${e.fontSize}px`,isEditing:n.isEditing,onEditStart:n.onEditStart,onEditEnd:n.onEditEnd})})})};av.displayName="text";sv.displayName="arrayView";cv.displayName="ParentContainerView";const uE={grid:dE,objectView:hu,arrayView:sv,text:av,parentContainer:cv},fE=({children:e,pattern:r="dot",backgroundColor:t})=>{const{colorMode:n}=Je(),o=n==="dark",i=o?"--chakra-colors-gray-700":"--chakra-colors-gray-500",s=o?"--chakra-colors-gray-700":"--chakra-colors-gray-800";return r==="none"?f.jsx(V.Box,{"data-flow-background":"none",width:"100%",height:"100%",padding:0,bg:t,children:e}):f.jsxs(V.Box,{"data-flow-background":r,position:"relative",width:"100%",height:"100%",padding:0,bg:t,children:[f.jsx(V.Box,{position:"absolute",top:0,left:0,right:0,bottom:0,width:"100%",height:"100%",zIndex:0,pointerEvents:"none",style:{backgroundImage:r==="dot"?`radial-gradient(var(${i}) 8%, transparent 8%)`:r==="steel"?`repeating-linear-gradient(45deg, var(${s}) 0, var(${s}) 1px, transparent 1px, transparent 20px)`:`linear-gradient(var(${s}) 1px, transparent 1px), linear-gradient(90deg, var(${s}) 1px, transparent 1px)`,backgroundSize:"20px 20px",opacity:.3}}),f.jsx(V.Box,{position:"relative",width:"100%",height:"100%",zIndex:1,padding:0,children:e})]})},hE=.4,Mr={borderWidth:6,borderStyle:"solid",borderRadius:50,fontSize:70,padding:120,labelPosition:"top",labelMargin:90},pE=({nodes:e,edges:r})=>{var We;const{themeColor:t,spacing:n,edgeRadius:o,backgroundVariant:i,backgroundSelected:s,setBackgroundSelected:a,edgeColor:c,direction:l,nodeAlignment:d,edgeMode:u,compactPropertyLayout:h,workflowContract:p,parentNodeStyle:m,engineRef:g,callbacks:y,config:b,selectedNodeIds:x,setSelectedNodeIds:v,selectedEdgeId:w,setSelectedEdgeId:C,setIsPerformanceMode:S,setNodeGridOptions:R,fillRadiusEditedIds:P,isZoomMode:k,setIsZoomMode:T,isMultiSelectMode:E,setIsMultiSelectMode:M,isDragMode:_,setIsDragMode:N,isEdgeHandlesEnabled:$,setIsEdgeHandlesEnabled:B,isArrayNodeMode:O}=Je(),I=j.useRef(null),[ee,ae]=j.useState(null),ne=j.useRef(null),oe=e.length>200;j.useEffect(()=>{S(oe)},[oe,S]);const{edgeSep:pe,rankSep:q,spacingFactor:F}=j.useMemo(()=>{const de=Uw(e.length),W=b.nodeGridSpacing==="layout"&&n<.5?n*1.3:n<1?.3+.7*n:.5+.5*n;return{edgeSep:de.edgeSep*W,rankSep:de.rankSep*W,spacingFactor:1.3+(n-1)*(n<1?.4:.3)}},[e.length,n,b.nodeGridSpacing]),{bgColor:G}=Ln(t),{canvas:D,borderSecondary:ce,colorText:Q}=lt(),K=i==="transparent"?"transparent":b.backgroundColor||D,ie=j.useCallback(de=>{if(!de)return Me(t);switch(de){case"dark":return Me(K);case"light":return Me(ce);default:return Me(de)}},[t,K,ce]),ye=b.colorMode==="dark",we=ye?Me("gray.500"):rn,fe=ye?G!=null&&G.includes("gray")?"whitesmoke":ie(G):we,ge=c?ie(c):we,X=j.useMemo(()=>{var de;return b.initialViewport||{pan:{x:0,y:0},zoom:(de=b.nodeGrid)!=null&&de.enabled&&b.nodeGrid.options.fill?1:.01}},[]),H=l==="C"?"LR":l,be=j.useCallback(de=>{const W={...m,...de};return{...W,bgColor:W.bgColor||t,bgOpacity:W.outline?0:W.bgOpacity??hE}},[m,t]),J=j.useMemo(()=>{var W;const de=new Map;for(const se of e)(W=se.data)!=null&&W.id&&de.set(se.data.id,se);return de},[e]),xe=j.useMemo(()=>{var W;const de=new Map;for(const se of r)(W=se.data)!=null&&W.id&&de.set(se.data.id,se);return de},[r]),Se=j.useCallback(de=>{var U;const W=(U=J.get(de))==null?void 0:U.data,se=be(W==null?void 0:W.viewProps),Be=Me(se.bgColor);return{animated:!!(W!=null&&W.isNodeAnimated)&&!oe,animationVariant:W==null?void 0:W.nodeAnimationVariant,animationColor:Me(se.borderColor||t),bgColor:se.outline?"transparent":Be,bgOpacity:se.bgOpacity,borderColor:se.borderColor?Me(se.borderColor):se.outline&&se.bgColor==="transparent"?Me(t):Be,borderWidth:Nn(se.borderWidth,Mr.borderWidth),borderStyle:se.borderStyle??Mr.borderStyle,borderRadius:se.borderRadius??Mr.borderRadius,textColor:se.textColor?Me(se.textColor):se.outline||se.bgColor==="transparent"?Me(Q):Be,fontSize:se.fontSize??Mr.fontSize,labelPosition:se.labelPosition??Mr.labelPosition,labelMargin:Mr.labelMargin,labelBg:Eu(ie("dark"),Be,se.bgOpacity)??ie("dark"),padding:se.padding??Mr.padding}},[be,J,Q,t,oe,ie]),Fe=j.useMemo(()=>{var se,Be;const de=new Map;for(const U of r){const Ce=(se=U.data)==null?void 0:se.source,Ne=(Be=U.data)==null?void 0:Be.target;if(!Ce||!Ne||Ce===Ne)continue;const je=Ce<Ne?`${Ce}|${Ne}`:`${Ne}|${Ce}`,Ve=de.get(je);Ve?Ve.push({id:U.data.id,source:Ce}):de.set(je,[{id:U.data.id,source:Ce}])}const W=new Map;for(const[U,Ce]of de){if(Ce.length<2)continue;const Ne=U.split("|")[0],je=Math.min(20,70/Ce.length);Ce.forEach(({id:Ve,source:nt},Xe)=>{const St=50+(Xe-(Ce.length-1)/2)*je;W.set(Ve,(nt===Ne?St:100-St)/100)})}return W},[r]),De=j.useMemo(()=>{const de=ie("dark");return r.filter(W=>{var se;return((se=W.data)==null?void 0:se.id)&&W.data.source&&W.data.target}).map(({data:W})=>{var Ce,Ne,je,Ve,nt,Xe;let se=de;const Be=(Ne=(Ce=J.get(W.source))==null?void 0:Ce.data)==null?void 0:Ne.parent,U=(Ve=(je=J.get(W.target))==null?void 0:je.data)==null?void 0:Ve.parent;if(Be&&Be===U){const St=be((Xe=(nt=J.get(Be))==null?void 0:nt.data)==null?void 0:Xe.viewProps),kt=Eu(de,Me(St.bgColor),St.bgOpacity);kt&&(se=kt)}return{id:W.id,data:W,type:W.type??b.edgeType??"rounded-orthogonal",source:W.source,target:W.target,sourceProperty:W.sourceProperty,targetProperty:W.targetProperty,label:W.label,validationIssue:(u==="auto"||u==="properties")&&(W.sourceProperty!==void 0||W.targetProperty!==void 0)&&p?$d(p,W):void 0,color:c?ge:W.color?Me(W.color):ge,connectorColor:c?ge:W.color?Me(W.color):fe,labelBg:se,dashed:!!W.isEdgeDashed,animated:!!W.isEdgeAnimated,inverted:!!W.isInverted,turn:Fe.get(W.id)??.5}})},[r,ge,fe,c,Fe,b.edgeType,u,p,J,be,ie]),he=j.useMemo(()=>{var W;const de=new Set;for(const se of e)(W=se.data)!=null&&W.parent&&de.add(se.data.parent);return de},[e]),Re=j.useMemo(()=>{const de=new Map;for(const W of r){const se=W.data.isInverted?W.data.target:W.data.source;se&&!de.has(se)&&de.set(se,W.data)}for(const W of r){if(W.data.connection)continue;const se=W.data.isInverted?W.data.target:W.data.source,Be=W.data.isInverted?W.data.source:W.data.target;Be.startsWith(`${se}.`)&&(de.set(se,W.data),de.set(Be,W.data))}return de},[r]),ze=j.useMemo(()=>{const de={...uE,...b.customViews};return e.filter(W=>{var se;return(se=W.data)==null?void 0:se.id}).map(W=>{var Ve,nt,Xe,St,kt,Nt,$t,mt,ht;const se=he.has(W.data.id)&&!W.data.parent,Be=se?W.data.label??W.data.headerTitle??"Container":void 0,U=se?de.parentContainer:de[W.data.type]||de.text,Ce=((Ve=b.customViews)==null?void 0:Ve.fillNode)??U,Ne=Re.get(W.data.id),je={...W,isInverted:((nt=W.data.config)==null?void 0:nt.isInverted)??(Ne==null?void 0:Ne.isInverted),isParent:se,containerStyle:se?Se(W.data.id):void 0};return{id:W.data.id,collapsed:(Xe=W.data.config)==null?void 0:Xe.collapsed,parent:W.data.parent,acceptsChildren:!!((St=W.data.config)!=null&&St.parentContainer)||he.has(W.data.id),label:Be,animated:!!W.data.isNodeAnimated,animationVariant:W.data.nodeAnimationVariant,hasCollapseControl:((kt=W.data.config)==null?void 0:kt.collapsed)!==void 0,animationColor:Me(((Nt=W.data.viewProps)==null?void 0:Nt.borderColor)||t),animationWidth:Nn(($t=W.data.viewProps)==null?void 0:$t.borderWidth,8),element:j.createElement(U,{...je,key:`${W.data.id}-${t}`}),fillElement:P.has(W.data.id)&&!((mt=b.customViews)!=null&&mt.fillNode)?void 0:j.createElement(Ce,{...je,...(ht=b.customViews)!=null&&ht.fillNode?{renderNode:U}:{},data:{...W.data,viewProps:P.has(W.data.id)?W.data.viewProps:{...W.data.viewProps,borderRadius:0}},containerStyle:je.containerStyle&&!P.has(W.data.id)?{...je.containerStyle,borderRadius:0}:je.containerStyle,key:`${W.data.id}-${t}`})}})},[e,he,Re,t,b.customViews,Se,P]),Te=j.useMemo(()=>oe?300:e.length>50?150:e.length>20?100:50,[e.length,oe]),qe=j.useRef(b);qe.current=b;const Qe=j.useRef(k);Qe.current=k;const ct=j.useRef(O);ct.current=O;const Pe=j.useRef(x);Pe.current=x;const Ze=j.useRef(w);Ze.current=w;const Ye=j.useRef(E);Ye.current=E;const at=j.useRef(J);at.current=J;const Ot=j.useRef(xe);Ot.current=xe;const Rt=j.useRef(new Map);j.useEffect(()=>{var se,Be;const de=new Map([...xe].filter(([,U])=>J.has(U.data.source)&&J.has(U.data.target))),W=Rt.current;Rt.current=de;for(const[U,Ce]of W)de.has(U)||(Ze.current===U&&(C(null),(se=y.onEdgeDeselect)==null||se.call(y)),(Be=y.onEdgeRemove)==null||Be.call(y,U,Ce.data))},[xe,J,y,C]),j.useEffect(()=>{const de=I.current;if(!ee||!de)return;let W=null,se=null,Be=0,U=0,Ce=0,Ne=0,je=0;const Ve=nt=>{var kt;if(qe.current.readOnly||qe.current.minZoom===qe.current.maxZoom&&qe.current.minZoom!==void 0&&((kt=de.parentElement)!=null&&kt.closest(".flow-sdk-canvas")))return;const Xe=de.ownerDocument.fullscreenElement;if(Xe&&Xe!==de&&de.contains(Xe)&&nt.target instanceof Node&&Xe.contains(nt.target))return;nt.preventDefault(),nt.stopPropagation(),Qe.current||nt.metaKey||nt.ctrlKey?(Ce+=nt.deltaY,Ne=nt.clientX,je=nt.clientY,se===null&&(se=requestAnimationFrame(()=>{se=null;const Nt=qe.current,$t=ee.zoom(),mt=Ce;Ce=0;let ht=$t-mt*.05/100;ht=Math.max(Nt.minZoom??.01,Math.min(Nt.maxZoom??1.5,ht));const jt=de.getBoundingClientRect();ee.zoomAt(ht,{x:Ne-jt.left,y:je-jt.top})}))):(Be+=nt.deltaX,U+=nt.deltaY,W===null&&(W=requestAnimationFrame(()=>{W=null;const Nt=ee.pan(),$t=ee.zoom(),mt=.35,ht=Be,jt=U;Be=0,U=0,ee.pan({x:Nt.x+-ht*mt/$t,y:Nt.y+-jt*mt/$t})})))};return de.addEventListener("wheel",Ve,{passive:!1}),()=>{de.removeEventListener("wheel",Ve),W!==null&&cancelAnimationFrame(W),se!==null&&cancelAnimationFrame(se)}},[ee]),j.useEffect(()=>{if(b.disableKeyboardShortcuts)return;const de=W=>{var Be,U,Ce,Ne;if(qe.current.readOnly)return;const se=W.target;if(!(se.tagName==="INPUT"||se.tagName==="TEXTAREA"||se.isContentEditable)){if((W.key==="z"||W.key==="Z")&&T(!Qe.current),(W.key==="m"||W.key==="M")&&M(!E),(W.key==="d"||W.key==="D")&&N(!_),(W.key==="v"||W.key==="V")&&!W.repeat&&!W.metaKey&&!W.ctrlKey&&!W.altKey&&se.tagName!=="SELECT"&&B(!$),(W.key==="Delete"||W.key==="Backspace")&&Ze.current){W.preventDefault();const je=Ze.current;(U=y.onEdgeDelete)==null||U.call(y,je,((Be=Ot.current.get(je))==null?void 0:Be.data)??{id:je}),C(null);return}if((W.key==="Delete"||W.key==="Backspace")&&Pe.current.length>0){W.preventDefault();const je=Pe.current.filter(Ve=>Ve!=="root");if(je.length===0)return;for(const Ve of je){const nt=(Ce=at.current.get(Ve))==null?void 0:Ce.data;(Ne=y.onNodeDelete)==null||Ne.call(y,Ve,nt||{})}v([])}}};return window.addEventListener("keydown",de),()=>window.removeEventListener("keydown",de)},[E,_,$,B,T,M,N,b.disableKeyboardShortcuts,y,v,C]);const Vr=j.useCallback(de=>{var W;g.current=de,ae(de),(W=y.onInit)==null||W.call(y,de)},[g,y]),rt=j.useCallback(de=>{var W;return(W=y.onViewportChange)==null?void 0:W.call(y,de)},[y]),Ke=j.useCallback(de=>{var se,Be,U;const W=((se=Ot.current.get(de))==null?void 0:se.data)??{id:de};if(Ze.current===de&&Ye.current){C(null),(Be=y.onEdgeDeselect)==null||Be.call(y);return}Pe.current.length&&v([]),C(de),(U=y.onEdgeSelect)==null||U.call(y,de,W)},[y,C,v]),Zt=j.useCallback(()=>{var de,W,se,Be,U;if(a(b.bottomBarCollapsed??(Pe.current.length>0||!!Ze.current||!s)),(de=y.onBackgroundClick)==null||de.call(y),!qe.current.readOnly){const Ce=new Set;for(const Ne of Pe.current){let je=at.current.get(Ne);for(;je&&!Ce.has(je.data.id);)Ce.add(je.data.id),he.has(je.data.id)&&((W=je.data.config)==null?void 0:W.collapsed)!==!0&&((se=y.onNodeCollapse)==null||se.call(y,je.data.id,!0)),je=je.data.parent?at.current.get(je.data.parent):void 0}}Pe.current.length&&(v([]),(Be=y.onNodeDeselect)==null||Be.call(y)),Ze.current&&(C(null),(U=y.onEdgeDeselect)==null||U.call(y))},[y,v,C,a,s,b.bottomBarCollapsed,he]),ft=j.useCallback(de=>{var Be,U;const W=Pe.current,se=de.filter(Ce=>!W.includes(Ce));if(se.length){v([...W,...se]);for(const Ce of se)(U=y.onNodeSelect)==null||U.call(y,Ce,((Be=at.current.get(Ce))==null?void 0:Be.data)??{id:Ce})}},[y,v]),jr=j.useCallback((de,W)=>{var se,Be;v([de]),(Be=y.onNodeSelect)==null||Be.call(y,de,((se=at.current.get(de))==null?void 0:se.data)??{id:de},W)},[y,v]),Pt=j.useRef(null),Er=j.useCallback((de,W,se)=>{var Be;Pt.current={source:de,target:W,edgeIds:new Set(Ot.current.keys())};try{(Be=y.onEdgeCreate)==null||Be.call(y,de,W,se)}catch(U){throw Pt.current=null,U}},[y]),Vt=j.useCallback((de,W,se,Be=!1)=>{var U,Ce;if(ne.current={sourceId:de,nodeIds:new Set(at.current.keys()),reverse:Be},!(u==="properties"&&((U=y.onNodeCreateRequest)==null?void 0:U.call(y,{sourceNodeId:de,position:W,sourceProperty:se,reverse:Be}))===!0)){if(se!==void 0||Be){ne.current=null;return}(Ce=y.onNodeCreate)==null||Ce.call(y,{type:"text",sourceNodeId:de,position:W,isArrayMode:ct.current})}},[y,u]),Xt=!b.readOnly&&$&&b.edgeHandles!==!1,ar=i==="transparent"?"none":i;return f.jsx(fE,{pattern:ar,backgroundColor:K,children:f.jsx(V.Box,{ref:I,padding:0,width:"100%",height:"100%",flex:1,position:"relative",children:f.jsx(Hj,{nodes:ze,edges:De,direction:H,nodeAlignment:d,onContainerCollapse:de=>{var W,se;(W=y.onNodeCollapse)==null||W.call(y,de,!0),(se=y.onNodeViewToggle)==null||se.call(y,de)},selectedNodeIds:x,edgeMode:u,compactPropertyLayout:h,edgeType:b.edgeType,edgeRadius:o,customEdgeTypes:b.customEdgeTypes,edgeReveal:b.disableAnimations?void 0:b.edgeReveal,rankSep:q,edgeSep:pe,nodeGridSpacing:b.nodeGridSpacing,nodeGridConnections:b.nodeGridConnections,initialNodeGrid:b.nodeGrid,spacingFactor:F,compactSpacingScale:n,layoutDebounce:Te,isPerformanceMode:oe,minZoom:b.minZoom??.01,maxZoom:b.maxZoom??1.5,initialViewport:X,fitOnInit:!b.initialViewport&&!((We=b.nodeGrid)!=null&&We.enabled&&b.nodeGrid.options.fill),readOnly:!!b.readOnly,containerStyle:Se,lineColor:c?ge:fe,drawMode:Xt,drawHandles:!b.readOnly&&b.edgeHandles!==!1,dragMode:_,multiSelect:!!E,onInit:Vr,onLayoutComplete:de=>{var Ce;(Ce=y.onLayoutComplete)==null||Ce.call(y,de);const W=Pt.current;W&&(!at.current.has(W.source)||!at.current.has(W.target)?Pt.current=null:r.some(({data:Ne})=>Ne.source===W.source&&Ne.target===W.target&&!W.edgeIds.has(Ne.id))&&de.getNodeBox(W.source)&&de.getNodeBox(W.target)&&(Pt.current=null,de.focusConnections(W.source)));const se=ne.current;if(!se)return;if(!at.current.has(se.sourceId)){ne.current=null;return}const U=e.filter(Ne=>!se.nodeIds.has(Ne.data.id)).filter(Ne=>r.some(({data:je})=>je.source===se.sourceId&&je.target===Ne.data.id||je.target===se.sourceId&&je.source===Ne.data.id));!U.length||U.some(Ne=>!de.getNodeBox(Ne.data.id))||(ne.current=null,de.focusBranch(se.reverse?U[0].data.id:se.sourceId))},onNodeGridModeChange:R,onNodeGridZoomOut:y.onNodeGridZoomOut,onNodeGridDrop:y.onNodeGridDrop,onNodeParentChange:y.onNodeParentChange,animateViewport:b.animateViewport,disableAnimations:b.disableAnimations,onViewportChange:rt,onBackgroundTap:Zt,onBoxSelect:ft,onEdgeSelect:Ke,onContainerSelect:jr,onEdgeDraw:Er,onDrawIntoSpace:Vt})})})},lv=j.memo(pE),gE=".flow-sdk-canvas{position:relative;width:100%;height:100%;overflow:clip;user-select:none;-webkit-user-select:none;touch-action:none}.flow-sdk-svg{position:absolute;top:0;left:0;width:100%;height:100%;overflow:visible;display:block}.flow-sdk-nodes{position:absolute;top:0;left:0;transform-origin:0 0;pointer-events:none;will-change:transform;backface-visibility:hidden;z-index:10}.flow-sdk-node{position:absolute;top:0;left:0;transform-origin:0 0;pointer-events:auto;will-change:transform;backface-visibility:hidden;z-index:10}.flow-sdk-node input,.flow-sdk-node textarea{pointer-events:auto;user-select:text;-webkit-user-select:text;cursor:text}.flow-sdk-edge-hit{fill:none;stroke:transparent;stroke-width:24px;vector-effect:non-scaling-stroke;pointer-events:stroke;cursor:pointer}.flow-sdk-container{cursor:pointer}.flow-sdk-edge-anim{animation:flow-sdk-dash .5s linear infinite}.flow-sdk-edge-anim-rev{animation-direction:reverse}@keyframes flow-sdk-dash{to{stroke-dashoffset:-50}}.flow-sdk-draw{cursor:crosshair}.flow-sdk-draw .flow-sdk-node,.flow-sdk-draw .flow-sdk-node input,.flow-sdk-draw .flow-sdk-node textarea,.flow-sdk-draw .flow-sdk-edge,.flow-sdk-draw .flow-sdk-container{pointer-events:none}.flow-sdk-perf.flow-sdk-busy .flow-sdk-edges{display:none}.flow-sdk-box{position:absolute;border:1px solid rgba(170,170,170,.9);background:rgba(221,221,221,.25);pointer-events:none;z-index:20}";let Rm=!1;function yE(){if(Rm||typeof document>"u")return;const e=document.createElement("style");e.setAttribute("data-flow-sdk",""),e.textContent=gE+".flow-sdk-canvas[data-node-grid] .flow-sdk-node,.flow-sdk-canvas[data-node-grid] .flow-sdk-node *,.flow-sdk-canvas[data-node-grid] .flow-sdk-node *::before,.flow-sdk-canvas[data-node-grid] .flow-sdk-node *::after{animation:none!important;transition:none!important}.flow-sdk-node[data-grid-fill] [data-flow-icon-label]{--flow-grid-caption-color:var(--flow-grid-on-surface-color)}.flow-sdk-node[data-grid-fill] [data-flow-node-surface]{border:0;outline:none;box-shadow:none}.flow-sdk-node[data-grid-fill]{box-sizing:border-box}.flow-sdk-node[data-grid-fill] :not(svg):has([data-flow-node-surface]),.flow-sdk-node[data-grid-fill]>:not(svg):not(button){width:100%;height:100%;min-width:0;max-width:none}.flow-sdk-node[data-grid-fill] [data-flow-node-surface]{width:100%;height:100%;min-width:0;max-width:none;box-sizing:border-box;overflow:hidden}.flow-sdk-node[data-grid-fill] [data-flow-icon-label]{gap:0}.flow-sdk-node[data-grid-fill] [data-flow-icon-caption]{position:absolute;bottom:12px;left:12px;width:calc(100% - 24px);max-height:40%;overflow:hidden}.flow-sdk-node[data-grid-fill] [data-flow-node-surface]>svg{max-width:45%;max-height:55%}.flow-sdk-node[data-grid-fill] p{font-size:var(--flow-grid-font);white-space:normal;overflow-wrap:anywhere}.flow-sdk-canvas[data-node-grid]:not([data-grid-connections]) .flow-sdk-property-port,.flow-sdk-canvas[data-node-grid]:not([data-grid-connections]) .flow-sdk-handle,.flow-sdk-canvas[data-node-grid] [data-flow-collapse-control]{display:none}.flow-sdk-node[data-grid-draggable] :not(button):not(input):not(textarea):not(select):not(a){cursor:inherit}"+zb+Ww+Dw+".flow-sdk-handle{position:absolute;left:-36px;top:50%;transform:translateY(-50%);width:36px;height:36px;display:grid;place-items:center;border:2px solid currentColor;border-radius:50%;background:white;cursor:crosshair;opacity:0;pointer-events:none}.flow-sdk-node:hover>.flow-sdk-handle,.flow-sdk-handle:focus-visible{opacity:1;pointer-events:auto}.flow-sdk-draw .flow-sdk-node *,.flow-sdk-draw .flow-sdk-edge *,.flow-sdk-draw .flow-sdk-container *,.flow-sdk-ghost *{pointer-events:none}",document.head.appendChild(e),e.textContent+=".flow-sdk-draw .flow-sdk-node{pointer-events:auto}.flow-sdk-draw .flow-sdk-node>.flow-sdk-handle{opacity:0;pointer-events:none}.flow-sdk-draw .flow-sdk-node:hover>.flow-sdk-handle,.flow-sdk-draw .flow-sdk-node>.flow-sdk-handle:focus-visible{opacity:1;pointer-events:auto}",e.textContent+='.flow-sdk-property-port{position:absolute;transform:translateY(-50%);width:32px;height:32px;margin:0;padding:0;border:3px solid currentColor;border-radius:50%;background:white;cursor:crosshair;pointer-events:auto;z-index:20}.flow-sdk-property-port[data-port-role="source"]{background:currentColor}.flow-sdk-property-port:hover{outline:3px solid currentColor;outline-offset:3px}.flow-sdk-draw .flow-sdk-node .flow-sdk-property-port{pointer-events:auto}',Rm=!0}function mE({loading:e=!1,loader:r,...t}){var c,l;const[n,o]=j.useState(null),i=j.useMemo(()=>!!(n!=null&&n.json)&&!!t.json&&Fw(n.json,t.json),[n==null?void 0:n.json,t.json]),s=n===null||n.json!==t.json&&!i,a=e||s;return j.useEffect(()=>{!e&&i&&(n==null?void 0:n.json)!==t.json&&o(t)},[e,i,n==null?void 0:n.json,t.json]),j.useEffect(()=>{if(e||!s)return;let d;const u=requestAnimationFrame(()=>{d=requestAnimationFrame(()=>o(t))});return()=>{cancelAnimationFrame(u),d!==void 0&&cancelAnimationFrame(d)}},[e,s,t.json]),f.jsxs(V.Box,{className:t.className,style:t.style,width:"100%",height:"100%",position:"relative","aria-busy":a,children:[f.jsx("div",{style:{width:"100%",height:"100%"},ref:d=>{var h;const u=(d==null?void 0:d.contains(document.activeElement))&&((h=document.activeElement)==null?void 0:h.matches("input, textarea, [contenteditable=true]"));a&&(e||!u)?d==null||d.setAttribute("inert",""):d==null||d.removeAttribute("inert")},children:n&&f.jsx(bE,{...s?n:t,children:t.children,config:t.config,className:void 0,style:void 0})}),a&&r!==null&&f.jsx(V.Box,{"data-flow-loader":"",role:"status","aria-label":"Loading diagram",position:"absolute",inset:0,zIndex:1e3,display:"grid",placeItems:"center",background:((c=t.config)==null?void 0:c.colorMode)==="dark"?"gray.800":"gray.100",color:((l=t.config)==null?void 0:l.colorMode)==="dark"?"whiteAlpha.800":"blackAlpha.800",children:r===void 0?f.jsx("span",{children:"Loading diagram..."}):r})]})}function bE({title:e="untitled",json:r,forms:t,nodes:n,edges:o,config:i={},callbacks:s={},className:a,style:c,showBottomBar:l=!0,children:d}){yE();const[u,h]=j.useState(),[p,m]=j.useState(!1),g=i.formSchema??u,y=j.useMemo(()=>r&&t?bb(r,t.state):r,[r,t==null?void 0:t.state]),b=i.direction==="C",x=j.useMemo(()=>{let E,M;return _=>(M=E&&M?zw(E,_,M)??md(_,{title:e,isCenter:b}):md(_,{title:e,isCenter:b}),E=_,M)},[e,b]),v=j.useMemo(()=>y?x(y):null,[y,x]),w=j.useMemo(()=>t!=null&&t.structured&&!p&&g?xb(t.state,t.bindings,g,(v==null?void 0:v.nodes)??n??[]):void 0,[t==null?void 0:t.structured,p,t==null?void 0:t.state,t==null?void 0:t.bindings,g,v,n]),C=(w==null?void 0:w.schema)??g,S=(w==null?void 0:w.bindings)??(t==null?void 0:t.bindings),R=j.useMemo(()=>[...(v==null?void 0:v.nodes)??n??[],...(w==null?void 0:w.nodes)??[]].map(M=>{var ee,ae,ne,oe;const _=r?(ee=Le(r,M.data.id))==null?void 0:ee.$view:(ae=M.data.config)==null?void 0:ae.typeView,N=_&&Ed.includes(_)?_:void 0,$=N?N==="icon-label":(ne=M.data.config)==null?void 0:ne.labelBelow,B=N==="object"?"objectView":N==="text"?"text":$?"arrayView":M.data.type,O=C&&(t?Fn(S,M.data.id,C):r&&on(r,M.data.id,C)),I=(((oe=M.data.config)==null?void 0:oe.ports)??[]).map(pe=>({...pe}));if(w&&O){const pe=i.direction==="RL"?{input:"right",output:"left",config:"bottom",error:"top"}:i.direction==="TB"?{input:"top",output:"bottom",config:"right",error:"left"}:i.direction==="BT"?{input:"bottom",output:"top",config:"left",error:"right"}:{input:"left",output:"right",config:"top",error:"bottom"};for(const[q,F]of Object.entries(O.type.ports??{})){const G=`${F.kind}:${q}`,D=I.find(ce=>ce.id===G);D?D.label===void 0&&F.label!==void 0&&(D.label=F.label):I.push({id:G,...F.label!==void 0?{label:F.label}:{},role:F.kind==="input"||F.kind==="config"?"target":"source",side:pe[F.kind],...F.kind==="config"?{placement:"config"}:{}})}for(const q of I){const F=I.filter(G=>G.side===q.side);q.position=(F.indexOf(q)+1)/(F.length+1)}}return O||$||N?{...M,data:{...M.data,type:B,...t?{description:Object.fromEntries(Object.entries(M.data.description??{}).filter(([pe])=>!pe.startsWith("$")&&!(w!=null&&w.slots.has(bn(M.data.id,pe)))))}:{},config:{...M.data.config,...w&&O?{ports:I}:{},...O?{form:!0}:{},...N?{typeView:N,labelBelow:!!$}:$?{labelBelow:!0}:{}}}}:M}),[v,n,r,C,S,w,i.direction]),P=j.useMemo(()=>[...(v==null?void 0:v.edges)??o??[],...(w==null?void 0:w.edges)??[]],[v==null?void 0:v.edges,o,w==null?void 0:w.edges]),k=j.useMemo(()=>{const E=r&&v?Fb(r,v.edges,s,s.onJsonChange,g):{...s};if(w){const M=new Set([...w.nodes.map(_=>_.data.id),...w.edges.map(_=>_.data.id)]);for(const _ of Object.keys(E)){if(!/^on(?:Node|Edge).*(?:Change|Collapse)$/.test(_))continue;const N=E[_];E[_]=($,...B)=>{if(!M.has($))return N==null?void 0:N($,...B)}}}return{...E,onAllNodesIconLabelChange:M=>{var _;m(M),(_=E.onAllNodesIconLabelChange)==null||_.call(E,M)}}},[r,v,s,g,w]),T=j.useMemo(()=>{if(!t)return k;let E=t.state;const M=N=>{if(i.readOnly||i.editable===!1)return;const $=t.onStateChange??t.onChange;if(!$)return;const B=Rw(E,N,s.onFormChange);B!==E&&(E=B,$(B,{...N,data:B}))},_=(N,$,B)=>{var I;const O=r&&((I=Le(r,N))==null?void 0:I[$]);return!O||typeof O.$state!="string"?!1:(M({address:O.$state,nodeAddress:N,previousValue:Le(E,O.$state),value:B,data:E}),!0)};return{...k,onFormChange:M,onNodeCreateRequest:N=>{var O,I;const $=(O=N.sourceProperty)!=null&&O.startsWith("config:")?N.sourceProperty.slice(7):void 0,B=$!==void 0&&(w==null?void 0:w.slots.get(bn(N.sourceNodeId,$)));return B?(B.present||M({data:E,nodeAddress:B.address.split(".").slice(0,-1).join("."),address:B.address,value:xn(B.type),previousValue:void 0}),!0):((I=k.onNodeCreateRequest)==null?void 0:I.call(k,N))??!1},onNodeDelete:(N,$)=>{var ne,oe;if(!(w!=null&&w.nodes.some(pe=>pe.data.id===N)))return(ne=k.onNodeDelete)==null?void 0:ne.call(k,N,$);const B=w&&[...w.slots.values()].find(pe=>pe.nodeId===N);if(!B)return(oe=k.onNodeDelete)==null?void 0:oe.call(k,N,$);const O=B.address.split("."),I=O.pop(),ee=O.join("."),ae=Le(E,ee);M(Array.isArray(ae)?{data:E,nodeAddress:ee,address:ee,previousValue:ae,value:ae.filter((pe,q)=>String(q)!==I)}:{data:E,nodeAddress:ee,address:B.address,previousValue:Le(E,B.address),value:void 0})},onEdgeCreate:(N,$,B)=>{var ee,ae;const O=((ee=B==null?void 0:B.targetProperty)==null?void 0:ee.startsWith("config:"))&&(w==null?void 0:w.slots.get(bn($,B.targetProperty.slice(7)))),I=w==null?void 0:w.containers.get(N);if(O&&I&&(B==null?void 0:B.sourceProperty)==="output:resource"){const ne=Pw(E,I,O);ne!==void 0&&M({data:E,nodeAddress:O.address.split(".").slice(0,-1).join("."),address:O.address,previousValue:Le(E,O.address),value:ne});return}O||w!=null&&w.nodes.some(ne=>ne.data.id===N||ne.data.id===$)||(ae=k.onEdgeCreate)==null||ae.call(k,N,$,B)},onEdgeDelete:(N,$)=>{var oe;const B=w==null?void 0:w.edges.find(pe=>pe.data.id===N);if(!B)return(oe=k.onEdgeDelete)==null?void 0:oe.call(k,N,$);const O=w.slots.get(bn(B.data.target,B.data.targetProperty.slice(7))),I=O.address.split("."),ee=I.pop(),ae=I.join("."),ne=Le(E,ae);M(Array.isArray(ne)?{data:E,nodeAddress:ae,address:ae,previousValue:ne,value:ne.filter((pe,q)=>String(q)!==ee)}:{data:E,nodeAddress:ae,address:O.address,previousValue:Le(E,O.address),value:void 0})},onNodeContentChange:(N,$)=>{var B,O;_(N,"$content",$)?(B=s.onNodeContentChange)==null||B.call(s,N,$):(O=k.onNodeContentChange)==null||O.call(k,N,$)},onNodeLabelChange:(N,$)=>{var B,O;_(N,"$label",$)?(B=s.onNodeLabelChange)==null||B.call(s,N,$):(O=k.onNodeLabelChange)==null||O.call(k,N,$)}}},[k,t,r,s,w,i.readOnly,i.editable]);return f.jsx(Tt.Provider,{value:{data:(t==null?void 0:t.state)??r,viewData:r,bindings:S,references:t==null?void 0:t.references,structured:w,renderForm:t==null?void 0:t.renderForm,editable:t?!!(t.onStateChange??t.onChange):!!s.onJsonChange,schema:C,setSchema:E=>{var M;h(E),(M=s.onFormSchemaChange)==null||M.call(s,E)},callbacks:T},children:f.jsx(Om,{config:w?{...i,formSchema:C}:i,callbacks:T,nodes:R,edges:P,children:f.jsxs(V.Box,{className:a,"data-flow-diagram":"","data-animations-disabled":i.disableAnimations||void 0,style:c,width:"100%",height:"100%",position:"relative",overflow:"hidden",css:{"&[data-animations-disabled], &[data-animations-disabled] *, &[data-animations-disabled] *::before, &[data-animations-disabled] *::after":{animation:"none !important",transition:"none !important"},"& input, & textarea, & select":{outline:"none !important",boxShadow:"none !important"}},children:[f.jsx(lv,{nodes:R,edges:P}),l&&f.jsx(Tb,{}),d]})})})}function xE(e){return jd(JSON.parse(e))}function jd(e){if(!e||typeof e!="object")throw new Error("Expected a JSON object or array.");const r=new Set,t=n=>{if(!(n===null||typeof n=="string"||typeof n=="boolean")&&!(typeof n=="number"&&Number.isFinite(n))){if(!n||typeof n!="object"||r.has(n)||!Array.isArray(n)&&![Object.prototype,null].includes(Object.getPrototypeOf(n)))throw new Error("Document must contain only finite, acyclic JSON values.");r.add(n);for(const[o,i]of Object.entries(n)){if(["__proto__","prototype","constructor"].includes(o))throw new Error(`Unsafe document key: ${o}`);t(i)}r.delete(n)}};return t(e),structuredClone(e)}function vE(e){return{replaceJson(r){if(e.readOnly||!e.onJsonChange)throw new Error("JSON document is read-only.");const t=jd(r);return e.onJsonChange(t,{type:"documentReplace",address:"root"}),t},replaceState(r){if(e.readOnly||!e.onStateChange)throw new Error("Form state is read-only.");const t=jd(r);return e.onStateChange(t,{address:"root",nodeAddress:"root",previousValue:e.state,value:t,data:t}),t}}}function wE(e,r){const t=(n,o)=>{if(n===null||typeof n!="object")return typeof n==typeof o?n:void 0;if(!(!o||typeof o!="object"))return Array.isArray(n)?Array.isArray(o)?n.map((i,s)=>t(i,o[s])).filter(i=>i!==void 0):void 0:Object.fromEntries(Object.entries(n).flatMap(([i,s])=>{if(!Object.prototype.hasOwnProperty.call(o,i))return[];if(i==="$content"&&n.$contentFormat==="jsx"&&o.$contentFormat==="jsx"&&Array.isArray(s)&&Array.isArray(o[i]))return[[i,s.filter((c,l)=>JSON.stringify(c)===JSON.stringify(o[i][l]))]];if(i.startsWith("$")&&i!=="$")return JSON.stringify(s)===JSON.stringify(o[i])?[[i,s]]:[];const a=t(s,o[i]);return a===void 0?[]:[[i,a]]}))};return t(e,r)??{}}function no(e){let r="",t=!1,n="",o;const i=()=>{clearTimeout(o),o=void 0},s=()=>{if(i(),!(t||!r.trim()))try{const c=e.parse(e.repair(r)),l=JSON.stringify(c);if(l===n)return;e.preview(c),n=l}catch{}},a=c=>{if(!t){if(new TextEncoder().encode(c).byteLength>(e.maxBytes??1024*1024))throw t=!0,i(),new Error("JSON stream exceeds the size limit.");r=c,o||(o=setTimeout(s,e.intervalMs??150))}};return{snapshot:a,append(c){a(r+c)},flush:s,finish(){if(t)throw new Error("JSON stream is closed.");t=!0,i();const c=e.parse(r);return e.commit(c),c},cancel(){t=!0,i(),r=""}}}function CE(e){const{source:r}=e,t=e.tickMs??50,n=e.durationMs??8e3;if(!Number.isFinite(t)||t<=0||!Number.isFinite(n)||n<=0)throw new Error("Playback timing must be positive.");if(new TextEncoder().encode(r).byteLength>(e.maxBytes??1024*1024))throw new Error("JSON stream exceeds the size limit.");e.parse(r);let o=no(e),i=0,s=!1,a=!1,c;const l=Math.max(1,Math.ceil(r.length*t/n)),d=()=>e.onChange({position:i,total:r.length,playing:s}),u=()=>{clearTimeout(c),c=void 0},h=(g=!1)=>{o.snapshot(r.slice(0,i)),i===r.length?(s=!1,u(),o.finish()):g&&o.flush()},p=g=>{s=!1,u(),o.cancel(),d(),e.onError(g)},m=()=>{if(c=void 0,!(!s||a)){i=Math.min(r.length,i+l);try{h()}catch(g){p(g);return}d(),s&&(c=setTimeout(m,t))}};return{play(){a||s||(i===r.length&&(o.cancel(),o=no(e),i=0),s=!0,d(),c=setTimeout(m,t))},pause(){a||(s=!1,u(),o.flush(),d())},seek(g){if(!a){if(!Number.isFinite(g))throw new Error("Playback position must be finite.");u(),i=Math.max(0,Math.min(r.length,Math.round(g))),o.cancel(),o=no(e);try{h(!0)}catch(y){p(y);return}d(),s&&(c=setTimeout(m,t))}},dispose(){a=!0,s=!1,u(),o.cancel()}}}function SE({nodeAddress:e,expanded:r=!1}){var l;const{data:t,schema:n,bindings:o}=j.useContext(Tt),{colorText:i,background:s}=lt();if((l=o==null?void 0:o[e])!=null&&l.portResources)return null;const a=o&&Fn(o,e,n);if(!t||!a)return null;const c=Le(t,a.address);return!c||typeof c!="object"?null:f.jsx("div",{"data-flow-config-summary":"",style:{width:"100%",minWidth:0,color:Me(i),background:Me(s),fontSize:24,lineHeight:1.4,textTransform:"none"},children:Object.keys(a.type.properties).map(d=>{const u=a.fields[d]??{};if(!bo(u.$visibleWhen,t))return null;const h=c[d],p=h==null?"":typeof h=="object"?JSON.stringify(h):String(h);return f.jsxs("div",{"data-flow-property":d,style:{display:"grid",gridTemplateColumns:"minmax(0, 1fr) minmax(0, 1fr)",gap:12,padding:"10px 16px",borderTop:"1px solid color-mix(in srgb, currentColor 12%, transparent)"},children:[f.jsx("span",{style:{overflowWrap:"anywhere"},children:Ft(u.$label??d)}),f.jsx("span",{title:p,style:{overflow:"hidden",textOverflow:"ellipsis",whiteSpace:r?"pre-wrap":"nowrap",overflowWrap:r?"anywhere":void 0},children:p})]},d)})})}exports.BottomBar=Tb;exports.CollapseAllToggle=ob;exports.CompactPropertyLayoutToggle=ib;exports.ConnectionsOnlyToggle=Lw;exports.ContentFullscreenButton=nv;exports.DEFAULT_PALETTE=ao;exports.DiagramAppearanceControls=ab;exports.DynamicIcon=or;exports.EdgeTools=Eb;exports.EditableLabel=tn;exports.ErrorToast=Mb;exports.FlowDiagram=mE;exports.FlowDiagramProvider=Om;exports.FlowPort=tv;exports.FlowView=lv;exports.FormDocumentContext=Tt;exports.GridAdjustmentToggle=sb;exports.LIGHT_BLACK=rn;exports.LoadingBorder=rv;exports.NODE_TYPE_VIEWS=Ed;exports.NodeBorderRadiusControl=_b;exports.NodeConfigSummary=SE;exports.NodeForm=Ld;exports.NodeFormPopover=du;exports.NodeGridControls=to;exports.NodeIconPicker=Fd;exports.NodeTools=Rb;exports.NodeView=Un;exports.PanelDragHandle=nb;exports.SvgExportButton=Pb;exports.Swatches=Lr;exports.TEXT_PALETTE=Sb;exports.ToolbarCloseButton=nn;exports.ToolbarCommitInput=qr;exports.ToolbarDivider=Sn;exports.ToolbarIconButton=Oe;exports.ToolbarRangeInput=Rd;exports.ToolbarScrollContainer=vo;exports.ToolbarSelect=Mt;exports.ToolbarTooltip=He;exports.TooltipIconButton=Sd;exports.WorkflowControls=zd;exports.addChild=Id;exports.addConnection=Td;exports.addTargetEdge=pb;exports.addressToPath=Gt;exports.applyCollapsed=jw;exports.applyFormChange=xo;exports.applyStateEdits=_w;exports.bindSqueedCallbacks=Fb;exports.compileSqueed=md;exports.connectionIssue=$d;exports.contentObjTheme=nr;exports.copySelection=Bd;exports.createFlowDiagram=$r;exports.createFlowDocumentActions=vE;exports.createFormNode=Nb;exports.createJsonPlayback=CE;exports.createJsonStream=no;exports.createWorkflowExecution=kv;exports.downloadSvg=Ab;exports.duplicateSelection=Lb;exports.exportSvg=kb;exports.formValueError=Ut;exports.getChakraColorHex=Me;exports.getColorVariant=Pm;exports.getDarkerHexColor=oo;exports.getInteractionSurface=xr;exports.getNode=Le;exports.getSelectionRoots=qb;exports.isNodeVisible=rr;exports.parseFlowDocument=xE;exports.parseJsonContract=Od;exports.parseTypeScriptContract=yb;exports.parseTypeScriptForm=Nd;exports.projectJsonPlaybackPreview=wE;exports.readFormSchema=qd;exports.readWorkflowContract=mb;exports.removeEdge=gb;exports.removeNode=hb;exports.reparentNode=$b;exports.resolveEdgeOwner=Or;exports.resolveStateView=bb;exports.setCollapsed=Md;exports.setEdgeProp=gr;exports.setEdgeStyle=fb;exports.setNodeProp=xt;exports.updateNode=_t;exports.useCustomColors=lt;exports.useEdgeProximity=ho;exports.useFlowData=Kt;exports.useFlowDiagramContext=Je;exports.useNodeViewActions=Hn;exports.useStopPropagation=lu;exports.useThemeContentColors=Ln;exports.validateGridAdjustment=Xx;
|
|
283
|
+
@media(prefers-reduced-motion:reduce){[data-flow-loading-border][data-flow-loading-border] .flow-sdk-node-border-animation{animation:none!important}}`;function rv({active:e=!0,label:r="Loading content",radius:t}){const{config:n,themeColor:o}=Ze(),{colorText:i}=lt(),s=j.useRef(null),[a,c]=j.useState({width:0,height:0,radius:0});if(j.useLayoutEffect(()=>{const u=s.current;if(!e||!u)return;const h=()=>{const m=u.parentElement,g={width:u.clientWidth,height:u.clientHeight,radius:t??(m&&parseFloat(getComputedStyle(m).borderTopLeftRadius)||0)};c(y=>y.width===g.width&&y.height===g.height&&y.radius===g.radius?y:g)},p=new ResizeObserver(h);return p.observe(u),h(),()=>p.disconnect()},[e,t]),!e)return null;const l=Me(o||i),d={x:4,y:4,width:a.width-8,height:a.height-8,radius:Math.max(0,a.radius-4),color:l,strokeWidth:2};return f.jsxs("div",{ref:s,role:"status","aria-label":r,"data-flow-loading-border":"","data-motion-disabled":n.disableAnimations||void 0,style:{position:"absolute",inset:0,pointerEvents:"none",borderRadius:"inherit",overflow:"hidden",zIndex:2},children:[f.jsx("style",{children:Zj}),f.jsxs("svg",{width:"100%",height:"100%","aria-hidden":"true",style:{display:"block",pointerEvents:"none"},children:[f.jsx("g",{opacity:.5,style:{filter:"blur(3px)"},children:f.jsx(so,{...d,strokeWidth:6})}),f.jsx(so,{...d})]})]})}function Xj({nodeId:e}){var E,M;const{nodeById:r}=Kt(),{callbacks:t,config:n,readOnly:o,colorMode:i,isPerformanceMode:s}=Ze(),{background:a,border:c,colorInactive:l,colorText:d}=lt(),u=[...r.values()].filter(({data:_})=>{var O,$,B,N,I;return _.type!=="grid"&&!((O=_.config)!=null&&O.parentContainer)&&((($=_.config)==null?void 0:$.contentFormat)==="html"||((B=_.config)==null?void 0:B.contentFormat)==="jsx")&&(typeof((N=_.config)==null?void 0:N.content)=="string"||Array.isArray((I=_.config)==null?void 0:I.content))}),[h,p]=j.useState(e),[m,g]=j.useState(!1),y=j.useRef(null),b=ho({edge:"top",enabled:!0,bounds:y,inside:[y],threshold:90}),x=j.useRef(null),v=j.useRef(1),w=u.find(_=>_.data.id===h)??u.find(_=>_.data.id===e)??u[0],C=u.indexOf(w),S=!!n.editable&&!o,R=_=>typeof _=="number"?_>0&&Number.isFinite(_)?String(_):"":typeof _=="string"&&/^\d+(\.\d+)?px$/.test(_)?String(parseFloat(_)):"",P=R((E=w==null?void 0:w.data.viewProps)==null?void 0:E.width),k=R((M=w==null?void 0:w.data.viewProps)==null?void 0:M.height);j.useLayoutEffect(()=>{const _=x.current;if(!_||n.disableAnimations||s||matchMedia("(prefers-reduced-motion: reduce)").matches)return;const O=_.animate({transform:[`translateX(${v.current*100}%)`,"translateX(0)"]},{duration:240,easing:"ease-out",id:"flow-content-slide"});return()=>O.cancel()},[w==null?void 0:w.data.id,n.disableAnimations,s]);const T=_=>{const O=u[C+_];!O||m||(v.current=_,p(O.data.id))};return w?f.jsxs(W.Box,{"data-content-gallery":"",position:"relative",h:"100%",display:"flex",flexDirection:"column",minH:0,color:d,onClick:_=>_.stopPropagation(),onDoubleClick:_=>_.stopPropagation(),onPointerDown:_=>_.stopPropagation(),children:[f.jsx(W.Box,{ref:y,role:"toolbar","aria-label":"Preview controls",position:"absolute",top:"8px",left:"8px",w:"max-content",maxW:"calc(100% - 76px)",zIndex:2,css:{"@media (hover: hover) and (pointer: fine)":{opacity:b?1:0},"&:hover, &:focus-within":{opacity:1}},children:f.jsx(vo,{background:a,border:i==="dark"?c:"gray.300",children:f.jsxs(W.HStack,{px:2,gap:2,width:"max-content",height:"100%",children:[f.jsx(He,{label:"Previous content",children:f.jsx(Ne,{"data-flow-content-navigation":"","aria-label":"Previous content",icon:f.jsx(Y.PiCaretLeft,{size:20}),disabled:C<=0||m,onClick:()=>T(-1),rememberAction:!1,size:"sm",variant:"ghost"})}),f.jsxs(W.Text,{"aria-live":"polite",fontSize:"12px",minW:"42px",textAlign:"center",children:[C+1," / ",u.length]}),f.jsx(He,{label:"Next content",children:f.jsx(Ne,{"data-flow-content-navigation":"","aria-label":"Next content",icon:f.jsx(Y.PiCaretRight,{size:20}),disabled:C>=u.length-1||m,onClick:()=>T(1),rememberAction:!1,size:"sm",variant:"ghost"})}),["width","height"].map(_=>f.jsxs(W.Box,{as:"label",display:"flex",alignItems:"center",gap:1,fontSize:"12px",opacity:S?1:.5,children:[_==="width"?"W":"H",f.jsx(qr,{value:_==="width"?P:k,placeholder:"Auto",ariaLabel:`Content ${_}`,type:"number",min:1,width:"72px",disabled:!S||!t.onNodeDimensionChange||m,onCommit:O=>{var $;S&&(($=t.onNodeDimensionChange)==null||$.call(t,w.data.id,_,O===""?void 0:Number(O)))}})]},`${w.data.id}:${_}`)),S&&!m&&f.jsx(He,{label:"Edit content source",children:f.jsx(Ne,{"aria-label":"Edit content source",icon:f.jsx(Y.PiCode,{size:20}),onClick:()=>g(!0),rememberAction:!1,size:"sm",variant:"ghost",color:l})})]})})}),f.jsx(W.Box,{flex:1,minH:0,overflow:"auto",position:"relative","data-content-slide-viewport":"",children:f.jsx(W.Box,{ref:x,"data-content-slide":w.data.id,width:P?`${P}px`:"100%",height:k?`${k}px`:"100%",minH:k?void 0:"100%",mx:"auto",overflow:"auto",children:f.jsx(uu,{nodeId:w.data.id,content:w.data.config.content,format:w.data.config.contentFormat,color:d,previewControls:!1,editOnMount:m,onEditEnd:()=>g(!1)},`${w.data.id}:${m}`)},w.data.id)})]}):f.jsx(W.Box,{role:"status",p:4,children:"No HTML or JSX content available."})}const nv=j.forwardRef(function({fullscreen:r,onClick:t},n){const{colorInactive:o}=lt();return f.jsx(Ne,{ref:n,"data-flow-fullscreen":"","aria-label":r?"Exit fullscreen":"Expand preview",title:r?"Exit fullscreen":"Expand preview","aria-expanded":r,icon:r?f.jsx(Y.PiArrowsIn,{size:20}):f.jsx(Y.PiArrowsOut,{size:20}),size:"sm",variant:"plain",bg:"transparent",color:o,borderRadius:"30px",w:"32px",h:"32px",minW:"32px",p:0,onClick:t})});function Yj({content:e,format:r,onEdit:t,autoHeight:n=!1,nodeId:o,controls:i=!0}){var F,G,D,ce,Q;const{config:s,colorMode:a}=Ze(),{nodeById:c}=Kt(),l=o?(G=(F=c.get(o))==null?void 0:F.data.viewProps)==null?void 0:G.height:void 0,d=typeof l=="number"?`${l}px`:typeof l=="string"&&/^\d+(\.\d+)?px$/.test(l)?l:void 0;n=n&&!d;const{background:u,border:h,colorInactive:p}=lt(),m=(D=s.customViews)==null?void 0:D.jsxContent,g=typeof e=="string"?e:JSON.stringify(e,null,2);let y,b=r==="jsx"&&o?(Q=(ce=c.get(o))==null?void 0:ce.data.config)==null?void 0:Q.contentReferenceError:void 0;if(r==="jsx"&&!b)try{const K=typeof e=="string"?JSON.parse(e):e;if(!Array.isArray(K)||K.some(ie=>!ie||typeof ie!="object"||Array.isArray(ie)||typeof ie.type!="string"))throw new Error("JSX content must be an array of components with a type.");y=K}catch(K){b=K instanceof Error?K.message:"Invalid components array."}const x=j.useRef(null),v=j.useRef(null),w=j.useRef(null),C=j.useRef(!1),[S,R]=j.useState(!1),P=j.useRef(null),k=ho({edge:"top",enabled:S,bounds:P,inside:[P],threshold:90}),[T,E]=j.useState(""),[M,_]=j.useState(),O=!!t;j.useEffect(()=>{const K=()=>{var ye;const ie=document.fullscreenElement===v.current;R(ie),C.current&&!ie&&!document.fullscreenElement&&((ye=w.current)==null||ye.focus({preventScroll:!0})),C.current=ie};return document.addEventListener("fullscreenchange",K),()=>document.removeEventListener("fullscreenchange",K)},[]);const $=async()=>{var K;E("");try{if(document.fullscreenElement===v.current)await document.exitFullscreen();else if((K=v.current)!=null&&K.requestFullscreen)await v.current.requestFullscreen();else throw new Error("Fullscreen is not supported in this browser.")}catch(ie){E(ie instanceof Error?ie.message:"Unable to change fullscreen.")}},[B,N]=j.useState(),[I,ee]=j.useState(),[ae,ne]=j.useState();j.useEffect(()=>{if(r==="jsx")return;let K=!1;return Promise.resolve().then(()=>require("./contentPreviewDocument-i1zWN5gw.cjs")).then(({contentPreviewDocument:ie})=>ie(g,r,O,n)).then(ie=>{K||N({content:g,format:r,editable:O,autoHeight:n,document:ie})},ie=>{K||N({content:g,format:r,editable:O,autoHeight:n,error:ie instanceof Error?ie.message:String(ie)})}),()=>{K=!0}},[g,r,O,n]),j.useEffect(()=>{if(!t)return;const K=async ie=>{var ye,we;if(!(!((ye=x.current)!=null&&ye.contentWindow)||ie.source!==x.current.contentWindow||((we=ie.data)==null?void 0:we.type)!=="squeed:content-edit"))try{document.fullscreenElement===v.current&&await document.exitFullscreen(),t()}catch(he){E(he instanceof Error?he.message:"Unable to close fullscreen.")}};return window.addEventListener("message",K),()=>window.removeEventListener("message",K)},[t]);const oe=(B==null?void 0:B.content)===g&&B.format===r&&B.editable===O&&B.autoHeight===n?B:void 0;j.useEffect(()=>{if(!n||r!=="html"||!(oe!=null&&oe.document))return;const K=oe.document,ie=ye=>{var he,ge,X;const we=(he=ye.data)==null?void 0:he.height;!((ge=x.current)!=null&&ge.contentWindow)||ye.source!==x.current.contentWindow||((X=ye.data)==null?void 0:X.type)!=="squeed:content-size"||typeof we!="number"||!Number.isFinite(we)||we<=0||we>1e5||document.fullscreenElement===v.current||_(H=>(H==null?void 0:H.document)===K&&H.height===we?H:{document:K,height:we})};return window.addEventListener("message",ie),()=>window.removeEventListener("message",ie)},[n,r,oe==null?void 0:oe.document]);const pe=!!oe&&oe===ae,q=r!=="jsx"&&!(oe!=null&&oe.error)&&!pe&&(!oe||I!==oe);return f.jsxs("div",{"data-flow-content-preview":"",style:{width:"100%",height:i?d??(n?r==="jsx"?"auto":(M==null?void 0:M.document)===(oe==null?void 0:oe.document)?M==null?void 0:M.height:360:360):n?"auto":"100%",fontSize:16,overflow:"auto"},children:[f.jsx("pre",{"data-flow-preview-source":"",style:{display:"none",whiteSpace:"pre-wrap"},children:g}),f.jsxs(W.Box,{ref:v,position:"relative",w:"100%",h:n&&r==="jsx"?"auto":"100%","aria-busy":!S&&r!=="jsx"?q:void 0,bg:r==="jsx"&&a==="dark"?"gray.900":"white",onDoubleClick:K=>{r!=="jsx"||!t||K.defaultPrevented||K.target.closest('button, a, input, textarea, select, [contenteditable], [role="button"], [role="textbox"]')||(K.stopPropagation(),(async()=>{document.fullscreenElement===v.current&&await document.exitFullscreen(),t()})().catch(ie=>E(String(ie))))},onKeyDownCapture:K=>{K.key!=="Escape"||document.fullscreenElement!==v.current||K.target instanceof Element&&K.target.closest('input, textarea, select, [contenteditable="true"]')||(K.preventDefault(),K.stopPropagation(),$())},css:{"&:fullscreen":{width:"100vw",height:"100dvh",maxWidth:"none",maxHeight:"none",padding:0},"&:not(:fullscreen):hover > [data-flow-content-toolbar], &:not(:fullscreen):focus-within > [data-flow-content-toolbar]":{opacity:1,pointerEvents:"auto"},"@media (hover: none)":{"& > [data-flow-content-toolbar]":{opacity:1,pointerEvents:"auto"}}},children:[i&&f.jsx(W.Box,{ref:P,role:"toolbar","aria-label":"Content controls","data-flow-content-toolbar":"",position:"absolute",top:"8px",right:"8px",zIndex:1,w:"max-content",maxW:"calc(100% - 16px)",opacity:S?1:0,pointerEvents:S?"auto":"none",css:S?{"@media (hover: hover) and (pointer: fine)":{opacity:k?1:0},"&:hover, &:focus-within":{opacity:1}}:void 0,children:f.jsx(vo,{background:u,border:a==="dark"?h:"gray.300",children:f.jsxs(W.HStack,{px:"8px",gap:"8px",h:"100%",w:"max-content",css:{"& button > svg":{width:"20px",height:"20px",minWidth:"20px",minHeight:"20px",flexShrink:0}},children:[t&&(!S||!o)&&f.jsx(Ne,{"data-flow-content-edit":"","aria-label":"Edit content source",title:"Edit content source",icon:f.jsx(Y.PiCode,{size:20}),size:"sm",variant:"plain",bg:"transparent",color:p,borderRadius:"30px",w:"32px",h:"32px",minW:"32px",p:0,onClick:K=>{K.stopPropagation(),(async()=>{document.fullscreenElement===v.current&&await document.exitFullscreen(),t()})().catch(ie=>E(String(ie)))}}),f.jsx(nv,{ref:w,fullscreen:S,onClick:K=>{K.stopPropagation(),$()}})]})})}),T&&f.jsx(W.Box,{role:"alert",position:"absolute",bottom:0,insetInline:0,bg:"white",color:"red.700",fontSize:"14px",children:T}),S&&o?f.jsx(Xj,{nodeId:o}):r==="jsx"?b?f.jsx("pre",{role:"alert",style:{whiteSpace:"pre-wrap"},children:b}):m&&y?f.jsx(m,{components:y,colorMode:a,fillHeight:!n||S}):f.jsx(W.Box,{role:"status",fontSize:"14px",children:"JSX content renderer is not available."}):oe!=null&&oe.error||pe?f.jsx("pre",{role:"alert",style:{whiteSpace:"pre-wrap"},children:(oe==null?void 0:oe.error)||"Content preview could not be loaded."}):oe!=null&&oe.document?f.jsx("iframe",{ref:x,title:`${r.toUpperCase()} content preview`,sandbox:O||n?"allow-scripts":"",allowFullScreen:!0,referrerPolicy:"no-referrer",srcDoc:oe.document,onLoad:()=>ee(oe),onError:()=>ne(oe),style:{width:"100%",height:"100%",border:0,display:"block",background:"white",visibility:q?"hidden":"visible"}},oe.document):null,f.jsx(rv,{active:!S&&q,label:"Loading HTML content"})]})]})}const _m=1.55;function uu({nodeId:e,content:r,color:t,format:n="markdown",fillBody:o=!1,autoHeight:i=!1,previewControls:s=!0,editOnMount:a=!1,onChange:c,onEditEnd:l}){var B,N;const{callbacks:d,config:u,readOnly:h,nodeGridOptions:p}=Ze(),m=!!u.editable&&!h,g=m&&(!p||o&&p.fill&&n==="markdown"),{nodeById:y}=Kt(),b=n==="jsx"&&!c?((N=(B=y.get(e))==null?void 0:B.data.config)==null?void 0:N.contentSource)??r:r,x=typeof b=="string"?b:JSON.stringify(b,null,2),[v,w]=j.useState(a&&m),[C,S]=j.useState(x),[R,P]=j.useState(""),[k,T]=j.useState(),E=j.useRef(null),M=j.useRef(!1),_=lu(v);j.useLayoutEffect(()=>{const I=E.current;!v||!I||(I.style.height="auto",I.style.height=`${Math.max((k==null?void 0:k.height)??0,I.scrollHeight)}px`)},[C,v,k]),j.useEffect(()=>{var I,ee;m?v&&(M.current=!1,(I=E.current)==null||I.focus({preventScroll:!0}),(ee=E.current)==null||ee.select()):w(!1)},[v,m]);const O=(I,ee=!1)=>{!m||p&&!g&&!ee||(T({width:I.offsetWidth,height:I.offsetHeight}),S(x),P(""),w(!0))},$=()=>{var ee;if(M.current||!m)return;let I=C;if(n==="jsx")try{if(I=JSON.parse(C),!Array.isArray(I)||I.some(ae=>!ae||typeof ae!="object"||Array.isArray(ae)||typeof ae.type!="string"&&typeof ae.$contentRef!="string"))throw new Error("JSX content must be an array of components with a type.")}catch(ae){P(ae instanceof Error?ae.message:"Invalid components array.");return}M.current=!0,C!==x&&(c?c(I):(ee=d.onNodeContentChange)==null||ee.call(d,e,I)),w(!1),l==null||l()};return(!v||!m)&&n!=="markdown"?f.jsx(W.Box,{ref:_,w:"100%",h:!s&&!i?"100%":void 0,position:"relative","data-flow-content":"",children:f.jsx(Yj,{nodeId:e,content:r,format:n,controls:s,autoHeight:i&&!(p!=null&&p.fill),onEdit:g?()=>{_.current&&O(_.current)}:void 0})}):!v||!m?f.jsx(W.Box,{"data-flow-content":"",color:t,opacity:r?void 0:.6,w:"100%",minH:"1.2em",whiteSpace:"normal",lineHeight:_m,overflowWrap:"anywhere",css:{"& > :first-of-type":{marginTop:0},"& > :last-of-type":{marginBottom:0},"& h1, & h2, & h3, & h4, & h5, & h6":{fontWeight:700,lineHeight:1.2,margin:"1em 0 0.45em"},"& h1":{fontSize:"1.5em"},"& h2":{fontSize:"1.3em"},"& h3":{fontSize:"1.1em"},"& p":{margin:"0.65em 0",whiteSpace:"pre-wrap"},"& ul, & ol":{margin:"0.65em 0",paddingInlineStart:"1.6em"},"& ul":{listStyleType:"disc"},"& ol":{listStyleType:"decimal"},"& li":{display:"list-item",margin:"0.3em 0",paddingInlineStart:"0.15em"},"& li > ul, & li > ol":{margin:"0.25em 0"},"& li > p":{margin:0},"& a":{color:"inherit",textDecoration:"underline"},"& code":{fontFamily:"monospace",fontSize:"0.85em"},"& :not(pre) > code":{background:"color-mix(in srgb, currentColor 10%, transparent)",padding:"0.1em 0.25em",borderRadius:"0.2em"},"& pre":{margin:"0.75em 0",padding:"0.75em",background:"color-mix(in srgb, currentColor 8%, transparent)",border:0,borderRadius:"6px",maxWidth:"100%",overflowX:"auto",whiteSpace:"pre",overflowWrap:"normal",lineHeight:1.5},"& pre code":{background:"transparent",padding:0,whiteSpace:"inherit"},"& strong":{fontWeight:700},"& em":{fontStyle:"italic"},"& blockquote":{margin:"0.4em 0",borderInlineStart:"0.1em solid currentColor",paddingInlineStart:"0.6em"},"& table":{width:"100%",tableLayout:"fixed",borderCollapse:"collapse",margin:"0.4em 0"},"& th, & td":{border:"1px solid currentColor",padding:"0.2em 0.3em",textAlign:"left"},"& th":{fontWeight:700},"& img":{maxWidth:"100%",height:"auto"}},cursor:g?"text":void 0,tabIndex:g?0:void 0,outline:"none",_focusVisible:{outline:"none",boxShadow:"none"},onClick:I=>{!m||p&&!g&&!I.shiftKey||I.target instanceof Element&&I.target.closest("a, button, input")||(I.stopPropagation(),O(I.currentTarget,I.shiftKey))},onDoubleClick:I=>{I.stopPropagation(),O(I.currentTarget,I.shiftKey)},onKeyDown:I=>{m&&(g||I.shiftKey)&&I.key==="Enter"&&I.target===I.currentTarget&&(I.preventDefault(),I.stopPropagation(),O(I.currentTarget,I.shiftKey))},children:f.jsx(Rv.default,{options:{forceBlock:!0,wrapper:j.Fragment,disableParsingRawHTML:!0,overrides:{a:{props:{target:"_blank",rel:"noopener noreferrer"}},img:{props:{loading:"lazy",referrerPolicy:"no-referrer"}}}},children:x||(u.editable&&!h?"Write your content here":"")})}):f.jsxs("div",{ref:_,style:{width:k==null?void 0:k.width,minHeight:k==null?void 0:k.height,maxWidth:"100%"},children:[f.jsx(W.Textarea,{ref:E,"aria-label":"Node content",placeholder:"Write your content here",value:C,"aria-invalid":!!R,onChange:I=>S(I.target.value),onBlur:$,onKeyDown:I=>{I.stopPropagation(),!I.nativeEvent.isComposing&&(I.key==="Enter"&&(I.ctrlKey||I.metaKey)&&(I.preventDefault(),$()),I.key==="Escape"&&(M.current=!0,w(!1),l==null||l()))},color:t,fontFamily:"inherit",fontSize:"inherit",lineHeight:_m,overflowWrap:"anywhere",whiteSpace:"pre-wrap",rows:1,bg:"transparent",display:"block",style:{border:0,outline:"none",boxShadow:"none"},_focus:{border:0,outline:"none",boxShadow:"none"},_focusVisible:{border:0,outline:"none",boxShadow:"none"},p:0,w:"100%",h:"100%",minW:0,minH:0,resize:"none"}),R&&f.jsx(W.Box,{role:"alert",fontSize:"14px",color:"red.500",children:R})]})}const Qj=({data:e,children:r,isInverted:t,isParent:n,onOpenView:o,editOnMount:i=!1,hoverLeaveDelay:s=0})=>{var he,ge,X,H,be,J,xe,Se,Fe,De;const{selectedNodeIds:a,setSelectedNodeIds:c,selectedEdgeId:l,setSelectedEdgeId:d,isMultiSelectMode:u,nodeGridOptions:h,isPerformanceMode:p,engineRef:m,callbacks:g,config:y,themeColor:b,direction:x,nodeViewModes:v}=Ze(),{background:w,border:C,colorText:S}=lt(),R=j.useRef(null),P=j.useRef(null);j.useEffect(()=>()=>{P.current&&clearTimeout(P.current)},[]);const[k,T]=j.useState(!1),[E,M]=j.useState(i&&!!y.editable&&!y.readOnly),[_,O]=j.useState(!1),$=e==null?void 0:e.id,B=wb($),N=a.includes($);j.useEffect(()=>{if(!N||a.length!==1||y.readOnly||E||_)return;const ue=Re=>{var qe,Qe,ct,Pe,Je;if(Re.key!=="Enter"||Re.defaultPrevented||Re.isComposing||Re.ctrlKey||Re.metaKey||Re.altKey||Re.shiftKey||Re.target instanceof Element&&Re.target.closest('button, input, textarea, select, a, [contenteditable], [role="textbox"], [role="dialog"], [role="menu"], [role="listbox"], [popover], [data-flow-content]')||Array.from(document.querySelectorAll('dialog[open], :popover-open, [role="dialog"], [role="menu"], [role="listbox"]')).some(Ye=>Ye.getClientRects().length&&getComputedStyle(Ye).visibility!=="hidden"))return;const ze=Array.from(((qe=R.current)==null?void 0:qe.querySelectorAll("[data-flow-content-toggle] button, button[data-flow-collapse-control]"))??[]).find(Ye=>{var nt;return((nt=Ye.closest("[data-node-id]"))==null?void 0:nt.getAttribute("data-node-id"))===$&&!Ye.disabled&&Ye.getClientRects().length&&getComputedStyle(Ye).visibility!=="hidden"}),Te=!ze&&(e==null?void 0:e.type)==="grid"&&((Qe=e.config)==null?void 0:Qe.documentId)&&((ct=R.current)==null?void 0:ct.getClientRects().length)&&g.onNodeHoverAction&&((Pe=y.nodeOverlayActions)==null?void 0:Pe.find(Ye=>Ye.id==="open-document"&&(!Ye.nodeTypes||Ye.nodeTypes.includes(e.type))));!ze&&!Te||(Re.preventDefault(),Re.stopPropagation(),Re.repeat||(ze?ze.click():(Je=g.onNodeHoverAction)==null||Je.call(g,Te.id,$,e)))};return window.addEventListener("keydown",ue,!0),()=>window.removeEventListener("keydown",ue,!0)},[$,N,a.length,y.readOnly,E,_,e,g.onNodeHoverAction,y.nodeOverlayActions]);const I=(he=y.nodeOverlayActions)==null?void 0:he.filter(ue=>!ue.nodeTypes||ue.nodeTypes.includes(e==null?void 0:e.type)),ee=y.renderNodeOverlay,ae=(e==null?void 0:e.type)==="grid"?(ge=y.customViews)==null?void 0:ge.gridHoverControls:void 0,ne=(e==null?void 0:e.type)==="grid"?"20px":"-100px",oe=(e==null?void 0:e.type)==="grid"?"top center":void 0,pe=(e==null?void 0:e.type)==="grid"?"translateX(-50%) scale3d(1.8, 1.8, 1)":"translateX(-50%) scale3d(3, 3, 1)",q=(()=>{var ue;try{const Re=(ue=m.current)==null?void 0:ue.zoom();return Re!==void 0&&Re<.08}catch{return!1}})(),F=j.useCallback((ue,Re=!1)=>{var Te,qe,Qe,ct,Pe;if(E||y.readOnly||h!=null&&h.fill&&!ue.shiftKey||ue.detail===2&&((Te=e==null?void 0:e.config)!=null&&Te.form)&&!o&&!Re&&!u&&!l&&!ue.shiftKey&&!ue.ctrlKey&&!ue.metaKey&&!ue.altKey&&a.length===1&&a[0]===$)return;const ze={shiftKey:ue.shiftKey,ctrlKey:ue.ctrlKey,metaKey:ue.metaKey,altKey:ue.altKey,...Re?{viewToggle:!0}:{}};if(l&&(d(null),(qe=g.onEdgeDeselect)==null||qe.call(g)),u||ue.shiftKey&&(h!=null&&h.fill)){const Je=a.includes($),Ye=Je?a.filter(nt=>nt!==$):[...a,$];c(Ye),Je?(Qe=g.onNodeDeselect)==null||Qe.call(g):(ct=g.onNodeSelect)==null||ct.call(g,$,e,ze)}else c([$]),(Pe=g.onNodeSelect)==null||Pe.call(g,$,e,ze)},[$,e,a,l,u,h,E,o,c,d,g,y]),G=j.useCallback(()=>{var ue;E||y.readOnly||(ue=g.onNodeDoubleClick)==null||ue.call(g,$,e)},[$,e,E,g,y]),D=j.useCallback(()=>{P.current&&clearTimeout(P.current),P.current=setTimeout(()=>T(!0),100)},[]),ce=j.useCallback(ue=>{var Re;ue.relatedTarget instanceof Node&&((Re=R.current)!=null&&Re.contains(ue.relatedTarget))||(P.current&&clearTimeout(P.current),s?P.current=setTimeout(()=>T(!1),s):T(!1))},[s]),Q=(e==null?void 0:e.type)==="text"&&!((X=e==null?void 0:e.config)!=null&&X.parentContainer)&&!((H=e==null?void 0:e.config)!=null&&H.form),K=!!((be=e==null?void 0:e.config)!=null&&be.form)||Q,ie={tabIndex:K?0:void 0,"aria-haspopup":K?"dialog":void 0,"aria-expanded":K?_:void 0,onDoubleClickCapture:ue=>{var Re;!K&&!o||y.readOnly||Q&&!y.editable||E||!ue.currentTarget.contains(ue.target)||ue.target instanceof Element&&ue.target.closest("button, input, textarea, select, a, [contenteditable=true], [data-flow-content]")||(ue.preventDefault(),ue.stopPropagation(),(a.length!==1||a[0]!==$)&&c([$]),o?o():O(!0),(Re=g.onNodeDoubleClick)==null||Re.call(g,$,e))},onKeyDown:ue=>{!K&&!o||y.readOnly||Q&&!y.editable||ue.target!==ue.currentTarget||ue.key!=="Enter"||(ue.preventDefault(),ue.stopPropagation(),c([$]),o?o():O(!0))}},ye=K&&f.jsx(du,{nodeAddress:$,active:N,label:e.label||e.headerTitle||"Node",open:_&&(!Q||!!y.editable&&!y.readOnly),onClose:()=>{var ue;O(!1),N&&((ue=R.current)==null||ue.focus({preventScroll:!0}))},children:Q?f.jsx(uu,{nodeId:$,content:e.label??e.text??"",color:Me(S),editOnMount:!0,onChange:ue=>{var Re;return(Re=g.onNodeLabelChange)==null?void 0:Re.call(g,$,String(ue))},onEditEnd:()=>O(!1)}):void 0}),we=Array.isArray((J=e==null?void 0:e.config)==null?void 0:J.ports)?e.config.ports.map(ue=>f.jsx(tv,{...ue},`${ue.id}:${ue.role}`)):null;return n?f.jsxs(W.Box,{ref:R,...ie,onClick:F,onDoubleClick:G,onMouseEnter:D,onMouseLeave:ce,cursor:"pointer",position:"relative",children:[ye,!p&&(ee||I&&I.length>0)&&k&&!q&&f.jsxs(f.Fragment,{children:[f.jsx(W.Box,{position:"absolute",top:-150,left:"0",right:"0",height:"150px",pointerEvents:"auto",onMouseEnter:()=>T(!0),onMouseLeave:ce}),ee?f.jsx(W.Box,{position:"absolute",zIndex:1e3,top:ne,transformOrigin:oe,left:"50%",pointerEvents:"auto",transform:pe,onMouseEnter:()=>T(!0),onMouseLeave:ce,willChange:"transform",children:ee({nodeId:$,nodeData:e,isRoot:$==="root",isParent:!0,isHovered:k,setIsHovered:T})}):f.jsx(W.Box,{position:"absolute",zIndex:1e3,top:ne,transformOrigin:oe,left:"50%",bg:w,p:3,borderColor:C,borderWidth:1,borderRadius:"30px",pointerEvents:"auto",transform:pe,boxShadow:"lg",onMouseEnter:()=>T(!0),onMouseLeave:ce,willChange:"transform",children:f.jsxs(W.HStack,{px:2,gap:2,"data-flow-grid-toolbar":(e==null?void 0:e.type)==="grid"?"":void 0,css:(e==null?void 0:e.type)==="grid"?{"& button svg":{width:"22px",height:"22px",minWidth:"22px",minHeight:"22px"}}:void 0,children:[I.map((ue,Re)=>f.jsxs(W.Box,{display:"contents",children:[Re>0&&f.jsx(W.Box,{borderColor:C,height:5,borderRightWidth:1}),f.jsx(Sd,{icon:ue.icon,label:ue.label,color:S,bgColor:w,borderColor:C,textColor:S,boxSize:5,onClick:ze=>{var Te;ze.stopPropagation(),(Te=g.onNodeHoverAction)==null||Te.call(g,ue.id,$,e)}})]},ue.id)),ae&&f.jsx(ae,{data:e})]})})]}),r({id:$,data:e,isActive:N,isHovered:k,isLowZoom:q,isEditing:E,onSelect:F,onEditStart:()=>M(!0),onEditEnd:()=>M(!1)}),B&&!((xe=e==null?void 0:e.config)!=null&&xe.parentContainer)&&((Se=e==null?void 0:e.config)==null?void 0:Se.collapsed)!==void 0&&(()=>{var ze;const ue=x==="TB"||x==="BT",Re=t||x==="RL";return f.jsx(W.IconButton,{position:"absolute",...ue?{[x==="BT"?"top":"bottom"]:"-75px",left:"50%",transform:"translateX(-50%)"}:{right:Re?void 0:"-75px",left:Re?"-75px":void 0,top:"50%",transform:"translateY(-50%)"},"data-flow-collapse-control":"","aria-label":e.config.collapsed?"Expand":"Collapse",disabled:y.readOnly,onClick:Te=>{var qe;Te.stopPropagation(),(qe=g.onNodeCollapse)==null||qe.call(g,$,!e.config.collapsed)},bgColor:Me(((ze=e==null?void 0:e.viewProps)==null?void 0:ze.bgColor)||b),size:"md",color:"gray.100",rounded:"full",mr:2,px:2,py:4,children:e.config.collapsed?f.jsx(Y.PiPlusBold,{size:30,color:Me("gray.800")}):f.jsx(Y.PiMinusBold,{size:30,color:Me("gray.800")})})})()]}):f.jsxs(W.Box,{ref:R,...ie,onClick:F,onDoubleClick:G,onMouseEnter:D,onMouseLeave:ce,cursor:"pointer",transition:"transform 0.1s ease",position:"relative",children:[ye,we,!p&&(ee||I&&I.length>0)&&k&&!q&&f.jsxs(f.Fragment,{children:[f.jsx(W.Box,{position:"absolute",top:-150,left:"0",right:"0",height:"150px",pointerEvents:"auto",onMouseEnter:()=>T(!0),onMouseLeave:ce}),ee?f.jsx(W.Box,{position:"absolute",zIndex:1e3,top:ne,transformOrigin:oe,left:"50%",pointerEvents:"auto",transform:pe,onMouseEnter:()=>T(!0),onMouseLeave:ce,willChange:"transform",children:ee({nodeId:$,nodeData:e,isRoot:$==="root",isParent:!!n,isHovered:k,setIsHovered:T})}):f.jsx(W.Box,{position:"absolute",zIndex:1e3,top:ne,transformOrigin:oe,left:"50%",bg:w,p:3,borderColor:C,borderWidth:1,borderRadius:"30px",pointerEvents:"auto",transform:pe,boxShadow:"lg",onMouseEnter:()=>T(!0),onMouseLeave:ce,willChange:"transform",children:f.jsxs(W.HStack,{px:2,gap:2,"data-flow-grid-toolbar":(e==null?void 0:e.type)==="grid"?"":void 0,css:(e==null?void 0:e.type)==="grid"?{"& button svg":{width:"22px",height:"22px",minWidth:"22px",minHeight:"22px"}}:void 0,children:[I.map((ue,Re)=>f.jsxs(W.Box,{display:"contents",children:[Re>0&&f.jsx(W.Box,{borderColor:C,height:5,borderRightWidth:1}),f.jsx(Sd,{icon:ue.icon,label:ue.label,color:S,bgColor:w,borderColor:C,textColor:S,boxSize:5,onClick:ze=>{var Te;ze.stopPropagation(),(Te=g.onNodeHoverAction)==null||Te.call(g,ue.id,$,e)}})]},ue.id)),ae&&f.jsx(ae,{data:e})]})})]}),f.jsxs(W.Box,{position:"relative",display:"flex",h:"100%",w:"100%",children:[B&&!((Fe=e==null?void 0:e.config)!=null&&Fe.parentContainer)&&((De=e==null?void 0:e.config)==null?void 0:De.collapsed)!==void 0&&!n&&(()=>{var Te,qe,Qe;const ue=x==="TB"||x==="BT",Re=t||x==="RL",ze=(Te=e==null?void 0:e.config)!=null&&Te.labelBelow&&v[$]!=="properties"?((((qe=e==null?void 0:e.viewProps)==null?void 0:qe.fontSize)||1)*100+100)/2:void 0;return f.jsx(W.IconButton,{position:"absolute",...ue?{[x==="BT"?"top":"bottom"]:"-75px",left:"50%",transform:"translateX(-50%)"}:{right:Re?void 0:ze===void 0?"-75px":`calc(50% - ${ze+75}px)`,left:Re?ze===void 0?"-75px":`calc(50% - ${ze+75}px)`:void 0,alignSelf:ze===void 0?"center":void 0,top:ze===void 0?void 0:`${ze}px`,transform:ze===void 0?void 0:"translateY(-50%)",zIndex:ze===void 0?void 0:1},"data-flow-collapse-control":"","aria-label":e.config.collapsed?"Expand":"Collapse",disabled:y.readOnly,onClick:ct=>{var Pe;ct.stopPropagation(),(Pe=g.onNodeCollapse)==null||Pe.call(g,$,!e.config.collapsed)},bgColor:Me(((Qe=e==null?void 0:e.viewProps)==null?void 0:Qe.bgColor)||b),size:"md",color:"gray.100",rounded:"full",mr:2,px:2,py:4,children:e.config.collapsed?f.jsx(Y.PiPlusBold,{size:30,color:Me("gray.800")}):f.jsx(Y.PiMinusBold,{size:30,color:Me("gray.800")})})})(),r({id:$,data:e,isActive:N,isHovered:k,isLowZoom:q,isEditing:E,onSelect:F,onEditStart:()=>M(!0),onEditEnd:()=>M(!1)})]})]})},Un=j.memo(Qj),eE=({id:e,data:r,isActive:t,isEditing:n,onEditStart:o,onEditEnd:i})=>{var g,y,b,x,v,w,C,S;const{themeColor:s}=Ze(),{colorText:a}=lt(),c=((g=r==null?void 0:r.viewProps)==null?void 0:g.bgColor)==="transparent",l=((y=r==null?void 0:r.viewProps)==null?void 0:y.outline)===!0,{highlightColor:d,borderColor:u,textColor:h}=Ln(((b=r==null?void 0:r.viewProps)==null?void 0:b.bgColor)||s),p=Me(((x=r==null?void 0:r.viewProps)==null?void 0:x.textColor)||(c||l?a:h)),m=((v=r==null?void 0:r.viewProps)==null?void 0:v.borderColor)||(l?!c&&((w=r==null?void 0:r.viewProps)==null?void 0:w.bgColor)||s:u);return f.jsx(W.Box,{"data-flow-node-surface":"",borderRadius:(C=r==null?void 0:r.viewProps)==null?void 0:C.borderRadius,bgColor:l?"transparent":d,...$n(r==null?void 0:r.viewProps,m,t,2),py:14,px:20,whiteSpace:"nowrap",w:"fit-content",children:f.jsxs(W.Flex,{justifyContent:"start",alignItems:"center",gap:8,w:"fit-content",maxW:900,minW:0,fontSize:"5xl",lineHeight:"normal",children:[((S=r==null?void 0:r.config)==null?void 0:S.icon)&&f.jsx(W.Box,{flexShrink:0,children:f.jsx(or,{name:r.config.icon,size:80,color:p})}),f.jsx(tn,{nodeId:e,label:(r==null?void 0:r.label)||(r==null?void 0:r.text)||"",color:p,isEditing:n,onEditStart:o,onEditEnd:i})]})})};function fu(e,r,t){const{readOnly:n,selectedNodeIds:o}=Ze(),i=o.includes(e),s=j.useRef(i),a=j.useRef(t);a.current=t,j.useEffect(()=>{s.current&&!i&&r&&!n&&a.current(),s.current=i},[i,r,n])}function Hn(){const{nodeViewModes:e,setNodeViewMode:r,allNodesIconLabel:t,setAllNodesIconLabel:n}=Ze();return{allNodesIconLabel:t,setAllNodesIconLabel:n,getNodeViewMode:o=>e[o]??"default",showNodeProperties:o=>r(o,"properties"),restoreNodeView:o=>r(o,"default"),toggleNodeView:o=>r(o,e[o]==="properties"?"default":"properties"),setNodeViewMode:r}}const tE=({id:e,isActive:r,data:t,isEditing:n,onEditStart:o,onEditEnd:i})=>{var v,w,C,S,R,P,k,T,E,M,_,O,$,B,N;const{themeColor:s}=Ze(),{colorText:a}=lt(),c=((v=t==null?void 0:t.viewProps)==null?void 0:v.bgColor)==="transparent",l=((w=t==null?void 0:t.viewProps)==null?void 0:w.outline)===!0,d=!c&&((C=t==null?void 0:t.viewProps)==null?void 0:C.bgColor)||s,{borderColor:u,highlightColor:h,textColor:p}=Ln(d),m=Me(((S=t==null?void 0:t.viewProps)==null?void 0:S.textColor)||(c||l?a:p)),g=c&&!l&&!((R=t==null?void 0:t.viewProps)!=null&&R.borderColor)?"transparent":Me(((P=t==null?void 0:t.viewProps)==null?void 0:P.borderColor)||(l?d:u)),y=c||l?"transparent":d!=null&&d.startsWith("#")?d:Me(h),b=(k=t==null?void 0:t.config)==null?void 0:k.icon,x=(t==null?void 0:t.label)??(t==null?void 0:t.text)??"";if((T=t==null?void 0:t.config)!=null&&T.labelBelow){const I=(((E=t==null?void 0:t.viewProps)==null?void 0:E.fontSize)||1)*100;return f.jsxs(W.Flex,{"data-flow-icon-label":"",css:{"--flow-grid-on-surface-color":m},direction:"column",align:"center",gap:"24px",width:`${Math.max(I+200,360)}px`,position:"relative",children:[f.jsx(W.Flex,{"data-flow-node-surface":"",align:"center",justify:"center",width:`${I+100}px`,height:`${I+100}px`,flexShrink:0,borderRadius:(M=t==null?void 0:t.viewProps)==null?void 0:M.borderRadius,backgroundColor:y,...$n(t==null?void 0:t.viewProps,g,r,2),children:!!b&&f.jsx(or,{name:b,size:I,color:m})}),f.jsxs(W.Flex,{"data-flow-icon-caption":"",direction:"column",align:"center",gap:"8px",justify:"center",width:"100%",minW:0,textAlign:"center",children:[f.jsx(tn,{nodeId:e,label:x,color:`var(--flow-grid-caption-color, ${Me(((_=t==null?void 0:t.viewProps)==null?void 0:_.textColor)||a)})`,isEditing:n,onEditStart:o,onEditEnd:i,wrap:!0}),typeof((O=t.config)==null?void 0:O.subtitle)=="string"&&t.config.subtitle!==""&&f.jsx(W.Text,{"data-flow-node-subtitle":"",color:Me((($=t==null?void 0:t.viewProps)==null?void 0:$.textColor)||a),opacity:.65,fontSize:"32px",fontWeight:"normal",lineHeight:1.3,width:"100%",whiteSpace:"nowrap",overflow:"hidden",textOverflow:"ellipsis",title:t.config.subtitle,children:t.config.subtitle})]})]})}return f.jsxs(W.Flex,{"data-flow-node-surface":"",align:"center",borderRadius:(B=t==null?void 0:t.viewProps)==null?void 0:B.borderRadius,bgColor:y,style:{backgroundColor:y},textTransform:"capitalize",...$n(t==null?void 0:t.viewProps,g,r,2),px:50,w:"fit-content",whiteSpace:"nowrap",children:[!!b&&f.jsx(W.Flex,{align:"center",py:14,mr:x?8:0,flexShrink:0,children:f.jsx(or,{name:b,size:(((N=t==null?void 0:t.viewProps)==null?void 0:N.fontSize)||1)*100,color:m},m)}),(x||!b)&&f.jsx(W.Flex,{justifyContent:"start",py:14,fontSize:"5xl",lineHeight:"normal",w:"fit-content",maxW:900,minW:0,children:f.jsx(tn,{nodeId:e,label:x,color:m,isEditing:n,onEditStart:o,onEditEnd:i})})]})};function uo({onExpand:e,toggleLabel:r="Show properties",toggleDisabled:t=!1,renderCompact:n=tE,...o}){const{colorMode:i,callbacks:s}=Ze();return f.jsx(Un,{...o,hoverLeaveDelay:e?350:0,children:a=>f.jsxs(W.Box,{position:"relative",children:[f.jsx(n,{...a}),e&&(a.isHovered||a.isActive)&&f.jsx(W.Box,{position:"absolute",top:"-24px",right:"-48px","data-flow-content-toggle":"",children:f.jsx(He,{label:r,children:f.jsx(Ne,{"aria-label":r,icon:f.jsx(W.Icon,{as:Y.PiCircleFill,boxSize:4}),variant:"ghost",w:12,h:12,minW:12,color:i==="dark"?"gray.100":"gray.800",disabled:t,onClick:c=>{var l;c.stopPropagation(),a.isActive||a.onSelect(c,!0),(l=s.onNodeViewToggle)==null||l.call(s,o.data.id),e()}})})})]})})}const rE=(e,r,t)=>{var h,p,m,g;const n=((h=e==null?void 0:e.viewProps)==null?void 0:h.bgColor)||r,[o]=n.split("."),i=Ln(n),s=((p=e==null?void 0:e.viewProps)==null?void 0:p.outline)===!0,a=n==="transparent"||s,c=t==="dark"?"gray.200":"gray.900",l=a?"transparent":n!=null&&n.startsWith("#")?Me(n):Me(i.bgColor),d=Me(((m=e==null?void 0:e.viewProps)==null?void 0:m.textColor)||(a?c:i.textColor)),u=Me(((g=e==null?void 0:e.viewProps)==null?void 0:g.borderColor)||(s?n==="transparent"?r:n:i.borderColor));return{...i,bgColor:a?"transparent":i.bgColor,highlightColor:a?"transparent":i.highlightColor,isTransparent:a,propertyColor:a?c:i.propertyColor,bg:n,wordBeforeDot:o,hexbgColor:l,hextextColor:d,hexborderColor:u}},nE=(e,r=350)=>`${String(e).substring(0,r)}${String(e).length>r?"...":""}`,oE=e=>e!=null&&e.includes("root")?e.replace("root","untitled"):e,ov=600,iE=3,aE=e=>{const r=Math.max(...Object.keys(e||{}).map(n=>n.length),0);return Math.max(r*28+30,200)};function sE({headerTitle:e,hasContent:r,data:t,icon:n,colors:o,hasConfig:i,id:s,isActive:a,isHovered:c,isEditing:l,onSelect:d,onEditStart:u,onEditEnd:h,props:p,objVisible:m,setObjVisible:g,onShowNativeIcon:y}){var w,C,S,R;const{callbacks:b}=Ze();if(r&&!m&&t.label===""&&(((w=t.config)==null?void 0:w.contentFormat)==="html"||((C=t.config)==null?void 0:C.contentFormat)==="jsx"))return null;const x=p.onShowIcon??y,v=x?"Show icon":m?"Show content":"Show properties";return f.jsx(f.Fragment,{children:(e||r||((S=t.config)==null?void 0:S.form)||(a||c)&&y)&&f.jsxs(W.Flex,{justify:"flex-start",direction:"row",p:r||Object.entries(t.description||{}).length?8:20,borderBottomWidth:1,minWidth:"max-content !important",width:"100%",textTransform:"capitalize",align:"center",textOverflow:"ellipsis",alignItems:"center",fontWeight:"bold",color:o.propertyColor,bgColor:o.highlightColor,borderBottomColor:!i&&!r?"transparent":o.hexborderColor,children:[!!n&&f.jsx(W.Flex,{mr:6,alignItems:"center",flexShrink:0,children:f.jsx(or,{name:n,size:64,color:o.hextextColor},o.hextextColor)}),f.jsx(tn,{nodeId:s,label:oE(e),color:((R=t==null?void 0:t.viewProps)==null?void 0:R.textColor)||o.propertyColor,isEditing:l,onEditStart:u,onEditEnd:h}),(a||c)&&(r||x)&&f.jsx(W.Box,{ml:"auto",pl:6,flexShrink:0,"data-flow-content-toggle":"",children:f.jsx(He,{label:v,children:f.jsx(Ne,{"aria-label":v,icon:f.jsx(W.Icon,{as:Y.PiCircleFill,boxSize:4}),variant:"ghost",w:12,h:12,minW:12,color:o.hextextColor,onClick:P=>{var k;P.stopPropagation(),a||d(P),x?x():g(!m),(k=b.onNodeViewToggle)==null||k.call(b,s)}})})})]})})}function cE({data:e,resourcePorts:r,inspecting:t,form:n,inspectionPorts:o,extraPorts:i,colors:s,direction:a,uniformKeyWidth:c}){const{edgeById:l}=Kt(),d=new Set;for(const{data:u}of l.values())u.source===e.id&&u.sourceProperty!==void 0&&d.add(`source:${u.sourceProperty}`),u.target===e.id&&u.targetProperty!==void 0&&d.add(`target:${u.targetProperty}`);return f.jsx(W.Box,{children:Object.entries(e.description||{}).map(([u,h],p)=>{var _,O,$;const m=r&&Object.keys(r).find(B=>B.slice(B.indexOf(":")+1)===u),g=t&&((_=n==null?void 0:n.type.ports)==null?void 0:_[u]),y=m??(g?`${g.kind}:${u}`:u),b=o.find(B=>B.id===y),x=m?"source":b==null?void 0:b.role,v=d.has(`source:${y}`),w=d.has(`target:${y}`),C=i.some(B=>B.id===u),S=h===""&&(C||(x?d.has(`${x}:${y}`):v||w)),R=x??(v!==w?v?"source":"target":void 0),P=(b==null?void 0:b.side)??(R?R==="source"!=(a==="RL")?"right":"left":void 0),k=S&&P==="right"?"right":"left",T=(b==null?void 0:b.label)??(g==null?void 0:g.label)??(C?u.replace(/^(template|input|output|config|error):/,""):u),E=nr(s.wordBeforeDot)[typeof h],M=nr(s.wordBeforeDot).property;return f.jsxs(W.Box,{"data-flow-property":m&&(a==="TB"||a==="BT")?void 0:y,"data-flow-port-role":x,"data-flow-inspection-row":t?"":void 0,children:[f.jsxs(W.Flex,{flexWrap:"nowrap",overflow:"hidden",children:[f.jsx(W.Flex,{justifyContent:"start",align:"center",background:s.highlightColor,width:S?"100%":`${c}px`,minWidth:`${c}px`,borderRightColor:s.hexborderColor,borderRightWidth:S?0:1,children:f.jsx(W.Text,{py:5,px:10,w:"100%",textAlign:k,whiteSpace:"nowrap",fontWeight:"bold",fontSize:"4xl",color:((O=e==null?void 0:e.viewProps)==null?void 0:O.textColor)||(s.isTransparent?s.hextextColor:M),children:T})}),!S&&f.jsx(W.Flex,{flex:1,justifyContent:"start",overflow:"hidden",p:4,background:s.hexbgColor,w:ov,maxH:200,children:f.jsx(W.Text,{overflow:"hidden",py:3,px:4,whiteSpace:"normal",textOverflow:"ellipsis",fontSize:"4xl",color:(($=e==null?void 0:e.viewProps)==null?void 0:$.textColor)||(s.isTransparent?s.hextextColor:E),fontWeight:400,children:nE(h)})})]}),p!==Object.entries(e.description||{}).length-1&&f.jsx(W.Box,{borderTopWidth:1,my:0,borderColor:s.hexborderColor})]},u)})})}function lE(e){var v,w,C,S,R;const{themeColor:r,colorMode:t,direction:n}=Ze(),o=Hn(),i=o.getNodeViewMode(e.data.id)==="properties",s=P=>o.setNodeViewMode(e.data.id,P?"properties":"default"),a=!!e.onShowIcon||i||typeof((v=e.data.config)==null?void 0:v.content)!="string"&&!(((w=e.data.config)==null?void 0:w.contentFormat)==="jsx"&&Array.isArray((C=e.data.config)==null?void 0:C.content)),{bindings:c,data:l,schema:d}=j.useContext(Tt),u=(S=c==null?void 0:c[e.data.id])==null?void 0:S.portResources,h=c?Fn(c,e.data.id,d):l&&d?on(l,e.data.id,d):void 0,p=h&&Le(l,"address"in h?h.address:e.data.id),m=p&&typeof p=="object"&&h?Object.fromEntries(Object.keys(h.type.properties).filter(P=>{var k;return Object.prototype.hasOwnProperty.call(p,P)&&bo((k=h.fields[P])==null?void 0:k.$visibleWhen,l)}).map(P=>[P,p[P]!==null&&typeof p[P]=="object"?JSON.stringify(p[P],null,2):p[P]===null?"null":p[P]])):{},g=u?Object.fromEntries(Object.entries(u).map(([P,k])=>{var T;return[P.slice(P.indexOf(":")+1),((T=Le(l,k))==null?void 0:T.name)??k.split(".").at(-1)]})):Object.keys(e.data.description??{}).length?e.data.description:m,y=a&&!u?((R=e.data.config)==null?void 0:R.ports)??[]:[],b=y.filter(P=>!Object.prototype.hasOwnProperty.call(g,P.id)&&!Object.entries((h==null?void 0:h.type.ports)??{}).some(([k,T])=>`${T.kind}:${k}`===P.id&&Object.prototype.hasOwnProperty.call(g,k))),x={...g,...Object.fromEntries(b.map(P=>[P.id,""]))};return{themeColor:r,colorMode:t,direction:n,objVisible:i,setObjVisible:s,inspecting:a,resourcePorts:u,form:h,description:x,inspectionPorts:y,extraPorts:b}}const hu=e=>{var x,v,w,C,S,R,P,k;const{themeColor:r,colorMode:t,direction:n,objVisible:o,setObjVisible:i,inspecting:s,resourcePorts:a,form:c,description:l,inspectionPorts:d,extraPorts:u}=lE(e),h=Hn(),p=h.getNodeViewMode(e.data.id)==="icon-label",m=!e.onShowIcon&&(typeof((x=e.data.config)==null?void 0:x.content)=="string"||((v=e.data.config)==null?void 0:v.contentFormat)==="jsx"&&Array.isArray((w=e.data.config)==null?void 0:w.content)),g=j.useRef(p);p&&(g.current=!0),fu(e.data.id,m&&!((C=e.data.config)!=null&&C.parentContainer)&&h.allNodesIconLabel&&!p&&g.current,()=>h.setNodeViewMode(e.data.id,"icon-label"));const b=!e.onShowIcon&&!((S=e.data.config)!=null&&S.parentContainer)?()=>h.setNodeViewMode(e.data.id,"icon-label"):void 0;return!e.onShowIcon&&p?f.jsx(uo,{...e,data:{...e.data,label:e.data.label??e.data.headerTitle,config:{...e.data.config,labelBelow:!0,icon:((R=e.data.config)==null?void 0:R.icon)||(m?((P=e.data.config)==null?void 0:P.contentFormat)==="html"?"PiFileHtml":((k=e.data.config)==null?void 0:k.contentFormat)==="jsx"?"PiFileJsx":"PiMarkdownLogo":"PiBracketsCurly")}},onExpand:()=>h.restoreNodeView(e.data.id)}):f.jsx(Un,{...e,data:{...e.data,description:l},hoverLeaveDelay:m||e.onShowIcon||b?350:0,children:({id:T,data:E,isActive:M,isHovered:_,isEditing:O,onSelect:$,onEditStart:B,onEditEnd:N})=>{var ce,Q,K,ie,ye,we,he,ge,X,H,be,J,xe,Se,Fe,De;const I=rE(E,r,t),ee=E.label??E.headerTitle,ae=Object.entries(E.description||{}).length>0,ne=aE(E.description),oe=(Q=(ce=e.data)==null?void 0:ce.config)==null?void 0:Q.icon,pe=(ie=(K=e.data)==null?void 0:K.config)==null?void 0:ie.content,q=m&&!o&&E.label===""&&(((ye=E.config)==null?void 0:ye.contentFormat)==="html"||((we=E.config)==null?void 0:we.contentFormat)==="jsx"),F=m&&!o&&(((he=E.config)==null?void 0:he.contentFormat)==="html"||((ge=E.config)==null?void 0:ge.contentFormat)==="jsx")&&((X=E.viewProps)==null?void 0:X.width)!==void 0&&E.viewProps.width!=="100%",G=((H=E==null?void 0:E.viewProps)==null?void 0:H.borderRadius)??"53px",D=$n(E==null?void 0:E.viewProps,I.hexborderColor,M,iE);return f.jsx(W.Flex,{justifyContent:"space-between",...E==null?void 0:E.viewProps,"data-flow-node-surface":"",direction:"column",p:0,borderRadius:G,overflow:"hidden",alignItems:"center",style:{backgroundColor:I.hexbgColor,transition:"border-color 0.2s ease-in-out"},width:q||F?((be=E.viewProps)==null?void 0:be.width)!==void 0&&E.viewProps.width!=="100%"?E.viewProps.width:"max-content":"100%",maxW:q?"calc(100vw - 40px)":void 0,minW:q||F?0:m||e.onShowIcon?ne+ov+D.borderWidth*2:void 0,...D,children:f.jsxs(W.Flex,{width:"100%",direction:"column",borderRadius:G,borderColor:I.hexborderColor,borderWidth:0,overflow:"hidden",children:[!e.fillBody&&f.jsx(sE,{headerTitle:ee,hasContent:m,data:E,icon:oe,colors:I,hasConfig:ae,id:T,isActive:M,isHovered:_,isEditing:O,onSelect:$,onEditStart:B,onEditEnd:N,props:e,objVisible:o,setObjVisible:i,onShowNativeIcon:b}),m&&!o?f.jsx(W.Flex,{w:"100%",overflow:"auto",justifyContent:"start",background:I.highlightColor,p:["html","jsx"].includes((xe=(J=e.data)==null?void 0:J.config)==null?void 0:xe.contentFormat)?0:12,fontSize:"5xl",lineHeight:"normal",children:f.jsx(uu,{nodeId:T,content:pe,format:(Fe=(Se=e.data)==null?void 0:Se.config)==null?void 0:Fe.contentFormat,fillBody:e.fillBody,autoHeight:q,color:((De=E==null?void 0:E.viewProps)==null?void 0:De.textColor)||I.hextextColor})}):f.jsx(cE,{data:E,resourcePorts:a,inspecting:s,form:c,inspectionPorts:d,extraPorts:u,colors:I,direction:n,uniformKeyWidth:ne})]})})}})};hu.displayName="NodeJsonObjectView";const iv=e=>{var h,p,m,g,y,b,x,v,w,C,S,R;const r=Hn(),[t,n]=j.useState(!1),o=r.getNodeViewMode(e.data.id)==="properties",i=P=>{n(P),r.setNodeViewMode(e.data.id,P?"properties":"default")},{callbacks:s,readOnly:a}=Ze(),c=(p=(h=e.data)==null?void 0:h.config)==null?void 0:p.parentContainer;fu(e.data.id,o&&((g=(m=e.data)==null?void 0:m.config)==null?void 0:g.labelBelow)&&!c,()=>i(!1));const l=c?"Show parent":"Show properties",d=c||((b=(y=e.data)==null?void 0:y.config)==null?void 0:b.form)||((w=(v=(x=e.data)==null?void 0:x.config)==null?void 0:v.ports)==null?void 0:w.length),u=d?()=>{var P;c?(P=s.onNodeCollapse)==null||P.call(s,e.data.id,!1):i(!0)}:void 0;return!c&&e.data.type==="text"&&r.getNodeViewMode(e.data.id)==="icon-label"?f.jsx(uo,{...e,renderCompact:void 0,data:{...e.data,config:{...e.data.config,labelBelow:!0,icon:((C=e.data.config)==null?void 0:C.icon)||"PiTextT"}},toggleLabel:"Show text",onExpand:()=>r.restoreNodeView(e.data.id)}):!c&&d&&o?f.jsx(hu,{...e,editOnMount:t,onShowIcon:()=>i(!1)}):f.jsx(uo,{...e,onOpenView:u&&(c||(R=(S=e.data)==null?void 0:S.config)!=null&&R.labelBelow)?()=>{var P;u(),(P=s.onNodeViewToggle)==null||P.call(s,e.data.id)}:void 0,toggleLabel:!c&&e.data.type==="text"?"Show icon":l,toggleDisabled:c&&a,onExpand:!c&&e.data.type==="text"?()=>r.setNodeViewMode(e.data.id,"icon-label"):u})};function dE(e){var b,x,v,w,C,S;const{config:r,callbacks:t,readOnly:n,selectedNodeIds:o,nodeRadiusPreviews:i,nodeViewModes:s,allNodesIconLabel:a}=Ze(),c=i[e.data.id]??((b=e.data.viewProps)==null?void 0:b.borderRadius),[l,d]=j.useState(!1),u=Hn(),{border:h,colorText:p}=lt(),m=(x=r.customViews)==null?void 0:x.gridContent,g=(s[e.data.id]??(a?"icon-label":"default"))==="icon-label",y=j.useRef(g);return g&&(y.current=!0),fu(e.data.id,a&&!g&&y.current,()=>u.setNodeViewMode(e.data.id,"icon-label")),g?f.jsx(W.Box,{"data-grid-document":((v=e.data.config)==null?void 0:v.documentId)??"",children:f.jsx(uo,{...e,data:{...e.data,viewProps:{...e.data.viewProps,borderRadius:c},config:{...e.data.config,labelBelow:!0,icon:((w=e.data.config)==null?void 0:w.icon)||"PiGridFour"}},toggleLabel:"Show grid",onExpand:()=>u.restoreNodeView(e.data.id)})}):f.jsxs(f.Fragment,{children:[f.jsx(Un,{...e,onOpenView:()=>d(!0),children:({data:R,isActive:P})=>{var k,T,E,M,_,O,$,B;return f.jsx(W.Box,{"data-flow-node-surface":"","data-grid-document":((k=R.config)==null?void 0:k.documentId)??"",width:`${((E=(T=R.config)==null?void 0:T.gridSize)==null?void 0:E.width)??600}px`,height:`${((_=(M=R.config)==null?void 0:M.gridSize)==null?void 0:_.height)??440}px`,overflow:"hidden",position:"relative",bg:((O=R.viewProps)==null?void 0:O.bgColor)??"transparent",color:(($=R.viewProps)==null?void 0:$.textColor)??p,borderRadius:`${c??0}px`,...$n(R.viewProps,Me(((B=R.viewProps)==null?void 0:B.borderColor)??h),P,0),children:m?f.jsx(m,{...e}):f.jsx(W.Box,{p:4,children:R.label??"Grid"})})}}),f.jsx(du,{nodeAddress:e.data.id,active:o.includes(e.data.id),label:e.data.label??"Grid",open:l&&!n,onClose:()=>d(!1),children:f.jsx(Tt.Provider,{value:{data:{metadata:{label:e.data.label??"",subtitle:((C=e.data.config)==null?void 0:C.subtitle)??"",icon:((S=e.data.config)==null?void 0:S.icon)??"PiGridFour"}},bindings:{[e.data.id]:{address:"root.metadata",type:"GridMetadata"}},schema:{GridMetadata:{kind:"object",properties:{label:{optional:!0,type:{kind:"string"}},subtitle:{optional:!0,type:{kind:"string"}},icon:{optional:!0,type:{kind:"string"}}}}},editable:!!r.editable&&!n,callbacks:{onFormChange:R=>{var k,T,E;if(n||!r.editable)return;const P=String(R.value??"");R.address==="root.metadata.label"?(k=t.onNodeLabelChange)==null||k.call(t,e.data.id,P):R.address==="root.metadata.subtitle"?(T=t.onNodeSubtitleChange)==null||T.call(t,e.data.id,P):R.address==="root.metadata.icon"&&((E=t.onNodeIconChange)==null||E.call(t,e.data.id,P))}}},children:f.jsx(Ld,{nodeAddress:e.data.id})})})]})}const av=e=>f.jsx(iv,{...e,renderCompact:eE}),sv=e=>f.jsx(iv,{...e}),cv=({containerStyle:e,...r})=>{const{selectedNodeIds:t}=Ze();return f.jsx(Un,{...r,editOnMount:t.includes(r.data.id),children:n=>f.jsx(W.Box,{bg:e.textColor==="transparent"?"transparent":e.labelBg,p:`${e.fontSize/5}px`,fontFamily:mr,lineHeight:1,w:"fit-content",children:f.jsx(tn,{nodeId:n.id,label:n.data.label??n.data.headerTitle??"Container",color:e.textColor,fontSize:`${e.fontSize}px`,isEditing:n.isEditing,onEditStart:n.onEditStart,onEditEnd:n.onEditEnd})})})};av.displayName="text";sv.displayName="arrayView";cv.displayName="ParentContainerView";const uE={grid:dE,objectView:hu,arrayView:sv,text:av,parentContainer:cv},fE=({children:e,pattern:r="dot",backgroundColor:t})=>{const{colorMode:n}=Ze(),o=n==="dark",i=o?"--chakra-colors-gray-700":"--chakra-colors-gray-500",s=o?"--chakra-colors-gray-700":"--chakra-colors-gray-800";return r==="none"?f.jsx(W.Box,{"data-flow-background":"none",width:"100%",height:"100%",padding:0,bg:t,children:e}):f.jsxs(W.Box,{"data-flow-background":r,position:"relative",width:"100%",height:"100%",padding:0,bg:t,children:[f.jsx(W.Box,{position:"absolute",top:0,left:0,right:0,bottom:0,width:"100%",height:"100%",zIndex:0,pointerEvents:"none",style:{backgroundImage:r==="dot"?`radial-gradient(var(${i}) 8%, transparent 8%)`:r==="steel"?`repeating-linear-gradient(45deg, var(${s}) 0, var(${s}) 1px, transparent 1px, transparent 20px)`:`linear-gradient(var(${s}) 1px, transparent 1px), linear-gradient(90deg, var(${s}) 1px, transparent 1px)`,backgroundSize:"20px 20px",opacity:.3}}),f.jsx(W.Box,{position:"relative",width:"100%",height:"100%",zIndex:1,padding:0,children:e})]})},hE=.4,Mr={borderWidth:6,borderStyle:"solid",borderRadius:50,fontSize:70,padding:120,labelPosition:"top",labelMargin:90},pE=({nodes:e,edges:r})=>{var Ve;const{themeColor:t,spacing:n,edgeRadius:o,backgroundVariant:i,backgroundSelected:s,setBackgroundSelected:a,edgeColor:c,direction:l,nodeAlignment:d,edgeMode:u,compactPropertyLayout:h,workflowContract:p,parentNodeStyle:m,engineRef:g,callbacks:y,config:b,selectedNodeIds:x,setSelectedNodeIds:v,selectedEdgeId:w,setSelectedEdgeId:C,setIsPerformanceMode:S,setNodeGridOptions:R,fillRadiusEditedIds:P,isZoomMode:k,setIsZoomMode:T,isMultiSelectMode:E,setIsMultiSelectMode:M,isDragMode:_,setIsDragMode:O,isEdgeHandlesEnabled:$,setIsEdgeHandlesEnabled:B,isArrayNodeMode:N}=Ze(),I=j.useRef(null),[ee,ae]=j.useState(null),ne=j.useRef(null),oe=e.length>200;j.useEffect(()=>{S(oe)},[oe,S]);const{edgeSep:pe,rankSep:q,spacingFactor:F}=j.useMemo(()=>{const de=Uw(e.length),V=b.nodeGridSpacing==="layout"&&n<.5?n*1.3:n<1?.3+.7*n:.5+.5*n;return{edgeSep:de.edgeSep*V,rankSep:de.rankSep*V,spacingFactor:1.3+(n-1)*(n<1?.4:.3)}},[e.length,n,b.nodeGridSpacing]),{bgColor:G}=Ln(t),{canvas:D,borderSecondary:ce,colorText:Q}=lt(),K=i==="transparent"?"transparent":b.backgroundColor||D,ie=j.useCallback(de=>{if(!de)return Me(t);switch(de){case"dark":return Me(K);case"light":return Me(ce);default:return Me(de)}},[t,K,ce]),ye=b.colorMode==="dark",we=ye?Me("gray.500"):rn,he=ye?G!=null&&G.includes("gray")?"whitesmoke":ie(G):we,ge=c?ie(c):we,X=j.useMemo(()=>{var de;return b.initialViewport||{pan:{x:0,y:0},zoom:(de=b.nodeGrid)!=null&&de.enabled&&b.nodeGrid.options.fill?1:.01}},[]),H=l==="C"?"LR":l,be=j.useCallback(de=>{const V={...m,...de};return{...V,bgColor:V.bgColor||t,bgOpacity:V.outline?0:V.bgOpacity??hE}},[m,t]),J=j.useMemo(()=>{var V;const de=new Map;for(const se of e)(V=se.data)!=null&&V.id&&de.set(se.data.id,se);return de},[e]),xe=j.useMemo(()=>{var V;const de=new Map;for(const se of r)(V=se.data)!=null&&V.id&&de.set(se.data.id,se);return de},[r]),Se=j.useCallback(de=>{var U;const V=(U=J.get(de))==null?void 0:U.data,se=be(V==null?void 0:V.viewProps),Be=Me(se.bgColor);return{animated:!!(V!=null&&V.isNodeAnimated)&&!oe,animationVariant:V==null?void 0:V.nodeAnimationVariant,animationColor:Me(se.borderColor||t),bgColor:se.outline?"transparent":Be,bgOpacity:se.bgOpacity,borderColor:se.borderColor?Me(se.borderColor):se.outline&&se.bgColor==="transparent"?Me(t):Be,borderWidth:On(se.borderWidth,Mr.borderWidth),borderStyle:se.borderStyle??Mr.borderStyle,borderRadius:se.borderRadius??Mr.borderRadius,textColor:se.textColor?Me(se.textColor):se.outline||se.bgColor==="transparent"?Me(Q):Be,fontSize:se.fontSize??Mr.fontSize,labelPosition:se.labelPosition??Mr.labelPosition,labelMargin:Mr.labelMargin,labelBg:Eu(ie("dark"),Be,se.bgOpacity)??ie("dark"),padding:se.padding??Mr.padding}},[be,J,Q,t,oe,ie]),Fe=j.useMemo(()=>{var se,Be;const de=new Map;for(const U of r){const Ce=(se=U.data)==null?void 0:se.source,Oe=(Be=U.data)==null?void 0:Be.target;if(!Ce||!Oe||Ce===Oe)continue;const je=Ce<Oe?`${Ce}|${Oe}`:`${Oe}|${Ce}`,We=de.get(je);We?We.push({id:U.data.id,source:Ce}):de.set(je,[{id:U.data.id,source:Ce}])}const V=new Map;for(const[U,Ce]of de){if(Ce.length<2)continue;const Oe=U.split("|")[0],je=Math.min(20,70/Ce.length);Ce.forEach(({id:We,source:ot},Xe)=>{const St=50+(Xe-(Ce.length-1)/2)*je;V.set(We,(ot===Oe?St:100-St)/100)})}return V},[r]),De=j.useMemo(()=>{const de=ie("dark");return r.filter(V=>{var se;return((se=V.data)==null?void 0:se.id)&&V.data.source&&V.data.target}).map(({data:V})=>{var Ce,Oe,je,We,ot,Xe;let se=de;const Be=(Oe=(Ce=J.get(V.source))==null?void 0:Ce.data)==null?void 0:Oe.parent,U=(We=(je=J.get(V.target))==null?void 0:je.data)==null?void 0:We.parent;if(Be&&Be===U){const St=be((Xe=(ot=J.get(Be))==null?void 0:ot.data)==null?void 0:Xe.viewProps),kt=Eu(de,Me(St.bgColor),St.bgOpacity);kt&&(se=kt)}return{id:V.id,data:V,type:V.type??b.edgeType??"rounded-orthogonal",source:V.source,target:V.target,sourceProperty:V.sourceProperty,targetProperty:V.targetProperty,label:V.label,validationIssue:(u==="auto"||u==="properties")&&(V.sourceProperty!==void 0||V.targetProperty!==void 0)&&p?$d(p,V):void 0,color:c?ge:V.color?Me(V.color):ge,connectorColor:c?ge:V.color?Me(V.color):he,labelBg:se,dashed:!!V.isEdgeDashed,animated:!!V.isEdgeAnimated,inverted:!!V.isInverted,turn:Fe.get(V.id)??.5}})},[r,ge,he,c,Fe,b.edgeType,u,p,J,be,ie]),ue=j.useMemo(()=>{var V;const de=new Set;for(const se of e)(V=se.data)!=null&&V.parent&&de.add(se.data.parent);return de},[e]),Re=j.useMemo(()=>{const de=new Map;for(const V of r){const se=V.data.isInverted?V.data.target:V.data.source;se&&!de.has(se)&&de.set(se,V.data)}for(const V of r){if(V.data.connection)continue;const se=V.data.isInverted?V.data.target:V.data.source,Be=V.data.isInverted?V.data.source:V.data.target;Be.startsWith(`${se}.`)&&(de.set(se,V.data),de.set(Be,V.data))}return de},[r]),ze=j.useMemo(()=>{const de={...uE,...b.customViews};return e.filter(V=>{var se;return(se=V.data)==null?void 0:se.id}).map(V=>{var We,ot,Xe,St,kt,Ot,$t,mt,ht;const se=ue.has(V.data.id)&&!V.data.parent,Be=se?V.data.label??V.data.headerTitle??"Container":void 0,U=se?de.parentContainer:de[V.data.type]||de.text,Ce=((We=b.customViews)==null?void 0:We.fillNode)??U,Oe=Re.get(V.data.id),je={...V,isInverted:((ot=V.data.config)==null?void 0:ot.isInverted)??(Oe==null?void 0:Oe.isInverted),isParent:se,containerStyle:se?Se(V.data.id):void 0};return{id:V.data.id,collapsed:(Xe=V.data.config)==null?void 0:Xe.collapsed,parent:V.data.parent,acceptsChildren:!!((St=V.data.config)!=null&&St.parentContainer)||ue.has(V.data.id),label:Be,animated:!!V.data.isNodeAnimated,animationVariant:V.data.nodeAnimationVariant,hasCollapseControl:((kt=V.data.config)==null?void 0:kt.collapsed)!==void 0,animationColor:Me(((Ot=V.data.viewProps)==null?void 0:Ot.borderColor)||t),animationWidth:On(($t=V.data.viewProps)==null?void 0:$t.borderWidth,8),element:j.createElement(U,{...je,key:`${V.data.id}-${t}`}),fillElement:P.has(V.data.id)&&!((mt=b.customViews)!=null&&mt.fillNode)?void 0:j.createElement(Ce,{...je,...(ht=b.customViews)!=null&&ht.fillNode?{renderNode:U}:{},data:{...V.data,viewProps:P.has(V.data.id)?V.data.viewProps:{...V.data.viewProps,borderRadius:0}},containerStyle:je.containerStyle&&!P.has(V.data.id)?{...je.containerStyle,borderRadius:0}:je.containerStyle,key:`${V.data.id}-${t}`})}})},[e,ue,Re,t,b.customViews,Se,P]),Te=j.useMemo(()=>oe?300:e.length>50?150:e.length>20?100:50,[e.length,oe]),qe=j.useRef(b);qe.current=b;const Qe=j.useRef(k);Qe.current=k;const ct=j.useRef(N);ct.current=N;const Pe=j.useRef(x);Pe.current=x;const Je=j.useRef(w);Je.current=w;const Ye=j.useRef(E);Ye.current=E;const nt=j.useRef(J);nt.current=J;const Nt=j.useRef(xe);Nt.current=xe;const Rt=j.useRef(new Map);j.useEffect(()=>{var se,Be;const de=new Map([...xe].filter(([,U])=>J.has(U.data.source)&&J.has(U.data.target))),V=Rt.current;Rt.current=de;for(const[U,Ce]of V)de.has(U)||(Je.current===U&&(C(null),(se=y.onEdgeDeselect)==null||se.call(y)),(Be=y.onEdgeRemove)==null||Be.call(y,U,Ce.data))},[xe,J,y,C]),j.useEffect(()=>{const de=I.current;if(!ee||!de)return;let V=null,se=null,Be=0,U=0,Ce=0,Oe=0,je=0;const We=ot=>{var kt;if(qe.current.readOnly||qe.current.minZoom===qe.current.maxZoom&&qe.current.minZoom!==void 0&&((kt=de.parentElement)!=null&&kt.closest(".flow-sdk-canvas")))return;const Xe=de.ownerDocument.fullscreenElement;if(Xe&&Xe!==de&&de.contains(Xe)&&ot.target instanceof Node&&Xe.contains(ot.target))return;ot.preventDefault(),ot.stopPropagation(),Qe.current||ot.metaKey||ot.ctrlKey?(Ce+=ot.deltaY,Oe=ot.clientX,je=ot.clientY,se===null&&(se=requestAnimationFrame(()=>{se=null;const Ot=qe.current,$t=ee.zoom(),mt=Ce;Ce=0;let ht=$t-mt*.05/100;ht=Math.max(Ot.minZoom??.01,Math.min(Ot.maxZoom??1.5,ht));const jt=de.getBoundingClientRect();ee.zoomAt(ht,{x:Oe-jt.left,y:je-jt.top})}))):(Be+=ot.deltaX,U+=ot.deltaY,V===null&&(V=requestAnimationFrame(()=>{V=null;const Ot=ee.pan(),$t=ee.zoom(),mt=.35,ht=Be,jt=U;Be=0,U=0,ee.pan({x:Ot.x+-ht*mt/$t,y:Ot.y+-jt*mt/$t})})))};return de.addEventListener("wheel",We,{passive:!1}),()=>{de.removeEventListener("wheel",We),V!==null&&cancelAnimationFrame(V),se!==null&&cancelAnimationFrame(se)}},[ee]),j.useEffect(()=>{if(b.disableKeyboardShortcuts)return;const de=V=>{var Be,U,Ce,Oe;if(qe.current.readOnly)return;const se=V.target;if(!(se.tagName==="INPUT"||se.tagName==="TEXTAREA"||se.isContentEditable)){if((V.key==="z"||V.key==="Z")&&T(!Qe.current),(V.key==="m"||V.key==="M")&&M(!E),(V.key==="d"||V.key==="D")&&O(!_),(V.key==="v"||V.key==="V")&&!V.repeat&&!V.metaKey&&!V.ctrlKey&&!V.altKey&&se.tagName!=="SELECT"&&B(!$),(V.key==="Delete"||V.key==="Backspace")&&Je.current){V.preventDefault();const je=Je.current;(U=y.onEdgeDelete)==null||U.call(y,je,((Be=Nt.current.get(je))==null?void 0:Be.data)??{id:je}),C(null);return}if((V.key==="Delete"||V.key==="Backspace")&&Pe.current.length>0){V.preventDefault();const je=Pe.current.filter(We=>We!=="root");if(je.length===0)return;for(const We of je){const ot=(Ce=nt.current.get(We))==null?void 0:Ce.data;(Oe=y.onNodeDelete)==null||Oe.call(y,We,ot||{})}v([])}}};return window.addEventListener("keydown",de),()=>window.removeEventListener("keydown",de)},[E,_,$,B,T,M,O,b.disableKeyboardShortcuts,y,v,C]);const Wr=j.useCallback(de=>{var V;g.current=de,ae(de),(V=y.onInit)==null||V.call(y,de)},[g,y]),rt=j.useCallback(de=>{var V;return(V=y.onViewportChange)==null?void 0:V.call(y,de)},[y]),Ke=j.useCallback(de=>{var se,Be,U;const V=((se=Nt.current.get(de))==null?void 0:se.data)??{id:de};if(Je.current===de&&Ye.current){C(null),(Be=y.onEdgeDeselect)==null||Be.call(y);return}Pe.current.length&&v([]),C(de),(U=y.onEdgeSelect)==null||U.call(y,de,V)},[y,C,v]),Zt=j.useCallback(()=>{var de,V,se,Be,U;if(a(b.bottomBarCollapsed??(Pe.current.length>0||!!Je.current||!s)),(de=y.onBackgroundClick)==null||de.call(y),!qe.current.readOnly){const Ce=new Set;for(const Oe of Pe.current){let je=nt.current.get(Oe);for(;je&&!Ce.has(je.data.id);)Ce.add(je.data.id),ue.has(je.data.id)&&((V=je.data.config)==null?void 0:V.collapsed)!==!0&&((se=y.onNodeCollapse)==null||se.call(y,je.data.id,!0)),je=je.data.parent?nt.current.get(je.data.parent):void 0}}Pe.current.length&&(v([]),(Be=y.onNodeDeselect)==null||Be.call(y)),Je.current&&(C(null),(U=y.onEdgeDeselect)==null||U.call(y))},[y,v,C,a,s,b.bottomBarCollapsed,ue]),ft=j.useCallback(de=>{var Be,U;const V=Pe.current,se=de.filter(Ce=>!V.includes(Ce));if(se.length){v([...V,...se]);for(const Ce of se)(U=y.onNodeSelect)==null||U.call(y,Ce,((Be=nt.current.get(Ce))==null?void 0:Be.data)??{id:Ce})}},[y,v]),jr=j.useCallback((de,V)=>{var se,Be;v([de]),(Be=y.onNodeSelect)==null||Be.call(y,de,((se=nt.current.get(de))==null?void 0:se.data)??{id:de},V)},[y,v]),Pt=j.useRef(null),Er=j.useCallback((de,V,se)=>{var Be;Pt.current={source:de,target:V,edgeIds:new Set(Nt.current.keys())};try{(Be=y.onEdgeCreate)==null||Be.call(y,de,V,se)}catch(U){throw Pt.current=null,U}},[y]),Wt=j.useCallback((de,V,se,Be=!1)=>{var U,Ce;if(ne.current={sourceId:de,nodeIds:new Set(nt.current.keys()),reverse:Be},!(u==="properties"&&((U=y.onNodeCreateRequest)==null?void 0:U.call(y,{sourceNodeId:de,position:V,sourceProperty:se,reverse:Be}))===!0)){if(se!==void 0||Be){ne.current=null;return}(Ce=y.onNodeCreate)==null||Ce.call(y,{type:"text",sourceNodeId:de,position:V,isArrayMode:ct.current})}},[y,u]),Xt=!b.readOnly&&$&&b.edgeHandles!==!1,ar=i==="transparent"?"none":i;return f.jsx(fE,{pattern:ar,backgroundColor:K,children:f.jsx(W.Box,{ref:I,padding:0,width:"100%",height:"100%",flex:1,position:"relative",children:f.jsx(Hj,{nodes:ze,edges:De,direction:H,nodeAlignment:d,onContainerCollapse:de=>{var V,se;(V=y.onNodeCollapse)==null||V.call(y,de,!0),(se=y.onNodeViewToggle)==null||se.call(y,de)},selectedNodeIds:x,edgeMode:u,compactPropertyLayout:h,edgeType:b.edgeType,edgeRadius:o,customEdgeTypes:b.customEdgeTypes,edgeReveal:b.disableAnimations?void 0:b.edgeReveal,rankSep:q,edgeSep:pe,nodeGridSpacing:b.nodeGridSpacing,nodeGridConnections:b.nodeGridConnections,initialNodeGrid:b.nodeGrid,spacingFactor:F,compactSpacingScale:n,layoutDebounce:Te,isPerformanceMode:oe,minZoom:b.minZoom??.01,maxZoom:b.maxZoom??1.5,initialViewport:X,fitOnInit:!b.initialViewport&&!((Ve=b.nodeGrid)!=null&&Ve.enabled&&b.nodeGrid.options.fill),readOnly:!!b.readOnly,containerStyle:Se,lineColor:c?ge:he,drawMode:Xt,drawHandles:!b.readOnly&&b.edgeHandles!==!1,dragMode:_,multiSelect:!!E,onInit:Wr,onLayoutComplete:de=>{var Ce;(Ce=y.onLayoutComplete)==null||Ce.call(y,de);const V=Pt.current;V&&(!nt.current.has(V.source)||!nt.current.has(V.target)?Pt.current=null:r.some(({data:Oe})=>Oe.source===V.source&&Oe.target===V.target&&!V.edgeIds.has(Oe.id))&&de.getNodeBox(V.source)&&de.getNodeBox(V.target)&&(Pt.current=null,de.focusConnections(V.source)));const se=ne.current;if(!se)return;if(!nt.current.has(se.sourceId)){ne.current=null;return}const U=e.filter(Oe=>!se.nodeIds.has(Oe.data.id)).filter(Oe=>r.some(({data:je})=>je.source===se.sourceId&&je.target===Oe.data.id||je.target===se.sourceId&&je.source===Oe.data.id));!U.length||U.some(Oe=>!de.getNodeBox(Oe.data.id))||(ne.current=null,de.focusBranch(se.reverse?U[0].data.id:se.sourceId))},onNodeGridModeChange:R,onNodeGridZoomOut:y.onNodeGridZoomOut,onNodeGridDrop:y.onNodeGridDrop,onNodeParentChange:y.onNodeParentChange,animateViewport:b.animateViewport,disableAnimations:b.disableAnimations,onViewportChange:rt,onBackgroundTap:Zt,onBoxSelect:ft,onEdgeSelect:Ke,onContainerSelect:jr,onEdgeDraw:Er,onDrawIntoSpace:Wt})})})},lv=j.memo(pE),gE=".flow-sdk-canvas{position:relative;width:100%;height:100%;overflow:clip;user-select:none;-webkit-user-select:none;touch-action:none}.flow-sdk-svg{position:absolute;top:0;left:0;width:100%;height:100%;overflow:visible;display:block}.flow-sdk-nodes{position:absolute;top:0;left:0;transform-origin:0 0;pointer-events:none;will-change:transform;backface-visibility:hidden;z-index:10}.flow-sdk-node{position:absolute;top:0;left:0;transform-origin:0 0;pointer-events:auto;will-change:transform;backface-visibility:hidden;z-index:10}.flow-sdk-node input,.flow-sdk-node textarea{pointer-events:auto;user-select:text;-webkit-user-select:text;cursor:text}.flow-sdk-edge-hit{fill:none;stroke:transparent;stroke-width:24px;vector-effect:non-scaling-stroke;pointer-events:stroke;cursor:pointer}.flow-sdk-container{cursor:pointer}.flow-sdk-edge-anim{animation:flow-sdk-dash .5s linear infinite}.flow-sdk-edge-anim-rev{animation-direction:reverse}@keyframes flow-sdk-dash{to{stroke-dashoffset:-50}}.flow-sdk-draw{cursor:crosshair}.flow-sdk-draw .flow-sdk-node,.flow-sdk-draw .flow-sdk-node input,.flow-sdk-draw .flow-sdk-node textarea,.flow-sdk-draw .flow-sdk-edge,.flow-sdk-draw .flow-sdk-container{pointer-events:none}.flow-sdk-perf.flow-sdk-busy .flow-sdk-edges{display:none}.flow-sdk-box{position:absolute;border:1px solid rgba(170,170,170,.9);background:rgba(221,221,221,.25);pointer-events:none;z-index:20}";let Rm=!1;function yE(){if(Rm||typeof document>"u")return;const e=document.createElement("style");e.setAttribute("data-flow-sdk",""),e.textContent=gE+".flow-sdk-canvas[data-node-grid] .flow-sdk-node,.flow-sdk-canvas[data-node-grid] .flow-sdk-node *,.flow-sdk-canvas[data-node-grid] .flow-sdk-node *::before,.flow-sdk-canvas[data-node-grid] .flow-sdk-node *::after{animation:none!important;transition:none!important}.flow-sdk-node[data-grid-fill] [data-flow-icon-label]{--flow-grid-caption-color:var(--flow-grid-on-surface-color)}.flow-sdk-node[data-grid-fill] [data-flow-node-surface]{border:0;outline:none;box-shadow:none}.flow-sdk-node[data-grid-fill]{box-sizing:border-box}.flow-sdk-node[data-grid-fill] :not(svg):has([data-flow-node-surface]),.flow-sdk-node[data-grid-fill]>:not(svg):not(button){width:100%;height:100%;min-width:0;max-width:none}.flow-sdk-node[data-grid-fill] [data-flow-node-surface]{width:100%;height:100%;min-width:0;max-width:none;box-sizing:border-box;overflow:hidden}.flow-sdk-node[data-grid-fill] [data-flow-icon-label]{gap:0}.flow-sdk-node[data-grid-fill] [data-flow-icon-caption]{position:absolute;bottom:12px;left:12px;width:calc(100% - 24px);max-height:40%;overflow:hidden}.flow-sdk-node[data-grid-fill] [data-flow-node-surface]>svg{max-width:45%;max-height:55%}.flow-sdk-node[data-grid-fill] p{font-size:var(--flow-grid-font);white-space:normal;overflow-wrap:anywhere}.flow-sdk-canvas[data-node-grid]:not([data-grid-connections]) .flow-sdk-property-port,.flow-sdk-canvas[data-node-grid]:not([data-grid-connections]) .flow-sdk-handle,.flow-sdk-canvas[data-node-grid] [data-flow-collapse-control]{display:none}.flow-sdk-node[data-grid-draggable] :not(button):not(input):not(textarea):not(select):not(a){cursor:inherit}"+zb+Vw+Dw+".flow-sdk-handle{position:absolute;left:-36px;top:50%;transform:translateY(-50%);width:36px;height:36px;display:grid;place-items:center;border:2px solid currentColor;border-radius:50%;background:white;cursor:crosshair;opacity:0;pointer-events:none}.flow-sdk-node:hover>.flow-sdk-handle,.flow-sdk-handle:focus-visible{opacity:1;pointer-events:auto}.flow-sdk-draw .flow-sdk-node *,.flow-sdk-draw .flow-sdk-edge *,.flow-sdk-draw .flow-sdk-container *,.flow-sdk-ghost *{pointer-events:none}",document.head.appendChild(e),e.textContent+=".flow-sdk-draw .flow-sdk-node{pointer-events:auto}.flow-sdk-draw .flow-sdk-node>.flow-sdk-handle{opacity:0;pointer-events:none}.flow-sdk-draw .flow-sdk-node:hover>.flow-sdk-handle,.flow-sdk-draw .flow-sdk-node>.flow-sdk-handle:focus-visible{opacity:1;pointer-events:auto}",e.textContent+='.flow-sdk-property-port{position:absolute;transform:translateY(-50%);width:32px;height:32px;margin:0;padding:0;border:3px solid currentColor;border-radius:50%;background:white;cursor:crosshair;pointer-events:auto;z-index:20}.flow-sdk-property-port[data-port-role="source"]{background:currentColor}.flow-sdk-property-port:hover{outline:3px solid currentColor;outline-offset:3px}.flow-sdk-draw .flow-sdk-node .flow-sdk-property-port{pointer-events:auto}',Rm=!0}function mE({loading:e=!1,loader:r,...t}){var c,l;const[n,o]=j.useState(null),i=j.useMemo(()=>!!(n!=null&&n.json)&&!!t.json&&Fw(n.json,t.json),[n==null?void 0:n.json,t.json]),s=n===null||n.json!==t.json&&!i,a=e||s;return j.useEffect(()=>{!e&&i&&(n==null?void 0:n.json)!==t.json&&o(t)},[e,i,n==null?void 0:n.json,t.json]),j.useEffect(()=>{if(e||!s)return;let d;const u=requestAnimationFrame(()=>{d=requestAnimationFrame(()=>o(t))});return()=>{cancelAnimationFrame(u),d!==void 0&&cancelAnimationFrame(d)}},[e,s,t.json]),f.jsxs(W.Box,{className:t.className,style:t.style,width:"100%",height:"100%",position:"relative","aria-busy":a,children:[f.jsx("div",{style:{width:"100%",height:"100%"},ref:d=>{var h;const u=(d==null?void 0:d.contains(document.activeElement))&&((h=document.activeElement)==null?void 0:h.matches("input, textarea, [contenteditable=true]"));a&&(e||!u)?d==null||d.setAttribute("inert",""):d==null||d.removeAttribute("inert")},children:n&&f.jsx(bE,{...s?n:t,children:t.children,config:t.config,className:void 0,style:void 0})}),a&&r!==null&&f.jsx(W.Box,{"data-flow-loader":"",role:"status","aria-label":"Loading diagram",position:"absolute",inset:0,zIndex:1e3,display:"grid",placeItems:"center",background:((c=t.config)==null?void 0:c.colorMode)==="dark"?"gray.800":"gray.100",color:((l=t.config)==null?void 0:l.colorMode)==="dark"?"whiteAlpha.800":"blackAlpha.800",children:r===void 0?f.jsx("span",{children:"Loading diagram..."}):r})]})}function bE({title:e="untitled",json:r,forms:t,nodes:n,edges:o,config:i={},callbacks:s={},className:a,style:c,showBottomBar:l=!0,children:d}){yE();const[u,h]=j.useState(),[p,m]=j.useState(!1),g=i.formSchema??u,y=j.useMemo(()=>r&&t?bb(r,t.state):r,[r,t==null?void 0:t.state]),b=i.direction==="C",x=j.useMemo(()=>{let E,M;return _=>(M=E&&M?zw(E,_,M)??md(_,{title:e,isCenter:b}):md(_,{title:e,isCenter:b}),E=_,M)},[e,b]),v=j.useMemo(()=>y?x(y):null,[y,x]),w=j.useMemo(()=>t!=null&&t.structured&&!p&&g?xb(t.state,t.bindings,g,(v==null?void 0:v.nodes)??n??[]):void 0,[t==null?void 0:t.structured,p,t==null?void 0:t.state,t==null?void 0:t.bindings,g,v,n]),C=(w==null?void 0:w.schema)??g,S=(w==null?void 0:w.bindings)??(t==null?void 0:t.bindings),R=j.useMemo(()=>[...(v==null?void 0:v.nodes)??n??[],...(w==null?void 0:w.nodes)??[]].map(M=>{var ee,ae,ne,oe;const _=r?(ee=Le(r,M.data.id))==null?void 0:ee.$view:(ae=M.data.config)==null?void 0:ae.typeView,O=_&&Ed.includes(_)?_:void 0,$=O?O==="icon-label":(ne=M.data.config)==null?void 0:ne.labelBelow,B=O==="object"?"objectView":O==="text"?"text":$?"arrayView":M.data.type,N=C&&(t?Fn(S,M.data.id,C):r&&on(r,M.data.id,C)),I=(((oe=M.data.config)==null?void 0:oe.ports)??[]).map(pe=>({...pe}));if(w&&N){const pe=i.direction==="RL"?{input:"right",output:"left",config:"bottom",error:"top"}:i.direction==="TB"?{input:"top",output:"bottom",config:"right",error:"left"}:i.direction==="BT"?{input:"bottom",output:"top",config:"left",error:"right"}:{input:"left",output:"right",config:"top",error:"bottom"};for(const[q,F]of Object.entries(N.type.ports??{})){const G=`${F.kind}:${q}`,D=I.find(ce=>ce.id===G);D?D.label===void 0&&F.label!==void 0&&(D.label=F.label):I.push({id:G,...F.label!==void 0?{label:F.label}:{},role:F.kind==="input"||F.kind==="config"?"target":"source",side:pe[F.kind],...F.kind==="config"?{placement:"config"}:{}})}for(const q of I){const F=I.filter(G=>G.side===q.side);q.position=(F.indexOf(q)+1)/(F.length+1)}}return N||$||O?{...M,data:{...M.data,type:B,...t?{description:Object.fromEntries(Object.entries(M.data.description??{}).filter(([pe])=>!pe.startsWith("$")&&!(w!=null&&w.slots.has(bn(M.data.id,pe)))))}:{},config:{...M.data.config,...w&&N?{ports:I}:{},...N?{form:!0}:{},...O?{typeView:O,labelBelow:!!$}:$?{labelBelow:!0}:{}}}}:M}),[v,n,r,C,S,w,i.direction]),P=j.useMemo(()=>[...(v==null?void 0:v.edges)??o??[],...(w==null?void 0:w.edges)??[]],[v==null?void 0:v.edges,o,w==null?void 0:w.edges]),k=j.useMemo(()=>{const E=r&&v?Fb(r,v.edges,s,s.onJsonChange,g):{...s};if(w){const M=new Set([...w.nodes.map(_=>_.data.id),...w.edges.map(_=>_.data.id)]);for(const _ of Object.keys(E)){if(!/^on(?:Node|Edge).*(?:Change|Collapse)$/.test(_))continue;const O=E[_];E[_]=($,...B)=>{if(!M.has($))return O==null?void 0:O($,...B)}}}return{...E,onAllNodesIconLabelChange:M=>{var _;m(M),(_=E.onAllNodesIconLabelChange)==null||_.call(E,M)}}},[r,v,s,g,w]),T=j.useMemo(()=>{if(!t)return k;let E=t.state;const M=O=>{if(i.readOnly||i.editable===!1)return;const $=t.onStateChange??t.onChange;if(!$)return;const B=Rw(E,O,s.onFormChange);B!==E&&(E=B,$(B,{...O,data:B}))},_=(O,$,B)=>{var I;const N=r&&((I=Le(r,O))==null?void 0:I[$]);return!N||typeof N.$state!="string"?!1:(M({address:N.$state,nodeAddress:O,previousValue:Le(E,N.$state),value:B,data:E}),!0)};return{...k,onFormChange:M,onNodeCreateRequest:O=>{var N,I;const $=(N=O.sourceProperty)!=null&&N.startsWith("config:")?O.sourceProperty.slice(7):void 0,B=$!==void 0&&(w==null?void 0:w.slots.get(bn(O.sourceNodeId,$)));return B?(B.present||M({data:E,nodeAddress:B.address.split(".").slice(0,-1).join("."),address:B.address,value:xn(B.type),previousValue:void 0}),!0):((I=k.onNodeCreateRequest)==null?void 0:I.call(k,O))??!1},onNodeDelete:(O,$)=>{var ne,oe;if(!(w!=null&&w.nodes.some(pe=>pe.data.id===O)))return(ne=k.onNodeDelete)==null?void 0:ne.call(k,O,$);const B=w&&[...w.slots.values()].find(pe=>pe.nodeId===O);if(!B)return(oe=k.onNodeDelete)==null?void 0:oe.call(k,O,$);const N=B.address.split("."),I=N.pop(),ee=N.join("."),ae=Le(E,ee);M(Array.isArray(ae)?{data:E,nodeAddress:ee,address:ee,previousValue:ae,value:ae.filter((pe,q)=>String(q)!==I)}:{data:E,nodeAddress:ee,address:B.address,previousValue:Le(E,B.address),value:void 0})},onEdgeCreate:(O,$,B)=>{var ee,ae;const N=((ee=B==null?void 0:B.targetProperty)==null?void 0:ee.startsWith("config:"))&&(w==null?void 0:w.slots.get(bn($,B.targetProperty.slice(7)))),I=w==null?void 0:w.containers.get(O);if(N&&I&&(B==null?void 0:B.sourceProperty)==="output:resource"){const ne=Pw(E,I,N);ne!==void 0&&M({data:E,nodeAddress:N.address.split(".").slice(0,-1).join("."),address:N.address,previousValue:Le(E,N.address),value:ne});return}N||w!=null&&w.nodes.some(ne=>ne.data.id===O||ne.data.id===$)||(ae=k.onEdgeCreate)==null||ae.call(k,O,$,B)},onEdgeDelete:(O,$)=>{var oe;const B=w==null?void 0:w.edges.find(pe=>pe.data.id===O);if(!B)return(oe=k.onEdgeDelete)==null?void 0:oe.call(k,O,$);const N=w.slots.get(bn(B.data.target,B.data.targetProperty.slice(7))),I=N.address.split("."),ee=I.pop(),ae=I.join("."),ne=Le(E,ae);M(Array.isArray(ne)?{data:E,nodeAddress:ae,address:ae,previousValue:ne,value:ne.filter((pe,q)=>String(q)!==ee)}:{data:E,nodeAddress:ae,address:N.address,previousValue:Le(E,N.address),value:void 0})},onNodeContentChange:(O,$)=>{var B,N;_(O,"$content",$)?(B=s.onNodeContentChange)==null||B.call(s,O,$):(N=k.onNodeContentChange)==null||N.call(k,O,$)},onNodeLabelChange:(O,$)=>{var B,N;_(O,"$label",$)?(B=s.onNodeLabelChange)==null||B.call(s,O,$):(N=k.onNodeLabelChange)==null||N.call(k,O,$)}}},[k,t,r,s,w,i.readOnly,i.editable]);return f.jsx(Tt.Provider,{value:{data:(t==null?void 0:t.state)??r,viewData:r,bindings:S,references:t==null?void 0:t.references,structured:w,renderForm:t==null?void 0:t.renderForm,editable:t?!!(t.onStateChange??t.onChange):!!s.onJsonChange,schema:C,setSchema:E=>{var M;h(E),(M=s.onFormSchemaChange)==null||M.call(s,E)},callbacks:T},children:f.jsx(Nm,{config:w?{...i,formSchema:C}:i,callbacks:T,nodes:R,edges:P,children:f.jsxs(W.Box,{className:a,"data-flow-diagram":"","data-animations-disabled":i.disableAnimations||void 0,style:c,width:"100%",height:"100%",position:"relative",overflow:"hidden",css:{"&[data-animations-disabled], &[data-animations-disabled] *, &[data-animations-disabled] *::before, &[data-animations-disabled] *::after":{animation:"none !important",transition:"none !important"},"& input, & textarea, & select":{outline:"none !important",boxShadow:"none !important"}},children:[f.jsx(lv,{nodes:R,edges:P}),l&&f.jsx(Tb,{}),d]})})})}function xE(e){return jd(JSON.parse(e))}function jd(e){if(!e||typeof e!="object")throw new Error("Expected a JSON object or array.");const r=new Set,t=n=>{if(!(n===null||typeof n=="string"||typeof n=="boolean")&&!(typeof n=="number"&&Number.isFinite(n))){if(!n||typeof n!="object"||r.has(n)||!Array.isArray(n)&&![Object.prototype,null].includes(Object.getPrototypeOf(n)))throw new Error("Document must contain only finite, acyclic JSON values.");r.add(n);for(const[o,i]of Object.entries(n)){if(["__proto__","prototype","constructor"].includes(o))throw new Error(`Unsafe document key: ${o}`);t(i)}r.delete(n)}};return t(e),structuredClone(e)}function vE(e){return{replaceJson(r){if(e.readOnly||!e.onJsonChange)throw new Error("JSON document is read-only.");const t=jd(r);return e.onJsonChange(t,{type:"documentReplace",address:"root"}),t},replaceState(r){if(e.readOnly||!e.onStateChange)throw new Error("Form state is read-only.");const t=jd(r);return e.onStateChange(t,{address:"root",nodeAddress:"root",previousValue:e.state,value:t,data:t}),t}}}function wE(e,r){const t=(n,o)=>{if(n===null||typeof n!="object")return typeof n==typeof o?n:void 0;if(!(!o||typeof o!="object"))return Array.isArray(n)?Array.isArray(o)?n.map((i,s)=>t(i,o[s])).filter(i=>i!==void 0):void 0:Object.fromEntries(Object.entries(n).flatMap(([i,s])=>{if(!Object.prototype.hasOwnProperty.call(o,i))return[];if(i==="$content"&&n.$contentFormat==="jsx"&&o.$contentFormat==="jsx"&&Array.isArray(s)&&Array.isArray(o[i]))return[[i,s.filter((c,l)=>JSON.stringify(c)===JSON.stringify(o[i][l]))]];if(i.startsWith("$")&&i!=="$")return JSON.stringify(s)===JSON.stringify(o[i])?[[i,s]]:[];const a=t(s,o[i]);return a===void 0?[]:[[i,a]]}))};return t(e,r)??{}}function no(e){let r="",t=!1,n="",o;const i=()=>{clearTimeout(o),o=void 0},s=()=>{if(i(),!(t||!r.trim()))try{const c=e.parse(e.repair(r)),l=JSON.stringify(c);if(l===n)return;e.preview(c),n=l}catch{}},a=c=>{if(!t){if(new TextEncoder().encode(c).byteLength>(e.maxBytes??1024*1024))throw t=!0,i(),new Error("JSON stream exceeds the size limit.");r=c,o||(o=setTimeout(s,e.intervalMs??150))}};return{snapshot:a,append(c){a(r+c)},flush:s,finish(){if(t)throw new Error("JSON stream is closed.");t=!0,i();const c=e.parse(r);return e.commit(c),c},cancel(){t=!0,i(),r=""}}}function CE(e){const{source:r}=e,t=e.tickMs??50,n=e.durationMs??8e3;if(!Number.isFinite(t)||t<=0||!Number.isFinite(n)||n<=0)throw new Error("Playback timing must be positive.");if(new TextEncoder().encode(r).byteLength>(e.maxBytes??1024*1024))throw new Error("JSON stream exceeds the size limit.");e.parse(r);let o=no(e),i=0,s=!1,a=!1,c;const l=Math.max(1,Math.ceil(r.length*t/n)),d=()=>e.onChange({position:i,total:r.length,playing:s}),u=()=>{clearTimeout(c),c=void 0},h=(g=!1)=>{o.snapshot(r.slice(0,i)),i===r.length?(s=!1,u(),o.finish()):g&&o.flush()},p=g=>{s=!1,u(),o.cancel(),d(),e.onError(g)},m=()=>{if(c=void 0,!(!s||a)){i=Math.min(r.length,i+l);try{h()}catch(g){p(g);return}d(),s&&(c=setTimeout(m,t))}};return{play(){a||s||(i===r.length&&(o.cancel(),o=no(e),i=0),s=!0,d(),c=setTimeout(m,t))},pause(){a||(s=!1,u(),o.flush(),d())},seek(g){if(!a){if(!Number.isFinite(g))throw new Error("Playback position must be finite.");u(),i=Math.max(0,Math.min(r.length,Math.round(g))),o.cancel(),o=no(e);try{h(!0)}catch(y){p(y);return}d(),s&&(c=setTimeout(m,t))}},dispose(){a=!0,s=!1,u(),o.cancel()}}}function SE({nodeAddress:e,expanded:r=!1}){var l;const{data:t,schema:n,bindings:o}=j.useContext(Tt),{colorText:i,background:s}=lt();if((l=o==null?void 0:o[e])!=null&&l.portResources)return null;const a=o&&Fn(o,e,n);if(!t||!a)return null;const c=Le(t,a.address);return!c||typeof c!="object"?null:f.jsx("div",{"data-flow-config-summary":"",style:{width:"100%",minWidth:0,color:Me(i),background:Me(s),fontSize:24,lineHeight:1.4,textTransform:"none"},children:Object.keys(a.type.properties).map(d=>{const u=a.fields[d]??{};if(!bo(u.$visibleWhen,t))return null;const h=c[d],p=h==null?"":typeof h=="object"?JSON.stringify(h):String(h);return f.jsxs("div",{"data-flow-property":d,style:{display:"grid",gridTemplateColumns:"minmax(0, 1fr) minmax(0, 1fr)",gap:12,padding:"10px 16px",borderTop:"1px solid color-mix(in srgb, currentColor 12%, transparent)"},children:[f.jsx("span",{style:{overflowWrap:"anywhere"},children:Ft(u.$label??d)}),f.jsx("span",{title:p,style:{overflow:"hidden",textOverflow:"ellipsis",whiteSpace:r?"pre-wrap":"nowrap",overflowWrap:r?"anywhere":void 0},children:p})]},d)})})}exports.BottomBar=Tb;exports.CollapseAllToggle=ob;exports.CompactPropertyLayoutToggle=ib;exports.ConnectionsOnlyToggle=Lw;exports.ContentFullscreenButton=nv;exports.DEFAULT_PALETTE=ao;exports.DiagramAppearanceControls=ab;exports.DynamicIcon=or;exports.EdgeTools=Eb;exports.EditableLabel=tn;exports.ErrorToast=Mb;exports.FlowDiagram=mE;exports.FlowDiagramProvider=Nm;exports.FlowPort=tv;exports.FlowView=lv;exports.FormDocumentContext=Tt;exports.GridAdjustmentToggle=sb;exports.LIGHT_BLACK=rn;exports.LoadingBorder=rv;exports.NODE_TYPE_VIEWS=Ed;exports.NodeBorderRadiusControl=_b;exports.NodeConfigSummary=SE;exports.NodeForm=Ld;exports.NodeFormPopover=du;exports.NodeGridControls=to;exports.NodeIconPicker=Fd;exports.NodeTools=Rb;exports.NodeView=Un;exports.PanelDragHandle=nb;exports.SvgExportButton=Pb;exports.Swatches=Lr;exports.TEXT_PALETTE=Sb;exports.ToolbarCloseButton=nn;exports.ToolbarCommitInput=qr;exports.ToolbarDivider=Sn;exports.ToolbarIconButton=Ne;exports.ToolbarRangeInput=Rd;exports.ToolbarScrollContainer=vo;exports.ToolbarSelect=Mt;exports.ToolbarTooltip=He;exports.TooltipIconButton=Sd;exports.WorkflowControls=zd;exports.addChild=Id;exports.addConnection=Td;exports.addTargetEdge=pb;exports.addressToPath=Gt;exports.applyCollapsed=jw;exports.applyFormChange=xo;exports.applyStateEdits=_w;exports.bindSqueedCallbacks=Fb;exports.compileSqueed=md;exports.connectionIssue=$d;exports.contentObjTheme=nr;exports.copySelection=Bd;exports.createFlowDiagram=$r;exports.createFlowDocumentActions=vE;exports.createFormNode=Ob;exports.createJsonPlayback=CE;exports.createJsonStream=no;exports.createWorkflowExecution=kv;exports.downloadSvg=Ab;exports.duplicateSelection=Lb;exports.exportSvg=kb;exports.formValueError=Ut;exports.getChakraColorHex=Me;exports.getColorVariant=Pm;exports.getDarkerHexColor=oo;exports.getInteractionSurface=xr;exports.getNode=Le;exports.getSelectionRoots=qb;exports.isNodeVisible=rr;exports.parseFlowDocument=xE;exports.parseJsonContract=Nd;exports.parseTypeScriptContract=yb;exports.parseTypeScriptForm=Od;exports.projectJsonPlaybackPreview=wE;exports.readFormSchema=qd;exports.readWorkflowContract=mb;exports.removeEdge=gb;exports.removeNode=hb;exports.reparentNode=$b;exports.resolveEdgeOwner=Nr;exports.resolveStateView=bb;exports.setCollapsed=Md;exports.setEdgeProp=gr;exports.setEdgeStyle=fb;exports.setNodeProp=xt;exports.updateNode=_t;exports.useCustomColors=lt;exports.useEdgeProximity=ho;exports.useFlowData=Kt;exports.useFlowDiagramContext=Ze;exports.useNodeViewActions=Hn;exports.useStopPropagation=lu;exports.useThemeContentColors=Ln;exports.validateGridAdjustment=Xx;
|
|
284
284
|
//# sourceMappingURL=index.cjs.map
|